Skip to content

Type Alias: AgentPaneCommand

agentmux


agentmux / agent-pane-state-store / AgentPaneCommand

AgentPaneCommand = { type: "InitStart"; } | { at: number; historyDamaged?: boolean; type: "InitReady"; } | { at: number; reason: string; type: "InitFailed"; } | { at: number; type: "StreamSubscribe"; } | { at: number; type: "StreamUnsubscribe"; } | { addedCount: number; at: number; turnRelevant?: boolean; type: "StreamFlushObserved"; } | { nowMs: number; type: "StreamWatchdogTick"; } | { active: boolean; at: number; type: "ReconcileTurnActive"; } | { at?: number | null; model?: string | null; reportedWindows?: ReportedContextWindows | null; tokens?: number | null; type: "ReconcileContextFromHistory"; } | { type: "ContextWindowsReported"; windows: ReportedContextWindows; } | { model?: string; tokens: number; type: "ContextReported"; window?: number; } | { reason: "fresh_session" | "transcript_replaced"; type: "ContextInvalidated"; } | { model: string; type: "ContextModelSwitched"; } | { at: number; content?: string; hidden?: boolean; type: "TurnStart"; } | { stats: SessionStats | null; type: "TurnEnd"; } | { type: "TurnReset"; } | { ledger: TurnLedger; type: "TurnObserved"; } | { type: "TurnStartFailed"; } | { arg?: string; id?: string; name: string; params?: Record<string, unknown>; parentId?: string; type: "ToolStart"; } | { id: string; text: string; type: "ToolProgress"; } | { at: number; id: string; type: "ToolOutput"; } | { text: string; type: "ThinkingHeadline"; } | { id?: string; type: "ToolEnd"; } | { cacheCreation?: number; cacheRead?: number; freshInput?: number; input: number; model?: string; type: "TokensIn"; } | { output: number; type: "TokensOut"; } | { type: "StreamSessionStarted"; } | { chars: number; kind?: "text" | "thinking" | "tool_input"; type: "OutputStreamed"; } | { type: "RequestStarted"; } | { type: "ModelEndedTurn"; } | { type: "ModelMessageStarted"; } | { at: number; type: "RequestStop"; } | { type: "StopFailed"; } | { at: number; type: "InterruptTimeoutElapsed"; } | { at: number; type: "SubmitTimeoutElapsed"; } | { at: number; attachments?: object[]; enqueuedWhileBusy: boolean; id: string; resend?: boolean; system?: boolean; text: string; type: "PendingMessageQueued"; } | { id: string; type: "PendingMessageFlushStarted"; } | { ahead: number; id: string; type: "PendingMessageWaiting"; } | { id: string; type: "PendingMessageAccepted"; } | { id: string; type: "PendingMessageRejected"; } | { id: string; type: "PendingMessageExpired"; } | { at: number; reason: "rate_limited"; retryAfterMs: number | null; type: "ProviderWaiting"; } | { at: number; failure: AgentFailure; since?: number; source?: FailureSource; turnAttempted?: boolean; type: "FailureObserved"; } | { onlyCode?: AgentFailure["code"]; reason?: FailureClearReason; type: "FailureCleared"; } | { type: "DetailsToggle"; } | { type: "DetailsExpand"; } | { type: "DetailsCollapse"; } | { at: number; trigger: "manual" | "auto"; type: "CompactionStarted"; } | { at: number; boundaryUuid?: string | null; durationMs: number; frameTimestamp?: string | null; postTokens: number; preTokens: number; trigger: "manual" | "auto"; type: "CompactionBoundary"; } | { at: number; type: "AttachedTaskObserved"; } | { type: "AttachedTaskCleared"; } | { at: number; type: "ResumeRetryStarted"; } | { type: "ResumeRetryResolved"; } | { at: number; type: "RegistryAttachedTaskObserved"; } | { type: "RegistryAttachedTaskCleared"; }

Defined in: agent-pane-state/types.ts:470

{ type: "InitStart"; }

Caller signal: history fetch began. Idempotent — if the pane is already in any terminal state (InitReady / InitFailed), InitStart is a no-op (we don’t reset back to pending).


{ at: number; historyDamaged?: boolean; type: "InitReady"; }

Caller signal: history fetch resolved successfully.


{ at: number; reason: string; type: "InitFailed"; }

Caller signal: history fetch failed; reason surfaced for diagnostics.


{ at: number; type: "StreamSubscribe"; }

Hook signal: subscription is up.


