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): adaptive remote action — Publish Branch / Push / Pull / Sync
enesb0a225882591
diff --git a/src/main/git-service.ts b/src/main/git-service.tsindex 848718c78..b8f661993 100644--- a/src/main/git-service.ts+++ b/src/main/git-service.ts@@ -158,6 +158,7 @@ export class GitService {ahead: 0,behind: 0,hasRemote: false,+ hasUpstream: false,ghAvailable: !!GH_PATH,ghAuthed: false,staged: [],@@ -173,13 +174,16 @@ export class GitService {// These reads are independent of each other; run them concurrently instead of// serially spawning ~10 git processes one after the next. (`remote get-url origin`// simply fails to empty when there's no origin, so it needn't wait on `remote`.)- const [branchR, branchesR, remotesR, originR, countsR, cachedR, workR, porcelainR, gh] =+ const [branchR, branchesR, remotesR, originR, countsR, upstreamR, cachedR, workR, porcelainR, gh] =await Promise.all([git(cwd, ['rev-parse', '--abbrev-ref', 'HEAD']),git(cwd, ['branch', '--format=%(refname:short)']),git(cwd, ['remote']),git(cwd, ['remote', 'get-url', 'origin']),git(cwd, ['rev-list', '--left-right', '--count', '@{upstream}...HEAD']),+ // Resolves only when the current branch has an upstream tracking ref —+ // distinguishes "never pushed (Publish Branch)" from "has upstream (Push/Pull/Sync)".+ git(cwd, ['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{upstream}']),git(cwd, ['diff', '--cached', '--numstat']),git(cwd, ['diff', '--numstat']),git(cwd, ['status', '--porcelain']),@@ -189,6 +193,7 @@ export class GitService {const branch = branchR.out.trim() || 'HEAD'const branches = branchesR.out.split('\n').map((b) => b.trim()).filter(Boolean)const hasRemote = !!remotesR.out.trim()+ const hasUpstream = upstreamR.ok && !!upstreamR.out.trim()const originUrl = originR.out.trim()const repoName = originUrl ? parseRepoName(originUrl, path.basename(cwd)) : path.basename(cwd)@@ -235,6 +240,7 @@ export class GitService {ahead,behind,hasRemote,+ hasUpstream,ghAvailable: !!GH_PATH,ghAuthed: gh,staged,diff --git a/src/renderer/components/SourceControlPanel.tsx b/src/renderer/components/SourceControlPanel.tsxindex 7c0ce8e22..bfa23cc97 100644--- a/src/renderer/components/SourceControlPanel.tsx+++ b/src/renderer/components/SourceControlPanel.tsx@@ -116,7 +116,9 @@ export function SourceControlPanel({const c = await git.commit(cwd!, message)if (!c.ok) return csetMessage('')- return status?.hasRemote ? git.push(cwd!) : c+ // Only auto-push when the branch already has an upstream. An unpublished+ // branch is published explicitly via the bar's "Publish Branch" action.+ return status?.hasUpstream ? git.push(cwd!) : c})const renderFiles = (list: GitFileChange[], staged: boolean) =>@@ -164,6 +166,87 @@ export function SourceControlPanel({const stagedCount = status?.staged.length ?? 0+ /**+ * The bar's primary remote action, adapting to the actual git state so the user+ * never sees a button that can't work:+ * - no remote at all → "Publish to GitHub" (create repo via gh)+ * - remote, branch unpushed → "Publish Branch" (push -u origin <branch>)+ * - upstream + ahead/behind → "Sync" / "Push" / "Pull"+ * - upstream, in sync → "Synced" (disabled)+ */+ const renderRemoteAction = () => {+ if (!status) return null+ if (!status.hasRemote) {+ return (+ <button+ className="scm-sync"+ disabled={busy || !status.ghAuthed}+ title={+ !status.ghAvailable+ ? 'GitHub CLI (gh) not found'+ : !status.ghAuthed+ ? 'Sign in to GitHub first'+ : 'Create a GitHub repo and push'+ }+ onClick={() => act(() => git.publish(cwd!, project?.name || 'repo', true))}+ >+ Publish to GitHub+ </button>+ )+ }+ if (!status.hasUpstream) {+ return (+ <button+ className="scm-sync"+ disabled={busy}+ title={`Publish ${status.branch} to origin`}+ onClick={() => act(() => git.push(cwd!))}+ >+ Publish Branch+ </button>+ )+ }+ const { ahead, behind } = status+ return (+ <>+ <span className="scm-ahead">↑{ahead}</span>+ <span className="scm-behind">↓{behind}</span>+ {ahead > 0 && behind > 0 ? (+ <button+ className="scm-sync"+ disabled={busy}+ title={`Pull ${behind}, push ${ahead}`}+ onClick={() => act(() => git.sync(cwd!))}+ >+ Sync+ </button>+ ) : behind > 0 ? (+ <button+ className="scm-sync"+ disabled={busy}+ title={`Pull ${behind} commit${behind === 1 ? '' : 's'}`}+ onClick={() => act(() => git.pull(cwd!))}+ >+ Pull+ </button>+ ) : ahead > 0 ? (+ <button+ className="scm-sync"+ disabled={busy}+ title={`Push ${ahead} commit${ahead === 1 ? '' : 's'}`}+ onClick={() => act(() => git.push(cwd!))}+ >+ Push+ </button>+ ) : (+ <button className="scm-sync" disabled title="Up to date with origin">+ Synced+ </button>+ )}+ </>+ )+ }+return createPortal(<div className="drawer-overlay" onClick={onClose}><aside className="drawer scm" onClick={(e) => e.stopPropagation()}>@@ -203,30 +286,7 @@ export function SourceControlPanel({⎇ {status.branch} ⌄</button><span className="scm-spacer" />- {status.hasRemote ? (- <>- <span className="scm-ahead">↑{status.ahead}</span>- <span className="scm-behind">↓{status.behind}</span>- <button className="scm-sync" disabled={busy} onClick={() => act(() => git.sync(cwd))}>- Sync- </button>- </>- ) : (- <button- className="scm-sync"- disabled={busy || !status.ghAuthed}- title={- !status.ghAvailable- ? 'GitHub CLI (gh) not found'- : !status.ghAuthed- ? 'Sign in to GitHub first'- : ''- }- onClick={() => act(() => git.publish(cwd, project?.name || 'repo', true))}- >- Publish- </button>- )}+ {renderRemoteAction()}</div><div className="drawer__body scm-body">@@ -293,7 +353,7 @@ export function SourceControlPanel({disabled={busy || !message.trim() || stagedCount === 0}onClick={commitAndPush}>- {status.hasRemote ? 'Commit & Push' : 'Commit'} → {status.branch}+ {status.hasUpstream ? 'Commit & Push' : 'Commit'} → {status.branch}</button></section>diff --git a/src/shared/types.ts b/src/shared/types.tsindex 18fcfb22c..b03100ea1 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -267,7 +267,10 @@ export interface GitStatus {branches: string[]ahead: numberbehind: number+ /** The repo has at least one remote (origin). */hasRemote: boolean+ /** The current branch has an upstream tracking ref (i.e. it has been published). */+ hasUpstream: booleanghAvailable: booleanghAuthed: booleanstaged: GitFileChange[]