Un terminal pouvait rester tout noir alors que sa session tournait. Le PTY était vivant et avait bien écrit sa sortie : la panne était dans le transport. Le replay d'attache est une frame BINAIRE, mais un client n'apprend son numéro de canal qu'avec le message `attached` ; le serveur envoyait le replay AVANT, donc tout client le jetait sur un canal inconnu. Rien n'était peint, et un TUI au repos (Claude à son prompt) ne réémet jamais rien de lui-même. `attach()` renvoie désormais le replay et la gateway l'émet APRÈS `attached` : un seul correctif serveur répare le web, l'app de bureau et l'extension VS Code, qui portaient le même défaut client. Le resize de l'attache masquait le bug en provoquant un SIGWINCH, d'où son apparence intermittente. Seconde moitié du symptôme (« je tape et rien ne se passe ») : le dock montait avant la liste des sessions, en déduisait « non attachable » et s'attachait en observateur, à vie et en silence. Un pane n'attache plus avant de connaître sa session (`sessions.loaded`). Attaches sans écran : le message `attach` accepte un `screen` optionnel (défaut true). Un client qui n'affiche rien et veut seulement répondre à un dialogue ne prend plus le contrôle de la session, ne lui impose plus ses dimensions (ce qui figeait la géométrie du vrai terminal) et ne reçoit plus le flux pour le jeter. Rendre les pannes visibles : la raison d'un exit est écrite dans le terminal (`[arboretum] bash exited with code 3`) avant le détachement ; un repaint est forcé si rien n'arrive 1,2 s après l'attache, puis annoncé avec « Refresh screen » ; les refus de canal remontent à l'écran au lieu d'un console.warn ; le chemin du CLI claude est revalidé (périmé après une bascule nvm/asdf, le PTY mourait sans un octet). Colonnes de terminaux : le dock devient une rangée de colonnes redimensionnables (3 max), chacune avec ses onglets. Algèbre pure dans lib/dock-model.ts, cinq invariants documentés, ratios plutôt que pixels. `dockSessionIds` et `activeDockSessionId` deviennent des computed dérivés : aucun consommateur ni test existant ne change. Alt+clic ouvre à côté depuis les quatre panneaux. Le plafond de hauteur du dock suit le viewport au lieu d'un 640 px figé. Correctif préexistant au passage : PanelSplitter passait ses bornes par valeur, figées au premier rendu, alors que le clavier les relisait. Portée git : la vue Changements suit le worktree du terminal focalisé, ou tous les dépôts de son groupe pour une session de groupe, avec « tout voir » à un clic. L'index Git de la sidebar reste global (c'est la sortie d'une portée étroite) et le badge d'activité aussi (il sert à signaler le travail qu'on ne regarde pas). Seul le TERMINAL impose le contexte : le repli sur l'onglet éditeur, essayé d'abord, rétrécissait la vue multi-projet dès qu'on ouvrait un fichier. Vérifications : acceptance-p17.mjs prouve l'ordre des trames sur un vrai WebSocket (avec l'ancien ordre : 0 octet rejoué, échec), verify-terminals.mjs prouve par interaction réelle que le terminal peint, que deux colonnes coexistent, que la frappe atteint le bon PTY (fichier témoin par cwd) et que la vue suit le terminal.
194 lines
8.5 KiB
Vue
194 lines
8.5 KiB
Vue
<template>
|
|
<Teleport to="body">
|
|
<div v-if="open" class="fixed inset-0 z-[60] flex items-start justify-center p-4 pt-[10vh]" role="dialog" aria-modal="true">
|
|
<div class="absolute inset-0 bg-black/60" @click="close" />
|
|
<div class="relative flex max-h-[70vh] w-full max-w-lg flex-col overflow-hidden rounded-xl border border-border-strong bg-surface-1 shadow-pop">
|
|
<div class="flex items-center gap-2 border-b border-border px-3">
|
|
<Search :size="16" class="text-fg-subtle" />
|
|
<input
|
|
ref="inputEl"
|
|
v-model="query"
|
|
type="text"
|
|
class="w-full bg-transparent py-3 text-sm text-fg outline-none placeholder:text-fg-subtle"
|
|
:placeholder="t('palette.placeholder')"
|
|
:aria-activedescendant="activeId ? `cmd-${activeId}` : undefined"
|
|
role="combobox"
|
|
aria-controls="cmd-listbox"
|
|
aria-expanded="true"
|
|
@keydown.down.prevent="move(1)"
|
|
@keydown.up.prevent="move(-1)"
|
|
@keydown.enter.prevent="run(results[activeIndex])"
|
|
@keydown.esc.prevent="close"
|
|
/>
|
|
</div>
|
|
|
|
<ul v-if="results.length" id="cmd-listbox" role="listbox" class="min-h-0 flex-1 overflow-y-auto p-1.5">
|
|
<li
|
|
v-for="(item, i) in results"
|
|
:id="`cmd-${item.id}`"
|
|
:key="item.id"
|
|
role="option"
|
|
:aria-selected="i === activeIndex"
|
|
class="flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-2"
|
|
:class="i === activeIndex ? 'bg-surface-2' : 'hover:bg-surface-2/50'"
|
|
@mousemove="activeIndex = i"
|
|
@click="run(item)"
|
|
>
|
|
<component :is="item.icon" :size="15" class="shrink-0 text-fg-subtle" />
|
|
<span class="min-w-0 flex-1">
|
|
<span class="block truncate text-sm text-fg">{{ item.label }}</span>
|
|
<span v-if="item.sublabel" class="block truncate font-mono text-[11px] text-fg-subtle">{{ item.sublabel }}</span>
|
|
</span>
|
|
<span class="shrink-0 text-[10px] uppercase tracking-wide text-fg-subtle">{{ t(`palette.types.${item.type}`) }}</span>
|
|
</li>
|
|
</ul>
|
|
<p v-else class="px-3 py-6 text-center text-sm text-fg-subtle">{{ t('palette.empty') }}</p>
|
|
|
|
<div class="border-t border-border px-3 py-1.5 text-[11px] text-fg-subtle">{{ t('palette.hint') }}</div>
|
|
</div>
|
|
</div>
|
|
</Teleport>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed, nextTick, onMounted, onUnmounted, ref, watch, type Component } from 'vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { Search, GitBranch, TerminalSquare, Boxes, Plus, FolderPlus, Rocket, SquareSplitHorizontal } from '@lucide/vue';
|
|
import type { WorktreeSummary } from '@arboretum/shared';
|
|
import { useSessionsStore } from '../stores/sessions';
|
|
import { useWorktreesStore } from '../stores/worktrees';
|
|
import { useGroupsStore } from '../stores/groups';
|
|
import { useIdeStore } from '../stores/ide';
|
|
import { useModalsStore } from '../stores/modals';
|
|
import { useCommandPalette } from '../composables/useCommandPalette';
|
|
import NewSessionModal from './ide/modals/NewSessionModal.vue';
|
|
import GroupCreateModal from './ide/modals/GroupCreateModal.vue';
|
|
import LaunchProjectModal from './ide/modals/LaunchProjectModal.vue';
|
|
|
|
interface PaletteItem {
|
|
id: string;
|
|
type: 'repo' | 'worktree' | 'session' | 'group' | 'action';
|
|
label: string;
|
|
sublabel?: string;
|
|
icon: Component;
|
|
keywords: string;
|
|
run: () => void;
|
|
}
|
|
|
|
const { t } = useI18n();
|
|
const { open, close, toggle } = useCommandPalette();
|
|
const sessions = useSessionsStore();
|
|
const worktrees = useWorktreesStore();
|
|
const groups = useGroupsStore();
|
|
const ide = useIdeStore();
|
|
const modals = useModalsStore();
|
|
|
|
// Toutes les actions restent DANS l'IDE (aucune navigation vers l'ancien monde).
|
|
function revealRepo(id: string): void {
|
|
ide.setActivity('explorer');
|
|
if (!ide.expandedRepoIds.includes(id)) ide.toggleRepo(id);
|
|
}
|
|
function revealWorktree(w: WorktreeSummary): void {
|
|
ide.revealWorktree(w.repoId, w.path);
|
|
const live = sessions.sessions.find((s) => s.live && s.cwd === w.path);
|
|
if (live) ide.openTerminal(live.id);
|
|
}
|
|
|
|
const query = ref('');
|
|
const activeIndex = ref(0);
|
|
const inputEl = ref<HTMLInputElement | null>(null);
|
|
|
|
const basename = (p: string): string => p.split('/').filter(Boolean).pop() ?? p;
|
|
|
|
const items = computed<PaletteItem[]>(() => {
|
|
const out: PaletteItem[] = [];
|
|
for (const r of worktrees.visibleRepos) {
|
|
out.push({ id: `repo-${r.id}`, type: 'repo', label: r.label, sublabel: r.path, icon: GitBranch as Component, keywords: `${r.label} ${r.path}`.toLowerCase(), run: () => revealRepo(r.id) });
|
|
out.push({
|
|
id: `launch-${r.id}`,
|
|
type: 'action',
|
|
label: t('launch.startNamed', { name: r.label }),
|
|
icon: Rocket as Component,
|
|
keywords: `${t('launch.startProject')} ${r.label}`.toLowerCase(),
|
|
run: () => void modals.open(LaunchProjectModal, { repoId: r.id }),
|
|
});
|
|
}
|
|
for (const w of worktrees.worktrees) {
|
|
out.push({ id: `wt-${w.path}`, type: 'worktree', label: w.branch ?? basename(w.path), sublabel: w.path, icon: GitBranch as Component, keywords: `${w.branch ?? ''} ${w.path}`.toLowerCase(), run: () => revealWorktree(w) });
|
|
}
|
|
for (const s of sessions.sessions) {
|
|
out.push({ id: `ses-${s.id}`, type: 'session', label: s.title ?? basename(s.cwd), sublabel: s.cwd, icon: TerminalSquare as Component, keywords: `${s.title ?? ''} ${s.cwd} ${s.command}`.toLowerCase(), run: () => ide.openTerminal(s.id) });
|
|
}
|
|
for (const g of groups.groups) {
|
|
out.push({ id: `grp-${g.id}`, type: 'group', label: g.label, ...(g.description ? { sublabel: g.description } : {}), icon: Boxes as Component, keywords: `${g.label} ${g.description ?? ''}`.toLowerCase(), run: () => ide.setActivity('groups') });
|
|
}
|
|
// actions globales : ouvrent des modals / panneaux DANS l'IDE.
|
|
out.push({ id: 'act-newSession', type: 'action', label: t('palette.actions.newSession'), icon: Plus as Component, keywords: t('palette.actions.newSession').toLowerCase(), run: () => void modals.open(NewSessionModal) });
|
|
out.push({ id: 'act-addRepo', type: 'action', label: t('palette.actions.addRepo'), icon: FolderPlus as Component, keywords: t('palette.actions.addRepo').toLowerCase(), run: () => ide.setActivity('explorer') });
|
|
out.push({ id: 'act-newGroup', type: 'action', label: t('palette.actions.newGroup'), icon: Boxes as Component, keywords: t('palette.actions.newGroup').toLowerCase(), run: () => void modals.open(GroupCreateModal) });
|
|
// Une SEULE entrée pour le split (et non une par session : la palette doublerait de taille).
|
|
if (ide.canSplitTerminal) {
|
|
out.push({ id: 'act-splitTerminal', type: 'action', label: t('palette.actions.splitTerminal'), icon: SquareSplitHorizontal as Component, keywords: t('palette.actions.splitTerminal').toLowerCase(), run: () => ide.splitTerminal() });
|
|
}
|
|
return out;
|
|
});
|
|
|
|
// fuzzy minimal : tous les tokens présents (AND), score = somme des positions (plus tôt = mieux).
|
|
const results = computed<PaletteItem[]>(() => {
|
|
const tokens = query.value.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
if (tokens.length === 0) return items.value.slice(0, 30);
|
|
const scored: { item: PaletteItem; score: number }[] = [];
|
|
for (const item of items.value) {
|
|
let score = 0;
|
|
let ok = true;
|
|
for (const tok of tokens) {
|
|
const idx = item.keywords.indexOf(tok);
|
|
if (idx < 0) {
|
|
ok = false;
|
|
break;
|
|
}
|
|
score += idx;
|
|
}
|
|
if (ok) scored.push({ item, score });
|
|
}
|
|
return scored.sort((a, b) => a.score - b.score).slice(0, 30).map((s) => s.item);
|
|
});
|
|
|
|
watch(results, () => {
|
|
if (activeIndex.value >= results.value.length) activeIndex.value = 0;
|
|
});
|
|
|
|
const activeId = computed(() => results.value[activeIndex.value]?.id);
|
|
|
|
function move(delta: number): void {
|
|
const n = results.value.length;
|
|
if (n === 0) return;
|
|
activeIndex.value = (activeIndex.value + delta + n) % n;
|
|
}
|
|
|
|
function run(item: PaletteItem | undefined): void {
|
|
if (!item) return;
|
|
close();
|
|
item.run();
|
|
}
|
|
|
|
watch(open, async (v) => {
|
|
if (v) {
|
|
query.value = '';
|
|
activeIndex.value = 0;
|
|
await nextTick();
|
|
inputEl.value?.focus();
|
|
}
|
|
});
|
|
|
|
// raccourci global ⌘K / Ctrl+K : en phase de capture pour passer devant xterm (SessionView).
|
|
function onKey(e: KeyboardEvent): void {
|
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'k') {
|
|
e.preventDefault();
|
|
toggle();
|
|
}
|
|
}
|
|
onMounted(() => window.addEventListener('keydown', onKey, { capture: true }));
|
|
onUnmounted(() => window.removeEventListener('keydown', onKey, { capture: true }));
|
|
</script>
|