@bastani/atomic 0.9.84 → 0.9.85-alpha.1

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 (183) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  3. package/dist/builtin/intercom/broker/broker.ts +25 -7
  4. package/dist/builtin/intercom/broker/spawn.ts +83 -17
  5. package/dist/builtin/intercom/index.bundle.mjs +89 -26
  6. package/dist/builtin/intercom/package.json +1 -1
  7. package/dist/builtin/mcp/package.json +1 -1
  8. package/dist/builtin/subagents/package.json +1 -1
  9. package/dist/builtin/web-access/package.json +1 -1
  10. package/dist/builtin/workflows/CHANGELOG.md +6 -0
  11. package/dist/builtin/workflows/package.json +1 -1
  12. package/dist/builtin/workflows/src/authoring.d.ts +1 -1
  13. package/dist/builtin/workflows/src/extension/index.bundle.mjs +48 -9
  14. package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +48 -9
  15. package/dist/builtin/workflows/src/index.js +48 -9
  16. package/dist/builtin/workflows/src/local-worker-entry.mjs +48 -9
  17. package/dist/config.d.ts +3 -2
  18. package/dist/config.d.ts.map +1 -1
  19. package/dist/config.js +4 -3
  20. package/dist/config.js.map +1 -1
  21. package/dist/core/agent-session-export.d.ts +2 -2
  22. package/dist/core/agent-session-export.d.ts.map +1 -1
  23. package/dist/core/agent-session-export.js +4 -5
  24. package/dist/core/agent-session-export.js.map +1 -1
  25. package/dist/core/agent-session-services.js +1 -1
  26. package/dist/core/agent-session-services.js.map +1 -1
  27. package/dist/core/agent-session-summary.d.ts.map +1 -1
  28. package/dist/core/agent-session-summary.js +8 -1
  29. package/dist/core/agent-session-summary.js.map +1 -1
  30. package/dist/core/agent-session-tree.d.ts.map +1 -1
  31. package/dist/core/agent-session-tree.js +3 -6
  32. package/dist/core/agent-session-tree.js.map +1 -1
  33. package/dist/core/builtin-resource-loader.d.ts.map +1 -1
  34. package/dist/core/builtin-resource-loader.js +1 -1
  35. package/dist/core/builtin-resource-loader.js.map +1 -1
  36. package/dist/core/extensions/loader-core.d.ts +6 -2
  37. package/dist/core/extensions/loader-core.d.ts.map +1 -1
  38. package/dist/core/extensions/loader-core.js +13 -9
  39. package/dist/core/extensions/loader-core.js.map +1 -1
  40. package/dist/core/extensions/loader-discovery.js +1 -1
  41. package/dist/core/extensions/loader-discovery.js.map +1 -1
  42. package/dist/core/extensions/loader-virtual-modules.d.ts +20 -14
  43. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  44. package/dist/core/extensions/loader-virtual-modules.js +133 -78
  45. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  46. package/dist/core/extensions/ts-source-specifiers.d.ts +1 -0
  47. package/dist/core/extensions/ts-source-specifiers.d.ts.map +1 -1
  48. package/dist/core/extensions/ts-source-specifiers.js +18 -2
  49. package/dist/core/extensions/ts-source-specifiers.js.map +1 -1
  50. package/dist/core/mandatory-resource-loader.d.ts +5 -2
  51. package/dist/core/mandatory-resource-loader.d.ts.map +1 -1
  52. package/dist/core/mandatory-resource-loader.js +17 -12
  53. package/dist/core/mandatory-resource-loader.js.map +1 -1
  54. package/dist/core/model-fallback-failures.d.ts.map +1 -1
  55. package/dist/core/model-fallback-failures.js +10 -3
  56. package/dist/core/model-fallback-failures.js.map +1 -1
  57. package/dist/core/resource-loader-extensions.d.ts.map +1 -1
  58. package/dist/core/resource-loader-extensions.js +1 -1
  59. package/dist/core/resource-loader-extensions.js.map +1 -1
  60. package/dist/core/resource-loader-reload.js +1 -1
  61. package/dist/core/resource-loader-reload.js.map +1 -1
  62. package/dist/core/resume/blueprint/resume.d.ts +4 -4
  63. package/dist/core/resume/blueprint/resume.js +4 -4
  64. package/dist/core/resume/blueprint/resume.js.map +1 -1
  65. package/dist/core/resume/session-resume.d.ts +6 -3
  66. package/dist/core/resume/session-resume.d.ts.map +1 -1
  67. package/dist/core/resume/session-resume.js +159 -37
  68. package/dist/core/resume/session-resume.js.map +1 -1
  69. package/dist/core/sdk.js +1 -1
  70. package/dist/core/sdk.js.map +1 -1
  71. package/dist/core/session-manager-core.d.ts +10 -4
  72. package/dist/core/session-manager-core.d.ts.map +1 -1
  73. package/dist/core/session-manager-core.js +23 -6
  74. package/dist/core/session-manager-core.js.map +1 -1
  75. package/dist/core/session-manager-entries.d.ts +2 -2
  76. package/dist/core/session-manager-entries.d.ts.map +1 -1
  77. package/dist/core/session-manager-entries.js +2 -1
  78. package/dist/core/session-manager-entries.js.map +1 -1
  79. package/dist/core/session-manager-history.d.ts +13 -1
  80. package/dist/core/session-manager-history.d.ts.map +1 -1
  81. package/dist/core/session-manager-history.js +21 -1
  82. package/dist/core/session-manager-history.js.map +1 -1
  83. package/dist/core/session-manager-types.d.ts +3 -1
  84. package/dist/core/session-manager-types.d.ts.map +1 -1
  85. package/dist/core/session-manager-types.js.map +1 -1
  86. package/dist/core/session-manager.d.ts +1 -1
  87. package/dist/core/session-manager.d.ts.map +1 -1
  88. package/dist/core/session-manager.js +1 -1
  89. package/dist/core/session-manager.js.map +1 -1
  90. package/dist/core/session-worktree-snapshots.d.ts +61 -4
  91. package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
  92. package/dist/core/session-worktree-snapshots.js +261 -28
  93. package/dist/core/session-worktree-snapshots.js.map +1 -1
  94. package/dist/core/storage/session/entry-structure.js +31 -1
  95. package/dist/core/storage/session/entry-structure.js.map +1 -1
  96. package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts.map +1 -1
  97. package/dist/core/tools/ask-user-question/state/build-questionnaire.js +2 -1
  98. package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
  99. package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts.map +1 -1
  100. package/dist/core/tools/ask-user-question/state/questionnaire-session.js +2 -0
  101. package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
  102. package/dist/core/tools/ask-user-question/state/selectors/field-tone.d.ts +26 -0
  103. package/dist/core/tools/ask-user-question/state/selectors/field-tone.d.ts.map +1 -0
  104. package/dist/core/tools/ask-user-question/state/selectors/field-tone.js +27 -0
  105. package/dist/core/tools/ask-user-question/state/selectors/field-tone.js.map +1 -0
  106. package/dist/core/tools/ask-user-question/state/selectors/projections.d.ts.map +1 -1
  107. package/dist/core/tools/ask-user-question/state/selectors/projections.js +1 -0
  108. package/dist/core/tools/ask-user-question/state/selectors/projections.js.map +1 -1
  109. package/dist/core/tools/ask-user-question/state/state-reducer.js +1 -1
  110. package/dist/core/tools/ask-user-question/state/state-reducer.js.map +1 -1
  111. package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts.map +1 -1
  112. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js +6 -6
  113. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
  114. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +5 -3
  115. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts.map +1 -1
  116. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js +14 -4
  117. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
  118. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts +2 -0
  119. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.d.ts.map +1 -1
  120. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js +3 -3
  121. package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js.map +1 -1
  122. package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts +16 -6
  123. package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts.map +1 -1
  124. package/dist/core/tools/ask-user-question/view/components/wrapping-select.js +42 -24
  125. package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
  126. package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts.map +1 -1
  127. package/dist/core/tools/ask-user-question/view/tab-content-strategy.js +12 -3
  128. package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
  129. package/dist/core/tools/read.d.ts +1 -0
  130. package/dist/core/tools/read.d.ts.map +1 -1
  131. package/dist/core/tools/read.js +13 -14
  132. package/dist/core/tools/read.js.map +1 -1
  133. package/dist/core/worktree-snapshot/index.d.ts +2 -2
  134. package/dist/core/worktree-snapshot/index.d.ts.map +1 -1
  135. package/dist/core/worktree-snapshot/index.js +1 -1
  136. package/dist/core/worktree-snapshot/index.js.map +1 -1
  137. package/dist/core/worktree-snapshot/records.d.ts +6 -0
  138. package/dist/core/worktree-snapshot/records.d.ts.map +1 -1
  139. package/dist/core/worktree-snapshot/records.js +18 -4
  140. package/dist/core/worktree-snapshot/records.js.map +1 -1
  141. package/dist/core/worktree-snapshot/restore.d.ts +24 -1
  142. package/dist/core/worktree-snapshot/restore.d.ts.map +1 -1
  143. package/dist/core/worktree-snapshot/restore.js +443 -72
  144. package/dist/core/worktree-snapshot/restore.js.map +1 -1
  145. package/dist/core/worktree-snapshot/types.d.ts +44 -0
  146. package/dist/core/worktree-snapshot/types.d.ts.map +1 -1
  147. package/dist/core/worktree-snapshot/types.js.map +1 -1
  148. package/dist/index.d.ts +2 -2
  149. package/dist/index.d.ts.map +1 -1
  150. package/dist/index.js +2 -2
  151. package/dist/index.js.map +1 -1
  152. package/dist/modes/interactive/components/tool-execution.js +2 -1
  153. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  154. package/dist/modes/interactive/interactive-slash-commands.js +4 -1
  155. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  156. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  157. package/dist/modes/interactive-engine/isolated-runtime.js +8 -0
  158. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  159. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  160. package/dist/modes/rpc/rpc-command-handler.js +11 -2
  161. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  162. package/dist/modes/rpc/rpc-command-timeouts.d.ts.map +1 -1
  163. package/dist/modes/rpc/rpc-command-timeouts.js +1 -0
  164. package/dist/modes/rpc/rpc-command-timeouts.js.map +1 -1
  165. package/dist/modes/rpc/rpc-input-scheduler.d.ts.map +1 -1
  166. package/dist/modes/rpc/rpc-input-scheduler.js +1 -0
  167. package/dist/modes/rpc/rpc-input-scheduler.js.map +1 -1
  168. package/dist/modes/rpc/rpc-types.d.ts +11 -1
  169. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  170. package/dist/modes/rpc/rpc-types.js.map +1 -1
  171. package/docs/environment-variables.md +1 -1
  172. package/docs/guides/resume-on-any-machine.md +6 -4
  173. package/docs/intercom/operations.md +4 -0
  174. package/docs/rpc/protocol.md +2 -2
  175. package/docs/sdk/reference.md +3 -0
  176. package/docs/sdk.md +2 -2
  177. package/docs/session-format.md +11 -2
  178. package/docs/sessions.md +4 -2
  179. package/docs/settings.md +1 -1
  180. package/docs/workflows/api-reference.md +2 -2
  181. package/docs/worktree-snapshots.md +13 -5
  182. package/npm-shrinkwrap.json +32 -32
  183. package/package.json +3 -3
@@ -36,7 +36,7 @@ export class PreviewPane {
36
36
  this.getTerminalWidth = config.getTerminalWidth;
37
37
  this.optionListView = config.optionListView;
38
38
  this.previewBlock = config.previewBlock;
39
- this.props = { notesVisible: false, selectedIndex: 0, focused: false };
39
+ this.props = { notesVisible: false, selectedIndex: 0, focused: false, notes: "" };
40
40
  }
