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(ssh): an untrackable tool_use must not read as a finished turn

enes03f7a8c5d54c
diff --git a/src/core/remote-ssh/agent-resync-decide.test.ts b/src/core/remote-ssh/agent-resync-decide.test.ts
index 41a0e71c2..1696dd07e 100644
--- a/src/core/remote-ssh/agent-resync-decide.test.ts
+++ b/src/core/remote-ssh/agent-resync-decide.test.ts
@@ -52,6 +52,22 @@ describe('decideFromTranscriptTail', () => {
expect(decideFromTranscriptTail(tail)).toBe('undecided')
})
+ it('a tool_use we cannot track decides nothing — never that the turn finished', () => {
+ const tail = [
+ assistantText('Let me check.'),
+ JSON.stringify({ type: 'assistant', message: { content: [{ type: 'tool_use', name: 'Bash' }] } })
+ ].join('\n')
+ expect(decideFromTranscriptTail(tail)).toBe('undecided')
+ })
+
+ it('a tool_use alongside text in the same message still counts as an open call', () => {
+ const tail = JSON.stringify({
+ type: 'assistant',
+ message: { content: [{ type: 'text', text: 'Running it.' }, { type: 'tool_use', id: 't3', name: 'Bash' }] }
+ })
+ expect(decideFromTranscriptTail(tail)).toBe('working')
+ })
+
it('an empty or unparseable tail decides nothing', () => {
expect(decideFromTranscriptTail('')).toBe('undecided')
expect(decideFromTranscriptTail('not json at all')).toBe('undecided')
@@ -63,6 +79,10 @@ describe('decideNode', () => {
expect(decideNode('zsh', null)).toBe('ended')
})
+ it('a shell in the pane beats a transcript that still looks busy — the CLI is gone either way', () => {
+ expect(decideNode('zsh', assistantToolUse('t1', 'Bash'))).toBe('ended')
+ })
+
it('falls through to the transcript when the CLI still owns the pane', () => {
expect(decideNode('claude', assistantText('Finished.'))).toBe('ended')
expect(decideNode('claude', assistantToolUse('t1', 'Bash'))).toBe('working')
diff --git a/src/core/remote-ssh/agent-resync-decide.ts b/src/core/remote-ssh/agent-resync-decide.ts
index 49b2ef598..7ce096319 100644
--- a/src/core/remote-ssh/agent-resync-decide.ts
+++ b/src/core/remote-ssh/agent-resync-decide.ts
@@ -50,9 +50,12 @@ export function decideFromTranscriptTail(tail: string): ResyncVerdict {
if (rec?.type === 'assistant' && Array.isArray(content)) {
let sawTool = false
for (const c of content as { type?: string; id?: string }[]) {
- if (c?.type === 'tool_use' && typeof c.id === 'string') {
- pending.add(c.id)
+ if (c?.type === 'tool_use') {
+ // Seeing the call is what makes this a tool turn; tracking its id is a separate, weaker
+ // claim. An id we cannot read leaves the call untrackable, so the record must still read
+ // as 'assistant-tool' (⇒ undecided) rather than decaying into a finished turn.
sawTool = true
+ if (typeof c.id === 'string') pending.add(c.id)
}
}
last = sawTool ? 'assistant-tool' : 'assistant-text'