@bastani/atomic 0.9.5-alpha.8 → 0.9.5-alpha.9

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 (207) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/builtin/cursor/package.json +2 -2
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/mcp/CHANGELOG.md +11 -0
  5. package/dist/builtin/mcp/README.md +6 -6
  6. package/dist/builtin/mcp/direct-tools.ts +41 -23
  7. package/dist/builtin/mcp/index.ts +31 -4
  8. package/dist/builtin/mcp/init.ts +4 -43
  9. package/dist/builtin/mcp/metadata-hydration.ts +37 -0
  10. package/dist/builtin/mcp/package.json +1 -1
  11. package/dist/builtin/mcp/proxy-info-modes.ts +67 -14
  12. package/dist/builtin/mcp/startup-warmup.ts +98 -0
  13. package/dist/builtin/mcp/tool-result-renderer.ts +3 -3
  14. package/dist/builtin/subagents/CHANGELOG.md +12 -0
  15. package/dist/builtin/subagents/package.json +1 -1
  16. package/dist/builtin/subagents/src/extension/index.ts +14 -25
  17. package/dist/builtin/subagents/src/extension/startup-maintenance.ts +89 -0
  18. package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +23 -18
  19. package/dist/builtin/subagents/src/runs/background/result-watcher.ts +20 -10
  20. package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +13 -3
  21. package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +10 -2
  22. package/dist/builtin/subagents/src/runs/shared/pi-spawn.ts +28 -1
  23. package/dist/builtin/subagents/src/tui/render-widget.ts +29 -0
  24. package/dist/builtin/web-access/package.json +1 -1
  25. package/dist/builtin/workflows/CHANGELOG.md +18 -0
  26. package/dist/builtin/workflows/README.md +1 -1
  27. package/dist/builtin/workflows/builtin/goal-runner.ts +39 -1
  28. package/dist/builtin/workflows/package.json +1 -1
  29. package/dist/builtin/workflows/skills/impeccable/SKILL.md +16 -13
  30. package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +1 -0
  31. package/dist/builtin/workflows/skills/impeccable/reference/adapt.native.md +58 -0
  32. package/dist/builtin/workflows/skills/impeccable/reference/android.md +40 -0
  33. package/dist/builtin/workflows/skills/impeccable/reference/animate.md +2 -0
  34. package/dist/builtin/workflows/skills/impeccable/reference/audit.md +2 -0
  35. package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +139 -0
  36. package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +69 -62
  37. package/dist/builtin/workflows/skills/impeccable/reference/critique.md +21 -7
  38. package/dist/builtin/workflows/skills/impeccable/reference/document.md +1 -1
  39. package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +92 -0
  40. package/dist/builtin/workflows/skills/impeccable/reference/init.md +29 -7
  41. package/dist/builtin/workflows/skills/impeccable/reference/ios.md +45 -0
  42. package/dist/builtin/workflows/skills/impeccable/reference/layout.md +25 -1
  43. package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +23 -1
  44. package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +2 -1
  45. package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +75 -14
  46. package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +1 -1
  47. package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +31 -0
  48. package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +64 -0
  49. package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +118 -11
  50. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +16 -11
  51. package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +66 -0
  52. package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +42 -10
  53. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/fonts.mjs +30 -0
  54. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +4 -6
  55. package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +660 -0
  56. package/dist/builtin/workflows/skills/impeccable/scripts/hook-before-edit.mjs +516 -0
  57. package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +1764 -0
  58. package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +61 -0
  59. package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +4 -2
  60. package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +2 -2
  61. package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +13 -16
  62. package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +17 -11
  63. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +104 -37
  64. package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +9 -0
  65. package/dist/builtin/workflows/src/durable/backend.ts +12 -0
  66. package/dist/builtin/workflows/src/durable/dbos-backend.ts +17 -1
  67. package/dist/builtin/workflows/src/durable/resume-catalog.ts +12 -0
  68. package/dist/builtin/workflows/src/durable/resume-runtime.ts +5 -2
  69. package/dist/builtin/workflows/src/durable/types.ts +16 -0
  70. package/dist/builtin/workflows/src/engine/primitives/task.ts +1 -0
  71. package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +1 -2
  72. package/dist/builtin/workflows/src/engine/run-returned-status.ts +50 -16
  73. package/dist/builtin/workflows/src/engine/run.ts +20 -19
  74. package/dist/builtin/workflows/src/engine/runtime.ts +5 -0
  75. package/dist/builtin/workflows/src/extension/extension-factory.ts +3 -0
  76. package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +9 -2
  77. package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +137 -27
  78. package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +22 -6
  79. package/dist/builtin/workflows/src/extension/public-types.ts +1 -1
  80. package/dist/builtin/workflows/src/extension/workflow-command-completions.ts +13 -1
  81. package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +19 -4
  82. package/dist/builtin/workflows/src/extension/workflow-command-surfaces.ts +9 -0
  83. package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +48 -23
  84. package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +20 -8
  85. package/dist/builtin/workflows/src/extension/workflow-tool.ts +24 -8
  86. package/dist/builtin/workflows/src/runs/background/status.ts +4 -3
  87. package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +29 -8
  88. package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +2 -1
  89. package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +3 -2
  90. package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +155 -20
  91. package/dist/builtin/workflows/src/runs/shared/worktree-types.ts +6 -0
  92. package/dist/builtin/workflows/src/runs/shared/worktree.ts +2 -1
  93. package/dist/builtin/workflows/src/shared/returned-run-status.ts +116 -0
  94. package/dist/builtin/workflows/src/shared/workflow-failures-decisions.ts +2 -0
  95. package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +21 -3
  96. package/dist/builtin/workflows/src/tui/graph-view-state.ts +3 -0
  97. package/dist/builtin/workflows/src/tui/graph-view-types.ts +3 -0
  98. package/dist/builtin/workflows/src/tui/status-list.ts +22 -15
  99. package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +4 -4
  100. package/dist/core/agent-session-auto-compaction.d.ts +23 -3
  101. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  102. package/dist/core/agent-session-auto-compaction.js +129 -17
  103. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  104. package/dist/core/agent-session-events.d.ts.map +1 -1
  105. package/dist/core/agent-session-events.js +7 -0
  106. package/dist/core/agent-session-events.js.map +1 -1
  107. package/dist/core/agent-session-methods.d.ts +6 -3
  108. package/dist/core/agent-session-methods.d.ts.map +1 -1
  109. package/dist/core/agent-session-methods.js.map +1 -1
  110. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  111. package/dist/core/agent-session-prompt.js +1 -1
  112. package/dist/core/agent-session-prompt.js.map +1 -1
  113. package/dist/core/agent-session.d.ts +4 -2
  114. package/dist/core/agent-session.d.ts.map +1 -1
  115. package/dist/core/agent-session.js +4 -2
  116. package/dist/core/agent-session.js.map +1 -1
  117. package/dist/core/extensions/loader-virtual-modules.d.ts +8 -1
  118. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  119. package/dist/core/extensions/loader-virtual-modules.js +2 -1
  120. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  121. package/dist/core/footer-data-provider.d.ts +6 -0
  122. package/dist/core/footer-data-provider.d.ts.map +1 -1
  123. package/dist/core/footer-data-provider.js +72 -29
  124. package/dist/core/footer-data-provider.js.map +1 -1
  125. package/dist/core/openai-responses-payload-sanitizer.d.ts +1 -0
  126. package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -1
  127. package/dist/core/openai-responses-payload-sanitizer.js +24 -9
  128. package/dist/core/openai-responses-payload-sanitizer.js.map +1 -1
  129. package/dist/core/slash-commands.d.ts +2 -0
  130. package/dist/core/slash-commands.d.ts.map +1 -1
  131. package/dist/core/slash-commands.js +141 -0
  132. package/dist/core/slash-commands.js.map +1 -1
  133. package/dist/index.d.ts +1 -0
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +1 -0
  136. package/dist/index.js.map +1 -1
  137. package/dist/main-deferred-startup.d.ts.map +1 -1
  138. package/dist/main-deferred-startup.js +2 -2
  139. package/dist/main-deferred-startup.js.map +1 -1
  140. package/dist/main-early-input.d.ts.map +1 -1
  141. package/dist/main-early-input.js +7 -0
  142. package/dist/main-early-input.js.map +1 -1
  143. package/dist/main.d.ts.map +1 -1
  144. package/dist/main.js +1 -1
  145. package/dist/main.js.map +1 -1
  146. package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
  147. package/dist/modes/interactive/components/chat-session-host-actions.js +0 -1
  148. package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
  149. package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
  150. package/dist/modes/interactive/interactive-agent-events.js +1 -0
  151. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  152. package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
  153. package/dist/modes/interactive/interactive-autocomplete.js +21 -9
  154. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  155. package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
  156. package/dist/modes/interactive/interactive-deferred-startup.js +41 -28
  157. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  158. package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
  159. package/dist/modes/interactive/interactive-hotkeys-debug.js +1 -0
  160. package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
  161. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  162. package/dist/modes/interactive/interactive-input-handling.js +41 -6
  163. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  164. package/dist/modes/interactive/interactive-mode-base.d.ts +3 -0
  165. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  166. package/dist/modes/interactive/interactive-mode-base.js +3 -0
  167. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  168. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  169. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  170. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  171. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  172. package/dist/modes/interactive/interactive-mode-surface.d.ts +2 -2
  173. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  174. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  175. package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
  176. package/dist/modes/interactive/interactive-model-routing.js +3 -1
  177. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  178. package/dist/modes/interactive/interactive-process-lifecycle.d.ts.map +1 -1
  179. package/dist/modes/interactive/interactive-process-lifecycle.js +0 -3
  180. package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
  181. package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
  182. package/dist/modes/interactive/interactive-render-chat.js +15 -1
  183. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  184. package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
  185. package/dist/modes/interactive/interactive-session-routing.js +5 -1
  186. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  187. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  188. package/dist/modes/interactive/interactive-startup.js +20 -21
  189. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  190. package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
  191. package/dist/modes/interactive/theme/global-theme.js +26 -2
  192. package/dist/modes/interactive/theme/global-theme.js.map +1 -1
  193. package/dist/utils/fs-watch.d.ts +24 -1
  194. package/dist/utils/fs-watch.d.ts.map +1 -1
  195. package/dist/utils/fs-watch.js +60 -5
  196. package/dist/utils/fs-watch.js.map +1 -1
  197. package/docs/compaction.md +5 -1
  198. package/docs/development.md +4 -0
  199. package/docs/extensions.md +5 -0
  200. package/docs/json.md +1 -1
  201. package/docs/quickstart.md +1 -1
  202. package/docs/settings.md +1 -1
  203. package/docs/subagents.md +4 -0
  204. package/docs/windows.md +4 -0
  205. package/docs/workflows.md +8 -6
  206. package/npm-shrinkwrap.json +23 -23
  207. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-render-chat.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-render-chat.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AgentMessage, type Component, type ContextCompactionResult, type SessionContext, type TruncationResult, type ChatMessageEntry, type ChatMessageRenderOptions, Spacer, Text, parseSkillBlock, AssistantMessageComponent, BashExecutionComponent, BranchSummaryMessageComponent, chatEntriesFromAgentMessages, renderChatMessageEntry, addChatTranscriptEntry, ContextCompactionSummaryMessageComponent, CustomMessageComponent, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, theme } from \"./interactive-mode-deps.ts\";\nimport { yieldToEventLoop } from \"../../utils/event-loop.ts\";\n\nInteractiveModeBase.prototype.showStatus = function(this: InteractiveModeBase, message: string): void {\n const children = this.chatContainer.children;\n const last =\n children.length > 0 ? children[children.length - 1] : undefined;\n const secondLast =\n children.length > 1 ? children[children.length - 2] : undefined;\n\n if (\n last &&\n secondLast &&\n last === this.lastStatusText &&\n secondLast === this.lastStatusSpacer\n ) {\n this.lastStatusText.setText(theme.fg(\"dim\", message));\n this.ui.requestRender();\n return;\n }\n\n const spacer = new Spacer(1);\n const text = new Text(theme.fg(\"dim\", message), 1, 0);\n this.chatContainer.addChild(spacer);\n this.chatContainer.addChild(text);\n this.lastStatusSpacer = spacer;\n this.lastStatusText = text;\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.renderDeferredUserInput = function(this: InteractiveModeBase, text: string): void {\n this.deferredRenderedUserInputs.push(text);\n const startIndex = this.chatContainer.children.length;\n this.addMessageToChat({ role: \"user\", content: text } as AgentMessage);\n const renderedComponents = this.chatContainer.children.slice(startIndex);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text) ?? [];\n trackedComponents.push(renderedComponents);\n this.deferredRenderedUserInputComponents.set(text, trackedComponents);\n this.updatePendingMessagesDisplay();\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.consumeDeferredRenderedUserInput = function(this: InteractiveModeBase, text: string): boolean {\n const index = this.deferredRenderedUserInputs.indexOf(text);\n if (index === -1) return false;\n this.deferredRenderedUserInputs.splice(index, 1);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text);\n trackedComponents?.shift();\n if (trackedComponents && trackedComponents.length === 0) {\n this.deferredRenderedUserInputComponents.delete(text);\n }\n return true;\n };\n\nInteractiveModeBase.prototype.discardDeferredRenderedUserInput = function(this: InteractiveModeBase, text: string): void {\n const index = this.deferredRenderedUserInputs.indexOf(text);\n if (index !== -1) this.deferredRenderedUserInputs.splice(index, 1);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text);\n const componentsToRemove = trackedComponents?.shift();\n if (trackedComponents && trackedComponents.length === 0) {\n this.deferredRenderedUserInputComponents.delete(text);\n }\n if (!componentsToRemove) return;\n for (const component of componentsToRemove) {\n this.chatContainer.removeChild(component);\n }\n this.updatePendingMessagesDisplay();\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.chatMessageRenderOptions = function(this: InteractiveModeBase): ChatMessageRenderOptions {\n return {\n ui: this.ui,\n cwd: this.sessionManager.getCwd(),\n markdownTheme: this.getMarkdownThemeWithSettings(),\n hideThinkingBlock: this.hideThinkingBlock,\n hiddenThinkingLabel: this.hiddenThinkingLabel,\n toolOutputExpanded: this.toolOutputExpanded,\n showImages: this.settingsManager.getShowImages(),\n imageWidthCells: this.settingsManager.getImageWidthCells(),\n outputPad: this.outputPad,\n getToolDefinition: (toolName) => this.getRegisteredToolDefinition(toolName),\n getCustomMessageRenderer: (customType) =>\n this.session.extensionRunner.getMessageRenderer(customType),\n };\n };\n\nInteractiveModeBase.prototype.addRenderedChatEntry = function(this: InteractiveModeBase, entry: ChatMessageEntry): Component {\n const component = renderChatMessageEntry(entry, this.chatMessageRenderOptions());\n addChatTranscriptEntry(this.chatContainer, component, entry.role);\n return component;\n };\n\nInteractiveModeBase.prototype.addContextCompactionSummaryToChat = function(this: InteractiveModeBase, result: ContextCompactionResult): void {\n this.chatContainer.addChild(new Spacer(1));\n const component = new ContextCompactionSummaryMessageComponent(\n result,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n };\n\nInteractiveModeBase.prototype.addMessageToChat = function(this: InteractiveModeBase, message: AgentMessage, options?: { populateHistory?: boolean }): void {\n switch (message.role) {\n case \"bashExecution\": {\n const component = new BashExecutionComponent(\n message.command,\n this.ui,\n message.excludeFromContext,\n );\n if (message.output) {\n component.appendOutput(message.output);\n }\n component.setComplete(\n message.exitCode,\n message.cancelled,\n message.truncated\n ? ({ truncated: true } as TruncationResult)\n : undefined,\n message.fullOutputPath,\n );\n this.chatContainer.addChild(component);\n break;\n }\n case \"custom\": {\n if (message.display) {\n const renderer = this.session.extensionRunner.getMessageRenderer(\n message.customType,\n );\n const component = new CustomMessageComponent(\n message,\n renderer,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n }\n break;\n }\n case \"branchSummary\": {\n this.chatContainer.addChild(new Spacer(1));\n const component = new BranchSummaryMessageComponent(\n message,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n break;\n }\n case \"user\": {\n const textContent = this.getUserMessageText(message);\n if (textContent) {\n if (this.chatContainer.children.length > 0) {\n this.chatContainer.addChild(new Spacer(1));\n }\n const skillBlock = parseSkillBlock(textContent);\n if (skillBlock) {\n // Render skill block (collapsible)\n const component = new SkillInvocationMessageComponent(\n skillBlock,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n // Render user message separately if present\n if (skillBlock.userMessage) {\n const userComponent = new UserMessageComponent(\n skillBlock.userMessage,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n } else {\n const userComponent = new UserMessageComponent(\n textContent,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n if (options?.populateHistory) {\n this.editor.addToHistory?.(textContent);\n }\n }\n break;\n }\n case \"assistant\": {\n const assistantComponent = new AssistantMessageComponent(\n message,\n this.hideThinkingBlock,\n this.getMarkdownThemeWithSettings(),\n this.hiddenThinkingLabel,\n this.outputPad,\n );\n this.chatContainer.addChild(assistantComponent);\n break;\n }\n case \"toolResult\": {\n // Tool results are rendered inline with tool calls, handled separately\n break;\n }\n default:\n break;\n }\n };\n\nInteractiveModeBase.prototype.renderSessionContext = function(this: InteractiveModeBase, sessionContext: SessionContext, options: { updateFooter?: boolean; populateHistory?: boolean } = {}): void {\n this.pendingTools.clear();\n const pendingDeferredInputs = [...this.deferredRenderedUserInputs];\n this.deferredRenderedUserInputs = [];\n this.deferredRenderedUserInputComponents.clear();\n\n if (options.updateFooter) {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n }\n\n const entries = chatEntriesFromAgentMessages(sessionContext.messages);\n for (const entry of entries) {\n const component = this.addRenderedChatEntry(entry);\n if (\n entry.kind === \"tool\" &&\n entry.isPartial !== false &&\n component instanceof ToolExecutionComponent\n ) {\n this.pendingTools.set(entry.toolCallId, component);\n }\n if (options.populateHistory && entry.kind === \"user\") {\n this.editor.addToHistory?.(entry.text);\n }\n }\n\n for (const input of pendingDeferredInputs) {\n this.renderDeferredUserInput(input);\n }\n\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.attachStartupNoticesContainer = function(this: InteractiveModeBase, options: { resetDetached?: boolean } = {}): void {\n const isAttached = this.chatContainer.children.includes(this.startupNoticesContainer);\n if (isAttached) return;\n if (options.resetDetached) {\n this.startupNoticesContainer.clear();\n }\n this.chatContainer.addChild(this.startupNoticesContainer);\n };\n\nInteractiveModeBase.prototype.renderInitialMessages = function(this: InteractiveModeBase): void {\n this.attachStartupNoticesContainer({ resetDetached: true });\n // Get aligned messages and entries from session context\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context, {\n updateFooter: true,\n populateHistory: true,\n });\n\n // Show compaction info if session was compacted\n const allEntries = this.sessionManager.getEntries();\n const compactionCount = allEntries.filter(\n (e) => e.type === \"compaction\",\n ).length;\n if (compactionCount > 0) {\n const times =\n compactionCount === 1 ? \"1 time\" : `${compactionCount} times`;\n this.showStatus(`Session compacted ${times}`);\n }\n };\n\nInteractiveModeBase.prototype.getUserInput = async function(this: InteractiveModeBase): Promise<string> {\n for (let attempt = 0; !this.startupCookedInputRecovered && attempt < 10; attempt += 1) {\n await yieldToEventLoop();\n if (this.recoverCookedStartupInput?.()) break;\n }\n while (true) {\n const queuedInput = this.pendingUserInputs.shift();\n if (queuedInput !== undefined) {\n return queuedInput;\n }\n\n if (this.startupReplayActiveInput) {\n await this.drainStartupReplayCommands();\n continue;\n }\n\n return new Promise((resolve) => {\n this.onInputCallback = (text: string) => {\n this.onInputCallback = undefined;\n resolve(text);\n };\n });\n }\n };\n\nInteractiveModeBase.prototype.rebuildChatFromMessages = function(this: InteractiveModeBase): void {\n this.chatContainer.clear();\n this.attachStartupNoticesContainer();\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context);\n };\n"]}