41
41
  setGlobalLeftWidth(getter) {
42
42
  this.globalLeftWidth = getter;
@@ -65,7 +65,7 @@ export class PreviewPane {
65
65
  return [
66
66
  ...this.optionListView.render(width),
67
67
  ...Array(STACKED_GAP_ROWS).fill(""),
68
- ...this.previewBlock.renderBlock(width, this.props.selectedIndex, mode, this.props.focused, this.props.notesVisible),
68
+ ...this.previewBlock.renderBlock(width, this.props.selectedIndex, mode, this.props.focused, this.props.notesVisible, this.props.notes),
69
69
  ];
70
70
  }
71
71
  maxNaturalHeight(width) {
@@ -107,7 +107,7 @@ export class PreviewPane {
107
107
  }
108
108
  renderPaddedPreviewLines(colWidth, mode) {
109
109
  const inner = Math.max(1, colWidth - PREVIEW_PADDING_LEFT);
110
- const contentLines = this.previewBlock.renderBlock(inner, this.props.selectedIndex, mode, this.props.focused, this.props.notesVisible);
110
+ const contentLines = this.previewBlock.renderBlock(inner, this.props.selectedIndex, mode, this.props.focused, this.props.notesVisible, this.props.notes);
111
111
  const pad = " ".repeat(PREVIEW_PADDING_LEFT);
112
112
  return contentLines.map((l) => (l === "" ? "" : `${pad}${l}`));
113
113
  }
@@ -1 +1 @@
1
- {"version":3,"file":"preview-pane.js","sourceRoot":"","sources":["../../../../../../../src/core/tools/ask-user-question/view/components/preview/preview-pane.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAKvF,OAAO,EACN,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,oBAAoB,EAEpB,gBAAgB,GAChB,MAAM,6BAA6B,CAAC;AAErC,2FAA2F;AAC3F,OAAO,EACN,+BAA+B,EAC/B,0BAA0B,EAC1B,eAAe,EACf,yBAAyB,GACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAC1F,OAAO,EACN,0BAA0B,EAC1B,+BAA+B,EAC/B,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,GACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,GAChB,MAAM,6BAA6B,CAAC;AAwBrC;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,WAAW;IACN,QAAQ,CAAe;IACvB,gBAAgB,CAAe;IAC/B,cAAc,CAAiB;IAC/B,YAAY,CAAuB;IAC5C,KAAK,CAAmB;IAChC;;;;OAIG;IACK,eAAe,GAAkC,GAAG,EAAE;QAC7D,MAAM,IAAI,KA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AAC,GAAG,CAAC,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC/E,MAAM,MAAM,GAAG,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,EAAE,CAAC;YAC9D,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IAEO,wBAAwB,CAAC,QAAgB,EAAE,IAAuB;QACzE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,oBAAoB,CAAC,CAAC;QAC3D,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CACjD,KAAK,EACL,IAAI,CAAC,KAAK,CAAC,aAAa,EACxB,IAAI,EACJ,IAAI,CAAC,KAAK,CAAC,OAAO,EAClB,IAAI,CAAC,KAAK,CAAC,YAAY,CACvB,CAAC;QACF,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;QAC7C,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAChE,CAAC;CACD","sourcesContent":["import { type Component, truncateToWidth, visibleWidth } from \"@earendil-works/pi-tui\";\nimport type { QuestionData } from \"../../../tool/types.js\";\nimport type { StatefulView } from \"../../stateful-view.ts\";\nimport type { OptionListView } from \"../option-list-view.ts\";\nimport type { PreviewBlockRenderer } from \"./preview-block-renderer.ts\";\nimport {\n\tbodyWidths,\n\tcolumnWidths,\n\tdecideLayout,\n\tPREVIEW_PADDING_LEFT,\n\ttype PreviewLayoutMode,\n\tSTACKED_GAP_ROWS,\n} from \"./preview-layout-decider.ts\";\n\n// ----- Re-exports for test imports — keep `./preview-pane.js` as the public surface -----\nexport {\n\tMAX_PREVIEW_HEIGHT_SIDE_BY_SIDE,\n\tMAX_PREVIEW_HEIGHT_STACKED,\n\tNO_PREVIEW_TEXT,\n\tNOTES_AFFORDANCE_OVERHEAD,\n} from \"./markdown-content-cache.ts\";\nexport { NOTES_AFFORDANCE_TEXT, PreviewBlockRenderer } from \"./preview-block-renderer.ts\";\nexport {\n\tBORDER_HORIZONTAL_OVERHEAD,\n\tBORDER_INNER_PADDING_HORIZONTAL,\n\tBORDER_VERTICAL_OVERHEAD,\n\tBOX_MIN_CONTENT_WIDTH,\n\trenderBorderedBox,\n\tstripFenceMarkers,\n} from \"./preview-box-renderer.ts\";\nexport {\n\tPREVIEW_COLUMN_GAP,\n\tPREVIEW_MIN_WIDTH,\n\tPREVIEW_PADDING_LEFT,\n\tSTACKED_GAP_ROWS,\n} from \"./preview-layout-decider.ts\";\n\n/**\n * Per-tick projection of PreviewPane state. Replaces the prior\n * `setNotesVisible(boolean)` sliver-setter and the sibling reads of\n * `optionListView.getSelectedIndex()` / `isFocused()`. The pane now reads\n * `selectedIndex` and `focused` from its own props — both derived from\n * canonical state via `selectPreviewPaneProps`. `OptionListView` and\n * `PreviewPane` see the same source of truth without the cross-component\n * live read.\n */\nexport interface PreviewPaneProps {\n\tnotesVisible: boolean;\n\tselectedIndex: number;\n\tfocused: boolean;\n}\n\nexport interface PreviewPaneConfig {\n\tquestion: QuestionData;\n\tgetTerminalWidth: () => number;\n\toptionListView: OptionListView;\n\tpreviewBlock: PreviewBlockRenderer;\n}\n\n/**\n * Thin layout composer. Receives `selectedIndex` / `focused` / `notesVisible`\n * via `setProps` per tick (computed by `selectPreviewPaneProps` from canonical\n * state). Delegates option-side rendering to `OptionListView` (which still\n * owns its render-time state — input buffer, confirmedIndex) and preview-side\n * rendering to `PreviewBlockRenderer` (which owns the markdown cache and\n * bordered-box composition).\n *\n * `maxNaturalHeight` reads both children's heights from their cached layouts;\n * `render` combines them via `decideLayout` (mode threaded into both calls —\n * never re-derived).\n */\nexport class PreviewPane implements StatefulView<PreviewPaneProps>, Component {\n\tprivate readonly question: QuestionData;\n\tprivate readonly getTerminalWidth: () => number;\n\tprivate readonly optionListView: OptionListView;\n\tprivate readonly previewBlock: PreviewBlockRenderer;\n\tprivate props: PreviewPaneProps;\n\t/**\n\t * Cross-tab max left-width getter. Set exactly once by `buildQuestionnaire.injectGlobalLeftWidth`\n\t * before any render. Initialized to a throwing sentinel so missing injection is a hard fail\n\t * rather than a silent fallback to a magic constant — render is illegal until injected.\n\t */\n\tprivate globalLeftWidth: (paneWidth: number) => number = () => {\n\t\tthrow new Error(\"PreviewPane.setGlobalLeftWidth must be called before render()\");\n\t};\n\n\tconstructor(config: PreviewPaneConfig) {\n\t\tthis.question = config.question;\n\t\tthis.getTerminalWidth = config.getTerminalWidth;\n\t\tthis.optionListView = config.optionListView;\n\t\tthis.previewBlock = config.previewBlock;\n\t\tthis.props = { notesVisible: false, selectedIndex: 0, focused: false };\n\t}\n\n\tsetGlobalLeftWidth(getter: (paneWidth: number) => number): void {\n\t\tthis.globalLeftWidth = getter;\n\t}\n\n\tprivate getAdaptiveLeft(paneWidth: number): number {\n\t\treturn this.globalLeftWidth(paneWidth);\n\t}\n\n\tsetProps(props: PreviewPaneProps): void {\n\t\tthis.props = props;\n\t}\n\n\thandleInput(_data: string): void {}\n\n\tinvalidate(): void {\n\t\tthis.previewBlock.invalidate();\n\t\tthis.optionListView.invalidate();\n\t}\n\n\trender(width: number): string[] {\n\t\tif (this.question.multiSelect === true) return this.optionListView.render(width);\n\t\t// Spec: hide the preview pane entirely when no option carries a `preview`.\n\t\tif (!this.previewBlock.hasAnyPreview()) return this.optionListView.render(width);\n\n\t\tconst mode = decideLayout(this.getTerminalWidth(), width);\n\t\tif (mode === \"side-by-side\") return this.renderSideBySide(width, mode);\n\n\t\t// Stacked: options + blank gap + preview block.\n\t\treturn [\n\t\t\t...this.optionListView.render(width),\n\t\t\t...Array(STACKED_GAP_ROWS).fill(\"\"),\n\t\t\t...this.previewBlock.renderBlock(\n\t\t\t\twidth,\n\t\t\t\tthis.props.selectedIndex,\n\t\t\t\tmode,\n\t\t\t\tthis.props.focused,\n\t\t\t\tthis.props.notesVisible,\n\t\t\t),\n\t\t];\n\t}\n\n\tmaxNaturalHeight(width: number): number {\n\t\tif (this.question.multiSelect === true) return this.optionListView.height(width);\n\t\tif (!this.previewBlock.hasAnyPreview()) return this.optionListView.height(width);\n\t\tconst mode = decideLayout(this.getTerminalWidth(), width);\n\t\tconst adaptiveLeft = this.getAdaptiveLeft(width);\n\t\tconst { optionsWidth, previewWidth } = bodyWidths(width, mode, adaptiveLeft);\n\t\tconst optionsHeight = this.optionListView.height(optionsWidth);\n\t\tlet maxPreviewBlock = 0;\n\t\tfor (let i = 0; i < this.question.options.length; i++) {\n\t\t\tconst h = this.previewBlock.blockHeight(previewWidth, i, mode);\n\t\t\tif (h > maxPreviewBlock) maxPreviewBlock = h;\n\t\t}\n\t\tif (mode === \"side-by-side\") return Math.max(optionsHeight, maxPreviewBlock);\n\t\treturn optionsHeight + STACKED_GAP_ROWS + maxPreviewBlock;\n\t}\n\n\tprivate renderSideBySide(width: number, mode: PreviewLayoutMode): string[] {\n\t\tconst adaptiveLeft = this.getAdaptiveLeft(width);\n\t\tconst { leftWidth, rightWidth, gap } = columnWidths(width, adaptiveLeft);\n\t\tconst leftLines = this.optionListView.render(leftWidth);\n\t\tconst rightLines = this.renderPaddedPreviewLines(rightWidth, mode);\n\t\tconst rows = Math.max(leftLines.length, rightLines.length);\n\t\tconst gapStr = \" \".repeat(gap);\n\t\tconst out: string[] = [];\n\t\tfor (let i = 0; i < rows; i++) {\n\t\t\tconst leftRaw = leftLines[i] ?? \"\";\n\t\t\tconst rightRaw = rightLines[i] ?? \"\";\n\t\t\tconst leftClamped = truncateToWidth(leftRaw, leftWidth, \"\");\n\t\t\tconst leftPad = \" \".repeat(Math.max(0, leftWidth - visibleWidth(leftClamped)));\n\t\t\tconst joined = `${leftClamped}${leftPad}${gapStr}${rightRaw}`;\n\t\t\tout.push(truncateToWidth(joined, width, \"\"));\n\t\t}\n\t\treturn out;\n\t}\n\n\tprivate renderPaddedPreviewLines(colWidth: number, mode: PreviewLayoutMode): string[] {\n\t\tconst inner = Math.max(1, colWidth - PREVIEW_PADDING_LEFT);\n\t\tconst contentLines = this.previewBlock.renderBlock(\n\t\t\tinner,\n\t\t\tthis.props.selectedIndex,\n\t\t\tmode,\n\t\t\tthis.props.focused,\n\t\t\tthis.props.notesVisible,\n\t\t);\n\t\tconst pad = \" \".repeat(PREVIEW_PADDING_LEFT);\n\t\treturn contentLines.map((l) => (l === \"\" ? \"\" : `${pad}${l}`));\n\t}\n}\n"]}
1
+ {"version":3,"file":"preview-pane.js","sourceRoot":"","sources":["../../../../../../../src/core/tools/ask-user-question/view/components/preview/preview-pane.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,eAAe,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAKvF,OAAO,EACN,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,oBAAoB,EAEpB,gBAAgB,GAChB,MAAM,6BAA6B,CAAC;AAErC,2FAA2F;AAC3F,OAAO,EACN,+BAA+B,EAC/B,0BAA0B,EAC1B,eAAe,EACf,yBAAyB,GACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAC1F,OAAO,EACN,0BAA0B,EAC1B,+BAA+B,EAC/B,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,GACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,GAChB,MAAM,6BAA6B,CAAC;AA0BrC;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,WAAW;IACN,QAAQ,CAAe;IACvB,gBAAgB,CAAe;I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AQ,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YACrC,MAAM,WAAW,GAAG,eAAe,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;YAC5D,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC/E,MAAM,MAAM,GAAG,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,EAAE,CAAC;YAC9D,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IAEO,wBAAwB,CAAC,QAAgB,EAAE,IAAuB;QACzE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,oBAAoB,CAAC,CAAC;QAC3D,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CACjD,KAAK,EACL,IAAI,CAAC,KAAK,CAAC,aAAa,EACxB,IAAI,EACJ,IAAI,CAAC,KAAK,CAAC,OAAO,EAClB,IAAI,CAAC,KAAK,CAAC,YAAY,EACvB,IAAI,CAAC,KAAK,CAAC,KAAK,CAChB,CAAC;QACF,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;QAC7C,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAChE,CAAC;CACD","sourcesContent":["import { type Component, truncateToWidth, visibleWidth } from \"@earendil-works/pi-tui\";\nimport type { QuestionData } from \"../../../tool/types.js\";\nimport type { StatefulView } from \"../../stateful-view.ts\";\nimport type { OptionListView } from \"../option-list-view.ts\";\nimport type { PreviewBlockRenderer } from \"./preview-block-renderer.ts\";\nimport {\n\tbodyWidths,\n\tcolumnWidths,\n\tdecideLayout,\n\tPREVIEW_PADDING_LEFT,\n\ttype PreviewLayoutMode,\n\tSTACKED_GAP_ROWS,\n} from \"./preview-layout-decider.ts\";\n\n// ----- Re-exports for test imports — keep `./preview-pane.js` as the public surface -----\nexport {\n\tMAX_PREVIEW_HEIGHT_SIDE_BY_SIDE,\n\tMAX_PREVIEW_HEIGHT_STACKED,\n\tNO_PREVIEW_TEXT,\n\tNOTES_AFFORDANCE_OVERHEAD,\n} from \"./markdown-content-cache.ts\";\nexport { NOTES_AFFORDANCE_TEXT, PreviewBlockRenderer } from \"./preview-block-renderer.ts\";\nexport {\n\tBORDER_HORIZONTAL_OVERHEAD,\n\tBORDER_INNER_PADDING_HORIZONTAL,\n\tBORDER_VERTICAL_OVERHEAD,\n\tBOX_MIN_CONTENT_WIDTH,\n\trenderBorderedBox,\n\tstripFenceMarkers,\n} from \"./preview-box-renderer.ts\";\nexport {\n\tPREVIEW_COLUMN_GAP,\n\tPREVIEW_MIN_WIDTH,\n\tPREVIEW_PADDING_LEFT,\n\tSTACKED_GAP_ROWS,\n} from \"./preview-layout-decider.ts\";\n\n/**\n * Per-tick projection of PreviewPane state. Replaces the prior\n * `setNotesVisible(boolean)` sliver-setter and the sibling reads of\n * `optionListView.getSelectedIndex()` / `isFocused()`. The pane now reads\n * `selectedIndex` and `focused` from its own props — both derived from\n * canonical state via `selectPreviewPaneProps`. `OptionListView` and\n * `PreviewPane` see the same source of truth without the cross-component\n * live read.\n */\nexport interface PreviewPaneProps {\n\tnotesVisible: boolean;\n\tselectedIndex: number;\n\tfocused: boolean;\n\t/** Saved notes for the active question; shown on the affordance row while notes mode is closed. */\n\tnotes: string;\n}\n\nexport interface PreviewPaneConfig {\n\tquestion: QuestionData;\n\tgetTerminalWidth: () => number;\n\toptionListView: OptionListView;\n\tpreviewBlock: PreviewBlockRenderer;\n}\n\n/**\n * Thin layout composer. Receives `selectedIndex` / `focused` / `notesVisible`\n * via `setProps` per tick (computed by `selectPreviewPaneProps` from canonical\n * state). Delegates option-side rendering to `OptionListView` (which still\n * owns its render-time state — input buffer, confirmedIndex) and preview-side\n * rendering to `PreviewBlockRenderer` (which owns the markdown cache and\n * bordered-box composition).\n *\n * `maxNaturalHeight` reads both children's heights from their cached layouts;\n * `render` combines them via `decideLayout` (mode threaded into both calls —\n * never re-derived).\n */\nexport class PreviewPane implements StatefulView<PreviewPaneProps>, Component {\n\tprivate readonly question: QuestionData;\n\tprivate readonly getTerminalWidth: () => number;\n\tprivate readonly optionListView: OptionListView;\n\tprivate readonly previewBlock: PreviewBlockRenderer;\n\tprivate props: PreviewPaneProps;\n\t/**\n\t * Cross-tab max left-width getter. Set exactly once by `buildQuestionnaire.injectGlobalLeftWidth`\n\t * before any render. Initialized to a throwing sentinel so missing injection is a hard fail\n\t * rather than a silent fallback to a magic constant — render is illegal until injected.\n\t */\n\tprivate globalLeftWidth: (paneWidth: number) => number = () => {\n\t\tthrow new Error(\"PreviewPane.setGlobalLeftWidth must be called before render()\");\n\t};\n\n\tconstructor(config: PreviewPaneConfig) {\n\t\tthis.question = config.question;\n\t\tthis.getTerminalWidth = config.getTerminalWidth;\n\t\tthis.optionListView = config.optionListView;\n\t\tthis.previewBlock = config.previewBlock;\n\t\tthis.props = { notesVisible: false, selectedIndex: 0, focused: false, notes: \"\" };\n\t}\n\n\tsetGlobalLeftWidth(getter: (paneWidth: number) => number): void {\n\t\tthis.globalLeftWidth = getter;\n\t}\n\n\tprivate getAdaptiveLeft(paneWidth: number): number {\n\t\treturn this.globalLeftWidth(paneWidth);\n\t}\n\n\tsetProps(props: PreviewPaneProps): void {\n\t\tthis.props = props;\n\t}\n\n\thandleInput(_data: string): void {}\n\n\tinvalidate(): void {\n\t\tthis.previewBlock.invalidate();\n\t\tthis.optionListView.invalidate();\n\t}\n\n\trender(width: number): string[] {\n\t\tif (this.question.multiSelect === true) return this.optionListView.render(width);\n\t\t// Spec: hide the preview pane entirely when no option carries a `preview`.\n\t\tif (!this.previewBlock.hasAnyPreview()) return this.optionListView.render(width);\n\n\t\tconst mode = decideLayout(this.getTerminalWidth(), width);\n\t\tif (mode === \"side-by-side\") return this.renderSideBySide(width, mode);\n\n\t\t// Stacked: options + blank gap + preview block.\n\t\treturn [\n\t\t\t...this.optionListView.render(width),\n\t\t\t...Array(STACKED_GAP_ROWS).fill(\"\"),\n\t\t\t...this.previewBlock.renderBlock(\n\t\t\t\twidth,\n\t\t\t\tthis.props.selectedIndex,\n\t\t\t\tmode,\n\t\t\t\tthis.props.focused,\n\t\t\t\tthis.props.notesVisible,\n\t\t\t\tthis.props.notes,\n\t\t\t),\n\t\t];\n\t}\n\n\tmaxNaturalHeight(width: number): number {\n\t\tif (this.question.multiSelect === true) return this.optionListView.height(width);\n\t\tif (!this.previewBlock.hasAnyPreview()) return this.optionListView.height(width);\n\t\tconst mode = decideLayout(this.getTerminalWidth(), width);\n\t\tconst adaptiveLeft = this.getAdaptiveLeft(width);\n\t\tconst { optionsWidth, previewWidth } = bodyWidths(width, mode, adaptiveLeft);\n\t\tconst optionsHeight = this.optionListView.height(optionsWidth);\n\t\tlet maxPreviewBlock = 0;\n\t\tfor (let i = 0; i < this.question.options.length; i++) {\n\t\t\tconst h = this.previewBlock.blockHeight(previewWidth, i, mode);\n\t\t\tif (h > maxPreviewBlock) maxPreviewBlock = h;\n\t\t}\n\t\tif (mode === \"side-by-side\") return Math.max(optionsHeight, maxPreviewBlock);\n\t\treturn optionsHeight + STACKED_GAP_ROWS + maxPreviewBlock;\n\t}\n\n\tprivate renderSideBySide(width: number, mode: PreviewLayoutMode): string[] {\n\t\tconst adaptiveLeft = this.getAdaptiveLeft(width);\n\t\tconst { leftWidth, rightWidth, gap } = columnWidths(width, adaptiveLeft);\n\t\tconst leftLines = this.optionListView.render(leftWidth);\n\t\tconst rightLines = this.renderPaddedPreviewLines(rightWidth, mode);\n\t\tconst rows = Math.max(leftLines.length, rightLines.length);\n\t\tconst gapStr = \" \".repeat(gap);\n\t\tconst out: string[] = [];\n\t\tfor (let i = 0; i < rows; i++) {\n\t\t\tconst leftRaw = leftLines[i] ?? \"\";\n\t\t\tconst rightRaw = rightLines[i] ?? \"\";\n\t\t\tconst leftClamped = truncateToWidth(leftRaw, leftWidth, \"\");\n\t\t\tconst leftPad = \" \".repeat(Math.max(0, leftWidth - visibleWidth(leftClamped)));\n\t\t\tconst joined = `${leftClamped}${leftPad}${gapStr}${rightRaw}`;\n\t\t\tout.push(truncateToWidth(joined, width, \"\"));\n\t\t}\n\t\treturn out;\n\t}\n\n\tprivate renderPaddedPreviewLines(colWidth: number, mode: PreviewLayoutMode): string[] {\n\t\tconst inner = Math.max(1, colWidth - PREVIEW_PADDING_LEFT);\n\t\tconst contentLines = this.previewBlock.renderBlock(\n\t\t\tinner,\n\t\t\tthis.props.selectedIndex,\n\t\t\tmode,\n\t\t\tthis.props.focused,\n\t\t\tthis.props.notesVisible,\n\t\t\tthis.props.notes,\n\t\t);\n\t\tconst pad = \" \".repeat(PREVIEW_PADDING_LEFT);\n\t\treturn contentLines.map((l) => (l === \"\" ? \"\" : `${pad}${l}`));\n\t}\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { Component } from "@earendil-works/pi-tui";
2
+ import { type FieldTone } from "../../state/selectors/field-tone.ts";
2
3
  /**
3
4
  * Row-intent discriminated union. `kind` is the single discriminator —
4
5
  * pre-1.0.3 boolean flags have been removed (see `banned-flags.test.ts`).
@@ -33,7 +34,8 @@ export type WrappingSelectItem = {
33
34
  description?: string;
34
35
  };
35
36
  export interface WrappingSelectTheme {
36
- selectedText: (text: string) => string;
37
+ /** Paints a row or inline field in its tone; tones come from `field-tone.ts`. */
38
+ field: (tone: FieldTone, text: string) => string;
37
39
  description: (text: string) => string;
38
40
  scrollInfo: (text: string) => string;
39
41
  }
@@ -73,9 +75,9 @@ export declare class WrappingSelect implements Component {
73
75
  private inputCursor;
74
76
  /**
75
77
  * Index of the row that was previously confirmed for this list (e.g. the user's prior
76
- * answer when re-entering a multi-question tab). Renders `<label> ✔` in the active-row
77
- * styling but WITHOUT the `❯` pointer — pointer is reserved for the live cursor. When
78
- * `selectedIndex === confirmedIndex && focused`, the active rendering wins (no double-mark).
78
+ * answer when re-entering a multi-question tab). Renders `<label> ✔` in the `answered`
79
+ * tone WITHOUT the `❯` pointer — pointer is reserved for the live cursor. When
80
+ * `selectedIndex === confirmedIndex && focused`, the row takes the `editing` tone.
79
81
  */
80
82
  private confirmedIndex;
81
83
  /**
@@ -109,14 +111,22 @@ export declare class WrappingSelect implements Component {
109
111
  private computeVisibleWindow;
110
112
  private hasItemsOutsideWindow;
111
113
  private renderItem;
114
+ /**
115
+ * An inline field without focus shows what it holds: the in-flight draft, else the
116
+ * confirmed answer (`confirmedLabelOverride`), else its own label as the placeholder.
117
+ * The ` ✔` mark only follows text that is the confirmed answer. The row stays one line,
118
+ * truncated, so a long draft does not change the dialog's height once focus leaves it;
119
+ * the editor shows the full text again on focus.
120
+ */
121
+ private renderInlineFieldAtRest;
112
122
  private buildRowPrefix;
113
- private shouldRenderAsInlineInput;
123
+ private isInlineField;
114
124
  /**
115
125
  * Render the inline input row across one or more lines, wrapping at `contentWidth`
116
126
  * so long input doesn't run off the right edge or trip the parent renderer's
117
127
  * width invariant. Mirrors `renderLabelBlock`'s contract: first line carries
118
128
  * `rowPrefix`, continuation lines carry `continuationPrefix` (spaces), and every
119
- * emitted line passes through `theme.selectedText`. The cursor mirrors the
129
+ * emitted line is painted in the `editing` tone. The cursor mirrors the
120
130
  * main chat editor: inverse-video over the character at the caret, or an
121
131
  * inverse-video space at end-of-line.
122
132
  */
@@ -1 +1 @@
1
- {"version":3,"file":"wrapping-select.d.ts","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/view/components/wrapping-select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,S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AAM,GAAG,IAAI,CAAG;IAEnC,UAAU,IAAI,IAAI,CAAG;IAErB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAwB9B;IAED,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,UAAU;IAiClB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,yBAAyB;IAIjC;;;;;;;;OAQG;IACH,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,gBAAgB;IAexB,OAAO,CAAC,sBAAsB;CAS9B"}
1
+ {"version":3,"file":"wrapping-select.d.ts","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/view/components/wrapping-select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAIxD,OAAO,EAAE,KAAK,SAAS,EAAsB,MAAM,qCAAqC,CAAC;AAEzF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,kBAAkB,GAC3B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzD,MAAM,WAAW,mBAAmB;IACnC,iFAAiF;IACjF,KAAK,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,M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G;IACH,OAAO,CAAC,sBAAsB,CAAiC;IAE/D,YACC,KAAK,EAAE,SAAS,kBAAkB,EAAE,EACpC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,mBAAmB,EAC1B,OAAO,GAAE,qBAA0B,EAQnC;IAED;;;;OAIG;IACH,YAAY,CAAC,iBAAiB,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAG5E;IAED,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAEpC;IAED,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEjC;IAED;;;;;OAKG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAQzE;IAED,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAGjC;IAED,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAEnC;IAED,oEAAoE;IACpE,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAG;IAEnC,UAAU,IAAI,IAAI,CAAG;IAErB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAwB9B;IAED,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,UAAU;IAgClB;;;;;;OAMG;IACH,OAAO,CAAC,uBAAuB;IAe/B,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,aAAa;IAIrB;;;;;;;;OAQG;IACH,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,gBAAgB;IAexB,OAAO,CAAC,sBAAsB;CAS9B"}
@@ -1,12 +1,14 @@
1
- import { visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
1
+ import { truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
2
2
  import { OVERLAY_ACTIVE_ROW_MARKER } from "../../../../extensions/ui-types.js";
3
3
  import { ROW_INTENT_META } from "../../state/row-intent.js";
4
+ import { fieldTone, rowTone } from "../../state/selectors/field-tone.js";
4
5
  export class WrappingSelect {
5
6
  static ACTIVE_POINTER = "❯ ";
6
7
  static INACTIVE_POINTER = " ";
7
8
  static NUMBER_SEPARATOR = ". ";
8
9
  static CURSOR_INVERSE_START = "\x1b[7m";
9
- static CURSOR_INVERSE_END = "\x1b[0m";
10
+ // Reverse-video off only: a full reset would drop the field color after the caret (#4741).
11
+ static CURSOR_INVERSE_END = "\x1b[27m";
10
12
  static CONFIRMED_MARK = " ✔";
11
13
  static MIN_CONTENT_WIDTH = 1;
12
14
  items;
@@ -21,9 +23,9 @@ export class WrappingSelect {
21
23
  inputCursor = undefined;
22
24
  /**
23
25
  * Index of the row that was previously confirmed for this list (e.g. the user's prior
24
- * answer when re-entering a multi-question tab). Renders `<label> ✔` in the active-row
25
- * styling but WITHOUT the `❯` pointer — pointer is reserved for the live cursor. When
26
- * `selectedIndex === confirmedIndex && focused`, the active rendering wins (no double-mark).
26
+ * answer when re-entering a multi-question tab). Renders `<label> ✔` in the `answered`
27
+ * tone WITHOUT the `❯` pointer — pointer is reserved for the live cursor. When
28
+ * `selectedIndex === confirmedIndex && focused`, the row takes the `editing` tone.
27
29
  */
28
30
  confirmedIndex = undefined;
29
31
  /**
@@ -118,40 +120,56 @@ export class WrappingSelect {
118
120
  const rowPrefix = this.buildRowPrefix(index, isActive, numberWidth);
119
121
  const continuationPrefix = " ".repeat(visibleWidth(rowPrefix));
120
122
  const contentWidth = Math.max(WrappingSelect.MIN_CONTENT_WIDTH, width - visibleWidth(rowPrefix));
121
- if (this.shouldRenderAsInlineInput(item, isActive)) {
122
- return this.renderInlineInputRow(rowPrefix, continuationPrefix, contentWidth);
123
+ if (this.isInlineField(item)) {
124
+ if (isActive)
125
+ return this.renderInlineInputRow(rowPrefix, continuationPrefix, contentWidth);
126
+ return [
127
+ ...this.renderInlineFieldAtRest(item, index, rowPrefix, contentWidth),
128
+ ...this.renderDescriptionBlock(item.description, continuationPrefix, contentWidth),
129
+ ];
123
130
  }
124
- // Confirmed row gets a trailing ` ✔` and accent+bold styling; pointer is independent
125
- // (still ❯ when active). When `index === confirmedIndex` AND `isActive`, both `❯` and
126
- // `✔` appear on the same row — load-bearing for the case where the prior answer was
127
- // row 0 (cursor resets to 0 on tab-back, so the confirmed row IS the active row).
128
- // Optional `confirmedLabelOverride` replaces the static label (used for `kind: "other"`
129
- // + `kind: "custom"` answer); the inline-input branch above still wins for `kind: "other" + isActive`.
131
+ // Confirmed row gets a trailing ` ✔`; pointer is independent (still ❯ when active).
132
+ // When `index === confirmedIndex` AND `isActive`, both `❯` and `✔` appear on the same
133
+ // row — load-bearing for the case where the prior answer was row 0 (cursor resets to
134
+ // 0 on tab-back, so the confirmed row IS the active row).
130
135
  const isConfirmed = index === this.confirmedIndex;
131
- const label = isConfirmed
132
- ? `${this.confirmedLabelOverride ?? item.label}${WrappingSelect.CONFIRMED_MARK}`
133
- : item.label;
134
- const applySelectedStyle = isActive || isConfirmed;
136
+ const label = isConfirmed ? `${item.label}${WrappingSelect.CONFIRMED_MARK}` : item.label;
135
137
  return [
136
- ...this.renderLabelBlock(label, rowPrefix, continuationPrefix, contentWidth, applySelectedStyle),
138
+ ...this.renderLabelBlock(label, rowPrefix, continuationPrefix, contentWidth, rowTone(isActive, isConfirmed)),
137
139
  ...this.renderDescriptionBlock(item.description, continuationPrefix, contentWidth),
138
140
  ];
139
141
  }
142
+ /**
143
+ * An inline field without focus shows what it holds: the in-flight draft, else the
144
+ * confirmed answer (`confirmedLabelOverride`), else its own label as the placeholder.
145
+ * The ` ✔` mark only follows text that is the confirmed answer. The row stays one line,
146
+ * truncated, so a long draft does not change the dialog's height once focus leaves it;
147
+ * the editor shows the full text again on focus.
148
+ */
149
+ renderInlineFieldAtRest(item, index, rowPrefix, contentWidth) {
150
+ const confirmedValue = index === this.confirmedIndex ? (this.confirmedLabelOverride ?? "") : "";
151
+ const value = this.inputBuffer.trim().length > 0 ? this.inputBuffer : confirmedValue;
152
+ const tone = fieldTone(false, value);
153
+ const text = tone === "placeholder" ? item.label : value;
154
+ const mark = confirmedValue.length > 0 && value === confirmedValue ? WrappingSelect.CONFIRMED_MARK : "";
155
+ const fitted = truncateToWidth(text, Math.max(1, contentWidth - visibleWidth(mark)), "…");
156
+ return [this.theme.field(tone, `${rowPrefix}${fitted}${mark}`)];
157
+ }
140
158
  buildRowPrefix(index, isActive, numberWidth) {
141
159
  const pointer = isActive ? WrappingSelect.ACTIVE_POINTER : WrappingSelect.INACTIVE_POINTER;
142
160
  const displayNumber = this.numberStartOffset + index + 1;
143
161
  const paddedNumber = String(displayNumber).padStart(numberWidth, " ");
144
162
  return `${pointer}${paddedNumber}${WrappingSelect.NUMBER_SEPARATOR}`;
145
163
  }
146
- shouldRenderAsInlineInput(item, isActive) {
147
- return this.inlineInputEnabled && isActive && ROW_INTENT_META[item.kind].activatesInputMode;
164
+ isInlineField(item) {
165
+ return this.inlineInputEnabled && ROW_INTENT_META[item.kind].activatesInputMode;
148
166
  }
149
167
  /**
150
168
  * Render the inline input row across one or more lines, wrapping at `contentWidth`
151
169
  * so long input doesn't run off the right edge or trip the parent renderer's
152
170
  * width invariant. Mirrors `renderLabelBlock`'s contract: first line carries
153
171
  * `rowPrefix`, continuation lines carry `continuationPrefix` (spaces), and every
154
- * emitted line passes through `theme.selectedText`. The cursor mirrors the
172
+ * emitted line is painted in the `editing` tone. The cursor mirrors the
155
173
  * main chat editor: inverse-video over the character at the caret, or an
156
174
  * inverse-video space at end-of-line.
157
175
  */
@@ -160,7 +178,7 @@ export class WrappingSelect {
160
178
  const wrapped = wrapTextWithAnsi(raw, contentWidth);
161
179
  return wrapped.map((segment, index) => {
162
180
  const prefix = index === 0 ? rowPrefix : continuationPrefix;
163
- return this.theme.selectedText(`${prefix}${segment}`);
181
+ return this.theme.field("editing", `${prefix}${segment}`);
164
182
  });
165
183
  }
166
184
  inputTextWithCursor() {
@@ -179,12 +197,12 @@ export class WrappingSelect {
179
197
  return this.inputBuffer.length;
180
198
  return Math.max(0, Math.min(cursor, this.inputBuffer.length));
181
199
  }
182
- renderLabelBlock(label, rowPrefix, continuationPrefix, contentWidth, applySelectedStyle) {
200
+ renderLabelBlock(label, rowPrefix, continuationPrefix, contentWidth, tone) {
183
201
  const wrapped = wrapTextWithAnsi(label, contentWidth);
184
202
  return wrapped.map((segment, index) => {
185
203
  const prefix = index === 0 ? rowPrefix : continuationPrefix;
186
204
  const line = `${prefix}${segment}`;
187
- return applySelectedStyle ? this.theme.selectedText(line) : line;
205
+ return tone ? this.theme.field(tone, line) : line;
188
206
  });
189
207
  }
190
208
  renderDescriptionBlock(description, continuationPrefix, contentWidth) {
@@ -1 +1 @@
1
- {"version":3,"file":"wrapping-select.js","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/view/components/wrapping-select.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AA+C5D,MAAM,OAAO,cAAc;IAClB,MAAM,CAAU,cAAc,GAAG,IAAI,CAAC;IACtC,MAAM,CAAU,gBAAgB,GAAG,IAAI,CAAC;IACxC,MAAM,CAAU,gBAAgB,GAAG,IAAI,CAAC;IACxC,MAAM,CAAU,oBAAoB,GAAG,SAAS,CAAC;IACjD,MAAM,CAAU,kBAAkB,GAAG,SAAS,CAAC;IAC/C,MAAM,CAAU,cAAc,GAAG,IAAI,CAAC;IACtC,MAAM,CAAU,iBAAiB,GAAG,CAAC,CAAC;IAE7B,KAAK,CAAgC;IACrC,UAAU,CAAS;IACnB,KAAK,CAAsB;IAC3B,kBAAkB,CAAU;IACrC,iBAAiB,CAAS;IAC1B,sBAAsB,CAAS;IA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AK,EAAE,EAAE;YACrC,MAAM,MAAM,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC;YAC5D,MAAM,IAAI,GAAG,GAAG,MAAM,GAAG,OAAO,EAAE,CAAC;YACnC,OAAO,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAClE,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,sBAAsB,CAC7B,WAA+B,EAC/B,kBAA0B,EAC1B,YAAoB;QAEpB,IAAI,CAAC,WAAW;YAAE,OAAO,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,gBAAgB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;QAC5D,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC5F,CAAC;CACD","sourcesContent":["import type { Component } from \"@earendil-works/pi-tui\";\nimport { visibleWidth, wrapTextWithAnsi } from \"@earendil-works/pi-tui\";\nimport { OVERLAY_ACTIVE_ROW_MARKER } from \"../../../../extensions/ui-types.js\";\nimport { ROW_INTENT_META } from \"../../state/row-intent.ts\";\n\n/**\n * Row-intent discriminated union. `kind` is the single discriminator —\n * pre-1.0.3 boolean flags have been removed (see `banned-flags.test.ts`).\n * Modeled after `QuestionnaireAction` (`key-router.ts:13-32`) and `Effect`\n * (`state-reducer.ts:26-32`) — pure literal-tagged variants, no shared base,\n * exhaustive-`switch` enforcement via non-`void` returns.\n *\n * Variant semantics:\n * - `option`: a regular author-defined option row.\n * - `other`: the inline free-text input row appended to single-select questions\n * (label is \"Type something.\"). Renders as inline `Input` when active.\n * - `chat`: the abandon-questionnaire escape-hatch row (label is \"Chat about this\").\n * Renders as inline `Input` when active.\n * - `next`: the explicit commit-and-advance row appended to multi-select questions\n * (label is \"Next\"). Renders without a number / checkbox.\n */\nexport type WrappingSelectItem =\n\t| { kind: \"option\"; label: string; description?: string }\n\t| { kind: \"other\"; label: string; description?: string }\n\t| { kind: \"chat\"; label: string; description?: string }\n\t| { kind: \"next\"; label: string; description?: string };\n\nexport interface WrappingSelectTheme {\n\tselectedText: (text: string) => string;\n\tdescription: (text: string) => string;\n\tscrollInfo: (text: string) => string;\n}\n\n/**\n * Numbering controls.\n *\n * Use `numberStartOffset` + `totalItemsForNumbering` when a list is logically a slice of a\n * larger numbered sequence — e.g. the chat row lives in its own WrappingSelect but should\n * render as `(N+1).` where N is the previous list's item count, with the column padded as\n * if both lists were one continuous numbered sequence.\n */\nexport interface WrappingSelectOptions {\n\t/** Start numbering at this offset + 1 (default 0 → rows labeled 1, 2, 3 …). */\n\tnumberStartOffset?: number;\n\t/** Override the total used to pad the number column (useful when items span multiple lists). */\n\ttotalItemsForNumbering?: number;\n\t/** When false, rows that normally open an inline editor stay ordinary labeled rows. */\n\tinlineInputEnabled?: boolean;\n}\n\nexport class WrappingSelect implements Component {\n\tprivate static readonly ACTIVE_POINTER = \"❯ \";\n\tprivate static readonly INACTIVE_POINTER = \" \";\n\tprivate static readonly NUMBER_SEPARATOR = \". \";\n\tprivate static readonly CURSOR_INVERSE_START = \"\\x1b[7m\";\n\tprivate static readonly CURSOR_INVERSE_END = \"\\x1b[0m\";\n\tprivate static readonly CONFIRMED_MARK = \" ✔\";\n\tprivate static readonly MIN_CONTENT_WIDTH = 1;\n\n\tprivate readonly items: readonly WrappingSelectItem[];\n\tprivate readonly maxVisible: number;\n\tprivate readonly theme: WrappingSelectTheme;\n\tprivate readonly inlineInputEnabled: boolean;\n\tprivate numberStartOffset: number;\n\tprivate totalItemsForNumbering: number;\n\n\tprivate selectedIndex = 0;\n\tprivate focused = true;\n\tprivate inputBuffer = \"\";\n\tprivate inputCursor: number | undefined = undefined;\n\t/**\n\t * Index of the row that was previously confirmed for this list (e.g. the user's prior\n\t * answer when re-entering a multi-question tab). Renders `<label> ✔` in the active-row\n\t * styling but WITHOUT the `❯` pointer — pointer is reserved for the live cursor. When\n\t * `selectedIndex === confirmedIndex && focused`, the active rendering wins (no double-mark).\n\t */\n\tprivate confirmedIndex: number | undefined = undefined;\n\t/**\n\t * When set together with `confirmedIndex`, replaces the row's static label at render time.\n\t * Used for the `kind: \"other\"` sentinel — its label is \"Type something.\" but if the user's\n\t * prior answer was custom text, we render that text instead (e.g. `4. Hello ✔`).\n\t */\n\tprivate confirmedLabelOverride: string | undefined = undefined;\n\n\tconstructor(\n\t\titems: readonly WrappingSelectItem[],\n\t\tmaxVisible: number,\n\t\ttheme: WrappingSelectTheme,\n\t\toptions: WrappingSelectOptions = {},\n\t) {\n\t\tthis.items = items;\n\t\tthis.maxVisible = Math.max(1, maxVisible);\n\t\tthis.theme = theme;\n\t\tthis.inlineInputEnabled = options.inlineInputEnabled !== false;\n\t\tthis.numberStartOffset = options.numberStartOffset ?? 0;\n\t\tthis.totalItemsForNumbering = options.totalItemsForNumbering ?? items.length;\n\t}\n\n\t/**\n\t * Update the numbering offset + total padding width without rebuilding the component.\n\t * Used by the host to keep the chat-row WrappingSelect's number aligned with the active tab's\n\t * options list when the user switches tabs (each tab can have a different items count).\n\t */\n\tsetNumbering(numberStartOffset: number, totalItemsForNumbering: number): void {\n\t\tthis.numberStartOffset = numberStartOffset;\n\t\tthis.totalItemsForNumbering = Math.max(1, totalItemsForNumbering);\n\t}\n\n\tsetSelectedIndex(index: number): void {\n\t\tthis.selectedIndex = Math.max(0, Math.min(index, this.items.length - 1));\n\t}\n\n\tsetFocused(focused: boolean): void {\n\t\tthis.focused = focused;\n\t}\n\n\t/**\n\t * Mark a previously-confirmed row. Pass `undefined` to clear. `labelOverride` replaces\n\t * the row's static `item.label` at render time — used for the `kind: \"other\"` sentinel so\n\t * the row reads `Hello ✔` instead of `Type something. ✔` when the prior answer was custom\n\t * text.\n\t */\n\tsetConfirmedIndex(index: number | undefined, labelOverride?: string): void {\n\t\tif (index === undefined) {\n\t\t\tthis.confirmedIndex = undefined;\n\t\t\tthis.confirmedLabelOverride = undefined;\n\t\t\treturn;\n\t\t}\n\t\tthis.confirmedIndex = Math.max(0, Math.min(index, this.items.length - 1));\n\t\tthis.confirmedLabelOverride = labelOverride;\n\t}\n\n\tsetInputBuffer(text: string): void {\n\t\tthis.inputBuffer = text;\n\t\tif (this.inputCursor !== undefined) this.inputCursor = this.clampInputCursor(this.inputCursor);\n\t}\n\n\tsetInputCursor(cursor: number): void {\n\t\tthis.inputCursor = this.clampInputCursor(cursor);\n\t}\n\n\t/** Intentionally empty — input is routed at the container level. */\n\thandleInput(_data: string): void {}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tif (this.items.length === 0) return [];\n\n\t\tconst { startIndex, endIndex } = this.computeVisibleWindow();\n\t\tconst numberWidth = String(Math.max(1, this.totalItemsForNumbering)).length;\n\t\tconst lines: string[] = [];\n\n\t\tfor (let i = startIndex; i < endIndex; i++) {\n\t\t\tconst item = this.items[i];\n\t\t\tif (!item) continue;\n\t\t\tconst isActive = i === this.selectedIndex && this.focused;\n\t\t\tconst itemLines = this.renderItem(item, i, isActive, width, numberWidth);\n\t\t\t// Tell a bounding host which row it must not crop away (#2378). The mark\n\t\t\t// is zero-width and the host strips it; see OVERLAY_ACTIVE_ROW_MARKER.\n\t\t\tif (isActive && itemLines.length > 0) {\n\t\t\t\titemLines[0] = `${itemLines[0] ?? \"\"}${OVERLAY_ACTIVE_ROW_MARKER}`;\n\t\t\t}\n\t\t\tlines.push(...itemLines);\n\t\t}\n\n\t\tif (this.hasItemsOutsideWindow(startIndex, endIndex)) {\n\t\t\tlines.push(this.theme.scrollInfo(` (${this.selectedIndex + 1}/${this.items.length})`));\n\t\t}\n\t\treturn lines;\n\t}\n\n\tprivate computeVisibleWindow(): { startIndex: number; endIndex: number } {\n\t\tconst half = Math.floor(this.maxVisible / 2);\n\t\tconst startIndex = Math.max(0, Math.min(this.selectedIndex - half, this.items.length - this.maxVisible));\n\t\tconst endIndex = Math.min(startIndex + this.maxVisible, this.items.length);\n\t\treturn { startIndex, endIndex };\n\t}\n\n\tprivate hasItemsOutsideWindow(startIndex: number, endIndex: number): boolean {\n\t\treturn startIndex > 0 || endIndex < this.items.length;\n\t}\n\n\tprivate renderItem(\n\t\titem: WrappingSelectItem,\n\t\tindex: number,\n\t\tisActive: boolean,\n\t\twidth: number,\n\t\tnumberWidth: number,\n\t): string[] {\n\t\tconst rowPrefix = this.buildRowPrefix(index, isActive, numberWidth);\n\t\tconst continuationPrefix = \" \".repeat(visibleWidth(rowPrefix));\n\t\tconst contentWidth = Math.max(WrappingSelect.MIN_CONTENT_WIDTH, width - visibleWidth(rowPrefix));\n\n\t\tif (this.shouldRenderAsInlineInput(item, isActive)) {\n\t\t\treturn this.renderInlineInputRow(rowPrefix, continuationPrefix, contentWidth);\n\t\t}\n\n\t\t// Confirmed row gets a trailing ` ✔` and accent+bold styling; pointer is independent\n\t\t// (still ❯ when active). When `index === confirmedIndex` AND `isActive`, both `❯` and\n\t\t// `✔` appear on the same row — load-bearing for the case where the prior answer was\n\t\t// row 0 (cursor resets to 0 on tab-back, so the confirmed row IS the active row).\n\t\t// Optional `confirmedLabelOverride` replaces the static label (used for `kind: \"other\"`\n\t\t// + `kind: \"custom\"` answer); the inline-input branch above still wins for `kind: \"other\" + isActive`.\n\t\tconst isConfirmed = index === this.confirmedIndex;\n\t\tconst label = isConfirmed\n\t\t\t? `${this.confirmedLabelOverride ?? item.label}${WrappingSelect.CONFIRMED_MARK}`\n\t\t\t: item.label;\n\t\tconst applySelectedStyle = isActive || isConfirmed;\n\n\t\treturn [\n\t\t\t...this.renderLabelBlock(label, rowPrefix, continuationPrefix, contentWidth, applySelectedStyle),\n\t\t\t...this.renderDescriptionBlock(item.description, continuationPrefix, contentWidth),\n\t\t];\n\t}\n\n\tprivate buildRowPrefix(index: number, isActive: boolean, numberWidth: number): string {\n\t\tconst pointer = isActive ? WrappingSelect.ACTIVE_POINTER : WrappingSelect.INACTIVE_POINTER;\n\t\tconst displayNumber = this.numberStartOffset + index + 1;\n\t\tconst paddedNumber = String(displayNumber).padStart(numberWidth, \" \");\n\t\treturn `${pointer}${paddedNumber}${WrappingSelect.NUMBER_SEPARATOR}`;\n\t}\n\n\tprivate shouldRenderAsInlineInput(item: WrappingSelectItem, isActive: boolean): boolean {\n\t\treturn this.inlineInputEnabled && isActive && ROW_INTENT_META[item.kind].activatesInputMode;\n\t}\n\n\t/**\n\t * Render the inline input row across one or more lines, wrapping at `contentWidth`\n\t * so long input doesn't run off the right edge or trip the parent renderer's\n\t * width invariant. Mirrors `renderLabelBlock`'s contract: first line carries\n\t * `rowPrefix`, continuation lines carry `continuationPrefix` (spaces), and every\n\t * emitted line passes through `theme.selectedText`. The cursor mirrors the\n\t * main chat editor: inverse-video over the character at the caret, or an\n\t * inverse-video space at end-of-line.\n\t */\n\tprivate renderInlineInputRow(rowPrefix: string, continuationPrefix: string, contentWidth: number): string[] {\n\t\tconst raw = this.inputTextWithCursor();\n\t\tconst wrapped = wrapTextWithAnsi(raw, contentWidth);\n\t\treturn wrapped.map((segment, index) => {\n\t\t\tconst prefix = index === 0 ? rowPrefix : continuationPrefix;\n\t\t\treturn this.theme.selectedText(`${prefix}${segment}`);\n\t\t});\n\t}\n\n\tprivate inputTextWithCursor(): string {\n\t\tconst cursor = this.clampInputCursor(this.inputCursor ?? this.inputBuffer.length);\n\t\tconst before = this.inputBuffer.slice(0, cursor);\n\t\tconst after = this.inputBuffer.slice(cursor);\n\t\tconst [at = \"\"] = Array.from(after);\n\t\tif (at === \"\") {\n\t\t\treturn `${before}${WrappingSelect.CURSOR_INVERSE_START} ${WrappingSelect.CURSOR_INVERSE_END}`;\n\t\t}\n\t\tconst rest = after.slice(at.length);\n\t\treturn `${before}${WrappingSelect.CURSOR_INVERSE_START}${at}${WrappingSelect.CURSOR_INVERSE_END}${rest}`;\n\t}\n\n\tprivate clampInputCursor(cursor: number): number {\n\t\tif (!Number.isFinite(cursor)) return this.inputBuffer.length;\n\t\treturn Math.max(0, Math.min(cursor, this.inputBuffer.length));\n\t}\n\n\tprivate renderLabelBlock(\n\t\tlabel: string,\n\t\trowPrefix: string,\n\t\tcontinuationPrefix: string,\n\t\tcontentWidth: number,\n\t\tapplySelectedStyle: boolean,\n\t): string[] {\n\t\tconst wrapped = wrapTextWithAnsi(label, contentWidth);\n\t\treturn wrapped.map((segment, index) => {\n\t\t\tconst prefix = index === 0 ? rowPrefix : continuationPrefix;\n\t\t\tconst line = `${prefix}${segment}`;\n\t\t\treturn applySelectedStyle ? this.theme.selectedText(line) : line;\n\t\t});\n\t}\n\n\tprivate renderDescriptionBlock(\n\t\tdescription: string | undefined,\n\t\tcontinuationPrefix: string,\n\t\tcontentWidth: number,\n\t): string[] {\n\t\tif (!description) return [];\n\t\tconst wrapped = wrapTextWithAnsi(description, contentWidth);\n\t\treturn wrapped.map((segment) => `${continuationPrefix}${this.theme.description(segment)}`);\n\t}\n}\n"]}
1
+ {"version":3,"file":"wrapping-select.js","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/view/components/wrapping-select.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAkB,SAAS,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAgDzF,MAAM,OAAO,cAAc;IAClB,MAAM,CAAU,cAAc,GAAG,IAAI,CAAC;IACtC,MAAM,CAAU,gBAAgB,GAAG,IAAI,CAAC;IACxC,MAAM,CAAU,gBAAgB,GAAG,IAAI,CAAC;IACxC,MAAM,CAAU,oBAAoB,GAAG,SAAS,CAAC;IACzD,2FAA2F;IACnF,MAAM,CAAU,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GAAG,gBAAgB,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QACtD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE;YACrC,MAAM,MAAM,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC;YAC5D,MAAM,IAAI,GAAG,GAAG,MAAM,GAAG,OAAO,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACnD,CAAC,CAAC,CAAC;IACJ,CAAC;IAEO,sBAAsB,CAC7B,WAA+B,EAC/B,kBAA0B,EAC1B,YAAoB;QAEpB,IAAI,CAAC,WAAW;YAAE,OAAO,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,gBAAgB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;QAC5D,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC5F,CAAC;CACD","sourcesContent":["import type { Component } from \"@earendil-works/pi-tui\";\nimport { truncateToWidth, visibleWidth, wrapTextWithAnsi } from \"@earendil-works/pi-tui\";\nimport { OVERLAY_ACTIVE_ROW_MARKER } from \"../../../../extensions/ui-types.js\";\nimport { ROW_INTENT_META } from \"../../state/row-intent.ts\";\nimport { type FieldTone, fieldTone, rowTone } from \"../../state/selectors/field-tone.ts\";\n\n/**\n * Row-intent discriminated union. `kind` is the single discriminator —\n * pre-1.0.3 boolean flags have been removed (see `banned-flags.test.ts`).\n * Modeled after `QuestionnaireAction` (`key-router.ts:13-32`) and `Effect`\n * (`state-reducer.ts:26-32`) — pure literal-tagged variants, no shared base,\n * exhaustive-`switch` enforcement via non-`void` returns.\n *\n * Variant semantics:\n * - `option`: a regular author-defined option row.\n * - `other`: the inline free-text input row appended to single-select questions\n * (label is \"Type something.\"). Renders as inline `Input` when active.\n * - `chat`: the abandon-questionnaire escape-hatch row (label is \"Chat about this\").\n * Renders as inline `Input` when active.\n * - `next`: the explicit commit-and-advance row appended to multi-select questions\n * (label is \"Next\"). Renders without a number / checkbox.\n */\nexport type WrappingSelectItem =\n\t| { kind: \"option\"; label: string; description?: string }\n\t| { kind: \"other\"; label: string; description?: string }\n\t| { kind: \"chat\"; label: string; description?: string }\n\t| { kind: \"next\"; label: string; description?: string };\n\nexport interface WrappingSelectTheme {\n\t/** Paints a row or inline field in its tone; tones come from `field-tone.ts`. */\n\tfield: (tone: FieldTone, text: string) => string;\n\tdescription: (text: string) => string;\n\tscrollInfo: (text: string) => string;\n}\n\n/**\n * Numbering controls.\n *\n * Use `numberStartOffset` + `totalItemsForNumbering` when a list is logically a slice of a\n * larger numbered sequence — e.g. the chat row lives in its own WrappingSelect but should\n * render as `(N+1).` where N is the previous list's item count, with the column padded as\n * if both lists were one continuous numbered sequence.\n */\nexport interface WrappingSelectOptions {\n\t/** Start numbering at this offset + 1 (default 0 → rows labeled 1, 2, 3 …). */\n\tnumberStartOffset?: number;\n\t/** Override the total used to pad the number column (useful when items span multiple lists). */\n\ttotalItemsForNumbering?: number;\n\t/** When false, rows that normally open an inline editor stay ordinary labeled rows. */\n\tinlineInputEnabled?: boolean;\n}\n\nexport class WrappingSelect implements Component {\n\tprivate static readonly ACTIVE_POINTER = \"❯ \";\n\tprivate static readonly INACTIVE_POINTER = \" \";\n\tprivate static readonly NUMBER_SEPARATOR = \". \";\n\tprivate static readonly CURSOR_INVERSE_START = \"\\x1b[7m\";\n\t// Reverse-video off only: a full reset would drop the field color after the caret (#4741).\n\tprivate static readonly CURSOR_INVERSE_END = \"\\x1b[27m\";\n\tprivate static readonly CONFIRMED_MARK = \" ✔\";\n\tprivate static readonly MIN_CONTENT_WIDTH = 1;\n\n\tprivate readonly items: readonly WrappingSelectItem[];\n\tprivate readonly maxVisible: number;\n\tprivate readonly theme: WrappingSelectTheme;\n\tprivate readonly inlineInputEnabled: boolean;\n\tprivate numberStartOffset: number;\n\tprivate totalItemsForNumbering: number;\n\n\tprivate selectedIndex = 0;\n\tprivate focused = true;\n\tprivate inputBuffer = \"\";\n\tprivate inputCursor: number | undefined = undefined;\n\t/**\n\t * Index of the row that was previously confirmed for this list (e.g. the user's prior\n\t * answer when re-entering a multi-question tab). Renders `<label> ✔` in the `answered`\n\t * tone WITHOUT the `❯` pointer — pointer is reserved for the live cursor. When\n\t * `selectedIndex === confirmedIndex && focused`, the row takes the `editing` tone.\n\t */\n\tprivate confirmedIndex: number | undefined = undefined;\n\t/**\n\t * When set together with `confirmedIndex`, replaces the row's static label at render time.\n\t * Used for the `kind: \"other\"` sentinel — its label is \"Type something.\" but if the user's\n\t * prior answer was custom text, we render that text instead (e.g. `4. Hello ✔`).\n\t */\n\tprivate confirmedLabelOverride: string | undefined = undefined;\n\n\tconstructor(\n\t\titems: readonly WrappingSelectItem[],\n\t\tmaxVisible: number,\n\t\ttheme: WrappingSelectTheme,\n\t\toptions: WrappingSelectOptions = {},\n\t) {\n\t\tthis.items = items;\n\t\tthis.maxVisible = Math.max(1, maxVisible);\n\t\tthis.theme = theme;\n\t\tthis.inlineInputEnabled = options.inlineInputEnabled !== false;\n\t\tthis.numberStartOffset = options.numberStartOffset ?? 0;\n\t\tthis.totalItemsForNumbering = options.totalItemsForNumbering ?? items.length;\n\t}\n\n\t/**\n\t * Update the numbering offset + total padding width without rebuilding the component.\n\t * Used by the host to keep the chat-row WrappingSelect's number aligned with the active tab's\n\t * options list when the user switches tabs (each tab can have a different items count).\n\t */\n\tsetNumbering(numberStartOffset: number, totalItemsForNumbering: number): void {\n\t\tthis.numberStartOffset = numberStartOffset;\n\t\tthis.totalItemsForNumbering = Math.max(1, totalItemsForNumbering);\n\t}\n\n\tsetSelectedIndex(index: number): void {\n\t\tthis.selectedIndex = Math.max(0, Math.min(index, this.items.length - 1));\n\t}\n\n\tsetFocused(focused: boolean): void {\n\t\tthis.focused = focused;\n\t}\n\n\t/**\n\t * Mark a previously-confirmed row. Pass `undefined` to clear. `labelOverride` replaces\n\t * the row's static `item.label` at render time — used for the `kind: \"other\"` sentinel so\n\t * the row reads `Hello ✔` instead of `Type something. ✔` when the prior answer was custom\n\t * text.\n\t */\n\tsetConfirmedIndex(index: number | undefined, labelOverride?: string): void {\n\t\tif (index === undefined) {\n\t\t\tthis.confirmedIndex = undefined;\n\t\t\tthis.confirmedLabelOverride = undefined;\n\t\t\treturn;\n\t\t}\n\t\tthis.confirmedIndex = Math.max(0, Math.min(index, this.items.length - 1));\n\t\tthis.confirmedLabelOverride = labelOverride;\n\t}\n\n\tsetInputBuffer(text: string): void {\n\t\tthis.inputBuffer = text;\n\t\tif (this.inputCursor !== undefined) this.inputCursor = this.clampInputCursor(this.inputCursor);\n\t}\n\n\tsetInputCursor(cursor: number): void {\n\t\tthis.inputCursor = this.clampInputCursor(cursor);\n\t}\n\n\t/** Intentionally empty — input is routed at the container level. */\n\thandleInput(_data: string): void {}\n\n\tinvalidate(): void {}\n\n\trender(width: number): string[] {\n\t\tif (this.items.length === 0) return [];\n\n\t\tconst { startIndex, endIndex } = this.computeVisibleWindow();\n\t\tconst numberWidth = String(Math.max(1, this.totalItemsForNumbering)).length;\n\t\tconst lines: string[] = [];\n\n\t\tfor (let i = startIndex; i < endIndex; i++) {\n\t\t\tconst item = this.items[i];\n\t\t\tif (!item) continue;\n\t\t\tconst isActive = i === this.selectedIndex && this.focused;\n\t\t\tconst itemLines = this.renderItem(item, i, isActive, width, numberWidth);\n\t\t\t// Tell a bounding host which row it must not crop away (#2378). The mark\n\t\t\t// is zero-width and the host strips it; see OVERLAY_ACTIVE_ROW_MARKER.\n\t\t\tif (isActive && itemLines.length > 0) {\n\t\t\t\titemLines[0] = `${itemLines[0] ?? \"\"}${OVERLAY_ACTIVE_ROW_MARKER}`;\n\t\t\t}\n\t\t\tlines.push(...itemLines);\n\t\t}\n\n\t\tif (this.hasItemsOutsideWindow(startIndex, endIndex)) {\n\t\t\tlines.push(this.theme.scrollInfo(` (${this.selectedIndex + 1}/${this.items.length})`));\n\t\t}\n\t\treturn lines;\n\t}\n\n\tprivate computeVisibleWindow(): { startIndex: number; endIndex: number } {\n\t\tconst half = Math.floor(this.maxVisible / 2);\n\t\tconst startIndex = Math.max(0, Math.min(this.selectedIndex - half, this.items.length - this.maxVisible));\n\t\tconst endIndex = Math.min(startIndex + this.maxVisible, this.items.length);\n\t\treturn { startIndex, endIndex };\n\t}\n\n\tprivate hasItemsOutsideWindow(startIndex: number, endIndex: number): boolean {\n\t\treturn startIndex > 0 || endIndex < this.items.length;\n\t}\n\n\tprivate renderItem(\n\t\titem: WrappingSelectItem,\n\t\tindex: number,\n\t\tisActive: boolean,\n\t\twidth: number,\n\t\tnumberWidth: number,\n\t): string[] {\n\t\tconst rowPrefix = this.buildRowPrefix(index, isActive, numberWidth);\n\t\tconst continuationPrefix = \" \".repeat(visibleWidth(rowPrefix));\n\t\tconst contentWidth = Math.max(WrappingSelect.MIN_CONTENT_WIDTH, width - visibleWidth(rowPrefix));\n\n\t\tif (this.isInlineField(item)) {\n\t\t\tif (isActive) return this.renderInlineInputRow(rowPrefix, continuationPrefix, contentWidth);\n\t\t\treturn [\n\t\t\t\t...this.renderInlineFieldAtRest(item, index, rowPrefix, contentWidth),\n\t\t\t\t...this.renderDescriptionBlock(item.description, continuationPrefix, contentWidth),\n\t\t\t];\n\t\t}\n\n\t\t// Confirmed row gets a trailing ` ✔`; pointer is independent (still ❯ when active).\n\t\t// When `index === confirmedIndex` AND `isActive`, both `❯` and `✔` appear on the same\n\t\t// row — load-bearing for the case where the prior answer was row 0 (cursor resets to\n\t\t// 0 on tab-back, so the confirmed row IS the active row).\n\t\tconst isConfirmed = index === this.confirmedIndex;\n\t\tconst label = isConfirmed ? `${item.label}${WrappingSelect.CONFIRMED_MARK}` : item.label;\n\n\t\treturn [\n\t\t\t...this.renderLabelBlock(label, rowPrefix, continuationPrefix, contentWidth, rowTone(isActive, isConfirmed)),\n\t\t\t...this.renderDescriptionBlock(item.description, continuationPrefix, contentWidth),\n\t\t];\n\t}\n\n\t/**\n\t * An inline field without focus shows what it holds: the in-flight draft, else the\n\t * confirmed answer (`confirmedLabelOverride`), else its own label as the placeholder.\n\t * The ` ✔` mark only follows text that is the confirmed answer. The row stays one line,\n\t * truncated, so a long draft does not change the dialog's height once focus leaves it;\n\t * the editor shows the full text again on focus.\n\t */\n\tprivate renderInlineFieldAtRest(\n\t\titem: WrappingSelectItem,\n\t\tindex: number,\n\t\trowPrefix: string,\n\t\tcontentWidth: number,\n\t): string[] {\n\t\tconst confirmedValue = index === this.confirmedIndex ? (this.confirmedLabelOverride ?? \"\") : \"\";\n\t\tconst value = this.inputBuffer.trim().length > 0 ? this.inputBuffer : confirmedValue;\n\t\tconst tone = fieldTone(false, value);\n\t\tconst text = tone === \"placeholder\" ? item.label : value;\n\t\tconst mark = confirmedValue.length > 0 && value === confirmedValue ? WrappingSelect.CONFIRMED_MARK : \"\";\n\t\tconst fitted = truncateToWidth(text, Math.max(1, contentWidth - visibleWidth(mark)), \"…\");\n\t\treturn [this.theme.field(tone, `${rowPrefix}${fitted}${mark}`)];\n\t}\n\n\tprivate buildRowPrefix(index: number, isActive: boolean, numberWidth: number): string {\n\t\tconst pointer = isActive ? WrappingSelect.ACTIVE_POINTER : WrappingSelect.INACTIVE_POINTER;\n\t\tconst displayNumber = this.numberStartOffset + index + 1;\n\t\tconst paddedNumber = String(displayNumber).padStart(numberWidth, \" \");\n\t\treturn `${pointer}${paddedNumber}${WrappingSelect.NUMBER_SEPARATOR}`;\n\t}\n\n\tprivate isInlineField(item: WrappingSelectItem): boolean {\n\t\treturn this.inlineInputEnabled && ROW_INTENT_META[item.kind].activatesInputMode;\n\t}\n\n\t/**\n\t * Render the inline input row across one or more lines, wrapping at `contentWidth`\n\t * so long input doesn't run off the right edge or trip the parent renderer's\n\t * width invariant. Mirrors `renderLabelBlock`'s contract: first line carries\n\t * `rowPrefix`, continuation lines carry `continuationPrefix` (spaces), and every\n\t * emitted line is painted in the `editing` tone. The cursor mirrors the\n\t * main chat editor: inverse-video over the character at the caret, or an\n\t * inverse-video space at end-of-line.\n\t */\n\tprivate renderInlineInputRow(rowPrefix: string, continuationPrefix: string, contentWidth: number): string[] {\n\t\tconst raw = this.inputTextWithCursor();\n\t\tconst wrapped = wrapTextWithAnsi(raw, contentWidth);\n\t\treturn wrapped.map((segment, index) => {\n\t\t\tconst prefix = index === 0 ? rowPrefix : continuationPrefix;\n\t\t\treturn this.theme.field(\"editing\", `${prefix}${segment}`);\n\t\t});\n\t}\n\n\tprivate inputTextWithCursor(): string {\n\t\tconst cursor = this.clampInputCursor(this.inputCursor ?? this.inputBuffer.length);\n\t\tconst before = this.inputBuffer.slice(0, cursor);\n\t\tconst after = this.inputBuffer.slice(cursor);\n\t\tconst [at = \"\"] = Array.from(after);\n\t\tif (at === \"\") {\n\t\t\treturn `${before}${WrappingSelect.CURSOR_INVERSE_START} ${WrappingSelect.CURSOR_INVERSE_END}`;\n\t\t}\n\t\tconst rest = after.slice(at.length);\n\t\treturn `${before}${WrappingSelect.CURSOR_INVERSE_START}${at}${WrappingSelect.CURSOR_INVERSE_END}${rest}`;\n\t}\n\n\tprivate clampInputCursor(cursor: number): number {\n\t\tif (!Number.isFinite(cursor)) return this.inputBuffer.length;\n\t\treturn Math.max(0, Math.min(cursor, this.inputBuffer.length));\n\t}\n\n\tprivate renderLabelBlock(\n\t\tlabel: string,\n\t\trowPrefix: string,\n\t\tcontinuationPrefix: string,\n\t\tcontentWidth: number,\n\t\ttone: FieldTone | undefined,\n\t): string[] {\n\t\tconst wrapped = wrapTextWithAnsi(label, contentWidth);\n\t\treturn wrapped.map((segment, index) => {\n\t\t\tconst prefix = index === 0 ? rowPrefix : continuationPrefix;\n\t\t\tconst line = `${prefix}${segment}`;\n\t\t\treturn tone ? this.theme.field(tone, line) : line;\n\t\t});\n\t}\n\n\tprivate renderDescriptionBlock(\n\t\tdescription: string | undefined,\n\t\tcontinuationPrefix: string,\n\t\tcontentWidth: number,\n\t): string[] {\n\t\tif (!description) return [];\n\t\tconst wrapped = wrapTextWithAnsi(description, contentWidth);\n\t\treturn wrapped.map((segment) => `${continuationPrefix}${this.theme.description(segment)}`);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tab-content-strategy.d.ts","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/view/tab-content-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAa,KAAK,KAAK,EAAgB,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8CAA8C,CAAC;AAE1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EACN,KAAK,WAAW,EAUhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIzD;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IAClC,wGAAwG;IACxG,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC,iFAAiF;IACjF,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,CAAC;IAE7C,8CAA8C;IAC9C,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IAE7C,0EAA0E;IAC1E,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,CAAC;IAEzC,2FAA2F;IAC3F,UAAU,CAAC,KAAK,EAAE,WAAW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AG,SAAS,EAAE,CAqB1C;CACD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,YAAY,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,GAAG,MAAM,CAS9G"}
1
+ {"version":3,"file":"tab-content-strategy.d.ts","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/view/tab-content-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAa,KAAK,KAAK,EAAgB,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8CAA8C,CAAC;AAG1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EACN,KAAK,WAAW,EAUhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIzD;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IAClC,wGAAwG;IACxG,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC,iFAAiF;IACjF,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,CAAC;IAE7C,8CAA8C;IAC9C,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IAE7C,0EAA0E;IAC1E,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,CAAC;IAEzC,2FAA2F;IAC3F,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,CAAC;CAC5C;AAED,MAAM,WAAW,yBAAyB;IACzC,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE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E,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,GAAG,MAAM,CAS9G"}
@@ -1,4 +1,5 @@
1
1
  import { Container, Spacer, Text } from "@earendil-works/pi-tui";
2
+ import { fieldTone, styleFieldTone } from "../state/selectors/field-tone.js";
2
3
  import { formatAnswerScalar } from "../tool/format-answer.js";
3
4
  import { HINT_PART_CANCEL, HINT_PART_ENTER, HINT_PART_NAV, HINT_PART_NOTES, HINT_PART_TAB, HINT_PART_TOGGLE, INCOMPLETE_WARNING_PREFIX, READY_PROMPT, REVIEW_HEADING, } from "./dialog-builder.js";
4
5
  const NOTES_HEADER = "Notes:";
@@ -32,7 +33,14 @@ export class QuestionTabStrategy {
32
33
  midRows(state) {
33
34
  if (!state.notesVisible)
34
35
  return [];
35
- return [new Text(this.config.theme.fg("muted", NOTES_HEADER), 1, 0), this.config.notesInput, new Spacer(1)];
36
+ const { theme, notesInput } = this.config;
37
+ // Notes mode open means the notes field has focus, so this resolves to `editing`.
38
+ const tone = fieldTone(state.notesVisible, state.notesDraft);
39
+ const notesField = {
40
+ render: (width) => notesInput.render(width).map((line) => styleFieldTone(theme, tone, line)),
41
+ invalidate: () => notesInput.invalidate(),
42
+ };
43
+ return [new Text(theme.fg("muted", NOTES_HEADER), 1, 0), notesField, new Spacer(1)];
36
44
  }
37
45
  footerRows(state) {
38
46
  const question = this.config.questions[state.currentTab];
@@ -63,9 +71,10 @@ export class SubmitTabStrategy {
63
71
  const label = q.header && q.header.length > 0 ? q.header : `Q${i + 1}`;
64
72
  const answerText = formatAnswerScalar(a, "summary");
65
73
  c.addChild(new Text(this.config.theme.fg("muted", ` ● ${label}`), 1, 0));
66
- c.addChild(new Text(` ${this.config.theme.fg("muted", "→")} ${this.config.theme.fg("text", answerText)}`, 1, 0));
74
+ const { theme } = this.config;
75
+ c.addChild(new Text(` ${theme.fg("muted", "→")} ${styleFieldTone(theme, "answered", answerText)}`, 1, 0));
67
76
  if (a.notes && a.notes.length > 0) {
68
- c.addChild(new Text(this.config.theme.fg("dim", ` notes: ${a.notes}`), 1, 0));
77
+ c.addChild(new Text(` ${theme.fg("muted", "notes:")} ${styleFieldTone(theme, "answered", a.notes)}`, 1, 0));
69
78
  }
70
79
  }
71
80
  return c;
@@ -1 +1 @@
1
- {"version":3,"file":"tab-content-strategy.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/view/tab-content-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAc,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAI9D,OAAO,EAEN,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,yBAAyB,EACzB,YAAY,EACZ,cAAc,GACd,MAAM,qBAAqB,CAAC;AAI7B,MAAM,YAAY,GAAG,QAAQ,CAAC;AAmC9B,MAAM,OAAO,mBAAmB;IAC/B,4EAA4E;IACnE,cAAc,GAAG,CAAC,CAAC;IAI5B,YAAY,MAAiC;QAC5C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAED,WAAW,CAAC,KAAkB;QAC7B,MAAM,GAAG,GAAgB,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACzD,0FAA0F;QAC1F,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,QAAQ,EAAE,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5E,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YACrF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Ae,EAAE,aAAa,CAAC,CAAC;IACzD,IAAI,QAAQ,EAAE,WAAW,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACjE,IAAI,QAAQ,IAAI,QAAQ,CAAC,WAAW,KAAK,IAAI,IAAI,KAAK,CAAC,uBAAuB,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;QACvG,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,OAAO;QAAE,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACvC,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC7B,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import { type Component, Container, type Input, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport type { Theme } from \"../../../../modes/interactive/theme/theme.js\";\nimport { formatAnswerScalar } from \"../tool/format-answer.ts\";\nimport type { QuestionData } from \"../tool/types.js\";\nimport type { ChatRowView } from \"./components/chat-row-view.ts\";\nimport type { PreviewPaneProps } from \"./components/preview/preview-pane.ts\";\nimport {\n\ttype DialogState,\n\tHINT_PART_CANCEL,\n\tHINT_PART_ENTER,\n\tHINT_PART_NAV,\n\tHINT_PART_NOTES,\n\tHINT_PART_TAB,\n\tHINT_PART_TOGGLE,\n\tINCOMPLETE_WARNING_PREFIX,\n\tREADY_PROMPT,\n\tREVIEW_HEADING,\n} from \"./dialog-builder.ts\";\nimport type { StatefulView } from \"./stateful-view.ts\";\nimport type { TabComponents } from \"./tab-components.ts\";\n\nconst NOTES_HEADER = \"Notes:\";\n\n/**\n * Per-tab content provider. Pure functional — closes over construction-time\n * config; per-tick state threads through method args. The chrome wrapper\n * enforces height equality across tabs from the rendered body's row count\n * plus `footerRowCount`.\n */\nexport interface TabContentStrategy {\n\t/** Total RENDERED footer rows — MUST equal what `footerRows()` actually emits. Drives residual math. */\n\treadonly footerRowCount: number;\n\n\t/** Variable rows above the body, after top chrome (border + tabBar + Spacer). */\n\theadingRows(state: DialogState): Component[];\n\n\t/** Body Component placed at the body slot. */\n\tbodyComponent(state: DialogState): Component;\n\n\t/** Optional rows between body's trailing Spacer and the bottom border. */\n\tmidRows(state: DialogState): Component[];\n\n\t/** Footer rows below the bottom border. Rendered row count MUST equal `footerRowCount`. */\n\tfooterRows(state: DialogState): Component[];\n}\n\nexport interface QuestionTabStrategyConfig {\n\ttheme: Theme;\n\tquestions: readonly QuestionData[];\n\tgetPreviewPane: () => StatefulView<PreviewPaneProps>;\n\ttabsByIndex: ReadonlyArray<TabComponents>;\n\tnotesInput: Input;\n\tchatRow: ChatRowView;\n\tisMulti: boolean;\n}\n\nexport class QuestionTabStrategy implements TabContentStrategy {\n\t/** Spacer(1) + chatRow(1) + Spacer(1) + Text(hint, 1) = 4 rendered rows. */\n\treadonly footerRowCount = 4;\n\n\tprivate declare readonly config: QuestionTabStrategyConfig;\n\n\tconstructor(config: QuestionTabStrategyConfig) {\n\t\tthis.config = config;\n\t}\n\n\theadingRows(state: DialogState): Component[] {\n\t\tconst out: Component[] = [];\n\t\tconst question = this.config.questions[state.currentTab];\n\t\t// In multi-question mode the tab bar already shows the header; suppress the inline badge.\n\t\tif (!this.config.isMulti && question?.header && question.header.length > 0) {\n\t\t\tout.push(new Text(this.config.theme.bg(\"selectedBg\", ` ${question.header} `), 1, 0));\n\t\t\tout.push(new Spacer(1));\n\t\t}\n\t\tif (question) {\n\t\t\tout.push(new Text(this.config.theme.bold(question.question), 1, 0));\n\t\t\tout.push(new Spacer(1));\n\t\t}\n\t\treturn out;\n\t}\n\n\tbodyComponent(state: DialogState): Component {\n\t\tconst question = this.config.questions[state.currentTab];\n\t\tconst mso = this.config.tabsByIndex[state.currentTab]?.multiSelect;\n\t\tif (question?.multiSelect === true && mso) return mso;\n\t\treturn this.config.getPreviewPane();\n\t}\n\n\tmidRows(state: DialogState): Component[] {\n\t\tif (!state.notesVisible) return [];\n\t\treturn [new Text(this.config.theme.fg(\"muted\", NOTES_HEADER), 1, 0), this.config.notesInput, new Spacer(1)];\n\t}\n\n\tfooterRows(state: DialogState): Component[] {\n\t\tconst question = this.config.questions[state.currentTab];\n\t\treturn [\n\t\t\tnew Spacer(1),\n\t\t\tthis.config.chatRow,\n\t\t\tnew Spacer(1),\n\t\t\tnew Text(this.config.theme.fg(\"dim\", buildHintText(question, this.config.isMulti, state)), 1, 0),\n\t\t];\n\t}\n}\n\nexport interface SubmitTabStrategyConfig {\n\ttheme: Theme;\n\tquestions: readonly QuestionData[];\n\tsubmitPicker: Component | undefined;\n}\n\nexport class SubmitTabStrategy implements TabContentStrategy {\n\t/** Spacer(1) + Text(prompt, 1) + Spacer(1) + submitPicker(2) = 5 rendered rows. Fallback path lands at 5 via 2 trailing Spacer(1)s. */\n\treadonly footerRowCount = 5;\n\n\tprivate declare readonly config: SubmitTabStrategyConfig;\n\n\tconstructor(config: SubmitTabStrategyConfig) {\n\t\tthis.config = config;\n\t}\n\n\theadingRows(_state: DialogState): Component[] {\n\t\treturn [new Text(this.config.theme.bold(this.config.theme.fg(\"accent\", REVIEW_HEADING)), 1, 0), new Spacer(1)];\n\t}\n\n\tbodyComponent(state: DialogState): Component {\n\t\tconst c = new Container();\n\t\tfor (let i = 0; i < this.config.questions.length; i++) {\n\t\t\tconst q = this.config.questions[i];\n\t\t\tconst a = state.answers.get(i);\n\t\t\tif (!a) continue;\n\t\t\tconst label = q.header && q.header.length > 0 ? q.header : `Q${i + 1}`;\n\t\t\tconst answerText = formatAnswerScalar(a, \"summary\");\n\t\t\tc.addChild(new Text(this.config.theme.fg(\"muted\", ` ● ${label}`), 1, 0));\n\t\t\tc.addChild(\n\t\t\t\tnew Text(` ${this.config.theme.fg(\"muted\", \"→\")} ${this.config.theme.fg(\"text\", answerText)}`, 1, 0),\n\t\t\t);\n\t\t\tif (a.notes && a.notes.length > 0) {\n\t\t\t\tc.addChild(new Text(this.config.theme.fg(\"dim\", ` notes: ${a.notes}`), 1, 0));\n\t\t\t}\n\t\t}\n\t\treturn c;\n\t}\n\n\tmidRows(_state: DialogState): Component[] {\n\t\treturn [];\n\t}\n\n\tfooterRows(state: DialogState): Component[] {\n\t\tconst missing: string[] = [];\n\t\tfor (let i = 0; i < this.config.questions.length; i++) {\n\t\t\tconst q = this.config.questions[i];\n\t\t\tif (!state.answers.has(i)) {\n\t\t\t\tmissing.push(q.header && q.header.length > 0 ? q.header : `Q${i + 1}`);\n\t\t\t}\n\t\t}\n\t\tconst promptText =\n\t\t\tmissing.length === 0\n\t\t\t\t? this.config.theme.fg(\"muted\", READY_PROMPT)\n\t\t\t\t: this.config.theme.fg(\"warning\", `${INCOMPLETE_WARNING_PREFIX} ${missing.join(\", \")}`);\n\t\tconst out: Component[] = [new Spacer(1), new Text(promptText, 1, 0), new Spacer(1)];\n\t\tif (this.config.submitPicker) {\n\t\t\tout.push(this.config.submitPicker);\n\t\t} else {\n\t\t\t// Padding when the picker isn't wired — keeps rendered row count at footerRowCount=5.\n\t\t\tout.push(new Spacer(1));\n\t\t\tout.push(new Spacer(1));\n\t\t}\n\t\treturn out;\n\t}\n}\n\n/**\n * Build the controls hint line. Order is fixed so `HINT_SINGLE` / `HINT_MULTI`\n * remain contiguous substrings of the result:\n * Enter · ↑/↓ [· Space toggle] [· n notes] [· Tab switch] · Esc\n */\nexport function buildHintText(question: QuestionData | undefined, isMulti: boolean, state: DialogState): string {\n\tconst parts: string[] = [HINT_PART_ENTER, HINT_PART_NAV];\n\tif (question?.multiSelect === true) parts.push(HINT_PART_TOGGLE);\n\tif (question && question.multiSelect !== true && state.focusedOptionHasPreview && !state.notesVisible) {\n\t\tparts.push(HINT_PART_NOTES);\n\t}\n\tif (isMulti) parts.push(HINT_PART_TAB);\n\tparts.push(HINT_PART_CANCEL);\n\treturn parts.join(\" · \");\n}\n"]}
1
+ {"version":3,"file":"tab-content-strategy.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/view/tab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AAI,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YACxB,GAAG,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,QAAkC,EAAE,OAAgB,EAAE,KAAkB;IACrG,MAAM,KAAK,GAAa,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;IACzD,IAAI,QAAQ,EAAE,WAAW,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACjE,IAAI,QAAQ,IAAI,QAAQ,CAAC,WAAW,KAAK,IAAI,IAAI,KAAK,CAAC,uBAAuB,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;QACvG,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,OAAO;QAAE,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACvC,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC7B,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import { type Component, Container, type Input, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport type { Theme } from \"../../../../modes/interactive/theme/theme.js\";\nimport { fieldTone, styleFieldTone } from \"../state/selectors/field-tone.ts\";\nimport { formatAnswerScalar } from \"../tool/format-answer.ts\";\nimport type { QuestionData } from \"../tool/types.js\";\nimport type { ChatRowView } from \"./components/chat-row-view.ts\";\nimport type { PreviewPaneProps } from \"./components/preview/preview-pane.ts\";\nimport {\n\ttype DialogState,\n\tHINT_PART_CANCEL,\n\tHINT_PART_ENTER,\n\tHINT_PART_NAV,\n\tHINT_PART_NOTES,\n\tHINT_PART_TAB,\n\tHINT_PART_TOGGLE,\n\tINCOMPLETE_WARNING_PREFIX,\n\tREADY_PROMPT,\n\tREVIEW_HEADING,\n} from \"./dialog-builder.ts\";\nimport type { StatefulView } from \"./stateful-view.ts\";\nimport type { TabComponents } from \"./tab-components.ts\";\n\nconst NOTES_HEADER = \"Notes:\";\n\n/**\n * Per-tab content provider. Pure functional — closes over construction-time\n * config; per-tick state threads through method args. The chrome wrapper\n * enforces height equality across tabs from the rendered body's row count\n * plus `footerRowCount`.\n */\nexport interface TabContentStrategy {\n\t/** Total RENDERED footer rows — MUST equal what `footerRows()` actually emits. Drives residual math. */\n\treadonly footerRowCount: number;\n\n\t/** Variable rows above the body, after top chrome (border + tabBar + Spacer). */\n\theadingRows(state: DialogState): Component[];\n\n\t/** Body Component placed at the body slot. */\n\tbodyComponent(state: DialogState): Component;\n\n\t/** Optional rows between body's trailing Spacer and the bottom border. */\n\tmidRows(state: DialogState): Component[];\n\n\t/** Footer rows below the bottom border. Rendered row count MUST equal `footerRowCount`. */\n\tfooterRows(state: DialogState): Component[];\n}\n\nexport interface QuestionTabStrategyConfig {\n\ttheme: Theme;\n\tquestions: readonly QuestionData[];\n\tgetPreviewPane: () => StatefulView<PreviewPaneProps>;\n\ttabsByIndex: ReadonlyArray<TabComponents>;\n\tnotesInput: Input;\n\tchatRow: ChatRowView;\n\tisMulti: boolean;\n}\n\nexport class QuestionTabStrategy implements TabContentStrategy {\n\t/** Spacer(1) + chatRow(1) + Spacer(1) + Text(hint, 1) = 4 rendered rows. */\n\treadonly footerRowCount = 4;\n\n\tprivate declare readonly config: QuestionTabStrategyConfig;\n\n\tconstructor(config: QuestionTabStrategyConfig) {\n\t\tthis.config = config;\n\t}\n\n\theadingRows(state: DialogState): Component[] {\n\t\tconst out: Component[] = [];\n\t\tconst question = this.config.questions[state.currentTab];\n\t\t// In multi-question mode the tab bar already shows the header; suppress the inline badge.\n\t\tif (!this.config.isMulti && question?.header && question.header.length > 0) {\n\t\t\tout.push(new Text(this.config.theme.bg(\"selectedBg\", ` ${question.header} `), 1, 0));\n\t\t\tout.push(new Spacer(1));\n\t\t}\n\t\tif (question) {\n\t\t\tout.push(new Text(this.config.theme.bold(question.question), 1, 0));\n\t\t\tout.push(new Spacer(1));\n\t\t}\n\t\treturn out;\n\t}\n\n\tbodyComponent(state: DialogState): Component {\n\t\tconst question = this.config.questions[state.currentTab];\n\t\tconst mso = this.config.tabsByIndex[state.currentTab]?.multiSelect;\n\t\tif (question?.multiSelect === true && mso) return mso;\n\t\treturn this.config.getPreviewPane();\n\t}\n\n\tmidRows(state: DialogState): Component[] {\n\t\tif (!state.notesVisible) return [];\n\t\tconst { theme, notesInput } = this.config;\n\t\t// Notes mode open means the notes field has focus, so this resolves to `editing`.\n\t\tconst tone = fieldTone(state.notesVisible, state.notesDraft);\n\t\tconst notesField: Component = {\n\t\t\trender: (width) => notesInput.render(width).map((line) => styleFieldTone(theme, tone, line)),\n\t\t\tinvalidate: () => notesInput.invalidate(),\n\t\t};\n\t\treturn [new Text(theme.fg(\"muted\", NOTES_HEADER), 1, 0), notesField, new Spacer(1)];\n\t}\n\n\tfooterRows(state: DialogState): Component[] {\n\t\tconst question = this.config.questions[state.currentTab];\n\t\treturn [\n\t\t\tnew Spacer(1),\n\t\t\tthis.config.chatRow,\n\t\t\tnew Spacer(1),\n\t\t\tnew Text(this.config.theme.fg(\"dim\", buildHintText(question, this.config.isMulti, state)), 1, 0),\n\t\t];\n\t}\n}\n\nexport interface SubmitTabStrategyConfig {\n\ttheme: Theme;\n\tquestions: readonly QuestionData[];\n\tsubmitPicker: Component | undefined;\n}\n\nexport class SubmitTabStrategy implements TabContentStrategy {\n\t/** Spacer(1) + Text(prompt, 1) + Spacer(1) + submitPicker(2) = 5 rendered rows. Fallback path lands at 5 via 2 trailing Spacer(1)s. */\n\treadonly footerRowCount = 5;\n\n\tprivate declare readonly config: SubmitTabStrategyConfig;\n\n\tconstructor(config: SubmitTabStrategyConfig) {\n\t\tthis.config = config;\n\t}\n\n\theadingRows(_state: DialogState): Component[] {\n\t\treturn [new Text(this.config.theme.bold(this.config.theme.fg(\"accent\", REVIEW_HEADING)), 1, 0), new Spacer(1)];\n\t}\n\n\tbodyComponent(state: DialogState): Component {\n\t\tconst c = new Container();\n\t\tfor (let i = 0; i < this.config.questions.length; i++) {\n\t\t\tconst q = this.config.questions[i];\n\t\t\tconst a = state.answers.get(i);\n\t\t\tif (!a) continue;\n\t\t\tconst label = q.header && q.header.length > 0 ? q.header : `Q${i + 1}`;\n\t\t\tconst answerText = formatAnswerScalar(a, \"summary\");\n\t\t\tc.addChild(new Text(this.config.theme.fg(\"muted\", ` ● ${label}`), 1, 0));\n\t\t\tconst { theme } = this.config;\n\t\t\tc.addChild(new Text(` ${theme.fg(\"muted\", \"→\")} ${styleFieldTone(theme, \"answered\", answerText)}`, 1, 0));\n\t\t\tif (a.notes && a.notes.length > 0) {\n\t\t\t\tc.addChild(\n\t\t\t\t\tnew Text(` ${theme.fg(\"muted\", \"notes:\")} ${styleFieldTone(theme, \"answered\", a.notes)}`, 1, 0),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn c;\n\t}\n\n\tmidRows(_state: DialogState): Component[] {\n\t\treturn [];\n\t}\n\n\tfooterRows(state: DialogState): Component[] {\n\t\tconst missing: string[] = [];\n\t\tfor (let i = 0; i < this.config.questions.length; i++) {\n\t\t\tconst q = this.config.questions[i];\n\t\t\tif (!state.answers.has(i)) {\n\t\t\t\tmissing.push(q.header && q.header.length > 0 ? q.header : `Q${i + 1}`);\n\t\t\t}\n\t\t}\n\t\tconst promptText =\n\t\t\tmissing.length === 0\n\t\t\t\t? this.config.theme.fg(\"muted\", READY_PROMPT)\n\t\t\t\t: this.config.theme.fg(\"warning\", `${INCOMPLETE_WARNING_PREFIX} ${missing.join(\", \")}`);\n\t\tconst out: Component[] = [new Spacer(1), new Text(promptText, 1, 0), new Spacer(1)];\n\t\tif (this.config.submitPicker) {\n\t\t\tout.push(this.config.submitPicker);\n\t\t} else {\n\t\t\t// Padding when the picker isn't wired — keeps rendered row count at footerRowCount=5.\n\t\t\tout.push(new Spacer(1));\n\t\t\tout.push(new Spacer(1));\n\t\t}\n\t\treturn out;\n\t}\n}\n\n/**\n * Build the controls hint line. Order is fixed so `HINT_SINGLE` / `HINT_MULTI`\n * remain contiguous substrings of the result:\n * Enter · ↑/↓ [· Space toggle] [· n notes] [· Tab switch] · Esc\n */\nexport function buildHintText(question: QuestionData | undefined, isMulti: boolean, state: DialogState): string {\n\tconst parts: string[] = [HINT_PART_ENTER, HINT_PART_NAV];\n\tif (question?.multiSelect === true) parts.push(HINT_PART_TOGGLE);\n\tif (question && question.multiSelect !== true && state.focusedOptionHasPreview && !state.notesVisible) {\n\t\tparts.push(HINT_PART_NOTES);\n\t}\n\tif (isMulti) parts.push(HINT_PART_TAB);\n\tparts.push(HINT_PART_CANCEL);\n\treturn parts.join(\" · \");\n}\n"]}
@@ -35,6 +35,7 @@ export interface ReadToolDetails {
35
35
  resolvedPath?: string;
36
36
  truncation?: TruncationResult;
37
37
  oversizedRead?: OversizedReadDetails;
38
+ imageUnsupportedByModel?: string;
38
39
  meta?: {
39
40
  source?: string;
40
41
  sourcePath?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA4B,uBAAuB,EAAe,MAAM,uBAAuB,CAAC;AAC5G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI/D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAO5C,OAAO,KAAK,EAAoB,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AAExG,OAAO,EAGN,KAAK,kBAAkB,EAEvB,MAAM,qBAAqB,CAAC;AAmC7B,OAAO,EAAoD,KAAK,gBAAgB,EAAgB,MAAM,eAAe,CAAC;AAEtH,QAAA,MAAM,UAAU;;EAQf,CAAC;AACF,eAAO,MAAM,gCAAgC;sBACnC,uBAAuB;;EAItB,CA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C,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,IAAI,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IAChG,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,EAAE,GAAG,SAAS,CAAC,CAAC;IAC9E,mBAAmB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACnF;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,KAAK,aAAa,CAAC,UAAU,CAAC,CAAC;CAC1G;AAUD,MAAM,WAAW,eAAe;IAC/B,mDAAmD;IACnD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gFAAgF;IAChF,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC,UAAU,CAAC,EAAE,cAAc,CAAC;CAC5B;AAgMD,wBAAgB,wBAAwB,CACvC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,eAAe,GACvB,cAAc,CAAC,OAAO,UAAU,EAAE,eAAe,GAAG,SAAS,CAAC,CAwiBhE;AACD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAEnG"}
@@ -70,11 +70,6 @@ function toReadOutput(content) {
70
70
  const image = content.find((block) => block.type === "image");
71
71
  return image ? { type: "image", data: image.data, mimeType: image.mimeType, note: text } : text;
72
72
  }
73
- function getNonVisionImageNote(model) {
74
- return !model || model.input.includes("image")
75
- ? undefined
76
- : "[Current model does not support images. The image will be omitted from this request.]";
77
- }
78
73
  function toPosixPath(filePath) {
79
74
  return filePath.split(sep).join("/");
80
75
  }
@@ -174,10 +169,14 @@ function formatCompactReadCall(classification, args, theme) {
174
169
  expandHint);
175
170
  }
176
171
  function formatReadResult(args, result, options, theme, showImages, _cwd, isError) {
172
+ const unsupportedBy = result.details?.imageUnsupportedByModel;
173
+ const imageWarning = unsupportedBy
174
+ ? `\n${theme.fg("warning", `[${unsupportedBy} does not support images; it saw a placeholder instead]`)}`
175
+ : "";
177
176
  const oversizedRead = result.details?.oversizedRead;
178
177
  const oversizedReadBlocked = oversizedRead?.blocked === true;
179
178
  if (!options.expanded && !isError && !oversizedReadBlocked) {
180
- return "";
179
+ return imageWarning;
181
180
  }
182
181
  const rawPath = str(args?.path);
183
182
  const output = oversizedRead ? buildOversizedReadMessage(oversizedRead) : getTextOutput(result, showImages);
@@ -204,7 +203,7 @@ function formatReadResult(args, result, options, theme, showImages, _cwd, isErro
204
203
  text += `\n${theme.fg("warning", `[Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)]`)}`;
205
204
  }
206
205
  }
207
- return text;
206
+ return text + imageWarning;
208
207
  }
209
208
  function archiveSelectorMemberExists(pathValue, cwd) {
210
209
  const archive = parseArchiveSelector(pathValue);
@@ -535,30 +534,30 @@ export function createReadToolDefinition(cwd, options) {
535
534
  return;
536
535
  }
537
536
  const mimeType = ops.detectImageMimeType ? await ops.detectImageMimeType(absolutePath) : undefined;
538
- const nonVisionImageNote = getNonVisionImageNote(ctx?.model);
539
537
  if (mimeType) {
540
- // Read image as binary.
541
538
  const buffer = await ops.readFile(absolutePath);
542
539
  const processed = await processImage(buffer, mimeType, {
543
540
  autoResizeImages,
544
541
  resizeOptions: ctx?.model?.inputLimits?.images?.resize ?? fallbackResizeOptions,
545
542
  });
546
543
  if (!processed.ok) {
547
- let textNote = `Read image file [${mimeType}]\n${processed.message}`;
548
- if (nonVisionImageNote)
549
- textNote += `\n${nonVisionImageNote}`;
544
+ const textNote = `Read image file [${mimeType}]\n${processed.message}`;
550
545
  content = [{ type: "text", text: textNote }];
551
546
  }
552
547
  else {
553
548
  let textNote = `Read image file [${processed.mimeType}]`;
554
549
  if (processed.hints.length > 0)
555
550
  textNote += `\n${processed.hints.join("\n")}`;
556
- if (nonVisionImageNote)
557
- textNote += `\n${nonVisionImageNote}`;
558
551
  content = [
559
552
  { type: "text", text: textNote },
560
553
  { type: "image", data: processed.data, mimeType: processed.mimeType },
561
554
  ];
555
+ if (ctx?.model && !ctx.model.input.includes("image")) {
556
+ details = {
557
+ ...readSourceMeta(absolutePath),
558
+ imageUnsupportedByModel: ctx.model.id,
559
+ };
560
+ }
562
561
  }
563
562
  }
564
563
  else {