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(chat): keep retrying an unbound held request with no card on screen

reviewcd61c939ff17
diff --git a/CLAUDE.md b/CLAUDE.md
index 7b0178f05..1b4cdd7fa 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -2580,10 +2580,14 @@ command-bearing opens; this does not add a human-confirm dialog or change mobile
is answerable. A held change forces a tail reload (queued behind a read in flight, which started
under A and cannot bind B, and behind an older-page fetch, which it never cancels). It is a QUIET
read (no "Loading…"), and one path owns it: on working → blocked the turn-end reload does. While a
- card says "Updating…" it retries with backoff (`rebindRetryDelay`: 2 s doubling to 30 s, reset per
- request). A read under B that still shows the card A was bound to (same tool id / line offset —
+ request is unbound it retries with backoff (`rebindRetryDelay`: 2 s doubling to 30 s, reset per
+ request) — card on screen or not; it stops once a read under the new request lands. A read under B that still shows the card A was bound to (same tool id / line offset —
the transcript can lag the hook) stays "Updating…": B must surface on a card the thread shows as
new. The answer payload carries the BOUND id, re-checked against store and binding at send time.
+ Residuals: the previous-card memory is per MOUNT (a panel opened fresh under B has none, so it
+ binds B to the latest matching card); a re-issued ticket for the SAME tool_use (duplicate hooks)
+ stays "Updating…" and is answered in the terminal; and the whole guarantee assumes Claude writes
+ the tool_use to the transcript before the hook fires.
**The thread look (2026-09-26, claude.ai-style)**: the user's message is a neutral rounded bubble
on the right (`term-chat__bubble`, a tint lift — never the blue accent), the assistant's is plain
full-width text with no bubble. One quiet action row per assistant TURN (`lib/chatThread.ts`
diff --git a/docs/hook-reply-approvals.md b/docs/hook-reply-approvals.md
index b5289be7f..51f26fc09 100644
--- a/docs/hook-reply-approvals.md
+++ b/docs/hook-reply-approvals.md
@@ -170,10 +170,15 @@ held ticket at the start of the last applied tail read. While the hook moves hel
card can still be on screen with no result; matched by tool name alone it would approve B. So a
request the thread was not read for gets no controls — the latest unanswered card of its tool shows
"Updating… — or answer in the terminal" — and the panel forces a quiet tail reload (queued behind a
-read or an older-page fetch in flight; retried with 2 s → 30 s backoff while a card says "Updating…").
+read or an older-page fetch in flight; retried with 2 s → 30 s backoff until a read under the new
+request lands, whether or not a card is on screen to say "Updating…").
A read under B that still shows the very card A was bound to does not bind B either: the transcript
can lag the hook, and a new request must surface on a card the thread shows as new. The answer
payload names the bound id, re-checked against both the store and the binding at send time.
+Residuals: the previous-card memory lives per panel mount, so a panel opened fresh under B binds B to
+the latest matching card; a re-issued ticket for the same tool_use (duplicate hooks) stays
+"Updating…" and must be answered in the terminal; and the guarantee assumes Claude writes the
+tool_use to the transcript before the hook fires.
**Surfaces.** Desktop: local + SSH (ControlMaster read + stdin write). Server Edition: local projects
(SSH projects remain unsupported there, as before). Relay: unchanged. Mobile: keeps writing
diff --git a/src/renderer/nodes/ChatPanel.answerBind.test.tsx b/src/renderer/nodes/ChatPanel.answerBind.test.tsx
index 73f286d39..9e43eb875 100644
--- a/src/renderer/nodes/ChatPanel.answerBind.test.tsx
+++ b/src/renderer/nodes/ChatPanel.answerBind.test.tsx
@@ -243,15 +243,31 @@ describe('answer card binding', () => {
expect(pending).toHaveLength(7)
})
- it('no retry when there is no card to update (nothing on screen would change)', async () => {
+ it('with no card on screen (A answered), a failed reload still retries — quietly, with backoff — until B lands', async () => {
+ const ANSWERED = [planMsg(0, 'Plan A', 'User approved')]
await hold(A)
await render()
- await settle(0, [planMsg(0, 'Plan A', 'User rejected')])
+ await settle(0, ANSWERED)
await hold(B)
- expect(pending).toHaveLength(2) // the one forced reload on the change
+ expect(pending).toHaveLength(2) // the forced reload on the change
+ expect(updatingOn()).toEqual([]) // no card to say "Updating…" on
await fail(1)
+ await advance(CHAT_ANSWER_REBIND_RETRY_MS)
+ expect(pending).toHaveLength(3)
+ await fail(2)
+ await advance(CHAT_ANSWER_REBIND_RETRY_MS) // backed off: the next one waits 4 s
+ expect(pending).toHaveLength(3)
+ await advance(CHAT_ANSWER_REBIND_RETRY_MS)
+ expect(pending).toHaveLength(4)
+ // Silent throughout: the answered thread stays, no "Loading…", no error line.
+ expect(host.textContent).toContain('Plan A')
+ expect(host.textContent).not.toContain('Loading conversation')
+ expect(host.textContent).not.toContain("Couldn't read")
+ // B's card lands: bound, and the retries stop.
+ await settle(3, [...ANSWERED, planMsg(10, 'Plan B')])
+ expect(controlsOn()).toEqual([1])
await advance(CHAT_ANSWER_REBIND_RETRY_MAX_MS * 2)
- expect(pending).toHaveLength(2)
+ expect(pending).toHaveLength(4)
})
it('the rebind reload never cancels an older-page fetch: it waits for it, and the page lands', async () => {
diff --git a/src/renderer/nodes/ChatPanel.tsx b/src/renderer/nodes/ChatPanel.tsx
index 685748a10..4c23640ca 100644
--- a/src/renderer/nodes/ChatPanel.tsx
+++ b/src/renderer/nodes/ChatPanel.tsx
@@ -253,6 +253,7 @@ export function ChatPanel({
// PREVIOUS request and cannot bind the new one. Any read that STARTS later satisfies it.
const heldReloadQueuedRef = useRef(false)
const loadRef = useRef<(live?: boolean, rebind?: boolean) => void>(() => {})
+ const requestHeldReloadRef = useRef<() => void>(() => {})
// `live` = a read driven by a hook event while the agent works (see `attemptLive`), as opposed to
// the first open, the turn-end reload and ↻. A live read is background refresh: it keeps
@@ -365,8 +366,10 @@ export function ChatPanel({
// has landed (microtask: after its setThread below).
if (heldReloadQueuedRef.current) {
heldReloadQueuedRef.current = false
+ // Through the one entry point: a tail read that started meanwhile (and so already captured
+ // the new request) is queued behind, never superseded.
queueMicrotask(() => {
- if (rebindForRef.current !== null) loadRef.current(false, true)
+ if (rebindForRef.current !== null) requestHeldReloadRef.current()
})
}
}
@@ -410,6 +413,7 @@ export function ChatPanel({
if (tailInFlightRef.current || olderInFlightRef.current) heldReloadQueuedRef.current = true
else loadRef.current(false, true)
}, [])
+ requestHeldReloadRef.current = requestHeldReload
// Retries back off (`rebindRetryDelay`), counted per held request: a new one starts over.
const rebindAttemptRef = useRef(0)
useEffect(() => {
@@ -420,16 +424,16 @@ export function ChatPanel({
}, [rebindFor, requestHeldReload]) // eslint-disable-line react-hooks/exhaustive-deps -- `state` is read, not a trigger
// …and while a card stays on "Updating…" with no read in flight (the reload failed, or the
// transcript has not caught up), try again: nothing else reads the tail while the agent is
- // blocked. Only while there IS a card saying so — with none, a reload changes nothing on screen.
- const hasUpdatingCard = updatingCard !== null
+ // blocked. Also with no card on screen (A answered, B's card not read yet): the reload is quiet,
+ // backs off, and stops by itself once a read under the new request lands.
useEffect(() => {
- if (rebindFor === null || tailLoading || !hasUpdatingCard) return
+ if (rebindFor === null || tailLoading) return
const t = setTimeout(() => {
rebindAttemptRef.current++
requestHeldReload()
}, rebindRetryDelay(rebindAttemptRef.current))
return () => clearTimeout(t)
- }, [rebindFor, tailLoading, hasUpdatingCard, requestHeldReload])
+ }, [rebindFor, tailLoading, requestHeldReload])
// Invalidate any in-flight read when the panel goes away.
useEffect(