{ at: number; type: "StreamUnsubscribe"; }

Hook signal: subscription torn down.


{ addedCount: number; at: number; turnRelevant?: boolean; type: "StreamFlushObserved"; }

RAF flush observed by useAgentStream — bumps bufferSize + lastEventTime. No state change beyond those counters.

addedCount: number

at: number

optional turnRelevant?: boolean

Did this flush carry evidence the TURN is alive: document nodes, node updates, tool chunks or a new shell node? false means shell OUTPUT only, a live BACKGROUND process writing to its dock row, which says nothing about the model, so it must not refresh the turn idle clock or resurrect a finished turn. Omitted counts as true; only the flush queue knows the difference and sets this (docs/reports/REPORT_AGENT_PANE_PROGRESS_INDICATORS_CONSOLIDATION_2026_09_09.md).

type: "StreamFlushObserved"


{ nowMs: number; type: "StreamWatchdogTick"; }

Periodic tick from useAgentStream’s watchdog interval. Emits a stream-stuck diagnostic past STUCK_THRESHOLD_MS and, past the longer LIVENESS_RECOVERY_MS, force-recovers a hung Streaming turn (no tool active, not rate-limited) to Idle, clearing a stuck “Working” that never got its session_end (SPEC_WORKING_STATE_LIVENESS_MODEL_2026_06_29.md).


{ active: boolean; at: number; type: "ReconcileTurnActive"; }

Reconciliation from the backend’s turn_active (health monitor on the NDJSON stream), fetched at mount and on every controllerstatus MPS event. active: true promotes only an Idle phase to Streaming; a phase a real stream or user event already produced wins. active: false demotes only a stuck Streaming to Idle (the backend flips it only on the CLI’s result, so it is authoritative); Submitting and Interrupting have their own timeouts.


{ at?: number | null; model?: string | null; reportedWindows?: ReportedContextWindows | null; tokens?: number | null; type: "ReconcileContextFromHistory"; }

Mount-time seed of context from the history’s last main-agent API call. Seeds only while contextSeedable: a historical snapshot must never clobber real-time data. An implausible seed is refused (context-reading-rejected); tokens is absent when the window holds no main-agent call; reportedWindows merge UNDER any reported live.

optional at?: number | null

When that call was received (unix ms), if the line was stamped.

optional model?: string | null

optional reportedWindows?: ReportedContextWindows | null

optional tokens?: number | null

type: "ReconcileContextFromHistory"


{ type: "ContextWindowsReported"; windows: ReportedContextWindows; }

A result frame reported context windows (modelUsage[*].contextWindow). Recorded per model; the current reading’s window is re-resolved.


{ model?: string; tokens: number; type: "ContextReported"; window?: number; }

An agent reported how full its context is (view/agent/context-reader.ts): the meter’s reading, on model (else the last one seen), with the window it was measured against when it said. Unlike TokensIn it starts no call, so the turn’s counters are untouched.


{ reason: "fresh_session" | "transcript_replaced"; type: "ContextInvalidated"; }

The conversation the reading measured is gone (a fresh session, or the transcript archived/restored). Clears context and ends contextSeedable, so the next reading isn’t read as a compaction and a late history seed can’t bring the old conversation back.


{ model: string; type: "ContextModelSwitched"; }

The pane’s model setting changed (/model, the model menu). The conversation, and so the reading’s tokens, carry over; the window becomes unknown until the new model’s first reply reports it (model is often a family alias such as sonnet, which doesn’t say its window).


{ at: number; content?: string; hidden?: boolean; type: "TurnStart"; }

User pressed send: the turn becomes active and the previous turn’s stale sessionStats are cleared. content is the submitted text, threaded into TurnPhase.Submitting.pendingContent (optional so test call sites compile; the reducer defaults to "").

at: number

optional content?: string

optional hidden?: boolean

