@bastani/atomic 0.9.38-alpha.9 → 0.9.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +10 -0
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/mcp/package.json +1 -1
  5. package/dist/builtin/subagents/CHANGELOG.md +10 -0
  6. package/dist/builtin/subagents/package.json +1 -1
  7. package/dist/builtin/web-access/CHANGELOG.md +7 -0
  8. package/dist/builtin/web-access/package.json +1 -1
  9. package/dist/builtin/workflows/CHANGELOG.md +60 -0
  10. package/dist/builtin/workflows/package.json +1 -1
  11. package/dist/builtin/workflows/src/extension/index.bundle.mjs +5 -0
  12. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  13. package/dist/core/agent-session-prompt.js +57 -15
  14. package/dist/core/agent-session-prompt.js.map +1 -1
  15. package/dist/core/queued-input-admission.d.ts +20 -0
  16. package/dist/core/queued-input-admission.d.ts.map +1 -0
  17. package/dist/core/queued-input-admission.js +55 -0
  18. package/dist/core/queued-input-admission.js.map +1 -0
  19. package/dist/extensions/mcp/client/transports/streamable-http.js +9 -8
  20. package/dist/extensions/mcp/client/transports/streamable-http.js.map +1 -1
  21. package/dist/modes/interactive/components/chat-session-host-actions.d.ts +4 -0
  22. package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
  23. package/dist/modes/interactive/components/chat-session-host-actions.js +104 -30
  24. package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
  25. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  26. package/dist/modes/interactive/components/chat-session-host-events.js +1 -0
  27. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  28. package/dist/modes/interactive/components/chat-session-host-state.d.ts +4 -0
  29. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  30. package/dist/modes/interactive/components/chat-session-host-state.js +4 -0
  31. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  32. package/dist/modes/interactive/components/session-selector.js +4 -3
  33. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  34. package/dist/modes/interactive/interactive-input-handling.js +8 -2
  35. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  36. package/dist/modes/interactive/interactive-mode-base.d.ts +4 -0
  37. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  38. package/dist/modes/interactive/interactive-mode-base.js +4 -0
  39. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  40. package/dist/modes/interactive/interactive-process-lifecycle.js +8 -2
  41. package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
  42. package/dist/modes/interactive/interactive-queueing.js +94 -73
  43. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  44. package/dist/modes/interactive/interactive-session-runtime.js +1 -0
  45. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  46. package/docs/usage.md +2 -0
  47. package/npm-shrinkwrap.json +32 -32
  48. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"chat-session-host-events.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-events.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,kCAAkC,EAClC,4BAA4B,GAG5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAEN,+BAA+B,EAC/B,2BAA2B,GAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EACN,qBAAqB,EACrB,gCAAgC,EAChC,gCAAgC,EAChC,+BAA+B,GAC/B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACN,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,oBAAoB,GACpB,MAAM,8BAA8B,CAAC;AAKtC,MAAM,UAAU,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AO,MAAM,KAAK,QAAQ,IAAI,SAAS,IAAI,MAAM;YACnE,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;QACnF,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,IAAI;KACjC,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAwB;IAIpD,MAAM,KAAK,GAAG,MAAM,CAAE,KAA6B,CAAC,KAAK,IAAK,KAA4B,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACvG,OAAO;QACN,IAAI,EAAE,gBAAgB;QACtB,qBAAqB,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAC,EAAE,KAAK,EAAE;KACzE,CAAC;AACH,CAAC","sourcesContent":["import type { AgentSession, AgentSessionEvent } from \"../../../core/agent-session.js\";\nimport type { CompactionReason } from \"../../../core/agent-session-types.js\";\nimport {\n\ttype CompactionRung,\n\tVERBATIM_COMPACTION_PROMPT_VERSION,\n\tVERBATIM_COMPACTION_STRATEGY,\n\ttype VerbatimCompactionDetails,\n\ttype VerbatimCompactionResult,\n} from \"../../../core/compaction/index.ts\";\nimport {\n\ttype CustomMessage,\n\tcreateVerbatimCompactionMessage,\n\tisVerbatimCompactionMessage,\n} from \"../../../core/messages.ts\";\nimport { pickWhimsicalWorkingMessage } from \"../whimsical-messages.ts\";\nimport { flushChatSessionCompactionQueue } from \"./chat-session-host-actions.ts\";\nimport {\n\tafterChatSessionEvent,\n\tdecrementOptimisticUserSignature,\n\tstartChatSessionWorkingLifecycle,\n\tstopChatSessionWorkingLifecycle,\n} from \"./chat-session-host-runtime.ts\";\nimport type { ChatSessionHostState } from \"./chat-session-host-state.ts\";\nimport {\n\textractMessageText,\n\tisMessageLike,\n\tisUserMessageLike,\n\tuserMessageSignature,\n} from \"./chat-session-host-utils.ts\";\nimport type { ChatTranscriptEntryLike } from \"./chat-transcript.js\";\n\nexport type { CompactionReason } from \"../../../core/agent-session-types.js\";\n\nexport function compactionStatusMessage(reason: CompactionReason): string {\n\tswitch (reason) {\n\t\tcase \"manual\":\n\t\t\treturn \"Compacting context...\";\n\t\tcase \"threshold\":\n\t\t\treturn \"Auto-compacting...\";\n\t\tcase \"overflow\":\n\t\t\treturn \"Context overflow detected. Auto-compacting...\";\n\t\tcase \"branchSummary\":\n\t\t\treturn \"summarizing branch…\";\n\t}\n}\n\nfunction hasVerbatimCompactionMessage(messages: AgentSession[\"messages\"]): boolean {\n\treturn messages.some((message) => message.role === \"custom\" && isVerbatimCompactionMessage(message));\n}\n\n/**\n * Every durable rung, derived from the union so a new member cannot be silently\n * rejected here. The event-only path (no session snapshot) is the one place a\n * `fresh` boundary would otherwise be dropped.\n */\nconst COMPACTION_RUNGS: ReadonlySet<CompactionRung> = new Set([\n\t\"planned\",\n\t\"extension\",\n\t\"fresh\",\n] as const satisfies readonly CompactionRung[]);\n\nfunction isCompleteCompactionResult(result: VerbatimCompactionResult): boolean {\n\treturn (\n\t\ttypeof result.compactedText === \"string\" &&\n\t\ttypeof result.tokensBefore === \"number\" &&\n\t\tresult.stats !== undefined &&\n\t\tresult.parameters !== undefined &&\n\t\tresult.promptVersion === VERBATIM_COMPACTION_PROMPT_VERSION &&\n\t\tCOMPACTION_RUNGS.has(result.rung)\n\t);\n}\n\nfunction boundaryMessageFromResult(\n\tresult: VerbatimCompactionResult,\n): CustomMessage<VerbatimCompactionDetails> | undefined {\n\tif (!isCompleteCompactionResult(result)) return undefined;\n\tconst details = {\n\t\tstrategy: VERBATIM_COMPACTION_STRATEGY,\n\t\tpromptVersion: result.promptVersion,\n\t\tparameters: result.parameters,\n\t\tstats: result.stats,\n\t\trung: result.rung,\n\t\t// Preserve the borrowed-planner identity; the event-only path is otherwise\n\t\t// the one place it is lost.\n\t\t...(result.plannerModel === undefined ? {} : { plannerModel: result.plannerModel }),\n\t\t...(result.backupPath === undefined ? {} : { backupPath: result.backupPath }),\n\t} satisfies VerbatimCompactionDetails;\n\treturn createVerbatimCompactionMessage(\n\t\tresult.compactedText,\n\t\tresult.tokensBefore,\n\t\tnew Date().toISOString(),\n\t\tdetails,\n\t) as CustomMessage<VerbatimCompactionDetails>;\n}\n\nfunction customMessageText(message: CustomMessage): string {\n\tif (typeof message.content === \"string\") return message.content;\n\treturn message.content\n\t\t.filter((block) => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.join(\"\\n\");\n}\n\nfunction transcriptHasBoundaryForResult(\n\ttranscript: readonly ChatTranscriptEntryLike[],\n\tresult: VerbatimCompactionResult,\n): boolean {\n\treturn transcript.some((entry) => {\n\t\tconst candidate = entry as ChatTranscriptEntryLike & {\n\t\t\treadonly kind?: string;\n\t\t\treadonly message?: CustomMessage<VerbatimCompactionDetails>;\n\t\t};\n\t\tif (\n\t\t\tcandidate.kind !== \"custom\" ||\n\t\t\tcandidate.message?.role !== \"custom\" ||\n\t\t\t!isVerbatimCompactionMessage(candidate.message)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\t// The rung is part of the identity, not decoration. A planned and a fresh\n\t\t// boundary can carry identical text, and treating them as the same result\n\t\t// silently swallows the fresh event — the one the user is meant to see.\n\t\tif (candidate.message?.details?.rung !== result.rung) return false;\n\t\treturn customMessageText(candidate.message).endsWith(result.compactedText);\n\t});\n}\n\nfunction refreshCompactedTranscript<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tresult: VerbatimCompactionResult,\n): void {\n\tconst compactedMessages = state.getAgentSession?.()?.messages;\n\tif (compactedMessages && hasVerbatimCompactionMessage(compactedMessages)) {\n\t\tstate.liveChat.replaceMessages(compactedMessages, state.extraEntries);\n\t\treturn;\n\t}\n\tif (transcriptHasBoundaryForResult(state.transcript, result)) return;\n\tconst boundary = boundaryMessageFromResult(result);\n\tif (boundary) state.liveChat.appendMessages([boundary]);\n}\n\nexport function applyChatSessionAgentEvent<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tevent: AgentSessionEvent,\n): boolean {\n\tif (state.disposed) return false;\n\tconst type = String((event as { type?: unknown }).type ?? \"\");\n\tif (type === \"message_start\") {\n\t\tconst message = (event as { message?: unknown }).message;\n\t\tif (isUserMessageLike(message)) {\n\t\t\tconst signature = userMessageSignature(extractMessageText(message.content));\n\t\t\tconst count = state.optimisticUserSignatureCounts.get(signature) ?? 0;\n\t\t\tif (count > 0) {\n\t\t\t\tdecrementOptimisticUserSignature(state, signature);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\tif (isSharedLiveChatEvent(type)) {\n\t\tconst changed = state.liveChat.applyEvent(event);\n\t\tconst toolCallEvent = assistantToolCallEvent(event);\n\t\tconst changedByToolCall = toolCallEvent !== undefined ? state.liveChat.applyEvent(toolCallEvent) : false;\n\t\tafterChatSessionEvent(state, changed || changedByToolCall);\n\t\treturn changed || changedByToolCall;\n\t}\n\tlet changed = false;\n\tswitch (type) {\n\t\tcase \"agent_start\":\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstartChatSessionWorkingLifecycle(state);\n\t\t\tstate.liveChat.clearPendingTools();\n\t\t\tstate.statusMessage = \"\";\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"agent_end\": {\n\t\t\tconst manualTakeoverPending = state.manualCompactionTakeoverPending;\n\t\t\tstate.sdkBusy = manualTakeoverPending;\n\t\t\tstate.compacting = manualTakeoverPending;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstate.liveChat.clearPendingTools();\n\t\t\tif (!manualTakeoverPending) state.statusMessage = \"\";\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tif (!manualTakeoverPending && state.compactionQueuedMessages.length > 0) {\n\t\t\t\tconst idle = state.getAgentSession?.()?.agent.waitForIdle() ?? Promise.resolve();\n\t\t\t\tvoid idle.then(() => flushChatSessionCompactionQueue(state));\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"turn_start\":\n\t\t\tstartChatSessionWorkingLifecycle(state);\n\t\t\tstate.workingMessage = pickWhimsicalWorkingMessage();\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"turn_end\":\n\t\t\tstate.compacting = state.manualCompactionTakeoverPending;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"queue_update\": {\n\t\t\tconst queue = event as { steering?: unknown; followUp?: unknown };\n\t\t\tstate.pendingSteeringMessages = Array.isArray(queue.steering)\n\t\t\t\t? queue.steering.filter((item): item is string => typeof item === \"string\")\n\t\t\t\t: [];\n\t\t\tstate.pendingFollowUpMessages = Array.isArray(queue.followUp)\n\t\t\t\t? queue.followUp.filter((item): item is string => typeof item === \"string\")\n\t\t\t\t: [];\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"tool_call\":\n\t\tcase \"tool_use\":\n\t\t\tchanged = state.liveChat.applyEvent(legacyToolStartEvent(event));\n\t\t\tbreak;\n\t\tcase \"tool_result\":\n\t\t\tchanged = state.liveChat.applyEvent(legacyToolResultEvent(event));\n\t\t\tbreak;\n\t\tcase \"thinking_delta\":\n\t\tcase \"thinking\":\n\t\t\tchanged = state.liveChat.applyEvent(legacyThinkingEvent(event));\n\t\t\tbreak;\n\t\tcase \"compaction_start\": {\n\t\t\tconst compaction = event as Extract<AgentSessionEvent, { type: \"compaction_start\" }>;\n\t\t\tstate.compacting = true;\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.statusMessage = compactionStatusMessage(compaction.reason);\n\t\t\t// The animation timer this event starts would otherwise swallow the\n\t\t\t// event's own paint request, delaying the factual status by a frame.\n\t\t\tstate.immediateEventRenderPending = true;\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"compaction_end\": {\n\t\t\tconst compaction = event as Extract<AgentSessionEvent, { type: \"compaction_end\" }>;\n\t\t\tconst manualTakeoverPending =\n\t\t\t\tcompaction.reason !== \"manual\" &&\n\t\t\t\t(compaction.manualTakeoverPending === true || state.manualCompactionTakeoverPending);\n\t\t\tif (manualTakeoverPending) {\n\t\t\t\tstate.manualCompactionTakeoverPending = true;\n\t\t\t} else if (compaction.reason === \"manual\") {\n\t\t\t\tstate.manualCompactionTakeoverPending = false;\n\t\t\t}\n\t\t\tstate.compacting = manualTakeoverPending;\n\t\t\tstate.sdkBusy = manualTakeoverPending || compaction.midTurn === true;\n\t\t\tif (!manualTakeoverPending) state.statusMessage = compaction.errorMessage ?? \"\";\n\t\t\tif (compaction.midTurn !== true || compaction.aborted || compaction.errorMessage) {\n\t\t\t\tstate.workingMessage = undefined;\n\t\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\t} else if (!state.workingLifecycleActive) {\n\t\t\t\t// A successful no-op ends before the next turn_start, so nothing else\n\t\t\t\t// would restart ordinary Working for the continuing stream.\n\t\t\t\tstartChatSessionWorkingLifecycle(state);\n\t\t\t}\n\t\t\tstate.immediateEventRenderPending = true;\n\t\t\t// `result` and `errorMessage` are independent facts. The post-tool gate can\n\t\t\t// report a hard-input-limit failure *after* the boundary was already\n\t\t\t// committed, and skipping the refresh there hid a durable context\n\t\t\t// destruction behind an error line. Show the boundary, then the status.\n\t\t\tif (!compaction.aborted && compaction.result) {\n\t\t\t\trefreshCompactedTranscript(state, compaction.result);\n\t\t\t}\n\t\t\tif (!manualTakeoverPending && state.compactionQueuedMessages.length > 0) {\n\t\t\t\tvoid flushChatSessionCompactionQueue(state);\n\t\t\t}\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"summarization_retry_scheduled\":\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.statusMessage = \"retrying summary…\";\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"summarization_retry_attempt_start\": {\n\t\t\tconst retry = event as Extract<AgentSessionEvent, { type: \"summarization_retry_attempt_start\" }>;\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.statusMessage = compactionStatusMessage(\n\t\t\t\tretry.source === \"branchSummary\" ? \"branchSummary\" : retry.reason,\n\t\t\t);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"summarization_retry_finished\":\n\t\t\tstate.statusMessage = state.compacting ? compactionStatusMessage(\"manual\") : \"\";\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"auto_retry_start\":\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstate.statusMessage = \"retrying…\";\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"model_fallback_start\":\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstate.statusMessage = \"switching model…\";\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"model_fallback_end\": {\n\t\t\tconst fallback = event as Extract<AgentSessionEvent, { type: \"model_fallback_end\" }>;\n\t\t\tstate.statusMessage = fallback.success ? \"\" : (fallback.finalError ?? \"model fallback failed\");\n\t\t\tstate.workingMessage = undefined;\n\t\t\tif (!fallback.success) {\n\t\t\t\tstate.sdkBusy = false;\n\t\t\t\tstate.compacting = false;\n\t\t\t}\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"auto_retry_end\": {\n\t\t\tconst retry = event as Extract<AgentSessionEvent, { type: \"auto_retry_end\" }>;\n\t\t\tstate.statusMessage = \"\";\n\t\t\tstate.workingMessage = undefined;\n\t\t\tif (!retry.success) {\n\t\t\t\tstate.sdkBusy = false;\n\t\t\t\tstate.compacting = false;\n\t\t\t}\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"agent_continue_error\": {\n\t\t\tconst continueError = event as Extract<AgentSessionEvent, { type: \"agent_continue_error\" }>;\n\t\t\tstate.sdkBusy = false;\n\t\t\tstate.compacting = false;\n\t\t\tstate.statusMessage = continueError.errorMessage;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tchanged = false;\n\t}\n\tafterChatSessionEvent(state, changed);\n\treturn changed;\n}\n\nfunction isSharedLiveChatEvent(type: string): boolean {\n\treturn (\n\t\ttype === \"message_start\" ||\n\t\ttype === \"message_update\" ||\n\t\ttype === \"message_end\" ||\n\t\ttype === \"tool_execution_start\" ||\n\t\ttype === \"tool_execution_update\" ||\n\t\ttype === \"tool_execution_end\"\n\t);\n}\n\nfunction assistantToolCallEvent(event: AgentSessionEvent):\n\t| {\n\t\t\ttype: \"tool_execution_start\";\n\t\t\ttoolCallId: string;\n\t\t\ttoolName: string;\n\t\t\targs: unknown;\n\t }\n\t| undefined {\n\tconst assistantEvent = (\n\t\tevent as {\n\t\t\tassistantMessageEvent?: {\n\t\t\t\ttype?: unknown;\n\t\t\t\tcontentIndex?: unknown;\n\t\t\t\tpartial?: unknown;\n\t\t\t\ttoolCall?: unknown;\n\t\t\t};\n\t\t}\n\t).assistantMessageEvent;\n\tconst streamType = String(assistantEvent?.type ?? \"\");\n\tif (!streamType.startsWith(\"toolcall_\")) return undefined;\n\tconst explicit = toolCallPayload(assistantEvent?.toolCall);\n\tif (explicit) return explicit;\n\tconst contentIndex = typeof assistantEvent?.contentIndex === \"number\" ? assistantEvent.contentIndex : undefined;\n\tif (contentIndex === undefined) return undefined;\n\tconst partial = assistantEvent?.partial;\n\tif (!isMessageLike(partial) || partial.role !== \"assistant\") return undefined;\n\tconst content = partial.content;\n\tif (!Array.isArray(content)) return undefined;\n\treturn toolCallPayload(content[contentIndex]);\n}\n\nfunction toolCallPayload(value: unknown):\n\t| {\n\t\t\ttype: \"tool_execution_start\";\n\t\t\ttoolCallId: string;\n\t\t\ttoolName: string;\n\t\t\targs: unknown;\n\t }\n\t| undefined {\n\tif (value === null || typeof value !== \"object\") return undefined;\n\tconst candidate = value as { type?: unknown; id?: unknown; name?: unknown; arguments?: unknown };\n\tif (candidate.type !== \"toolCall\") return undefined;\n\tif (typeof candidate.id !== \"string\" || typeof candidate.name !== \"string\") return undefined;\n\treturn {\n\t\ttype: \"tool_execution_start\",\n\t\ttoolCallId: candidate.id,\n\t\ttoolName: candidate.name,\n\t\targs: candidate.arguments ?? {},\n\t};\n}\n\nfunction legacyToolStartEvent(event: AgentSessionEvent): {\n\ttype: \"tool_execution_start\";\n\ttoolCallId: string;\n\ttoolName: string;\n\targs: unknown;\n} {\n\tconst payload = event as { toolCallId?: unknown; name?: unknown; input?: unknown; args?: unknown };\n\tconst toolName = typeof payload.name === \"string\" ? payload.name : \"tool\";\n\tconst toolCallId = typeof payload.toolCallId === \"string\" ? payload.toolCallId : `live-${toolName}`;\n\treturn {\n\t\ttype: \"tool_execution_start\",\n\t\ttoolCallId,\n\t\ttoolName,\n\t\targs: payload.input ?? payload.args ?? {},\n\t};\n}\n\nfunction legacyToolResultEvent(event: AgentSessionEvent): {\n\ttype: \"tool_execution_end\";\n\ttoolCallId: string;\n\ttoolName: string;\n\tresult: unknown;\n\tisError: boolean;\n} {\n\tconst payload = event as {\n\t\ttoolCallId?: unknown;\n\t\tname?: unknown;\n\t\toutput?: unknown;\n\t\tisError?: unknown;\n\t};\n\tconst toolName = typeof payload.name === \"string\" ? payload.name : \"tool\";\n\tconst toolCallId = typeof payload.toolCallId === \"string\" ? payload.toolCallId : `live-${toolName}`;\n\tconst output = payload.output;\n\treturn {\n\t\ttype: \"tool_execution_end\",\n\t\ttoolCallId,\n\t\ttoolName,\n\t\tresult:\n\t\t\toutput !== null && typeof output === \"object\" && \"content\" in output\n\t\t\t\t? output\n\t\t\t\t: { content: typeof output === \"string\" ? [{ type: \"text\", text: output }] : [] },\n\t\tisError: payload.isError === true,\n\t};\n}\n\nfunction legacyThinkingEvent(event: AgentSessionEvent): {\n\ttype: \"message_update\";\n\tassistantMessageEvent: { type: \"thinking_delta\"; contentIndex: number; delta: string };\n} {\n\tconst delta = String((event as { delta?: unknown }).delta ?? (event as { text?: unknown }).text ?? \"\");\n\treturn {\n\t\ttype: \"message_update\",\n\t\tassistantMessageEvent: { type: \"thinking_delta\", contentIndex: 0, delta },\n\t};\n}\n"]}
