@bastani/atomic 0.9.5-alpha.5 → 0.9.5-alpha.7

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 (216) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/builtin/cursor/package.json +2 -2
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/mcp/package.json +1 -1
  5. package/dist/builtin/subagents/package.json +1 -1
  6. package/dist/builtin/web-access/package.json +1 -1
  7. package/dist/builtin/workflows/CHANGELOG.md +6 -0
  8. package/dist/builtin/workflows/package.json +1 -1
  9. package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +8 -0
  10. package/dist/builtin/workflows/src/runs/foreground/stage-control-registry.ts +2 -0
  11. package/dist/builtin/workflows/src/runs/foreground/stage-tool-execution-buffer.ts +47 -0
  12. package/dist/builtin/workflows/src/tui/stage-chat-view-pending-tools.ts +9 -0
  13. package/dist/builtin/workflows/src/tui/stage-chat-view-render-settings.ts +27 -0
  14. package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +5 -6
  15. package/dist/bun/split-loader.d.ts +2 -0
  16. package/dist/bun/split-loader.d.ts.map +1 -0
  17. package/dist/bun/split-loader.js +37 -0
  18. package/dist/bun/split-loader.js.map +1 -0
  19. package/dist/config.d.ts.map +1 -1
  20. package/dist/config.js +6 -4
  21. package/dist/config.js.map +1 -1
  22. package/dist/core/agent-session-auto-compaction.d.ts +5 -4
  23. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  24. package/dist/core/agent-session-auto-compaction.js +15 -9
  25. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  26. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  27. package/dist/core/agent-session-extension-bindings.js +1 -1
  28. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  29. package/dist/core/agent-session-methods.d.ts +1 -1
  30. package/dist/core/agent-session-methods.d.ts.map +1 -1
  31. package/dist/core/agent-session-methods.js.map +1 -1
  32. package/dist/core/builtin-packages.d.ts.map +1 -1
  33. package/dist/core/builtin-packages.js +8 -4
  34. package/dist/core/builtin-packages.js.map +1 -1
  35. package/dist/core/copilot-model-catalog.d.ts.map +1 -1
  36. package/dist/core/copilot-model-catalog.js +3 -2
  37. package/dist/core/copilot-model-catalog.js.map +1 -1
  38. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  39. package/dist/core/extensions/loader-core.js +6 -0
  40. package/dist/core/extensions/loader-core.js.map +1 -1
  41. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  42. package/dist/core/extensions/loader-virtual-modules.js +8 -3
  43. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  44. package/dist/core/model-resolver-scope.d.ts +9 -0
  45. package/dist/core/model-resolver-scope.d.ts.map +1 -1
  46. package/dist/core/model-resolver-scope.js +12 -4
  47. package/dist/core/model-resolver-scope.js.map +1 -1
  48. package/dist/core/model-resolver.d.ts +3 -2
  49. package/dist/core/model-resolver.d.ts.map +1 -1
  50. package/dist/core/model-resolver.js +1 -1
  51. package/dist/core/model-resolver.js.map +1 -1
  52. package/dist/core/openai-responses-payload-sanitizer.d.ts +6 -0
  53. package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -0
  54. package/dist/core/openai-responses-payload-sanitizer.js +59 -0
  55. package/dist/core/openai-responses-payload-sanitizer.js.map +1 -0
  56. package/dist/core/package-manager-auto-resources.d.ts +2 -2
  57. package/dist/core/package-manager-auto-resources.d.ts.map +1 -1
  58. package/dist/core/package-manager-auto-resources.js +32 -52
  59. package/dist/core/package-manager-auto-resources.js.map +1 -1
  60. package/dist/core/package-manager-resolver.d.ts.map +1 -1
  61. package/dist/core/package-manager-resolver.js +23 -14
  62. package/dist/core/package-manager-resolver.js.map +1 -1
  63. package/dist/core/package-manager-resource-collector.d.ts +3 -3
  64. package/dist/core/package-manager-resource-collector.d.ts.map +1 -1
  65. package/dist/core/package-manager-resource-collector.js +76 -73
  66. package/dist/core/package-manager-resource-collector.js.map +1 -1
  67. package/dist/core/package-manager-resource-files.d.ts +9 -8
  68. package/dist/core/package-manager-resource-files.d.ts.map +1 -1
  69. package/dist/core/package-manager-resource-files.js +92 -81
  70. package/dist/core/package-manager-resource-files.js.map +1 -1
  71. package/dist/core/prompt-templates-async.d.ts +3 -0
  72. package/dist/core/prompt-templates-async.d.ts.map +1 -0
  73. package/dist/core/prompt-templates-async.js +118 -0
  74. package/dist/core/prompt-templates-async.js.map +1 -0
  75. package/dist/core/provider-context-usage.d.ts +11 -0
  76. package/dist/core/provider-context-usage.d.ts.map +1 -0
  77. package/dist/core/provider-context-usage.js +58 -0
  78. package/dist/core/provider-context-usage.js.map +1 -0
  79. package/dist/core/resource-loader-assets.d.ts +3 -3
  80. package/dist/core/resource-loader-assets.d.ts.map +1 -1
  81. package/dist/core/resource-loader-assets.js +66 -83
  82. package/dist/core/resource-loader-assets.js.map +1 -1
  83. package/dist/core/resource-loader-core.d.ts +1 -1
  84. package/dist/core/resource-loader-core.d.ts.map +1 -1
  85. package/dist/core/resource-loader-core.js +5 -5
  86. package/dist/core/resource-loader-core.js.map +1 -1
  87. package/dist/core/resource-loader-extensions.d.ts.map +1 -1
  88. package/dist/core/resource-loader-extensions.js +4 -0
  89. package/dist/core/resource-loader-extensions.js.map +1 -1
  90. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  91. package/dist/core/resource-loader-reload.js +54 -7
  92. package/dist/core/resource-loader-reload.js.map +1 -1
  93. package/dist/core/resource-loader-types.d.ts +7 -1
  94. package/dist/core/resource-loader-types.d.ts.map +1 -1
  95. package/dist/core/resource-loader-types.js.map +1 -1
  96. package/dist/core/sdk.d.ts.map +1 -1
  97. package/dist/core/sdk.js +6 -4
  98. package/dist/core/sdk.js.map +1 -1
  99. package/dist/core/settings-manager-core.d.ts.map +1 -1
  100. package/dist/core/settings-manager-core.js +3 -2
  101. package/dist/core/settings-manager-core.js.map +1 -1
  102. package/dist/core/settings-storage.d.ts.map +1 -1
  103. package/dist/core/settings-storage.js +2 -1
  104. package/dist/core/settings-storage.js.map +1 -1
  105. package/dist/core/skills-async.d.ts +3 -0
  106. package/dist/core/skills-async.d.ts.map +1 -0
  107. package/dist/core/skills-async.js +269 -0
  108. package/dist/core/skills-async.js.map +1 -0
  109. package/dist/core/trust-manager.d.ts +9 -0
  110. package/dist/core/trust-manager.d.ts.map +1 -1
  111. package/dist/core/trust-manager.js +44 -2
  112. package/dist/core/trust-manager.js.map +1 -1
  113. package/dist/index.d.ts +1 -1
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js +1 -1
  116. package/dist/index.js.map +1 -1
  117. package/dist/main-deferred-startup.d.ts +21 -0
  118. package/dist/main-deferred-startup.d.ts.map +1 -0
  119. package/dist/main-deferred-startup.js +23 -0
  120. package/dist/main-deferred-startup.js.map +1 -0
  121. package/dist/main.d.ts.map +1 -1
  122. package/dist/main.js +28 -26
  123. package/dist/main.js.map +1 -1
  124. package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
  125. package/dist/modes/interactive/interactive-agent-events.js +10 -1
  126. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  127. package/dist/modes/interactive/interactive-deferred-startup.d.ts +8 -1
  128. package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
  129. package/dist/modes/interactive/interactive-deferred-startup.js +58 -11
  130. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  131. package/dist/modes/interactive/interactive-editor-actions.d.ts.map +1 -1
  132. package/dist/modes/interactive/interactive-editor-actions.js +13 -13
  133. package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
  134. package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
  135. package/dist/modes/interactive/interactive-extension-runtime.js +16 -0
  136. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  137. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  138. package/dist/modes/interactive/interactive-input-handling.js +48 -0
  139. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  140. package/dist/modes/interactive/interactive-mode-base.d.ts +5 -0
  141. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  142. package/dist/modes/interactive/interactive-mode-base.js +5 -0
  143. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  144. package/dist/modes/interactive/interactive-mode-deps.d.ts +2 -2
  145. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  146. package/dist/modes/interactive/interactive-mode-deps.js +2 -2
  147. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  148. package/dist/modes/interactive/interactive-mode-surface.d.ts +18 -6
  149. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  150. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  151. package/dist/modes/interactive/interactive-mode-types.d.ts +5 -1
  152. package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
  153. package/dist/modes/interactive/interactive-mode-types.js.map +1 -1
  154. package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
  155. package/dist/modes/interactive/interactive-model-routing.js +3 -3
  156. package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
  157. package/dist/modes/interactive/interactive-onboarding.d.ts.map +1 -1
  158. package/dist/modes/interactive/interactive-onboarding.js +1 -0
  159. package/dist/modes/interactive/interactive-onboarding.js.map +1 -1
  160. package/dist/modes/interactive/interactive-process-lifecycle.d.ts.map +1 -1
  161. package/dist/modes/interactive/interactive-process-lifecycle.js +43 -6
  162. package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
  163. package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
  164. package/dist/modes/interactive/interactive-render-chat.js +57 -0
  165. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  166. package/dist/modes/interactive/interactive-resource-disclosure.d.ts.map +1 -1
  167. package/dist/modes/interactive/interactive-resource-disclosure.js +3 -2
  168. package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
  169. package/dist/modes/interactive/interactive-resource-rendering.d.ts.map +1 -1
  170. package/dist/modes/interactive/interactive-resource-rendering.js +10 -8
  171. package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
  172. package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
  173. package/dist/modes/interactive/interactive-session-routing.js +2 -2
  174. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  175. package/dist/modes/interactive/interactive-session-runtime.d.ts.map +1 -1
  176. package/dist/modes/interactive/interactive-session-runtime.js +1 -1
  177. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  178. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  179. package/dist/modes/interactive/interactive-startup.js +59 -52
  180. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  181. package/dist/modes/interactive/theme/theme-loading.d.ts +1 -0
  182. package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -1
  183. package/dist/modes/interactive/theme/theme-loading.js +3 -0
  184. package/dist/modes/interactive/theme/theme-loading.js.map +1 -1
  185. package/dist/modes/interactive/theme/theme.d.ts +1 -1
  186. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  187. package/dist/modes/interactive/theme/theme.js +1 -1
  188. package/dist/modes/interactive/theme/theme.js.map +1 -1
  189. package/dist/utils/child-process.d.ts +8 -1
  190. package/dist/utils/child-process.d.ts.map +1 -1
  191. package/dist/utils/child-process.js +39 -6
  192. package/dist/utils/child-process.js.map +1 -1
  193. package/dist/utils/event-loop.d.ts +7 -0
  194. package/dist/utils/event-loop.d.ts.map +1 -0
  195. package/dist/utils/event-loop.js +14 -0
  196. package/dist/utils/event-loop.js.map +1 -0
  197. package/dist/utils/json.d.ts +4 -0
  198. package/dist/utils/json.d.ts.map +1 -1
  199. package/dist/utils/json.js +8 -0
  200. package/dist/utils/json.js.map +1 -1
  201. package/dist/utils/module-require.d.ts +11 -0
  202. package/dist/utils/module-require.d.ts.map +1 -1
  203. package/dist/utils/module-require.js +14 -1
  204. package/dist/utils/module-require.js.map +1 -1
  205. package/dist/utils/split-launcher.d.ts +38 -0
  206. package/dist/utils/split-launcher.d.ts.map +1 -0
  207. package/dist/utils/split-launcher.js +63 -0
  208. package/dist/utils/split-launcher.js.map +1 -0
  209. package/docs/compaction.md +3 -0
  210. package/docs/keybindings.md +2 -2
  211. package/docs/providers.md +1 -1
  212. package/docs/settings.md +5 -1
  213. package/docs/usage.md +1 -1
  214. package/docs/workflows.md +1 -1
  215. package/npm-shrinkwrap.json +23 -23
  216. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-deferred-startup.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-deferred-startup.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { recordTimeSinceReset, resolveSavedModelReference, setRegisteredThemes, Text, theme } from \"./interactive-mode-deps.ts\";\n\n/**\n * Finishes a startup where extension loading was deferred so the TUI could\n * paint immediately. Loads extension code via session.reload(), then applies\n * the same post-load UI wiring as /reload and discloses loaded resources.\n */\nInteractiveModeBase.prototype.completeDeferredStartup = async function(this: InteractiveModeBase): Promise<void> {\n const loadingIndicator = new Text(theme.fg(\"dim\", \"Loading extensions, skills, prompts, themes...\"), 1, 0);\n this.chatContainer.addChild(loadingIndicator);\n this.ui.requestRender();\n\n try {\n await this.session.reload({ reason: \"startup\" });\n } catch (error) {\n this.chatContainer.removeChild(loadingIndicator);\n this.deferredStartupPending = false;\n this.showError(\n `Extension loading failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n return;\n }\n\n this.chatContainer.removeChild(loadingIndicator);\n this.deferredStartupPending = false;\n recordTimeSinceReset(\"deferred-extension-load\");\n\n setRegisteredThemes(this.session.resourceLoader.getThemes().themes);\n await this.themeController.applyFromSettings();\n this.setupAutocompleteProvider();\n this.setupExtensionShortcuts(this.session.extensionRunner);\n await this.retryDeferredModelRestore();\n this.showLoadedResources({ force: false, showDiagnosticsWhenQuiet: true });\n this.showStartupNoticesIfNeeded();\n\n const modelsJsonError = this.session.modelRegistry.getError();\n if (modelsJsonError) {\n this.showError(`models.json error: ${modelsJsonError}`);\n }\n void this.updateAvailableProviderCount().catch(() => {});\n this.updateEditorBorderColor();\n this.ui.requestRender();\n };\n\n/**\n * A session model saved with an extension-registered provider cannot resolve\n * until extensions load; retry the restore now and only surface the fallback\n * warning if it still fails.\n */\nInteractiveModeBase.prototype.retryDeferredModelRestore = async function(this: InteractiveModeBase): Promise<void> {\n const fallbackMessage = this.options.modelFallbackMessage;\n if (!fallbackMessage) {\n return;\n }\n const savedModel = this.sessionManager.buildSessionContext().model;\n if (savedModel) {\n const restoredModel = await resolveSavedModelReference(\n savedModel.provider,\n savedModel.modelId,\n this.session.modelRegistry,\n );\n if (restoredModel && this.session.modelRegistry.hasConfiguredAuth(restoredModel)) {\n await this.session.setModel(restoredModel);\n return;\n }\n }\n this.showWarning(fallbackMessage);\n };\n"]}
