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
Merge origin/main into fix/chat-turn-end-reload
reviewa2e44e76b272
diff --cc src/renderer/lib/chatLive.test.tsindex 33e228b18,8fea7a8c2..f1eb5cd83--- a/src/renderer/lib/chatLive.test.ts+++ b/src/renderer/lib/chatLive.test.ts@@@ -4,7 -4,7 +4,8 @@@ importCHAT_OPTIMISTIC_WORKING_MS,chatActivity,planLiveReload,- shouldPollScreen++ shouldPollScreen,+ turnEndReloadCarries} from './chatLive'describe('chatActivity — the status row at the end of the ⌘M thread', () => {@@@ -59,17 -59,26 +60,41 @@@ describe('planLiveReload — throttled})})+describe('turnEndReloadCarries — which turn-end reloads keep unconfirmed sends', () => {+ it('every reload but the last carries: a prompt sent as the turn ended may not be written yet', () => {+ expect(turnEndReloadCarries({ final: false, working: false })).toBe(true)+ expect(turnEndReloadCarries({ final: false, working: true })).toBe(true)+ })++ it('the last reconciles outright while idle — a send that never landed must not linger', () => {+ expect(turnEndReloadCarries({ final: true, working: false })).toBe(false)+ })++ it('…but keeps carrying if the agent is working again (that send is the turn now running)', () => {+ expect(turnEndReloadCarries({ final: true, working: true })).toBe(true)+ })+})+++ describe('shouldPollScreen — reading the pane for the agent\'s own dialogs', () => {+ const base = { readable: true, readOnly: false, remote: false, refusal: null } as const++ it('polls a local pane of a readable agent, idle or working', () => {+ expect(shouldPollScreen(base)).toBe(true)+ expect(shouldPollScreen({ ...base, refusal: 'working' })).toBe(true)+ })++ it('never polls a remote pane: every read would be a network round trip', () => {+ expect(shouldPollScreen({ ...base, remote: true })).toBe(false)+ })++ it('not for an agent whose screen we cannot read, nor a read-only transcript', () => {+ expect(shouldPollScreen({ ...base, readable: false })).toBe(false)+ expect(shouldPollScreen({ ...base, readOnly: true })).toBe(false)+ })++ it('not while a hook-reported dialog or a shell-owned pane already stands the composer down', () => {+ for (const refusal of ['dialog', 'asleep', 'paused', 'dropped', 'exited'] as const) {+ expect(shouldPollScreen({ ...base, refusal })).toBe(false)+ }+ })+ })diff --cc src/renderer/lib/chatLive.tsindex 59e243477,87c6ab75f..810ab9c9e--- a/src/renderer/lib/chatLive.ts+++ b/src/renderer/lib/chatLive.ts@@@ -22,27 -22,29 +22,50 @@@ export const CHAT_LIVE_RELOAD_MIN_MS =*/export const CHAT_OPTIMISTIC_WORKING_MS = 15_000+/**+ * Extra tail reloads after a turn ends, in ms from the working -> idle edge. Claude Code fires its+ * Stop hook (our `done`) BEFORE it appends the turn's final reply to the transcript — measured ~50 ms+ * apart — so the one reload at `done` reads the file too early, the live refresh has already+ * stopped (`planLiveReload` skips once the agent is idle), and the reply only appeared after+ * reopening the view. A fixed schedule rather than "retry until the last message is the+ * assistant's": a turn that ends on a tool call already has an assistant message last while its+ * final text is still unwritten.+ */+export const TURN_END_RELOAD_DELAYS_MS: readonly number[] = [500, 2000]++/**+ * Does a turn-end reload keep the unconfirmed sends on screen (`applyTail`'s `carryUnconfirmed`)?+ * Every reload but the LAST in the schedule does: a prompt sent right as the turn ended may not be+ * in the transcript yet. The last one reconciles outright — a send that never landed must not+ * linger — unless the agent is working again, i.e. that prompt is the turn now running.+ */+export function turnEndReloadCarries(s: { final: boolean; working: boolean }): boolean {+ return !s.final || s.working+}++ /**+ * How often an open chat view re-reads the pane's screen for the agent's own dialogs+ * (shared/agents/claude-screen.ts) — they fire no hook, so this is the only way to disable the+ * composer while one is up. One local `tmux capture-pane` per tick.+ */+ export const CHAT_SCREEN_POLL_MS = 2000++ /**+ * Should the panel poll the pane's screen? Only for an agent whose screen we can read, only for a+ * LOCAL pane (each read of an SSH or relay pane is a network round trip, every two seconds, for as+ * long as the view is open — those rely on the check at send time alone), and only while no other+ * refusal already explains the pane: a hook-reported dialog or a shell-owned pane stands the+ * composer down on its own. `working` still polls — a harness dialog can open mid-turn.+ */+ export function shouldPollScreen(s: {+ readable: boolean+ readOnly: boolean+ remote: boolean+ refusal: ChatSendRefusal+ }): boolean {+ return s.readable && !s.readOnly && !s.remote && (s.refusal === null || s.refusal === 'working')+ }+/** What the row at the end of the thread says; `null` = no row. */export type ChatActivity = 'working' | 'dialog' | nulldiff --cc src/renderer/nodes/ChatPanel.tsxindex 7efcb231e,d0afe06b2..83fc38b88--- a/src/renderer/nodes/ChatPanel.tsx+++ b/src/renderer/nodes/ChatPanel.tsx@@@ -25,10 -26,10 +26,12 @@@ import { Spinner } from '../components/import {CHAT_LIVE_RELOAD_MIN_MS,CHAT_OPTIMISTIC_WORKING_MS,+ CHAT_SCREEN_POLL_MS,+ TURN_END_RELOAD_DELAYS_MS,chatActivity,planLiveReload,- shouldPollScreen++ shouldPollScreen,+ turnEndReloadCarries} from '../lib/chatLive'import { sentCommand } from '@shared/chat-command'import { isInteractiveBuiltin } from '@shared/chat-catalog'