1
+ {"version":3,"file":"chat-session-host-events.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-events.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,kCAAkC,EAClC,4BAA4B,GAG5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAEN,+BAA+B,EAC/B,2BAA2B,GAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EACN,qBAAqB,EACrB,gCAAgC,EAChC,gCAAgC,EAChC,+BAA+B,GAC/B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACN,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,oBAAoB,GACpB,MAAM,8BAA8B,CAAC;AAKtC,MAAM,UAAU,uBAAuB,CAAC,MAAwB;IAC/D,QAAQ,MAAM,EAAE,CAAC;QAChB,KAAK,QAAQ;YACZ,OAAO,uBAAuB,CAAC;QAChC,KAAK,WAAW;YACf,OAAO,oBAAoB,CAAC;QAC7B,KAAK,UAAU;YACd,OAAO,+CAA+C,CAAC;QACxD,KAAK,eAAe;YACnB,OAAO,qBAAqB,CAAC;IAC/B,CAAC;AACF,CAAC;AAED,SAAS,4BAA4B,CAAC,QAAkC;IAC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ACnF,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,IAAI;KACjC,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAwB;IAIpD,MAAM,KAAK,GAAG,MAAM,CAAE,KAA6B,CAAC,KAAK,IAAK,KAA4B,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACvG,OAAO;QACN,IAAI,EAAE,gBAAgB;QACtB,qBAAqB,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAC,EAAE,KAAK,EAAE;KACzE,CAAC;AACH,CAAC","sourcesContent":["import type { AgentSession, AgentSessionEvent } from \"../../../core/agent-session.js\";\nimport type { CompactionReason } from \"../../../core/agent-session-types.js\";\nimport {\n\ttype CompactionRung,\n\tVERBATIM_COMPACTION_PROMPT_VERSION,\n\tVERBATIM_COMPACTION_STRATEGY,\n\ttype VerbatimCompactionDetails,\n\ttype VerbatimCompactionResult,\n} from \"../../../core/compaction/index.ts\";\nimport {\n\ttype CustomMessage,\n\tcreateVerbatimCompactionMessage,\n\tisVerbatimCompactionMessage,\n} from \"../../../core/messages.ts\";\nimport { pickWhimsicalWorkingMessage } from \"../whimsical-messages.ts\";\nimport { flushChatSessionCompactionQueue } from \"./chat-session-host-actions.ts\";\nimport {\n\tafterChatSessionEvent,\n\tdecrementOptimisticUserSignature,\n\tstartChatSessionWorkingLifecycle,\n\tstopChatSessionWorkingLifecycle,\n} from \"./chat-session-host-runtime.ts\";\nimport type { ChatSessionHostState } from \"./chat-session-host-state.ts\";\nimport {\n\textractMessageText,\n\tisMessageLike,\n\tisUserMessageLike,\n\tuserMessageSignature,\n} from \"./chat-session-host-utils.ts\";\nimport type { ChatTranscriptEntryLike } from \"./chat-transcript.js\";\n\nexport type { CompactionReason } from \"../../../core/agent-session-types.js\";\n\nexport function compactionStatusMessage(reason: CompactionReason): string {\n\tswitch (reason) {\n\t\tcase \"manual\":\n\t\t\treturn \"Compacting context...\";\n\t\tcase \"threshold\":\n\t\t\treturn \"Auto-compacting...\";\n\t\tcase \"overflow\":\n\t\t\treturn \"Context overflow detected. Auto-compacting...\";\n\t\tcase \"branchSummary\":\n\t\t\treturn \"summarizing branch…\";\n\t}\n}\n\nfunction hasVerbatimCompactionMessage(messages: AgentSession[\"messages\"]): boolean {\n\treturn messages.some((message) => message.role === \"custom\" && isVerbatimCompactionMessage(message));\n}\n\n/**\n * Every durable rung, derived from the union so a new member cannot be silently\n * rejected here. The event-only path (no session snapshot) is the one place a\n * `fresh` boundary would otherwise be dropped.\n */\nconst COMPACTION_RUNGS: ReadonlySet<CompactionRung> = new Set([\n\t\"planned\",\n\t\"extension\",\n\t\"fresh\",\n] as const satisfies readonly CompactionRung[]);\n\nfunction isCompleteCompactionResult(result: VerbatimCompactionResult): boolean {\n\treturn (\n\t\ttypeof result.compactedText === \"string\" &&\n\t\ttypeof result.tokensBefore === \"number\" &&\n\t\tresult.stats !== undefined &&\n\t\tresult.parameters !== undefined &&\n\t\tresult.promptVersion === VERBATIM_COMPACTION_PROMPT_VERSION &&\n\t\tCOMPACTION_RUNGS.has(result.rung)\n\t);\n}\n\nfunction boundaryMessageFromResult(\n\tresult: VerbatimCompactionResult,\n): CustomMessage<VerbatimCompactionDetails> | undefined {\n\tif (!isCompleteCompactionResult(result)) return undefined;\n\tconst details = {\n\t\tstrategy: VERBATIM_COMPACTION_STRATEGY,\n\t\tpromptVersion: result.promptVersion,\n\t\tparameters: result.parameters,\n\t\tstats: result.stats,\n\t\trung: result.rung,\n\t\t// Preserve the borrowed-planner identity; the event-only path is otherwise\n\t\t// the one place it is lost.\n\t\t...(result.plannerModel === undefined ? {} : { plannerModel: result.plannerModel }),\n\t\t...(result.backupPath === undefined ? {} : { backupPath: result.backupPath }),\n\t} satisfies VerbatimCompactionDetails;\n\treturn createVerbatimCompactionMessage(\n\t\tresult.compactedText,\n\t\tresult.tokensBefore,\n\t\tnew Date().toISOString(),\n\t\tdetails,\n\t) as CustomMessage<VerbatimCompactionDetails>;\n}\n\nfunction customMessageText(message: CustomMessage): string {\n\tif (typeof message.content === \"string\") return message.content;\n\treturn message.content\n\t\t.filter((block) => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.join(\"\\n\");\n}\n\nfunction transcriptHasBoundaryForResult(\n\ttranscript: readonly ChatTranscriptEntryLike[],\n\tresult: VerbatimCompactionResult,\n): boolean {\n\treturn transcript.some((entry) => {\n\t\tconst candidate = entry as ChatTranscriptEntryLike & {\n\t\t\treadonly kind?: string;\n\t\t\treadonly message?: CustomMessage<VerbatimCompactionDetails>;\n\t\t};\n\t\tif (\n\t\t\tcandidate.kind !== \"custom\" ||\n\t\t\tcandidate.message?.role !== \"custom\" ||\n\t\t\t!isVerbatimCompactionMessage(candidate.message)\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\t// The rung is part of the identity, not decoration. A planned and a fresh\n\t\t// boundary can carry identical text, and treating them as the same result\n\t\t// silently swallows the fresh event — the one the user is meant to see.\n\t\tif (candidate.message?.details?.rung !== result.rung) return false;\n\t\treturn customMessageText(candidate.message).endsWith(result.compactedText);\n\t});\n}\n\nfunction refreshCompactedTranscript<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tresult: VerbatimCompactionResult,\n): void {\n\tconst compactedMessages = state.getAgentSession?.()?.messages;\n\tif (compactedMessages && hasVerbatimCompactionMessage(compactedMessages)) {\n\t\tstate.liveChat.replaceMessages(compactedMessages, state.extraEntries);\n\t\treturn;\n\t}\n\tif (transcriptHasBoundaryForResult(state.transcript, result)) return;\n\tconst boundary = boundaryMessageFromResult(result);\n\tif (boundary) state.liveChat.appendMessages([boundary]);\n}\n\nexport function applyChatSessionAgentEvent<TExtraEntry extends ChatTranscriptEntryLike>(\n\tstate: ChatSessionHostState<TExtraEntry>,\n\tevent: AgentSessionEvent,\n): boolean {\n\tif (state.disposed) return false;\n\tconst type = String((event as { type?: unknown }).type ?? \"\");\n\tif (type === \"message_start\") {\n\t\tconst message = (event as { message?: unknown }).message;\n\t\tif (isUserMessageLike(message)) {\n\t\t\tconst signature = userMessageSignature(extractMessageText(message.content));\n\t\t\tconst count = state.optimisticUserSignatureCounts.get(signature) ?? 0;\n\t\t\tif (count > 0) {\n\t\t\t\tdecrementOptimisticUserSignature(state, signature);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\tif (isSharedLiveChatEvent(type)) {\n\t\tconst changed = state.liveChat.applyEvent(event);\n\t\tconst toolCallEvent = assistantToolCallEvent(event);\n\t\tconst changedByToolCall = toolCallEvent !== undefined ? state.liveChat.applyEvent(toolCallEvent) : false;\n\t\tafterChatSessionEvent(state, changed || changedByToolCall);\n\t\treturn changed || changedByToolCall;\n\t}\n\tlet changed = false;\n\tswitch (type) {\n\t\tcase \"agent_start\":\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstartChatSessionWorkingLifecycle(state);\n\t\t\tstate.liveChat.clearPendingTools();\n\t\t\tstate.statusMessage = \"\";\n\t\t\tchanged = true;\n\t\t\tstate.compactionPromptStarted?.();\n\t\t\tbreak;\n\t\tcase \"agent_end\": {\n\t\t\tconst manualTakeoverPending = state.manualCompactionTakeoverPending;\n\t\t\tstate.sdkBusy = manualTakeoverPending;\n\t\t\tstate.compacting = manualTakeoverPending;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstate.liveChat.clearPendingTools();\n\t\t\tif (!manualTakeoverPending) state.statusMessage = \"\";\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tif (!manualTakeoverPending && state.compactionQueuedMessages.length > 0) {\n\t\t\t\tconst idle = state.getAgentSession?.()?.agent.waitForIdle() ?? Promise.resolve();\n\t\t\t\tvoid idle.then(() => flushChatSessionCompactionQueue(state));\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase \"turn_start\":\n\t\t\tstartChatSessionWorkingLifecycle(state);\n\t\t\tstate.workingMessage = pickWhimsicalWorkingMessage();\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"turn_end\":\n\t\t\tstate.compacting = state.manualCompactionTakeoverPending;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"queue_update\": {\n\t\t\tconst queue = event as { steering?: unknown; followUp?: unknown };\n\t\t\tstate.pendingSteeringMessages = Array.isArray(queue.steering)\n\t\t\t\t? queue.steering.filter((item): item is string => typeof item === \"string\")\n\t\t\t\t: [];\n\t\t\tstate.pendingFollowUpMessages = Array.isArray(queue.followUp)\n\t\t\t\t? queue.followUp.filter((item): item is string => typeof item === \"string\")\n\t\t\t\t: [];\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"tool_call\":\n\t\tcase \"tool_use\":\n\t\t\tchanged = state.liveChat.applyEvent(legacyToolStartEvent(event));\n\t\t\tbreak;\n\t\tcase \"tool_result\":\n\t\t\tchanged = state.liveChat.applyEvent(legacyToolResultEvent(event));\n\t\t\tbreak;\n\t\tcase \"thinking_delta\":\n\t\tcase \"thinking\":\n\t\t\tchanged = state.liveChat.applyEvent(legacyThinkingEvent(event));\n\t\t\tbreak;\n\t\tcase \"compaction_start\": {\n\t\t\tconst compaction = event as Extract<AgentSessionEvent, { type: \"compaction_start\" }>;\n\t\t\tstate.compacting = true;\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.statusMessage = compactionStatusMessage(compaction.reason);\n\t\t\t// The animation timer this event starts would otherwise swallow the\n\t\t\t// event's own paint request, delaying the factual status by a frame.\n\t\t\tstate.immediateEventRenderPending = true;\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"compaction_end\": {\n\t\t\tconst compaction = event as Extract<AgentSessionEvent, { type: \"compaction_end\" }>;\n\t\t\tconst manualTakeoverPending =\n\t\t\t\tcompaction.reason !== \"manual\" &&\n\t\t\t\t(compaction.manualTakeoverPending === true || state.manualCompactionTakeoverPending);\n\t\t\tif (manualTakeoverPending) {\n\t\t\t\tstate.manualCompactionTakeoverPending = true;\n\t\t\t} else if (compaction.reason === \"manual\") {\n\t\t\t\tstate.manualCompactionTakeoverPending = false;\n\t\t\t}\n\t\t\tstate.compacting = manualTakeoverPending;\n\t\t\tstate.sdkBusy = manualTakeoverPending || compaction.midTurn === true;\n\t\t\tif (!manualTakeoverPending) state.statusMessage = compaction.errorMessage ?? \"\";\n\t\t\tif (compaction.midTurn !== true || compaction.aborted || compaction.errorMessage) {\n\t\t\t\tstate.workingMessage = undefined;\n\t\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\t} else if (!state.workingLifecycleActive) {\n\t\t\t\t// A successful no-op ends before the next turn_start, so nothing else\n\t\t\t\t// would restart ordinary Working for the continuing stream.\n\t\t\t\tstartChatSessionWorkingLifecycle(state);\n\t\t\t}\n\t\t\tstate.immediateEventRenderPending = true;\n\t\t\t// `result` and `errorMessage` are independent facts. The post-tool gate can\n\t\t\t// report a hard-input-limit failure *after* the boundary was already\n\t\t\t// committed, and skipping the refresh there hid a durable context\n\t\t\t// destruction behind an error line. Show the boundary, then the status.\n\t\t\tif (!compaction.aborted && compaction.result) {\n\t\t\t\trefreshCompactedTranscript(state, compaction.result);\n\t\t\t}\n\t\t\tif (!manualTakeoverPending && state.compactionQueuedMessages.length > 0) {\n\t\t\t\tvoid flushChatSessionCompactionQueue(state);\n\t\t\t}\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"summarization_retry_scheduled\":\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.statusMessage = \"retrying summary…\";\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"summarization_retry_attempt_start\": {\n\t\t\tconst retry = event as Extract<AgentSessionEvent, { type: \"summarization_retry_attempt_start\" }>;\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.statusMessage = compactionStatusMessage(\n\t\t\t\tretry.source === \"branchSummary\" ? \"branchSummary\" : retry.reason,\n\t\t\t);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"summarization_retry_finished\":\n\t\t\tstate.statusMessage = state.compacting ? compactionStatusMessage(\"manual\") : \"\";\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"auto_retry_start\":\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstate.statusMessage = \"retrying…\";\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"model_fallback_start\":\n\t\t\tstate.sdkBusy = true;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstate.statusMessage = \"switching model…\";\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\tcase \"model_fallback_end\": {\n\t\t\tconst fallback = event as Extract<AgentSessionEvent, { type: \"model_fallback_end\" }>;\n\t\t\tstate.statusMessage = fallback.success ? \"\" : (fallback.finalError ?? \"model fallback failed\");\n\t\t\tstate.workingMessage = undefined;\n\t\t\tif (!fallback.success) {\n\t\t\t\tstate.sdkBusy = false;\n\t\t\t\tstate.compacting = false;\n\t\t\t}\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"auto_retry_end\": {\n\t\t\tconst retry = event as Extract<AgentSessionEvent, { type: \"auto_retry_end\" }>;\n\t\t\tstate.statusMessage = \"\";\n\t\t\tstate.workingMessage = undefined;\n\t\t\tif (!retry.success) {\n\t\t\t\tstate.sdkBusy = false;\n\t\t\t\tstate.compacting = false;\n\t\t\t}\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tcase \"agent_continue_error\": {\n\t\t\tconst continueError = event as Extract<AgentSessionEvent, { type: \"agent_continue_error\" }>;\n\t\t\tstate.sdkBusy = false;\n\t\t\tstate.compacting = false;\n\t\t\tstate.statusMessage = continueError.errorMessage;\n\t\t\tstate.workingMessage = undefined;\n\t\t\tstopChatSessionWorkingLifecycle(state);\n\t\t\tchanged = true;\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t\tchanged = false;\n\t}\n\tafterChatSessionEvent(state, changed);\n\treturn changed;\n}\n\nfunction isSharedLiveChatEvent(type: string): boolean {\n\treturn (\n\t\ttype === \"message_start\" ||\n\t\ttype === \"message_update\" ||\n\t\ttype === \"message_end\" ||\n\t\ttype === \"tool_execution_start\" ||\n\t\ttype === \"tool_execution_update\" ||\n\t\ttype === \"tool_execution_end\"\n\t);\n}\n\nfunction assistantToolCallEvent(event: AgentSessionEvent):\n\t| {\n\t\t\ttype: \"tool_execution_start\";\n\t\t\ttoolCallId: string;\n\t\t\ttoolName: string;\n\t\t\targs: unknown;\n\t }\n\t| undefined {\n\tconst assistantEvent = (\n\t\tevent as {\n\t\t\tassistantMessageEvent?: {\n\t\t\t\ttype?: unknown;\n\t\t\t\tcontentIndex?: unknown;\n\t\t\t\tpartial?: unknown;\n\t\t\t\ttoolCall?: unknown;\n\t\t\t};\n\t\t}\n\t).assistantMessageEvent;\n\tconst streamType = String(assistantEvent?.type ?? \"\");\n\tif (!streamType.startsWith(\"toolcall_\")) return undefined;\n\tconst explicit = toolCallPayload(assistantEvent?.toolCall);\n\tif (explicit) return explicit;\n\tconst contentIndex = typeof assistantEvent?.contentIndex === \"number\" ? assistantEvent.contentIndex : undefined;\n\tif (contentIndex === undefined) return undefined;\n\tconst partial = assistantEvent?.partial;\n\tif (!isMessageLike(partial) || partial.role !== \"assistant\") return undefined;\n\tconst content = partial.content;\n\tif (!Array.isArray(content)) return undefined;\n\treturn toolCallPayload(content[contentIndex]);\n}\n\nfunction toolCallPayload(value: unknown):\n\t| {\n\t\t\ttype: \"tool_execution_start\";\n\t\t\ttoolCallId: string;\n\t\t\ttoolName: string;\n\t\t\targs: unknown;\n\t }\n\t| undefined {\n\tif (value === null || typeof value !== \"object\") return undefined;\n\tconst candidate = value as { type?: unknown; id?: unknown; name?: unknown; arguments?: unknown };\n\tif (candidate.type !== \"toolCall\") return undefined;\n\tif (typeof candidate.id !== \"string\" || typeof candidate.name !== \"string\") return undefined;\n\treturn {\n\t\ttype: \"tool_execution_start\",\n\t\ttoolCallId: candidate.id,\n\t\ttoolName: candidate.name,\n\t\targs: candidate.arguments ?? {},\n\t};\n}\n\nfunction legacyToolStartEvent(event: AgentSessionEvent): {\n\ttype: \"tool_execution_start\";\n\ttoolCallId: string;\n\ttoolName: string;\n\targs: unknown;\n} {\n\tconst payload = event as { toolCallId?: unknown; name?: unknown; input?: unknown; args?: unknown };\n\tconst toolName = typeof payload.name === \"string\" ? payload.name : \"tool\";\n\tconst toolCallId = typeof payload.toolCallId === \"string\" ? payload.toolCallId : `live-${toolName}`;\n\treturn {\n\t\ttype: \"tool_execution_start\",\n\t\ttoolCallId,\n\t\ttoolName,\n\t\targs: payload.input ?? payload.args ?? {},\n\t};\n}\n\nfunction legacyToolResultEvent(event: AgentSessionEvent): {\n\ttype: \"tool_execution_end\";\n\ttoolCallId: string;\n\ttoolName: string;\n\tresult: unknown;\n\tisError: boolean;\n} {\n\tconst payload = event as {\n\t\ttoolCallId?: unknown;\n\t\tname?: unknown;\n\t\toutput?: unknown;\n\t\tisError?: unknown;\n\t};\n\tconst toolName = typeof payload.name === \"string\" ? payload.name : \"tool\";\n\tconst toolCallId = typeof payload.toolCallId === \"string\" ? payload.toolCallId : `live-${toolName}`;\n\tconst output = payload.output;\n\treturn {\n\t\ttype: \"tool_execution_end\",\n\t\ttoolCallId,\n\t\ttoolName,\n\t\tresult:\n\t\t\toutput !== null && typeof output === \"object\" && \"content\" in output\n\t\t\t\t? output\n\t\t\t\t: { content: typeof output === \"string\" ? [{ type: \"text\", text: output }] : [] },\n\t\tisError: payload.isError === true,\n\t};\n}\n\nfunction legacyThinkingEvent(event: AgentSessionEvent): {\n\ttype: \"message_update\";\n\tassistantMessageEvent: { type: \"thinking_delta\"; contentIndex: number; delta: string };\n} {\n\tconst delta = String((event as { delta?: unknown }).delta ?? (event as { text?: unknown }).text ?? \"\");\n\treturn {\n\t\ttype: \"message_update\",\n\t\tassistantMessageEvent: { type: \"thinking_delta\", contentIndex: 0, delta },\n\t};\n}\n"]}
@@ -55,6 +55,10 @@ export declare class ChatSessionHostState<TExtraEntry extends ChatTranscriptEntr
55
55
  text: string;
