Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(scm): persist commit-message draft + AI generation across panel close
enes00a44e03199f
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 229a4d950..d1c19ed68 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -618,23 +618,26 @@ export function Canvas() {}}, [])- // Pinch-zoom (trackpad / ctrl+wheel) must keep working even over a focused terminal, which- // carries `nowheel` so plain scroll stays inside xterm. React Flow ignores wheel over a- // nowheel element, so we zoom-to-cursor manually there; on open canvas React Flow handles it.+ // Zoom on Cmd/Ctrl+wheel and trackpad pinch (ctrl+wheel), handled in one capture-phase+ // listener for the whole canvas — so it works on the open canvas, over a selected node, and+ // even over a *focused* terminal (whose `nowheel` would otherwise route the wheel into xterm+ // scrollback). We intercept (preventDefault + stopPropagation) before xterm sees it, then+ // zoom to the cursor. React Flow's own zoomOnPinch / zoomActivationKeyCode are disabled so+ // this is the single source of zoom (no double-zoom on the open canvas).useEffect(() => {const wrap = flowWrapRef.currentif (!wrap) returnconst onWheel = (e: WheelEvent) => {- if (!e.ctrlKey) return // only the pinch gesture (browsers deliver it as ctrl+wheel)- const target = e.target as Element | null- if (!target?.closest('.nowheel')) return // open canvas → leave it to React Flow+ if (!e.ctrlKey && !e.metaKey) return // pinch (ctrl+wheel) or Cmd/Ctrl+scroll = zoome.preventDefault()e.stopPropagation()const { x, y, zoom } = getViewport()const rect = wrap.getBoundingClientRect()const px = e.clientX - rect.leftconst py = e.clientY - rect.top- const next = Math.min(2, Math.max(0.2, zoom * Math.exp(-e.deltaY * 0.01)))+ // Cap a single event's influence so a chunky mouse-wheel tick doesn't jump zoom levels.+ const d = Math.max(-50, Math.min(50, e.deltaY))+ const next = Math.min(2, Math.max(0.2, zoom * Math.exp(-d * 0.01)))if (next === zoom) returnconst k = next / zoomsetViewport({ x: px - (px - x) * k, y: py - (py - y) * k, zoom: next })@@ -1683,7 +1686,8 @@ export function Canvas() {panOnDrag={[1]}panOnScrollzoomOnScroll={false}- zoomOnPinch+ zoomOnPinch={false}+ zoomActivationKeyCode={null}snapToGrid={settings.snapToGrid}snapGrid={[settings.gridSize, settings.gridSize]}>diff --git a/src/renderer/components/SourceControlPanel.tsx b/src/renderer/components/SourceControlPanel.tsxindex f71fec4ff..d0cf80fcf 100644--- a/src/renderer/components/SourceControlPanel.tsx+++ b/src/renderer/components/SourceControlPanel.tsx@@ -3,6 +3,7 @@ import { createPortal } from 'react-dom'import type { GitFileChange, GitResult, GitStatus } from '@shared/types'import type { GitHistoryItem, GitHistoryResult } from '@shared/git-history'import { useProjects } from '../state/projects'+import { useScmDraft } from '../state/scmDraft'import { GitHistoryPanel } from './git-history/GitHistoryPanel'import { buildCommitMenuItems } from './git-history/git-history-menu'import { ContextMenu } from './ContextMenu'@@ -45,12 +46,20 @@ export function SourceControlPanel({const project = useProjects((s) => s.projects.find((p) => p.id === s.activeProjectId))const cwd = project?.cwdconst [status, setStatus] = useState<GitStatus | null>(null)- const [message, setMessage] = useState('')+ // Commit message + AI-generate state live in a per-repo store (keyed by cwd), so closing the+ // panel mid-generation neither discards the message nor abandons the run — reopening shows it.+ const draftKey = cwd ?? ''+ const message = useScmDraft((s) => s.messages[draftKey] ?? '')+ const generating = useScmDraft((s) => !!s.generating[draftKey])+ const genError = useScmDraft((s) => s.errors[draftKey] ?? '')+ const setMessage = useCallback(+ (m: string) => useScmDraft.getState().setMessage(draftKey, m),+ [draftKey]+ )const [busy, setBusy] = useState(false)const [error, setError] = useState('')const [branchMenu, setBranchMenu] = useState<{ top: number; left: number } | null>(null)const [newBranch, setNewBranch] = useState('')- const [generating, setGenerating] = useState(false)const [fileMenu, setFileMenu] = useState<{ x: number; y: number; path: string } | null>(null)const [history, setHistory] = useState<GitHistoryResult | null>(null)const [historyLoading, setHistoryLoading] = useState(false)@@ -104,14 +113,9 @@ export function SourceControlPanel({void act(() => git.discard(cwd!, f.path, f.status === 'U'))}- const generate = async () => {- setGenerating(true)- setError('')- const r = await git.generateMessage(cwd!)- setGenerating(false)- if (r.ok) setMessage(r.message)- else setError(r.message)- }+ // Runs in the store so it completes even if the panel is closed mid-generation; the result+ // (or error) is stashed per-cwd and shown when the panel reopens.+ const generate = () => useScmDraft.getState().generate(draftKey)const commitAndPush = () =>act(async () => {@@ -295,14 +299,17 @@ export function SourceControlPanel({{/* Surface git action errors (e.g. a branch switch blocked by local changes)at the top, right under the repo/branch bar, so the user sees why theaction they just triggered failed instead of missing it at the bottom. */}- {error && (+ {(error || genError) && (<div className="scm-error" role="alert">- <pre className="scm-error__msg">{error}</pre>+ <pre className="scm-error__msg">{error || genError}</pre><buttonclassName="scm-error__dismiss"title="Dismiss"aria-label="Dismiss error"- onClick={() => setError('')}+ onClick={() => {+ setError('')+ useScmDraft.getState().clearError(draftKey)+ }}>×</button>diff --git a/src/renderer/state/scmDraft.ts b/src/renderer/state/scmDraft.tsnew file mode 100644index 000000000..efbaf1bd6--- /dev/null+++ b/src/renderer/state/scmDraft.ts@@ -0,0 +1,48 @@+import { create } from 'zustand'++/**+ * Per-repo Source Control draft state — the commit message and the in-flight "generate"+ * status, keyed by the repo's cwd. Lives OUTSIDE the SourceControlPanel component so closing+ * the panel doesn't discard a typed message or abandon a running AI generation: the generate+ * action completes in the store and stashes its result, so reopening the panel shows it.+ */+interface ScmDraftState {+ messages: Record<string, string>+ generating: Record<string, boolean>+ errors: Record<string, string>+ setMessage(cwd: string, message: string): void+ clearError(cwd: string): void+ /** Generate a commit message from the staged diff (survives panel close). */+ generate(cwd: string): Promise<void>+}++export const useScmDraft = create<ScmDraftState>((set, get) => ({+ messages: {},+ generating: {},+ errors: {},++ setMessage: (cwd, message) => set((s) => ({ messages: { ...s.messages, [cwd]: message } })),+ clearError: (cwd) => set((s) => ({ errors: { ...s.errors, [cwd]: '' } })),++ generate: async (cwd) => {+ if (!cwd || get().generating[cwd]) return+ set((s) => ({+ generating: { ...s.generating, [cwd]: true },+ errors: { ...s.errors, [cwd]: '' }+ }))+ try {+ const r = await window.nodeTerminal.git.generateMessage(cwd)+ set((s) => ({+ generating: { ...s.generating, [cwd]: false },+ ...(r.ok+ ? { messages: { ...s.messages, [cwd]: r.message } }+ : { errors: { ...s.errors, [cwd]: r.message } })+ }))+ } catch (e) {+ set((s) => ({+ generating: { ...s.generating, [cwd]: false },+ errors: { ...s.errors, [cwd]: e instanceof Error ? e.message : 'Generate failed' }+ }))+ }+ }+}))diff --git a/src/renderer/terminal/useTerminalSearch.ts b/src/renderer/terminal/useTerminalSearch.tsindex 549d4b777..dda8170a1 100644--- a/src/renderer/terminal/useTerminalSearch.ts+++ b/src/renderer/terminal/useTerminalSearch.ts@@ -60,6 +60,8 @@ export function useTerminalSearch({}if (!captured) captured = readBuffer()for (const t of captured.split('\n')) lines.push({ source: 'terminal', text: t })+ // [find2] TEMP diagnostic — one line tells us which link is broken.+ console.log('[find2] searchTranscript=', searchTranscript, '| sessionId=', sessionId, '| cwd=', cwd, '| terminalLines=', lines.length)// Search the full Claude transcript for agent nodes. Resolved by sessionId when known,// else by cwd (durable) — so it works even when no live hook event set the sessionId.if (searchTranscript) {@@ -68,12 +70,15 @@ export function useTerminalSearch({sessionId,cwd)+ console.log('[find2] readTranscript ->', tr.length, 'transcript lines')for (const l of tr) {for (const t of l.text.split('\n')) lines.push({ source: 'claude', role: l.role, text: t })}- } catch {- /* terminal-only */+ } catch (e) {+ console.error('[find2] readTranscript THREW (preload/main not reloaded?):', e)}+ } else {+ console.log('[find2] transcript SKIPPED — searchTranscript is false (not an agent node?)')}if (!cancelled) setSource(lines)})()