1
+ {"version":3,"file":"interactive-render-chat.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-render-chat.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AgentMessage, type Component, type ContextCompactionResult, type SessionContext, type TruncationResult, type ChatMessageEntry, type ChatMessageRenderOptions, Spacer, Text, parseSkillBlock, AssistantMessageComponent, BashExecutionComponent, BranchSummaryMessageComponent, chatEntriesFromAgentMessages, renderChatMessageEntry, addChatTranscriptEntry, ContextCompactionSummaryMessageComponent, CustomMessageComponent, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, recordTimeSinceReset, theme } from \"./interactive-mode-deps.ts\";\nimport { yieldToEventLoop } from \"../../utils/event-loop.ts\";\n\nInteractiveModeBase.prototype.showStatus = function(this: InteractiveModeBase, message: string): void {\n const children = this.chatContainer.children;\n const last =\n children.length > 0 ? children[children.length - 1] : undefined;\n const secondLast =\n children.length > 1 ? children[children.length - 2] : undefined;\n\n if (\n last &&\n secondLast &&\n last === this.lastStatusText &&\n secondLast === this.lastStatusSpacer\n ) {\n this.lastStatusText.setText(theme.fg(\"dim\", message));\n this.ui.requestRender();\n return;\n }\n\n const spacer = new Spacer(1);\n const text = new Text(theme.fg(\"dim\", message), 1, 0);\n this.chatContainer.addChild(spacer);\n this.chatContainer.addChild(text);\n this.lastStatusSpacer = spacer;\n this.lastStatusText = text;\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.renderDeferredUserInput = function(this: InteractiveModeBase, text: string): void {\n this.deferredRenderedUserInputs.push(text);\n const startIndex = this.chatContainer.children.length;\n this.addMessageToChat({ role: \"user\", content: text } as AgentMessage);\n const renderedComponents = this.chatContainer.children.slice(startIndex);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text) ?? [];\n trackedComponents.push(renderedComponents);\n this.deferredRenderedUserInputComponents.set(text, trackedComponents);\n this.updatePendingMessagesDisplay();\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.consumeDeferredRenderedUserInput = function(this: InteractiveModeBase, text: string): boolean {\n const index = this.deferredRenderedUserInputs.indexOf(text);\n if (index === -1) return false;\n this.deferredRenderedUserInputs.splice(index, 1);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text);\n trackedComponents?.shift();\n if (trackedComponents && trackedComponents.length === 0) {\n this.deferredRenderedUserInputComponents.delete(text);\n }\n return true;\n };\n\nInteractiveModeBase.prototype.discardDeferredRenderedUserInput = function(this: InteractiveModeBase, text: string): void {\n const index = this.deferredRenderedUserInputs.indexOf(text);\n if (index !== -1) this.deferredRenderedUserInputs.splice(index, 1);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text);\n const componentsToRemove = trackedComponents?.shift();\n if (trackedComponents && trackedComponents.length === 0) {\n this.deferredRenderedUserInputComponents.delete(text);\n }\n if (!componentsToRemove) return;\n for (const component of componentsToRemove) {\n this.chatContainer.removeChild(component);\n }\n this.updatePendingMessagesDisplay();\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.chatMessageRenderOptions = function(this: InteractiveModeBase): ChatMessageRenderOptions {\n return {\n ui: this.ui,\n cwd: this.sessionManager.getCwd(),\n markdownTheme: this.getMarkdownThemeWithSettings(),\n hideThinkingBlock: this.hideThinkingBlock,\n hiddenThinkingLabel: this.hiddenThinkingLabel,\n toolOutputExpanded: this.toolOutputExpanded,\n showImages: this.settingsManager.getShowImages(),\n imageWidthCells: this.settingsManager.getImageWidthCells(),\n outputPad: this.outputPad,\n getToolDefinition: (toolName) => this.getRegisteredToolDefinition(toolName),\n getCustomMessageRenderer: (customType) =>\n this.session.extensionRunner.getMessageRenderer(customType),\n };\n };\n\nInteractiveModeBase.prototype.addRenderedChatEntry = function(this: InteractiveModeBase, entry: ChatMessageEntry): Component {\n const component = renderChatMessageEntry(entry, this.chatMessageRenderOptions());\n addChatTranscriptEntry(this.chatContainer, component, entry.role);\n return component;\n };\n\nInteractiveModeBase.prototype.addContextCompactionSummaryToChat = function(this: InteractiveModeBase, result: ContextCompactionResult): void {\n this.chatContainer.addChild(new Spacer(1));\n const component = new ContextCompactionSummaryMessageComponent(\n result,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n };\n\nInteractiveModeBase.prototype.addMessageToChat = function(this: InteractiveModeBase, message: AgentMessage, options?: { populateHistory?: boolean }): void {\n switch (message.role) {\n case \"bashExecution\": {\n const component = new BashExecutionComponent(\n message.command,\n this.ui,\n message.excludeFromContext,\n );\n if (message.output) {\n component.appendOutput(message.output);\n }\n component.setComplete(\n message.exitCode,\n message.cancelled,\n message.truncated\n ? ({ truncated: true } as TruncationResult)\n : undefined,\n message.fullOutputPath,\n );\n this.chatContainer.addChild(component);\n break;\n }\n case \"custom\": {\n if (message.display) {\n const renderer = this.session.extensionRunner.getMessageRenderer(\n message.customType,\n );\n const component = new CustomMessageComponent(\n message,\n renderer,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n }\n break;\n }\n case \"branchSummary\": {\n this.chatContainer.addChild(new Spacer(1));\n const component = new BranchSummaryMessageComponent(\n message,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n break;\n }\n case \"user\": {\n const textContent = this.getUserMessageText(message);\n if (textContent) {\n if (this.chatContainer.children.length > 0) {\n this.chatContainer.addChild(new Spacer(1));\n }\n const skillBlock = parseSkillBlock(textContent);\n if (skillBlock) {\n // Render skill block (collapsible)\n const component = new SkillInvocationMessageComponent(\n skillBlock,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n // Render user message separately if present\n if (skillBlock.userMessage) {\n const userComponent = new UserMessageComponent(\n skillBlock.userMessage,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n } else {\n const userComponent = new UserMessageComponent(\n textContent,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n if (options?.populateHistory) {\n this.editor.addToHistory?.(textContent);\n }\n }\n break;\n }\n case \"assistant\": {\n const assistantComponent = new AssistantMessageComponent(\n message,\n this.hideThinkingBlock,\n this.getMarkdownThemeWithSettings(),\n this.hiddenThinkingLabel,\n this.outputPad,\n );\n this.chatContainer.addChild(assistantComponent);\n break;\n }\n case \"toolResult\": {\n // Tool results are rendered inline with tool calls, handled separately\n break;\n }\n default:\n break;\n }\n };\n\nInteractiveModeBase.prototype.renderSessionContext = function(this: InteractiveModeBase, sessionContext: SessionContext, options: { updateFooter?: boolean; populateHistory?: boolean } = {}): void {\n this.pendingTools.clear();\n const pendingDeferredInputs = [...this.deferredRenderedUserInputs];\n this.deferredRenderedUserInputs = [];\n this.deferredRenderedUserInputComponents.clear();\n\n if (options.updateFooter) {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n }\n\n const entries = chatEntriesFromAgentMessages(sessionContext.messages);\n for (const entry of entries) {\n const component = this.addRenderedChatEntry(entry);\n if (\n entry.kind === \"tool\" &&\n entry.isPartial !== false &&\n component instanceof ToolExecutionComponent\n ) {\n this.pendingTools.set(entry.toolCallId, component);\n }\n if (options.populateHistory && entry.kind === \"user\") {\n this.editor.addToHistory?.(entry.text);\n }\n }\n\n for (const input of pendingDeferredInputs) {\n this.renderDeferredUserInput(input);\n }\n\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.attachStartupNoticesContainer = function(this: InteractiveModeBase, options: { resetDetached?: boolean } = {}): void {\n const isAttached = this.chatContainer.children.includes(this.startupNoticesContainer);\n if (isAttached) return;\n if (options.resetDetached) {\n this.startupNoticesContainer.clear();\n }\n this.chatContainer.addChild(this.startupNoticesContainer);\n };\n\nInteractiveModeBase.prototype.renderInitialMessages = function(this: InteractiveModeBase): void {\n this.attachStartupNoticesContainer({ resetDetached: true });\n // Get aligned messages and entries from session context\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context, {\n updateFooter: true,\n populateHistory: true,\n });\n\n // Show compaction info if session was compacted\n const allEntries = this.sessionManager.getEntries();\n const compactionCount = allEntries.filter(\n (e) => e.type === \"compaction\",\n ).length;\n if (compactionCount > 0) {\n const times =\n compactionCount === 1 ? \"1 time\" : `${compactionCount} times`;\n this.showStatus(`Session compacted ${times}`);\n }\n };\n\nInteractiveModeBase.prototype.getUserInput = async function(this: InteractiveModeBase): Promise<string> {\n for (let attempt = 0; !this.startupCookedInputRecovered && attempt < 10; attempt += 1) {\n await yieldToEventLoop();\n if (this.recoverCookedStartupInput?.()) break;\n }\n while (true) {\n const queuedInput = this.pendingUserInputs.shift();\n if (queuedInput !== undefined) {\n return queuedInput;\n }\n\n if (this.startupReplayActiveInput) {\n await this.drainStartupReplayCommands();\n continue;\n }\n\n return new Promise((resolve) => {\n this.onInputCallback = (text: string) => {\n this.onInputCallback = undefined;\n resolve(text);\n };\n if (!this.inputHandlerReadyRecorded) {\n this.inputHandlerReadyRecorded = true;\n recordTimeSinceReset(\"interactive-input-handler-ready\");\n void (async () => {\n await yieldToEventLoop();\n this.footerDataProvider.startGitWatcher();\n if (this.deferredStartupPending) {\n await this.ensureDeferredStartupComplete();\n }\n })().catch((error) => {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`Deferred input-readiness startup task failed: ${message}`);\n });\n }\n });\n }\n };\n\nInteractiveModeBase.prototype.rebuildChatFromMessages = function(this: InteractiveModeBase): void {\n this.chatContainer.clear();\n this.attachStartupNoticesContainer();\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context);\n };\n"]}
@@ -1,5 +1,5 @@
1
1
  import { InteractiveModeBase } from "./interactive-mode-base.js";
2
- import { Spacer, Text, parseSkillBlock, AssistantMessageComponent, BashExecutionComponent, BranchSummaryMessageComponent, chatEntriesFromAgentMessages, renderChatMessageEntry, addChatTranscriptEntry, ContextCompactionSummaryMessageComponent, CustomMessageComponent, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, theme } from "./interactive-mode-deps.js";
2
+ import { Spacer, Text, parseSkillBlock, AssistantMessageComponent, BashExecutionComponent, BranchSummaryMessageComponent, chatEntriesFromAgentMessages, renderChatMessageEntry, addChatTranscriptEntry, ContextCompactionSummaryMessageComponent, CustomMessageComponent, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, recordTimeSinceReset, theme } from "./interactive-mode-deps.js";
3
3
  import { yieldToEventLoop } from "../../utils/event-loop.js";
4
4
  InteractiveModeBase.prototype.showStatus = function (message) {
5
5
  const children = this.chatContainer.children;
@@ -228,6 +228,20 @@ InteractiveModeBase.prototype.getUserInput = async function () {
228
228
  this.onInputCallback = undefined;
229
229
  resolve(text);
230
230
  };
231
+ if (!this.inputHandlerReadyRecorded) {
232
+ this.inputHandlerReadyRecorded = true;
233
+ recordTimeSinceReset("interactive-input-handler-ready");
234
+ void (async () => {
235
+ await yieldToEventLoop();
236
+ this.footerDataProvider.startGitWatcher();
237
+ if (this.deferredStartupPending) {
238
+ await this.ensureDeferredStartupComplete();
239
+ }
240
+ })().catch((error) => {
241
+ const message = error instanceof Error ? error.message : String(error);
242
+ console.error(`Deferred input-readiness startup task failed: ${message}`);
243
+ });
244
+ }
231
245
  });
232
246
  }
