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.

fix(git): route commit history through the ssh-aware executor — it never worked on SSH projects

enesac16b66bc997
diff --git a/src/core/git-service.ts b/src/core/git-service.ts
index 006854a02..0509936ef 100644
--- a/src/core/git-service.ts
+++ b/src/core/git-service.ts
@@ -465,11 +465,16 @@ export class GitService {
if (!cwd) {
return { items: [], hasIncomingChanges: false, hasOutgoingChanges: false, hasMore: false, limit: opts.limit ?? 50 }
}
- // Adapt the shared executor (throws on failure) onto our env-configured git runner.
+ // Adapt the shared executor (throws on failure) onto the ssh-routing `git()` runner — NOT a
+ // direct local `run('git', …)`: for an SSH project the scope cwd is a REMOTE path, and local
+ // git against it fails every history load (or, if the path happens to exist here, serves the
+ // wrong machine's history). `git()` returns {ok,…} instead of throwing, so re-raise on !ok —
+ // the loader's per-probe catches (upstream ref, merge-base, …) rely on failures throwing.
return loadGitHistoryFromExecutor(
async (args, dir) => {
- const { stdout } = await run('git', args, { cwd: dir, env: GIT_ENV, maxBuffer: 50 * 1024 * 1024 })
- return { stdout }
+ const r = await git(dir, args)
+ if (!r.ok) throw new Error(r.err || `git ${args[0] ?? ''} failed`)
+ return { stdout: r.out }
},
cwd,
opts
diff --git a/src/core/git-service.worktree-remote.test.ts b/src/core/git-service.worktree-remote.test.ts
index 09285c8bc..4534163a3 100644
--- a/src/core/git-service.worktree-remote.test.ts
+++ b/src/core/git-service.worktree-remote.test.ts
@@ -107,3 +107,24 @@ describe('worktree ops on a REMOTE repo', () => {
expect(listed.entries.map((e) => e.path)).toEqual([repo])
})
})
+
+// history() was the ONE GitService op that bypassed the ssh-routing `git()` executor and ran
+// LOCAL git directly against the scope cwd. For an SSH project that cwd is a REMOTE path, so the
+// panel's commit history always failed ("Failed to load history") — and, worse in principle, a
+// remote path that happens to exist locally would have served the WRONG machine's history.
+describe('history routing', () => {
+ it('a LOCAL repo lists its commits (the guard must not swallow the local path)', async () => {
+ const r = await svc.history(repo)
+ expect(r.items.map((i) => i.subject)).toContain('init')
+ })
+
+ it('a remote-claimed repo never gets LOCAL git run against its (remote) path', async () => {
+ claimAsRemote(repo) // bogus master socket → the remote git fails
+ // The invariant is "the local repo's commits are never served as if they were the host's".
+ // With every remote call failing, the loader lands on its empty result (or throws) — either
+ // reads as a failed load; what it must NOT contain is the LOCAL repo's history.
+ const r = await svc.history(repo).catch(() => ({ items: [] }))
+ expect(r.items.map((i) => i.subject)).not.toContain('init')
+ expect(r.items).toHaveLength(0)
+ })
+})