1
+ {"version":3,"file":"interactive-deferred-startup.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-deferred-startup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAIjE,MAAM,WAAW,mBAAmB;IAChC,sBAAsB,EAAE,OAAO,CAAC;IAChC,sBAAsB,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;IAClD,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAEH,wBAAsB,6BAA6B,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAI1F;AAqDH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCpF","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { modelsAreEqual } from \"@earendil-works/pi-ai/compat\";\nimport { type Container, recordTimeSinceReset, resolveModelScopeWithDiagnostics, resolveSavedModelReference, setRegisteredThemes } from \"./interactive-mode-deps.ts\";\n\nexport interface DeferredStartupMode {\n deferredStartupPending: boolean;\n deferredStartupPromise: Promise<void> | undefined;\n completeDeferredStartup(): Promise<void>;\n }\n\nexport async function ensureDeferredStartupComplete(mode: DeferredStartupMode): Promise<void> {\n if (!mode.deferredStartupPending && !mode.deferredStartupPromise) return;\n mode.deferredStartupPromise ??= mode.completeDeferredStartup();\n await mode.deferredStartupPromise;\n }\n\nInteractiveModeBase.prototype.ensureDeferredStartupComplete = async function(this: InteractiveModeBase): Promise<void> {\n await ensureDeferredStartupComplete(this);\n };\n\n/**\n * Finishes a startup where extension loading was deferred so the TUI could\n * paint immediately. Loads extension code via session.reload(), then applies\n * the same post-load UI wiring as /reload and discloses loaded resources.\n */\nInteractiveModeBase.prototype.completeDeferredStartup = async function(this: InteractiveModeBase): Promise<void> {\n\ttry {\n\t\tawait this.bindCurrentSessionExtensions();\n\t\tawait this.session.reload({ reason: \"startup\" });\n\t} catch (error) {\n\t\tthis.stopWorkingLoader();\n this.deferredStartupPending = false;\n this.showError(\n `Extension loading failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n // The RESOURCES disclosure will not render; surface the held warning.\n void this.maybeWarnAboutAnthropicSubscriptionAuth(undefined, this.startupNoticesContainer);\n return;\n }\n\n\tthis.stopWorkingLoader();\n\tthis.deferredStartupPending = false;\n recordTimeSinceReset(\"deferred-extension-load\");\n\n setRegisteredThemes(this.session.resourceLoader.getThemes().themes);\n await this.themeController.applyFromSettings();\n this.setupAutocompleteProvider();\n this.setupExtensionShortcuts(this.session.extensionRunner);\n await applyDeferredModelScope(this);\n await this.retryDeferredModelRestore(this.startupNoticesContainer);\n\tif (this.deferLoadedResourcesDisclosureUntilAgentEnd) {\n\t\tthis.pendingLoadedResourcesDisclosure = true;\n\t} else {\n\t\tthis.showLoadedResources({ force: true, showDiagnosticsWhenQuiet: true, targetContainer: this.startupNoticesContainer });\n\t\t// Keep the subscription warning after the RESOURCES disclosure.\n\t\tvoid this.maybeWarnAboutAnthropicSubscriptionAuth(undefined, this.startupNoticesContainer);\n\t}\n\tthis.showStartupNoticesIfNeeded(this.startupNoticesContainer);\n const modelsJsonError = this.session.modelRegistry.getError();\n if (modelsJsonError) {\n this.showError(`models.json error: ${modelsJsonError}`);\n }\n void this.updateAvailableProviderCount().catch(() => {});\n this.updateEditorBorderColor();\n this.ui.requestRender();\n };\n\nexport async function applyDeferredModelScope(mode: InteractiveModeBase): Promise<void> {\n const patterns = mode.options.deferredModelScopePatterns;\n if (!patterns || patterns.length === 0) {\n return;\n }\n\n const { scopedModels, diagnostics } = await resolveModelScopeWithDiagnostics(patterns, mode.session.modelRegistry);\n for (const diagnostic of diagnostics) {\n mode.showWarning(diagnostic.message);\n }\n mode.session.setScopedModels(scopedModels);\n\n if (mode.sessionManager.buildSessionContext().messages.length > 0 || scopedModels.length === 0) {\n return;\n }\n\n const currentModel = mode.session.model;\n if (currentModel && scopedModels.some((scoped) => modelsAreEqual(scoped.model, currentModel))) {\n return;\n }\n\n const savedProvider = mode.settingsManager.getDefaultProvider();\n const savedModelId = mode.settingsManager.getDefaultModel();\n const savedModel = savedProvider && savedModelId ? mode.session.modelRegistry.find(savedProvider, savedModelId) : undefined;\n const preferred = savedModel ? scopedModels.find((scoped) => modelsAreEqual(scoped.model, savedModel)) : undefined;\n const nextScopedModel = preferred ?? scopedModels[0];\n if (mode.session.modelRegistry.hasConfiguredAuth(nextScopedModel.model)) {\n await mode.session.setModel(nextScopedModel.model);\n if (nextScopedModel.thinkingLevel && !mode.options.deferredModelScopePreserveThinking) {\n mode.session.setThinkingLevel(nextScopedModel.thinkingLevel);\n }\n }\n }\n\n/**\n * A session model saved with an extension-registered provider cannot resolve\n * until extensions load; retry the restore now and only surface the fallback\n * warning if it still fails.\n */\nInteractiveModeBase.prototype.retryDeferredModelRestore = async function(this: InteractiveModeBase, targetContainer?: Container): Promise<void> {\n const fallbackMessage = this.options.modelFallbackMessage;\n if (!fallbackMessage) {\n return;\n }\n const savedModel = this.sessionManager.buildSessionContext().model;\n if (savedModel) {\n const restoredModel = await resolveSavedModelReference(\n savedModel.provider,\n savedModel.modelId,\n this.session.modelRegistry,\n );\n if (restoredModel && this.session.modelRegistry.hasConfiguredAuth(restoredModel)) {\n await this.session.setModel(restoredModel);\n return;\n }\n }\n this.showWarning(fallbackMessage, targetContainer);\n };\n"]}
@@ -1,33 +1,51 @@
1
1
  import { InteractiveModeBase } from "./interactive-mode-base.js";
2
- import { recordTimeSinceReset, resolveSavedModelReference, setRegisteredThemes, Text, theme } from "./interactive-mode-deps.js";
2
+ import { modelsAreEqual } from "@earendil-works/pi-ai/compat";
3
+ import { recordTimeSinceReset, resolveModelScopeWithDiagnostics, resolveSavedModelReference, setRegisteredThemes } from "./interactive-mode-deps.js";
4
+ export async function ensureDeferredStartupComplete(mode) {
5
+ if (!mode.deferredStartupPending && !mode.deferredStartupPromise)
6
+ return;
7
+ mode.deferredStartupPromise ??= mode.completeDeferredStartup();
8
+ await mode.deferredStartupPromise;
9
+ }
10
+ InteractiveModeBase.prototype.ensureDeferredStartupComplete = async function () {
11
+ await ensureDeferredStartupComplete(this);
12
+ };
3
13
  /**
4
14
  * Finishes a startup where extension loading was deferred so the TUI could
5
15
  * paint immediately. Loads extension code via session.reload(), then applies
6
16
  * the same post-load UI wiring as /reload and discloses loaded resources.
7
17
  */