56
56
  mode: ChatSessionSubmitMode;
57
57
  }[];
58
+ /** True while compaction-queued messages are being sent one at a time. */
59
+ compactionFlushPending: boolean;
60
+ /** Resolves the pending compaction-queue prompt when its run starts. */
61
+ compactionPromptStarted: (() => void) | undefined;
58
62
  compacting: boolean;
59
63
  /** Keeps input queued while automatic compaction hands off to a manual request. */
60
64
  manualCompactionTakeoverPending: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"chat-session-host-state.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EACX,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,uBAAuB,EACvB,KAAK,uBAAuB,EAC5B,2BAA2B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,WAAW,6BAA6B,CAAC,WAAW,SAAS,uBAAuB;IACzF,WAAW,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,WAA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C;QAAC,IAAI,EAAE,qBAAqB,CAAA;KAAE,EAAE,CAAM;IACxF,UAAU,UAAS;IACnB,mFAAmF;IACnF,+BAA+B,UAAS;IACxC,cAAc,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,GAAG,SAAS,CAAC;IAC3D,mBAAmB,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,SAAS,CAAC;IAC/D,YAAY,EAAE,2BAA2B,CAAC;IAC1C,mBAAmB,EAAE,uBAAuB,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC;IAChF,2BAA2B,SAAM;IACjC,iBAAiB,0BAAiC;IAClD,oBAAoB,SAAK;IACzB,QAAQ,EAAE,yBAAyB,CAAC;IACpC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;IACpC,6BAA6B,sBAA6B;IAC1D;;;;;;OAMG;IACH,0BAA0B,UAAQ;IAElC,YAAY,IAAI,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,6BAA6B,CAAC,WAAW,CAAC,EA2BxG;CACD"}
