an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions
HTML agent-harnessagent-orchestrationagentsai-agentsautonomous-agentsclaude-codecodexcoding-agentsdesktop-appdeveloper-toolselectrongemini-cliharnessharness-engineeringlocal-firstmemorymulti-agentopencodeorchestrationtypescript
feat(fullscreen): agent roster rail with repo grouping and ambient notes
Vyapak Goyalaabf62f8bdb3
diff --git a/src/main/git.ts b/src/main/git.tsindex 8dd229e5..48826f34 100644--- a/src/main/git.ts+++ b/src/main/git.ts@@ -142,6 +142,25 @@ export async function isRepo(cwd: string): Promise<boolean> {return res.ok && res.stdout.trim() === 'true';}+/** The MAIN working tree of the repository `cwd` belongs to.+ *+ * For a normal checkout that's just the repo root. For a linked worktree it is+ * the original repo, NOT the worktree directory — an isolated agent's cwd is+ * `<harnessHome>/worktrees/<agent-id>`, whose basename is the agent id and says+ * nothing about which project it's working on. `--git-common-dir` resolves to+ * the shared `.git` of the main checkout from anywhere in the worktree family.+ * Returns null when `cwd` isn't a git repo (or git is unavailable). */+export async function mainRepoRoot(cwd: string): Promise<string | null> {+ const res = await runGit(cwd, ['rev-parse', '--path-format=absolute', '--git-common-dir']);+ if (!res.ok) return null;+ const gitDir = res.stdout.trim();+ if (!gitDir) return null;+ // `<repo>/.git` → `<repo>`. A bare repo has no working tree to name, so its+ // own path is the best answer we have.+ const stripped = gitDir.replace(/[\\/]\.git[\\/]?$/, '');+ return stripped || gitDir;+}+/** Derive a safe `agent/<id>` branch name from a worktree path's basename. */function agentBranchFor(wtPath: string): string {const base = wtPath.split(/[\\/]/).filter(Boolean).pop() ?? 'agent';diff --git a/src/main/index.ts b/src/main/index.tsindex 3cac3f47..36eac6eb 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -7,7 +7,6 @@ import {} from 'node:fs';import { randomBytes, createHash, timingSafeEqual } from 'node:crypto';import { join, resolve, sep, basename, dirname } from 'node:path';-import { tmpdir } from 'node:os';import { request as httpsRequest } from 'node:https';import { PtyManager, type SpawnOptions } from './pty';import { enableOpsStandupAutoCompact } from '../shared/autoCompact';@@ -17,7 +16,7 @@ import {} from './config';import { listDir, readFileText, writeFileText } from './fs';import {- getBranch, getStatus, getLog, getBranches, getAheadBehind, isRepo,+ getBranch, getStatus, getLog, getBranches, getAheadBehind, isRepo, mainRepoRoot,addWorktree, removeWorktree} from './git';import { HiveManager, type AgentMeta, type HiveMessage, type HiveTask } from './hive';@@ -47,6 +46,7 @@ import {CODEX_REMOTE_SOCKET_RELATIVE,codexRemoteAliasPath,codexRemoteEndpoint,+ codexRemoteSocketFits,withCodexRemoteArgs} from '../shared/codexRemote';@@ -120,7 +120,14 @@ async function enableCodexRemoteForSpawn(const realHome = opts.env?.CODEX_HOME;if (!realHome) return false;try {- const alias = codexRemoteAliasPath(realHome, agentId, tmpdir());+ const alias = codexRemoteAliasPath(realHome, agentId);+ // Bail before touching the filesystem if even the short alias would exceed+ // sun_path — the daemon would start and then die on bind, and the warning+ // below names the real reason instead of a generic readiness timeout.+ if (!codexRemoteSocketFits(alias)) {+ console.warn('[codex-remote] socket path exceeds sun_path; starting local TUI:', alias);+ return false;+ }const aliasRoot = dirname(alias);mkdirSync(aliasRoot, { recursive: true });if (existsSync(alias)) {@@ -1926,6 +1933,13 @@ ipcMain.handle('git:isRepo', (_evt, cwd: unknown) => {if (typeof cwd !== 'string') return false;return isRepo(cwd);});++// The repo a cwd belongs to, following a linked worktree back to its main+// checkout — the renderer groups the agent roster by this.+ipcMain.handle('git:mainRepo', (_evt, cwd: unknown) => {+ if (typeof cwd !== 'string' || !cwd) return null;+ return mainRepoRoot(cwd);+});ipcMain.handle('git:branch', (_evt, cwd: unknown) => {if (typeof cwd !== 'string') return { error: 'invalid cwd' };return getBranch(cwd);diff --git a/src/preload/index.ts b/src/preload/index.tsindex 9e48d978..ff832f6a 100644--- a/src/preload/index.ts+++ b/src/preload/index.ts@@ -453,6 +453,9 @@ const api = {// ─── Git ─────────────────────────────────────────────────────────────────gitIsRepo: (cwd: string): Promise<boolean> => ipcRenderer.invoke('git:isRepo', cwd),+ /** Absolute path of the MAIN working tree `cwd` belongs to — a linked worktree+ * resolves to the original repo, not to itself. null when not a git repo. */+ gitMainRepo: (cwd: string): Promise<string | null> => ipcRenderer.invoke('git:mainRepo', cwd),gitBranch: (cwd: string) =>ipcRenderer.invoke('git:branch', cwd) as Promise<{ current: string | null; detached: boolean } | { error: string }>,gitStatus: (cwd: string) =>diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsxindex f16eb894..f61aef47 100644--- a/src/renderer/src/App.tsx+++ b/src/renderer/src/App.tsx@@ -303,7 +303,7 @@ export function App() {/>)}- {fullscreenAgentId && <FullscreenTerminal />}+ {fullscreenAgentId && <FullscreenTerminal config={config} />}{fullscreenFilePath && <FullscreenFileEditor />}<TaskDetailOverlay /></div>diff --git a/src/renderer/src/components/AgentStrip.tsx b/src/renderer/src/components/AgentStrip.tsxindex fdc6b5dd..26b70cab 100644--- a/src/renderer/src/components/AgentStrip.tsx+++ b/src/renderer/src/components/AgentStrip.tsx@@ -5,6 +5,7 @@ import { Icon } from './Icon';import { useStore, type Agent } from '@/store/store';import { buildSpawnCommand, inferAgentProvider, tokenizeCommand, type HarnessConfig } from '@/store/config';import { OFFICE_CAST, DEFAULT_CHARACTER } from '@/scene/office/cast';+import { useRestoreTeam } from '@/hooks/useRestoreTeam';export interface AgentStripProps {/** Needed to rebuild a spawn command when a restorable agent predates the@@ -21,8 +22,8 @@ export function AgentStrip({ config }: AgentStripProps) {const openTaskDetail = useStore(s => s.openTaskDetail);const reorderAgents = useStore(s => s.reorderAgents);const setAgentNote = useStore(s => s.setAgentNote);- const [restoring, setRestoring] = useState(false);- const [restoreNote, setRestoreNote] = useState<string | null>(null);+ // Shared with the fullscreen roster so both show one restore in progress.+ const { restoring, restoreNote, restoreTeam } = useRestoreTeam(config);// Drag-to-reorder the roster: dragId = the card being dragged, overId = the card// currently hovered as a drop target (drives the insertion-line cue).const [dragId, setDragId] = useState<string | null>(null);@@ -112,131 +113,6 @@ export function AgentStrip({ config }: AgentStripProps) {return () => { cancelled = true; };}, []);- /** Respawn every worker from the previous session with its ORIGINAL agent id,- * cwd, model and command — the hive workspace (memory.md, inbox, registry- * entry) reattaches by itself, no memory transplant needed. */- const restoreTeam = async () => {- if (restoring) return;- setRestoring(true);- setRestoreNote(null);- const prevSel = useStore.getState().selectedId;- // Tally every agent's outcome so the loop ALWAYS leaves a visible trace — the- // original bug was that every failure path was console-only, so a click that- // couldn't spawn anything looked like a dead button.- let restored = 0;- let alreadyLive = 0;- const failures: string[] = [];- try {- // Restore every agent CONCURRENTLY. Each spawn is keyed by its own ptyId and- // touches no cross-agent state in the renderer, and in the main process the- // whole `pty:spawn` handler (hive registry read-modify-write included) runs- // synchronously between awaits, so concurrent handlers can't interleave- // mid-update. Serially this cost the sum of every agent's git probe + spawn;- // a 6-agent team took ~6× one agent for no reason.- await Promise.all([...restorableAgents].map(async (a) => {- // Per-agent guard: one agent's failure (or a rejected IPC call) must NEVER- // abort the others — an unhandled rejection here used to make the- // entire restore a silent no-op after the first bad agent.- try {- const provider = inferAgentProvider(a.command, a.provider);- const command = (a.command ?? '').trim() || (config ? buildSpawnCommand(config, a.model, provider) : '');- if (!command || !a.cwd) {- // No spawn recipe (an old entry persisted before `command`, with no- // config to rebuild one). Keep it restorable and SAY why rather than- // silently dropping it — silent removal read as "nothing happened".- failures.push(`${a.name}: no saved command`);- return;- }- const [exe, ...args] = tokenizeCommand(command);- const ptyId = a.ptyId ?? `pty-${a.id}`;- // An isolated agent's worktree SURVIVES an app restart on disk (it's only- // torn down on per-tab close / mid-session exit, not on quit). So re-enter- // that exact worktree as the cwd rather than re-isolating — `git worktree- // add` would conflict with the existing path/branch, and re-isolating would- // also lose the worktree's uncommitted work. cwd = the worktree means- // resume + seedSessionTranscript land in the CORRECT checkout.- // But the user may have manually pruned/deleted the worktree between runs —- // gitIsRepo (git rev-parse) returns false for a missing/invalid dir, so- // fall back to the base repo cwd rather than spawning into a dead path.- let cwd = a.cwd;- let worktreeGone = false;- if (a.worktreePath) {- if (await window.cth.gitIsRepo(a.worktreePath)) {- cwd = a.worktreePath;- } else {- worktreeGone = true;- console.warn(`[restore] worktree gone for ${a.id} (${a.worktreePath}); falling back to base repo ${a.cwd}`);- }- }- const res = await window.cth.spawnPty({- id: ptyId,- cwd,- command: exe,- provider,- args,- cols: 100,- rows: 30,- // Worktree (if any) already exists on disk — cd into it, don't create a- // new one (re-isolating would conflict on the existing path/branch and- // lose its uncommitted work).- isolate: false,- // Continue the worker's prior CLI session if one was recorded — the- // main process picks the provider's resume flag (Claude --resume,- // agy --conversation) and for Claude reattaches the transcript. The- // agent id is preserved across restart, so its registry entry,- // memory.md and inbox reattach by id. No-op without a recorded session.- resume: true,- hive: { id: a.id, name: a.name, provider, cwd, role: a.description }- });- if (res.ok) {- restored++;- useStore.getState().addAgent({- ...a,- provider,- ptyId,- archived: false,- status: 'idle',- // Surface the worktree fallback on the floor card; otherwise normal.- action: worktreeGone ? 'worktree gone — using base repo' : 'starting up',- // The worktree is no longer on disk — drop it so this agent is treated- // as a plain base-cwd agent going forward (a future restore won't keep- // re-probing a dead path).- worktreePath: worktreeGone ? undefined : a.worktreePath,- carrying: undefined,- currentStation: 'desk',- recentTextTs: Date.now()- });- } else if ((res.error ?? '').includes('already exists')) {- // A live PTY with this id is already running (e.g. respawned at boot or- // by another path) — the agent isn't actually missing, so retire it from- // the restorable list rather than reporting a phantom failure.- alreadyLive++;- useStore.getState().removeRestorableAgent(a.id);- } else {- // Leave it restorable so the user can retry — but record WHY so the- // outcome is shown on the floor, not buried in the devtools console.- failures.push(`${a.name}: ${res.error ?? 'spawn failed'}`);- console.error('[restore] spawn failed for', a.id, res.error);- }- } catch (e) {- failures.push(`${a.name}: ${e instanceof Error ? e.message : String(e)}`);- console.error('[restore] error for', a.id, e);- }- }));- } finally {- // addAgent auto-selects each spawn; put the user back where they were.- const sel = useStore.getState();- if (prevSel && sel.agents.some((x) => x.id === prevSel)) sel.select(prevSel);- setRestoring(false);- // ALWAYS surface a result so the button can never look inert.- const parts: string[] = [];- if (restored) parts.push(`restored ${restored}`);- if (alreadyLive) parts.push(`${alreadyLive} already live`);- if (failures.length) parts.push(`${failures.length} failed — ${failures.join('; ')}`);- setRestoreNote(parts.length ? parts.join(' · ') : 'nothing to restore');- }- };-return (<div style={{display: 'flex',@@ -311,7 +187,7 @@ export function AgentStrip({ config }: AgentStripProps) {onClick={(e) => e.stopPropagation()}onMouseDown={(e) => e.stopPropagation()}style={{- position: 'absolute', left: 60, right: 7, bottom: 7, height: 25, zIndex: 5,+ position: 'absolute', left: 60, right: 7, bottom: 7, height: 30, zIndex: 5,display: 'flex', alignItems: 'center', gap: 4, padding: '3px 4px',background: 'var(--cth-paper-100)',boxShadow: 'inset 0 0 0 1px var(--cth-ink-900), 2px 2px 0 rgba(26,19,32,0.2)',@@ -319,21 +195,29 @@ export function AgentStrip({ config }: AgentStripProps) {}}><span style={{- flexShrink: 0, fontFamily: 'var(--cth-font-mono)', fontSize: 9,+ flexShrink: 0, fontFamily: 'var(--cth-font-mono)', fontSize: 10,lineHeight: '18px', color: 'var(--cth-ink-700)'}}>NOTE</span>- <input+ {/* A textarea, not an input: the note is a bullet list (one line+ each) and the fullscreen roster renders every line. An <input>+ silently drops the newlines the moment the user edits here,+ which would eat every bullet but the first. */}+ <textareadraggable={false}+ rows={1}+ wrap="off"value={a.note ?? ''}onChange={(e) => setAgentNote(a.id, e.target.value)}placeholder="private note…"aria-label={`Note for ${a.name}`}+ title={a.note || undefined}style={{- flex: 1, minWidth: 0, height: 17, padding: '0 4px',+ flex: 1, minWidth: 0, height: 22, padding: '2px 5px',border: 'none', outline: 'none', boxSizing: 'border-box',+ resize: 'none', overflow: 'auto',background: 'var(--cth-cream-100)',- fontFamily: 'var(--cth-font-mono)', fontSize: 10,- lineHeight: '17px', color: 'var(--cth-ink-900)'+ fontFamily: 'var(--cth-font-mono)', fontSize: 12,+ lineHeight: '18px', color: 'var(--cth-ink-900)'}}/></div>diff --git a/src/renderer/src/components/CommandCenterPanel.tsx b/src/renderer/src/components/CommandCenterPanel.tsxindex 3f13271e..e7af8496 100644--- a/src/renderer/src/components/CommandCenterPanel.tsx+++ b/src/renderer/src/components/CommandCenterPanel.tsx@@ -64,7 +64,11 @@ const TABS: { key: CCTab; label: string; icon: Parameters<typeof Icon>[0]['name'{ key: 'handbook', label: 'commands', icon: 'code' }];-export function CommandCenterPanel({ agent }: { agent: Agent }) {+/** @param fullscreen this instance IS the fullscreen overlay, so it owns the pty+ * and renders the real terminal. The docked instance renders the "open in+ * fullscreen" placeholder instead — two live xterms on one pty fight over its+ * cols/rows and corrupt the display. */+export function CommandCenterPanel({ agent, fullscreen = false }: { agent: Agent; fullscreen?: boolean }) {const [tab, setTab] = useState<CCTab>('terminal');// External tab requests (the office task board → 'tasks', the boss-room// calendar → 'schedules'). seq-keyed so clicking again re-opens the tab even@@ -90,7 +94,8 @@ export function CommandCenterPanel({ agent }: { agent: Agent }) {const setFullscreen = useStore((s) => s.setFullscreen);const fullscreenAgentId = useStore((s) => s.fullscreenAgentId);const onPtyStream = usePtyParser(agent.id);- const isFullscreenedHere = fullscreenAgentId === agent.id;+ // True only for the DOCKED panel while the overlay holds this agent.+ const isFullscreenedHere = fullscreenAgentId === agent.id && !fullscreen;return (<PixelPanel@@ -169,9 +174,9 @@ export function CommandCenterPanel({ agent }: { agent: Agent }) {}void window.cth.historyAdd({ agentId: agent.id, cwd: agent.cwd, text: t });}}- onToggleFullscreen={() => setFullscreen(agent.id)}- fullscreen={false}- embedded+ onToggleFullscreen={() => setFullscreen(fullscreen ? null : agent.id)}+ fullscreen={fullscreen}+ embedded={!fullscreen}/></div><MessageQueueComposer agent={agent} />diff --git a/src/renderer/src/components/FullscreenTerminal.tsx b/src/renderer/src/components/FullscreenTerminal.tsxindex 6902b1ad..6456c0d3 100644--- a/src/renderer/src/components/FullscreenTerminal.tsx+++ b/src/renderer/src/components/FullscreenTerminal.tsx@@ -1,30 +1,170 @@-import { useEffect, useRef, useState } from 'react';+import { useEffect, useMemo, useRef, useState } from 'react';import { createPortal } from 'react-dom';import { PixelBadge } from './PixelBadge';import { PixelButton } from './PixelButton';import { PtyTerminalView } from './PtyTerminalView';import { terminalInstanceKey } from './terminalRecovery';import { MessageQueueComposer } from './MessageQueueComposer';-import { disposeTerminal } from './terminalPool';+import { AgentControlStrip } from './AgentControlStrip';+import { CommandCenterPanel } from './CommandCenterPanel';import { Icon } from './Icon';import { SpritePortrait } from './SpritePortrait';import { useStore, type Agent } from '@/store/store';import { usePtyParser } from '@/hooks/usePtyParser';+import { useRestoreTeam } from '@/hooks/useRestoreTeam';+import { useTerminalFontSize } from './terminalFontSize';+import type { HarnessConfig } from '@/store/config';-export function FullscreenTerminal() {+/** Roster rail width. A fixed 232px is right on a 14" laptop but reads as a+ * sliver on a 27" display, where names truncate for no reason — so it tracks+ * the viewport between those two ends. */+const SIDEBAR_WIDTH = 'clamp(232px, 14vw, 340px)';++/** Roster type scale, derived from the shared terminal zoom so Cmd +/- resizes+ * the whole roster along with the terminal — one knob for the whole view+ * instead of a size that only looked right on the display it was tuned on.+ * Each is clamped: names are a pixel display face that turns to mush when it+ * strays too far from its native size, and the bullets have to stay subordinate+ * to the name however far the terminal is zoomed. */+function rosterScale(zoom: number) {+ const clamp = (n: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, Math.round(n)));+ return {+ name: clamp(zoom * 0.48, 7, 14),+ group: clamp(zoom * 0.45, 7, 13),+ note: clamp(zoom * 0.68, 10, 20),+ portrait: clamp(zoom * 1.2, 18, 40)+ };+}++function basename(path: string): string {+ return path.split('/').filter(Boolean).pop() ?? path;+}++/** cwd → main-repo basename, resolved once per path and shared by every mount.+ * An isolated agent's cwd is its own git worktree (`…/worktrees/<agent-id>`),+ * so naming the group after that path buckets each such agent under its own id+ * instead of the repository the user actually picked. `git:mainRepo` follows a+ * linked worktree back to its main checkout. */+const repoNameByCwd = new Map<string, string>();++/** Which repository an agent belongs to. Falls back to `project` (the basename+ * of the cwd chosen in Add Agent) until the async resolution lands, and for+ * agents whose directory isn't a git repo at all. */+function repoOf(agent: Agent): string {+ const resolved = repoNameByCwd.get(agent.cwd);+ if (resolved) return resolved;+ const project = agent.project?.trim();+ if (project) return project;+ return basename(agent.cwd) || 'unknown';+}++/** Resolve every distinct cwd's repository name, then re-render. Cheap: one git+ * call per NEW path, and results are cached for the process lifetime. */+function useResolvedRepoNames(agents: Agent[]): number {+ const [version, setVersion] = useState(0);+ useEffect(() => {+ let cancelled = false;+ const pending = [...new Set(agents.map(a => a.cwd).filter(Boolean))]+ .filter(cwd => !repoNameByCwd.has(cwd));+ if (pending.length === 0) return;+ void Promise.all(pending.map(async (cwd) => {+ try {+ const root = await window.cth.gitMainRepo(cwd);+ if (root) repoNameByCwd.set(cwd, basename(root));+ } catch { /* leave unresolved — the `project` fallback still names it */ }+ })).then(() => { if (!cancelled) setVersion(v => v + 1); });+ return () => { cancelled = true; };+ }, [agents]);+ return version;+}++/** The roster section an agent lives in — god agents share one ungrouped+ * section, everyone else groups by repository. */+function groupKey(agent: Agent): string {+ return agent.isGod ? '__god__' : repoOf(agent);+}++/** Drag-reorder wiring handed down to each row. */+interface RowDrag {+ dragId: string | null;+ overId: string | null;+ start: (id: string) => void;+ over: (id: string) => void;+ leave: (id: string) => void;+ drop: (id: string) => void;+ end: () => void;+}++export interface FullscreenTerminalProps {+ /** Only needed to rebuild a spawn command for a restorable agent saved before+ * the `command` field existed — same role as in AgentStrip. */+ config?: HarnessConfig | null;+}++export function FullscreenTerminal({ config }: FullscreenTerminalProps) {const agents = useStore(s => s.agents);+ const restorableAgents = useStore(s => s.restorableAgents);const fullscreenAgentId = useStore(s => s.fullscreenAgentId);const setFullscreen = useStore(s => s.setFullscreen);const select = useStore(s => s.select);const setAddAgentOpen = useStore(s => s.setAddAgentOpen);const addAgentOpen = useStore(s => s.addAgentOpen);const setAgentNote = useStore(s => s.setAgentNote);- const archiveAgent = useStore(s => s.archiveAgent);const updateAgent = useStore(s => s.updateAgent);+ // The floor strip (and with it the restore button) is hidden behind the+ // overlay, so the roster carries restore too.+ const { restoring, restoreNote, restoreTeam } = useRestoreTeam(config);const agent = agents.find(a => a.id === fullscreenAgentId);const parser = usePtyParser(agent?.id ?? '__none__');+ const repoVersion = useResolvedRepoNames(agents);+ const scale = rosterScale(useTerminalFontSize());++ // Drag-to-reorder, same as the floor strip (native HTML5 DnD, no dep). A plain+ // click still selects — a drag only starts on movement. Drops are confined to+ // the dragged agent's OWN group: the repo header comes from its cwd, so a+ // cross-group drop would reorder the array and then snap the row straight back+ // under its own header, which just reads as "reordering is broken".+ const reorderAgents = useStore(s => s.reorderAgents);+ const [dragId, setDragId] = useState<string | null>(null);+ const [overId, setOverId] = useState<string | null>(null);+ const drag: RowDrag = {+ dragId,+ overId,+ start: (id) => setDragId(id),+ over: (id) => setOverId((prev) => (prev === id ? prev : id)),+ leave: (id) => setOverId((prev) => (prev === id ? null : prev)),+ drop: (id) => {+ if (dragId && dragId !== id) {+ const from = agents.find(a => a.id === dragId);+ const to = agents.find(a => a.id === id);+ if (from && to && groupKey(from) === groupKey(to)) reorderAgents(dragId, id);+ }+ setDragId(null);+ setOverId(null);+ },+ end: () => { setDragId(null); setOverId(null); }+ };++ // Roster: god agents first and ungrouped, everyone else bucketed by repo.+ // Insertion order is preserved inside each bucket (it's the user's own+ // drag-reorder from the floor strip) and buckets appear in first-seen order,+ // so the list doesn't reshuffle as statuses change.+ const { gods, groups } = useMemo(() => {+ const godList: Agent[] = [];+ const byRepo = new Map<string, Agent[]>();+ for (const a of agents) {+ if (a.isGod) { godList.push(a); continue; }+ const repo = repoOf(a);+ const bucket = byRepo.get(repo);+ if (bucket) bucket.push(a);+ else byRepo.set(repo, [a]);+ }+ return { gods: godList, groups: [...byRepo.entries()] };+ // repoVersion: rebucket once the async main-repo lookups land.+ }, [agents, repoVersion]);+// Esc exits fullscreenuseEffect(() => {const onKey = (e: KeyboardEvent) => {@@ -46,15 +186,11 @@ export function FullscreenTerminal() {return null;}- const onKill = async () => {- if (!agent.ptyId) return;- if (!confirm(`Close ${agent.name}? The PTY process will terminate and the agent is archived (kept in history, off the floor).`)) return;- await window.cth.killPty(agent.ptyId);- disposeTerminal(agent.ptyId);- archiveAgent(agent.id);- setFullscreen(null);- };-+ // No kill button here on purpose. Killing an agent is a destructive action+ // that belongs with the rest of its lifecycle controls in the docked panel;+ // sitting inches from the tab you click to switch agents, it was only ever a+ // mis-click waiting to happen. Exiting fullscreen is likewise already covered+ // twice over (Esc, and the terminal toolbar's own fullscreen toggle).return (<div style={{position: 'fixed', inset: 0,@@ -82,185 +218,371 @@ export function FullscreenTerminal() {}}>MUNDER DIFFLIN · FULLSCREEN</span></div>- {/* Tabs row — the agent tabs scroll in their own track (scrollbar hidden- via .cth-tabbar) so the kill / exit controls stay pinned and aligned at- the right edge instead of being crowded off when many agents are open. */}- <div style={{- display: 'flex', alignItems: 'flex-end', gap: 8,- padding: '8px 12px 0',- background: 'var(--cth-cream-200)',- borderBottom: '2px solid var(--cth-ink-900)'- }}>- <div className="cth-tabbar" style={{- flex: 1, minWidth: 0, display: 'flex', alignItems: 'flex-end', gap: 4, overflowX: 'auto'+ {/* Body — roster on the left, the focused agent's terminal on the right.+ A vertical list scales past the handful of agents a horizontal tab bar+ could show, and grouping by repository is how the user actually thinks+ about the fleet. */}+ <div style={{ flex: 1, minHeight: 0, display: 'flex' }}>+ <aside style={{+ width: SIDEBAR_WIDTH, flexShrink: 0,+ display: 'flex', flexDirection: 'column',+ background: 'var(--cth-cream-200)',+ borderRight: '2px solid var(--cth-ink-900)'}}>- {agents.map(a => (- <Tab- key={a.id}- agent={a}- active={a.id === agent.id}- onClick={() => { select(a.id); setFullscreen(a.id); }}- onNoteChange={(note) => setAgentNote(a.id, note)}- />- ))}- <button- onClick={() => setAddAgentOpen(true)}- title="Add agent"- style={{- height: 32, padding: '0 10px', marginBottom: 4, flexShrink: 0,- background: 'var(--cth-cream-100)',- border: 'none',- boxShadow: 'inset 0 0 0 1px var(--cth-ink-700)',- fontFamily: 'var(--cth-font-ui)', fontSize: 14,- color: 'var(--cth-ink-900)',- display: 'inline-flex', alignItems: 'center', gap: 4,- cursor: 'pointer'- }}- >- <Icon name="plus" /> agent- </button>- </div>- <div style={{ flexShrink: 0, display: 'flex', alignItems: 'center', gap: 6, paddingBottom: 6 }}>- <PixelButton variant="destructive" size="sm" onClick={onKill}>- <span style={{ display: 'inline-flex', gap: 4, alignItems: 'center' }}>- <Icon name="x" /> kill- </span>- </PixelButton>- <PixelButton variant="secondary" size="sm" onClick={() => setFullscreen(null)}>- <span style={{ display: 'inline-flex', gap: 4, alignItems: 'center' }}>- <Icon name="minimize" /> exit (esc)- </span>- </PixelButton>- </div>- </div>-- {/* Body */}- <div style={{- flex: 1, minHeight: 0,- display: 'flex', flexDirection: 'column',- padding: 12, gap: 10- }}>- <Header agent={agent} />-- <div style={{ flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column' }}>- <div style={{ flex: 1, minHeight: 0, display: 'flex' }}>- <PtyTerminalView- key={terminalInstanceKey(agent.ptyId, agent.terminalGeneration)}- ptyId={agent.ptyId}- onStreamData={parser}- onUserPrompt={(t) => {- updateAgent(agent.id, { lastPrompt: t });- if (t.trim().toLowerCase() === '/clear') {- updateAgent(agent.id, { contextTokens: 0, contextLimit: undefined, progress: 0 });- }- void window.cth.historyAdd({ agentId: agent.id, cwd: agent.cwd, text: t });+ <div style={{ padding: 8, borderBottom: '1px solid var(--cth-ink-300)' }}>+ <button+ onClick={() => setAddAgentOpen(true)}+ title="Add agent"+ style={{+ width: '100%', height: 32,+ background: 'var(--cth-cream-100)',+ border: 'none',+ boxShadow: 'inset 0 0 0 1px var(--cth-ink-700)',+ fontFamily: 'var(--cth-font-ui)',+ fontSize: 'clamp(14px, 0.7vw, 15px)',+ color: 'var(--cth-ink-900)',+ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 4,+ cursor: 'pointer'}}- onToggleFullscreen={() => setFullscreen(null)}- fullscreen- />+ >+ <Icon name="plus" /> agent+ </button>+ </div>++ <div className="cth-scroll-hidden" style={{ flex: 1, minHeight: 0, overflowY: 'auto', padding: '6px 0' }}>+ {/* The god agent runs the floor rather than a checkout, so it gets no+ repository header — it sits alone at the top of the roster. */}+ {gods.map(a => (+ <SidebarRow+ key={a.id}+ agent={a}+ active={a.id === agent.id}+ onClick={() => { select(a.id); setFullscreen(a.id); }}+ onNoteChange={(note) => setAgentNote(a.id, note)}+ drag={drag}+ scale={scale}+ />+ ))}+ {groups.map(([repo, members]) => (+ // Repos are the roster's real structure, so they get real+ // separation — a hairline plus air above, not just a label.+ <div key={repo} style={{ marginTop: 16, paddingTop: 10, borderTop: '1px solid var(--cth-ink-300)' }}>+ <div+ title={repo}+ style={{+ display: 'flex', alignItems: 'center', gap: 6,+ padding: '0 10px 6px',+ fontFamily: 'var(--cth-font-display)',+ fontSize: scale.group, lineHeight: 1.5,+ color: 'var(--cth-ink-500)'+ }}+ >+ {/* Native 16px, never a fraction of it: this is pixel art on+ a 16-unit grid, so squeezing it to match a 7px label+ merged the outline into mush. Dimmed instead of shrunk. */}+ <span style={{ flexShrink: 0, display: 'inline-flex', opacity: 0.7 }}>+ <Icon name="folder" size={scale.group >= 13 ? 2 : 1} />+ </span>+ <span style={{+ minWidth: 0,+ whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'+ }}>{repo.toUpperCase()}</span>+ </div>+ {members.map(a => (+ <SidebarRow+ key={a.id}+ agent={a}+ active={a.id === agent.id}+ onClick={() => { select(a.id); setFullscreen(a.id); }}+ onNoteChange={(note) => setAgentNote(a.id, note)}+ drag={drag}+ scale={scale}+ />+ ))}+ </div>+ ))}</div>- <MessageQueueComposer agent={agent} />++ {/* Last session's team, same as the floor strip — pinned to the bottom+ so it can't be scrolled out of reach behind a long roster. */}+ {(restorableAgents.length > 0 || restoreNote) && (+ <div style={{+ flexShrink: 0, padding: 8, display: 'flex', flexDirection: 'column', gap: 6,+ borderTop: '1px solid var(--cth-ink-300)'+ }}>+ {restorableAgents.length > 0 && (+ <PixelButton+ variant="primary"+ size="sm"+ onClick={restoreTeam}+ disabled={restoring}+ style={{ width: '100%' }}+ title={`Respawn from last session: ${restorableAgents.map((a: Agent) => a.name).join(', ')} — same ids, memory and inboxes reattach automatically`}+ >+ <span style={{ display: 'inline-flex', gap: 6, alignItems: 'center' }}>+ <Icon name="play" /> {restoring ? 'restoring…' : `restore team (${restorableAgents.length})`}+ </span>+ </PixelButton>+ )}+ {restorableAgents.length > 0 && (+ <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>+ {restorableAgents.map((a: Agent) => (+ <span+ key={a.id}+ title={`${a.name} — restorable from last session`}+ style={{+ display: 'inline-flex', alignItems: 'center', gap: 2,+ height: 20, padding: '0 2px 0 6px',+ fontFamily: 'var(--cth-font-ui)', fontSize: 11,+ color: 'var(--cth-ink-700)', background: 'var(--cth-paper-100)',+ boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)'+ }}+ >+ {a.name}+ <button+ onClick={() => useStore.getState().removeRestorableAgent(a.id)}+ title={`Dismiss ${a.name} — remove permanently from the restore list`}+ aria-label={`Dismiss ${a.name}`}+ style={{+ display: 'inline-flex', alignItems: 'center', justifyContent: 'center',+ width: 14, height: 14, padding: 0, lineHeight: 1,+ fontFamily: 'var(--cth-font-ui)', fontSize: 11,+ color: 'var(--cth-ink-500)', background: 'transparent',+ border: 'none', cursor: 'pointer'+ }}+ >✕</button>+ </span>+ ))}+ </div>+ )}+ {restoreNote && (+ <span+ title={restoreNote}+ style={{+ fontFamily: 'var(--cth-font-ui)', fontSize: 11,+ color: 'var(--cth-ink-500)',+ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap'+ }}+ >{restoreNote}</span>+ )}+ </div>+ )}+ </aside>++ <div style={{+ flex: 1, minWidth: 0, minHeight: 0,+ display: 'flex', flexDirection: 'column',+ padding: 12, gap: 10+ }}>+ {agent.isGod ? (+ // Michael runs the floor from the command center — its tabs (tasks,+ // ask me, schedules, memory, graph…) are the whole point of selecting+ // him, and fullscreen used to drop them for a bare terminal.+ // Column so the panel's `height: 100%` resolves against a definite+ // height and `align-items: stretch` gives it the full width.+ <div style={{ flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column' }}>+ <CommandCenterPanel agent={agent} fullscreen />+ </div>+ ) : (+ <>+ <Header agent={agent} />++ {/* #7C — pause / halt / steer. These only existed in the docked+ sidebar, so going fullscreen took the operator controls away. */}+ <AgentControlStrip key={agent.id} agentId={agent.id} />++ <div style={{ flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column' }}>+ <div style={{ flex: 1, minHeight: 0, display: 'flex' }}>+ <PtyTerminalView+ key={terminalInstanceKey(agent.ptyId, agent.terminalGeneration)}+ ptyId={agent.ptyId}+ onStreamData={parser}+ onUserPrompt={(t) => {+ updateAgent(agent.id, { lastPrompt: t });+ if (t.trim().toLowerCase() === '/clear') {+ updateAgent(agent.id, { contextTokens: 0, contextLimit: undefined, progress: 0 });+ }+ void window.cth.historyAdd({ agentId: agent.id, cwd: agent.cwd, text: t });+ }}+ onToggleFullscreen={() => setFullscreen(null)}+ fullscreen+ />+ </div>+ <MessageQueueComposer agent={agent} />+ </div>+ </>+ )}</div></div></div>);}-function Tab({+function SidebarRow({agent,active,onClick,- onNoteChange+ onNoteChange,+ drag,+ scale}: {agent: Agent;active: boolean;onClick: () => void;onNoteChange: (note: string) => void;+ drag: RowDrag;+ scale: ReturnType<typeof rosterScale>;}) {const buttonRef = useRef<HTMLButtonElement>(null);const noteRef = useRef<HTMLDivElement>(null);const hideTimer = useRef<number | null>(null);const [notePosition, setNotePosition] = useState<{ left: number; top: number } | null>(null);+ // The editor rides the terminal's zoom, capped — it's a short note, not a+ // reading pane, and following the terminal all the way up turned it into a+ // banner wider than the roster itself.+ const noteFontSize = Math.min(useTerminalFontSize(), 14);+ const noteLabelSize = Math.max(8, Math.round(noteFontSize * 0.6));+ const noteWidth = Math.min(300, Math.round(noteFontSize * 20));+ const noteHeight = Math.round(noteFontSize * 9);++ // One line of the note = one bullet on the row.+ const bullets = (agent.note ?? '').split('\n').map(s => s.trim()).filter(Boolean);+useEffect(() => () => {if (hideTimer.current !== null) window.clearTimeout(hideTimer.current);}, []);- const showNote = () => {+ /** Hovering a row opens its editor beside it — the bullets on the row are the+ * summary, this is where you write them. */+ const openEditor = () => {+ // An editor popping up under the cursor mid-drag just gets in the way.+ if (drag.dragId) return;if (hideTimer.current !== null) window.clearTimeout(hideTimer.current);const rect = buttonRef.current?.getBoundingClientRect();if (!rect) return;- const width = 280;- // Fullscreen tabs sit against the top edge, so the note always opens BELOW- // its agent. Clamp horizontally so right-most tabs stay inside the viewport.+ // The roster is a left rail, so the editor opens to the RIGHT of its row.+ // Clamp so rows near an edge stay fully on screen.setNotePosition({- left: Math.max(8, Math.min(rect.left, window.innerWidth - width - 8)),- top: rect.bottom + 6+ left: Math.min(rect.right + 6, window.innerWidth - noteWidth - 8),+ top: Math.max(8, Math.min(rect.top, window.innerHeight - noteHeight - 8))});};- const scheduleHideNote = () => {+ /** Close on a delay so the pointer can travel from the row into the editor+ * without it vanishing en route, and stay open while it's being typed in. */+ const scheduleClose = () => {if (hideTimer.current !== null) window.clearTimeout(hideTimer.current);hideTimer.current = window.setTimeout(() => {- // Keep the editor open while the user is typing, even if their pointer- // leaves the popover. Blur schedules the normal close.if (noteRef.current?.contains(document.activeElement)) return;setNotePosition(null);- }, 120);+ }, 160);};return (<><buttonref={buttonRef}+ draggable+ onDragStart={(e) => { drag.start(agent.id); e.dataTransfer.effectAllowed = 'move'; }}+ onDragOver={(e) => {+ if (!drag.dragId || drag.dragId === agent.id) return;+ e.preventDefault();+ e.dataTransfer.dropEffect = 'move';+ drag.over(agent.id);+ }}+ onDragLeave={() => drag.leave(agent.id)}+ onDrop={(e) => { e.preventDefault(); drag.drop(agent.id); }}+ onDragEnd={drag.end}onClick={onClick}- onMouseEnter={showNote}- onMouseLeave={scheduleHideNote}+ onMouseEnter={openEditor}+ onMouseLeave={scheduleClose}aria-label={`${agent.name} · ${agent.project}`}+ aria-current={active ? 'true' : undefined}style={{- height: active ? 38 : 32,- padding: '0 10px',- marginBottom: active ? 0 : 4,- background: active ? 'var(--cth-cream-100)' : 'var(--cth-cream-300)',+ width: '100%',+ padding: '6px 8px',+ background: active ? 'var(--cth-cream-100)' : 'transparent',border: 'none',boxShadow: active- ? 'inset 0 0 0 2px var(--cth-ink-900), inset 0 -3px 0 var(--cth-cream-100)'- : 'inset 0 0 0 1px var(--cth-ink-700)',- display: 'inline-flex', alignItems: 'center', gap: 8,- cursor: 'pointer',+ ? 'inset 3px 0 0 var(--cth-ink-900), inset 0 0 0 1px var(--cth-ink-700)'+ // Insertion cue on the hovered drop target.+ : drag.overId === agent.id && drag.dragId && drag.dragId !== agent.id+ ? 'inset 0 2px 0 var(--cth-ink-900)'+ : 'none',+ opacity: drag.dragId === agent.id ? 0.4 : 1,+ display: 'flex', alignItems: 'flex-start', gap: 8,+ cursor: drag.dragId ? 'grabbing' : 'grab',position: 'relative',+ textAlign: 'left',fontFamily: 'var(--cth-font-ui)', fontSize: 14,color: 'var(--cth-ink-900)',- maxWidth: 240,- whiteSpace: 'nowrap'+ transition: 'opacity 120ms ease'}}><div style={{- width: 20, height: 32,+ width: scale.portrait, height: Math.round(scale.portrait * 1.3), flexShrink: 0,background: `var(--cth-${agent.accent}-light)`,boxShadow: 'inset 0 0 0 1px var(--cth-ink-900)',display: 'flex', alignItems: 'flex-end', justifyContent: 'center',overflow: 'hidden'}}>- <SpritePortrait character={agent.character} scale={1} />+ {/* Sprites only scale by whole pixels — doubling past the point where+ 1× would leave a stamp adrift in an oversized frame. */}+ <SpritePortrait character={agent.character} scale={scale.portrait >= 32 ? 2 : 1} />+ </div>+ <div style={{ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 3 }}>+ <div style={{ display: 'flex', alignItems: 'center', gap: 6, minWidth: 0 }}>+ <span style={{+ flex: 1, minWidth: 0,+ whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis',+ fontFamily: 'var(--cth-font-display)',+ fontSize: scale.name, lineHeight: 1.5+ }}>{agent.name.toUpperCase()}</span>+ <PixelBadge status={agent.status} />+ </div>+ {/* Every line of every agent, always on screen — the roster's job is+ to answer "who is on what" without a single interaction. */}+ <div style={{ display: 'flex', flexDirection: 'column', gap: 1 }}>+ {bullets.map((line, i) => (+ <span+ key={i}+ title={line}+ style={{+ display: 'flex', gap: 5, alignItems: 'baseline',+ fontSize: scale.note, lineHeight: 1.35,+ color: 'var(--cth-ink-500)'+ }}+ >+ <span style={{ flexShrink: 0, color: 'var(--cth-ink-300)' }}>•</span>+ {/* Exactly one line per bullet — a wrapping row would make the+ roster's height jump around as notes are typed. The full+ text is on hover (title, and the editor beside it). */}+ <span style={{+ whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'+ }}>{line}</span>+ </span>+ ))}+ {bullets.length === 0 && (+ <span style={{+ fontSize: scale.note, lineHeight: 1.35,+ color: 'var(--cth-ink-300)', fontStyle: 'italic'+ }}>no note</span>+ )}+ </div></div>- <span style={{- overflow: 'hidden', textOverflow: 'ellipsis',- fontFamily: 'var(--cth-font-display)', fontSize: 8, lineHeight: '12px'- }}>{agent.name.toUpperCase()}</span>- <PixelBadge status={agent.status} /></button>{notePosition && createPortal(<divref={noteRef}- onMouseEnter={showNote}- onMouseLeave={scheduleHideNote}+ onMouseEnter={openEditor}+ onMouseLeave={scheduleClose}onClick={(e) => e.stopPropagation()}style={{position: 'fixed',left: notePosition.left,top: notePosition.top,- width: 280,+ width: noteWidth,zIndex: 450,padding: 8,background: 'var(--cth-paper-100)',@@ -269,44 +591,54 @@ function Tab({}}><div style={{- marginBottom: 5,+ marginBottom: 6,fontFamily: 'var(--cth-font-display)',- fontSize: 8,- lineHeight: '12px',+ fontSize: noteLabelSize,+ lineHeight: `${Math.round(noteLabelSize * 1.5)}px`,color: 'var(--cth-ink-700)'}}>{agent.name.toUpperCase()} · PRIVATE NOTE</div>- <input+ {/* A textarea, not an input: the note is a bullet list, so Enter has+ to make a new line rather than doing nothing. */}+ {/* No autoFocus — the editor opens on hover, and stealing focus every+ time the pointer crosses the roster would pull the caret out of+ whatever the user was typing. Click into it to edit. */}+ <textareavalue={agent.note ?? ''}onChange={(e) => onNoteChange(e.target.value)}onFocus={() => {if (hideTimer.current !== null) window.clearTimeout(hideTimer.current);}}- onBlur={scheduleHideNote}+ onBlur={scheduleClose}onKeyDown={(e) => {+ e.stopPropagation(); // don't let Esc/typing reach the fullscreen handlerif (e.key === 'Escape') {- e.stopPropagation();setNotePosition(null);buttonRef.current?.focus();}}}- placeholder="private note…"+ placeholder="one line per bullet…"aria-label={`Note for ${agent.name}`}style={{width: '100%',- height: 28,- padding: '2px 7px',+ height: noteHeight,+ padding: '5px 7px',border: 'none',outline: 'none',+ resize: 'vertical',boxSizing: 'border-box',background: 'var(--cth-cream-100)',boxShadow: 'inset 0 0 0 1px var(--cth-ink-700)',fontFamily: 'var(--cth-font-mono)',- fontSize: 11,+ fontSize: noteFontSize,+ lineHeight: `${Math.round(noteFontSize * 1.6)}px`,color: 'var(--cth-ink-900)'}}/>+ <div style={{+ marginTop: 5, fontSize: 10, color: 'var(--cth-ink-500)'+ }}>one line = one bullet · esc to close</div></div>,document.body)}diff --git a/src/renderer/src/components/MessageQueueComposer.tsx b/src/renderer/src/components/MessageQueueComposer.tsxindex 747cf078..972d44f2 100644--- a/src/renderer/src/components/MessageQueueComposer.tsx+++ b/src/renderer/src/components/MessageQueueComposer.tsx@@ -1,8 +1,11 @@-import { ClipboardEvent, DragEvent, KeyboardEvent, useState } from 'react';+import { ClipboardEvent, DragEvent, KeyboardEvent, useEffect, useLayoutEffect, useRef, useState } from 'react';import { PixelButton } from './PixelButton';import { Icon } from './Icon';import { useStore, type Agent, type QueuedMessage } from '@/store/store';+import { clearTerminalDraft, terminalAutomationBlockFor } from './terminalPool';+import type { TerminalAutomationBlock } from './terminalAutomation';import { freeflowRecorder, useFreeflow } from '@/freeflow/recorder';+import { useTerminalFontSize } from './terminalFontSize';const EMPTY_QUEUE: QueuedMessage[] = [];@@ -54,6 +57,11 @@ export function MessageQueueComposer({ agent }: MessageQueueComposerProps) {? `voice: ${ff.error}`: null;+ // The draft box is the terminal's twin — it should read at the same size the+ // agent's output does, at every zoom level.+ const composerFontSize = useTerminalFontSize();+ const composerLineHeight = Math.round(composerFontSize * 1.4);+const idle = agent.status === 'idle';// Only the god/Michael agent gets the delegation toggle. Default OFF.@@ -140,11 +148,22 @@ export function MessageQueueComposer({ agent }: MessageQueueComposerProps) {}};+ // Delivery can be held back by the agent's own terminal (a half-typed draft or+ // an open slash-command picker owns the prompt). That used to be invisible —+ // the hint claimed it was sending while nothing moved — so poll it and say so.+ const block = useTerminalBlock(agent.ptyId, queue.length > 0 && idle);+const statusHint = queue.length === 0? null- : idle- ? `sending to ${agent.name} one-by-one…`- : `${agent.name} is busy — ${queue.length} queued`;+ : !idle+ ? `${agent.name} is busy — ${queue.length} queued`+ : block === 'draft'+ ? `held — ${agent.name}'s terminal has unsent text on its prompt`+ : block === 'picker'+ ? `held — a slash-command picker is open in ${agent.name}'s terminal`+ : block === 'exited'+ ? `held — ${agent.name}'s terminal has exited`+ : `sending to ${agent.name} one-by-one…`;return (<div@@ -193,6 +212,17 @@ export function MessageQueueComposer({ agent }: MessageQueueComposerProps) {whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}}>{statusHint}</span>)}+ {(block === 'draft' || block === 'picker') && agent.ptyId && (+ <button+ onClick={() => clearTerminalDraft(agent.ptyId!)}+ title="Clear the leftover text on this agent's terminal prompt so queued messages can be delivered"+ style={{+ border: 'none', background: 'transparent', cursor: 'pointer', padding: 0,+ fontFamily: 'var(--cth-font-ui)', fontSize: 12,+ color: 'var(--cth-ink-900)', textDecoration: 'underline'+ }}+ >clear prompt</button>+ )}{queue.length > 1 && (<buttononClick={() => clearQueue(agent.id)}@@ -214,39 +244,12 @@ export function MessageQueueComposer({ agent }: MessageQueueComposerProps) {maxHeight: 280, overflowY: 'auto'}}>{queue.map((m, i) => (- <div key={m.id} style={{- display: 'flex', alignItems: 'flex-start', gap: 6,- padding: '4px 6px',- background: 'var(--cth-paper-100)',- boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)'- }}>- <span style={{- fontFamily: 'var(--cth-font-mono)', fontSize: 12,- color: 'var(--cth-ink-500)', lineHeight: '18px', flexShrink: 0- }}>{`${i + 1}.`}</span>- <div- title={m.text}- style={{- flex: 1, minWidth: 0,- fontSize: 13, lineHeight: '18px',- color: 'var(--cth-ink-900)',- display: '-webkit-box', WebkitLineClamp: 2, WebkitBoxOrient: 'vertical',- overflow: 'hidden', whiteSpace: 'pre-wrap', wordBreak: 'break-word'- }}- >{m.text}</div>- <button- onClick={() => removeQueuedMessage(agent.id, m.id)}- title="Remove from queue"- style={{- flexShrink: 0, border: 'none', background: 'transparent',- cursor: 'pointer',- color: 'var(--cth-ink-500)', padding: 0,- display: 'inline-flex', alignItems: 'center'- }}- >- <Icon name="x" />- </button>- </div>+ <QueuedMessageRow+ key={m.id}+ index={i}+ message={m}+ onRemove={() => removeQueuedMessage(agent.id, m.id)}+ />))}</div>)}@@ -310,13 +313,18 @@ export function MessageQueueComposer({ agent }: MessageQueueComposerProps) {style={{width: '100%',resize: 'vertical',- minHeight: 96, maxHeight: 320,+ // Track the terminal's zoom (Cmd +/- or the terminal's own zoom+ // buttons) instead of a hardcoded 13px. On a large display the+ // terminal text scaled up while this box stayed tiny; box height is+ // derived from the same size so the visible line count is stable.+ minHeight: composerLineHeight * 5 + 14,+ maxHeight: composerLineHeight * 18,padding: '6px 8px',background: 'var(--cth-paper-100)',border: 'none',boxShadow: 'inset 0 0 0 1px var(--cth-ink-700)',fontFamily: 'var(--cth-font-mono)',- fontSize: 13, lineHeight: '18px',+ fontSize: composerFontSize, lineHeight: `${composerLineHeight}px`,color: 'var(--cth-ink-900)',outline: 'none',boxSizing: 'border-box'@@ -345,6 +353,108 @@ export function MessageQueueComposer({ agent }: MessageQueueComposerProps) {);}+/** Poll the pty's automation block while there is something waiting on it. The+ * flag lives in the terminal pool (a plain module map, not the store), so there+ * is nothing to subscribe to — a 1s tick while the queue is pending is enough. */+function useTerminalBlock(ptyId: string | undefined, active: boolean): TerminalAutomationBlock {+ const [block, setBlock] = useState<TerminalAutomationBlock>(null);+ useEffect(() => {+ if (!ptyId || !active) { setBlock(null); return; }+ const read = () => setBlock(terminalAutomationBlockFor(ptyId));+ read();+ const iv = setInterval(read, 1000);+ return () => clearInterval(iv);+ }, [ptyId, active]);+ // 'settling' is a sub-second gap between writes — not worth telling anyone.+ return block === 'settling' ? null : block;+}++/**+ * One pending queue row. Collapsed it clamps to 2 lines; "see more" expands it+ * in place so a long message can be read without hovering for the tooltip. The+ * toggle only renders when the text actually clips, so short messages stay tidy.+ */+function QueuedMessageRow(+ { index, message, onRemove }: { index: number; message: QueuedMessage; onRemove: () => void }+) {+ const [expanded, setExpanded] = useState(false);+ const [clipped, setClipped] = useState(false);+ const bodyRef = useRef<HTMLDivElement>(null);++ // Measure against the CLAMPED box, so the toggle survives being expanded (the+ // expanded box never overflows and would otherwise report clipped = false).+ useLayoutEffect(() => {+ const el = bodyRef.current;+ if (!el) return;+ const measure = () => {+ if (expanded) return;+ setClipped(el.scrollHeight > el.clientHeight + 1);+ };+ measure();+ // The panel is resizable — re-measure on width changes, not just text ones.+ const ro = new ResizeObserver(measure);+ ro.observe(el);+ return () => ro.disconnect();+ }, [message.text, expanded]);++ return (+ <div style={{+ display: 'flex', alignItems: 'flex-start', gap: 6,+ padding: '4px 6px',+ background: 'var(--cth-paper-100)',+ boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)'+ }}>+ <span style={{+ fontFamily: 'var(--cth-font-mono)', fontSize: 12,+ color: 'var(--cth-ink-500)', lineHeight: '18px', flexShrink: 0+ }}>{`${index + 1}.`}</span>+ <div style={{ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 2 }}>+ <div+ ref={bodyRef}+ title={expanded ? undefined : message.text}+ style={{+ fontSize: 13, lineHeight: '18px',+ color: 'var(--cth-ink-900)',+ whiteSpace: 'pre-wrap', wordBreak: 'break-word',+ ...(expanded+ // Cap the expanded body so one long message can't push the rest of+ // the queue out of the list's own 280px scroll area.+ ? { maxHeight: 220, overflowY: 'auto' as const }+ : {+ display: '-webkit-box', WebkitLineClamp: 2, WebkitBoxOrient: 'vertical',+ overflow: 'hidden'+ })+ }}+ >{message.text}</div>+ {(clipped || expanded) && (+ <button+ onClick={() => setExpanded((e) => !e)}+ title={expanded ? 'Collapse this message' : 'Show the full message'}+ style={{+ alignSelf: 'flex-start',+ border: 'none', background: 'transparent', cursor: 'pointer', padding: 0,+ fontFamily: 'var(--cth-font-ui)', fontSize: 12, lineHeight: '16px',+ color: 'var(--cth-ink-500)', textDecoration: 'underline'+ }}+ >{expanded ? 'see less' : 'see more'}</button>+ )}+ </div>+ <button+ onClick={onRemove}+ title="Remove from queue"+ style={{+ flexShrink: 0, border: 'none', background: 'transparent',+ cursor: 'pointer',+ color: 'var(--cth-ink-500)', padding: 0,+ display: 'inline-flex', alignItems: 'center'+ }}+ >+ <Icon name="x" />+ </button>+ </div>+ );+}+/*** A pixel-style toggle switch for the god/Michael delegation flag. ON prepends* DELEGATE_PREFIX to the enqueued message so Michael fans the task out to otherdiff --git a/src/renderer/src/components/PtyTerminalView.tsx b/src/renderer/src/components/PtyTerminalView.tsxindex 15cd4281..a36b4479 100644--- a/src/renderer/src/components/PtyTerminalView.tsx+++ b/src/renderer/src/components/PtyTerminalView.tsx@@ -3,24 +3,25 @@ import type { CSSProperties } from 'react';import '@xterm/xterm/css/xterm.css';import { Icon } from './Icon';import { acquireTerminal, attachTerminal, reflowTerminal } from './terminalPool';+import {+ DEFAULT_TERMINAL_FONT_SIZE,+ MAX_TERMINAL_FONT_SIZE,+ MIN_TERMINAL_FONT_SIZE,+ getTerminalFontSize,+ setTerminalFontSize,+ useTerminalFontSize+} from './terminalFontSize';-const DEFAULT_FONT_SIZE = 14;-const MIN_FONT_SIZE = 8;-const MAX_FONT_SIZE = 40;+// Zoom lives in ./terminalFontSize so anything outside the terminal (the message+// composer) can scale with it too; these aliases keep the call sites below short.+const DEFAULT_FONT_SIZE = DEFAULT_TERMINAL_FONT_SIZE;+const MIN_FONT_SIZE = MIN_TERMINAL_FONT_SIZE;+const MAX_FONT_SIZE = MAX_TERMINAL_FONT_SIZE;-const LS_FONT_SIZE = 'cth.ptyFontSize';const LS_THEME = 'cth.ptyTheme';type PtyTheme = 'light' | 'dark';-function loadFontSize(): number {- try {- const n = parseInt(window.localStorage.getItem(LS_FONT_SIZE) ?? '', 10);- if (!Number.isNaN(n) && n >= MIN_FONT_SIZE && n <= MAX_FONT_SIZE) return n;- } catch { /* noop */ }- return DEFAULT_FONT_SIZE;-}-function loadTheme(): PtyTheme {try {const v = window.localStorage.getItem(LS_THEME);@@ -131,7 +132,7 @@ export function PtyTerminalView({ ptyId, onStreamData, onUserPrompt, onToggleFulonStreamDataRef.current = onStreamData;const onUserPromptRef = useRef(onUserPrompt);onUserPromptRef.current = onUserPrompt;- const [fontSize, setFontSize] = useState(loadFontSize);+ const fontSize = useTerminalFontSize();const fontSizeRef = useRef(fontSize);const [ptyTheme, setPtyTheme] = useState<PtyTheme>(loadTheme);const ptyThemeRef = useRef(ptyTheme);@@ -279,7 +280,6 @@ export function PtyTerminalView({ ptyId, onStreamData, onUserPrompt, onToggleFul// Apply font-size (zoom) changes to the pooled terminal and re-fit cols/rows.useEffect(() => {fontSizeRef.current = fontSize;- try { window.localStorage.setItem(LS_FONT_SIZE, String(fontSize)); } catch { /* noop */ }const entry = acquireTerminal(ptyId, THEMES[ptyThemeRef.current], fontSize);entry.term.options.fontSize = fontSize;try {@@ -334,9 +334,8 @@ export function PtyTerminalView({ ptyId, onStreamData, onUserPrompt, onToggleFulvoid window.cth.writePty(ptyId, paths.join(' ') + ' ');};- const zoom = (delta: number) =>- setFontSize((s) => Math.min(MAX_FONT_SIZE, Math.max(MIN_FONT_SIZE, s + delta)));- const resetZoom = () => setFontSize(DEFAULT_FONT_SIZE);+ const zoom = (delta: number) => setTerminalFontSize(getTerminalFontSize() + delta);+ const resetZoom = () => setTerminalFontSize(DEFAULT_FONT_SIZE);// Keyboard zoom: Cmd/Ctrl + '=' / '-' / '0'useEffect(() => {diff --git a/src/renderer/src/components/terminalFontSize.ts b/src/renderer/src/components/terminalFontSize.tsnew file mode 100644index 00000000..72a579c6--- /dev/null+++ b/src/renderer/src/components/terminalFontSize.ts@@ -0,0 +1,54 @@+import { useSyncExternalStore } from 'react';++/** The terminal zoom level, shared by every component that should scale with it.+ *+ * It used to be component-local state inside PtyTerminalView, persisted to+ * localStorage. That kept the xterm panes in sync only because each one read the+ * stored value at mount — anything OUTSIDE the terminal (notably the message+ * composer) could not follow the user's Cmd +/- at all, so on a large display the+ * terminal text grew while the box you type into stayed at its hardcoded 13px.+ * Holding the value in one module with subscribers makes the zoom a first-class+ * app-wide setting: PtyTerminalView writes it, anyone can read it live. */++export const DEFAULT_TERMINAL_FONT_SIZE = 14;+export const MIN_TERMINAL_FONT_SIZE = 8;+export const MAX_TERMINAL_FONT_SIZE = 40;++const LS_FONT_SIZE = 'cth.ptyFontSize';++function load(): number {+ try {+ const n = parseInt(window.localStorage.getItem(LS_FONT_SIZE) ?? '', 10);+ if (!Number.isNaN(n) && n >= MIN_TERMINAL_FONT_SIZE && n <= MAX_TERMINAL_FONT_SIZE) return n;+ } catch { /* noop */ }+ return DEFAULT_TERMINAL_FONT_SIZE;+}++let current = load();+const listeners = new Set<() => void>();++export function getTerminalFontSize(): number {+ return current;+}++/** Set the shared zoom level (clamped) and persist it. No-op when unchanged, so+ * a redundant set can't churn every subscriber's effects. */+export function setTerminalFontSize(next: number): number {+ const clamped = Math.min(MAX_TERMINAL_FONT_SIZE, Math.max(MIN_TERMINAL_FONT_SIZE, Math.round(next)));+ if (clamped === current) return current;+ current = clamped;+ try { window.localStorage.setItem(LS_FONT_SIZE, String(clamped)); } catch { /* noop */ }+ for (const l of [...listeners]) l();+ return clamped;+}++function subscribe(listener: () => void): () => void {+ listeners.add(listener);+ return () => { listeners.delete(listener); };+}++/** Live terminal font size. Re-renders the caller whenever the zoom changes,+ * wherever it was changed from. */+export function useTerminalFontSize(): number {+ return useSyncExternalStore(subscribe, getTerminalFontSize, getTerminalFontSize);+}diff --git a/src/renderer/src/design/global.css b/src/renderer/src/design/global.cssindex 91e2107f..378898d1 100644--- a/src/renderer/src/design/global.css+++ b/src/renderer/src/design/global.css@@ -53,6 +53,12 @@ input, textarea, [contenteditable='true'] {.cth-tabbar { scrollbar-width: none; -ms-overflow-style: none; }.cth-tabbar::-webkit-scrollbar { height: 0; display: none; }+/* Same treatment for a vertical list (the fullscreen agent roster): still+ scrollable by wheel/trackpad, but the bar itself never takes a slice out of an+ already narrow rail. */+.cth-scroll-hidden { scrollbar-width: none; -ms-overflow-style: none; }+.cth-scroll-hidden::-webkit-scrollbar { width: 0; height: 0; display: none; }+/* Pixel-snapping for any rasterised content */canvas, img, svg { image-rendering: pixelated; image-rendering: crisp-edges; }diff --git a/src/renderer/src/hooks/useRestoreTeam.ts b/src/renderer/src/hooks/useRestoreTeam.tsnew file mode 100644index 00000000..9adb76db--- /dev/null+++ b/src/renderer/src/hooks/useRestoreTeam.ts@@ -0,0 +1,175 @@+import { useSyncExternalStore } from 'react';+import { useStore } from '@/store/store';+import { buildSpawnCommand, inferAgentProvider, tokenizeCommand, type HarnessConfig } from '@/store/config';++/** "Restore team" — respawn every worker from the previous session.+ *+ * Lives here rather than inside AgentStrip because the floor strip is hidden in+ * fullscreen, which used to mean the restore button (and the list of restorable+ * agents) simply vanished when you went fullscreen. Both mount points share the+ * progress state below, so a restore kicked off from one view shows as running+ * in the other and can't be double-started. */++let restoring = false;+let note: string | null = null;+const listeners = new Set<() => void>();++function emit(): void {+ for (const l of [...listeners]) l();+}++function subscribe(listener: () => void): () => void {+ listeners.add(listener);+ return () => { listeners.delete(listener); };+}++// useSyncExternalStore requires a stable snapshot identity — returning a fresh+// object each call would loop forever, so the two fields are read separately.+const getRestoring = (): boolean => restoring;+const getNote = (): string | null => note;++export interface RestoreTeamState {+ restoring: boolean;+ /** Outcome of the last run ("restored 3 · 1 failed — …"), or null. */+ restoreNote: string | null;+ restoreTeam: () => Promise<void>;+}++/**+ * @param config used only to rebuild a spawn command for a restorable agent+ * persisted before the `command` field existed.+ */+export function useRestoreTeam(config?: HarnessConfig | null): RestoreTeamState {+ const isRestoring = useSyncExternalStore(subscribe, getRestoring, getRestoring);+ const restoreNote = useSyncExternalStore(subscribe, getNote, getNote);++ /** Respawn every worker from the previous session with its ORIGINAL agent id,+ * cwd, model and command — the hive workspace (memory.md, inbox, registry+ * entry) reattaches by itself, no memory transplant needed. */+ const restoreTeam = async (): Promise<void> => {+ if (restoring) return;+ restoring = true;+ note = null;+ emit();+ const prevSel = useStore.getState().selectedId;+ const restorableAgents = useStore.getState().restorableAgents;+ // Tally every agent's outcome so the run ALWAYS leaves a visible trace — the+ // original bug was that every failure path was console-only, so a click that+ // couldn't spawn anything looked like a dead button.+ let restored = 0;+ let alreadyLive = 0;+ const failures: string[] = [];+ try {+ // Restore every agent CONCURRENTLY. Each spawn is keyed by its own ptyId and+ // touches no cross-agent state in the renderer, and in the main process the+ // whole `pty:spawn` handler (hive registry read-modify-write included) runs+ // synchronously between awaits, so concurrent handlers can't interleave+ // mid-update. Serially this cost the sum of every agent's git probe + spawn;+ // a 6-agent team took ~6× one agent for no reason.+ await Promise.all([...restorableAgents].map(async (a) => {+ // Per-agent guard: one agent's failure (or a rejected IPC call) must NEVER+ // abort the others — an unhandled rejection here used to make the+ // entire restore a silent no-op after the first bad agent.+ try {+ const provider = inferAgentProvider(a.command, a.provider);+ const command = (a.command ?? '').trim() || (config ? buildSpawnCommand(config, a.model, provider) : '');+ if (!command || !a.cwd) {+ // No spawn recipe (an old entry persisted before `command`, with no+ // config to rebuild one). Keep it restorable and SAY why rather than+ // silently dropping it — silent removal read as "nothing happened".+ failures.push(`${a.name}: no saved command`);+ return;+ }+ const [exe, ...args] = tokenizeCommand(command);+ const ptyId = a.ptyId ?? `pty-${a.id}`;+ // An isolated agent's worktree SURVIVES an app restart on disk (it's only+ // torn down on per-tab close / mid-session exit, not on quit). So re-enter+ // that exact worktree as the cwd rather than re-isolating — `git worktree+ // add` would conflict with the existing path/branch, and re-isolating would+ // also lose the worktree's uncommitted work. cwd = the worktree means+ // resume + seedSessionTranscript land in the CORRECT checkout.+ // But the user may have manually pruned/deleted the worktree between runs —+ // gitIsRepo (git rev-parse) returns false for a missing/invalid dir, so+ // fall back to the base repo cwd rather than spawning into a dead path.+ let cwd = a.cwd;+ let worktreeGone = false;+ if (a.worktreePath) {+ if (await window.cth.gitIsRepo(a.worktreePath)) {+ cwd = a.worktreePath;+ } else {+ worktreeGone = true;+ console.warn(`[restore] worktree gone for ${a.id} (${a.worktreePath}); falling back to base repo ${a.cwd}`);+ }+ }+ const res = await window.cth.spawnPty({+ id: ptyId,+ cwd,+ command: exe,+ provider,+ args,+ cols: 100,+ rows: 30,+ // Worktree (if any) already exists on disk — cd into it, don't create a+ // new one (re-isolating would conflict on the existing path/branch and+ // lose its uncommitted work).+ isolate: false,+ // Continue the worker's prior CLI session if one was recorded — the+ // main process picks the provider's resume flag (Claude --resume,+ // agy --conversation) and for Claude reattaches the transcript. The+ // agent id is preserved across restart, so its registry entry,+ // memory.md and inbox reattach by id. No-op without a recorded session.+ resume: true,+ hive: { id: a.id, name: a.name, provider, cwd, role: a.description }+ });+ if (res.ok) {+ restored++;+ useStore.getState().addAgent({+ ...a,+ provider,+ ptyId,+ archived: false,+ status: 'idle',+ // Surface the worktree fallback on the floor card; otherwise normal.+ action: worktreeGone ? 'worktree gone — using base repo' : 'starting up',+ // The worktree is no longer on disk — drop it so this agent is treated+ // as a plain base-cwd agent going forward (a future restore won't keep+ // re-probing a dead path).+ worktreePath: worktreeGone ? undefined : a.worktreePath,+ carrying: undefined,+ currentStation: 'desk',+ recentTextTs: Date.now()+ });+ } else if ((res.error ?? '').includes('already exists')) {+ // A live PTY with this id is already running (e.g. respawned at boot or+ // by another path) — the agent isn't actually missing, so retire it from+ // the restorable list rather than reporting a phantom failure.+ alreadyLive++;+ useStore.getState().removeRestorableAgent(a.id);+ } else {+ // Leave it restorable so the user can retry — but record WHY so the+ // outcome is shown on the floor, not buried in the devtools console.+ failures.push(`${a.name}: ${res.error ?? 'spawn failed'}`);+ console.error('[restore] spawn failed for', a.id, res.error);+ }+ } catch (e) {+ failures.push(`${a.name}: ${e instanceof Error ? e.message : String(e)}`);+ console.error('[restore] error for', a.id, e);+ }+ }));+ } finally {+ // addAgent auto-selects each spawn; put the user back where they were.+ const sel = useStore.getState();+ if (prevSel && sel.agents.some((x) => x.id === prevSel)) sel.select(prevSel);+ restoring = false;+ // ALWAYS surface a result so the button can never look inert.+ const parts: string[] = [];+ if (restored) parts.push(`restored ${restored}`);+ if (alreadyLive) parts.push(`${alreadyLive} already live`);+ if (failures.length) parts.push(`${failures.length} failed — ${failures.join('; ')}`);+ note = parts.length ? parts.join(' · ') : 'nothing to restore';+ emit();+ }+ };++ return { restoring: isRestoring, restoreNote, restoreTeam };+}