8
18
  InteractiveModeBase.prototype.completeDeferredStartup = async function () {
9
- const loadingIndicator = new Text(theme.fg("dim", "Loading extensions, skills, prompts, themes..."), 1, 0);
10
- this.chatContainer.addChild(loadingIndicator);
11
- this.ui.requestRender();
12
19
  try {
20
+ await this.bindCurrentSessionExtensions();
13
21
  await this.session.reload({ reason: "startup" });
14
22
  }
15
23
  catch (error) {
16
- this.chatContainer.removeChild(loadingIndicator);
24
+ this.stopWorkingLoader();
17
25
  this.deferredStartupPending = false;
18
26
  this.showError(`Extension loading failed: ${error instanceof Error ? error.message : String(error)}`);
27
+ // The RESOURCES disclosure will not render; surface the held warning.
28
+ void this.maybeWarnAboutAnthropicSubscriptionAuth(undefined, this.startupNoticesContainer);
19
29
  return;
20
30
  }
21
- this.chatContainer.removeChild(loadingIndicator);
31
+ this.stopWorkingLoader();
22
32
  this.deferredStartupPending = false;
23
33
  recordTimeSinceReset("deferred-extension-load");
24
34
  setRegisteredThemes(this.session.resourceLoader.getThemes().themes);
25
35
  await this.themeController.applyFromSettings();
26
36
  this.setupAutocompleteProvider();
27
37
  this.setupExtensionShortcuts(this.session.extensionRunner);
28
- await this.retryDeferredModelRestore();
29
- this.showLoadedResources({ force: false, showDiagnosticsWhenQuiet: true });
30
- this.showStartupNoticesIfNeeded();
38
+ await applyDeferredModelScope(this);
39
+ await this.retryDeferredModelRestore(this.startupNoticesContainer);
40
+ if (this.deferLoadedResourcesDisclosureUntilAgentEnd) {
41
+ this.pendingLoadedResourcesDisclosure = true;
42
+ }
43
+ else {
44
+ this.showLoadedResources({ force: true, showDiagnosticsWhenQuiet: true, targetContainer: this.startupNoticesContainer });
45
+ // Keep the subscription warning after the RESOURCES disclosure.
46
+ void this.maybeWarnAboutAnthropicSubscriptionAuth(undefined, this.startupNoticesContainer);
47
+ }
48
+ this.showStartupNoticesIfNeeded(this.startupNoticesContainer);
31
49
  const modelsJsonError = this.session.modelRegistry.getError();
32
50
  if (modelsJsonError) {
33
51
  this.showError(`models.json error: ${modelsJsonError}`);
@@ -36,12 +54,41 @@ InteractiveModeBase.prototype.completeDeferredStartup = async function () {
36
54
  this.updateEditorBorderColor();
37
55
  this.ui.requestRender();
38
56
  };
57
+ export async function applyDeferredModelScope(mode) {
58
+ const patterns = mode.options.deferredModelScopePatterns;
59
+ if (!patterns || patterns.length === 0) {
60
+ return;
61
+ }
62
+ const { scopedModels, diagnostics } = await resolveModelScopeWithDiagnostics(patterns, mode.session.modelRegistry);
63
+ for (const diagnostic of diagnostics) {
64
+ mode.showWarning(diagnostic.message);
65
+ }
66
+ mode.session.setScopedModels(scopedModels);
67
+ if (mode.sessionManager.buildSessionContext().messages.length > 0 || scopedModels.length === 0) {
68
+ return;
69
+ }
70
+ const currentModel = mode.session.model;
71
+ if (currentModel && scopedModels.some((scoped) => modelsAreEqual(scoped.model, currentModel))) {
72
+ return;
73
+ }
74
+ const savedProvider = mode.settingsManager.getDefaultProvider();
75
+ const savedModelId = mode.settingsManager.getDefaultModel();
76
+ const savedModel = savedProvider && savedModelId ? mode.session.modelRegistry.find(savedProvider, savedModelId) : undefined;
77
+ const preferred = savedModel ? scopedModels.find((scoped) => modelsAreEqual(scoped.model, savedModel)) : undefined;
78
+ const nextScopedModel = preferred ?? scopedModels[0];
79
+ if (mode.session.modelRegistry.hasConfiguredAuth(nextScopedModel.model)) {
80
+ await mode.session.setModel(nextScopedModel.model);
81
+ if (nextScopedModel.thinkingLevel && !mode.options.deferredModelScopePreserveThinking) {
82
+ mode.session.setThinkingLevel(nextScopedModel.thinkingLevel);
83
+ }
84
+ }
85
+ }
39
86
  /**
40
87
  * A session model saved with an extension-registered provider cannot resolve
41
88
  * until extensions load; retry the restore now and only surface the fallback
42
89
  * warning if it still fails.
43
90
  */
44
- InteractiveModeBase.prototype.retryDeferredModelRestore = async function () {
91
+ InteractiveModeBase.prototype.retryDeferredModelRestore = async function (targetContainer) {
45
92
  const fallbackMessage = this.options.modelFallbackMessage;
46
93
  if (!fallbackMessage) {
47
94
  return;
@@ -54,6 +101,6 @@ InteractiveModeBase.prototype.retryDeferredModelRestore = async function () {
54
101
  return;
55
102
  }
56
103
  }
57
- this.showWarning(fallbackMessage);
104
+ this.showWarning(fallbackMessage, targetContainer);
58
105
  };
59
106
  //# sourceMappingURL=interactive-deferred-startup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-deferred-startup.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-deferred-startup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,mBAAmB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ACpC,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { recordTimeSinceReset, resolveSavedModelReference, setRegisteredThemes, Text, theme } from \"./interactive-mode-deps.ts\";\n\n/**\n * Finishes a startup where extension loading was deferred so the TUI could\n * paint immediately. Loads extension code via session.reload(), then applies\n * the same post-load UI wiring as /reload and discloses loaded resources.\n */\nInteractiveModeBase.prototype.completeDeferredStartup = async function(this: InteractiveModeBase): Promise<void> {\n const loadingIndicator = new Text(theme.fg(\"dim\", \"Loading extensions, skills, prompts, themes...\"), 1, 0);\n this.chatContainer.addChild(loadingIndicator);\n this.ui.requestRender();\n\n try {\n await this.session.reload({ reason: \"startup\" });\n } catch (error) {\n this.chatContainer.removeChild(loadingIndicator);\n this.deferredStartupPending = false;\n this.showError(\n `Extension loading failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n return;\n }\n\n this.chatContainer.removeChild(loadingIndicator);\n this.deferredStartupPending = false;\n recordTimeSinceReset(\"deferred-extension-load\");\n\n setRegisteredThemes(this.session.resourceLoader.getThemes().themes);\n await this.themeController.applyFromSettings();\n this.setupAutocompleteProvider();\n this.setupExtensionShortcuts(this.session.extensionRunner);\n await this.retryDeferredModelRestore();\n this.showLoadedResources({ force: false, showDiagnosticsWhenQuiet: true });\n this.showStartupNoticesIfNeeded();\n\n const modelsJsonError = this.session.modelRegistry.getError();\n if (modelsJsonError) {\n this.showError(`models.json error: ${modelsJsonError}`);\n }\n void this.updateAvailableProviderCount().catch(() => {});\n this.updateEditorBorderColor();\n this.ui.requestRender();\n };\n\n/**\n * A session model saved with an extension-registered provider cannot resolve\n * until extensions load; retry the restore now and only surface the fallback\n * warning if it still fails.\n */\nInteractiveModeBase.prototype.retryDeferredModelRestore = async function(this: InteractiveModeBase): Promise<void> {\n const fallbackMessage = this.options.modelFallbackMessage;\n if (!fallbackMessage) {\n return;\n }\n const savedModel = this.sessionManager.buildSessionContext().model;\n if (savedModel) {\n const restoredModel = await resolveSavedModelReference(\n savedModel.provider,\n savedModel.modelId,\n this.session.modelRegistry,\n );\n if (restoredModel && this.session.modelRegistry.hasConfiguredAuth(restoredModel)) {\n await this.session.setModel(restoredModel);\n return;\n }\n }\n this.showWarning(fallbackMessage);\n };\n"]}
1
+ {"version":3,"file":"interactive-deferred-startup.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-deferred-startup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAkB,oBAAoB,EAAE,gCAAgC,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAQrK,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAAC,IAAyB;IACzE,IAAI,CAAC,IAAI,CAAC,sBAAsB,IAAI,CAAC,IAAI,CAAC,sBAAsB;QAAE,OAAO;IACzE,IAAI,CAAC,sBAAsB,KAAK,IAAI,CAAC,uBAAuB,EAAE,CAAC;IAC/D,MAAM,IAAI,CAAC,sBAAsB,CAAC;AACpC,CAAC;AAEH,mBAAmB,CAAC,SAAS,CAAC,6BAA6B,GAAG,KAAK;IAC/D,MAAM,6BAA6B,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEJ;;;;GAIG;AACH,mBAAmB,CAAC,SAAS,CAAC,uBAAuB,GAAG,KAAK;IAC5D,IAAI,CAAC;QACJ,MAAM,IAAI,CAAC,4BAA4B,EAAE,CAAC;QAC1C,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACrB,IAAI,CAAC,sBAAsB,GAAG,KAAK,CAAC;QACpC,IAAI,CAAC,SAAS,CACZ,6BAA6B,KAAK,YAAY,KAA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AAa,GAAG,MAAM,0BAA0B,CACpD,UAAU,CAAC,QAAQ,EACnB,UAAU,CAAC,OAAO,EAClB,IAAI,CAAC,OAAO,CAAC,aAAa,CAC3B,CAAC;QACF,IAAI,aAAa,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,aAAa,CAAC,EAAE,CAAC;YACjF,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;YAC3C,OAAO;QACT,CAAC;IACH,CAAC;IACD,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;AACrD,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { modelsAreEqual } from \"@earendil-works/pi-ai/compat\";\nimport { type Container, recordTimeSinceReset, resolveModelScopeWithDiagnostics, resolveSavedModelReference, setRegisteredThemes } from \"./interactive-mode-deps.ts\";\n\nexport interface DeferredStartupMode {\n deferredStartupPending: boolean;\n deferredStartupPromise: Promise<void> | undefined;\n completeDeferredStartup(): Promise<void>;\n }\n\nexport async function ensureDeferredStartupComplete(mode: DeferredStartupMode): Promise<void> {\n if (!mode.deferredStartupPending && !mode.deferredStartupPromise) return;\n mode.deferredStartupPromise ??= mode.completeDeferredStartup();\n await mode.deferredStartupPromise;\n }\n\nInteractiveModeBase.prototype.ensureDeferredStartupComplete = async function(this: InteractiveModeBase): Promise<void> {\n await ensureDeferredStartupComplete(this);\n };\n\n/**\n * Finishes a startup where extension loading was deferred so the TUI could\n * paint immediately. Loads extension code via session.reload(), then applies\n * the same post-load UI wiring as /reload and discloses loaded resources.\n */\nInteractiveModeBase.prototype.completeDeferredStartup = async function(this: InteractiveModeBase): Promise<void> {\n\ttry {\n\t\tawait this.bindCurrentSessionExtensions();\n\t\tawait this.session.reload({ reason: \"startup\" });\n\t} catch (error) {\n\t\tthis.stopWorkingLoader();\n this.deferredStartupPending = false;\n this.showError(\n `Extension loading failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n // The RESOURCES disclosure will not render; surface the held warning.\n void this.maybeWarnAboutAnthropicSubscriptionAuth(undefined, this.startupNoticesContainer);\n return;\n }\n\n\tthis.stopWorkingLoader();\n\tthis.deferredStartupPending = false;\n recordTimeSinceReset(\"deferred-extension-load\");\n\n setRegisteredThemes(this.session.resourceLoader.getThemes().themes);\n await this.themeController.applyFromSettings();\n this.setupAutocompleteProvider();\n this.setupExtensionShortcuts(this.session.extensionRunner);\n await applyDeferredModelScope(this);\n await this.retryDeferredModelRestore(this.startupNoticesContainer);\n\tif (this.deferLoadedResourcesDisclosureUntilAgentEnd) {\n\t\tthis.pendingLoadedResourcesDisclosure = true;\n\t} else {\n\t\tthis.showLoadedResources({ force: true, showDiagnosticsWhenQuiet: true, targetContainer: this.startupNoticesContainer });\n\t\t// Keep the subscription warning after the RESOURCES disclosure.\n\t\tvoid this.maybeWarnAboutAnthropicSubscriptionAuth(undefined, this.startupNoticesContainer);\n\t}\n\tthis.showStartupNoticesIfNeeded(this.startupNoticesContainer);\n const modelsJsonError = this.session.modelRegistry.getError();\n if (modelsJsonError) {\n this.showError(`models.json error: ${modelsJsonError}`);\n }\n void this.updateAvailableProviderCount().catch(() => {});\n this.updateEditorBorderColor();\n this.ui.requestRender();\n };\n\nexport async function applyDeferredModelScope(mode: InteractiveModeBase): Promise<void> {\n const patterns = mode.options.deferredModelScopePatterns;\n if (!patterns || patterns.length === 0) {\n return;\n }\n\n const { scopedModels, diagnostics } = await resolveModelScopeWithDiagnostics(patterns, mode.session.modelRegistry);\n for (const diagnostic of diagnostics) {\n mode.showWarning(diagnostic.message);\n }\n mode.session.setScopedModels(scopedModels);\n\n if (mode.sessionManager.buildSessionContext().messages.length > 0 || scopedModels.length === 0) {\n return;\n }\n\n const currentModel = mode.session.model;\n if (currentModel && scopedModels.some((scoped) => modelsAreEqual(scoped.model, currentModel))) {\n return;\n }\n\n const savedProvider = mode.settingsManager.getDefaultProvider();\n const savedModelId = mode.settingsManager.getDefaultModel();\n const savedModel = savedProvider && savedModelId ? mode.session.modelRegistry.find(savedProvider, savedModelId) : undefined;\n const preferred = savedModel ? scopedModels.find((scoped) => modelsAreEqual(scoped.model, savedModel)) : undefined;\n const nextScopedModel = preferred ?? scopedModels[0];\n if (mode.session.modelRegistry.hasConfiguredAuth(nextScopedModel.model)) {\n await mode.session.setModel(nextScopedModel.model);\n if (nextScopedModel.thinkingLevel && !mode.options.deferredModelScopePreserveThinking) {\n mode.session.setThinkingLevel(nextScopedModel.thinkingLevel);\n }\n }\n }\n\n/**\n * A session model saved with an extension-registered provider cannot resolve\n * until extensions load; retry the restore now and only surface the fallback\n * warning if it still fails.\n */\nInteractiveModeBase.prototype.retryDeferredModelRestore = async function(this: InteractiveModeBase, targetContainer?: Container): Promise<void> {\n const fallbackMessage = this.options.modelFallbackMessage;\n if (!fallbackMessage) {\n return;\n }\n const savedModel = this.sessionManager.buildSessionContext().model;\n if (savedModel) {\n const restoredModel = await resolveSavedModelReference(\n savedModel.provider,\n savedModel.modelId,\n this.session.modelRegistry,\n );\n if (restoredModel && this.session.modelRegistry.hasConfiguredAuth(restoredModel)) {\n await this.session.setModel(restoredModel);\n return;\n }\n }\n this.showWarning(fallbackMessage, targetContainer);\n };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-editor-actions.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-editor-actions.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { getCapabilities, hyperlink, Spacer, Text, APP_NAME, CHANGELOG_URL, openExternalEditorForText, DynamicBorder, theme } from \"./interactive-mode-deps.ts\";\nimport { ExpandableText, isExpandable } from \"./interactive-mode-helpers.ts\";\n\nInteractiveModeBase.prototype.refreshBuiltInHeader = function(this: InteractiveModeBase): void {\n if (this.builtInHeader instanceof ExpandableText) {\n this.builtInHeader.refresh();\n }\n };\n\nInteractiveModeBase.prototype.updateEditorBorderColor = function(this: InteractiveModeBase): void {\n if (this.isBashMode) {\n this.editor.borderColor = theme.getBashModeBorderColor();\n } else {\n const level = this.session.thinkingLevel || \"off\";\n this.editor.borderColor = theme.getThinkingBorderColor(level);\n }\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.cycleThinkingLevel = function(this: InteractiveModeBase): void {\n const newLevel = this.session.cycleThinkingLevel();\n if (newLevel === undefined) {\n this.showStatus(\"Current model does not support thinking\");\n } else {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n this.showStatus(`Thinking level: ${newLevel}`);\n }\n };\n\nInteractiveModeBase.prototype.cycleModel = async function(this: InteractiveModeBase, direction: \"forward\" | \"backward\"): Promise<void> {\n try {\n const result = await this.session.cycleModel(direction);\n if (result === undefined) {\n const msg =\n this.session.scopedModels.length > 0\n ? \"Only one model in scope\"\n : \"Only one model available\";\n this.showStatus(msg);\n } else {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n const thinkingStr =\n result.model.reasoning && result.thinkingLevel !== \"off\"\n ? ` (thinking: ${result.thinkingLevel})`\n : \"\";\n this.showStatus(\n `Switched to ${result.model.name || result.model.id}${thinkingStr}`,\n );\n void this.maybeWarnAboutAnthropicSubscriptionAuth(result.model);\n }\n } catch (error) {\n this.showError(error instanceof Error ? error.message : String(error));\n }\n };\n\nInteractiveModeBase.prototype.toggleToolOutputExpansion = function(this: InteractiveModeBase): void {\n this.setToolsExpanded(!this.toolOutputExpanded);\n };\n\nInteractiveModeBase.prototype.setToolsExpanded = function(this: InteractiveModeBase, expanded: boolean): void {\n this.toolOutputExpanded = expanded;\n const activeHeader = this.customHeader ?? this.builtInHeader;\n if (isExpandable(activeHeader)) {\n activeHeader.setExpanded(expanded);\n }\n for (const child of this.chatContainer.children) {\n if (isExpandable(child)) {\n child.setExpanded(expanded);\n }\n }\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.toggleThinkingBlockVisibility = function(this: InteractiveModeBase): void {\n this.hideThinkingBlock = !this.hideThinkingBlock;\n this.settingsManager.setHideThinkingBlock(this.hideThinkingBlock);\n\n // Rebuild chat from session messages\n this.chatContainer.clear();\n this.rebuildChatFromMessages();\n\n // If streaming, re-add the streaming component with updated visibility and re-render\n if (this.streamingComponent && this.streamingMessage) {\n this.streamingComponent.setHideThinkingBlock(this.hideThinkingBlock);\n this.streamingComponent.updateContent(this.streamingMessage);\n this.chatContainer.addChild(this.streamingComponent);\n }\n\n this.showStatus(\n `Thinking blocks: ${this.hideThinkingBlock ? \"hidden\" : \"visible\"}`,\n );\n };\n\nInteractiveModeBase.prototype.openExternalEditor = function(this: InteractiveModeBase): void {\n const currentText = this.editor.getExpandedText?.() ?? this.editor.getText();\n const updated = openExternalEditorForText(currentText, this.ui, {\n editorCommand: this.settingsManager.getExternalEditorCommand(),\n showWarning: (message) => this.showWarning(message),\n });\n if (updated !== undefined) this.editor.setText(updated);\n };\n\nInteractiveModeBase.prototype.clearEditor = function(this: InteractiveModeBase): void {\n this.editor.setText(\"\");\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showError = function(this: InteractiveModeBase, errorMessage: string): void {\n this.chatContainer.addChild(new Spacer(1));\n this.chatContainer.addChild(\n new Text(theme.fg(\"error\", `Error: ${errorMessage}`), 1, 0),\n );\n this.chatContainer.addChild(new Spacer(1));\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showWarning = function(this: InteractiveModeBase, warningMessage: string): void {\n this.chatContainer.addChild(new Spacer(1));\n this.chatContainer.addChild(\n new Text(theme.fg(\"warning\", `Warning: ${warningMessage}`), 1, 0),\n );\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showNewVersionNotification = function(this: InteractiveModeBase, newVersion: string): void {\n const action = theme.fg(\"accent\", `${APP_NAME} update`);\n const updateInstruction =\n theme.fg(\"muted\", `New version ${newVersion} is available. Run `) +\n action;\n const changelogLine = CHANGELOG_URL\n ? `\\n${theme.fg(\"muted\", \"Changelog: \")}${\n getCapabilities().hyperlinks\n ? hyperlink(theme.fg(\"accent\", \"open changelog\"), CHANGELOG_URL)\n : theme.fg(\"accent\", CHANGELOG_URL)\n }`\n : \"\";\n\n this.chatContainer.addChild(new Spacer(1));\n this.chatContainer.addChild(\n new DynamicBorder((text) => theme.fg(\"warning\", text)),\n );\n this.chatContainer.addChild(\n new Text(\n `${theme.bold(theme.fg(\"warning\", \"Update Available\"))}\\n${updateInstruction}${changelogLine}`,\n 1,\n 0,\n ),\n );\n this.chatContainer.addChild(\n new DynamicBorder((text) => theme.fg(\"warning\", text)),\n );\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showPackageUpdateNotification = function(this: InteractiveModeBase, packages: string[]): void {\n const action = theme.fg(\"accent\", `${APP_NAME} update --extensions`);\n const updateInstruction =\n theme.fg(\"muted\", \"Package updates are available. Run \") + action;\n const packageLines = packages.map((pkg) => `- ${pkg}`).join(\"\\n\");\n\n this.chatContainer.addChild(new Spacer(1));\n this.chatContainer.addChild(\n new DynamicBorder((text) => theme.fg(\"warning\", text)),\n );\n this.chatContainer.addChild(\n new Text(\n `${theme.bold(theme.fg(\"warning\", \"Package Updates Available\"))}\\n${updateInstruction}\\n${theme.fg(\"muted\", \"Packages:\")}\\n${packageLines}`,\n 1,\n 0,\n ),\n );\n this.chatContainer.addChild(\n new DynamicBorder((text) => theme.fg(\"warning\", text)),\n );\n this.ui.requestRender();\n };\n"]}
1
+ {"version":3,"file":"interactive-editor-actions.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-editor-actions.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { getCapabilities, hyperlink, Spacer, Text, APP_NAME, CHANGELOG_URL, openExternalEditorForText, DynamicBorder, theme } from \"./interactive-mode-deps.ts\";\nimport { ExpandableText, isExpandable } from \"./interactive-mode-helpers.ts\";\n\nInteractiveModeBase.prototype.refreshBuiltInHeader = function(this: InteractiveModeBase): void {\n if (this.builtInHeader instanceof ExpandableText) {\n this.builtInHeader.refresh();\n }\n };\n\nInteractiveModeBase.prototype.updateEditorBorderColor = function(this: InteractiveModeBase): void {\n if (this.isBashMode) {\n this.editor.borderColor = theme.getBashModeBorderColor();\n } else {\n const level = this.session.thinkingLevel || \"off\";\n this.editor.borderColor = theme.getThinkingBorderColor(level);\n }\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.cycleThinkingLevel = function(this: InteractiveModeBase): void {\n const newLevel = this.session.cycleThinkingLevel();\n if (newLevel === undefined) {\n this.showStatus(\"Current model does not support thinking\");\n } else {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n this.showStatus(`Thinking level: ${newLevel}`);\n }\n };\n\nInteractiveModeBase.prototype.cycleModel = async function(this: InteractiveModeBase, direction: \"forward\" | \"backward\"): Promise<void> {\n try {\n const result = await this.session.cycleModel(direction);\n if (result === undefined) {\n const msg =\n this.session.scopedModels.length > 0\n ? \"Only one model in scope\"\n : \"Only one model available\";\n this.showStatus(msg);\n } else {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n const thinkingStr =\n result.model.reasoning && result.thinkingLevel !== \"off\"\n ? ` (thinking: ${result.thinkingLevel})`\n : \"\";\n this.showStatus(\n `Switched to ${result.model.name || result.model.id}${thinkingStr}`,\n );\n void this.maybeWarnAboutAnthropicSubscriptionAuth(result.model);\n }\n } catch (error) {\n this.showError(error instanceof Error ? error.message : String(error));\n }\n };\n\nInteractiveModeBase.prototype.toggleToolOutputExpansion = function(this: InteractiveModeBase): void {\n this.setToolsExpanded(!this.toolOutputExpanded);\n };\n\nInteractiveModeBase.prototype.setToolsExpanded = function(this: InteractiveModeBase, expanded: boolean): void {\n this.toolOutputExpanded = expanded;\n const activeHeader = this.customHeader ?? this.builtInHeader;\n if (isExpandable(activeHeader)) {\n activeHeader.setExpanded(expanded);\n }\n for (const child of this.chatContainer.children) {\n if (isExpandable(child)) {\n child.setExpanded(expanded);\n }\n }\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.toggleThinkingBlockVisibility = function(this: InteractiveModeBase): void {\n this.hideThinkingBlock = !this.hideThinkingBlock;\n this.settingsManager.setHideThinkingBlock(this.hideThinkingBlock);\n\n // Rebuild chat from session messages\n this.chatContainer.clear();\n this.rebuildChatFromMessages();\n\n // If streaming, re-add the streaming component with updated visibility and re-render\n if (this.streamingComponent && this.streamingMessage) {\n this.streamingComponent.setHideThinkingBlock(this.hideThinkingBlock);\n this.streamingComponent.updateContent(this.streamingMessage);\n this.chatContainer.addChild(this.streamingComponent);\n }\n\n this.showStatus(\n `Thinking blocks: ${this.hideThinkingBlock ? \"hidden\" : \"visible\"}`,\n );\n };\n\nInteractiveModeBase.prototype.openExternalEditor = function(this: InteractiveModeBase): void {\n const currentText = this.editor.getExpandedText?.() ?? this.editor.getText();\n const updated = openExternalEditorForText(currentText, this.ui, {\n editorCommand: this.settingsManager.getExternalEditorCommand(),\n showWarning: (message) => this.showWarning(message),\n });\n if (updated !== undefined) this.editor.setText(updated);\n };\n\nInteractiveModeBase.prototype.clearEditor = function(this: InteractiveModeBase): void {\n this.editor.setText(\"\");\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showError = function(this: InteractiveModeBase, errorMessage: string): void {\n this.chatContainer.addChild(new Spacer(1));\n this.chatContainer.addChild(\n new Text(theme.fg(\"error\", `Error: ${errorMessage}`), 1, 0),\n );\n this.chatContainer.addChild(new Spacer(1));\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showWarning = function(this: InteractiveModeBase, warningMessage: string, targetContainer = this.chatContainer): void {\n targetContainer.addChild(new Spacer(1));\n targetContainer.addChild(\n new Text(theme.fg(\"warning\", `Warning: ${warningMessage}`), 1, 0),\n );\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showNewVersionNotification = function(this: InteractiveModeBase, newVersion: string, targetContainer = this.chatContainer): void {\n const action = theme.fg(\"accent\", `${APP_NAME} update`);\n const updateInstruction =\n theme.fg(\"muted\", `New version ${newVersion} is available. Run `) +\n action;\n const changelogLine = CHANGELOG_URL\n ? `\\n${theme.fg(\"muted\", \"Changelog: \")}${\n getCapabilities().hyperlinks\n ? hyperlink(theme.fg(\"accent\", \"open changelog\"), CHANGELOG_URL)\n : theme.fg(\"accent\", CHANGELOG_URL)\n }`\n : \"\";\n\n targetContainer.addChild(new Spacer(1));\n targetContainer.addChild(\n new DynamicBorder((text) => theme.fg(\"warning\", text)),\n );\n targetContainer.addChild(\n new Text(\n `${theme.bold(theme.fg(\"warning\", \"Update Available\"))}\\n${updateInstruction}${changelogLine}`,\n 1,\n 0,\n ),\n );\n targetContainer.addChild(\n new DynamicBorder((text) => theme.fg(\"warning\", text)),\n );\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showPackageUpdateNotification = function(this: InteractiveModeBase, packages: string[], targetContainer = this.chatContainer): void {\n const action = theme.fg(\"accent\", `${APP_NAME} update --extensions`);\n const updateInstruction =\n theme.fg(\"muted\", \"Package updates are available. Run \") + action;\n const packageLines = packages.map((pkg) => `- ${pkg}`).join(\"\\n\");\n\n targetContainer.addChild(new Spacer(1));\n targetContainer.addChild(\n new DynamicBorder((text) => theme.fg(\"warning\", text)),\n );\n targetContainer.addChild(\n new Text(\n `${theme.bold(theme.fg(\"warning\", \"Package Updates Available\"))}\\n${updateInstruction}\\n${theme.fg(\"muted\", \"Packages:\")}\\n${packageLines}`,\n 1,\n 0,\n ),\n );\n targetContainer.addChild(\n new DynamicBorder((text) => theme.fg(\"warning\", text)),\n );\n this.ui.requestRender();\n };\n"]}
@@ -99,12 +99,12 @@ InteractiveModeBase.prototype.showError = function (errorMessage) {
99
99
  this.chatContainer.addChild(new Spacer(1));
100
100
  this.ui.requestRender();
101
101
  };
102
- InteractiveModeBase.prototype.showWarning = function (warningMessage) {
103
- this.chatContainer.addChild(new Spacer(1));
104
- this.chatContainer.addChild(new Text(theme.fg("warning", `Warning: ${warningMessage}`), 1, 0));
102
+ InteractiveModeBase.prototype.showWarning = function (warningMessage, targetContainer = this.chatContainer) {
103
+ targetContainer.addChild(new Spacer(1));
104
+ targetContainer.addChild(new Text(theme.fg("warning", `Warning: ${warningMessage}`), 1, 0));
105
105
  this.ui.requestRender();
106
106
  };
107
- InteractiveModeBase.prototype.showNewVersionNotification = function (newVersion) {
107
+ InteractiveModeBase.prototype.showNewVersionNotification = function (newVersion, targetContainer = this.chatContainer) {
108
108
  const action = theme.fg("accent", `${APP_NAME} update`);
109
109
  const updateInstruction = theme.fg("muted", `New version ${newVersion} is available. Run `) +
110
110
  action;
@@ -113,20 +113,20 @@ InteractiveModeBase.prototype.showNewVersionNotification = function (newVersion)
113
113
  ? hyperlink(theme.fg("accent", "open changelog"), CHANGELOG_URL)
114
114
  : theme.fg("accent", CHANGELOG_URL)}`
115
115
  : "";
116
- this.chatContainer.addChild(new Spacer(1));
117
- this.chatContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
118
- this.chatContainer.addChild(new Text(`${theme.bold(theme.fg("warning", "Update Available"))}\n${updateInstruction}${changelogLine}`, 1, 0));
119
- this.chatContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
116
+ targetContainer.addChild(new Spacer(1));
117
+ targetContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
118
+ targetContainer.addChild(new Text(`${theme.bold(theme.fg("warning", "Update Available"))}\n${updateInstruction}${changelogLine}`, 1, 0));
119
+ targetContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
120
120
  this.ui.requestRender();
121
121
  };
122
- InteractiveModeBase.prototype.showPackageUpdateNotification = function (packages) {
122
+ InteractiveModeBase.prototype.showPackageUpdateNotification = function (packages, targetContainer = this.chatContainer) {
123
123
  const action = theme.fg("accent", `${APP_NAME} update --extensions`);
124
124
  const updateInstruction = theme.fg("muted", "Package updates are available. Run ") + action;
125
125
  const packageLines = packages.map((pkg) => `- ${pkg}`).join("\n");
126
- this.chatContainer.addChild(new Spacer(1));
127
- this.chatContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
128
- this.chatContainer.addChild(new Text(`${theme.bold(theme.fg("warning", "Package Updates Available"))}\n${updateInstruction}\n${theme.fg("muted", "Packages:")}\n${packageLines}`, 1, 0));
129
- this.chatContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
126
+ targetContainer.addChild(new Spacer(1));
127
+ targetContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
128
+ targetContainer.addChild(new Text(`${theme.bold(theme.fg("warning", "Package Updates Available"))}\n${updateInstruction}\n${theme.fg("muted", "Packages:")}\n${packageLines}`, 1, 0));
129
+ targetContainer.addChild(new DynamicBorder((text) => theme.fg("warning", text)));
130
130
  this.ui.requestRender();
131
131
  };
132
132
  //# sourceMappingURL=interactive-editor-actions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-editor-actions.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-editor-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,yBAAyB,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAChK,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7E,mBAAmB,CAAC,SAAS,CAAC,oBAAoB,GAAG;IACjD,IAAI,IAAI,CAAC,aAAa,YAAY,cAAc,EAAE,CAAC;QACjD,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;AACH,CAAC,CAAC;AAEJ,mBAAmB,CAAC,SAAS,CAAC,uBAAuB,GAAG;IACpD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC,sBAAsB,EAAE,CAAC;IAC3D,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,IAAI,KAAK,CAAC;QAClD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AAqC,CAAC,GAAG,MAAM,CAAC;IACpE,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,CAAC,aAAa,CAAC,QAAQ,CACzB,IAAI,aAAa,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CACvD,CAAC;IACF,IAAI,CAAC,aAAa,CAAC,QAAQ,CACzB,IAAI,IAAI,CACN,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,2BAA2B,CAAC,CAAC,KAAK,iBAAiB,KAAK,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,YAAY,EAAE,EAC3I,CAAC,EACD,CAAC,CACF,CACF,CAAC;IACF,IAAI,CAAC,aAAa,CAAC,QAAQ,CACzB,IAAI,aAAa,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CACvD,CAAC;IACF,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;AAC1B,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { getCapabilities, hyperlink, Spacer, Text, APP_NAME, CHANGELOG_URL, openExternalEditorForText, DynamicBorder, theme } from \"./interactive-mode-deps.ts\";\nimport { ExpandableText, isExpandable } from \"./interactive-mode-helpers.ts\";\n\nInteractiveModeBase.prototype.refreshBuiltInHeader = function(this: InteractiveModeBase): void {\n if (this.builtInHeader instanceof ExpandableText) {\n this.builtInHeader.refresh();\n }\n };\n\nInteractiveModeBase.prototype.updateEditorBorderColor = function(this: InteractiveModeBase): void {\n if (this.isBashMode) {\n this.editor.borderColor = theme.getBashModeBorderColor();\n } else {\n const level = this.session.thinkingLevel || \"off\";\n this.editor.borderColor = theme.getThinkingBorderColor(level);\n }\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.cycleThinkingLevel = function(this: InteractiveModeBase): void {\n const newLevel = this.session.cycleThinkingLevel();\n if (newLevel === undefined) {\n this.showStatus(\"Current model does not support thinking\");\n } else {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n this.showStatus(`Thinking level: ${newLevel}`);\n }\n };\n\nInteractiveModeBase.prototype.cycleModel = async function(this: InteractiveModeBase, direction: \"forward\" | \"backward\"): Promise<void> {\n try {\n const result = await this.session.cycleModel(direction);\n if (result === undefined) {\n const msg =\n this.session.scopedModels.length > 0\n ? \"Only one model in scope\"\n : \"Only one model available\";\n this.showStatus(msg);\n } else {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n const thinkingStr =\n result.model.reasoning && result.thinkingLevel !== \"off\"\n ? ` (thinking: ${result.thinkingLevel})`\n : \"\";\n this.showStatus(\n `Switched to ${result.model.name || result.model.id}${thinkingStr}`,\n );\n void this.maybeWarnAboutAnthropicSubscriptionAuth(result.model);\n }\n } catch (error) {\n this.showError(error instanceof Error ? error.message : String(error));\n }\n };\n\nInteractiveModeBase.prototype.toggleToolOutputExpansion = function(this: InteractiveModeBase): void {\n this.setToolsExpanded(!this.toolOutputExpanded);\n };\n\nInteractiveModeBase.prototype.setToolsExpanded = function(this: InteractiveModeBase, expanded: boolean): void {\n this.toolOutputExpanded = expanded;\n const activeHeader = this.customHeader ?? this.builtInHeader;\n if (isExpandable(activeHeader)) {\n activeHeader.setExpanded(expanded);\n }\n for (const child of this.chatContainer.children) {\n if (isExpandable(child)) {\n child.setExpanded(expanded);\n }\n }\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.toggleThinkingBlockVisibility = function(this: InteractiveModeBase): void {\n this.hideThinkingBlock = !this.hideThinkingBlock;\n this.settingsManager.setHideThinkingBlock(this.hideThinkingBlock);\n\n // Rebuild chat from session messages\n this.chatContainer.clear();\n this.rebuildChatFromMessages();\n\n // If streaming, re-add the streaming component with updated visibility and re-render\n if (this.streamingComponent && this.streamingMessage) {\n this.streamingComponent.setHideThinkingBlock(this.hideThinkingBlock);\n this.streamingComponent.updateContent(this.streamingMessage);\n this.chatContainer.addChild(this.streamingComponent);\n }\n\n this.showStatus(\n `Thinking blocks: ${this.hideThinkingBlock ? \"hidden\" : \"visible\"}`,\n );\n };\n\nInteractiveModeBase.prototype.openExternalEditor = function(this: InteractiveModeBase): void {\n const currentText = this.editor.getExpandedText?.() ?? this.editor.getText();\n const updated = openExternalEditorForText(currentText, this.ui, {\n editorCommand: this.settingsManager.getExternalEditorCommand(),\n showWarning: (message) => this.showWarning(message),\n });\n if (updated !== undefined) this.editor.setText(updated);\n };\n\nInteractiveModeBase.prototype.clearEditor = function(this: InteractiveModeBase): void {\n this.editor.setText(\"\");\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showError = function(this: InteractiveModeBase, errorMessage: string): void {\n this.chatContainer.addChild(new Spacer(1));\n this.chatContainer.addChild(\n new Text(theme.fg(\"error\", `Error: ${errorMessage}`), 1, 0),\n );\n this.chatContainer.addChild(new Spacer(1));\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showWarning = function(this: InteractiveModeBase, warningMessage: string): void {\n this.chatContainer.addChild(new Spacer(1));\n this.chatContainer.addChild(\n new Text(theme.fg(\"warning\", `Warning: ${warningMessage}`), 1, 0),\n );\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showNewVersionNotification = function(this: InteractiveModeBase, newVersion: string): void {\n const action = theme.fg(\"accent\", `${APP_NAME} update`);\n const updateInstruction =\n theme.fg(\"muted\", `New version ${newVersion} is available. Run `) +\n action;\n const changelogLine = CHANGELOG_URL\n ? `\\n${theme.fg(\"muted\", \"Changelog: \")}${\n getCapabilities().hyperlinks\n ? hyperlink(theme.fg(\"accent\", \"open changelog\"), CHANGELOG_URL)\n : theme.fg(\"accent\", CHANGELOG_URL)\n }`\n : \"\";\n\n this.chatContainer.addChild(new Spacer(1));\n this.chatContainer.addChild(\n new DynamicBorder((text) => theme.fg(\"warning\", text)),\n );\n this.chatContainer.addChild(\n new Text(\n `${theme.bold(theme.fg(\"warning\", \"Update Available\"))}\\n${updateInstruction}${changelogLine}`,\n 1,\n 0,\n ),\n );\n this.chatContainer.addChild(\n new DynamicBorder((text) => theme.fg(\"warning\", text)),\n );\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showPackageUpdateNotification = function(this: InteractiveModeBase, packages: string[]): void {\n const action = theme.fg(\"accent\", `${APP_NAME} update --extensions`);\n const updateInstruction =\n theme.fg(\"muted\", \"Package updates are available. Run \") + action;\n const packageLines = packages.map((pkg) => `- ${pkg}`).join(\"\\n\");\n\n this.chatContainer.addChild(new Spacer(1));\n this.chatContainer.addChild(\n new DynamicBorder((text) => theme.fg(\"warning\", text)),\n );\n this.chatContainer.addChild(\n new Text(\n `${theme.bold(theme.fg(\"warning\", \"Package Updates Available\"))}\\n${updateInstruction}\\n${theme.fg(\"muted\", \"Packages:\")}\\n${packageLines}`,\n 1,\n 0,\n ),\n );\n this.chatContainer.addChild(\n new DynamicBorder((text) => theme.fg(\"warning\", text)),\n );\n this.ui.requestRender();\n };\n"]}
1
+ {"version":3,"file":"interactive-editor-actions.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-editor-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,yBAAyB,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAChK,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7E,mBAAmB,C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,CAAC,CAAC,CACvD,CAAC;IACF,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;AAC1B,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { getCapabilities, hyperlink, Spacer, Text, APP_NAME, CHANGELOG_URL, openExternalEditorForText, DynamicBorder, theme } from \"./interactive-mode-deps.ts\";\nimport { ExpandableText, isExpandable } from \"./interactive-mode-helpers.ts\";\n\nInteractiveModeBase.prototype.refreshBuiltInHeader = function(this: InteractiveModeBase): void {\n if (this.builtInHeader instanceof ExpandableText) {\n this.builtInHeader.refresh();\n }\n };\n\nInteractiveModeBase.prototype.updateEditorBorderColor = function(this: InteractiveModeBase): void {\n if (this.isBashMode) {\n this.editor.borderColor = theme.getBashModeBorderColor();\n } else {\n const level = this.session.thinkingLevel || \"off\";\n this.editor.borderColor = theme.getThinkingBorderColor(level);\n }\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.cycleThinkingLevel = function(this: InteractiveModeBase): void {\n const newLevel = this.session.cycleThinkingLevel();\n if (newLevel === undefined) {\n this.showStatus(\"Current model does not support thinking\");\n } else {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n this.showStatus(`Thinking level: ${newLevel}`);\n }\n };\n\nInteractiveModeBase.prototype.cycleModel = async function(this: InteractiveModeBase, direction: \"forward\" | \"backward\"): Promise<void> {\n try {\n const result = await this.session.cycleModel(direction);\n if (result === undefined) {\n const msg =\n this.session.scopedModels.length > 0\n ? \"Only one model in scope\"\n : \"Only one model available\";\n this.showStatus(msg);\n } else {\n this.footer.invalidate();\n this.updateEditorBorderColor();\n const thinkingStr =\n result.model.reasoning && result.thinkingLevel !== \"off\"\n ? ` (thinking: ${result.thinkingLevel})`\n : \"\";\n this.showStatus(\n `Switched to ${result.model.name || result.model.id}${thinkingStr}`,\n );\n void this.maybeWarnAboutAnthropicSubscriptionAuth(result.model);\n }\n } catch (error) {\n this.showError(error instanceof Error ? error.message : String(error));\n }\n };\n\nInteractiveModeBase.prototype.toggleToolOutputExpansion = function(this: InteractiveModeBase): void {\n this.setToolsExpanded(!this.toolOutputExpanded);\n };\n\nInteractiveModeBase.prototype.setToolsExpanded = function(this: InteractiveModeBase, expanded: boolean): void {\n this.toolOutputExpanded = expanded;\n const activeHeader = this.customHeader ?? this.builtInHeader;\n if (isExpandable(activeHeader)) {\n activeHeader.setExpanded(expanded);\n }\n for (const child of this.chatContainer.children) {\n if (isExpandable(child)) {\n child.setExpanded(expanded);\n }\n }\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.toggleThinkingBlockVisibility = function(this: InteractiveModeBase): void {\n this.hideThinkingBlock = !this.hideThinkingBlock;\n this.settingsManager.setHideThinkingBlock(this.hideThinkingBlock);\n\n // Rebuild chat from session messages\n this.chatContainer.clear();\n this.rebuildChatFromMessages();\n\n // If streaming, re-add the streaming component with updated visibility and re-render\n if (this.streamingComponent && this.streamingMessage) {\n this.streamingComponent.setHideThinkingBlock(this.hideThinkingBlock);\n this.streamingComponent.updateContent(this.streamingMessage);\n this.chatContainer.addChild(this.streamingComponent);\n }\n\n this.showStatus(\n `Thinking blocks: ${this.hideThinkingBlock ? \"hidden\" : \"visible\"}`,\n );\n };\n\nInteractiveModeBase.prototype.openExternalEditor = function(this: InteractiveModeBase): void {\n const currentText = this.editor.getExpandedText?.() ?? this.editor.getText();\n const updated = openExternalEditorForText(currentText, this.ui, {\n editorCommand: this.settingsManager.getExternalEditorCommand(),\n showWarning: (message) => this.showWarning(message),\n });\n if (updated !== undefined) this.editor.setText(updated);\n };\n\nInteractiveModeBase.prototype.clearEditor = function(this: InteractiveModeBase): void {\n this.editor.setText(\"\");\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showError = function(this: InteractiveModeBase, errorMessage: string): void {\n this.chatContainer.addChild(new Spacer(1));\n this.chatContainer.addChild(\n new Text(theme.fg(\"error\", `Error: ${errorMessage}`), 1, 0),\n );\n this.chatContainer.addChild(new Spacer(1));\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showWarning = function(this: InteractiveModeBase, warningMessage: string, targetContainer = this.chatContainer): void {\n targetContainer.addChild(new Spacer(1));\n targetContainer.addChild(\n new Text(theme.fg(\"warning\", `Warning: ${warningMessage}`), 1, 0),\n );\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showNewVersionNotification = function(this: InteractiveModeBase, newVersion: string, targetContainer = this.chatContainer): void {\n const action = theme.fg(\"accent\", `${APP_NAME} update`);\n const updateInstruction =\n theme.fg(\"muted\", `New version ${newVersion} is available. Run `) +\n action;\n const changelogLine = CHANGELOG_URL\n ? `\\n${theme.fg(\"muted\", \"Changelog: \")}${\n getCapabilities().hyperlinks\n ? hyperlink(theme.fg(\"accent\", \"open changelog\"), CHANGELOG_URL)\n : theme.fg(\"accent\", CHANGELOG_URL)\n }`\n : \"\";\n\n targetContainer.addChild(new Spacer(1));\n targetContainer.addChild(\n new DynamicBorder((text) => theme.fg(\"warning\", text)),\n );\n targetContainer.addChild(\n new Text(\n `${theme.bold(theme.fg(\"warning\", \"Update Available\"))}\\n${updateInstruction}${changelogLine}`,\n 1,\n 0,\n ),\n );\n targetContainer.addChild(\n new DynamicBorder((text) => theme.fg(\"warning\", text)),\n );\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.showPackageUpdateNotification = function(this: InteractiveModeBase, packages: string[], targetContainer = this.chatContainer): void {\n const action = theme.fg(\"accent\", `${APP_NAME} update --extensions`);\n const updateInstruction =\n theme.fg(\"muted\", \"Package updates are available. Run \") + action;\n const packageLines = packages.map((pkg) => `- ${pkg}`).join(\"\\n\");\n\n targetContainer.addChild(new Spacer(1));\n targetContainer.addChild(\n new DynamicBorder((text) => theme.fg(\"warning\", text)),\n );\n targetContainer.addChild(\n new Text(\n `${theme.bold(theme.fg(\"warning\", \"Package Updates Available\"))}\\n${updateInstruction}\\n${theme.fg(\"muted\", \"Packages:\")}\\n${packageLines}`,\n 1,\n 0,\n ),\n );\n targetContainer.addChild(\n new DynamicBorder((text) => theme.fg(\"warning\", text)),\n );\n this.ui.requestRender();\n };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-extension-runtime.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-extension-runtime.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type KeyId, type Component, type LoaderIndicatorOptions, type ExtensionContext, type ExtensionRunner, type ExtensionWidgetOptions, Container, Loader, matchesKey, Text, TUI, AssistantMessageComponent, keyText, Theme, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.setupExtensionShortcuts = function(this: InteractiveModeBase, extensionRunner: ExtensionRunner): void {\n const shortcuts = extensionRunner.getShortcuts(\n this.keybindings.getEffectiveConfig(),\n );\n if (shortcuts.size === 0) return;\n\n // Create a context for shortcut handlers\n const createContext = (): ExtensionContext => ({\n ui: this.createExtensionUIContext(),\n mode: \"tui\",\n hasUI: true,\n cwd: this.sessionManager.getCwd(),\n sessionManager: this.sessionManager,\n modelRegistry: this.session.modelRegistry,\n model: this.session.model,\n isIdle: () => !this.session.isStreaming,\n isProjectTrusted: () => this.session.settingsManager.isProjectTrusted(),\n signal: this.session.agent.signal,\n abort: () => this.session.abort(),\n hasPendingMessages: () => this.session.pendingMessageCount > 0,\n shutdown: () => {\n this.shutdownRequested = true;\n },\n getContextUsage: () => this.session.getContextUsage(),\n compact: (options) => {\n void (async () => {\n try {\n const result = await this.session.compact();\n options?.onComplete?.(result);\n } catch (error) {\n const err =\n error instanceof Error ? error : new Error(String(error));\n options?.onError?.(err);\n }\n })();\n },\n getSystemPrompt: () => this.session.systemPrompt,\n });\n\n // Set up the extension shortcut handler on the default editor\n this.defaultEditor.onExtensionShortcut = (data: string) => {\n for (const [shortcutStr, shortcut] of shortcuts) {\n // Cast to KeyId - extension shortcuts use the same format\n if (matchesKey(data, shortcutStr as KeyId)) {\n // Run handler async, don't block input\n Promise.resolve(shortcut.handler(createContext())).catch((err) => {\n this.showError(\n `Shortcut handler error: ${err instanceof Error ? err.message : String(err)}`,\n );\n });\n return true;\n }\n }\n return false;\n };\n };\n\nInteractiveModeBase.prototype.setExtensionStatus = function(this: InteractiveModeBase, key: string, text: string | undefined): void {\n this.footerDataProvider.setExtensionStatus(key, text);\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.getWorkingLoaderMessage = function(this: InteractiveModeBase): string {\n return this.workingMessage ?? this.defaultWorkingMessage;\n };\n\nInteractiveModeBase.prototype.createWorkingLoader = function(this: InteractiveModeBase): Loader {\n return new Loader(\n this.ui,\n (spinner) => theme.fg(\"accent\", spinner),\n (text) => theme.fg(\"muted\", text),\n this.getWorkingLoaderMessage(),\n this.workingIndicatorOptions,\n );\n };\n\nInteractiveModeBase.prototype.stopWorkingLoader = function(this: InteractiveModeBase): void {\n if (this.loadingAnimation) {\n this.loadingAnimation.stop();\n this.loadingAnimation = undefined;\n }\n this.statusContainer.clear();\n };\n\nInteractiveModeBase.prototype.setWorkingVisible = function(this: InteractiveModeBase, visible: boolean): void {\n this.workingVisible = visible;\n if (!visible) {\n this.stopWorkingLoader();\n this.ui.requestRender();\n return;\n }\n if (this.session.isStreaming && !this.loadingAnimation) {\n this.statusContainer.clear();\n this.loadingAnimation = this.createWorkingLoader();\n this.statusContainer.addChild(this.loadingAnimation);\n }\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.setWorkingIndicator = function(this: InteractiveModeBase, options?: LoaderIndicatorOptions): void {\n this.workingIndicatorOptions = options;\n this.loadingAnimation?.setIndicator(options);\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.setHiddenThinkingLabel = function(this: InteractiveModeBase, label?: string): void {\n this.hiddenThinkingLabel = label ?? this.defaultHiddenThinkingLabel;\n for (const child of this.chatContainer.children) {\n if (child instanceof AssistantMessageComponent) {\n child.setHiddenThinkingLabel(this.hiddenThinkingLabel);\n }\n }\n if (this.streamingComponent) {\n this.streamingComponent.setHiddenThinkingLabel(this.hiddenThinkingLabel);\n }\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.setExtensionWidget = function(this: InteractiveModeBase, key: string, content:\n | string[]\n | ((tui: TUI, thm: Theme) => Component & { dispose?(): void })\n | undefined, options?: ExtensionWidgetOptions): void {\n const placement = options?.placement ?? \"aboveEditor\";\n const removeExisting = (\n map: Map<string, Component & { dispose?(): void }>,\n ) => {\n const existing = map.get(key);\n if (existing?.dispose) existing.dispose();\n map.delete(key);\n };\n\n removeExisting(this.extensionWidgetsAbove);\n removeExisting(this.extensionWidgetsBelow);\n\n if (content === undefined) {\n this.renderWidgets();\n return;\n }\n\n let component: Component & { dispose?(): void };\n\n if (Array.isArray(content)) {\n // Wrap string array in a Container with Text components\n const container = new Container();\n for (const line of content.slice(0, InteractiveModeBase.MAX_WIDGET_LINES)) {\n container.addChild(new Text(line, 1, 0));\n }\n if (content.length > InteractiveModeBase.MAX_WIDGET_LINES) {\n container.addChild(\n new Text(theme.fg(\"muted\", \"... (widget truncated)\"), 1, 0),\n );\n }\n component = container;\n } else {\n // Factory function - create component\n component = content(this.ui, theme);\n }\n\n const targetMap =\n placement === \"belowEditor\"\n ? this.extensionWidgetsBelow\n : this.extensionWidgetsAbove;\n targetMap.set(key, component);\n this.renderWidgets();\n };\n\nInteractiveModeBase.prototype.clearExtensionWidgets = function(this: InteractiveModeBase): void {\n for (const widget of this.extensionWidgetsAbove.values()) {\n widget.dispose?.();\n }\n for (const widget of this.extensionWidgetsBelow.values()) {\n widget.dispose?.();\n }\n this.extensionWidgetsAbove.clear();\n this.extensionWidgetsBelow.clear();\n this.renderWidgets();\n };\n\nInteractiveModeBase.prototype.resetExtensionUI = function(this: InteractiveModeBase): void {\n if (this.extensionSelector) {\n this.hideExtensionSelector();\n }\n if (this.extensionInput) {\n this.hideExtensionInput();\n }\n if (this.extensionEditor) {\n this.hideExtensionEditor();\n }\n this.ui.hideOverlay();\n this.clearExtensionTerminalInputListeners();\n this.setExtensionFooter(undefined);\n this.setExtensionHeader(undefined);\n this.clearExtensionWidgets();\n this.footerDataProvider.clearExtensionStatuses();\n this.footer.invalidate();\n this.autocompleteProviderWrappers = [];\n this.setCustomEditorComponent(undefined);\n this.setupAutocompleteProvider();\n this.defaultEditor.onExtensionShortcut = undefined;\n this.updateTerminalTitle();\n this.workingMessage = undefined;\n this.workingVisible = true;\n this.setWorkingIndicator();\n if (this.loadingAnimation) {\n this.loadingAnimation.setMessage(\n `${this.defaultWorkingMessage} (${keyText(\"app.interrupt\")} Interrupt)`,\n );\n }\n this.setHiddenThinkingLabel();\n };\n"]}
1
+ {"version":3,"file":"interactive-extension-runtime.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-extension-runtime.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type KeyId, type Component, type LoaderIndicatorOptions, type ExtensionContext, type ExtensionRunner, type ExtensionWidgetOptions, Container, Loader, matchesKey, Text, TUI, AssistantMessageComponent, keyText, Theme, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.setupExtensionShortcuts = function(this: InteractiveModeBase, extensionRunner: ExtensionRunner): void {\n const shortcuts = extensionRunner.getShortcuts(\n this.keybindings.getEffectiveConfig(),\n );\n if (shortcuts.size === 0) return;\n\n // Create a context for shortcut handlers\n const createContext = (): ExtensionContext => ({\n ui: this.createExtensionUIContext(),\n mode: \"tui\",\n hasUI: true,\n cwd: this.sessionManager.getCwd(),\n sessionManager: this.sessionManager,\n modelRegistry: this.session.modelRegistry,\n model: this.session.model,\n isIdle: () => !this.session.isStreaming,\n isProjectTrusted: () => this.session.settingsManager.isProjectTrusted(),\n signal: this.session.agent.signal,\n abort: () => this.session.abort(),\n hasPendingMessages: () => this.session.pendingMessageCount > 0,\n shutdown: () => {\n this.shutdownRequested = true;\n },\n getContextUsage: () => this.session.getContextUsage(),\n compact: (options) => {\n void (async () => {\n try {\n const result = await this.session.compact();\n options?.onComplete?.(result);\n } catch (error) {\n const err =\n error instanceof Error ? error : new Error(String(error));\n options?.onError?.(err);\n }\n })();\n },\n getSystemPrompt: () => this.session.systemPrompt,\n });\n\n // Set up the extension shortcut handler on the default editor\n this.defaultEditor.onExtensionShortcut = (data: string) => {\n for (const [shortcutStr, shortcut] of shortcuts) {\n // Cast to KeyId - extension shortcuts use the same format\n if (matchesKey(data, shortcutStr as KeyId)) {\n // Run handler async, don't block input\n Promise.resolve(shortcut.handler(createContext())).catch((err) => {\n this.showError(\n `Shortcut handler error: ${err instanceof Error ? err.message : String(err)}`,\n );\n });\n return true;\n }\n }\n return false;\n };\n };\n\nInteractiveModeBase.prototype.setExtensionStatus = function(this: InteractiveModeBase, key: string, text: string | undefined): void {\n this.footerDataProvider.setExtensionStatus(key, text);\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.getWorkingLoaderMessage = function(this: InteractiveModeBase): string {\n return this.workingMessage ?? this.defaultWorkingMessage;\n };\n\nInteractiveModeBase.prototype.createWorkingLoader = function(this: InteractiveModeBase): Loader {\n return new Loader(\n this.ui,\n (spinner) => theme.fg(\"accent\", spinner),\n (text) => theme.fg(\"muted\", text),\n this.getWorkingLoaderMessage(),\n this.workingIndicatorOptions,\n );\n };\n\nInteractiveModeBase.prototype.stopWorkingLoader = function(this: InteractiveModeBase): void {\n if (this.loadingAnimation) {\n this.loadingAnimation.stop();\n this.loadingAnimation = undefined;\n }\n this.statusContainer.clear();\n };\n\nInteractiveModeBase.prototype.showWorkingLoaderNow = function(this: InteractiveModeBase): void {\n // Mount the working spinner immediately, regardless of streaming state, so\n // there is no visible gap between submitting a prompt and the agent turn\n // actually starting. Prompt preflight (extension input hooks, template/skill\n // expansion, auth and compaction checks, deferred startup) runs before the\n // agent emits `agent_start`, which is otherwise the only place the loader is\n // created. Respect `workingVisible` so extensions can still suppress it.\n if (!this.workingVisible || this.loadingAnimation) {\n this.ui.requestRender();\n return;\n }\n this.statusContainer.clear();\n this.loadingAnimation = this.createWorkingLoader();\n this.statusContainer.addChild(this.loadingAnimation);\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.setWorkingVisible = function(this: InteractiveModeBase, visible: boolean): void {\n this.workingVisible = visible;\n if (!visible) {\n this.stopWorkingLoader();\n this.ui.requestRender();\n return;\n }\n if (this.session.isStreaming && !this.loadingAnimation) {\n this.statusContainer.clear();\n this.loadingAnimation = this.createWorkingLoader();\n this.statusContainer.addChild(this.loadingAnimation);\n }\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.setWorkingIndicator = function(this: InteractiveModeBase, options?: LoaderIndicatorOptions): void {\n this.workingIndicatorOptions = options;\n this.loadingAnimation?.setIndicator(options);\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.setHiddenThinkingLabel = function(this: InteractiveModeBase, label?: string): void {\n this.hiddenThinkingLabel = label ?? this.defaultHiddenThinkingLabel;\n for (const child of this.chatContainer.children) {\n if (child instanceof AssistantMessageComponent) {\n child.setHiddenThinkingLabel(this.hiddenThinkingLabel);\n }\n }\n if (this.streamingComponent) {\n this.streamingComponent.setHiddenThinkingLabel(this.hiddenThinkingLabel);\n }\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.setExtensionWidget = function(this: InteractiveModeBase, key: string, content:\n | string[]\n | ((tui: TUI, thm: Theme) => Component & { dispose?(): void })\n | undefined, options?: ExtensionWidgetOptions): void {\n const placement = options?.placement ?? \"aboveEditor\";\n const removeExisting = (\n map: Map<string, Component & { dispose?(): void }>,\n ) => {\n const existing = map.get(key);\n if (existing?.dispose) existing.dispose();\n map.delete(key);\n };\n\n removeExisting(this.extensionWidgetsAbove);\n removeExisting(this.extensionWidgetsBelow);\n\n if (content === undefined) {\n this.renderWidgets();\n return;\n }\n\n let component: Component & { dispose?(): void };\n\n if (Array.isArray(content)) {\n // Wrap string array in a Container with Text components\n const container = new Container();\n for (const line of content.slice(0, InteractiveModeBase.MAX_WIDGET_LINES)) {\n container.addChild(new Text(line, 1, 0));\n }\n if (content.length > InteractiveModeBase.MAX_WIDGET_LINES) {\n container.addChild(\n new Text(theme.fg(\"muted\", \"... (widget truncated)\"), 1, 0),\n );\n }\n component = container;\n } else {\n // Factory function - create component\n component = content(this.ui, theme);\n }\n\n const targetMap =\n placement === \"belowEditor\"\n ? this.extensionWidgetsBelow\n : this.extensionWidgetsAbove;\n targetMap.set(key, component);\n this.renderWidgets();\n };\n\nInteractiveModeBase.prototype.clearExtensionWidgets = function(this: InteractiveModeBase): void {\n for (const widget of this.extensionWidgetsAbove.values()) {\n widget.dispose?.();\n }\n for (const widget of this.extensionWidgetsBelow.values()) {\n widget.dispose?.();\n }\n this.extensionWidgetsAbove.clear();\n this.extensionWidgetsBelow.clear();\n this.renderWidgets();\n };\n\nInteractiveModeBase.prototype.resetExtensionUI = function(this: InteractiveModeBase): void {\n if (this.extensionSelector) {\n this.hideExtensionSelector();\n }\n if (this.extensionInput) {\n this.hideExtensionInput();\n }\n if (this.extensionEditor) {\n this.hideExtensionEditor();\n }\n this.ui.hideOverlay();\n this.clearExtensionTerminalInputListeners();\n this.setExtensionFooter(undefined);\n this.setExtensionHeader(undefined);\n this.clearExtensionWidgets();\n this.footerDataProvider.clearExtensionStatuses();\n this.footer.invalidate();\n this.autocompleteProviderWrappers = [];\n this.setCustomEditorComponent(undefined);\n this.setupAutocompleteProvider();\n this.defaultEditor.onExtensionShortcut = undefined;\n this.updateTerminalTitle();\n this.workingMessage = undefined;\n this.workingVisible = true;\n this.setWorkingIndicator();\n if (this.loadingAnimation) {\n this.loadingAnimation.setMessage(\n `${this.defaultWorkingMessage} (${keyText(\"app.interrupt\")} Interrupt)`,\n );\n }\n this.setHiddenThinkingLabel();\n };\n"]}
@@ -68,6 +68,22 @@ InteractiveModeBase.prototype.stopWorkingLoader = function () {
68
68
  }