233
247
  };
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-render-chat.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-render-chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAqK,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,wCAAwC,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACtiB,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,mBAAmB,CAAC,SAAS,CAAC,UAAU,GAAG,UAAoC,OAAe;IAC1F,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC;IAC7C,MAAM,IAAI,GACR,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAClE,MAAM,UAAU,GACd,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAElE,IACE,IAAI;QACJ,UAAU;QACV,IAAI,KAAK,IAAI,CAAC,cAAc;QAC5B,UAAU,KAAK,IAAI,CAAC,gBAAgB,EACtC,CAAC;QACC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;QACtD,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;QACxB,OAAO;IACT,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,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ACnD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,IAAI,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAClC,MAAM,IAAI,CAAC,0BAA0B,EAAE,CAAC;YACxC,SAAS;QACX,CAAC;QAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,IAAI,CAAC,eAAe,GAAG,CAAC,IAAY,EAAE,EAAE;gBACtC,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;gBACjC,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC;AAEJ,mBAAmB,CAAC,SAAS,CAAC,uBAAuB,GAAG;IACpD,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC3B,IAAI,CAAC,6BAA6B,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,mBAAmB,EAAE,CAAC;IAC1D,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AgentMessage, type Component, type ContextCompactionResult, type SessionContext, type TruncationResult, type ChatMessageEntry, type ChatMessageRenderOptions, Spacer, Text, parseSkillBlock, AssistantMessageComponent, BashExecutionComponent, BranchSummaryMessageComponent, chatEntriesFromAgentMessages, renderChatMessageEntry, addChatTranscriptEntry, ContextCompactionSummaryMessageComponent, CustomMessageComponent, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, theme } from \"./interactive-mode-deps.ts\";\nimport { yieldToEventLoop } from \"../../utils/event-loop.ts\";\n\nInteractiveModeBase.prototype.showStatus = function(this: InteractiveModeBase, message: string): void {\n const children = this.chatContainer.children;\n const last =\n children.length > 0 ? children[children.length - 1] : undefined;\n const secondLast =\n children.length > 1 ? children[children.length - 2] : undefined;\n\n if (\n last &&\n secondLast &&\n last === this.lastStatusText &&\n secondLast === this.lastStatusSpacer\n ) {\n this.lastStatusText.setText(theme.fg(\"dim\", message));\n this.ui.requestRender();\n return;\n }\n\n const spacer = new Spacer(1);\n const text = new Text(theme.fg(\"dim\", message), 1, 0);\n this.chatContainer.addChild(spacer);\n this.chatContainer.addChild(text);\n this.lastStatusSpacer = spacer;\n this.lastStatusText = text;\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.renderDeferredUserInput = function(this: InteractiveModeBase, text: string): void {\n this.deferredRenderedUserInputs.push(text);\n const startIndex = this.chatContainer.children.length;\n this.addMessageToChat({ role: \"user\", content: text } as AgentMessage);\n const renderedComponents = this.chatContainer.children.slice(startIndex);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text) ?? [];\n trackedComponents.push(renderedComponents);\n this.deferredRenderedUserInputComponents.set(text, trackedComponents);\n this.updatePendingMessagesDisplay();\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.consumeDeferredRenderedUserInput = function(this: InteractiveModeBase, text: string): boolean {\n const index = this.deferredRenderedUserInputs.indexOf(text);\n if (index === -1) return false;\n this.deferredRenderedUserInputs.splice(index, 1);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text);\n trackedComponents?.shift();\n if (trackedComponents && trackedComponents.length === 0) {\n this.deferredRenderedUserInputComponents.delete(text);\n }\n return true;\n };\n\nInteractiveModeBase.prototype.discardDeferredRenderedUserInput = function(this: InteractiveModeBase, text: string): void {\n const index = this.deferredRenderedUserInputs.indexOf(text);\n if (index !== -1) this.deferredRenderedUserInputs.splice(index, 1);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text);\n const componentsToRemove = trackedComponents?.shift();\n if (trackedComponents && trackedComponents.length === 0) {\n this.deferredRenderedUserInputComponents.delete(text);\n }\n if (!componentsToRemove) return;\n for (const component of componentsToRemove) {\n this.chatContainer.removeChild(component);\n }\n this.updatePendingMessagesDisplay();\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.chatMessageRenderOptions = function(this: InteractiveModeBase): ChatMessageRenderOptions {\n return {\n ui: this.ui,\n cwd: this.sessionManager.getCwd(),\n markdownTheme: this.getMarkdownThemeWithSettings(),\n hideThinkingBlock: this.hideThinkingBlock,\n hiddenThinkingLabel: this.hiddenThinkingLabel,\n toolOutputExpanded: this.toolOutputExpanded,\n showImages: this.settingsManager.getShowImages(),\n imageWidthCells: this.settingsManager.getImageWidthCells(),\n outputPad: this.outputPad,\n getToolDefinition: (toolName) => this.getRegisteredToolDefinition(toolName),\n getCustomMessageRenderer: (customType) =>\n this.session.extensionRunner.getMessageRenderer(customType),\n };\n };\n\nInteractiveModeBase.prototype.addRenderedChatEntry = function(this: InteractiveModeBase, entry: ChatMessageEntry): Component {\n const component = renderChatMessageEntry(entry, this.chatMessageRenderOptions());\n addChatTranscriptEntry(this.chatContainer, component, entry.role);\n return component;\n };\n\nInteractiveModeBase.prototype.addContextCompactionSummaryToChat = function(this: InteractiveModeBase, result: ContextCompactionResult): void {\n this.chatContainer.addChild(new Spacer(1));\n const component = new ContextCompactionSummaryMessageComponent(\n result,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n };\n\nInteractiveModeBase.prototype.addMessageToChat = function(this: InteractiveModeBase, message: AgentMessage, options?: { populateHistory?: boolean }): void {\n switch (message.role) {\n case \"bashExecution\": {\n const component = new BashExecutionComponent(\n message.command,\n this.ui,\n message.excludeFromContext,\n );\n if (message.output) {\n component.appendOutput(message.output);\n }\n component.setComplete(\n message.exitCode,\n message.cancelled,\n message.truncated\n ? ({ truncated: true } as TruncationResult)\n : undefined,\n message.fullOutputPath,\n );\n this.chatContainer.addChild(component);\n break;\n }\n case \"custom\": {\n if (message.display) {\n const renderer = this.session.extensionRunner.getMessageRenderer(\n message.customType,\n );\n const component = new CustomMessageComponent(\n message,\n renderer,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n }\n break;\n }\n case \"branchSummary\": {\n this.chatContainer.addChild(new Spacer(1));\n const component = new BranchSummaryMessageComponent(\n message,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n break;\n }\n case \"user\": {\n const textContent = this.getUserMessageText(message);\n if (textContent) {\n if (this.chatContainer.children.length > 0) {\n this.chatContainer.addChild(new Spacer(1));\n }\n const skillBlock = parseSkillBlock(textContent);\n if (skillBlock) {\n // Render skill block (collapsible)\n const component = new SkillInvocationMessageComponent(\n skillBlock,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n // Render user message separately if present\n if (skillBlock.userMessage) {\n const userComponent = new UserMessageComponent(\n skillBlock.userMessage,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n } else {\n const userComponent = new UserMessageComponent(\n textContent,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n if (options?.populateHistory) {\n this.editor.addToHistory?.(textContent);\n }\n }\n break;\n }\n case \"assistant\": {\n const assistantComponent = new AssistantMessageComponent(\n message,\n this.hideThinkingBlock,\n this.getMarkdownThemeWithSettings(),\n this.hiddenThinkingLabel,\n this.outputPad,\n );\n this.chatContainer.addChild(assistantComponent);\n break;\n }\n case \"toolResult\": {\n // Tool results are rendered inline with tool calls, handled separately\n break;\n }\n default:\n break;\n }\n };\n\nInteractiveModeBase.prototype.renderSessionContext = function(this: InteractiveModeBase, sessionContext: SessionContext, options: { updateFooter?: boolean; populateHistory?: boolean } = {}): void {\n this.pendingTools.clear();\n const pendingDeferredInputs = [...this.deferredRenderedUserInputs];\n this.deferredRenderedUserInputs = [];\n this.deferredRenderedUserInputComponents.clear();\n\n if (options.updateFooter) {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n }\n\n const entries = chatEntriesFromAgentMessages(sessionContext.messages);\n for (const entry of entries) {\n const component = this.addRenderedChatEntry(entry);\n if (\n entry.kind === \"tool\" &&\n entry.isPartial !== false &&\n component instanceof ToolExecutionComponent\n ) {\n this.pendingTools.set(entry.toolCallId, component);\n }\n if (options.populateHistory && entry.kind === \"user\") {\n this.editor.addToHistory?.(entry.text);\n }\n }\n\n for (const input of pendingDeferredInputs) {\n this.renderDeferredUserInput(input);\n }\n\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.attachStartupNoticesContainer = function(this: InteractiveModeBase, options: { resetDetached?: boolean } = {}): void {\n const isAttached = this.chatContainer.children.includes(this.startupNoticesContainer);\n if (isAttached) return;\n if (options.resetDetached) {\n this.startupNoticesContainer.clear();\n }\n this.chatContainer.addChild(this.startupNoticesContainer);\n };\n\nInteractiveModeBase.prototype.renderInitialMessages = function(this: InteractiveModeBase): void {\n this.attachStartupNoticesContainer({ resetDetached: true });\n // Get aligned messages and entries from session context\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context, {\n updateFooter: true,\n populateHistory: true,\n });\n\n // Show compaction info if session was compacted\n const allEntries = this.sessionManager.getEntries();\n const compactionCount = allEntries.filter(\n (e) => e.type === \"compaction\",\n ).length;\n if (compactionCount > 0) {\n const times =\n compactionCount === 1 ? \"1 time\" : `${compactionCount} times`;\n this.showStatus(`Session compacted ${times}`);\n }\n };\n\nInteractiveModeBase.prototype.getUserInput = async function(this: InteractiveModeBase): Promise<string> {\n for (let attempt = 0; !this.startupCookedInputRecovered && attempt < 10; attempt += 1) {\n await yieldToEventLoop();\n if (this.recoverCookedStartupInput?.()) break;\n }\n while (true) {\n const queuedInput = this.pendingUserInputs.shift();\n if (queuedInput !== undefined) {\n return queuedInput;\n }\n\n if (this.startupReplayActiveInput) {\n await this.drainStartupReplayCommands();\n continue;\n }\n\n return new Promise((resolve) => {\n this.onInputCallback = (text: string) => {\n this.onInputCallback = undefined;\n resolve(text);\n };\n });\n }\n };\n\nInteractiveModeBase.prototype.rebuildChatFromMessages = function(this: InteractiveModeBase): void {\n this.chatContainer.clear();\n this.attachStartupNoticesContainer();\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context);\n };\n"]}
1
+ {"version":3,"file":"interactive-render-chat.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-render-chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAqK,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,wCAAwC,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAC5jB,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,mBAAmB,CAAC,SAAS,CAAC,UAAU,GAAG,UAAoC,OAAe;IAC1F,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC;IAC7C,MAAM,IAAI,GACR,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAClE,MAAM,UAAU,GACd,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAElE,IACE,IAAI;QACJ,UAAU;QACV,IAAI,KAAK,IAAI,CAAC,cAAc;QAC5B,UAAU,KAAK,IAAI,CAAC,gBAAgB,EACtC,CAAC;QACC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAA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AmB,CAAC,SAAS,CAAC,uBAAuB,GAAG;IACpD,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC3B,IAAI,CAAC,6BAA6B,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,mBAAmB,EAAE,CAAC;IAC1D,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type AgentMessage, type Component, type ContextCompactionResult, type SessionContext, type TruncationResult, type ChatMessageEntry, type ChatMessageRenderOptions, Spacer, Text, parseSkillBlock, AssistantMessageComponent, BashExecutionComponent, BranchSummaryMessageComponent, chatEntriesFromAgentMessages, renderChatMessageEntry, addChatTranscriptEntry, ContextCompactionSummaryMessageComponent, CustomMessageComponent, SkillInvocationMessageComponent, ToolExecutionComponent, UserMessageComponent, recordTimeSinceReset, theme } from \"./interactive-mode-deps.ts\";\nimport { yieldToEventLoop } from \"../../utils/event-loop.ts\";\n\nInteractiveModeBase.prototype.showStatus = function(this: InteractiveModeBase, message: string): void {\n const children = this.chatContainer.children;\n const last =\n children.length > 0 ? children[children.length - 1] : undefined;\n const secondLast =\n children.length > 1 ? children[children.length - 2] : undefined;\n\n if (\n last &&\n secondLast &&\n last === this.lastStatusText &&\n secondLast === this.lastStatusSpacer\n ) {\n this.lastStatusText.setText(theme.fg(\"dim\", message));\n this.ui.requestRender();\n return;\n }\n\n const spacer = new Spacer(1);\n const text = new Text(theme.fg(\"dim\", message), 1, 0);\n this.chatContainer.addChild(spacer);\n this.chatContainer.addChild(text);\n this.lastStatusSpacer = spacer;\n this.lastStatusText = text;\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.renderDeferredUserInput = function(this: InteractiveModeBase, text: string): void {\n this.deferredRenderedUserInputs.push(text);\n const startIndex = this.chatContainer.children.length;\n this.addMessageToChat({ role: \"user\", content: text } as AgentMessage);\n const renderedComponents = this.chatContainer.children.slice(startIndex);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text) ?? [];\n trackedComponents.push(renderedComponents);\n this.deferredRenderedUserInputComponents.set(text, trackedComponents);\n this.updatePendingMessagesDisplay();\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.consumeDeferredRenderedUserInput = function(this: InteractiveModeBase, text: string): boolean {\n const index = this.deferredRenderedUserInputs.indexOf(text);\n if (index === -1) return false;\n this.deferredRenderedUserInputs.splice(index, 1);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text);\n trackedComponents?.shift();\n if (trackedComponents && trackedComponents.length === 0) {\n this.deferredRenderedUserInputComponents.delete(text);\n }\n return true;\n };\n\nInteractiveModeBase.prototype.discardDeferredRenderedUserInput = function(this: InteractiveModeBase, text: string): void {\n const index = this.deferredRenderedUserInputs.indexOf(text);\n if (index !== -1) this.deferredRenderedUserInputs.splice(index, 1);\n const trackedComponents = this.deferredRenderedUserInputComponents.get(text);\n const componentsToRemove = trackedComponents?.shift();\n if (trackedComponents && trackedComponents.length === 0) {\n this.deferredRenderedUserInputComponents.delete(text);\n }\n if (!componentsToRemove) return;\n for (const component of componentsToRemove) {\n this.chatContainer.removeChild(component);\n }\n this.updatePendingMessagesDisplay();\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.chatMessageRenderOptions = function(this: InteractiveModeBase): ChatMessageRenderOptions {\n return {\n ui: this.ui,\n cwd: this.sessionManager.getCwd(),\n markdownTheme: this.getMarkdownThemeWithSettings(),\n hideThinkingBlock: this.hideThinkingBlock,\n hiddenThinkingLabel: this.hiddenThinkingLabel,\n toolOutputExpanded: this.toolOutputExpanded,\n showImages: this.settingsManager.getShowImages(),\n imageWidthCells: this.settingsManager.getImageWidthCells(),\n outputPad: this.outputPad,\n getToolDefinition: (toolName) => this.getRegisteredToolDefinition(toolName),\n getCustomMessageRenderer: (customType) =>\n this.session.extensionRunner.getMessageRenderer(customType),\n };\n };\n\nInteractiveModeBase.prototype.addRenderedChatEntry = function(this: InteractiveModeBase, entry: ChatMessageEntry): Component {\n const component = renderChatMessageEntry(entry, this.chatMessageRenderOptions());\n addChatTranscriptEntry(this.chatContainer, component, entry.role);\n return component;\n };\n\nInteractiveModeBase.prototype.addContextCompactionSummaryToChat = function(this: InteractiveModeBase, result: ContextCompactionResult): void {\n this.chatContainer.addChild(new Spacer(1));\n const component = new ContextCompactionSummaryMessageComponent(\n result,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n };\n\nInteractiveModeBase.prototype.addMessageToChat = function(this: InteractiveModeBase, message: AgentMessage, options?: { populateHistory?: boolean }): void {\n switch (message.role) {\n case \"bashExecution\": {\n const component = new BashExecutionComponent(\n message.command,\n this.ui,\n message.excludeFromContext,\n );\n if (message.output) {\n component.appendOutput(message.output);\n }\n component.setComplete(\n message.exitCode,\n message.cancelled,\n message.truncated\n ? ({ truncated: true } as TruncationResult)\n : undefined,\n message.fullOutputPath,\n );\n this.chatContainer.addChild(component);\n break;\n }\n case \"custom\": {\n if (message.display) {\n const renderer = this.session.extensionRunner.getMessageRenderer(\n message.customType,\n );\n const component = new CustomMessageComponent(\n message,\n renderer,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n }\n break;\n }\n case \"branchSummary\": {\n this.chatContainer.addChild(new Spacer(1));\n const component = new BranchSummaryMessageComponent(\n message,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n break;\n }\n case \"user\": {\n const textContent = this.getUserMessageText(message);\n if (textContent) {\n if (this.chatContainer.children.length > 0) {\n this.chatContainer.addChild(new Spacer(1));\n }\n const skillBlock = parseSkillBlock(textContent);\n if (skillBlock) {\n // Render skill block (collapsible)\n const component = new SkillInvocationMessageComponent(\n skillBlock,\n this.getMarkdownThemeWithSettings(),\n );\n component.setExpanded(this.toolOutputExpanded);\n this.chatContainer.addChild(component);\n // Render user message separately if present\n if (skillBlock.userMessage) {\n const userComponent = new UserMessageComponent(\n skillBlock.userMessage,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n } else {\n const userComponent = new UserMessageComponent(\n textContent,\n this.getMarkdownThemeWithSettings(),\n this.outputPad,\n );\n this.chatContainer.addChild(userComponent);\n }\n if (options?.populateHistory) {\n this.editor.addToHistory?.(textContent);\n }\n }\n break;\n }\n case \"assistant\": {\n const assistantComponent = new AssistantMessageComponent(\n message,\n this.hideThinkingBlock,\n this.getMarkdownThemeWithSettings(),\n this.hiddenThinkingLabel,\n this.outputPad,\n );\n this.chatContainer.addChild(assistantComponent);\n break;\n }\n case \"toolResult\": {\n // Tool results are rendered inline with tool calls, handled separately\n break;\n }\n default:\n break;\n }\n };\n\nInteractiveModeBase.prototype.renderSessionContext = function(this: InteractiveModeBase, sessionContext: SessionContext, options: { updateFooter?: boolean; populateHistory?: boolean } = {}): void {\n this.pendingTools.clear();\n const pendingDeferredInputs = [...this.deferredRenderedUserInputs];\n this.deferredRenderedUserInputs = [];\n this.deferredRenderedUserInputComponents.clear();\n\n if (options.updateFooter) {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n }\n\n const entries = chatEntriesFromAgentMessages(sessionContext.messages);\n for (const entry of entries) {\n const component = this.addRenderedChatEntry(entry);\n if (\n entry.kind === \"tool\" &&\n entry.isPartial !== false &&\n component instanceof ToolExecutionComponent\n ) {\n this.pendingTools.set(entry.toolCallId, component);\n }\n if (options.populateHistory && entry.kind === \"user\") {\n this.editor.addToHistory?.(entry.text);\n }\n }\n\n for (const input of pendingDeferredInputs) {\n this.renderDeferredUserInput(input);\n }\n\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.attachStartupNoticesContainer = function(this: InteractiveModeBase, options: { resetDetached?: boolean } = {}): void {\n const isAttached = this.chatContainer.children.includes(this.startupNoticesContainer);\n if (isAttached) return;\n if (options.resetDetached) {\n this.startupNoticesContainer.clear();\n }\n this.chatContainer.addChild(this.startupNoticesContainer);\n };\n\nInteractiveModeBase.prototype.renderInitialMessages = function(this: InteractiveModeBase): void {\n this.attachStartupNoticesContainer({ resetDetached: true });\n // Get aligned messages and entries from session context\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context, {\n updateFooter: true,\n populateHistory: true,\n });\n\n // Show compaction info if session was compacted\n const allEntries = this.sessionManager.getEntries();\n const compactionCount = allEntries.filter(\n (e) => e.type === \"compaction\",\n ).length;\n if (compactionCount > 0) {\n const times =\n compactionCount === 1 ? \"1 time\" : `${compactionCount} times`;\n this.showStatus(`Session compacted ${times}`);\n }\n };\n\nInteractiveModeBase.prototype.getUserInput = async function(this: InteractiveModeBase): Promise<string> {\n for (let attempt = 0; !this.startupCookedInputRecovered && attempt < 10; attempt += 1) {\n await yieldToEventLoop();\n if (this.recoverCookedStartupInput?.()) break;\n }\n while (true) {\n const queuedInput = this.pendingUserInputs.shift();\n if (queuedInput !== undefined) {\n return queuedInput;\n }\n\n if (this.startupReplayActiveInput) {\n await this.drainStartupReplayCommands();\n continue;\n }\n\n return new Promise((resolve) => {\n this.onInputCallback = (text: string) => {\n this.onInputCallback = undefined;\n resolve(text);\n };\n if (!this.inputHandlerReadyRecorded) {\n this.inputHandlerReadyRecorded = true;\n recordTimeSinceReset(\"interactive-input-handler-ready\");\n void (async () => {\n await yieldToEventLoop();\n this.footerDataProvider.startGitWatcher();\n if (this.deferredStartupPending) {\n await this.ensureDeferredStartupComplete();\n }\n })().catch((error) => {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`Deferred input-readiness startup task failed: ${message}`);\n });\n }\n });\n }\n };\n\nInteractiveModeBase.prototype.rebuildChatFromMessages = function(this: InteractiveModeBase): void {\n this.chatContainer.clear();\n this.attachStartupNoticesContainer();\n const context = this.sessionManager.buildSessionContext();\n this.renderSessionContext(context);\n };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-session-routing.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-session-routing.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type ExtensionCommandContext, Loader, Spacer, APP_NAME, MissingSessionCwdError, SessionManager, keyText, SessionSelectorComponent, TreeSelectorComponent, TrustSelectorComponent, hasTrustRequiringProjectResources, ProjectTrustStore, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.handleCloneCommand = async function(this: InteractiveModeBase): Promise<void> {\n const leafId = this.sessionManager.getLeafId();\n if (!leafId) {\n this.showStatus(\"Nothing to clone yet\");\n return;\n }\n\n try {\n const result = await this.runtimeHost.fork(leafId, { position: \"at\" });\n if (result.cancelled) {\n this.ui.requestRender();\n return;\n }\n\n this.renderCurrentSessionState();\n this.editor.setText(\"\");\n this.showStatus(\"Cloned to new session\");\n } catch (error: unknown) {\n this.showError(error instanceof Error ? error.message : String(error));\n }\n };\n\nInteractiveModeBase.prototype.maybeSaveImplicitProjectTrustAfterReload = function(this: InteractiveModeBase): boolean {\n const cwd = this.sessionManager.getCwd();\n if (this.autoTrustOnReloadCwd !== cwd) {\n return false;\n }\n if (!this.settingsManager.isProjectTrusted() || !hasTrustRequiringProjectResources(cwd)) {\n return false;\n }\n\n const trustStore = new ProjectTrustStore(this.runtimeHost.services.agentDir);\n try {\n if (trustStore.get(cwd) !== null) {\n this.autoTrustOnReloadCwd = undefined;\n return false;\n }\n trustStore.set(cwd, true);\n this.autoTrustOnReloadCwd = undefined;\n return true;\n } catch (error) {\n this.showWarning(\n `Could not save project trust after reload: ${error instanceof Error ? error.message : String(error)}`,\n );\n return false;\n }\n };\n\nInteractiveModeBase.prototype.showTrustSelector = function(this: InteractiveModeBase): void {\n const cwd = this.sessionManager.getCwd();\n const trustStore = new ProjectTrustStore(this.runtimeHost.services.agentDir);\n const savedDecision = trustStore.getEntry(cwd);\n this.showSelector((done) => {\n const selector = new TrustSelectorComponent({\n cwd,\n savedDecision,\n projectTrusted: this.settingsManager.isProjectTrusted(),\n onSelect: (selection) => {\n trustStore.setMany(selection.updates);\n done();\n this.showStatus(\n `Saved trust decision: ${selection.trusted ? \"trusted\" : \"untrusted\"}. Restart ${APP_NAME} for this to take effect.`,\n );\n },\n onCancel: () => {\n done();\n this.ui.requestRender();\n },\n });\n return { component: selector, focus: selector };\n });\n };\n\nInteractiveModeBase.prototype.showTreeSelector = function(this: InteractiveModeBase, initialSelectedId?: string): void {\n const tree = this.sessionManager.getTree();\n const realLeafId = this.sessionManager.getLeafId();\n const initialFilterMode = this.settingsManager.getTreeFilterMode();\n\n if (tree.length === 0) {\n this.showStatus(\"No entries in session\");\n return;\n }\n\n this.showSelector((done) => {\n const selector = new TreeSelectorComponent(\n tree,\n realLeafId,\n this.ui.terminal.rows,\n async (entryId) => {\n // Selecting the current leaf is a no-op (already there)\n if (entryId === realLeafId) {\n done();\n this.showStatus(\"Already at this point\");\n return;\n }\n\n // Ask about summarization\n done(); // Close selector first\n\n // Loop until user makes a complete choice or cancels to tree\n let wantsSummary = false;\n let customInstructions: string | undefined;\n\n // Check if we should skip the prompt (user preference to always default to no summary)\n if (!this.settingsManager.getBranchSummarySkipPrompt()) {\n while (true) {\n const summaryChoice = await this.showExtensionSelector(\n \"Summarize branch?\",\n [\"No summary\", \"Summarize\", \"Summarize with custom prompt\"],\n );\n\n if (summaryChoice === undefined) {\n // User pressed escape - re-show tree selector with same selection\n this.showTreeSelector(entryId);\n return;\n }\n\n wantsSummary = summaryChoice !== \"No summary\";\n\n if (summaryChoice === \"Summarize with custom prompt\") {\n customInstructions = await this.showExtensionEditor(\n \"Custom summarization instructions\",\n );\n if (customInstructions === undefined) {\n // User cancelled - loop back to summary selector\n continue;\n }\n }\n\n // User made a complete choice\n break;\n }\n }\n\n // Set up escape handler and loader if summarizing\n let summaryLoader: Loader | undefined;\n const originalOnEscape = this.defaultEditor.onEscape;\n\n if (wantsSummary) {\n this.defaultEditor.onEscape = () => {\n this.session.abortBranchSummary();\n };\n this.chatContainer.addChild(new Spacer(1));\n summaryLoader = new Loader(\n this.ui,\n (spinner) => theme.fg(\"accent\", spinner),\n (text) => theme.fg(\"muted\", text),\n `Summarizing branch... (${keyText(\"app.interrupt\")} Cancel)`,\n );\n this.statusContainer.addChild(summaryLoader);\n this.ui.requestRender();\n }\n\n try {\n const result = await this.session.navigateTree(entryId, {\n summarize: wantsSummary,\n customInstructions,\n });\n\n if (result.aborted) {\n // Summarization aborted - re-show tree selector with same selection\n this.showStatus(\"Branch summarization cancelled\");\n this.showTreeSelector(entryId);\n return;\n }\n if (result.cancelled) {\n this.showStatus(\"Navigation cancelled\");\n return;\n }\n\n // Update UI\n this.chatContainer.clear();\n this.renderInitialMessages();\n if (result.editorText && !this.editor.getText().trim()) {\n this.editor.setText(result.editorText);\n }\n this.showStatus(\"Navigated to selected point\");\n void this.flushCompactionQueue({ willRetry: false });\n } catch (error) {\n this.showError(\n error instanceof Error ? error.message : String(error),\n );\n } finally {\n if (summaryLoader) {\n summaryLoader.stop();\n this.statusContainer.clear();\n }\n this.defaultEditor.onEscape = originalOnEscape;\n }\n },\n () => {\n done();\n this.ui.requestRender();\n },\n (entryId, label) => {\n this.sessionManager.appendLabelChange(entryId, label);\n this.ui.requestRender();\n },\n initialSelectedId,\n initialFilterMode,\n );\n return { component: selector, focus: selector };\n });\n };\n\nInteractiveModeBase.prototype.showSessionSelector = function(this: InteractiveModeBase): void {\n this.showSelector((done) => {\n const selector = new SessionSelectorComponent(\n (onProgress) =>\n SessionManager.list(\n this.sessionManager.getCwd(),\n this.sessionManager.getSessionDir(),\n onProgress,\n ),\n (onProgress) =>\n this.sessionManager.usesDefaultSessionDir()\n ? SessionManager.listAll(onProgress)\n : SessionManager.listAll(\n this.sessionManager.getSessionDir(),\n onProgress,\n ),\n async (sessionPath) => {\n done();\n await this.handleResumeSession(sessionPath);\n },\n () => {\n done();\n this.ui.requestRender();\n },\n () => {\n void this.shutdown();\n },\n () => this.ui.requestRender(),\n {\n renameSession: async (\n sessionFilePath: string,\n nextName: string | undefined,\n ) => {\n const next = (nextName ?? \"\").trim();\n if (!next) return;\n const mgr = SessionManager.open(sessionFilePath);\n mgr.appendSessionInfo(next);\n },\n showRenameHint: true,\n keybindings: this.keybindings,\n },\n\n this.sessionManager.getSessionFile(),\n );\n return { component: selector, focus: selector };\n });\n };\n\nInteractiveModeBase.prototype.handleResumeSession = async function(this: InteractiveModeBase, sessionPath: string, options?: Parameters<ExtensionCommandContext[\"switchSession\"]>[1]): Promise<{ cancelled: boolean }> {\n if (this.loadingAnimation) {\n this.loadingAnimation.stop();\n this.loadingAnimation = undefined;\n }\n this.statusContainer.clear();\n try {\n const result = await this.runtimeHost.switchSession(sessionPath, {\n withSession: options?.withSession,\n projectTrustContextFactory: (cwd) => this.createProjectTrustContext(cwd),\n });\n if (result.cancelled) {\n return result;\n }\n this.renderCurrentSessionState();\n if (this.firstRunNoticeVisible) {\n this.clearFirstRunOnboardingUi();\n }\n this.showStatus(\"Resumed session\");\n return result;\n } catch (error: unknown) {\n if (error instanceof MissingSessionCwdError) {\n const selectedCwd = await this.promptForMissingSessionCwd(error);\n if (!selectedCwd) {\n this.showStatus(\"Resume cancelled\");\n return { cancelled: true };\n }\n const result = await this.runtimeHost.switchSession(sessionPath, {\n cwdOverride: selectedCwd,\n withSession: options?.withSession,\n projectTrustContextFactory: (cwd) => this.createProjectTrustContext(cwd),\n });\n if (result.cancelled) {\n return result;\n }\n this.renderCurrentSessionState();\n if (this.firstRunNoticeVisible) {\n this.clearFirstRunOnboardingUi();\n }\n this.showStatus(\"Resumed session in current cwd\");\n return result;\n }\n return this.handleFatalRuntimeError(\"Failed to resume session\", error);\n }\n };\n"]}
1
+ {"version":3,"file":"interactive-session-routing.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-session-routing.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type ExtensionCommandContext, Loader, Spacer, APP_NAME, MissingSessionCwdError, SessionManager, keyText, SessionSelectorComponent, TreeSelectorComponent, TrustSelectorComponent, hasTrustRequiringProjectResources, ProjectTrustStore, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.handleCloneCommand = async function(this: InteractiveModeBase): Promise<void> {\n await this.ensureDeferredStartupComplete();\n const leafId = this.sessionManager.getLeafId();\n if (!leafId) {\n this.showStatus(\"Nothing to clone yet\");\n return;\n }\n\n try {\n const result = await this.runtimeHost.fork(leafId, { position: \"at\" });\n if (result.cancelled) {\n this.ui.requestRender();\n return;\n }\n\n this.renderCurrentSessionState();\n this.editor.setText(\"\");\n this.showStatus(\"Cloned to new session\");\n } catch (error: unknown) {\n this.showError(error instanceof Error ? error.message : String(error));\n }\n };\n\nInteractiveModeBase.prototype.maybeSaveImplicitProjectTrustAfterReload = function(this: InteractiveModeBase): boolean {\n const cwd = this.sessionManager.getCwd();\n if (this.autoTrustOnReloadCwd !== cwd) {\n return false;\n }\n if (!this.settingsManager.isProjectTrusted() || !hasTrustRequiringProjectResources(cwd)) {\n return false;\n }\n\n const trustStore = new ProjectTrustStore(this.runtimeHost.services.agentDir);\n try {\n if (trustStore.get(cwd) !== null) {\n this.autoTrustOnReloadCwd = undefined;\n return false;\n }\n trustStore.set(cwd, true);\n this.autoTrustOnReloadCwd = undefined;\n return true;\n } catch (error) {\n this.showWarning(\n `Could not save project trust after reload: ${error instanceof Error ? error.message : String(error)}`,\n );\n return false;\n }\n };\n\nInteractiveModeBase.prototype.showTrustSelector = function(this: InteractiveModeBase): void {\n const cwd = this.sessionManager.getCwd();\n const trustStore = new ProjectTrustStore(this.runtimeHost.services.agentDir);\n const savedDecision = trustStore.getEntry(cwd);\n this.showSelector((done) => {\n const selector = new TrustSelectorComponent({\n cwd,\n savedDecision,\n projectTrusted: this.settingsManager.isProjectTrusted(),\n onSelect: (selection) => {\n trustStore.setMany(selection.updates);\n done();\n this.showStatus(\n `Saved trust decision: ${selection.trusted ? \"trusted\" : \"untrusted\"}. Restart ${APP_NAME} for this to take effect.`,\n );\n },\n onCancel: () => {\n done();\n this.ui.requestRender();\n },\n });\n return { component: selector, focus: selector };\n });\n };\n\nInteractiveModeBase.prototype.showTreeSelector = async function(this: InteractiveModeBase, initialSelectedId?: string): Promise<void> {\n await this.ensureDeferredStartupComplete();\n const tree = this.sessionManager.getTree();\n const realLeafId = this.sessionManager.getLeafId();\n const initialFilterMode = this.settingsManager.getTreeFilterMode();\n\n if (tree.length === 0) {\n this.showStatus(\"No entries in session\");\n return;\n }\n\n this.showSelector((done) => {\n const selector = new TreeSelectorComponent(\n tree,\n realLeafId,\n this.ui.terminal.rows,\n async (entryId) => {\n // Selecting the current leaf is a no-op (already there)\n if (entryId === realLeafId) {\n done();\n this.showStatus(\"Already at this point\");\n return;\n }\n\n // Ask about summarization\n done(); // Close selector first\n\n // Loop until user makes a complete choice or cancels to tree\n let wantsSummary = false;\n let customInstructions: string | undefined;\n\n // Check if we should skip the prompt (user preference to always default to no summary)\n if (!this.settingsManager.getBranchSummarySkipPrompt()) {\n while (true) {\n const summaryChoice = await this.showExtensionSelector(\n \"Summarize branch?\",\n [\"No summary\", \"Summarize\", \"Summarize with custom prompt\"],\n );\n\n if (summaryChoice === undefined) {\n // User pressed escape - re-show tree selector with same selection\n this.showTreeSelector(entryId);\n return;\n }\n\n wantsSummary = summaryChoice !== \"No summary\";\n\n if (summaryChoice === \"Summarize with custom prompt\") {\n customInstructions = await this.showExtensionEditor(\n \"Custom summarization instructions\",\n );\n if (customInstructions === undefined) {\n // User cancelled - loop back to summary selector\n continue;\n }\n }\n\n // User made a complete choice\n break;\n }\n }\n\n // Set up escape handler and loader if summarizing\n let summaryLoader: Loader | undefined;\n const originalOnEscape = this.defaultEditor.onEscape;\n\n if (wantsSummary) {\n this.defaultEditor.onEscape = () => {\n this.session.abortBranchSummary();\n };\n this.chatContainer.addChild(new Spacer(1));\n summaryLoader = new Loader(\n this.ui,\n (spinner) => theme.fg(\"accent\", spinner),\n (text) => theme.fg(\"muted\", text),\n `Summarizing branch... (${keyText(\"app.interrupt\")} Cancel)`,\n );\n this.statusContainer.addChild(summaryLoader);\n this.ui.requestRender();\n }\n\n try {\n await this.ensureDeferredStartupComplete();\n const result = await this.session.navigateTree(entryId, {\n summarize: wantsSummary,\n customInstructions,\n });\n\n if (result.aborted) {\n // Summarization aborted - re-show tree selector with same selection\n this.showStatus(\"Branch summarization cancelled\");\n this.showTreeSelector(entryId);\n return;\n }\n if (result.cancelled) {\n this.showStatus(\"Navigation cancelled\");\n return;\n }\n\n // Update UI\n this.chatContainer.clear();\n this.renderInitialMessages();\n if (result.editorText && !this.editor.getText().trim()) {\n this.editor.setText(result.editorText);\n }\n this.showStatus(\"Navigated to selected point\");\n void this.flushCompactionQueue({ willRetry: false });\n } catch (error) {\n this.showError(\n error instanceof Error ? error.message : String(error),\n );\n } finally {\n if (summaryLoader) {\n summaryLoader.stop();\n this.statusContainer.clear();\n }\n this.defaultEditor.onEscape = originalOnEscape;\n }\n },\n () => {\n done();\n this.ui.requestRender();\n },\n (entryId, label) => {\n this.sessionManager.appendLabelChange(entryId, label);\n this.ui.requestRender();\n },\n initialSelectedId,\n initialFilterMode,\n );\n return { component: selector, focus: selector };\n });\n };\n\nInteractiveModeBase.prototype.showSessionSelector = function(this: InteractiveModeBase): void {\n this.showSelector((done) => {\n const selector = new SessionSelectorComponent(\n (onProgress) =>\n SessionManager.list(\n this.sessionManager.getCwd(),\n this.sessionManager.getSessionDir(),\n onProgress,\n ),\n (onProgress) =>\n this.sessionManager.usesDefaultSessionDir()\n ? SessionManager.listAll(onProgress)\n : SessionManager.listAll(\n this.sessionManager.getSessionDir(),\n onProgress,\n ),\n async (sessionPath) => {\n done();\n await this.handleResumeSession(sessionPath);\n },\n () => {\n done();\n this.ui.requestRender();\n },\n () => {\n void this.shutdown();\n },\n () => this.ui.requestRender(),\n {\n renameSession: async (\n sessionFilePath: string,\n nextName: string | undefined,\n ) => {\n const next = (nextName ?? \"\").trim();\n if (!next) return;\n const mgr = SessionManager.open(sessionFilePath);\n mgr.appendSessionInfo(next);\n },\n showRenameHint: true,\n keybindings: this.keybindings,\n },\n\n this.sessionManager.getSessionFile(),\n );\n return { component: selector, focus: selector };\n });\n };\n\nInteractiveModeBase.prototype.handleResumeSession = async function(this: InteractiveModeBase, sessionPath: string, options?: Parameters<ExtensionCommandContext[\"switchSession\"]>[1]): Promise<{ cancelled: boolean }> {\n await this.ensureDeferredStartupComplete();\n if (this.loadingAnimation) {\n this.loadingAnimation.stop();\n this.loadingAnimation = undefined;\n }\n this.statusContainer.clear();\n try {\n const result = await this.runtimeHost.switchSession(sessionPath, {\n withSession: options?.withSession,\n projectTrustContextFactory: (cwd) => this.createProjectTrustContext(cwd),\n });\n if (result.cancelled) {\n return result;\n }\n this.renderCurrentSessionState();\n if (this.firstRunNoticeVisible) {\n this.clearFirstRunOnboardingUi();\n }\n this.showStatus(\"Resumed session\");\n return result;\n } catch (error: unknown) {\n if (error instanceof MissingSessionCwdError) {\n const selectedCwd = await this.promptForMissingSessionCwd(error);\n if (!selectedCwd) {\n this.showStatus(\"Resume cancelled\");\n return { cancelled: true };\n }\n const result = await this.runtimeHost.switchSession(sessionPath, {\n cwdOverride: selectedCwd,\n withSession: options?.withSession,\n projectTrustContextFactory: (cwd) => this.createProjectTrustContext(cwd),\n });\n if (result.cancelled) {\n return result;\n }\n this.renderCurrentSessionState();\n if (this.firstRunNoticeVisible) {\n this.clearFirstRunOnboardingUi();\n }\n this.showStatus(\"Resumed session in current cwd\");\n return result;\n }\n return this.handleFatalRuntimeError(\"Failed to resume session\", error);\n }\n };\n"]}
@@ -1,6 +1,7 @@
1
1
  import { InteractiveModeBase } from "./interactive-mode-base.js";
