Skip to content

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.

Merge worktree-group-worktree: worktree-backed groups

enes6a1f2d791022
diff --cc src/main/git-service.ts
index c8270a99d,f22db98b4..105771312
--- a/src/main/git-service.ts
+++ b/src/main/git-service.ts
@@@ -177,25 -179,33 +179,52 @@@ export class GitService
ipcMain.handle(IPC.gitRemoteCommitUrl, (_e, cwd: string, sha: string) =>
this.remoteCommitUrl(cwd, sha)
)
+ ipcMain.handle(IPC.gitMerge, (_e, cwd: string, ref: string) => this.merge(cwd, ref))
+ ipcMain.handle(IPC.gitRebase, (_e, cwd: string, onto: string) => this.rebase(cwd, onto))
+ ipcMain.handle(IPC.gitDeleteBranch, (_e, cwd: string, name: string, force: boolean) =>
+ this.deleteBranch(cwd, name, force)
+ )
+ ipcMain.handle(IPC.gitRenameBranch, (_e, cwd: string, newName: string) =>
+ this.renameBranch(cwd, newName)
+ )
+ ipcMain.handle(IPC.gitFetch, (_e, cwd: string) => this.fetch(cwd))
+ ipcMain.handle(IPC.gitForcePush, (_e, cwd: string) => this.forcePush(cwd))
+ ipcMain.handle(IPC.gitStashPush, (_e, cwd: string) => this.stashPush(cwd))
+ ipcMain.handle(IPC.gitStashPop, (_e, cwd: string) => this.stashPop(cwd))
+ ipcMain.handle(IPC.gitRevert, (_e, cwd: string, oid: string) => this.revert(cwd, oid))
+ ipcMain.handle(IPC.gitBranchAt, (_e, cwd: string, name: string, oid: string) =>
+ this.branchAt(cwd, name, oid)
+ )
+ ipcMain.handle(IPC.gitCheckoutCommit, (_e, cwd: string, oid: string) =>
+ this.checkoutCommit(cwd, oid)
+ )
+ ipcMain.handle(IPC.gitRepoRoot, (_e, cwd: string) => this.repoRoot(cwd))
+ ipcMain.handle(IPC.gitWorktreeList, (_e, repoPath: string) => this.worktreeList(repoPath))
+ ipcMain.handle(IPC.gitWorktreeAdd, (_e, repoPath: string, wtPath: string, branch: string, baseRef: string, isNew: boolean) =>
+ this.worktreeAdd(repoPath, wtPath, branch, baseRef, isNew)
+ )
+ ipcMain.handle(IPC.gitWorktreeMerge, (_e, repoPath: string, branch: string, baseRef: string) =>
+ this.worktreeMerge(repoPath, branch, baseRef)
+ )
+ ipcMain.handle(IPC.gitWorktreeRemove, (_e, repoPath: string, wtPath: string, deleteBranch: boolean) =>
+ this.worktreeRemove(repoPath, wtPath, deleteBranch)
+ )
+ }
+
+ repoRoot(cwd: string) {
+ return worktreeOps.repoRoot(git, cwd)
+ }
+ worktreeList(repoPath: string) {
+ return worktreeOps.worktreeList(git, repoPath)
+ }
+ worktreeAdd(repoPath: string, wtPath: string, branch: string, baseRef: string, isNew: boolean) {
+ return worktreeOps.worktreeAdd(git, repoPath, wtPath, branch, baseRef, isNew)
+ }
+ worktreeMerge(repoPath: string, branch: string, baseRef: string) {
+ return worktreeOps.worktreeMerge(git, repoPath, branch, baseRef)
+ }
+ worktreeRemove(repoPath: string, wtPath: string, deleteBranch: boolean) {
+ return worktreeOps.worktreeRemove(git, repoPath, wtPath, os.homedir(), deleteBranch)
}
async status(cwd: string): Promise<GitStatus> {
diff --cc src/preload/index.ts
index 2e52d2eea,193c28d2e..a458d8ca4
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@@ -100,17 -95,14 +100,25 @@@ const api: NodeTerminalApi =
history: (cwd, options) => ipcRenderer.invoke(IPC.gitHistory, cwd, options),
commitFiles: (cwd, oid) => ipcRenderer.invoke(IPC.gitCommitFiles, cwd, oid),
remoteCommitUrl: (cwd, sha) => ipcRenderer.invoke(IPC.gitRemoteCommitUrl, cwd, sha),
+ merge: (cwd, ref) => ipcRenderer.invoke(IPC.gitMerge, cwd, ref),
+ rebase: (cwd, onto) => ipcRenderer.invoke(IPC.gitRebase, cwd, onto),
+ deleteBranch: (cwd, name, force) => ipcRenderer.invoke(IPC.gitDeleteBranch, cwd, name, force),
+ renameBranch: (cwd, newName) => ipcRenderer.invoke(IPC.gitRenameBranch, cwd, newName),
+ fetch: (cwd) => ipcRenderer.invoke(IPC.gitFetch, cwd),
+ forcePush: (cwd) => ipcRenderer.invoke(IPC.gitForcePush, cwd),
+ stashPush: (cwd) => ipcRenderer.invoke(IPC.gitStashPush, cwd),
+ stashPop: (cwd) => ipcRenderer.invoke(IPC.gitStashPop, cwd),
+ revert: (cwd, oid) => ipcRenderer.invoke(IPC.gitRevert, cwd, oid),
+ branchAt: (cwd, name, oid) => ipcRenderer.invoke(IPC.gitBranchAt, cwd, name, oid),
- checkoutCommit: (cwd, oid) => ipcRenderer.invoke(IPC.gitCheckoutCommit, cwd, oid)
++ checkoutCommit: (cwd, oid) => ipcRenderer.invoke(IPC.gitCheckoutCommit, cwd, oid),
+ repoRoot: (cwd) => ipcRenderer.invoke(IPC.gitRepoRoot, cwd),
+ worktreeList: (repoPath) => ipcRenderer.invoke(IPC.gitWorktreeList, repoPath),
+ worktreeAdd: (repoPath, wtPath, branch, baseRef, isNew) =>
+ ipcRenderer.invoke(IPC.gitWorktreeAdd, repoPath, wtPath, branch, baseRef, isNew),
+ worktreeMerge: (repoPath, branch, baseRef) =>
+ ipcRenderer.invoke(IPC.gitWorktreeMerge, repoPath, branch, baseRef),
+ worktreeRemove: (repoPath, wtPath, deleteBranch) =>
+ ipcRenderer.invoke(IPC.gitWorktreeRemove, repoPath, wtPath, deleteBranch)
},
clipboard: {
writeText: (text: string) => clipboard.writeText(text)
diff --cc src/renderer/canvas/Canvas.tsx
index 7fcf97072,41428a23e..c769d686c
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@@ -53,12 -52,9 +53,13 @@@ import { ShortcutsPanel } from '../comp
import { UpdateCard } from '../components/UpdateCard'
import { AnnouncementBanner } from '../components/AnnouncementBanner'
import { ConfirmDialog } from '../components/ConfirmDialog'
+import { UpgradeDialog } from '../components/UpgradeDialog'
+import { RemotePicker } from '../components/RemotePicker'
+ import { BindWorktreeDialog, type BindWorktreeValue } from '../components/BindWorktreeDialog'
import { NotifyConsentDialog } from '../components/NotifyConsentDialog'
import { ExplorerPanel } from '../components/ExplorerPanel'
+import { SessionsSidebar } from '../components/SessionsSidebar'
+import type { SessionNodeInput } from '../lib/sessionList'
import { UsageIndicator } from '../components/UsageIndicator'
import { RemoteSessionView } from './RemoteSessionView'
import { transport } from '../terminal/local-transport'
@@@ -920,34 -820,17 +951,37 @@@ export function Canvas()
)
const addAgentNode = useCallback(
- (agentId: AgentId, center?: { x: number; y: number }) => {
- const cwd = useProjects.getState().getProject(activeProjectId)?.cwd
- setNodes((ns) => [...ns, createAgentNode(agentId, ns.length, cwd, center ?? viewCenter())])
+ (agentId: AgentId, center?: { x: number; y: number }, groupId?: string) => {
+ const cwd = cwdForNewNodeIn(groupId) ?? useProjects.getState().getProject(activeProjectId)?.cwd
+ setNodes((ns) => {
+ const node = createAgentNode(agentId, ns.length, cwd, center ?? viewCenter())
+ return [...ns, groupId ? parentInto(node, groupId) : node]
+ })
markDirty()
},
- [setNodes, markDirty, activeProjectId, viewCenter]
+ [setNodes, markDirty, activeProjectId, viewCenter, cwdForNewNodeIn, parentInto]
)
+ // Open a terminal node that ssh's into a saved server. `screenPos` (a pane/dock cursor) is
+ // converted to a flow position; otherwise the node lands at the view center. The new node is
+ // selected (and others deselected) so it's the active focus right away.
+ const addSshTerminal = useCallback(
+ (server: SshServer, screenPos?: { x: number; y: number }) => {
+ const at = screenPos ? screenToFlowPosition(screenPos) : viewCenter()
+ setNodes((ns) => [
+ ...ns.map((n) => ({ ...n, selected: false })),
+ { ...createSshTerminalNode(server, ns.length, at), selected: true }
+ ])
+ markDirty()
+ },
+ [setNodes, markDirty, screenToFlowPosition, viewCenter]
+ )
+
+ // Pro-gated entry to the SSH server picker: free users get the upgrade dialog instead.
+ const openRemotePicker = useCallback((screenPos: { x: number; y: number }) => {
+ requireProOr('Remote SSH terminals', () => setRemotePicker(screenPos))
+ }, [])
+
// ⌘T = new terminal, ⌘⇧C = new default agent (ignored while typing in a field/terminal).
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
@@@ -2141,18 -2034,41 +2355,53 @@@
/>
)}
+ <UpgradeDialog />
+
+ {remotePicker && (
+ <RemotePicker
+ x={remotePicker.x}
+ y={remotePicker.y}
+ onPick={(srv) => addSshTerminal(srv, { x: remotePicker.x, y: remotePicker.y })}
+ onManage={() => setSettingsOpen(true)}
+ onClose={() => setRemotePicker(null)}
+ />
+ )}
+
+ {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)}
+ />
+ )}
+
+ {moveTarget && (
+ <ConfirmDialog
+ message="Move this terminal into the worktree? Its session restarts and any running process ends."
+ confirmLabel="Move"
+ danger={false}
+ onConfirm={confirmMoveIntoWorktree}
+ onCancel={() => setMoveTarget(null)}
+ />
+ )}
+
+ {removeTarget && (
+ <ConfirmDialog
+ message={`Remove this worktree and delete its branch?${
+ removeTarget.warning ? '\n\n⚠ ' + removeTarget.warning : ''
+ }`}
+ confirmLabel="Remove"
+ danger
+ onConfirm={confirmRemoveWorktree}
+ onCancel={() => setRemoveTarget(null)}
+ />
+ )}
+
{consentOpen && (
<NotifyConsentDialog
onEnable={() => {
diff --cc src/renderer/state/workspace.ts
index fa850cfe9,404b58491..744b26b36
--- a/src/renderer/state/workspace.ts
+++ b/src/renderer/state/workspace.ts
@@@ -472,7 -442,7 +480,8 @@@ export function nodeStatesToFlow(states
diffStaged: n.diffStaged,
commitOid: n.commitOid,
agentId,
- ssh: n.ssh
++ ssh: n.ssh,
+ worktree: n.worktree
}
}
})
@@@ -521,7 -491,7 +530,8 @@@ export function flowToNodeStates(nodes
diffStaged: n.data.diffStaged,
commitOid: n.data.commitOid,
agentId: n.data.agentId,
- ssh: n.data.ssh
++ ssh: n.data.ssh,
+ worktree: n.data.worktree
}
})
}
diff --cc src/shared/ipc.ts
index ac27b61b6,5e76f8835..c91dc5c16
--- a/src/shared/ipc.ts
+++ b/src/shared/ipc.ts
@@@ -80,17 -76,11 +80,22 @@@ export const IPC =
gitHistory: 'git:history',
gitCommitFiles: 'git:commit-files',
gitRemoteCommitUrl: 'git:remote-commit-url',
+ gitMerge: 'git:merge',
+ gitRebase: 'git:rebase',
+ gitDeleteBranch: 'git:delete-branch',
+ gitRenameBranch: 'git:rename-branch',
+ gitFetch: 'git:fetch',
+ gitForcePush: 'git:force-push',
+ gitStashPush: 'git:stash-push',
+ gitStashPop: 'git:stash-pop',
+ gitRevert: 'git:revert',
+ gitBranchAt: 'git:branch-at',
+ gitCheckoutCommit: 'git:checkout-commit',
+ gitRepoRoot: 'git:repo-root',
+ gitWorktreeList: 'git:worktree-list',
+ gitWorktreeAdd: 'git:worktree-add',
+ gitWorktreeMerge: 'git:worktree-merge',
+ gitWorktreeRemove: 'git:worktree-remove',
shellOpenExternal: 'shell:open-external',
commitGenerate: 'commit:generate',
remoteHostStart: 'remote:host:start',
diff --cc src/shared/types.ts
index 3e1e51f4c,a68fb9bda..512a49e6b
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@@ -351,28 -339,11 +354,33 @@@ export interface GitApi
commitFiles(cwd: string, oid: string): Promise<GitFileChange[]>
/** Remote web URL for a commit sha, or null if it can't be derived. */
remoteCommitUrl(cwd: string, sha: string): Promise<string | null>
+ /** Merge a branch into the current branch. */
+ merge(cwd: string, ref: string): Promise<GitResult>
+ /** Rebase the current branch onto another. */
+ rebase(cwd: string, onto: string): Promise<GitResult>
+ /** Delete a branch (force = -D, for unmerged). */
+ deleteBranch(cwd: string, name: string, force: boolean): Promise<GitResult>
+ /** Rename the current branch. */
+ renameBranch(cwd: string, newName: string): Promise<GitResult>
+ /** Fetch all remotes and prune. */
+ fetch(cwd: string): Promise<GitResult>
+ /** Push with --force-with-lease. */
+ forcePush(cwd: string): Promise<GitResult>
+ /** Stash uncommitted changes (incl. untracked). */
+ stashPush(cwd: string): Promise<GitResult>
+ /** Pop the latest stash. */
+ stashPop(cwd: string): Promise<GitResult>
+ /** Revert a commit (--no-edit). */
+ revert(cwd: string, oid: string): Promise<GitResult>
+ /** Create + switch to a new branch at a commit. */
+ branchAt(cwd: string, name: string, oid: string): Promise<GitResult>
+ /** Checkout a commit (detached HEAD). */
+ checkoutCommit(cwd: string, oid: string): Promise<GitResult>
+ repoRoot(cwd: string): Promise<string | null>
+ worktreeList(repoPath: string): Promise<import('./worktree').WorktreeEntry[]>
+ worktreeAdd(repoPath: string, wtPath: string, branch: string, baseRef: string, isNew: boolean): Promise<GitResult>
+ worktreeMerge(repoPath: string, branch: string, baseRef: string): Promise<GitResult>
+ worktreeRemove(repoPath: string, wtPath: string, deleteBranch: boolean): Promise<GitResult>
}
export interface UpdateInfo {