69
69
  this.statusContainer.clear();
70
70
  };
71
+ InteractiveModeBase.prototype.showWorkingLoaderNow = function () {
72
+ // Mount the working spinner immediately, regardless of streaming state, so
73
+ // there is no visible gap between submitting a prompt and the agent turn
74
+ // actually starting. Prompt preflight (extension input hooks, template/skill
75
+ // expansion, auth and compaction checks, deferred startup) runs before the
76
+ // agent emits `agent_start`, which is otherwise the only place the loader is
77
+ // created. Respect `workingVisible` so extensions can still suppress it.
78
+ if (!this.workingVisible || this.loadingAnimation) {
79
+ this.ui.requestRender();
80
+ return;
81
+ }
82
+ this.statusContainer.clear();
83
+ this.loadingAnimation = this.createWorkingLoader();
84
+ this.statusContainer.addChild(this.loadingAnimation);
85
+ this.ui.requestRender();
86
+ };
71
87
  InteractiveModeBase.prototype.setWorkingVisible = function (visible) {
72
88
  this.workingVisible = visible;
73
89
  if (!visible) {
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-extension-runtime.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-extension-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAqI,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAO,yBAAyB,EAAE,OAAO,EAAS,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAE3Q,mBAAmB,CAAC,SAAS,CAAC,uBAAuB,GAAG,UAAoC,eAAgC;IACxH,MAAM,SAAS,GAAG,eAAe,CAAC,YAAY,CAC5C,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE,CACtC,CAAC;IACF,IAAI,SAAS,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO;IAEjC,yCAAyC;IACzC,MAAM,aAAa,GAAG,GAAqB,EAAE,CAAC,CAAC;QAC7C,EAAE,EAAE,IAAI,CAAC,wBAAwB,EAAE;QACnC,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,IAAI;QACX,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE;QACjC,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa;QACzC,KAAK,EAAE,IAAI,CAAC,OAAO,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AAa,CACxE,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,sBAAsB,EAAE,CAAC;AAChC,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type KeyId, type Component, type LoaderIndicatorOptions, type ExtensionContext, type ExtensionRunner, type ExtensionWidgetOptions, Container, Loader, matchesKey, Text, TUI, AssistantMessageComponent, keyText, Theme, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.setupExtensionShortcuts = function(this: InteractiveModeBase, extensionRunner: ExtensionRunner): void {\n const shortcuts = extensionRunner.getShortcuts(\n this.keybindings.getEffectiveConfig(),\n );\n if (shortcuts.size === 0) return;\n\n // Create a context for shortcut handlers\n const createContext = (): ExtensionContext => ({\n ui: this.createExtensionUIContext(),\n mode: \"tui\",\n hasUI: true,\n cwd: this.sessionManager.getCwd(),\n sessionManager: this.sessionManager,\n modelRegistry: this.session.modelRegistry,\n model: this.session.model,\n isIdle: () => !this.session.isStreaming,\n isProjectTrusted: () => this.session.settingsManager.isProjectTrusted(),\n signal: this.session.agent.signal,\n abort: () => this.session.abort(),\n hasPendingMessages: () => this.session.pendingMessageCount > 0,\n shutdown: () => {\n this.shutdownRequested = true;\n },\n getContextUsage: () => this.session.getContextUsage(),\n compact: (options) => {\n void (async () => {\n try {\n const result = await this.session.compact();\n options?.onComplete?.(result);\n } catch (error) {\n const err =\n error instanceof Error ? error : new Error(String(error));\n options?.onError?.(err);\n }\n })();\n },\n getSystemPrompt: () => this.session.systemPrompt,\n });\n\n // Set up the extension shortcut handler on the default editor\n this.defaultEditor.onExtensionShortcut = (data: string) => {\n for (const [shortcutStr, shortcut] of shortcuts) {\n // Cast to KeyId - extension shortcuts use the same format\n if (matchesKey(data, shortcutStr as KeyId)) {\n // Run handler async, don't block input\n Promise.resolve(shortcut.handler(createContext())).catch((err) => {\n this.showError(\n `Shortcut handler error: ${err instanceof Error ? err.message : String(err)}`,\n );\n });\n return true;\n }\n }\n return false;\n };\n };\n\nInteractiveModeBase.prototype.setExtensionStatus = function(this: InteractiveModeBase, key: string, text: string | undefined): void {\n this.footerDataProvider.setExtensionStatus(key, text);\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.getWorkingLoaderMessage = function(this: InteractiveModeBase): string {\n return this.workingMessage ?? this.defaultWorkingMessage;\n };\n\nInteractiveModeBase.prototype.createWorkingLoader = function(this: InteractiveModeBase): Loader {\n return new Loader(\n this.ui,\n (spinner) => theme.fg(\"accent\", spinner),\n (text) => theme.fg(\"muted\", text),\n this.getWorkingLoaderMessage(),\n this.workingIndicatorOptions,\n );\n };\n\nInteractiveModeBase.prototype.stopWorkingLoader = function(this: InteractiveModeBase): void {\n if (this.loadingAnimation) {\n this.loadingAnimation.stop();\n this.loadingAnimation = undefined;\n }\n this.statusContainer.clear();\n };\n\nInteractiveModeBase.prototype.setWorkingVisible = function(this: InteractiveModeBase, visible: boolean): void {\n this.workingVisible = visible;\n if (!visible) {\n this.stopWorkingLoader();\n this.ui.requestRender();\n return;\n }\n if (this.session.isStreaming && !this.loadingAnimation) {\n this.statusContainer.clear();\n this.loadingAnimation = this.createWorkingLoader();\n this.statusContainer.addChild(this.loadingAnimation);\n }\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.setWorkingIndicator = function(this: InteractiveModeBase, options?: LoaderIndicatorOptions): void {\n this.workingIndicatorOptions = options;\n this.loadingAnimation?.setIndicator(options);\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.setHiddenThinkingLabel = function(this: InteractiveModeBase, label?: string): void {\n this.hiddenThinkingLabel = label ?? this.defaultHiddenThinkingLabel;\n for (const child of this.chatContainer.children) {\n if (child instanceof AssistantMessageComponent) {\n child.setHiddenThinkingLabel(this.hiddenThinkingLabel);\n }\n }\n if (this.streamingComponent) {\n this.streamingComponent.setHiddenThinkingLabel(this.hiddenThinkingLabel);\n }\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.setExtensionWidget = function(this: InteractiveModeBase, key: string, content:\n | string[]\n | ((tui: TUI, thm: Theme) => Component & { dispose?(): void })\n | undefined, options?: ExtensionWidgetOptions): void {\n const placement = options?.placement ?? \"aboveEditor\";\n const removeExisting = (\n map: Map<string, Component & { dispose?(): void }>,\n ) => {\n const existing = map.get(key);\n if (existing?.dispose) existing.dispose();\n map.delete(key);\n };\n\n removeExisting(this.extensionWidgetsAbove);\n removeExisting(this.extensionWidgetsBelow);\n\n if (content === undefined) {\n this.renderWidgets();\n return;\n }\n\n let component: Component & { dispose?(): void };\n\n if (Array.isArray(content)) {\n // Wrap string array in a Container with Text components\n const container = new Container();\n for (const line of content.slice(0, InteractiveModeBase.MAX_WIDGET_LINES)) {\n container.addChild(new Text(line, 1, 0));\n }\n if (content.length > InteractiveModeBase.MAX_WIDGET_LINES) {\n container.addChild(\n new Text(theme.fg(\"muted\", \"... (widget truncated)\"), 1, 0),\n );\n }\n component = container;\n } else {\n // Factory function - create component\n component = content(this.ui, theme);\n }\n\n const targetMap =\n placement === \"belowEditor\"\n ? this.extensionWidgetsBelow\n : this.extensionWidgetsAbove;\n targetMap.set(key, component);\n this.renderWidgets();\n };\n\nInteractiveModeBase.prototype.clearExtensionWidgets = function(this: InteractiveModeBase): void {\n for (const widget of this.extensionWidgetsAbove.values()) {\n widget.dispose?.();\n }\n for (const widget of this.extensionWidgetsBelow.values()) {\n widget.dispose?.();\n }\n this.extensionWidgetsAbove.clear();\n this.extensionWidgetsBelow.clear();\n this.renderWidgets();\n };\n\nInteractiveModeBase.prototype.resetExtensionUI = function(this: InteractiveModeBase): void {\n if (this.extensionSelector) {\n this.hideExtensionSelector();\n }\n if (this.extensionInput) {\n this.hideExtensionInput();\n }\n if (this.extensionEditor) {\n this.hideExtensionEditor();\n }\n this.ui.hideOverlay();\n this.clearExtensionTerminalInputListeners();\n this.setExtensionFooter(undefined);\n this.setExtensionHeader(undefined);\n this.clearExtensionWidgets();\n this.footerDataProvider.clearExtensionStatuses();\n this.footer.invalidate();\n this.autocompleteProviderWrappers = [];\n this.setCustomEditorComponent(undefined);\n this.setupAutocompleteProvider();\n this.defaultEditor.onExtensionShortcut = undefined;\n this.updateTerminalTitle();\n this.workingMessage = undefined;\n this.workingVisible = true;\n this.setWorkingIndicator();\n if (this.loadingAnimation) {\n this.loadingAnimation.setMessage(\n `${this.defaultWorkingMessage} (${keyText(\"app.interrupt\")} Interrupt)`,\n );\n }\n this.setHiddenThinkingLabel();\n };\n"]}
1
+ {"version":3,"file":"interactive-extension-runtime.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-extension-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAqI,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAO,yBAAyB,EAAE,OAAO,EAAS,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAE3Q,mBAAmB,CAAC,SAAS,CAAC,uBAAuB,GAAG,UAAoC,eAAgC;IACxH,MAAM,SAAS,GAAG,eAAe,CAAC,YAAY,CAC5C,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE,CACtC,CAAC;IACF,IAAI,SAAS,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO;IAEjC,yCAAyC;IACzC,MAAM,aAAa,GAAG,GAAqB,EAAE,CAAC,CAAC;QAC7C,EAAE,EAAE,IAAI,CAAC,wBAAwB,EAAE;QACnC,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,IAAI;QACX,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE;QACjC,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa;QACzC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;QACzB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW;QACvC,gBAAgB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAA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IAAI,CAAC,yBAAyB,EAAE,CAAC;IACjC,IAAI,CAAC,aAAa,CAAC,mBAAmB,GAAG,SAAS,CAAC;IACnD,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC3B,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;IAChC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC3B,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC3B,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1B,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAC9B,GAAG,IAAI,CAAC,qBAAqB,KAAK,OAAO,CAAC,eAAe,CAAC,aAAa,CACxE,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,sBAAsB,EAAE,CAAC;AAChC,CAAC,CAAC","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { type KeyId, type Component, type LoaderIndicatorOptions, type ExtensionContext, type ExtensionRunner, type ExtensionWidgetOptions, Container, Loader, matchesKey, Text, TUI, AssistantMessageComponent, keyText, Theme, theme } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.setupExtensionShortcuts = function(this: InteractiveModeBase, extensionRunner: ExtensionRunner): void {\n const shortcuts = extensionRunner.getShortcuts(\n this.keybindings.getEffectiveConfig(),\n );\n if (shortcuts.size === 0) return;\n\n // Create a context for shortcut handlers\n const createContext = (): ExtensionContext => ({\n ui: this.createExtensionUIContext(),\n mode: \"tui\",\n hasUI: true,\n cwd: this.sessionManager.getCwd(),\n sessionManager: this.sessionManager,\n modelRegistry: this.session.modelRegistry,\n model: this.session.model,\n isIdle: () => !this.session.isStreaming,\n isProjectTrusted: () => this.session.settingsManager.isProjectTrusted(),\n signal: this.session.agent.signal,\n abort: () => this.session.abort(),\n hasPendingMessages: () => this.session.pendingMessageCount > 0,\n shutdown: () => {\n this.shutdownRequested = true;\n },\n getContextUsage: () => this.session.getContextUsage(),\n compact: (options) => {\n void (async () => {\n try {\n const result = await this.session.compact();\n options?.onComplete?.(result);\n } catch (error) {\n const err =\n error instanceof Error ? error : new Error(String(error));\n options?.onError?.(err);\n }\n })();\n },\n getSystemPrompt: () => this.session.systemPrompt,\n });\n\n // Set up the extension shortcut handler on the default editor\n this.defaultEditor.onExtensionShortcut = (data: string) => {\n for (const [shortcutStr, shortcut] of shortcuts) {\n // Cast to KeyId - extension shortcuts use the same format\n if (matchesKey(data, shortcutStr as KeyId)) {\n // Run handler async, don't block input\n Promise.resolve(shortcut.handler(createContext())).catch((err) => {\n this.showError(\n `Shortcut handler error: ${err instanceof Error ? err.message : String(err)}`,\n );\n });\n return true;\n }\n }\n return false;\n };\n };\n\nInteractiveModeBase.prototype.setExtensionStatus = function(this: InteractiveModeBase, key: string, text: string | undefined): void {\n this.footerDataProvider.setExtensionStatus(key, text);\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.getWorkingLoaderMessage = function(this: InteractiveModeBase): string {\n return this.workingMessage ?? this.defaultWorkingMessage;\n };\n\nInteractiveModeBase.prototype.createWorkingLoader = function(this: InteractiveModeBase): Loader {\n return new Loader(\n this.ui,\n (spinner) => theme.fg(\"accent\", spinner),\n (text) => theme.fg(\"muted\", text),\n this.getWorkingLoaderMessage(),\n this.workingIndicatorOptions,\n );\n };\n\nInteractiveModeBase.prototype.stopWorkingLoader = function(this: InteractiveModeBase): void {\n if (this.loadingAnimation) {\n this.loadingAnimation.stop();\n this.loadingAnimation = undefined;\n }\n this.statusContainer.clear();\n };\n\nInteractiveModeBase.prototype.showWorkingLoaderNow = function(this: InteractiveModeBase): void {\n // Mount the working spinner immediately, regardless of streaming state, so\n // there is no visible gap between submitting a prompt and the agent turn\n // actually starting. Prompt preflight (extension input hooks, template/skill\n // expansion, auth and compaction checks, deferred startup) runs before the\n // agent emits `agent_start`, which is otherwise the only place the loader is\n // created. Respect `workingVisible` so extensions can still suppress it.\n if (!this.workingVisible || this.loadingAnimation) {\n this.ui.requestRender();\n return;\n }\n this.statusContainer.clear();\n this.loadingAnimation = this.createWorkingLoader();\n this.statusContainer.addChild(this.loadingAnimation);\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.setWorkingVisible = function(this: InteractiveModeBase, visible: boolean): void {\n this.workingVisible = visible;\n if (!visible) {\n this.stopWorkingLoader();\n this.ui.requestRender();\n return;\n }\n if (this.session.isStreaming && !this.loadingAnimation) {\n this.statusContainer.clear();\n this.loadingAnimation = this.createWorkingLoader();\n this.statusContainer.addChild(this.loadingAnimation);\n }\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.setWorkingIndicator = function(this: InteractiveModeBase, options?: LoaderIndicatorOptions): void {\n this.workingIndicatorOptions = options;\n this.loadingAnimation?.setIndicator(options);\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.setHiddenThinkingLabel = function(this: InteractiveModeBase, label?: string): void {\n this.hiddenThinkingLabel = label ?? this.defaultHiddenThinkingLabel;\n for (const child of this.chatContainer.children) {\n if (child instanceof AssistantMessageComponent) {\n child.setHiddenThinkingLabel(this.hiddenThinkingLabel);\n }\n }\n if (this.streamingComponent) {\n this.streamingComponent.setHiddenThinkingLabel(this.hiddenThinkingLabel);\n }\n this.ui.requestRender();\n };\n\nInteractiveModeBase.prototype.setExtensionWidget = function(this: InteractiveModeBase, key: string, content:\n | string[]\n | ((tui: TUI, thm: Theme) => Component & { dispose?(): void })\n | undefined, options?: ExtensionWidgetOptions): void {\n const placement = options?.placement ?? \"aboveEditor\";\n const removeExisting = (\n map: Map<string, Component & { dispose?(): void }>,\n ) => {\n const existing = map.get(key);\n if (existing?.dispose) existing.dispose();\n map.delete(key);\n };\n\n removeExisting(this.extensionWidgetsAbove);\n removeExisting(this.extensionWidgetsBelow);\n\n if (content === undefined) {\n this.renderWidgets();\n return;\n }\n\n let component: Component & { dispose?(): void };\n\n if (Array.isArray(content)) {\n // Wrap string array in a Container with Text components\n const container = new Container();\n for (const line of content.slice(0, InteractiveModeBase.MAX_WIDGET_LINES)) {\n container.addChild(new Text(line, 1, 0));\n }\n if (content.length > InteractiveModeBase.MAX_WIDGET_LINES) {\n container.addChild(\n new Text(theme.fg(\"muted\", \"... (widget truncated)\"), 1, 0),\n );\n }\n component = container;\n } else {\n // Factory function - create component\n component = content(this.ui, theme);\n }\n\n const targetMap =\n placement === \"belowEditor\"\n ? this.extensionWidgetsBelow\n : this.extensionWidgetsAbove;\n targetMap.set(key, component);\n this.renderWidgets();\n };\n\nInteractiveModeBase.prototype.clearExtensionWidgets = function(this: InteractiveModeBase): void {\n for (const widget of this.extensionWidgetsAbove.values()) {\n widget.dispose?.();\n }\n for (const widget of this.extensionWidgetsBelow.values()) {\n widget.dispose?.();\n }\n this.extensionWidgetsAbove.clear();\n this.extensionWidgetsBelow.clear();\n this.renderWidgets();\n };\n\nInteractiveModeBase.prototype.resetExtensionUI = function(this: InteractiveModeBase): void {\n if (this.extensionSelector) {\n this.hideExtensionSelector();\n }\n if (this.extensionInput) {\n this.hideExtensionInput();\n }\n if (this.extensionEditor) {\n this.hideExtensionEditor();\n }\n this.ui.hideOverlay();\n this.clearExtensionTerminalInputListeners();\n this.setExtensionFooter(undefined);\n this.setExtensionHeader(undefined);\n this.clearExtensionWidgets();\n this.footerDataProvider.clearExtensionStatuses();\n this.footer.invalidate();\n this.autocompleteProviderWrappers = [];\n this.setCustomEditorComponent(undefined);\n this.setupAutocompleteProvider();\n this.defaultEditor.onExtensionShortcut = undefined;\n this.updateTerminalTitle();\n this.workingMessage = undefined;\n this.workingVisible = true;\n this.setWorkingIndicator();\n if (this.loadingAnimation) {\n this.loadingAnimation.setMessage(\n `${this.defaultWorkingMessage} (${keyText(\"app.interrupt\")} Interrupt)`,\n );\n }\n this.setHiddenThinkingLabel();\n };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-input-handling.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-input-handling.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { pasteClipboardImageToEditor } from \"./interactive-mode-deps.ts\";\n\nInteractiveModeBase.prototype.setupKeyHandlers = function(this: InteractiveModeBase): void {\n // Set up handlers on defaultEditor - they use this.editor for text access\n // so they work correctly regardless of which editor is active\n this.defaultEditor.onEscape = () => {\n if (this.session.isStreaming) {\n this.restoreQueuedMessagesToEditor({ abort: true });\n } else if (this.session.isBashRunning) {\n this.session.abortBash();\n } else if (this.isBashMode) {\n this.editor.setText(\"\");\n this.isBashMode = false;\n this.updateEditorBorderColor();\n } else if (!this.editor.getText().trim()) {\n // Double-escape with empty editor triggers /tree, /fork, or nothing based on setting\n const action = this.settingsManager.getDoubleEscapeAction();\n if (action !== \"none\") {\n const now = Date.now();\n if (now - this.lastEscapeTime < 500) {\n if (action === \"tree\") {\n this.showTreeSelector();\n } else {\n this.showUserMessageSelector();\n }\n this.lastEscapeTime = 0;\n } else {\n this.lastEscapeTime = now;\n }\n }\n }\n };\n\n // Register app action handlers\n this.defaultEditor.onAction(\"app.clear\", () => this.handleCtrlC());\n this.defaultEditor.onCtrlD = () => this.handleCtrlD();\n this.defaultEditor.onAction(\"app.suspend\", () => this.handleCtrlZ());\n this.defaultEditor.onAction(\"app.thinking.cycle\", () =>\n this.cycleThinkingLevel(),\n );\n this.defaultEditor.onAction(\"app.model.cycleForward\", () =>\n this.cycleModel(\"forward\"),\n );\n this.defaultEditor.onAction(\"app.model.cycleBackward\", () =>\n this.cycleModel(\"backward\"),\n );\n\n // Global debug handler on TUI (works regardless of focus)\n this.ui.onDebug = () => this.handleDebugCommand();\n this.defaultEditor.onAction(\"app.model.select\", () =>\n this.showModelSelector(),\n );\n this.defaultEditor.onAction(\"app.tools.expand\", () =>\n this.toggleToolOutputExpansion(),\n );\n this.defaultEditor.onAction(\"app.thinking.toggle\", () =>\n this.toggleThinkingBlockVisibility(),\n );\n this.defaultEditor.onAction(\"app.editor.external\", () =>\n this.openExternalEditor(),\n );\n this.defaultEditor.onAction(\"app.message.followUp\", () =>\n this.handleFollowUp(),\n );\n this.defaultEditor.onAction(\"app.message.dequeue\", () =>\n this.handleDequeue(),\n );\n this.defaultEditor.onAction(\"app.session.new\", () =>\n this.handleClearCommand(),\n );\n this.defaultEditor.onAction(\"app.session.tree\", () =>\n this.showTreeSelector(),\n );\n this.defaultEditor.onAction(\"app.session.fork\", () =>\n this.showUserMessageSelector(),\n );\n this.defaultEditor.onAction(\"app.session.resume\", () =>\n this.showSessionSelector(),\n );\n\n this.defaultEditor.onChange = (text: string) => {\n const wasBashMode = this.isBashMode;\n this.isBashMode = text.trimStart().startsWith(\"!\");\n if (wasBashMode !== this.isBashMode) {\n this.updateEditorBorderColor();\n }\n };\n\n // Handle clipboard image paste (triggered on Ctrl+V)\n this.defaultEditor.onPasteImage = () => {\n this.handleClipboardImagePaste();\n };\n };\n\nInteractiveModeBase.prototype.handleClipboardImagePaste = async function(this: InteractiveModeBase): Promise<void> {\n await pasteClipboardImageToEditor(this.editor, () => this.ui.requestRender(), {\n showWarning: (message) => this.showWarning(message),\n });\n };\n\nInteractiveModeBase.prototype.setupEditorSubmitHandler = function(this: InteractiveModeBase): void {\n this.defaultEditor.onSubmit = async (text: string) => {\n text = text.trim();\n if (!text) return;\n\n // Handle commands\n if (text === \"/settings\") {\n this.showSettingsSelector();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/fast\") {\n this.editor.setText(\"\");\n this.showFastModeSelector();\n return;\n }\n if (text === \"/scoped-models\") {\n this.editor.setText(\"\");\n await this.showModelsSelector();\n return;\n }\n if (text === \"/model\" || text.startsWith(\"/model \")) {\n const searchTerm = text.startsWith(\"/model \")\n ? text.slice(7).trim()\n : undefined;\n this.editor.setText(\"\");\n await this.handleModelCommand(searchTerm);\n return;\n }\n if (text === \"/export\" || text.startsWith(\"/export \")) {\n await this.handleExportCommand(text);\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/import\" || text.startsWith(\"/import \")) {\n await this.handleImportCommand(text);\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/share\") {\n await this.handleShareCommand();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/copy\") {\n await this.handleCopyCommand();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/name\" || text.startsWith(\"/name \")) {\n this.handleNameCommand(text);\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/session\") {\n this.handleSessionCommand();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/changelog\") {\n this.handleChangelogCommand();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/atomic\" || text.startsWith(\"/atomic \")) {\n this.editor.setText(\"\");\n await this.session.prompt(text);\n return;\n }\n if (text === \"/hotkeys\") {\n this.handleHotkeysCommand();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/fork\") {\n this.showUserMessageSelector();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/clone\") {\n this.editor.setText(\"\");\n await this.handleCloneCommand();\n return;\n }\n if (text === \"/tree\") {\n this.showTreeSelector();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/trust\") {\n this.showTrustSelector();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/login\") {\n this.showOAuthSelector(\"login\");\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/logout\") {\n this.showOAuthSelector(\"logout\");\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/new\") {\n this.editor.setText(\"\");\n await this.handleClearCommand();\n return;\n }\n if (/^\\/compact(?:\\s|$)/.test(text)) {\n this.editor.setText(\"\");\n if (text !== \"/compact\") {\n this.showWarning(\"Usage: /compact\");\n return;\n }\n await this.handleCompactCommand();\n return;\n }\n if (text === \"/reload\") {\n this.editor.setText(\"\");\n await this.handleReloadCommand();\n return;\n }\n if (text === \"/debug\") {\n this.handleDebugCommand();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/arminsayshi\") {\n this.handleArminSaysHi();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/dementedelves\") {\n this.handleDementedDelves();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/resume\") {\n this.showSessionSelector();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/quit\" || text === \"/exit\") {\n this.editor.setText(\"\");\n await this.shutdown();\n return;\n }\n\n // Handle bash command (! for normal, !! for excluded from context)\n if (text.startsWith(\"!\")) {\n const isExcluded = text.startsWith(\"!!\");\n const command = isExcluded\n ? text.slice(2).trim()\n : text.slice(1).trim();\n if (command) {\n if (this.session.isBashRunning) {\n this.showWarning(\n \"A bash command is already running. esc cancel first.\",\n );\n this.editor.setText(text);\n return;\n }\n this.editor.addToHistory?.(text);\n await this.handleBashCommand(command, isExcluded);\n this.isBashMode = false;\n this.updateEditorBorderColor();\n return;\n }\n }\n\n // Queue input during compaction (extension commands execute immediately)\n if (this.session.isCompacting) {\n if (this.isExtensionCommand(text)) {\n this.editor.addToHistory?.(text);\n this.editor.setText(\"\");\n await this.session.prompt(text);\n } else {\n this.queueCompactionMessage(text, \"steer\");\n }\n return;\n }\n\n // If streaming, use prompt() with steer behavior\n // This handles extension commands (execute immediately), prompt template expansion, and queueing\n if (this.session.isStreaming) {\n this.editor.addToHistory?.(text);\n this.editor.setText(\"\");\n await this.session.prompt(text, { streamingBehavior: \"steer\" });\n this.updatePendingMessagesDisplay();\n this.ui.requestRender();\n return;\n }\n\n // Normal message submission\n // First, move any pending bash components to chat\n this.flushPendingBashComponents();\n\n if (this.onInputCallback) {\n this.onInputCallback(text);\n } else {\n this.pendingUserInputs.push(text);\n }\n this.editor.addToHistory?.(text);\n };\n };\n"]}
1
+ {"version":3,"file":"interactive-input-handling.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-input-handling.ts"],"names":[],"mappings":"","sourcesContent":["import { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { pasteClipboardImageToEditor } from \"./interactive-mode-deps.ts\";\nimport { yieldToEventLoop } from \"../../utils/event-loop.ts\";\n\nInteractiveModeBase.prototype.runUserPromptTurn = async function(this: InteractiveModeBase, userInput: string): Promise<void> {\n // Show the working spinner immediately on submit so there is no visible gap\n // while prompt preflight runs before the agent emits `agent_start`.\n this.showWorkingLoaderNow();\n if (this.deferredStartupPending) {\n this.deferLoadedResourcesDisclosureUntilAgentEnd = true;\n }\n // Yield once so the freshly-mounted spinner paints before synchronous\n // preflight work can block the event loop.\n await yieldToEventLoop();\n try {\n await this.ensureDeferredStartupComplete();\n await this.session.prompt(userInput);\n this.deferLoadedResourcesDisclosureUntilAgentEnd = false;\n if (this.pendingLoadedResourcesDisclosure) {\n this.pendingLoadedResourcesDisclosure = false;\n this.showLoadedResources({ force: true, showDiagnosticsWhenQuiet: true, targetContainer: this.startupNoticesContainer });\n void this.maybeWarnAboutAnthropicSubscriptionAuth(undefined, this.startupNoticesContainer);\n }\n } catch (error: unknown) {\n this.deferLoadedResourcesDisclosureUntilAgentEnd = false;\n this.discardDeferredRenderedUserInput(userInput);\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error occurred\";\n this.showError(errorMessage);\n } finally {\n // A submission that resolves without starting an agent turn (e.g. an\n // extension slash-command) never emits `agent_end`, so clear the\n // pre-shown spinner here when idle to avoid a lingering indicator.\n if (!this.session.isStreaming) {\n this.stopWorkingLoader();\n }\n }\n };\n\nInteractiveModeBase.prototype.setupKeyHandlers = function(this: InteractiveModeBase): void {\n this.ui.addInputListener((data) => {\n if (!this.keybindings.matches(data, \"app.clear\")) return undefined;\n if (this.ui.hasOverlay()) return undefined;\n this.handleCtrlC();\n this.ui.requestRender();\n return { consume: true };\n });\n\n // Set up handlers on defaultEditor - they use this.editor for text access\n // so they work correctly regardless of which editor is active\n this.defaultEditor.onEscape = () => {\n if (this.session.isStreaming) {\n this.restoreQueuedMessagesToEditor({ abort: true });\n } else if (this.session.isBashRunning) {\n this.session.abortBash();\n } else if (this.isBashMode) {\n this.editor.setText(\"\");\n this.isBashMode = false;\n this.updateEditorBorderColor();\n } else if (!this.editor.getText().trim()) {\n // Double-escape with empty editor triggers /tree, /fork, or nothing based on setting\n const action = this.settingsManager.getDoubleEscapeAction();\n if (action !== \"none\") {\n const now = Date.now();\n if (now - this.lastEscapeTime < 500) {\n if (action === \"tree\") {\n this.showTreeSelector();\n } else {\n this.showUserMessageSelector();\n }\n this.lastEscapeTime = 0;\n } else {\n this.lastEscapeTime = now;\n }\n }\n }\n };\n\n // Register app action handlers\n this.defaultEditor.onAction(\"app.clear\", () => this.handleCtrlC());\n this.defaultEditor.onCtrlD = () => this.handleCtrlD();\n this.defaultEditor.onAction(\"app.suspend\", () => this.handleCtrlZ());\n this.defaultEditor.onAction(\"app.thinking.cycle\", () =>\n this.cycleThinkingLevel(),\n );\n this.defaultEditor.onAction(\"app.model.cycleForward\", () =>\n this.cycleModel(\"forward\"),\n );\n this.defaultEditor.onAction(\"app.model.cycleBackward\", () =>\n this.cycleModel(\"backward\"),\n );\n\n // Global debug handler on TUI (works regardless of focus)\n this.ui.onDebug = () => this.handleDebugCommand();\n this.defaultEditor.onAction(\"app.model.select\", () =>\n this.showModelSelector(),\n );\n this.defaultEditor.onAction(\"app.tools.expand\", () =>\n this.toggleToolOutputExpansion(),\n );\n this.defaultEditor.onAction(\"app.thinking.toggle\", () =>\n this.toggleThinkingBlockVisibility(),\n );\n this.defaultEditor.onAction(\"app.editor.external\", () =>\n this.openExternalEditor(),\n );\n this.defaultEditor.onAction(\"app.message.followUp\", () =>\n this.handleFollowUp(),\n );\n this.defaultEditor.onAction(\"app.message.dequeue\", () =>\n this.handleDequeue(),\n );\n this.defaultEditor.onAction(\"app.session.new\", () =>\n this.handleClearCommand(),\n );\n this.defaultEditor.onAction(\"app.session.tree\", () =>\n this.showTreeSelector(),\n );\n this.defaultEditor.onAction(\"app.session.fork\", () =>\n this.showUserMessageSelector(),\n );\n this.defaultEditor.onAction(\"app.session.resume\", () =>\n this.showSessionSelector(),\n );\n\n this.defaultEditor.onChange = (text: string) => {\n const wasBashMode = this.isBashMode;\n this.isBashMode = text.trimStart().startsWith(\"!\");\n if (wasBashMode !== this.isBashMode) {\n this.updateEditorBorderColor();\n }\n };\n\n // Handle clipboard image paste (triggered on Ctrl+V)\n this.defaultEditor.onPasteImage = () => {\n this.handleClipboardImagePaste();\n };\n };\n\nInteractiveModeBase.prototype.handleClipboardImagePaste = async function(this: InteractiveModeBase): Promise<void> {\n await pasteClipboardImageToEditor(this.editor, () => this.ui.requestRender(), {\n showWarning: (message) => this.showWarning(message),\n });\n };\n\nInteractiveModeBase.prototype.setupEditorSubmitHandler = function(this: InteractiveModeBase): void {\n this.defaultEditor.onSubmit = async (text: string) => {\n text = text.trim();\n if (!text) return;\n\n // Handle commands\n if (text === \"/settings\") {\n this.showSettingsSelector();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/fast\") {\n this.editor.setText(\"\");\n this.showFastModeSelector();\n return;\n }\n if (text === \"/scoped-models\") {\n this.editor.setText(\"\");\n await this.showModelsSelector();\n return;\n }\n if (text === \"/model\" || text.startsWith(\"/model \")) {\n const searchTerm = text.startsWith(\"/model \")\n ? text.slice(7).trim()\n : undefined;\n this.editor.setText(\"\");\n await this.handleModelCommand(searchTerm);\n return;\n }\n if (text === \"/export\" || text.startsWith(\"/export \")) {\n await this.handleExportCommand(text);\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/import\" || text.startsWith(\"/import \")) {\n await this.handleImportCommand(text);\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/share\") {\n await this.handleShareCommand();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/copy\") {\n await this.handleCopyCommand();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/name\" || text.startsWith(\"/name \")) {\n this.handleNameCommand(text);\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/session\") {\n this.handleSessionCommand();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/changelog\") {\n this.handleChangelogCommand();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/atomic\" || text.startsWith(\"/atomic \")) {\n this.editor.setText(\"\");\n await this.session.prompt(text);\n return;\n }\n if (text === \"/hotkeys\") {\n this.handleHotkeysCommand();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/fork\") {\n this.showUserMessageSelector();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/clone\") {\n this.editor.setText(\"\");\n await this.handleCloneCommand();\n return;\n }\n if (text === \"/tree\") {\n this.showTreeSelector();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/trust\") {\n this.showTrustSelector();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/login\") {\n this.showOAuthSelector(\"login\");\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/logout\") {\n this.showOAuthSelector(\"logout\");\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/new\") {\n this.editor.setText(\"\");\n await this.handleClearCommand();\n return;\n }\n if (/^\\/compact(?:\\s|$)/.test(text)) {\n this.editor.setText(\"\");\n if (text !== \"/compact\") {\n this.showWarning(\"Usage: /compact\");\n return;\n }\n await this.handleCompactCommand();\n return;\n }\n if (text === \"/reload\") {\n this.editor.setText(\"\");\n await this.handleReloadCommand();\n return;\n }\n if (text === \"/debug\") {\n this.handleDebugCommand();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/arminsayshi\") {\n this.handleArminSaysHi();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/dementedelves\") {\n this.handleDementedDelves();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/resume\") {\n this.showSessionSelector();\n this.editor.setText(\"\");\n return;\n }\n if (text === \"/quit\" || text === \"/exit\") {\n this.editor.setText(\"\");\n await this.shutdown();\n return;\n }\n\n // Handle bash command (! for normal, !! for excluded from context)\n if (text.startsWith(\"!\")) {\n const isExcluded = text.startsWith(\"!!\");\n const command = isExcluded\n ? text.slice(2).trim()\n : text.slice(1).trim();\n if (command) {\n if (this.session.isBashRunning) {\n this.showWarning(\n \"A bash command is already running. esc cancel first.\",\n );\n this.editor.setText(text);\n return;\n }\n this.editor.addToHistory?.(text);\n await this.handleBashCommand(command, isExcluded);\n this.isBashMode = false;\n this.updateEditorBorderColor();\n return;\n }\n }\n\n // Queue input during compaction (extension commands execute immediately)\n if (this.session.isCompacting) {\n if (this.isExtensionCommand(text)) {\n this.editor.addToHistory?.(text);\n this.editor.setText(\"\");\n await this.session.prompt(text);\n } else {\n this.queueCompactionMessage(text, \"steer\");\n }\n return;\n }\n\n // If streaming, use prompt() with steer behavior\n // This handles extension commands (execute immediately), prompt template expansion, and queueing\n if (this.session.isStreaming) {\n this.editor.addToHistory?.(text);\n this.editor.setText(\"\");\n await this.session.prompt(text, { streamingBehavior: \"steer\" });\n this.updatePendingMessagesDisplay();\n this.ui.requestRender();\n return;\n }\n\n // Normal message submission\n // First, move any pending bash components to chat\n this.flushPendingBashComponents();\n\n if (this.onInputCallback) {\n if (!text.startsWith(\"/\")) {\n this.renderDeferredUserInput(text);\n }\n this.onInputCallback(text);\n } else {\n this.pendingUserInputs.push(text);\n }\n this.editor.addToHistory?.(text);\n };\n };\n"]}
@@ -1,6 +1,51 @@
1
1
  import { InteractiveModeBase } from "./interactive-mode-base.js";
2
2
  import { pasteClipboardImageToEditor } from "./interactive-mode-deps.js";
3
+ import { yieldToEventLoop } from "../../utils/event-loop.js";
4
+ InteractiveModeBase.prototype.runUserPromptTurn = async function (userInput) {
5
+ // Show the working spinner immediately on submit so there is no visible gap
6
+ // while prompt preflight runs before the agent emits `agent_start`.
7
+ this.showWorkingLoaderNow();
8
+ if (this.deferredStartupPending) {
9
+ this.deferLoadedResourcesDisclosureUntilAgentEnd = true;
10
+ }
11
+ // Yield once so the freshly-mounted spinner paints before synchronous
12
+ // preflight work can block the event loop.
13
+ await yieldToEventLoop();
14
+ try {
15
+ await this.ensureDeferredStartupComplete();
16
+ await this.session.prompt(userInput);
17
+ this.deferLoadedResourcesDisclosureUntilAgentEnd = false;
18
+ if (this.pendingLoadedResourcesDisclosure) {
19
+ this.pendingLoadedResourcesDisclosure = false;
20
+ this.showLoadedResources({ force: true, showDiagnosticsWhenQuiet: true, targetContainer: this.startupNoticesContainer });
21
+ void this.maybeWarnAboutAnthropicSubscriptionAuth(undefined, this.startupNoticesContainer);
22
+ }
23
+ }
24
+ catch (error) {
25
+ this.deferLoadedResourcesDisclosureUntilAgentEnd = false;
26
+ this.discardDeferredRenderedUserInput(userInput);
27
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
28
+ this.showError(errorMessage);
29
+ }
30
+ finally {
31
+ // A submission that resolves without starting an agent turn (e.g. an
32
+ // extension slash-command) never emits `agent_end`, so clear the
33
+ // pre-shown spinner here when idle to avoid a lingering indicator.
34
+ if (!this.session.isStreaming) {
35
+ this.stopWorkingLoader();
36
+ }
37
+ }
38
+ };
3
39
  InteractiveModeBase.prototype.setupKeyHandlers = function () {
40
+ this.ui.addInputListener((data) => {
41
+ if (!this.keybindings.matches(data, "app.clear"))
42
+ return undefined;
43
+ if (this.ui.hasOverlay())
44
+ return undefined;
45
+ this.handleCtrlC();
46
+ this.ui.requestRender();
47
+ return { consume: true };
48
+ });
4
49
  // Set up handlers on defaultEditor - they use this.editor for text access
5
50
  // so they work correctly regardless of which editor is active
6
51
  this.defaultEditor.onEscape = () => {
@@ -264,6 +309,9 @@ InteractiveModeBase.prototype.setupEditorSubmitHandler = function () {
264
309
  // First, move any pending bash components to chat
265
310
  this.flushPendingBashComponents();
266
311
  if (this.onInputCallback) {
312
+ if (!text.startsWith("/")) {
313
+ this.renderDeferredUserInput(text);
314
+ }
267
315
  this.onInputCallback(text);
268
316
  }
269
317
  else {