2
2
  import { Loader, Spacer, APP_NAME, MissingSessionCwdError, SessionManager, keyText, SessionSelectorComponent, TreeSelectorComponent, TrustSelectorComponent, hasTrustRequiringProjectResources, ProjectTrustStore, theme } from "./interactive-mode-deps.js";
3
3
  InteractiveModeBase.prototype.handleCloneCommand = async function () {
4
+ await this.ensureDeferredStartupComplete();
4
5
  const leafId = this.sessionManager.getLeafId();
5
6
  if (!leafId) {
6
7
  this.showStatus("Nothing to clone yet");
@@ -65,7 +66,8 @@ InteractiveModeBase.prototype.showTrustSelector = function () {
65
66
  return { component: selector, focus: selector };
66
67
  });
67
68
  };
68
- InteractiveModeBase.prototype.showTreeSelector = function (initialSelectedId) {
69
+ InteractiveModeBase.prototype.showTreeSelector = async function (initialSelectedId) {
70
+ await this.ensureDeferredStartupComplete();
69
71
  const tree = this.sessionManager.getTree();
70
72
  const realLeafId = this.sessionManager.getLeafId();
71
73
  const initialFilterMode = this.settingsManager.getTreeFilterMode();
@@ -120,6 +122,7 @@ InteractiveModeBase.prototype.showTreeSelector = function (initialSelectedId) {
120
122
  this.ui.requestRender();
121
123
  }
122
124
  try {
125
+ await this.ensureDeferredStartupComplete();
123
126
  const result = await this.session.navigateTree(entryId, {
124
127
  summarize: wantsSummary,
125
128
  customInstructions,
@@ -190,6 +193,7 @@ InteractiveModeBase.prototype.showSessionSelector = function () {
190
193
  });
191
194
  };
192
195
  InteractiveModeBase.prototype.handleResumeSession = async function (sessionPath, options) {
196
+ await this.ensureDeferredStartupComplete();
193
197
  if (this.loadingAnimation) {
194
198
  this.loadingAnimation.stop();
195
199
  this.loadingAnimation = undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-session-routing.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-session-routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAgC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,sBAAsB,EAAE,cAAc,EAAE,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,iCAAiC,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAE3R,mBAAmB,CAAC,SAAS,CAAC,kBAAkB,GAAG,KAAK;I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;YACD,IAAI,CAAC,UAAU,CAAC,gCAAgC,CAAC,CAAC;YAClD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,CAAC,uBAAuB,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type ExtensionCommandContext, Loader, Spacer, APP_NAME, MissingSessionCwdError, SessionManager, keyText, SessionSelectorComponent, TreeSelectorComponent, TrustSelectorComponent, hasTrustRequiringProjectResources, ProjectTrustStore, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.handleCloneCommand = async function(this: InteractiveModeBase): Promise<void> {\n const leafId = this.sessionManager.getLeafId();\n if (!leafId) {\n this.showStatus(\"Nothing to clone yet\");\n return;\n }\n\n try {\n const result = await this.runtimeHost.fork(leafId, { position: \"at\" });\n if (result.cancelled) {\n this.ui.requestRender();\n return;\n }\n\n this.renderCurrentSessionState();\n this.editor.setText(\"\");\n this.showStatus(\"Cloned to new session\");\n } catch (error: unknown) {\n this.showError(error instanceof Error ? error.message : String(error));\n }\n };\n\nInteractiveModeBase.prototype.maybeSaveImplicitProjectTrustAfterReload = function(this: InteractiveModeBase): boolean {\n const cwd = this.sessionManager.getCwd();\n if (this.autoTrustOnReloadCwd !== cwd) {\n return false;\n }\n if (!this.settingsManager.isProjectTrusted() || !hasTrustRequiringProjectResources(cwd)) {\n return false;\n }\n\n const trustStore = new ProjectTrustStore(this.runtimeHost.services.agentDir);\n try {\n if (trustStore.get(cwd) !== null) {\n this.autoTrustOnReloadCwd = undefined;\n return false;\n }\n trustStore.set(cwd, true);\n this.autoTrustOnReloadCwd = undefined;\n return true;\n } catch (error) {\n this.showWarning(\n `Could not save project trust after reload: ${error instanceof Error ? error.message : String(error)}`,\n );\n return false;\n }\n };\n\nInteractiveModeBase.prototype.showTrustSelector = function(this: InteractiveModeBase): void {\n const cwd = this.sessionManager.getCwd();\n const trustStore = new ProjectTrustStore(this.runtimeHost.services.agentDir);\n const savedDecision = trustStore.getEntry(cwd);\n this.showSelector((done) => {\n const selector = new TrustSelectorComponent({\n cwd,\n savedDecision,\n projectTrusted: this.settingsManager.isProjectTrusted(),\n onSelect: (selection) => {\n trustStore.setMany(selection.updates);\n done();\n this.showStatus(\n `Saved trust decision: ${selection.trusted ? \"trusted\" : \"untrusted\"}. Restart ${APP_NAME} for this to take effect.`,\n );\n },\n onCancel: () => {\n done();\n this.ui.requestRender();\n },\n });\n return { component: selector, focus: selector };\n });\n };\n\nInteractiveModeBase.prototype.showTreeSelector = function(this: InteractiveModeBase, initialSelectedId?: string): void {\n const tree = this.sessionManager.getTree();\n const realLeafId = this.sessionManager.getLeafId();\n const initialFilterMode = this.settingsManager.getTreeFilterMode();\n\n if (tree.length === 0) {\n this.showStatus(\"No entries in session\");\n return;\n }\n\n this.showSelector((done) => {\n const selector = new TreeSelectorComponent(\n tree,\n realLeafId,\n this.ui.terminal.rows,\n async (entryId) => {\n // Selecting the current leaf is a no-op (already there)\n if (entryId === realLeafId) {\n done();\n this.showStatus(\"Already at this point\");\n return;\n }\n\n // Ask about summarization\n done(); // Close selector first\n\n // Loop until user makes a complete choice or cancels to tree\n let wantsSummary = false;\n let customInstructions: string | undefined;\n\n // Check if we should skip the prompt (user preference to always default to no summary)\n if (!this.settingsManager.getBranchSummarySkipPrompt()) {\n while (true) {\n const summaryChoice = await this.showExtensionSelector(\n \"Summarize branch?\",\n [\"No summary\", \"Summarize\", \"Summarize with custom prompt\"],\n );\n\n if (summaryChoice === undefined) {\n // User pressed escape - re-show tree selector with same selection\n this.showTreeSelector(entryId);\n return;\n }\n\n wantsSummary = summaryChoice !== \"No summary\";\n\n if (summaryChoice === \"Summarize with custom prompt\") {\n customInstructions = await this.showExtensionEditor(\n \"Custom summarization instructions\",\n );\n if (customInstructions === undefined) {\n // User cancelled - loop back to summary selector\n continue;\n }\n }\n\n // User made a complete choice\n break;\n }\n }\n\n // Set up escape handler and loader if summarizing\n let summaryLoader: Loader | undefined;\n const originalOnEscape = this.defaultEditor.onEscape;\n\n if (wantsSummary) {\n this.defaultEditor.onEscape = () => {\n this.session.abortBranchSummary();\n };\n this.chatContainer.addChild(new Spacer(1));\n summaryLoader = new Loader(\n this.ui,\n (spinner) => theme.fg(\"accent\", spinner),\n (text) => theme.fg(\"muted\", text),\n `Summarizing branch... (${keyText(\"app.interrupt\")} Cancel)`,\n );\n this.statusContainer.addChild(summaryLoader);\n this.ui.requestRender();\n }\n\n try {\n const result = await this.session.navigateTree(entryId, {\n summarize: wantsSummary,\n customInstructions,\n });\n\n if (result.aborted) {\n // Summarization aborted - re-show tree selector with same selection\n this.showStatus(\"Branch summarization cancelled\");\n this.showTreeSelector(entryId);\n return;\n }\n if (result.cancelled) {\n this.showStatus(\"Navigation cancelled\");\n return;\n }\n\n // Update UI\n this.chatContainer.clear();\n this.renderInitialMessages();\n if (result.editorText && !this.editor.getText().trim()) {\n this.editor.setText(result.editorText);\n }\n this.showStatus(\"Navigated to selected point\");\n void this.flushCompactionQueue({ willRetry: false });\n } catch (error) {\n this.showError(\n error instanceof Error ? error.message : String(error),\n );\n } finally {\n if (summaryLoader) {\n summaryLoader.stop();\n this.statusContainer.clear();\n }\n this.defaultEditor.onEscape = originalOnEscape;\n }\n },\n () => {\n done();\n this.ui.requestRender();\n },\n (entryId, label) => {\n this.sessionManager.appendLabelChange(entryId, label);\n this.ui.requestRender();\n },\n initialSelectedId,\n initialFilterMode,\n );\n return { component: selector, focus: selector };\n });\n };\n\nInteractiveModeBase.prototype.showSessionSelector = function(this: InteractiveModeBase): void {\n this.showSelector((done) => {\n const selector = new SessionSelectorComponent(\n (onProgress) =>\n SessionManager.list(\n this.sessionManager.getCwd(),\n this.sessionManager.getSessionDir(),\n onProgress,\n ),\n (onProgress) =>\n this.sessionManager.usesDefaultSessionDir()\n ? SessionManager.listAll(onProgress)\n : SessionManager.listAll(\n this.sessionManager.getSessionDir(),\n onProgress,\n ),\n async (sessionPath) => {\n done();\n await this.handleResumeSession(sessionPath);\n },\n () => {\n done();\n this.ui.requestRender();\n },\n () => {\n void this.shutdown();\n },\n () => this.ui.requestRender(),\n {\n renameSession: async (\n sessionFilePath: string,\n nextName: string | undefined,\n ) => {\n const next = (nextName ?? \"\").trim();\n if (!next) return;\n const mgr = SessionManager.open(sessionFilePath);\n mgr.appendSessionInfo(next);\n },\n showRenameHint: true,\n keybindings: this.keybindings,\n },\n\n this.sessionManager.getSessionFile(),\n );\n return { component: selector, focus: selector };\n });\n };\n\nInteractiveModeBase.prototype.handleResumeSession = async function(this: InteractiveModeBase, sessionPath: string, options?: Parameters<ExtensionCommandContext[\"switchSession\"]>[1]): Promise<{ cancelled: boolean }> {\n if (this.loadingAnimation) {\n this.loadingAnimation.stop();\n this.loadingAnimation = undefined;\n }\n this.statusContainer.clear();\n try {\n const result = await this.runtimeHost.switchSession(sessionPath, {\n withSession: options?.withSession,\n projectTrustContextFactory: (cwd) => this.createProjectTrustContext(cwd),\n });\n if (result.cancelled) {\n return result;\n }\n this.renderCurrentSessionState();\n if (this.firstRunNoticeVisible) {\n this.clearFirstRunOnboardingUi();\n }\n this.showStatus(\"Resumed session\");\n return result;\n } catch (error: unknown) {\n if (error instanceof MissingSessionCwdError) {\n const selectedCwd = await this.promptForMissingSessionCwd(error);\n if (!selectedCwd) {\n this.showStatus(\"Resume cancelled\");\n return { cancelled: true };\n }\n const result = await this.runtimeHost.switchSession(sessionPath, {\n cwdOverride: selectedCwd,\n withSession: options?.withSession,\n projectTrustContextFactory: (cwd) => this.createProjectTrustContext(cwd),\n });\n if (result.cancelled) {\n return result;\n }\n this.renderCurrentSessionState();\n if (this.firstRunNoticeVisible) {\n this.clearFirstRunOnboardingUi();\n }\n this.showStatus(\"Resumed session in current cwd\");\n return result;\n }\n return this.handleFatalRuntimeError(\"Failed to resume session\", error);\n }\n };\n"]}
1
+ {"version":3,"file":"interactive-session-routing.js","sourceRoot":"","sources":["../../../src/modes/interact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AAC;gBACpC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;YAC7B,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,WAAW,EAAE;gBAC/D,WAAW,EAAE,WAAW;gBACxB,WAAW,EAAE,OAAO,EAAE,WAAW;gBACjC,0BAA0B,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC;aACzE,CAAC,CAAC;YACH,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;gBACrB,OAAO,MAAM,CAAC;YAChB,CAAC;YACD,IAAI,CAAC,yBAAyB,EAAE,CAAC;YACjC,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;gBAC/B,IAAI,CAAC,yBAAyB,EAAE,CAAC;YACnC,CAAC;YACD,IAAI,CAAC,UAAU,CAAC,gCAAgC,CAAC,CAAC;YAClD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,CAAC,uBAAuB,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type ExtensionCommandContext, Loader, Spacer, APP_NAME, MissingSessionCwdError, SessionManager, keyText, SessionSelectorComponent, TreeSelectorComponent, TrustSelectorComponent, hasTrustRequiringProjectResources, ProjectTrustStore, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.handleCloneCommand = async function(this: InteractiveModeBase): Promise<void> {\n await this.ensureDeferredStartupComplete();\n const leafId = this.sessionManager.getLeafId();\n if (!leafId) {\n this.showStatus(\"Nothing to clone yet\");\n return;\n }\n\n try {\n const result = await this.runtimeHost.fork(leafId, { position: \"at\" });\n if (result.cancelled) {\n this.ui.requestRender();\n return;\n }\n\n this.renderCurrentSessionState();\n this.editor.setText(\"\");\n this.showStatus(\"Cloned to new session\");\n } catch (error: unknown) {\n this.showError(error instanceof Error ? error.message : String(error));\n }\n };\n\nInteractiveModeBase.prototype.maybeSaveImplicitProjectTrustAfterReload = function(this: InteractiveModeBase): boolean {\n const cwd = this.sessionManager.getCwd();\n if (this.autoTrustOnReloadCwd !== cwd) {\n return false;\n }\n if (!this.settingsManager.isProjectTrusted() || !hasTrustRequiringProjectResources(cwd)) {\n return false;\n }\n\n const trustStore = new ProjectTrustStore(this.runtimeHost.services.agentDir);\n try {\n if (trustStore.get(cwd) !== null) {\n this.autoTrustOnReloadCwd = undefined;\n return false;\n }\n trustStore.set(cwd, true);\n this.autoTrustOnReloadCwd = undefined;\n return true;\n } catch (error) {\n this.showWarning(\n `Could not save project trust after reload: ${error instanceof Error ? error.message : String(error)}`,\n );\n return false;\n }\n };\n\nInteractiveModeBase.prototype.showTrustSelector = function(this: InteractiveModeBase): void {\n const cwd = this.sessionManager.getCwd();\n const trustStore = new ProjectTrustStore(this.runtimeHost.services.agentDir);\n const savedDecision = trustStore.getEntry(cwd);\n this.showSelector((done) => {\n const selector = new TrustSelectorComponent({\n cwd,\n savedDecision,\n projectTrusted: this.settingsManager.isProjectTrusted(),\n onSelect: (selection) => {\n trustStore.setMany(selection.updates);\n done();\n this.showStatus(\n `Saved trust decision: ${selection.trusted ? \"trusted\" : \"untrusted\"}. Restart ${APP_NAME} for this to take effect.`,\n );\n },\n onCancel: () => {\n done();\n this.ui.requestRender();\n },\n });\n return { component: selector, focus: selector };\n });\n };\n\nInteractiveModeBase.prototype.showTreeSelector = async function(this: InteractiveModeBase, initialSelectedId?: string): Promise<void> {\n await this.ensureDeferredStartupComplete();\n const tree = this.sessionManager.getTree();\n const realLeafId = this.sessionManager.getLeafId();\n const initialFilterMode = this.settingsManager.getTreeFilterMode();\n\n if (tree.length === 0) {\n this.showStatus(\"No entries in session\");\n return;\n }\n\n this.showSelector((done) => {\n const selector = new TreeSelectorComponent(\n tree,\n realLeafId,\n this.ui.terminal.rows,\n async (entryId) => {\n // Selecting the current leaf is a no-op (already there)\n if (entryId === realLeafId) {\n done();\n this.showStatus(\"Already at this point\");\n return;\n }\n\n // Ask about summarization\n done(); // Close selector first\n\n // Loop until user makes a complete choice or cancels to tree\n let wantsSummary = false;\n let customInstructions: string | undefined;\n\n // Check if we should skip the prompt (user preference to always default to no summary)\n if (!this.settingsManager.getBranchSummarySkipPrompt()) {\n while (true) {\n const summaryChoice = await this.showExtensionSelector(\n \"Summarize branch?\",\n [\"No summary\", \"Summarize\", \"Summarize with custom prompt\"],\n );\n\n if (summaryChoice === undefined) {\n // User pressed escape - re-show tree selector with same selection\n this.showTreeSelector(entryId);\n return;\n }\n\n wantsSummary = summaryChoice !== \"No summary\";\n\n if (summaryChoice === \"Summarize with custom prompt\") {\n customInstructions = await this.showExtensionEditor(\n \"Custom summarization instructions\",\n );\n if (customInstructions === undefined) {\n // User cancelled - loop back to summary selector\n continue;\n }\n }\n\n // User made a complete choice\n break;\n }\n }\n\n // Set up escape handler and loader if summarizing\n let summaryLoader: Loader | undefined;\n const originalOnEscape = this.defaultEditor.onEscape;\n\n if (wantsSummary) {\n this.defaultEditor.onEscape = () => {\n this.session.abortBranchSummary();\n };\n this.chatContainer.addChild(new Spacer(1));\n summaryLoader = new Loader(\n this.ui,\n (spinner) => theme.fg(\"accent\", spinner),\n (text) => theme.fg(\"muted\", text),\n `Summarizing branch... (${keyText(\"app.interrupt\")} Cancel)`,\n );\n this.statusContainer.addChild(summaryLoader);\n this.ui.requestRender();\n }\n\n try {\n await this.ensureDeferredStartupComplete();\n const result = await this.session.navigateTree(entryId, {\n summarize: wantsSummary,\n customInstructions,\n });\n\n if (result.aborted) {\n // Summarization aborted - re-show tree selector with same selection\n this.showStatus(\"Branch summarization cancelled\");\n this.showTreeSelector(entryId);\n return;\n }\n if (result.cancelled) {\n this.showStatus(\"Navigation cancelled\");\n return;\n }\n\n // Update UI\n this.chatContainer.clear();\n this.renderInitialMessages();\n if (result.editorText && !this.editor.getText().trim()) {\n this.editor.setText(result.editorText);\n }\n this.showStatus(\"Navigated to selected point\");\n void this.flushCompactionQueue({ willRetry: false });\n } catch (error) {\n this.showError(\n error instanceof Error ? error.message : String(error),\n );\n } finally {\n if (summaryLoader) {\n summaryLoader.stop();\n this.statusContainer.clear();\n }\n this.defaultEditor.onEscape = originalOnEscape;\n }\n },\n () => {\n done();\n this.ui.requestRender();\n },\n (entryId, label) => {\n this.sessionManager.appendLabelChange(entryId, label);\n this.ui.requestRender();\n },\n initialSelectedId,\n initialFilterMode,\n );\n return { component: selector, focus: selector };\n });\n };\n\nInteractiveModeBase.prototype.showSessionSelector = function(this: InteractiveModeBase): void {\n this.showSelector((done) => {\n const selector = new SessionSelectorComponent(\n (onProgress) =>\n SessionManager.list(\n this.sessionManager.getCwd(),\n this.sessionManager.getSessionDir(),\n onProgress,\n ),\n (onProgress) =>\n this.sessionManager.usesDefaultSessionDir()\n ? SessionManager.listAll(onProgress)\n : SessionManager.listAll(\n this.sessionManager.getSessionDir(),\n onProgress,\n ),\n async (sessionPath) => {\n done();\n await this.handleResumeSession(sessionPath);\n },\n () => {\n done();\n this.ui.requestRender();\n },\n () => {\n void this.shutdown();\n },\n () => this.ui.requestRender(),\n {\n renameSession: async (\n sessionFilePath: string,\n nextName: string | undefined,\n ) => {\n const next = (nextName ?? \"\").trim();\n if (!next) return;\n const mgr = SessionManager.open(sessionFilePath);\n mgr.appendSessionInfo(next);\n },\n showRenameHint: true,\n keybindings: this.keybindings,\n },\n\n this.sessionManager.getSessionFile(),\n );\n return { component: selector, focus: selector };\n });\n };\n\nInteractiveModeBase.prototype.handleResumeSession = async function(this: InteractiveModeBase, sessionPath: string, options?: Parameters<ExtensionCommandContext[\"switchSession\"]>[1]): Promise<{ cancelled: boolean }> {\n await this.ensureDeferredStartupComplete();\n if (this.loadingAnimation) {\n this.loadingAnimation.stop();\n this.loadingAnimation = undefined;\n }\n this.statusContainer.clear();\n try {\n const result = await this.runtimeHost.switchSession(sessionPath, {\n withSession: options?.withSession,\n projectTrustContextFactory: (cwd) => this.createProjectTrustContext(cwd),\n });\n if (result.cancelled) {\n return result;\n }\n this.renderCurrentSessionState();\n if (this.firstRunNoticeVisible) {\n this.clearFirstRunOnboardingUi();\n }\n this.showStatus(\"Resumed session\");\n return result;\n } catch (error: unknown) {\n if (error instanceof MissingSessionCwdError) {\n const selectedCwd = await this.promptForMissingSessionCwd(error);\n if (!selectedCwd) {\n this.showStatus(\"Resume cancelled\");\n return { cancelled: true };\n }\n const result = await this.runtimeHost.switchSession(sessionPath, {\n cwdOverride: selectedCwd,\n withSession: options?.withSession,\n projectTrustContextFactory: (cwd) => this.createProjectTrustContext(cwd),\n });\n if (result.cancelled) {\n return result;\n }\n this.renderCurrentSessionState();\n if (this.firstRunNoticeVisible) {\n this.clearFirstRunOnboardingUi();\n }\n this.showStatus(\"Resumed session in current cwd\");\n return result;\n }\n return this.handleFatalRuntimeError(\"Failed to resume session\", error);\n }\n };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-startup.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-startup.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase, seedStartupInput } from \"./interactive-mode-base.ts\";\nimport { type Container, type MarkdownTheme, os, path, Markdown, Spacer, Text, spawn, APP_NAME, APP_TITLE, ENV_OFFLINE, getEnvValue, getAgentDir, VERSION, formatCodexFastModeModelLabel, shouldApplyCodexFastMode, DefaultPackageManager, isInstallTelemetryEnabled, getChangelogPath, getEntriesForVersion, getNewEntries, normalizeChangelogLinks, parseChangelog, getCwdRelativePath, getPiUserAgent, recordTimeSinceReset, ensureTool, checkForNewPiVersion, renderAtomicAnsiBanner, DynamicBorder, getMarkdownTheme, onThemeChange, theme } from \"./interactive-mode-deps.ts\";\nimport { ExpandableText } from \"./interactive-mode-helpers.ts\";\nimport { ONBOARDING_COPY } from \"./interactive-onboarding.ts\";\n\nInteractiveModeBase.prototype.showStartupNoticesIfNeeded = function(this: InteractiveModeBase, targetContainer: Container = this.chatContainer): void {\n if (this.startupNoticesShown) {\n return;\n }\n this.startupNoticesShown = true;\n\n const changelogMarkdown = this.changelogMarkdown;\n if (!changelogMarkdown && !this.firstRunNoticeVisible) {\n return;\n }\n\n if (changelogMarkdown) {\n if (targetContainer.children.length > 0) {\n targetContainer.addChild(new Spacer(1));\n }\n targetContainer.addChild(new DynamicBorder());\n if (this.settingsManager.getCollapseChangelog()) {\n const versionMatch = changelogMarkdown.match(\n /##\\s+\\[?((?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-(?:alpha\\.)?(?:0|[1-9]\\d*))?)\\]?/,\n );\n const latestVersion = versionMatch ? versionMatch[1] : this.version;\n const condensedText = `Updated to v${latestVersion}. Use ${theme.bold(\"/changelog\")} to view full changelog.`;\n targetContainer.addChild(new Text(condensedText, 1, 0));\n } else {\n targetContainer.addChild(\n new Text(theme.bold(theme.fg(\"accent\", \"What's New\")), 1, 0),\n );\n targetContainer.addChild(new Spacer(1));\n targetContainer.addChild(\n new Markdown(\n changelogMarkdown.trim(),\n 1,\n 0,\n this.getMarkdownThemeWithSettings(),\n ),\n );\n targetContainer.addChild(new Spacer(1));\n }\n targetContainer.addChild(new DynamicBorder());\n }\n\n if (this.firstRunNoticeVisible) {\n this.firstRunOnboardingNoticeComponents = [];\n if (targetContainer.children.length > 0) {\n this.firstRunOnboardingNoticeComponents.push(new Spacer(1));\n }\n this.firstRunOnboardingNoticeComponents.push(\n new DynamicBorder(),\n new Text(ONBOARDING_COPY, 1, 0),\n new DynamicBorder(),\n new Spacer(1),\n );\n for (const component of this.firstRunOnboardingNoticeComponents) {\n targetContainer.addChild(component);\n }\n // Mark completion only after queueing the notice in the chat canvas so\n // launches that skip rendering retry the first-run notice next time.\n this.settingsManager.setOnboardedVersion(this.version);\n }\n\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.init = async function(this: InteractiveModeBase): Promise<void> {\n if (this.isInitialized) return;\n\n this.registerSignalHandlers();\n\n // Load changelog (only show new entries, skip for resumed sessions)\n this.hadLastChangelogVersionAtStartup = Boolean(this.settingsManager.getLastChangelogVersion());\n this.changelogMarkdown = this.getChangelogForDisplay();\n this.initializeFirstRunOnboardingMarkers();\n\n // Add header container as first child. Populate it after theme initialization.\n this.ui.addChild(this.headerContainer);\n\n this.ui.addChild(this.chatContainer);\n this.ui.addChild(this.pendingMessagesContainer);\n this.ui.addChild(this.statusContainer);\n this.renderWidgets(); // Initialize with default spacer\n this.ui.addChild(this.widgetContainerAbove);\n this.ui.addChild(this.usageMeter);\n this.ui.addChild(this.editorContainer);\n // Footer (persistent model + cwd identity) stays pinned directly under the\n // editor; below-editor widgets render after it, at the very bottom. This\n // keeps the session identity line attached to the input and places\n // transient run status (e.g. the workflow companion counter) beneath it.\n // Rendering below-editor widgets last also keeps a live widget at the\n // absolute bottom of the buffer (always within the viewport), so its\n // per-tick updates never sit above the fold — preserving the #1109\n // resize-flicker fix.\n this.ui.addChild(this.footer);\n this.ui.addChild(this.widgetContainerBelow);\n this.ui.setFocus(this.editor);\n\n this.setupKeyHandlers();\n this.setupEditorSubmitHandler();\n\n this.firstRunNoticeVisible = this.isFirstRunOnboardingEligible();\n\n seedStartupInput(\n this.pendingUserInputs,\n this.defaultEditor,\n this.options.startupInputCapture?.consume(),\n this.startupReplayInputs,\n (text) => {\n this.startupDraftText = text;\n },\n (text) => {\n this.startupReplayActiveInput = text;\n },\n );\n\n // Start the UI before initializing extensions so session_start handlers can use interactive dialogs.\n // fd/rg readiness is intentionally checked after first paint because ensureTool may spawn\n // or download tools on cold machines.\n this.ui.start();\n recordTimeSinceReset(\"time-to-first-frame\");\n this.isInitialized = true;\n\n await this.themeController.applyFromSettings();\n\n // Add the quiet startup identity (unless silenced). Resource details are\n // disclosed separately in the chat canvas via the tools/resources toggle.\n if (this.options.verbose || !this.settingsManager.getQuietStartup()) {\n this.builtInHeader = new ExpandableText(\n () => this.getStartupIdentityText(),\n () => this.getStartupIdentityText(),\n this.getStartupExpansionState(),\n 1,\n 0,\n );\n\n this.headerContainer.addChild(new Spacer(1));\n this.headerContainer.addChild(this.builtInHeader);\n this.headerContainer.addChild(new Spacer(1));\n } else {\n // Minimal header when silenced\n this.builtInHeader = new Text(\"\", 0, 0);\n this.headerContainer.addChild(this.builtInHeader);\n }\n this.ui.requestRender();\n\n void Promise.all([ensureTool(\"fd\"), ensureTool(\"rg\")])\n .then(([fdPath]) => {\n this.fdPath = fdPath;\n this.setupAutocompleteProvider();\n })\n .catch((error) => {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`Tool readiness check failed: ${message}`);\n });\n\n // When startup resources are deferred, keep the already-painted editor responsive.\n // Extension UI bindings are installed at the deferred reload boundary, not here,\n // so no post-paint resource work can block visible typing.\n if (this.deferredStartupPending) {\n this.applyRuntimeSettings();\n this.subscribeToAgent();\n this.updateEditorBorderColor();\n this.updateTerminalTitle();\n } else {\n await this.rebindCurrentSession();\n }\n\n this.attachStartupNoticesContainer();\n // Render initial messages AFTER the initial session binding is in place.\n this.renderInitialMessages();\n\tif (this.deferredStartupPending) {\n\t\tsetTimeout(() => {\n\t\t\tif (!this.deferredStartupPending || this.deferredStartupPromise) return;\n\t\t\tvoid this.ensureDeferredStartupComplete();\n\t\t}, 2000);\n\t}\n // Set up theme file watcher\n onThemeChange(() => {\n this.ui.invalidate();\n this.updateEditorBorderColor();\n this.ui.requestRender();\n });\n\n // Set up git branch watcher (uses provider instead of footer)\n this.footerDataProvider.onBranchChange(() => {\n this.ui.requestRender();\n });\n\n // Initialize available provider count for footer display without delaying first-frame startup.\n void this.updateAvailableProviderCount().catch((error) => {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`Failed to update provider count: ${message}`);\n });\n };\n\nInteractiveModeBase.prototype.updateTerminalTitle = function(this: InteractiveModeBase): void {\n const cwdBasename = path.basename(this.sessionManager.getCwd());\n const sessionName = this.sessionManager.getSessionName();\n if (sessionName) {\n this.ui.terminal.setTitle(\n `${APP_TITLE} - ${sessionName} - ${cwdBasename}`,\n );\n } else {\n this.ui.terminal.setTitle(`${APP_TITLE} - ${cwdBasename}`);\n }\n };\n\nInteractiveModeBase.prototype.run = async function(this: InteractiveModeBase): Promise<void> {\n await this.init();\n\n\tsetTimeout(() => {\n\t\tvoid this.refreshCopilotModelCatalog();\n const startupNoticesContainer = this.startupNoticesContainer;\n\t\tcheckForNewPiVersion(this.version).then((newVersion) => {\n\t\t\tif (newVersion) this.showNewVersionNotification(newVersion, startupNoticesContainer);\n\t\t});\n\t\tthis.checkForPackageUpdates().then((updates) => {\n\t\t\tif (updates.length > 0) this.showPackageUpdateNotification(updates, startupNoticesContainer);\n\t\t});\n\t\tthis.checkTmuxKeyboardSetup().then((warning) => {\n\t\t\tif (warning) this.showWarning(warning, startupNoticesContainer);\n\t\t});\n\t\t// When startup is deferred, the RESOURCES disclosure renders after the\n\t\t// deferred extension load; hold the subscription warning until then so\n\t\t// the disclosure always appears first.\n\t\tif (!this.deferredStartupPending && !this.deferredStartupPromise && !this.pendingLoadedResourcesDisclosure) {\n\t\t\tvoid this.maybeWarnAboutAnthropicSubscriptionAuth(undefined, startupNoticesContainer);\n\t\t}\n\t}, 500);\n\n // Show startup warnings\n const {\n migratedProviders,\n modelFallbackMessage,\n initialMessage,\n initialImages,\n initialMessages,\n } = this.options;\n\n if (migratedProviders && migratedProviders.length > 0) {\n this.showWarning(\n `Migrated credentials to auth.json: ${migratedProviders.join(\", \")}`,\n );\n }\n\n const modelsJsonError = this.session.modelRegistry.getError();\n if (modelsJsonError) {\n this.showError(`models.json error: ${modelsJsonError}`);\n }\n\n if (modelFallbackMessage && !this.deferredStartupPending) {\n this.showWarning(modelFallbackMessage, this.startupNoticesContainer);\n }\n\n // CLI-provided startup prompts need extension tools/resources; wait before sending them,\n // but do not block the normal no-prompt input loop from becoming ready.\n if (this.deferredStartupPending && (initialMessage || (initialMessages && initialMessages.length > 0))) {\n await this.ensureDeferredStartupComplete();\n }\n\n // Process initial messages\n if (initialMessage) {\n try {\n await this.session.prompt(initialMessage, { images: initialImages });\n } catch (error: unknown) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error occurred\";\n this.showError(errorMessage);\n }\n }\n\n if (initialMessages) {\n for (const message of initialMessages) {\n try {\n await this.session.prompt(message);\n } catch (error: unknown) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error occurred\";\n this.showError(errorMessage);\n }\n }\n }\n\n // Main interactive loop\n while (true) {\n const userInput = await this.getUserInput();\n await this.runUserPromptTurn(userInput);\n }\n };\n\nInteractiveModeBase.prototype.checkForPackageUpdates = async function(this: InteractiveModeBase): Promise<string[]> {\n if (getEnvValue(ENV_OFFLINE)) {\n return [];\n }\n\n try {\n const packageManager = new DefaultPackageManager({\n cwd: this.sessionManager.getCwd(),\n agentDir: getAgentDir(),\n settingsManager: this.settingsManager,\n });\n const updates = await packageManager.checkForAvailableUpdates();\n return updates.map((update) => update.displayName);\n } catch {\n return [];\n }\n };\n\nInteractiveModeBase.prototype.checkTmuxKeyboardSetup = async function(this: InteractiveModeBase): Promise<string | undefined> {\n if (!process.env.TMUX) return undefined;\n\n const runTmuxShow = (option: string): Promise<string | undefined> => {\n return new Promise((resolve) => {\n const proc = spawn(\"tmux\", [\"show\", \"-gv\", option], {\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n });\n let stdout = \"\";\n const timer = setTimeout(() => {\n proc.kill();\n resolve(undefined);\n }, 2000);\n\n proc.stdout?.on(\"data\", (data) => {\n stdout += data.toString();\n });\n proc.on(\"error\", () => {\n clearTimeout(timer);\n resolve(undefined);\n });\n proc.on(\"close\", (code) => {\n clearTimeout(timer);\n resolve(code === 0 ? stdout.trim() : undefined);\n });\n });\n };\n\n const [extendedKeys, extendedKeysFormat] = await Promise.all([\n runTmuxShow(\"extended-keys\"),\n runTmuxShow(\"extended-keys-format\"),\n ]);\n\n // If we couldn't query tmux (timeout, sandbox, etc.), don't warn\n if (extendedKeys === undefined) return undefined;\n\n if (extendedKeys !== \"on\" && extendedKeys !== \"always\") {\n return \"tmux extended-keys is off. Modified enter keys may not work. Add `set -g extended-keys on` to ~/.tmux.conf and restart tmux.\";\n }\n\n if (extendedKeysFormat === \"xterm\") {\n return \"tmux extended-keys-format is xterm. Pi works best with csi-u. Add `set -g extended-keys-format csi-u` to ~/.tmux.conf and restart tmux.\";\n }\n\n return undefined;\n };\n\nInteractiveModeBase.prototype.getChangelogForDisplay = function(this: InteractiveModeBase): string | undefined {\n // Skip changelog for resumed/continued sessions (already have messages)\n if (this.session.state.messages.length > 0) {\n return undefined;\n }\n\n const lastVersion = this.settingsManager.getLastChangelogVersion();\n const changelogPath = getChangelogPath();\n const entries = parseChangelog(changelogPath);\n\n if (!lastVersion) {\n // Fresh install - record the version, send telemetry, don't show changelog\n this.settingsManager.setLastChangelogVersion(VERSION);\n this.reportInstallTelemetry(VERSION);\n return undefined;\n }\n\n const newEntries = getNewEntries(entries, lastVersion, VERSION);\n const currentEntries = getEntriesForVersion(newEntries, VERSION);\n if (currentEntries.length > 0) {\n this.settingsManager.setLastChangelogVersion(VERSION);\n this.reportInstallTelemetry(VERSION);\n return currentEntries.map((e) => normalizeChangelogLinks(e.content, e)).join(\"\\n\\n\");\n }\n\n return undefined;\n };\n\nInteractiveModeBase.prototype.reportInstallTelemetry = function(this: InteractiveModeBase, version: string): void {\n if (getEnvValue(ENV_OFFLINE)) {\n return;\n }\n\n if (!isInstallTelemetryEnabled(this.settingsManager)) {\n return;\n }\n\n void fetch(\n `https://pi.dev/api/report-install?version=${encodeURIComponent(version)}`,\n {\n headers: {\n \"User-Agent\": getPiUserAgent(version),\n },\n signal: AbortSignal.timeout(5000),\n },\n )\n .then(() => undefined)\n .catch(() => undefined);\n };\n\nInteractiveModeBase.prototype.getMarkdownThemeWithSettings = function(this: InteractiveModeBase): MarkdownTheme {\n return {\n ...getMarkdownTheme(),\n codeBlockIndent: this.settingsManager.getCodeBlockIndent(),\n };\n };\n\nInteractiveModeBase.prototype.formatDisplayPath = function(this: InteractiveModeBase, p: string): string {\n const home = os.homedir();\n let result = p;\n\n // Replace home directory with ~\n if (result.startsWith(home)) {\n result = `~${result.slice(home.length)}`;\n }\n\n return result;\n };\n\nInteractiveModeBase.prototype.formatExtensionDisplayPath = function(this: InteractiveModeBase, path: string): string {\n let result = this.formatDisplayPath(path);\n result = result.replace(/\\/index\\.ts$/, \"\").replace(/\\/index\\.js$/, \"\");\n return result;\n };\n\nInteractiveModeBase.prototype.formatContextPath = function(this: InteractiveModeBase, p: string): string {\n const cwd = path.resolve(this.sessionManager.getCwd());\n const absolutePath = path.isAbsolute(p)\n ? path.resolve(p)\n : path.resolve(cwd, p);\n const relativePath = getCwdRelativePath(absolutePath, cwd);\n if (relativePath !== undefined) {\n return relativePath;\n }\n\n return this.formatDisplayPath(absolutePath);\n };\n\nInteractiveModeBase.prototype.getStartupModelLabel = function(this: InteractiveModeBase): string {\n const model = this.session.state.model;\n let modelLabel = model?.id ?? \"no-model\";\n\n if (model?.reasoning) {\n modelLabel = `${modelLabel} ${this.session.thinkingLevel || \"off\"}`;\n }\n\n if (!model) {\n return modelLabel;\n }\n\n const fastModeEnabled = shouldApplyCodexFastMode(\n model,\n this.session.settingsManager.getCodexFastModeSettings(),\n this.session.orchestrationContext,\n );\n return formatCodexFastModeModelLabel(modelLabel, fastModeEnabled);\n };\n\nInteractiveModeBase.prototype.getStartupIdentityText = function(this: InteractiveModeBase): string {\n const appLabel = APP_NAME.length > 0\n ? `${APP_NAME[0]!.toUpperCase()}${APP_NAME.slice(1)}`\n : \"Atomic\";\n const title = `${theme.bold(theme.fg(\"text\", appLabel))} ${theme.fg(\"muted\", `v${this.version}`)}`;\n const model = this.session.state.model;\n const provider = model ? theme.fg(\"dim\", `(${model.provider})`) : theme.fg(\"dim\", \"(no-provider)\");\n const modelLine = `${provider} ${theme.fg(\"muted\", this.getStartupModelLabel())}`;\n const cwd = theme.fg(\"muted\", this.formatDisplayPath(this.sessionManager.getCwd()));\n const metaLines = [title, modelLine, cwd];\n const markLines = this.getAtomicAnsiMarkLines();\n\n return markLines\n .map((line, index) => `${line} ${metaLines[index] ?? \"\"}`.trimEnd())\n .join(\"\\n\");\n };\n\nInteractiveModeBase.prototype.getAtomicAnsiMarkLines = function(this: InteractiveModeBase): string[] {\n return renderAtomicAnsiBanner(theme, this.session.thinkingLevel || \"off\");\n };\n\nInteractiveModeBase.prototype.getStartupExpansionState = function(this: InteractiveModeBase): boolean {\n return this.options.verbose || this.toolOutputExpanded;\n };\n"]}
1
+ {"version":3,"file":"interactive-startup.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-startup.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase, seedStartupInput } from \"./interactive-mode-base.ts\";\nimport { type Container, type MarkdownTheme, os, path, Markdown, Spacer, Text, spawn, APP_NAME, APP_TITLE, ENV_OFFLINE, getEnvValue, getAgentDir, VERSION, formatCodexFastModeModelLabel, shouldApplyCodexFastMode, DefaultPackageManager, isInstallTelemetryEnabled, getChangelogPath, getEntriesForVersion, getNewEntries, normalizeChangelogLinks, parseChangelog, getCwdRelativePath, getPiUserAgent, recordTimeSinceReset, ensureTool, checkForNewPiVersion, renderAtomicAnsiBanner, DynamicBorder, getMarkdownTheme, onThemeChange, theme } from \"./interactive-mode-deps.ts\";\nimport { ExpandableText } from \"./interactive-mode-helpers.ts\";\nimport { ONBOARDING_COPY } from \"./interactive-onboarding.ts\";\n\nfunction prepareStartupNotices(mode: InteractiveModeBase): void {\n if (mode.startupNoticesPrepared) return;\n mode.startupNoticesPrepared = true;\n mode.hadLastChangelogVersionAtStartup = Boolean(mode.settingsManager.getLastChangelogVersion?.());\n if (mode.changelogMarkdown === undefined) {\n mode.changelogMarkdown = mode.getChangelogForDisplay?.();\n }\n mode.initializeFirstRunOnboardingMarkers?.();\n if (!mode.firstRunNoticeVisible) {\n mode.firstRunNoticeVisible = mode.isFirstRunOnboardingEligible?.() ?? false;\n }\n }\n\nInteractiveModeBase.prototype.showStartupNoticesIfNeeded = function(this: InteractiveModeBase, targetContainer: Container = this.chatContainer): void {\n if (this.startupNoticesShown) {\n return;\n }\n prepareStartupNotices(this);\n this.startupNoticesShown = true;\n\n const changelogMarkdown = this.changelogMarkdown;\n if (!changelogMarkdown && !this.firstRunNoticeVisible) {\n return;\n }\n\n if (changelogMarkdown) {\n if (targetContainer.children.length > 0) {\n targetContainer.addChild(new Spacer(1));\n }\n targetContainer.addChild(new DynamicBorder());\n if (this.settingsManager.getCollapseChangelog()) {\n const versionMatch = changelogMarkdown.match(\n /##\\s+\\[?((?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-(?:alpha\\.)?(?:0|[1-9]\\d*))?)\\]?/,\n );\n const latestVersion = versionMatch ? versionMatch[1] : this.version;\n const condensedText = `Updated to v${latestVersion}. Use ${theme.bold(\"/changelog\")} to view full changelog.`;\n targetContainer.addChild(new Text(condensedText, 1, 0));\n } else {\n targetContainer.addChild(\n new Text(theme.bold(theme.fg(\"accent\", \"What's New\")), 1, 0),\n );\n targetContainer.addChild(new Spacer(1));\n targetContainer.addChild(\n new Markdown(\n changelogMarkdown.trim(),\n 1,\n 0,\n this.getMarkdownThemeWithSettings(),\n ),\n );\n targetContainer.addChild(new Spacer(1));\n }\n targetContainer.addChild(new DynamicBorder());\n }\n\n if (this.firstRunNoticeVisible) {\n this.firstRunOnboardingNoticeComponents = [];\n if (targetContainer.children.length > 0) {\n this.firstRunOnboardingNoticeComponents.push(new Spacer(1));\n }\n this.firstRunOnboardingNoticeComponents.push(\n new DynamicBorder(),\n new Text(ONBOARDING_COPY, 1, 0),\n new DynamicBorder(),\n new Spacer(1),\n );\n for (const component of this.firstRunOnboardingNoticeComponents) {\n targetContainer.addChild(component);\n }\n // Mark completion only after queueing the notice in the chat canvas so\n // launches that skip rendering retry the first-run notice next time.\n this.settingsManager.setOnboardedVersion(this.version);\n }\n\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.init = async function(this: InteractiveModeBase): Promise<void> {\n if (this.isInitialized) return;\n\n this.registerSignalHandlers();\n\n // Changelog and first-run onboarding are prepared lazily after first paint.\n\n // Add header container as first child. Populate it after theme initialization.\n this.ui.addChild(this.headerContainer);\n\n this.ui.addChild(this.chatContainer);\n this.ui.addChild(this.pendingMessagesContainer);\n this.ui.addChild(this.statusContainer);\n this.renderWidgets(); // Initialize with default spacer\n this.ui.addChild(this.widgetContainerAbove);\n this.ui.addChild(this.usageMeter);\n this.ui.addChild(this.editorContainer);\n // Footer (persistent model + cwd identity) stays pinned directly under the\n // editor; below-editor widgets render after it, at the very bottom. This\n // keeps the session identity line attached to the input and places\n // transient run status (e.g. the workflow companion counter) beneath it.\n // Rendering below-editor widgets last also keeps a live widget at the\n // absolute bottom of the buffer (always within the viewport), so its\n // per-tick updates never sit above the fold — preserving the #1109\n // resize-flicker fix.\n this.ui.addChild(this.footer);\n this.ui.addChild(this.widgetContainerBelow);\n this.ui.setFocus(this.editor);\n\n this.setupKeyHandlers();\n this.setupEditorSubmitHandler();\n\n seedStartupInput(\n this.pendingUserInputs,\n this.defaultEditor,\n this.options.startupInputCapture?.consume(),\n this.startupReplayInputs,\n (text) => {\n this.startupDraftText = text;\n },\n (text) => {\n this.startupReplayActiveInput = text;\n },\n );\n\n // Start UI before extension/session work; fd/rg readiness and git watching move after first paint.\n this.ui.start();\n recordTimeSinceReset(\"time-to-first-frame\");\n this.footerDataProvider.onBranchChange(() => {\n this.ui.requestRender();\n });\n this.isInitialized = true;\n\n await this.themeController.applyFromSettings();\n\n // Add the quiet startup identity unless silenced.\n if (this.options.verbose || !this.settingsManager.getQuietStartup()) {\n this.builtInHeader = new ExpandableText(\n () => this.getStartupIdentityText(),\n () => this.getStartupIdentityText(),\n this.getStartupExpansionState(),\n 1,\n 0,\n );\n\n this.headerContainer.addChild(new Spacer(1));\n this.headerContainer.addChild(this.builtInHeader);\n this.headerContainer.addChild(new Spacer(1));\n } else {\n // Minimal header when silenced\n this.builtInHeader = new Text(\"\", 0, 0);\n this.headerContainer.addChild(this.builtInHeader);\n }\n this.ui.requestRender();\n\n void Promise.all([ensureTool(\"fd\"), ensureTool(\"rg\")])\n .then(([fdPath]) => {\n this.fdPath = fdPath;\n this.setupAutocompleteProvider();\n })\n .catch((error) => {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`Tool readiness check failed: ${message}`);\n });\n\n // When startup resources are deferred, keep the already-painted editor responsive.\n // Extension UI bindings are installed at the deferred reload boundary, not here,\n // so no post-paint resource work can block visible typing.\n if (this.deferredStartupPending) {\n this.applyRuntimeSettings();\n this.subscribeToAgent();\n this.updateEditorBorderColor();\n this.updateTerminalTitle();\n } else {\n await this.rebindCurrentSession();\n }\n\n this.attachStartupNoticesContainer();\n // Render initial messages AFTER the initial session binding is in place.\n this.renderInitialMessages();\n // Set up theme file watcher\n onThemeChange(() => {\n this.ui.invalidate();\n this.updateEditorBorderColor();\n this.ui.requestRender();\n });\n\n // Initialize available provider count for footer display without delaying first-frame startup.\n void this.updateAvailableProviderCount().catch((error) => {\n const message = error instanceof Error ? error.message : String(error);\n console.error(`Failed to update provider count: ${message}`);\n });\n };\n\nInteractiveModeBase.prototype.updateTerminalTitle = function(this: InteractiveModeBase): void {\n const cwdBasename = path.basename(this.sessionManager.getCwd());\n const sessionName = this.sessionManager.getSessionName();\n if (sessionName) {\n this.ui.terminal.setTitle(\n `${APP_TITLE} - ${sessionName} - ${cwdBasename}`,\n );\n } else {\n this.ui.terminal.setTitle(`${APP_TITLE} - ${cwdBasename}`);\n }\n };\n\nInteractiveModeBase.prototype.run = async function(this: InteractiveModeBase): Promise<void> {\n await this.init();\n\n\tsetTimeout(() => {\n\t\tvoid this.refreshCopilotModelCatalog();\n const startupNoticesContainer = this.startupNoticesContainer;\n\t\tcheckForNewPiVersion(this.version).then((newVersion) => {\n\t\t\tif (newVersion) this.showNewVersionNotification(newVersion, startupNoticesContainer);\n\t\t});\n\t\tthis.checkForPackageUpdates().then((updates) => {\n\t\t\tif (updates.length > 0) this.showPackageUpdateNotification(updates, startupNoticesContainer);\n\t\t});\n\t\tthis.checkTmuxKeyboardSetup().then((warning) => {\n\t\t\tif (warning) this.showWarning(warning, startupNoticesContainer);\n\t\t});\n\t\t// When startup is deferred, the RESOURCES disclosure renders after the\n\t\t// deferred extension load; hold the subscription warning until then so\n\t\t// the disclosure always appears first.\n\t\tif (!this.deferredStartupPending && !this.deferredStartupPromise && !this.pendingLoadedResourcesDisclosure) {\n\t\t\tvoid this.maybeWarnAboutAnthropicSubscriptionAuth(undefined, startupNoticesContainer);\n\t\t}\n\t}, 500);\n\n // Show startup warnings\n const {\n migratedProviders,\n modelFallbackMessage,\n initialMessage,\n initialImages,\n initialMessages,\n } = this.options;\n\n if (migratedProviders && migratedProviders.length > 0) {\n this.showWarning(\n `Migrated credentials to auth.json: ${migratedProviders.join(\", \")}`,\n );\n }\n\n const modelsJsonError = this.session.modelRegistry.getError();\n if (modelsJsonError) {\n this.showError(`models.json error: ${modelsJsonError}`);\n }\n\n if (modelFallbackMessage && !this.deferredStartupPending) {\n this.showWarning(modelFallbackMessage, this.startupNoticesContainer);\n }\n\n // CLI-provided startup prompts need extension tools/resources; wait before sending them,\n // but do not block the normal no-prompt input loop from becoming ready.\n if (this.deferredStartupPending && (initialMessage || (initialMessages && initialMessages.length > 0))) {\n await this.ensureDeferredStartupComplete();\n }\n\n // Process initial messages\n if (initialMessage) {\n try {\n await this.session.prompt(initialMessage, { images: initialImages });\n } catch (error: unknown) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error occurred\";\n this.showError(errorMessage);\n }\n }\n\n if (initialMessages) {\n for (const message of initialMessages) {\n try {\n await this.session.prompt(message);\n } catch (error: unknown) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error occurred\";\n this.showError(errorMessage);\n }\n }\n }\n\n // Main interactive loop\n while (true) {\n const userInput = await this.getUserInput();\n await this.runUserPromptTurn(userInput);\n }\n };\n\nInteractiveModeBase.prototype.checkForPackageUpdates = async function(this: InteractiveModeBase): Promise<string[]> {\n if (getEnvValue(ENV_OFFLINE)) {\n return [];\n }\n\n try {\n const packageManager = new DefaultPackageManager({\n cwd: this.sessionManager.getCwd(),\n agentDir: getAgentDir(),\n settingsManager: this.settingsManager,\n });\n const updates = await packageManager.checkForAvailableUpdates();\n return updates.map((update) => update.displayName);\n } catch {\n return [];\n }\n };\n\nInteractiveModeBase.prototype.checkTmuxKeyboardSetup = async function(this: InteractiveModeBase): Promise<string | undefined> {\n if (!process.env.TMUX) return undefined;\n\n const runTmuxShow = (option: string): Promise<string | undefined> => {\n return new Promise((resolve) => {\n const proc = spawn(\"tmux\", [\"show\", \"-gv\", option], {\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n });\n let stdout = \"\";\n const timer = setTimeout(() => {\n proc.kill();\n resolve(undefined);\n }, 2000);\n\n proc.stdout?.on(\"data\", (data) => {\n stdout += data.toString();\n });\n proc.on(\"error\", () => {\n clearTimeout(timer);\n resolve(undefined);\n });\n proc.on(\"close\", (code) => {\n clearTimeout(timer);\n resolve(code === 0 ? stdout.trim() : undefined);\n });\n });\n };\n\n const [extendedKeys, extendedKeysFormat] = await Promise.all([\n runTmuxShow(\"extended-keys\"),\n runTmuxShow(\"extended-keys-format\"),\n ]);\n\n // If we couldn't query tmux (timeout, sandbox, etc.), don't warn\n if (extendedKeys === undefined) return undefined;\n\n if (extendedKeys !== \"on\" && extendedKeys !== \"always\") {\n return \"tmux extended-keys is off. Modified enter keys may not work. Add `set -g extended-keys on` to ~/.tmux.conf and restart tmux.\";\n }\n\n if (extendedKeysFormat === \"xterm\") {\n return \"tmux extended-keys-format is xterm. Pi works best with csi-u. Add `set -g extended-keys-format csi-u` to ~/.tmux.conf and restart tmux.\";\n }\n\n return undefined;\n };\n\nInteractiveModeBase.prototype.getChangelogForDisplay = function(this: InteractiveModeBase): string | undefined {\n // Skip changelog for resumed/continued sessions (already have messages)\n if (this.session.state.messages.length > 0) {\n return undefined;\n }\n\n const lastVersion = this.settingsManager.getLastChangelogVersion();\n const changelogPath = getChangelogPath();\n const entries = parseChangelog(changelogPath);\n\n if (!lastVersion) {\n // Fresh install - record the version, send telemetry, don't show changelog\n this.settingsManager.setLastChangelogVersion(VERSION);\n this.reportInstallTelemetry(VERSION);\n return undefined;\n }\n\n const newEntries = getNewEntries(entries, lastVersion, VERSION);\n const currentEntries = getEntriesForVersion(newEntries, VERSION);\n if (currentEntries.length > 0) {\n this.settingsManager.setLastChangelogVersion(VERSION);\n this.reportInstallTelemetry(VERSION);\n return currentEntries.map((e) => normalizeChangelogLinks(e.content, e)).join(\"\\n\\n\");\n }\n\n return undefined;\n };\n\nInteractiveModeBase.prototype.reportInstallTelemetry = function(this: InteractiveModeBase, version: string): void {\n if (getEnvValue(ENV_OFFLINE)) {\n return;\n }\n\n if (!isInstallTelemetryEnabled(this.settingsManager)) {\n return;\n }\n\n void fetch(\n `https://pi.dev/api/report-install?version=${encodeURIComponent(version)}`,\n {\n headers: {\n \"User-Agent\": getPiUserAgent(version),\n },\n signal: AbortSignal.timeout(5000),\n },\n )\n .then(() => undefined)\n .catch(() => undefined);\n };\n\nInteractiveModeBase.prototype.getMarkdownThemeWithSettings = function(this: InteractiveModeBase): MarkdownTheme {\n return {\n ...getMarkdownTheme(),\n codeBlockIndent: this.settingsManager.getCodeBlockIndent(),\n };\n };\n\nInteractiveModeBase.prototype.formatDisplayPath = function(this: InteractiveModeBase, p: string): string {\n const home = os.homedir();\n let result = p;\n\n // Replace home directory with ~\n if (result.startsWith(home)) {\n result = `~${result.slice(home.length)}`;\n }\n\n return result;\n };\n\nInteractiveModeBase.prototype.formatExtensionDisplayPath = function(this: InteractiveModeBase, path: string): string {\n let result = this.formatDisplayPath(path);\n result = result.replace(/\\/index\\.ts$/, \"\").replace(/\\/index\\.js$/, \"\");\n return result;\n };\n\nInteractiveModeBase.prototype.formatContextPath = function(this: InteractiveModeBase, p: string): string {\n const cwd = path.resolve(this.sessionManager.getCwd());\n const absolutePath = path.isAbsolute(p)\n ? path.resolve(p)\n : path.resolve(cwd, p);\n const relativePath = getCwdRelativePath(absolutePath, cwd);\n if (relativePath !== undefined) {\n return relativePath;\n }\n\n return this.formatDisplayPath(absolutePath);\n };\n\nInteractiveModeBase.prototype.getStartupModelLabel = function(this: InteractiveModeBase): string {\n const model = this.session.state.model;\n let modelLabel = model?.id ?? \"no-model\";\n\n if (model?.reasoning) {\n modelLabel = `${modelLabel} ${this.session.thinkingLevel || \"off\"}`;\n }\n\n if (!model) {\n return modelLabel;\n }\n\n const fastModeEnabled = shouldApplyCodexFastMode(\n model,\n this.session.settingsManager.getCodexFastModeSettings(),\n this.session.orchestrationContext,\n );\n return formatCodexFastModeModelLabel(modelLabel, fastModeEnabled);\n };\n\nInteractiveModeBase.prototype.getStartupIdentityText = function(this: InteractiveModeBase): string {\n const appLabel = APP_NAME.length > 0\n ? `${APP_NAME[0]!.toUpperCase()}${APP_NAME.slice(1)}`\n : \"Atomic\";\n const title = `${theme.bold(theme.fg(\"text\", appLabel))} ${theme.fg(\"muted\", `v${this.version}`)}`;\n const model = this.session.state.model;\n const provider = model ? theme.fg(\"dim\", `(${model.provider})`) : theme.fg(\"dim\", \"(no-provider)\");\n const modelLine = `${provider} ${theme.fg(\"muted\", this.getStartupModelLabel())}`;\n const cwd = theme.fg(\"muted\", this.formatDisplayPath(this.sessionManager.getCwd()));\n const metaLines = [title, modelLine, cwd];\n const markLines = this.getAtomicAnsiMarkLines();\n\n return markLines\n .map((line, index) => `${line} ${metaLines[index] ?? \"\"}`.trimEnd())\n .join(\"\\n\");\n };\n\nInteractiveModeBase.prototype.getAtomicAnsiMarkLines = function(this: InteractiveModeBase): string[] {\n return renderAtomicAnsiBanner(theme, this.session.thinkingLevel || \"off\");\n };\n\nInteractiveModeBase.prototype.getStartupExpansionState = function(this: InteractiveModeBase): boolean {\n return this.options.verbose || this.toolOutputExpanded;\n };\n"]}
@@ -2,10 +2,24 @@ import { InteractiveModeBase, seedStartupInput } from "./interactive-mode-base.j
2
2
  import { os, path, Markdown, Spacer, Text, spawn, APP_NAME, APP_TITLE, ENV_OFFLINE, getEnvValue, getAgentDir, VERSION, formatCodexFastModeModelLabel, shouldApplyCodexFastMode, DefaultPackageManager, isInstallTelemetryEnabled, getChangelogPath, getEntriesForVersion, getNewEntries, normalizeChangelogLinks, parseChangelog, getCwdRelativePath, getPiUserAgent, recordTimeSinceReset, ensureTool, checkForNewPiVersion, renderAtomicAnsiBanner, DynamicBorder, getMarkdownTheme, onThemeChange, theme } from "./interactive-mode-deps.js";
3
3
  import { ExpandableText } from "./interactive-mode-helpers.js";
4
4
  import { ONBOARDING_COPY } from "./interactive-onboarding.js";
5
+ function prepareStartupNotices(mode) {
6
+ if (mode.startupNoticesPrepared)
7
+ return;
8
+ mode.startupNoticesPrepared = true;
9
+ mode.hadLastChangelogVersionAtStartup = Boolean(mode.settingsManager.getLastChangelogVersion?.());
10
+ if (mode.changelogMarkdown === undefined) {
11
+ mode.changelogMarkdown = mode.getChangelogForDisplay?.();
12
+ }
13
+ mode.initializeFirstRunOnboardingMarkers?.();
14
+ if (!mode.firstRunNoticeVisible) {
15
+ mode.firstRunNoticeVisible = mode.isFirstRunOnboardingEligible?.() ?? false;
16
+ }
17
+ }
5
18
  InteractiveModeBase.prototype.showStartupNoticesIfNeeded = function (targetContainer = this.chatContainer) {
6
19
  if (this.startupNoticesShown) {
7
20
  return;
8
21
  }
22
+ prepareStartupNotices(this);
9
23
  this.startupNoticesShown = true;
10
24
  const changelogMarkdown = this.changelogMarkdown;
11
25
  if (!changelogMarkdown && !this.firstRunNoticeVisible) {
@@ -49,10 +63,7 @@ InteractiveModeBase.prototype.init = async function () {
49
63
  if (this.isInitialized)
50
64
  return;
51
65
  this.registerSignalHandlers();
52
- // Load changelog (only show new entries, skip for resumed sessions)
53
- this.hadLastChangelogVersionAtStartup = Boolean(this.settingsManager.getLastChangelogVersion());
54
- this.changelogMarkdown = this.getChangelogForDisplay();
55
- this.initializeFirstRunOnboardingMarkers();
66
+ // Changelog and first-run onboarding are prepared lazily after first paint.
56
67
  // Add header container as first child. Populate it after theme initialization.
57
68
  this.ui.addChild(this.headerContainer);
58
69
  this.ui.addChild(this.chatContainer);
@@ -75,21 +86,20 @@ InteractiveModeBase.prototype.init = async function () {
75
86
  this.ui.setFocus(this.editor);
76
87
  this.setupKeyHandlers();
77
88
  this.setupEditorSubmitHandler();
78
- this.firstRunNoticeVisible = this.isFirstRunOnboardingEligible();
79
89
  seedStartupInput(this.pendingUserInputs, this.defaultEditor, this.options.startupInputCapture?.consume(), this.startupReplayInputs, (text) => {
80
90
  this.startupDraftText = text;
81
91
  }, (text) => {
82
92
  this.startupReplayActiveInput = text;
83
93
  });
84
- // Start the UI before initializing extensions so session_start handlers can use interactive dialogs.
85
- // fd/rg readiness is intentionally checked after first paint because ensureTool may spawn
86
- // or download tools on cold machines.
94
+ // Start UI before extension/session work; fd/rg readiness and git watching move after first paint.
87
95
  this.ui.start();
88
96
  recordTimeSinceReset("time-to-first-frame");
97
+ this.footerDataProvider.onBranchChange(() => {
98
+ this.ui.requestRender();
99
+ });
89
100
  this.isInitialized = true;
90
101
  await this.themeController.applyFromSettings();
91
- // Add the quiet startup identity (unless silenced). Resource details are
92
- // disclosed separately in the chat canvas via the tools/resources toggle.
102
+ // Add the quiet startup identity unless silenced.
93
103
  if (this.options.verbose || !this.settingsManager.getQuietStartup()) {
94
104
  this.builtInHeader = new ExpandableText(() => this.getStartupIdentityText(), () => this.getStartupIdentityText(), this.getStartupExpansionState(), 1, 0);
95
105
  this.headerContainer.addChild(new Spacer(1));
@@ -126,23 +136,12 @@ InteractiveModeBase.prototype.init = async function () {
126
136
  this.attachStartupNoticesContainer();
127
137
  // Render initial messages AFTER the initial session binding is in place.
128
138
  this.renderInitialMessages();
129
- if (this.deferredStartupPending) {
130
- setTimeout(() => {
131
- if (!this.deferredStartupPending || this.deferredStartupPromise)
132
- return;
133
- void this.ensureDeferredStartupComplete();
134
- }, 2000);
135
- }
136
139
  // Set up theme file watcher
137
140
  onThemeChange(() => {
138
141
  this.ui.invalidate();
139
142
  this.updateEditorBorderColor();
140
143
  this.ui.requestRender();
141
144
  });
142
- // Set up git branch watcher (uses provider instead of footer)
143
- this.footerDataProvider.onBranchChange(() => {
144
- this.ui.requestRender();
145
- });
146
145
  // Initialize available provider count for footer display without delaying first-frame startup.
147
146
  void this.updateAvailableProviderCount().catch((error) => {
148
147
  const message = error instanceof Error ? error.message : String(error);