1
+ {"version":3,"file":"chat-session-host-state.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EACX,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,uBAAuB,EACvB,KAAK,uBAAuB,EAC5B,2BAA2B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B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,QAAQ,UAAS;IACjB,uBAAuB,EAAE,SAAS,MAAM,EAAE,CAAM;IAChD,uBAAuB,EAAE,SAAS,MAAM,EAAE,CAAM;IAChD,wBAAwB,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,qBAAqB,CAAA;KAAE,EAAE,CAAM;IACxF,0EAA0E;IAC1E,sBAAsB,UAAS;IAC/B,wEAAwE;IACxE,uBAAuB,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IAClD,UAAU,UAAS;IACnB,mFAAmF;IACnF,+BAA+B,UAAS;IACxC,cAAc,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,GAAG,SAAS,CAAC;IAC3D,mBAAmB,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,SAAS,CAAC;IAC/D,YAAY,EAAE,2BAA2B,CAAC;IAC1C,mBAAmB,EAAE,uBAAuB,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC;IAChF,2BAA2B,SAAM;IACjC,iBAAiB,0BAAiC;IAClD,oBAAoB,SAAK;IACzB,QAAQ,EAAE,yBAAyB,CAAC;IACpC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;IACpC,6BAA6B,sBAA6B;IAC1D;;;;;;OAMG;IACH,0BAA0B,UAAQ;IAElC,YAAY,IAAI,EAAE,mBAAmB,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,6BAA6B,CAAC,WAAW,CAAC,EA2BxG;CACD"}
@@ -43,6 +43,10 @@ export class ChatSessionHostState {
43
43
  pendingSteeringMessages = [];
44
44
  pendingFollowUpMessages = [];
45
45
  compactionQueuedMessages = [];
46
+ /** True while compaction-queued messages are being sent one at a time. */
47
+ compactionFlushPending = false;
48
+ /** Resolves the pending compaction-queue prompt when its run starts. */
49
+ compactionPromptStarted;
46
50
  compacting = false;
47
51
  /** Keeps input queued while automatic compaction hands off to a manual request. */
48
52
  manualCompactionTakeoverPending = false;
@@ -1 +1 @@
1
- {"version":3,"file":"chat-session-host-state.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-state.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAQvE,OAAO,EACN,uBAAuB,EAEvB,2BAA2B,GAC3B,MAAM,sBAAsB,CAAC;AAY9B,MAAM,OAAO,oBAAoB;IACvB,KAAK,CAAuB;IAC5B,QAAQ,CAA0B;IAClC,aAAa,CAA2B;IACxC,eAAe,CAA+C;IAC9D,mBAAmB,CAA8B;IACjD,QAAQ,CAA8B;IACtC,UAAU,CAA8B;IACxC,qBAAqB,CAA8B;IACnD,WAAW,CAA0C;IACrD,UAAU,CAA0C;IACpD,OAAO,CAAyD;IAChE,mBAAmB,CAA2C;IAC9D,gBAAgB,CAAoC;IACpD,qBAAqB,CAA4D;IACjF,MAAM,CAA6B;IACnC,UAAU,CAAyC;IACnD,gBAAgB,CAAkD;IAClE,GAAG,CAAkB;IAE9B,MAAM,CAA8B;IACpC,sBAAsB,GAAG,KAAK,CAAC;IAC/B,WAAW,GAAG,EAAE,CAAC;IACjB,UAAU,GAAwC,EAAE,CAAC;IACrD,YAAY,GAAkB,EAAE,CAAC;IACjC,aAAa,GAAG,EAAE,CAAC;IACnB,+FAA+F;IAC/F,kBAAkB,CAAqB;IACvC,UAAU,GAAG,KAAK,CAAC;IACnB,gBAAgB,GAAG,KAAK,CAAC;IACzB,OAAO,GAAG,KAAK,CAAC;IAChB,yEAAyE;IACzE,mBAAmB,CAA4B;IAC/C,4EAA4E;IAC5E,uBAAuB,CAAqB;IAC5C,cAAc,CAAqB;IACnC,YAAY,GAAG,CAAC,CAAC;IACjB,sBAAsB,CAAU;IAChC,0BAA0B,GAAG,CAAC,CAAC;IAC/B,2BAA2B,GAAG,KAAK,CAAC;IACpC,QAAQ,GAAG,KAAK,CAAC;IACjB,uBAAuB,GAAsB,EAAE,CAAC;IAChD,uBAAuB,GAAsB,EAAE,CAAC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AG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACpD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAC;QACxD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,yBAAyB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/D,IAAI,CAAC,mBAAmB,GAAG,IAAI,uBAAuB,CACrD,IAAI,CAAC,UAAU,EACf,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,EAC7C,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAClE,CAAC;IACH,CAAC;CACD","sourcesContent":["import type { Component, EditorComponent, MarkdownTheme, TUI } from \"@earendil-works/pi-tui\";\nimport type { AgentSession } from \"../../../core/agent-session.js\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.ts\";\nimport { LiveChatEntriesController } from \"./chat-message-renderer.ts\";\nimport type {\n\tChatSessionHostCommands,\n\tChatSessionHostEntry,\n\tChatSessionHostOpts,\n\tChatSessionHostStyle,\n\tChatSessionSubmitMode,\n} from \"./chat-session-host-types.ts\";\nimport {\n\tChatTranscriptComponent,\n\ttype ChatTranscriptEntryLike,\n\tScrollableComponentViewport,\n} from \"./chat-transcript.js\";\nimport type { FooterComponent } from \"./footer.ts\";\n\nexport interface ChatSessionHostStateCallbacks<TExtraEntry extends ChatTranscriptEntryLike> {\n\trenderEntry: (state: ChatSessionHostState<TExtraEntry>, entry: ChatSessionHostEntry<TExtraEntry>) => Component;\n\ttranscriptCacheKey: (\n\t\tstate: ChatSessionHostState<TExtraEntry>,\n\t\tentry: ChatSessionHostEntry<TExtraEntry>,\n\t\tindex: number,\n\t) => string;\n}\n\nexport class ChatSessionHostState<TExtraEntry extends ChatTranscriptEntryLike = never> {\n\treadonly style: ChatSessionHostStyle;\n\treadonly commands: ChatSessionHostCommands;\n\treadonly requestRender: (() => void) | undefined;\n\treadonly getAgentSession: (() => AgentSession | undefined) | undefined;\n\treadonly isStreamingOverride: (() => boolean) | undefined;\n\treadonly isPaused: (() => boolean) | undefined;\n\treadonly isDisabled: (() => boolean) | undefined;\n\treadonly isBashRunningOverride: (() => boolean) | undefined;\n\treadonly showWarning: ((message: string) => void) | undefined;\n\treadonly showStatus: ((message: string) => void) | undefined;\n\treadonly actions: Record<string, () => void | Promise<void>> | undefined;\n\treadonly getActionKeyDisplay: ((action: string) => string) | undefined;\n\treadonly getMarkdownTheme: (() => MarkdownTheme) | undefined;\n\treadonly getChatRenderSettings: ChatSessionHostOpts<TExtraEntry>[\"getChatRenderSettings\"];\n\treadonly getCwd: (() => string) | undefined;\n\treadonly footerData: ReadonlyFooterDataProvider | undefined;\n\treadonly renderExtraEntry: ((entry: TExtraEntry) => Component) | undefined;\n\treadonly tui: TUI | undefined;\n\n\tfooter: FooterComponent | undefined;\n\tfooterNavigationActive = false;\n\tinputBuffer = \"\";\n\ttranscript: ChatSessionHostEntry<TExtraEntry>[] = [];\n\textraEntries: TExtraEntry[] = [];\n\tstatusMessage = \"\";\n\t/** Explicit diagnostics survive busy-state cleanup, but are not restored after later input. */\n\tlastWarningMessage: string | undefined;\n\tisBashMode = false;\n\tlocalBashRunning = false;\n\tsdkBusy = false;\n\t/** Escape interrupt plus asynchronous workflow pause acknowledgement. */\n\tinterruptSettlement: Promise<void> | undefined;\n\t/** Recorded pause failure consumed by the first submit after settlement. */\n\tinterruptFailureMessage: string | undefined;\n\tworkingMessage: string | undefined;\n\tworkingFrame = 0;\n\tworkingLifecycleActive: boolean;\n\tworkingLifecycleGeneration = 0;\n\timmediateEventRenderPending = false;\n\tdisposed = false;\n\tpendingSteeringMessages: readonly string[] = [];\n\tpendingFollowUpMessages: readonly string[] = [];\n\tcompactionQueuedMessages: readonly { text: string; mode: ChatSessionSubmitMode }[] = [];\n\tcompacting = false;\n\t/** Keeps input queued while automatic compaction hands off to a manual request. */\n\tmanualCompactionTakeoverPending = false;\n\tanimationTimer: ReturnType<typeof setInterval> | undefined;\n\trenderThrottleTimer: ReturnType<typeof setTimeout> | undefined;\n\tbodyViewport: ScrollableComponentViewport;\n\ttranscriptComponent: ChatTranscriptComponent<ChatSessionHostEntry<TExtraEntry>>;\n\ttranscriptRenderSettingsKey = \"\";\n\trenderIdentityIds = new WeakMap<object, number>();\n\tnextRenderIdentityId = 1;\n\tliveChat: LiveChatEntriesController;\n\teditor: EditorComponent | undefined;\n\toptimisticUserSignatureCounts = new Map<string, number>();\n\t/**\n\t * Whether an assistant entry still streaming into a sticky-bottom body is\n\t * rendered as its tail alone.\n\t *\n\t * On by default: while the reader is following a live stream, the rows far\n\t * above the cursor cost layout work nobody is reading.\n\t */\n\tstreamingTailWindowEnabled = true;\n\n\tconstructor(opts: ChatSessionHostOpts<TExtraEntry>, callbacks: ChatSessionHostStateCallbacks<TExtraEntry>) {\n\t\tthis.style = opts.style;\n\t\tthis.commands = opts.commands ?? {};\n\t\tthis.bodyViewport = new ScrollableComponentViewport(opts.keybindings);\n\t\tthis.requestRender = opts.requestRender;\n\t\tthis.getAgentSession = opts.getAgentSession;\n\t\tthis.isStreamingOverride = opts.isStreaming;\n\t\tthis.workingLifecycleActive = opts.isStreaming?.() === true;\n\t\tthis.isPaused = opts.isPaused;\n\t\tthis.isDisabled = opts.isDisabled;\n\t\tthis.isBashRunningOverride = opts.isBashRunning;\n\t\tthis.showWarning = opts.showWarning;\n\t\tthis.showStatus = opts.showStatus;\n\t\tthis.actions = opts.actions;\n\t\tthis.getActionKeyDisplay = opts.getActionKeyDisplay;\n\t\tthis.getMarkdownTheme = opts.getMarkdownTheme;\n\t\tthis.getChatRenderSettings = opts.getChatRenderSettings;\n\t\tthis.getCwd = opts.getCwd;\n\t\tthis.footerData = opts.footerData;\n\t\tthis.renderExtraEntry = opts.renderExtraEntry;\n\t\tthis.tui = opts.tui;\n\t\tthis.liveChat = new LiveChatEntriesController(this.transcript);\n\t\tthis.transcriptComponent = new ChatTranscriptComponent(\n\t\t\tthis.transcript,\n\t\t\t(entry) => callbacks.renderEntry(this, entry),\n\t\t\t(entry, index) => callbacks.transcriptCacheKey(this, entry, index),\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"chat-session-host-state.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/chat-session-host-state.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAQvE,OAAO,EACN,uBAAuB,EAEvB,2BAA2B,GAC3B,MAAM,sBAAsB,CAAC;AAY9B,MAAM,OAAO,oBAAoB;IACvB,KAAK,CAAuB;IAC5B,QAAQ,CAA0B;IAClC,aAAa,CAA2B;IACxC,eAAe,CAA+C;IAC9D,mBAAmB,CAA8B;IACjD,QAAQ,CAA8B;IACtC,UAAU,CAA8B;IACxC,qBAAqB,CAA8B;IACnD,WAAW,CAA0C;IACrD,UAAU,CAA0C;IACpD,OAAO,CAAyD;IAChE,mBAAmB,CAA2C;IAC9D,gBAAgB,CAAoC;IACpD,qBAAqB,CAA4D;IACjF,MAAM,CAA6B;IACnC,UAAU,CAAyC;IACnD,gBAAgB,CAAkD;IAClE,GAAG,CAAkB;IAE9B,MAAM,CAA8B;IACpC,sBAAsB,GAAG,KAAK,CAAC;IAC/B,WAAW,GAAG,EAAE,CAAC;IACjB,UAAU,GAAwC,EAAE,CAAC;IACrD,Y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E,KAAK,CAAC,EAC7C,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAClE,CAAC;IACH,CAAC;CACD","sourcesContent":["import type { Component, EditorComponent, MarkdownTheme, TUI } from \"@earendil-works/pi-tui\";\nimport type { AgentSession } from \"../../../core/agent-session.js\";\nimport type { ReadonlyFooterDataProvider } from \"../../../core/footer-data-provider.ts\";\nimport { LiveChatEntriesController } from \"./chat-message-renderer.ts\";\nimport type {\n\tChatSessionHostCommands,\n\tChatSessionHostEntry,\n\tChatSessionHostOpts,\n\tChatSessionHostStyle,\n\tChatSessionSubmitMode,\n} from \"./chat-session-host-types.ts\";\nimport {\n\tChatTranscriptComponent,\n\ttype ChatTranscriptEntryLike,\n\tScrollableComponentViewport,\n} from \"./chat-transcript.js\";\nimport type { FooterComponent } from \"./footer.ts\";\n\nexport interface ChatSessionHostStateCallbacks<TExtraEntry extends ChatTranscriptEntryLike> {\n\trenderEntry: (state: ChatSessionHostState<TExtraEntry>, entry: ChatSessionHostEntry<TExtraEntry>) => Component;\n\ttranscriptCacheKey: (\n\t\tstate: ChatSessionHostState<TExtraEntry>,\n\t\tentry: ChatSessionHostEntry<TExtraEntry>,\n\t\tindex: number,\n\t) => string;\n}\n\nexport class ChatSessionHostState<TExtraEntry extends ChatTranscriptEntryLike = never> {\n\treadonly style: ChatSessionHostStyle;\n\treadonly commands: ChatSessionHostCommands;\n\treadonly requestRender: (() => void) | undefined;\n\treadonly getAgentSession: (() => AgentSession | undefined) | undefined;\n\treadonly isStreamingOverride: (() => boolean) | undefined;\n\treadonly isPaused: (() => boolean) | undefined;\n\treadonly isDisabled: (() => boolean) | undefined;\n\treadonly isBashRunningOverride: (() => boolean) | undefined;\n\treadonly showWarning: ((message: string) => void) | undefined;\n\treadonly showStatus: ((message: string) => void) | undefined;\n\treadonly actions: Record<string, () => void | Promise<void>> | undefined;\n\treadonly getActionKeyDisplay: ((action: string) => string) | undefined;\n\treadonly getMarkdownTheme: (() => MarkdownTheme) | undefined;\n\treadonly getChatRenderSettings: ChatSessionHostOpts<TExtraEntry>[\"getChatRenderSettings\"];\n\treadonly getCwd: (() => string) | undefined;\n\treadonly footerData: ReadonlyFooterDataProvider | undefined;\n\treadonly renderExtraEntry: ((entry: TExtraEntry) => Component) | undefined;\n\treadonly tui: TUI | undefined;\n\n\tfooter: FooterComponent | undefined;\n\tfooterNavigationActive = false;\n\tinputBuffer = \"\";\n\ttranscript: ChatSessionHostEntry<TExtraEntry>[] = [];\n\textraEntries: TExtraEntry[] = [];\n\tstatusMessage = \"\";\n\t/** Explicit diagnostics survive busy-state cleanup, but are not restored after later input. */\n\tlastWarningMessage: string | undefined;\n\tisBashMode = false;\n\tlocalBashRunning = false;\n\tsdkBusy = false;\n\t/** Escape interrupt plus asynchronous workflow pause acknowledgement. */\n\tinterruptSettlement: Promise<void> | undefined;\n\t/** Recorded pause failure consumed by the first submit after settlement. */\n\tinterruptFailureMessage: string | undefined;\n\tworkingMessage: string | undefined;\n\tworkingFrame = 0;\n\tworkingLifecycleActive: boolean;\n\tworkingLifecycleGeneration = 0;\n\timmediateEventRenderPending = false;\n\tdisposed = false;\n\tpendingSteeringMessages: readonly string[] = [];\n\tpendingFollowUpMessages: readonly string[] = [];\n\tcompactionQueuedMessages: readonly { text: string; mode: ChatSessionSubmitMode }[] = [];\n\t/** True while compaction-queued messages are being sent one at a time. */\n\tcompactionFlushPending = false;\n\t/** Resolves the pending compaction-queue prompt when its run starts. */\n\tcompactionPromptStarted: (() => void) | undefined;\n\tcompacting = false;\n\t/** Keeps input queued while automatic compaction hands off to a manual request. */\n\tmanualCompactionTakeoverPending = false;\n\tanimationTimer: ReturnType<typeof setInterval> | undefined;\n\trenderThrottleTimer: ReturnType<typeof setTimeout> | undefined;\n\tbodyViewport: ScrollableComponentViewport;\n\ttranscriptComponent: ChatTranscriptComponent<ChatSessionHostEntry<TExtraEntry>>;\n\ttranscriptRenderSettingsKey = \"\";\n\trenderIdentityIds = new WeakMap<object, number>();\n\tnextRenderIdentityId = 1;\n\tliveChat: LiveChatEntriesController;\n\teditor: EditorComponent | undefined;\n\toptimisticUserSignatureCounts = new Map<string, number>();\n\t/**\n\t * Whether an assistant entry still streaming into a sticky-bottom body is\n\t * rendered as its tail alone.\n\t *\n\t * On by default: while the reader is following a live stream, the rows far\n\t * above the cursor cost layout work nobody is reading.\n\t */\n\tstreamingTailWindowEnabled = true;\n\n\tconstructor(opts: ChatSessionHostOpts<TExtraEntry>, callbacks: ChatSessionHostStateCallbacks<TExtraEntry>) {\n\t\tthis.style = opts.style;\n\t\tthis.commands = opts.commands ?? {};\n\t\tthis.bodyViewport = new ScrollableComponentViewport(opts.keybindings);\n\t\tthis.requestRender = opts.requestRender;\n\t\tthis.getAgentSession = opts.getAgentSession;\n\t\tthis.isStreamingOverride = opts.isStreaming;\n\t\tthis.workingLifecycleActive = opts.isStreaming?.() === true;\n\t\tthis.isPaused = opts.isPaused;\n\t\tthis.isDisabled = opts.isDisabled;\n\t\tthis.isBashRunningOverride = opts.isBashRunning;\n\t\tthis.showWarning = opts.showWarning;\n\t\tthis.showStatus = opts.showStatus;\n\t\tthis.actions = opts.actions;\n\t\tthis.getActionKeyDisplay = opts.getActionKeyDisplay;\n\t\tthis.getMarkdownTheme = opts.getMarkdownTheme;\n\t\tthis.getChatRenderSettings = opts.getChatRenderSettings;\n\t\tthis.getCwd = opts.getCwd;\n\t\tthis.footerData = opts.footerData;\n\t\tthis.renderExtraEntry = opts.renderExtraEntry;\n\t\tthis.tui = opts.tui;\n\t\tthis.liveChat = new LiveChatEntriesController(this.transcript);\n\t\tthis.transcriptComponent = new ChatTranscriptComponent(\n\t\t\tthis.transcript,\n\t\t\t(entry) => callbacks.renderEntry(this, entry),\n\t\t\t(entry, index) => callbacks.transcriptCacheKey(this, entry, index),\n\t\t);\n\t}\n}\n"]}
@@ -239,9 +239,7 @@ export class SessionSelectorComponent extends Container {
239
239
  this.requestRender();
240
240
  };
241
241
  try {
242
- const sessions = await (scope === "current"
243
- ? this.currentSessionsLoader(onProgress)
244
- : this.allSessionsLoader(onProgress));
242
+ const sessions = (await (scope === "current" ? this.currentSessionsLoader(onProgress) : this.allSessionsLoader(onProgress))).filter(isResumableSession);
245
243
  if (scope === "current") {
246
244
  this.currentSessions = sessions;
247
245
  this.currentLoading = false;
@@ -345,4 +343,7 @@ export class SessionSelectorComponent extends Container {
345
343
  this.header.setStatusMessage(null);
346
344
  }
347
345
  }
346
+ function isResumableSession(session) {
347
+ return session.messageCount > 0 || session.hasName === true || session.summary !== undefined;
348
+ }
348
349
  //# sourceMappingURL=session-selector.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"session-selector.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/session-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAkB,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACxH,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAgC,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAIzD;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,SAAS;IACtD,WAAW,CAAC,IAAY;QACvB,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC5B,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC;YAC5B,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,mBAAmB,CAAC,EA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,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAEjC,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;gBAC/B,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;gBAC9B,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBACrD,IAAI,CAAC,aAAa,EAAE,CAAC;gBACrB,OAAO;YACR,CAAC;YAED,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;gBACtB,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YACtC,CAAC;YACD,OAAO;QACR,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC5C,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,eAAe,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;QAChE,IAAI,CAAC,aAAa,EAAE,CAAC;IACtB,CAAC;IAED,cAAc;QACb,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,OAAO;QACN,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,2EAA2E;QAC3E,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACD","sourcesContent":["import { type Component, Container, type Focusable, getKeybindings, Input, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport { KeybindingsManager } from \"../../../core/keybindings.ts\";\nimport type { SessionInfo } from \"../../../core/session-manager.ts\";\nimport { theme } from \"../theme/theme.js\";\nimport { DynamicBorder } from \"./dynamic-border.ts\";\nimport { keyText } from \"./keybinding-hints.js\";\nimport { type DeleteSessionFileResult, deleteSessionFile } from \"./session-selector-delete.ts\";\nimport { SessionSelectorHeader } from \"./session-selector-header.ts\";\nimport { SessionList } from \"./session-selector-list.ts\";\nimport type { NameFilter, SortMode } from \"./session-selector-search.ts\";\nimport type { SessionScope, SessionsLoader } from \"./session-selector-types.ts\";\n\n/**\n * Component that renders a session selector\n */\nexport class SessionSelectorComponent extends Container implements Focusable {\n\thandleInput(data: string): boolean {\n\t\tif (this.mode === \"rename\") {\n\t\t\tconst kb = getKeybindings();\n\t\t\tif (kb.matches(data, \"tui.select.cancel\")) {\n\t\t\t\tthis.exitRenameMode();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tthis.renameInput.handleInput(data);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn this.sessionList.handleInput(data);\n\t}\n\n\tprivate canRename = true;\n\tprivate sessionList: SessionList;\n\tprivate header: SessionSelectorHeader;\n\tprivate keybindings: KeybindingsManager;\n\tprivate scope: SessionScope = \"current\";\n\tprivate sortMode: SortMode = \"threaded\";\n\tprivate nameFilter: NameFilter = \"all\";\n\tprivate currentSessions: SessionInfo[] | null = null;\n\tprivate allSessions: SessionInfo[] | null = null;\n\tprivate currentSessionsLoader: SessionsLoader;\n\tprivate allSessionsLoader: SessionsLoader;\n\tprivate onCancel: () => void;\n\tprivate requestRender: () => void;\n\tprivate renameSession?: (session: SessionInfo, currentName: string | undefined) => Promise<void>;\n\tprivate currentLoading = false;\n\tprivate allLoading = false;\n\tprivate allLoadSeq = 0;\n\tprivate disposed = false;\n\n\tprivate mode: \"list\" | \"rename\" = \"list\";\n\tprivate renameInput = new Input();\n\tprivate renameTarget: SessionInfo | null = null;\n\n\t// Focusable implementation - propagate to sessionList for IME cursor positioning\n\tprivate _focused = false;\n\tget focused(): boolean {\n\t\treturn this._focused;\n\t}\n\tset focused(value: boolean) {\n\t\tthis._focused = value;\n\t\tthis.sessionList.focused = value;\n\t\tthis.renameInput.focused = value;\n\t\tif (value && this.mode === \"rename\") {\n\t\t\tthis.renameInput.focused = true;\n\t\t}\n\t}\n\n\tprivate buildBaseLayout(content: Component, options?: { showHeader?: boolean }): void {\n\t\tthis.clear();\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new DynamicBorder((s) => theme.fg(\"accent\", s)));\n\t\tthis.addChild(new Spacer(1));\n\t\tif (options?.showHeader ?? true) {\n\t\t\tthis.addChild(this.header);\n\t\t\tthis.addChild(new Spacer(1));\n\t\t}\n\t\tthis.addChild(content);\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new DynamicBorder((s) => theme.fg(\"accent\", s)));\n\t}\n\n\tconstructor(\n\t\tcurrentSessionsLoader: SessionsLoader,\n\t\tallSessionsLoader: SessionsLoader,\n\t\tonSelect: (session: SessionInfo) => void,\n\t\tonCancel: () => void,\n\t\tonExit: () => void,\n\t\trequestRender: () => void,\n\t\toptions?: {\n\t\t\trenameSession?: (session: SessionInfo, currentName: string | undefined) => Promise<void>;\n\t\t\tdeleteSession?: (sessionId: string) => Promise<void>;\n\t\t\tshowRenameHint?: boolean;\n\t\t\tkeybindings?: KeybindingsManager;\n\t\t\t/**\n\t\t\t * Rows to display in the first rendered frame before the async loader\n\t\t\t * resolves (e.g. cheap in-memory live workflow runs). Seeding lets the\n\t\t\t * selector mount and stay interactive while durable/on-disk rows load,\n\t\t\t * and keeps live rows visible if the loader later errors.\n\t\t\t */\n\t\t\tinitialSessions?: SessionInfo[];\n\t\t},\n\t\tcurrentSession?: { id: string; directory: string },\n\t) {\n\t\tsuper();\n\t\tthis.keybindings = options?.keybindings ?? KeybindingsManager.create();\n\t\tthis.currentSessionsLoader = currentSessionsLoader;\n\t\tthis.allSessionsLoader = allSessionsLoader;\n\t\tthis.onCancel = onCancel;\n\t\tthis.requestRender = requestRender;\n\t\tthis.header = new SessionSelectorHeader(this.scope, this.sortMode, this.nameFilter, this.requestRender);\n\t\tconst renameSession = options?.renameSession;\n\t\tthis.renameSession = renameSession;\n\t\tthis.canRename = !!renameSession;\n\t\tthis.header.setShowRenameHint(options?.showRenameHint ?? this.canRename);\n\n\t\t// Create the session list. Seed with any provided initial rows so the very\n\t\t// first frame is populated (kept minimal/in-memory by the caller) while the\n\t\t// async loader resolves the full catalog off the host hot path.\n\t\tconst initialSessions = options?.initialSessions;\n\t\tthis.sessionList = new SessionList(\n\t\t\tinitialSessions ?? [],\n\t\t\tfalse,\n\t\t\tthis.sortMode,\n\t\t\tthis.nameFilter,\n\t\t\tthis.keybindings,\n\t\t\toptions?.deleteSession && currentSession ? { id: currentSession.id } : currentSession,\n\t\t);\n\t\tif (initialSessions !== undefined) {\n\t\t\tthis.currentSessions = initialSessions;\n\t\t}\n\n\t\tthis.buildBaseLayout(this.sessionList);\n\n\t\tthis.renameInput.onSubmit = (value) => {\n\t\t\tvoid this.confirmRename(value);\n\t\t};\n\n\t\t// Ensure header status timeouts are cleared when leaving the selector\n\t\tconst clearStatusMessage = () => this.header.setStatusMessage(null);\n\t\tthis.sessionList.onSelect = (session) => {\n\t\t\tclearStatusMessage();\n\t\t\tonSelect(session);\n\t\t};\n\t\tthis.sessionList.onCancel = () => {\n\t\t\tclearStatusMessage();\n\t\t\tonCancel();\n\t\t};\n\t\tthis.sessionList.onExit = () => {\n\t\t\tclearStatusMessage();\n\t\t\tonExit();\n\t\t};\n\t\tthis.sessionList.onToggleScope = () => this.toggleScope();\n\t\tthis.sessionList.onToggleSort = () => this.toggleSortMode();\n\t\tthis.sessionList.onToggleNameFilter = () => this.toggleNameFilter();\n\t\tthis.sessionList.onRenameSession = (session) => {\n\t\t\tif (!renameSession) return;\n\t\t\tif (this.scope === \"current\" && this.currentLoading) return;\n\t\t\tif (this.scope === \"all\" && this.allLoading) return;\n\t\t\tthis.enterRenameMode(session);\n\t\t};\n\n\t\t// Sync list events to header\n\t\tthis.sessionList.onTogglePath = (showPath) => {\n\t\t\tthis.header.setShowPath(showPath);\n\t\t\tthis.requestRender();\n\t\t};\n\t\tthis.sessionList.onDeleteConfirmationChange = (path) => {\n\t\t\tthis.header.setConfirmingDeletePath(path);\n\t\t\tthis.requestRender();\n\t\t};\n\t\tthis.sessionList.onError = (msg) => {\n\t\t\tthis.header.setStatusMessage({ type: \"error\", message: msg }, 3000);\n\t\t\tthis.requestRender();\n\t\t};\n\n\t\t// Handle session deletion\n\t\tthis.sessionList.onDeleteSession = async (sessionPath, session) => {\n\t\t\tlet result: DeleteSessionFileResult;\n\t\t\ttry {\n\t\t\t\tif (options?.deleteSession) {\n\t\t\t\t\tawait options.deleteSession(session.id);\n\t\t\t\t\tresult = { ok: true, method: \"store\" };\n\t\t\t\t} else result = await deleteSessionFile(sessionPath);\n\t\t\t} catch (error) {\n\t\t\t\tresult = { ok: false, method: \"store\", error: error instanceof Error ? error.message : String(error) };\n\t\t\t}\n\n\t\t\tif (result.ok) {\n\t\t\t\tif (this.currentSessions) {\n\t\t\t\t\tthis.currentSessions = this.currentSessions.filter((s) =>\n\t\t\t\t\t\toptions?.deleteSession ? s.id !== session.id : s.path !== sessionPath,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (this.allSessions) {\n\t\t\t\t\tthis.allSessions = this.allSessions.filter((s) =>\n\t\t\t\t\t\toptions?.deleteSession ? s.id !== session.id : s.path !== sessionPath,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst sessions = this.scope === \"all\" ? (this.allSessions ?? []) : (this.currentSessions ?? []);\n\t\t\t\tconst showCwd = this.scope === \"all\";\n\t\t\t\tthis.sessionList.setSessions(sessions, showCwd);\n\n\t\t\t\tconst msg = result.method === \"trash\" ? \"Session moved to trash\" : \"Session deleted\";\n\t\t\t\tthis.header.setStatusMessage({ type: \"info\", message: msg }, 2000);\n\t\t\t\tawait this.refreshSessionsAfterMutation();\n\t\t\t} else {\n\t\t\t\tconst errorMessage = result.error ?? \"Unknown error\";\n\t\t\t\tthis.header.setStatusMessage({ type: \"error\", message: `Failed to delete: ${errorMessage}` }, 3000);\n\t\t\t}\n\n\t\t\tthis.requestRender();\n\t\t};\n\n\t\t// Start loading current sessions immediately\n\t\tthis.loadCurrentSessions();\n\t}\n\n\tprivate loadCurrentSessions(): void {\n\t\tvoid this.loadScope(\"current\", \"initial\");\n\t}\n\n\tprivate enterRenameMode(session: SessionInfo): void {\n\t\tthis.mode = \"rename\";\n\t\tthis.renameTarget = session;\n\t\tthis.renameInput.setValue(session.name ?? \"\");\n\t\tthis.renameInput.focused = true;\n\n\t\tconst panel = new Container();\n\t\tpanel.addChild(new Text(theme.bold(\"Rename Session\"), 1, 0));\n\t\tpanel.addChild(new Spacer(1));\n\t\tpanel.addChild(this.renameInput);\n\t\tpanel.addChild(new Spacer(1));\n\t\tpanel.addChild(\n\t\t\tnew Text(\n\t\t\t\ttheme.fg(\"muted\", `${keyText(\"tui.select.confirm\")} Save · ${keyText(\"tui.select.cancel\")} Cancel`),\n\t\t\t\t1,\n\t\t\t\t0,\n\t\t\t),\n\t\t);\n\n\t\tthis.buildBaseLayout(panel, { showHeader: false });\n\t\tthis.requestRender();\n\t}\n\n\tprivate exitRenameMode(): void {\n\t\tthis.mode = \"list\";\n\t\tthis.renameTarget = null;\n\n\t\tthis.buildBaseLayout(this.sessionList);\n\n\t\tthis.requestRender();\n\t}\n\n\tprivate async confirmRename(value: string): Promise<void> {\n\t\tconst next = value.trim();\n\t\tif (!next) return;\n\t\tconst target = this.renameTarget;\n\t\tif (!target) {\n\t\t\tthis.exitRenameMode();\n\t\t\treturn;\n\t\t}\n\n\t\t// Find current name for callback\n\t\tconst renameSession = this.renameSession;\n\t\tif (!renameSession) {\n\t\t\tthis.exitRenameMode();\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait renameSession(target, next);\n\t\t\tawait this.refreshSessionsAfterMutation();\n\t\t} finally {\n\t\t\tthis.exitRenameMode();\n\t\t}\n\t}\n\n\tprivate async loadScope(scope: SessionScope, reason: \"initial\" | \"refresh\" | \"toggle\"): Promise<void> {\n\t\tconst showCwd = scope === \"all\";\n\n\t\t// Mark loading\n\t\tif (scope === \"current\") {\n\t\t\tthis.currentLoading = true;\n\t\t} else {\n\t\t\tthis.allLoading = true;\n\t\t}\n\n\t\tconst seq = scope === \"all\" ? ++this.allLoadSeq : undefined;\n\t\tthis.header.setScope(scope);\n\t\tthis.header.setLoading(true);\n\t\tthis.requestRender();\n\n\t\tconst onProgress = (loaded: number, total: number) => {\n\t\t\tif (this.disposed) return;\n\t\t\tif (scope !== this.scope) return;\n\t\t\tif (seq !== undefined && seq !== this.allLoadSeq) return;\n\t\t\tthis.header.setProgress(loaded, total);\n\t\t\tthis.requestRender();\n\t\t};\n\n\t\ttry {\n\t\t\tconst sessions = await (scope === \"current\"\n\t\t\t\t? this.currentSessionsLoader(onProgress)\n\t\t\t\t: this.allSessionsLoader(onProgress));\n\n\t\t\tif (scope === \"current\") {\n\t\t\t\tthis.currentSessions = sessions;\n\t\t\t\tthis.currentLoading = false;\n\t\t\t} else {\n\t\t\t\tthis.allSessions = sessions;\n\t\t\t\tthis.allLoading = false;\n\t\t\t}\n\n\t\t\t// Stale-result guards: ignore a resolved load after the selector was\n\t\t\t// closed, the visible scope changed, or a newer all-scope load started.\n\t\t\tif (this.disposed) return;\n\t\t\tif (scope !== this.scope) return;\n\t\t\tif (seq !== undefined && seq !== this.allLoadSeq) return;\n\n\t\t\tthis.header.setLoading(false);\n\t\t\tthis.sessionList.setSessions(sessions, showCwd);\n\t\t\tthis.requestRender();\n\n\t\t\tif (scope === \"all\" && sessions.length === 0 && (this.currentSessions?.length ?? 0) === 0) {\n\t\t\t\tthis.onCancel();\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tif (scope === \"current\") {\n\t\t\t\tthis.currentLoading = false;\n\t\t\t} else {\n\t\t\t\tthis.allLoading = false;\n\t\t\t}\n\n\t\t\tif (this.disposed) return;\n\t\t\tif (scope !== this.scope) return;\n\t\t\tif (seq !== undefined && seq !== this.allLoadSeq) return;\n\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\tthis.header.setLoading(false);\n\t\t\tthis.header.setStatusMessage({ type: \"error\", message: `Failed to load sessions: ${message}` }, 4000);\n\n\t\t\t// Only blank the list on the initial load when there is nothing already\n\t\t\t// on screen. Seeded live rows must survive a loader failure so errors\n\t\t\t// render inside the still-usable picker (contract §2).\n\t\t\tconst seeded = scope === \"current\" ? this.currentSessions : this.allSessions;\n\t\t\tif (reason === \"initial\" && (seeded === null || seeded.length === 0)) {\n\t\t\t\tthis.sessionList.setSessions([], showCwd);\n\t\t\t}\n\t\t\tthis.requestRender();\n\t\t}\n\t}\n\n\tprivate toggleSortMode(): void {\n\t\t// Cycle: threaded -> recent -> relevance -> threaded\n\t\tthis.sortMode = this.sortMode === \"threaded\" ? \"recent\" : this.sortMode === \"recent\" ? \"relevance\" : \"threaded\";\n\t\tthis.header.setSortMode(this.sortMode);\n\t\tthis.sessionList.setSortMode(this.sortMode);\n\t\tthis.requestRender();\n\t}\n\n\tprivate toggleNameFilter(): void {\n\t\tthis.nameFilter = this.nameFilter === \"all\" ? \"named\" : \"all\";\n\t\tthis.header.setNameFilter(this.nameFilter);\n\t\tthis.sessionList.setNameFilter(this.nameFilter);\n\t\tthis.requestRender();\n\t}\n\n\tprivate async refreshSessionsAfterMutation(): Promise<void> {\n\t\tawait this.loadScope(this.scope, \"refresh\");\n\t}\n\n\tprivate toggleScope(): void {\n\t\tif (this.scope === \"current\") {\n\t\t\tthis.scope = \"all\";\n\t\t\tthis.header.setScope(this.scope);\n\n\t\t\tif (this.allSessions !== null) {\n\t\t\t\tthis.header.setLoading(false);\n\t\t\t\tthis.sessionList.setSessions(this.allSessions, true);\n\t\t\t\tthis.requestRender();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!this.allLoading) {\n\t\t\t\tvoid this.loadScope(\"all\", \"toggle\");\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tthis.scope = \"current\";\n\t\tthis.header.setScope(this.scope);\n\t\tthis.header.setLoading(this.currentLoading);\n\t\tthis.sessionList.setSessions(this.currentSessions ?? [], false);\n\t\tthis.requestRender();\n\t}\n\n\tgetSessionList(): SessionList {\n\t\treturn this.sessionList;\n\t}\n\n\t/**\n\t * Mark the selector closed so any in-flight or late-resolving loads are\n\t * ignored (stale-result guard) and status timeouts are cleared. Idempotent;\n\t * safe to call from close/select/cancel/dispose paths.\n\t */\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\t// Invalidate any pending all-scope load so its seq check fails on resolve.\n\t\tthis.allLoadSeq += 1;\n\t\tthis.header.setStatusMessage(null);\n\t}\n}\n"]}
1
+ {"version":3,"file":"session-selector.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/session-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAkB,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACxH,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAgC,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAIzD;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,SAAS;IACtD,WAAW,CAAC,IAAY;QACvB,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC5B,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC;YAC5B,IAAI,EAAE,CA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B;IAC/C,OAAO,OAAO,CAAC,YAAY,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,CAAC;AAC9F,CAAC","sourcesContent":["import { type Component, Container, type Focusable, getKeybindings, Input, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport { KeybindingsManager } from \"../../../core/keybindings.ts\";\nimport type { SessionInfo } from \"../../../core/session-manager.ts\";\nimport { theme } from \"../theme/theme.js\";\nimport { DynamicBorder } from \"./dynamic-border.ts\";\nimport { keyText } from \"./keybinding-hints.js\";\nimport { type DeleteSessionFileResult, deleteSessionFile } from \"./session-selector-delete.ts\";\nimport { SessionSelectorHeader } from \"./session-selector-header.ts\";\nimport { SessionList } from \"./session-selector-list.ts\";\nimport type { NameFilter, SortMode } from \"./session-selector-search.ts\";\nimport type { SessionScope, SessionsLoader } from \"./session-selector-types.ts\";\n\n/**\n * Component that renders a session selector\n */\nexport class SessionSelectorComponent extends Container implements Focusable {\n\thandleInput(data: string): boolean {\n\t\tif (this.mode === \"rename\") {\n\t\t\tconst kb = getKeybindings();\n\t\t\tif (kb.matches(data, \"tui.select.cancel\")) {\n\t\t\t\tthis.exitRenameMode();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tthis.renameInput.handleInput(data);\n\t\t\treturn true;\n\t\t}\n\n\t\treturn this.sessionList.handleInput(data);\n\t}\n\n\tprivate canRename = true;\n\tprivate sessionList: SessionList;\n\tprivate header: SessionSelectorHeader;\n\tprivate keybindings: KeybindingsManager;\n\tprivate scope: SessionScope = \"current\";\n\tprivate sortMode: SortMode = \"threaded\";\n\tprivate nameFilter: NameFilter = \"all\";\n\tprivate currentSessions: SessionInfo[] | null = null;\n\tprivate allSessions: SessionInfo[] | null = null;\n\tprivate currentSessionsLoader: SessionsLoader;\n\tprivate allSessionsLoader: SessionsLoader;\n\tprivate onCancel: () => void;\n\tprivate requestRender: () => void;\n\tprivate renameSession?: (session: SessionInfo, currentName: string | undefined) => Promise<void>;\n\tprivate currentLoading = false;\n\tprivate allLoading = false;\n\tprivate allLoadSeq = 0;\n\tprivate disposed = false;\n\n\tprivate mode: \"list\" | \"rename\" = \"list\";\n\tprivate renameInput = new Input();\n\tprivate renameTarget: SessionInfo | null = null;\n\n\t// Focusable implementation - propagate to sessionList for IME cursor positioning\n\tprivate _focused = false;\n\tget focused(): boolean {\n\t\treturn this._focused;\n\t}\n\tset focused(value: boolean) {\n\t\tthis._focused = value;\n\t\tthis.sessionList.focused = value;\n\t\tthis.renameInput.focused = value;\n\t\tif (value && this.mode === \"rename\") {\n\t\t\tthis.renameInput.focused = true;\n\t\t}\n\t}\n\n\tprivate buildBaseLayout(content: Component, options?: { showHeader?: boolean }): void {\n\t\tthis.clear();\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new DynamicBorder((s) => theme.fg(\"accent\", s)));\n\t\tthis.addChild(new Spacer(1));\n\t\tif (options?.showHeader ?? true) {\n\t\t\tthis.addChild(this.header);\n\t\t\tthis.addChild(new Spacer(1));\n\t\t}\n\t\tthis.addChild(content);\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new DynamicBorder((s) => theme.fg(\"accent\", s)));\n\t}\n\n\tconstructor(\n\t\tcurrentSessionsLoader: SessionsLoader,\n\t\tallSessionsLoader: SessionsLoader,\n\t\tonSelect: (session: SessionInfo) => void,\n\t\tonCancel: () => void,\n\t\tonExit: () => void,\n\t\trequestRender: () => void,\n\t\toptions?: {\n\t\t\trenameSession?: (session: SessionInfo, currentName: string | undefined) => Promise<void>;\n\t\t\tdeleteSession?: (sessionId: string) => Promise<void>;\n\t\t\tshowRenameHint?: boolean;\n\t\t\tkeybindings?: KeybindingsManager;\n\t\t\t/**\n\t\t\t * Rows to display in the first rendered frame before the async loader\n\t\t\t * resolves (e.g. cheap in-memory live workflow runs). Seeding lets the\n\t\t\t * selector mount and stay interactive while durable/on-disk rows load,\n\t\t\t * and keeps live rows visible if the loader later errors.\n\t\t\t */\n\t\t\tinitialSessions?: SessionInfo[];\n\t\t},\n\t\tcurrentSession?: { id: string; directory: string },\n\t) {\n\t\tsuper();\n\t\tthis.keybindings = options?.keybindings ?? KeybindingsManager.create();\n\t\tthis.currentSessionsLoader = currentSessionsLoader;\n\t\tthis.allSessionsLoader = allSessionsLoader;\n\t\tthis.onCancel = onCancel;\n\t\tthis.requestRender = requestRender;\n\t\tthis.header = new SessionSelectorHeader(this.scope, this.sortMode, this.nameFilter, this.requestRender);\n\t\tconst renameSession = options?.renameSession;\n\t\tthis.renameSession = renameSession;\n\t\tthis.canRename = !!renameSession;\n\t\tthis.header.setShowRenameHint(options?.showRenameHint ?? this.canRename);\n\n\t\t// Create the session list. Seed with any provided initial rows so the very\n\t\t// first frame is populated (kept minimal/in-memory by the caller) while the\n\t\t// async loader resolves the full catalog off the host hot path.\n\t\tconst initialSessions = options?.initialSessions;\n\t\tthis.sessionList = new SessionList(\n\t\t\tinitialSessions ?? [],\n\t\t\tfalse,\n\t\t\tthis.sortMode,\n\t\t\tthis.nameFilter,\n\t\t\tthis.keybindings,\n\t\t\toptions?.deleteSession && currentSession ? { id: currentSession.id } : currentSession,\n\t\t);\n\t\tif (initialSessions !== undefined) {\n\t\t\tthis.currentSessions = initialSessions;\n\t\t}\n\n\t\tthis.buildBaseLayout(this.sessionList);\n\n\t\tthis.renameInput.onSubmit = (value) => {\n\t\t\tvoid this.confirmRename(value);\n\t\t};\n\n\t\t// Ensure header status timeouts are cleared when leaving the selector\n\t\tconst clearStatusMessage = () => this.header.setStatusMessage(null);\n\t\tthis.sessionList.onSelect = (session) => {\n\t\t\tclearStatusMessage();\n\t\t\tonSelect(session);\n\t\t};\n\t\tthis.sessionList.onCancel = () => {\n\t\t\tclearStatusMessage();\n\t\t\tonCancel();\n\t\t};\n\t\tthis.sessionList.onExit = () => {\n\t\t\tclearStatusMessage();\n\t\t\tonExit();\n\t\t};\n\t\tthis.sessionList.onToggleScope = () => this.toggleScope();\n\t\tthis.sessionList.onToggleSort = () => this.toggleSortMode();\n\t\tthis.sessionList.onToggleNameFilter = () => this.toggleNameFilter();\n\t\tthis.sessionList.onRenameSession = (session) => {\n\t\t\tif (!renameSession) return;\n\t\t\tif (this.scope === \"current\" && this.currentLoading) return;\n\t\t\tif (this.scope === \"all\" && this.allLoading) return;\n\t\t\tthis.enterRenameMode(session);\n\t\t};\n\n\t\t// Sync list events to header\n\t\tthis.sessionList.onTogglePath = (showPath) => {\n\t\t\tthis.header.setShowPath(showPath);\n\t\t\tthis.requestRender();\n\t\t};\n\t\tthis.sessionList.onDeleteConfirmationChange = (path) => {\n\t\t\tthis.header.setConfirmingDeletePath(path);\n\t\t\tthis.requestRender();\n\t\t};\n\t\tthis.sessionList.onError = (msg) => {\n\t\t\tthis.header.setStatusMessage({ type: \"error\", message: msg }, 3000);\n\t\t\tthis.requestRender();\n\t\t};\n\n\t\t// Handle session deletion\n\t\tthis.sessionList.onDeleteSession = async (sessionPath, session) => {\n\t\t\tlet result: DeleteSessionFileResult;\n\t\t\ttry {\n\t\t\t\tif (options?.deleteSession) {\n\t\t\t\t\tawait options.deleteSession(session.id);\n\t\t\t\t\tresult = { ok: true, method: \"store\" };\n\t\t\t\t} else result = await deleteSessionFile(sessionPath);\n\t\t\t} catch (error) {\n\t\t\t\tresult = { ok: false, method: \"store\", error: error instanceof Error ? error.message : String(error) };\n\t\t\t}\n\n\t\t\tif (result.ok) {\n\t\t\t\tif (this.currentSessions) {\n\t\t\t\t\tthis.currentSessions = this.currentSessions.filter((s) =>\n\t\t\t\t\t\toptions?.deleteSession ? s.id !== session.id : s.path !== sessionPath,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (this.allSessions) {\n\t\t\t\t\tthis.allSessions = this.allSessions.filter((s) =>\n\t\t\t\t\t\toptions?.deleteSession ? s.id !== session.id : s.path !== sessionPath,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst sessions = this.scope === \"all\" ? (this.allSessions ?? []) : (this.currentSessions ?? []);\n\t\t\t\tconst showCwd = this.scope === \"all\";\n\t\t\t\tthis.sessionList.setSessions(sessions, showCwd);\n\n\t\t\t\tconst msg = result.method === \"trash\" ? \"Session moved to trash\" : \"Session deleted\";\n\t\t\t\tthis.header.setStatusMessage({ type: \"info\", message: msg }, 2000);\n\t\t\t\tawait this.refreshSessionsAfterMutation();\n\t\t\t} else {\n\t\t\t\tconst errorMessage = result.error ?? \"Unknown error\";\n\t\t\t\tthis.header.setStatusMessage({ type: \"error\", message: `Failed to delete: ${errorMessage}` }, 3000);\n\t\t\t}\n\n\t\t\tthis.requestRender();\n\t\t};\n\n\t\t// Start loading current sessions immediately\n\t\tthis.loadCurrentSessions();\n\t}\n\n\tprivate loadCurrentSessions(): void {\n\t\tvoid this.loadScope(\"current\", \"initial\");\n\t}\n\n\tprivate enterRenameMode(session: SessionInfo): void {\n\t\tthis.mode = \"rename\";\n\t\tthis.renameTarget = session;\n\t\tthis.renameInput.setValue(session.name ?? \"\");\n\t\tthis.renameInput.focused = true;\n\n\t\tconst panel = new Container();\n\t\tpanel.addChild(new Text(theme.bold(\"Rename Session\"), 1, 0));\n\t\tpanel.addChild(new Spacer(1));\n\t\tpanel.addChild(this.renameInput);\n\t\tpanel.addChild(new Spacer(1));\n\t\tpanel.addChild(\n\t\t\tnew Text(\n\t\t\t\ttheme.fg(\"muted\", `${keyText(\"tui.select.confirm\")} Save · ${keyText(\"tui.select.cancel\")} Cancel`),\n\t\t\t\t1,\n\t\t\t\t0,\n\t\t\t),\n\t\t);\n\n\t\tthis.buildBaseLayout(panel, { showHeader: false });\n\t\tthis.requestRender();\n\t}\n\n\tprivate exitRenameMode(): void {\n\t\tthis.mode = \"list\";\n\t\tthis.renameTarget = null;\n\n\t\tthis.buildBaseLayout(this.sessionList);\n\n\t\tthis.requestRender();\n\t}\n\n\tprivate async confirmRename(value: string): Promise<void> {\n\t\tconst next = value.trim();\n\t\tif (!next) return;\n\t\tconst target = this.renameTarget;\n\t\tif (!target) {\n\t\t\tthis.exitRenameMode();\n\t\t\treturn;\n\t\t}\n\n\t\t// Find current name for callback\n\t\tconst renameSession = this.renameSession;\n\t\tif (!renameSession) {\n\t\t\tthis.exitRenameMode();\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait renameSession(target, next);\n\t\t\tawait this.refreshSessionsAfterMutation();\n\t\t} finally {\n\t\t\tthis.exitRenameMode();\n\t\t}\n\t}\n\n\tprivate async loadScope(scope: SessionScope, reason: \"initial\" | \"refresh\" | \"toggle\"): Promise<void> {\n\t\tconst showCwd = scope === \"all\";\n\n\t\t// Mark loading\n\t\tif (scope === \"current\") {\n\t\t\tthis.currentLoading = true;\n\t\t} else {\n\t\t\tthis.allLoading = true;\n\t\t}\n\n\t\tconst seq = scope === \"all\" ? ++this.allLoadSeq : undefined;\n\t\tthis.header.setScope(scope);\n\t\tthis.header.setLoading(true);\n\t\tthis.requestRender();\n\n\t\tconst onProgress = (loaded: number, total: number) => {\n\t\t\tif (this.disposed) return;\n\t\t\tif (scope !== this.scope) return;\n\t\t\tif (seq !== undefined && seq !== this.allLoadSeq) return;\n\t\t\tthis.header.setProgress(loaded, total);\n\t\t\tthis.requestRender();\n\t\t};\n\n\t\ttry {\n\t\t\tconst sessions = (\n\t\t\t\tawait (scope === \"current\" ? this.currentSessionsLoader(onProgress) : this.allSessionsLoader(onProgress))\n\t\t\t).filter(isResumableSession);\n\n\t\t\tif (scope === \"current\") {\n\t\t\t\tthis.currentSessions = sessions;\n\t\t\t\tthis.currentLoading = false;\n\t\t\t} else {\n\t\t\t\tthis.allSessions = sessions;\n\t\t\t\tthis.allLoading = false;\n\t\t\t}\n\n\t\t\t// Stale-result guards: ignore a resolved load after the selector was\n\t\t\t// closed, the visible scope changed, or a newer all-scope load started.\n\t\t\tif (this.disposed) return;\n\t\t\tif (scope !== this.scope) return;\n\t\t\tif (seq !== undefined && seq !== this.allLoadSeq) return;\n\n\t\t\tthis.header.setLoading(false);\n\t\t\tthis.sessionList.setSessions(sessions, showCwd);\n\t\t\tthis.requestRender();\n\n\t\t\tif (scope === \"all\" && sessions.length === 0 && (this.currentSessions?.length ?? 0) === 0) {\n\t\t\t\tthis.onCancel();\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tif (scope === \"current\") {\n\t\t\t\tthis.currentLoading = false;\n\t\t\t} else {\n\t\t\t\tthis.allLoading = false;\n\t\t\t}\n\n\t\t\tif (this.disposed) return;\n\t\t\tif (scope !== this.scope) return;\n\t\t\tif (seq !== undefined && seq !== this.allLoadSeq) return;\n\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\tthis.header.setLoading(false);\n\t\t\tthis.header.setStatusMessage({ type: \"error\", message: `Failed to load sessions: ${message}` }, 4000);\n\n\t\t\t// Only blank the list on the initial load when there is nothing already\n\t\t\t// on screen. Seeded live rows must survive a loader failure so errors\n\t\t\t// render inside the still-usable picker (contract §2).\n\t\t\tconst seeded = scope === \"current\" ? this.currentSessions : this.allSessions;\n\t\t\tif (reason === \"initial\" && (seeded === null || seeded.length === 0)) {\n\t\t\t\tthis.sessionList.setSessions([], showCwd);\n\t\t\t}\n\t\t\tthis.requestRender();\n\t\t}\n\t}\n\n\tprivate toggleSortMode(): void {\n\t\t// Cycle: threaded -> recent -> relevance -> threaded\n\t\tthis.sortMode = this.sortMode === \"threaded\" ? \"recent\" : this.sortMode === \"recent\" ? \"relevance\" : \"threaded\";\n\t\tthis.header.setSortMode(this.sortMode);\n\t\tthis.sessionList.setSortMode(this.sortMode);\n\t\tthis.requestRender();\n\t}\n\n\tprivate toggleNameFilter(): void {\n\t\tthis.nameFilter = this.nameFilter === \"all\" ? \"named\" : \"all\";\n\t\tthis.header.setNameFilter(this.nameFilter);\n\t\tthis.sessionList.setNameFilter(this.nameFilter);\n\t\tthis.requestRender();\n\t}\n\n\tprivate async refreshSessionsAfterMutation(): Promise<void> {\n\t\tawait this.loadScope(this.scope, \"refresh\");\n\t}\n\n\tprivate toggleScope(): void {\n\t\tif (this.scope === \"current\") {\n\t\t\tthis.scope = \"all\";\n\t\t\tthis.header.setScope(this.scope);\n\n\t\t\tif (this.allSessions !== null) {\n\t\t\t\tthis.header.setLoading(false);\n\t\t\t\tthis.sessionList.setSessions(this.allSessions, true);\n\t\t\t\tthis.requestRender();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!this.allLoading) {\n\t\t\t\tvoid this.loadScope(\"all\", \"toggle\");\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tthis.scope = \"current\";\n\t\tthis.header.setScope(this.scope);\n\t\tthis.header.setLoading(this.currentLoading);\n\t\tthis.sessionList.setSessions(this.currentSessions ?? [], false);\n\t\tthis.requestRender();\n\t}\n\n\tgetSessionList(): SessionList {\n\t\treturn this.sessionList;\n\t}\n\n\t/**\n\t * Mark the selector closed so any in-flight or late-resolving loads are\n\t * ignored (stale-result guard) and status timeouts are cleared. Idempotent;\n\t * safe to call from close/select/cancel/dispose paths.\n\t */\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\t// Invalidate any pending all-scope load so its seq check fails on resolve.\n\t\tthis.allLoadSeq += 1;\n\t\tthis.header.setStatusMessage(null);\n\t}\n}\n\nfunction isResumableSession(session: SessionInfo): boolean {\n\treturn session.messageCount > 0 || session.hasName === true || session.summary !== undefined;\n}\n"]}
@@ -399,8 +399,9 @@ InteractiveModeBase.prototype.setupEditorSubmitHandler = function () {
399
399
  return;
400
400
  }
401
401
  }
402
- // Queue input during compaction (extension commands execute immediately)
403
- if (this.compactionActive) {
402
+ // Queue input behind compaction-queued messages (extension commands execute immediately)
403
+ if (this.compactionActive ||
404
+ (!this.session.queuedMessagesPaused && (this.compactionFlushPending || this.compactionSendFailed))) {
404
405
  if (this.isExtensionCommand(text)) {
405
406
  this.editor.addToHistory?.(text);
406
407
  this.editor.setText("");
@@ -411,6 +412,11 @@ InteractiveModeBase.prototype.setupEditorSubmitHandler = function () {
411
412
  }
412
413
  return;
413
414
  }
415
+ // A paused submission releases the session queue before its own turn, so move held
416
+ // messages there first to keep them ahead of this one.
417
+ if (this.session.queuedMessagesPaused && this.compactionSendFailed && !this.compactionFlushPending) {
418
+ await this.flushCompactionQueue({ willRetry: false });
419
+ }
414
420
  // If streaming, use prompt() with steer behavior
415
421
  // This handles extension commands (execute immediately), prompt template expansion, and queueing
416
422
  if (this.session.isStreaming && !this.session.queuedMessagesPaused) {