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.

perf(ssh): reset the codex remote tail backoff on every hook

enesa3bbda1efb0e
diff --git a/src/core/remote-ssh/codex-context.test.ts b/src/core/remote-ssh/codex-context.test.ts
index 2bce6fc0a..f76905346 100644
--- a/src/core/remote-ssh/codex-context.test.ts
+++ b/src/core/remote-ssh/codex-context.test.ts
@@ -93,6 +93,20 @@ describe('remote Codex context routing', () => {
expect(h.run).not.toHaveBeenCalled()
})
+ it('a later hook for an already-tracked path pokes the tail again without a new lookup', async () => {
+ // The tail's same-ref track() is what resets its idle poll backoff — every hook must reach it.
+ const h = harness()
+ await h.controller.hook('node', payload)
+ expect(h.tail.track).toHaveBeenCalledTimes(1)
+ const ref = h.tail.track.mock.calls[0][1]
+ await h.controller.hook('node', { ...payload, hook_event_name: 'UserPromptSubmit' })
+ expect(h.run).toHaveBeenCalledTimes(1)
+ expect(h.tail.track).toHaveBeenCalledTimes(2)
+ expect(h.tail.track).toHaveBeenLastCalledWith(JSON.stringify(['node', sid]), ref)
+ expect(h.tail.untrack).not.toHaveBeenCalled()
+ expect(h.tail.replay).not.toHaveBeenCalled()
+ })
+
it('ignores child rollouts, rejects stale in-flight generations and clears SessionEnd', async () => {
const h = harness()
await h.controller.hook('node', { ...payload, agent_id: 'child' })
diff --git a/src/core/remote-ssh/codex-context.ts b/src/core/remote-ssh/codex-context.ts
index 1ab0cdf3d..2de96130f 100644
--- a/src/core/remote-ssh/codex-context.ts
+++ b/src/core/remote-ssh/codex-context.ts
@@ -99,7 +99,12 @@ export function createRemoteCodexContext(deps: RemoteCodexContextDeps) {
bindings.set(nodeId, binding)
deps.onClear?.(nodeId, sessionId)
}
- if (hookPath && binding.ref?.path === hookPath) return 'tracked'
+ if (hookPath && binding.ref?.path === hookPath) {
+ // Already tracked: no lookup, but a hook means the transcript is about to grow — the tail's
+ // same-ref track() resets its idle poll backoff (it does not re-bootstrap).
+ deps.tail.track(binding.tailId, binding.ref)
+ return 'tracked'
+ }
const current = binding
const pendingKey = JSON.stringify([nodeId, key, sessionId, hookPath, current.generation])
const existing = pending.get(pendingKey)