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(worktree): bind dialog + group bind action
enes7626677a52fe
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex f191abdd6..4b671d80a 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -52,6 +52,7 @@ import { ShortcutsPanel } from '../components/ShortcutsPanel'import { UpdateCard } from '../components/UpdateCard'import { AnnouncementBanner } from '../components/AnnouncementBanner'import { ConfirmDialog } from '../components/ConfirmDialog'+import { BindWorktreeDialog, type BindWorktreeValue } from '../components/BindWorktreeDialog'import { NotifyConsentDialog } from '../components/NotifyConsentDialog'import { ExplorerPanel } from '../components/ExplorerPanel'import { UsageIndicator } from '../components/UsageIndicator'@@ -63,6 +64,7 @@ import { useAgentNodes } from '../state/agentNodes'import { SubagentNode } from '../nodes/SubagentNode'import { LoopNode } from '../nodes/LoopNode'import type { NormalizedAgentEvent } from '@shared/agents/normalize'+import { computeWorktreePath, sanitizeWorktreeBranch } from '@shared/worktree'import {agentConfig,hasHooks,@@ -132,6 +134,8 @@ export function Canvas() {// Node to center once its project finishes loading (cross-project notification click).const pendingFocusRef = useRef<string | null>(null)const [consentOpen, setConsentOpen] = useState(false)+ // Group id awaiting a worktree bind (drives BindWorktreeDialog).+ const [bindTarget, setBindTarget] = useState<string | null>(null)const settings = useSettings((s) => s.settings)const viewportRef = useRef<Viewport>({ x: 0, y: 0, zoom: 1 })const nodesRef = useRef<CanvasNode[]>(nodes)@@ -942,6 +946,46 @@ export function Canvas() {[setNodes, markDirty])+ const groupHasWorktree = useCallback(+ (groupId: string) => !!nodesRef.current.find((n) => n.id === groupId)?.data.worktree,+ []+ )++ const bindGroupToWorktree = useCallback((groupId: string) => setBindTarget(groupId), [])++ const confirmBind = useCallback(+ async (v: BindWorktreeValue) => {+ const git = window.nodeTerminal.git+ const res = await git.worktreeAdd(v.repoPath, v.path, v.branch, v.baseRef, v.mode === 'new')+ if (!res.ok) {+ window.alert(res.message)+ return+ }+ setNodes((ns) =>+ ns.map((n) =>+ n.id === bindTarget+ ? {+ ...n,+ data: {+ ...n.data,+ worktree: {+ repoPath: v.repoPath,+ branch: v.branch,+ baseRef: v.baseRef,+ path: v.path,+ createdByApp: true+ }+ }+ }+ : n+ )+ )+ setBindTarget(null)+ markDirty()+ },+ [bindTarget, setNodes, markDirty]+ )+const toggleMarkdown = useCallback((ids: string[]) => {const set = new Set(ids)@@ -1251,10 +1295,19 @@ export function Canvas() {{ type: 'label', label: 'Group' },{ type: 'colors', onPick: (c) => setNodesColor([groupId], c) },{ type: 'separator' },+ ...(groupHasWorktree(groupId)+ ? []+ : [+ {+ label: 'Bind to worktree…',+ icon: <IconBranch />,+ onClick: () => bindGroupToWorktree(groupId)+ } as MenuItem+ ]),{ label: 'Ungroup', icon: <IconUngroup />, onClick: () => ungroup(groupId) },{ label: 'Delete (keeps nodes)', icon: <IconTrash />, danger: true, onClick: () => ungroup(groupId) }],- [setNodesColor, ungroup]+ [setNodesColor, ungroup, groupHasWorktree, bindGroupToWorktree])const onPaneContextMenu = useCallback(@@ -1820,6 +1873,19 @@ export function Canvas() {/>)}+ {bindTarget && (+ <BindWorktreeDialog+ initialRepoPath={+ (nodesRef.current.find((n) => n.id === bindTarget)?.data.cwd as string) || ''+ }+ defaultPath={(repoPath, branch) =>+ computeWorktreePath('', repoPath.split('/').pop() || 'repo', sanitizeWorktreeBranch(branch))+ }+ onConfirm={confirmBind}+ onCancel={() => setBindTarget(null)}+ />+ )}+{consentOpen && (<NotifyConsentDialogonEnable={() => {diff --git a/src/renderer/components/BindWorktreeDialog.tsx b/src/renderer/components/BindWorktreeDialog.tsxnew file mode 100644index 000000000..908d7debd--- /dev/null+++ b/src/renderer/components/BindWorktreeDialog.tsx@@ -0,0 +1,107 @@+import { useEffect, useState } from 'react'+import { createPortal } from 'react-dom'++export interface BindWorktreeValue {+ repoPath: string+ mode: 'new' | 'existing'+ branch: string+ baseRef: string+ path: string+}++interface Props {+ initialRepoPath: string+ /** Suggests an on-disk worktree path from the repo + branch. */+ defaultPath: (repoPath: string, branch: string) => string+ onConfirm: (v: BindWorktreeValue) => void+ onCancel: () => void+}++/** Modal to bind a group to a git worktree (new or existing branch). Esc cancels. */+export function BindWorktreeDialog({ initialRepoPath, defaultPath, onConfirm, onCancel }: Props) {+ const [repoPath, setRepoPath] = useState(initialRepoPath)+ const [mode, setMode] = useState<'new' | 'existing'>('new')+ const [branch, setBranch] = useState('feature/')+ const [baseRef, setBaseRef] = useState('main')+ const [path, setPath] = useState(() => defaultPath(initialRepoPath, 'feature/'))+ const [pathEdited, setPathEdited] = useState(false)++ // Keep the path in sync with the branch until the user edits it by hand.+ useEffect(() => {+ if (!pathEdited) setPath(defaultPath(repoPath, branch || 'work'))+ }, [repoPath, branch, pathEdited, defaultPath])++ useEffect(() => {+ const onKey = (e: KeyboardEvent) => {+ if (e.key === 'Escape') {+ e.preventDefault()+ onCancel()+ }+ }+ window.addEventListener('keydown', onKey)+ return () => window.removeEventListener('keydown', onKey)+ }, [onCancel])++ const valid = !!repoPath.trim() && !!branch.trim() && !!path.trim()++ return createPortal(+ <div className="confirm-overlay" onClick={onCancel}>+ <div className="confirm bind-dialog" onClick={(e) => e.stopPropagation()}>+ <p className="confirm__msg">Bind group to worktree</p>+ <label className="bind-field">+ Repo+ <input value={repoPath} onChange={(e) => setRepoPath(e.target.value)} />+ </label>+ <div className="bind-mode">+ <label>+ <input type="radio" checked={mode === 'new'} onChange={() => setMode('new')} /> New branch+ </label>+ <label>+ <input type="radio" checked={mode === 'existing'} onChange={() => setMode('existing')} /> Existing branch+ </label>+ </div>+ <label className="bind-field">+ Branch+ <input value={branch} onChange={(e) => setBranch(e.target.value)} />+ </label>+ {mode === 'new' && (+ <label className="bind-field">+ Base+ <input value={baseRef} onChange={(e) => setBaseRef(e.target.value)} />+ </label>+ )}+ <label className="bind-field">+ Worktree path+ <input+ value={path}+ onChange={(e) => {+ setPath(e.target.value)+ setPathEdited(true)+ }}+ />+ </label>+ <div className="confirm__actions">+ <button className="confirm__btn" onClick={onCancel}>+ Cancel+ </button>+ <button+ className="confirm__btn primary"+ disabled={!valid}+ onClick={() =>+ onConfirm({+ repoPath: repoPath.trim(),+ mode,+ branch: branch.trim(),+ baseRef: baseRef.trim(),+ path: path.trim()+ })+ }+ >+ Bind+ </button>+ </div>+ </div>+ </div>,+ document.body+ )+}diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 468a6d343..732d0634f 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -2589,6 +2589,54 @@ body,padding: 18px;}+/* ---- Bind-to-worktree dialog (reuses .confirm shell) ---- */+.confirm.bind-dialog {+ width: 420px;+}++.bind-field {+ display: flex;+ flex-direction: column;+ gap: 5px;+ margin: 0 0 12px;+ font-size: 12px;+ color: var(--muted);+}++.bind-field input {+ background: var(--panel-header);+ border: 1px solid var(--border);+ border-radius: 8px;+ color: var(--text);+ font-size: 13px;+ padding: 7px 10px;+}++.bind-field input:focus {+ outline: none;+ border-color: var(--accent);+}++.bind-mode {+ display: flex;+ gap: 18px;+ margin: 0 0 12px;+ font-size: 13px;+ color: var(--text);+}++.bind-mode label {+ display: flex;+ align-items: center;+ gap: 6px;+ cursor: pointer;+}++.confirm__btn:disabled {+ opacity: 0.45;+ cursor: not-allowed;+}+/* ---- Notification consent dialog (polished, icon + title + actions) ---- */.consent-overlay {position: fixed;