True for a hidden memory-reinjection turn, never set by an ordinary send. Propagated onto TurnPhase.Submitting.hidden so every ambient hook keyed off turnPhase skips its own LLM call for the turn (an ambient summary of the injected text once became the visible pane title, #3502). content for a hidden turn is also never the real message.

type: "TurnStart"


{ stats: SessionStats | null; type: "TurnEnd"; }

Stream produced session_end (or the fallback timer fired). Final stats merge with the current turn tokens, which are still there when the backend’s turn-ended push already moved the phase to Idle. Clears currentTool and turnTokens; the phase becomes Done (Interrupting → Done.stopped, otherwise Done.completed).


{ type: "TurnReset"; }

Truncate path: the doc was reset (or whatever caused the local stream-restart). Clears all per-turn state but does NOT touch pending or streaming.


{ ledger: TurnLedger; type: "TurnObserved"; }

srv published the block’s turn ledger (agentturn). An older turn’s, or an older state of this one, landing late is ignored.


{ type: "TurnStartFailed"; }

Revert an OPTIMISTIC TurnStart when the turn never began (the send’s RPC failed synchronously, or a slash/bang command was handled locally). Phase only: unlike TurnReset it must NOT touch sessionStats / sessionTotals / context, which accumulate over the pane’s lifetime (#2318).


{ arg?: string; id?: string; name: string; params?: Record<string, unknown>; parentId?: string; type: "ToolStart"; }

id: the tool_use id, so its end removes exactly it; params: its input, for the live status’s words (tool-labels.ts).


{ id: string; text: string; type: "ToolProgress"; }

A running call’s test progress, from its live output (status/test-progress.ts).


{ at: number; id: string; type: "ToolOutput"; }

A running call wrote output (at most every few seconds per call).


{ text: string; type: "ThinkingHeadline"; }

The model’s thinking block’s gist (status/thinking-headline.ts).


{ id?: string; type: "ToolEnd"; }


{ cacheCreation?: number; cacheRead?: number; freshInput?: number; input: number; model?: string; type: "TokensIn"; }


{ output: number; type: "TokensOut"; }


{ type: "StreamSessionStarted"; }

The stream shows a new CLI session starting (system/init, not the one a compaction writes mid-turn; view/agent/session-start.ts): any turn still holding tokens ended without a result (the process died), so they belong to no turn that is coming.


{ chars: number; kind?: "text" | "thinking" | "tool_input"; type: "OutputStreamed"; }

Characters the main agent’s latest call streamed (text, thinking, tool input) since the last one: its output estimate until TokensOut.


{ type: "RequestStarted"; }

The main agent’s tool results went back: a request is in flight (↑) until the next call’s TokensIn.


{ type: "ModelEndedTurn"; }

The main agent’s model sent stop_reason: end_turn; see modelEndedTurn on the Streaming phase.


{ type: "ModelMessageStarted"; }

The main agent’s model began a new message; it is working again.


{ at: number; type: "RequestStop"; }

User pressed Esc / clicked Stop.


{ type: "StopFailed"; }

Stop RPC failed — bail on the stopping state.


{ at: number; type: "InterruptTimeoutElapsed"; }

Interrupt timeout watchdog fired: bounded Interrupting → Done force transition when the agent never acks the SIGINT. A no-op once the phase has left Interrupting. Spec §8.


{ at: number; type: "SubmitTimeoutElapsed"; }

Submit timeout watchdog fired: bounded Submitting → Done.errored force transition when the backend never acks a TurnStart within SUBMIT_TIMEOUT_MS (#728 gap 2). A no-op once the phase has left Submitting. Spec §8.


{ at: number; attachments?: object[]; enqueuedWhileBusy: boolean; id: string; resend?: boolean; system?: boolean; text: string; type: "PendingMessageQueued"; }

at: number

optional attachments?: object[]

Images sent with the message (ids + names, tray order).

enqueuedWhileBusy: boolean

True when the user sent this while a turn was in flight (isWorking was true before TurnStart); false for idle sends. Stored on the PendingMessage entry; PendingMessagesPanel uses it so an idle-send message never flashes in the amber queued zone.

id: string

optional resend?: boolean

The same message again (a Retry): acceptance takes it off the queue and adds no second node.

optional system?: boolean

The pane sends it on AgentMux’s behalf (the start-up document): a retry sends it so again.

text: string

type: "PendingMessageQueued"


{ id: string; type: "PendingMessageFlushStarted"; }

A held message is about to be delivered (dispatched right before deliverToBackend: the moment sending actually begins). Marks the entry flushing so PendingMessagesPanel stops claiming “sends at the agent’s next step”.


{ ahead: number; id: string; type: "PendingMessageWaiting"; }

srv has the message but queued it behind the agent’s live process (agent-message-queued): ahead messages are in front of it. The panel says what it waits for.


{ id: string; type: "PendingMessageAccepted"; }

Backend acknowledged the message — remove from pending.


{ id: string; type: "PendingMessageRejected"; }

RPC failed — remove the entry so user doesn’t see a ghost row.


{ id: string; type: "PendingMessageExpired"; }

Pending entry ageing watchdog fired (caller-scheduled setTimeout). Removes the entry by id; idempotent. Prevents zombie pending rows when the backend never acknowledges a queued message (RPC hang post-send; #728 gap 2).


{ at: number; reason: "rate_limited"; retryAfterMs: number | null; type: "ProviderWaiting"; }

Provider is rate-limited (429) and waiting to retry. Updates lastEventMs (keeps the stuck-stream watchdog quiet) and sets waitingReason on Streaming so the working row can say “Rate limited — retrying…”. Cleared by the next real activity (bumpEvent).


{ at: number; failure: AgentFailure; since?: number; source?: FailureSource; turnAttempted?: boolean; type: "FailureObserved"; }

Backend classified a failure for this pane (the agentfailure event). Force-ends a working turn unconditionally (→ Done.errored): an authoritative failure doesn’t depend on the CLI process exiting, which persistent-mode agents never do between turns.

at: number

failure: AgentFailure

optional since?: number

For a seed only: when the pane mounted. A seed is dropped when a turn is running or has finished since, so a stored failure that arrives late never ends or overwrites it.

optional source?: FailureSource

Who raises it. Omitted means the backend’s event (live). Dropped, with no other effect, when the failure showing outranks it (failure-precedence.ts).

optional turnAttempted?: boolean

See PaneFailure.turnAttempted. Omitted by the backend-event path (a classified failure always FOLLOWS a turn that ran), set to false only by the pane’s own synthetic pre-launch auth failure.

type: "FailureObserved"


{ onlyCode?: AgentFailure["code"]; reason?: FailureClearReason; type: "FailureCleared"; }

The failure row goes: dismissed, its episode over, proven resolved, or retracted. onlyCode clears it only when it is that class, decided here in the reducer so no caller reads the failure and then clears a different one that landed in between.


{ type: "DetailsToggle"; }

Toggle the log panel open/closed.


{ type: "DetailsExpand"; }

Explicitly open the log panel. Idempotent if already open.


{ type: "DetailsCollapse"; }

Explicitly close the log panel. Idempotent if already closed.


{ at: number; trigger: "manual" | "auto"; type: "CompactionStarted"; }

The PreCompact hook fired: compaction has begun (the compaction_started MPS event). Sets compacting and bumps lastEventMs so the stuck-stream watchdog doesn’t misfire during a long compaction.


{ at: number; boundaryUuid?: string | null; durationMs: number; frameTimestamp?: string | null; postTokens: number; preTokens: number; trigger: "manual" | "auto"; type: "CompactionBoundary"; }

The real compact_boundary frame arrived: compaction finished (exact, not inferred). Clears compacting, records lastCompactionBoundaryAt, and reconciles context to postTokens.

at: number

optional boundaryUuid?: string | null

The frame’s own uuid: keys the emitted context-compacted node’s id, so it matches parseHistoryLines.ts’s id for the same line. Optional for callers without a frame.

durationMs: number

optional frameTimestamp?: string | null

The frame’s own timestamp, raw; absent/null when the frame has none or the caller has no raw frame. A time value only (the stale-boundary checks and the node’s time, falling back to at); never an id: see boundaryUuid.

postTokens: number

preTokens: number

trigger: "manual" | "auto"

type: "CompactionBoundary"


{ at: number; type: "AttachedTaskObserved"; }

Fires on the 0→1 transition of “≥1 PinnedActivity is running for this block”. Idempotent: it must NOT reset since when a second task starts running alongside.


{ type: "AttachedTaskCleared"; }

Fires on the 1→0 transition — the last currently-running PinnedActivity for this block just ended. No-op if already null.


{ at: number; type: "ResumeRetryStarted"; }

mps.EVENT_AGENT_RESUME_RETRY’s {status:"retrying"} landed: a stale --resume was detected and a retry is about to fire. Idempotent: a cascaded second retry must not push startedAt later.


{ type: "ResumeRetryResolved"; }

{status:"resolved"} landed — the retry’s outcome (Fresh or Resumed) is now known. No-op if already null.


{ at: number; type: "RegistryAttachedTaskObserved"; }

Sets registryAttachedTaskSince verbatim (idempotent set, not an edge-triggered toggle like AttachedTaskObserved — the registry’s own earliest-running-task computation already handles the “already observed” case, so the reducer doesn’t need its own no-op guard).


{ type: "RegistryAttachedTaskCleared"; }

Clears registryAttachedTaskSince back to null.