@bastani/atomic 0.9.84 → 0.9.85

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 +64 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +16 -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 +16 -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
@@ -156,7 +156,9 @@ export class QuestionnaireSession {
156
156
  writeInputCursor(this.inlineInput, effect.caret);
157
157
  return;
158
158
  case "set_notes_value":
159
+ // Same caret however the tab was reached; `Input.setValue` would keep the old one.
159
160
  this.notesInput.setValue(effect.value);
161
+ writeInputCursor(this.notesInput, effect.value.length);
160
162
  return;
161
163
  case "set_notes_focused":
162
164
  this.notesInput.focused = effect.focused;
@@ -1 +1 @@
1
- {"version":3,"file":"questionnaire-session.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/state/questionnaire-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAc,MAAM,wBAAwB,CAAC;AAK1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACtF,OAAO,EAA4B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AC;IACH,CAAC;IAEO,YAAY;QACnB,OAAO;YACN,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACpD,CAAC;IACH,CAAC;IAEO,WAAW;QAClB,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW;YAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QACvF,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QACzD,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,GAAG,CAAC,MAAM;YAAE,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IAC5D,CAAC;CACD","sourcesContent":["import { decodeKittyPrintable, getKeybindings, type Input } from \"@earendil-works/pi-tui\";\nimport type { Theme } from \"../../../../modes/interactive/theme/theme.js\";\nimport type { QuestionData, QuestionnaireResult, QuestionParams } from \"../tool/types.js\";\nimport type { WrappingSelectItem } from \"../view/components/wrapping-select.ts\";\nimport type { QuestionnairePropsAdapter } from \"../view/props-adapter.ts\";\nimport { buildQuestionnaire } from \"./build-questionnaire.ts\";\nimport { readInlineCaret, readInlineDraft, withInlineDraft } from \"./inline-input.ts\";\nimport { type QuestionnaireAction, routeKey } from \"./key-router.ts\";\nimport { ROW_INTENT_META } from \"./row-intent.ts\";\nimport { computeFocusedOptionHasPreview } from \"./selectors/derivations.ts\";\nimport type { QuestionnaireRuntime, QuestionnaireState } from \"./state.ts\";\nimport { type ApplyContext, type Effect, reduce } from \"./state-reducer.ts\";\n\nfunction readInputCursor(input: Input): number {\n\tconst value = input.getValue();\n\tconst raw = Reflect.get(input, \"cursor\");\n\treturn typeof raw === \"number\" && Number.isFinite(raw) ? Math.max(0, Math.min(raw, value.length)) : value.length;\n}\n\nfunction writeInputCursor(input: Input, cursor: number): void {\n\tconst value = input.getValue();\n\tReflect.set(input, \"cursor\", Math.max(0, Math.min(cursor, value.length)));\n}\n\nfunction inlineInputHandles(data: string): boolean {\n\tif (data.includes(\"\\x1b[200~\")) return true;\n\tif (data === \"\\n\") return true;\n\tconst keybindings = getKeybindings();\n\tconst inputActions: Array<Parameters<typeof keybindings.matches>[1]> = [\n\t\t\"tui.select.cancel\",\n\t\t\"tui.editor.undo\",\n\t\t\"tui.input.submit\",\n\t\t\"tui.editor.deleteCharBackward\",\n\t\t\"tui.editor.deleteCharForward\",\n\t\t\"tui.editor.deleteWordBackward\",\n\t\t\"tui.editor.deleteWordForward\",\n\t\t\"tui.editor.deleteToLineStart\",\n\t\t\"tui.editor.deleteToLineEnd\",\n\t\t\"tui.editor.yank\",\n\t\t\"tui.editor.yankPop\",\n\t\t\"tui.editor.cursorLeft\",\n\t\t\"tui.editor.cursorRight\",\n\t\t\"tui.editor.cursorLineStart\",\n\t\t\"tui.editor.cursorLineEnd\",\n\t\t\"tui.editor.cursorWordLeft\",\n\t\t\"tui.editor.cursorWordRight\",\n\t];\n\tif (inputActions.some((action) => keybindings.matches(data, action))) {\n\t\treturn true;\n\t}\n\tif (decodeKittyPrintable(data) !== undefined) return true;\n\treturn [...data].every((character) => {\n\t\tconst code = character.charCodeAt(0);\n\t\treturn code >= 32 && code !== 0x7f && !(code >= 0x80 && code <= 0x9f);\n\t});\n}\n\nexport interface QuestionnaireSessionConfig {\n\ttui: { terminal: { columns: number }; requestRender(): void };\n\ttheme: Theme;\n\tparams: QuestionParams;\n\titemsByTab: WrappingSelectItem[][];\n\tdone: (result: QuestionnaireResult) => void;\n\t/** When true, Chat about this is a plain option and does not open an inline editor. */\n\tchatAsOption?: boolean;\n}\n\nexport interface QuestionnaireSessionComponent {\n\trender(width: number): string[];\n\tinvalidate(): void;\n\thandleInput(data: string): boolean;\n}\n\nfunction initialState(): QuestionnaireState {\n\treturn {\n\t\tcurrentTab: 0,\n\t\toptionIndex: 0,\n\t\tinputMode: false,\n\t\tinlineInputOwner: null,\n\t\tnotesVisible: false,\n\t\tchatFocused: false,\n\t\tanswers: new Map(),\n\t\tmultiSelectChecked: new Set(),\n\t\tnotesByTab: new Map(),\n\t\tfocusedOptionHasPreview: false,\n\t\tsubmitChoiceIndex: 0,\n\t\tnotesDraft: \"\",\n\t\tcustomDraftByTab: new Map(),\n\t\tcustomCaretByTab: new Map(),\n\t\tchatDraftByTab: new Map(),\n\t\tchatCaretByTab: new Map(),\n\t};\n}\n\n/**\n * Slim runtime: owns the canonical state cell, the input-buffer cell, the\n * two-pass `notesVisible` dispatch loop, and the effect runner. State\n * transitions go through the pure `reduce` reducer; UI fan-out goes through\n * the `QuestionnairePropsAdapter` produced by `buildQuestionnaire`.\n */\nexport class QuestionnaireSession {\n\tprivate state: QuestionnaireState = initialState();\n\n\tprivate readonly questions: readonly QuestionData[];\n\tprivate readonly isMulti: boolean;\n\tprivate readonly itemsByTab: WrappingSelectItem[][];\n\tprivate readonly chatAsOption: boolean;\n\n\tprivate readonly notesInput: Input;\n\tprivate readonly inlineInput: Input;\n\tprivate readonly viewAdapter: QuestionnairePropsAdapter;\n\n\tprivate readonly tui: QuestionnaireSessionConfig[\"tui\"];\n\tprivate readonly done: QuestionnaireSessionConfig[\"done\"];\n\n\treadonly component: QuestionnaireSessionComponent;\n\n\tconstructor(config: QuestionnaireSessionConfig) {\n\t\tthis.tui = config.tui;\n\t\tthis.done = config.done;\n\t\tthis.questions = config.params.questions;\n\t\tthis.isMulti = this.questions.length > 1;\n\t\tthis.itemsByTab = config.itemsByTab;\n\t\tthis.chatAsOption = config.chatAsOption === true;\n\t\t// Seed from the focused option at start; the reducer keeps it in sync via withFocusedOptionHasPreview.\n\t\tthis.state = { ...this.state, focusedOptionHasPreview: computeFocusedOptionHasPreview(this.questions, 0, 0) };\n\n\t\tconst built = buildQuestionnaire({\n\t\t\ttui: this.tui,\n\t\t\ttheme: config.theme,\n\t\t\tquestions: this.questions,\n\t\t\titemsByTab: this.itemsByTab,\n\t\t\tisMulti: this.isMulti,\n\t\t\tinitialState: this.state,\n\t\t\t...(this.chatAsOption ? { chatAsOption: true } : {}),\n\t\t});\n\n\t\tthis.notesInput = built.notesInput;\n\t\tthis.inlineInput = built.inlineInput;\n\t\tthis.viewAdapter = built.adapter;\n\n\t\tthis.component = {\n\t\t\trender: built.render,\n\t\t\tinvalidate: built.invalidate,\n\t\t\thandleInput: (data) => this.dispatch(data),\n\t\t};\n\n\t\tthis.viewAdapter.apply(this.state);\n\t}\n\n\tdispatch(data: string): boolean {\n\t\tconst action = routeKey(data, this.state, this.runtime());\n\t\tif (action.kind === \"ignore\") {\n\t\t\tconst hasInlineInput = this.state.inputMode && this.state.inlineInputOwner !== null;\n\t\t\tthis.handleIgnoreInline(data);\n\t\t\treturn hasInlineInput && inlineInputHandles(data);\n\t\t}\n\t\tthis.commit(action);\n\t\treturn true;\n\t}\n\n\tprivate commit(action: QuestionnaireAction): void {\n\t\tthis.state = this.mirrorInlineInputDraft(this.state);\n\t\tconst result = reduce(this.state, action, this.applyContext());\n\t\tthis.state = result.state;\n\t\tfor (const effect of result.effects) this.runEffect(effect);\n\t\tthis.state = this.mirrorNotesDraft(this.state);\n\t\tthis.viewAdapter.apply(this.state);\n\t}\n\n\tprivate mirrorNotesDraft(s: QuestionnaireState): QuestionnaireState {\n\t\tconst draft = this.notesInput.getValue();\n\t\treturn s.notesDraft === draft ? s : { ...s, notesDraft: draft };\n\t}\n\n\tprivate mirrorInlineInputDraft(s: QuestionnaireState): QuestionnaireState {\n\t\tif (!s.inputMode || !s.inlineInputOwner) return s;\n\t\tconst owner = s.inlineInputOwner;\n\t\tconst value = this.inlineInput.getValue();\n\t\tconst caret = readInputCursor(this.inlineInput);\n\t\tif (readInlineDraft(s, owner) === value && readInlineCaret(s, owner) === caret) {\n\t\t\treturn s;\n\t\t}\n\t\treturn withInlineDraft(s, owner, value, caret);\n\t}\n\n\tprivate runEffect(effect: Effect): void {\n\t\tswitch (effect.kind) {\n\t\t\tcase \"set_input_buffer\":\n\t\t\t\tthis.inlineInput.setValue(effect.value);\n\t\t\t\twriteInputCursor(this.inlineInput, effect.caret);\n\t\t\t\treturn;\n\t\t\tcase \"set_notes_value\":\n\t\t\t\tthis.notesInput.setValue(effect.value);\n\t\t\t\treturn;\n\t\t\tcase \"set_notes_focused\":\n\t\t\t\tthis.notesInput.focused = effect.focused;\n\t\t\t\treturn;\n\t\t\tcase \"forward_notes_keystroke\":\n\t\t\t\tthis.notesInput.handleInput(effect.data);\n\t\t\t\treturn;\n\t\t\tcase \"done\":\n\t\t\t\tthis.done(effect.result);\n\t\t\t\treturn;\n\t\t}\n\t}\n\n\t/**\n\t * Per-keystroke `ignore` fast path: delegates to the headless `inlineInput`\n\t * Input so bracketed-paste accumulator (`input.js:33-63`) and Kitty CSI-u\n\t * decode (`input.js:155-163`) take effect. Cursor is NOT force-reset here —\n\t * doing so would corrupt split-chunk pastes (a `\\x05` byte mid-paste lands\n\t * verbatim in `pasteBuffer` and survives `handlePaste`'s narrow strip).\n\t * Cursor advances naturally via `insertCharacter` on typing/paste; cursor-\n\t * movement keys (Left/Right/Home/End/word-jumps) are now functional, and\n\t * the live buffer/caret are mirrored into canonical state so rendering can\n\t * draw the same thick cursor at the editing caret. `viewAdapter.apply` is\n\t * called directly without a reducer round-trip — preserves the D3 fast-path\n\t * latency profile from Phase 11.\n\t */\n\tprivate handleIgnoreInline(data: string): void {\n\t\tif (!this.state.inputMode || !this.state.inlineInputOwner) return;\n\t\tthis.inlineInput.handleInput(data);\n\t\tthis.state = this.mirrorInlineInputDraft(this.state);\n\t\tthis.viewAdapter.apply(this.state);\n\t}\n\n\tprivate runtime(): QuestionnaireRuntime {\n\t\treturn {\n\t\t\tkeybindings: getKeybindings(),\n\t\t\tinputBuffer: this.inlineInput.getValue(),\n\t\t\tquestions: this.questions,\n\t\t\tisMulti: this.isMulti,\n\t\t\tcurrentItem: this.currentItem(),\n\t\t\titems: this.itemsByTab[this.state.currentTab] ?? [],\n\t\t};\n\t}\n\n\tprivate applyContext(): ApplyContext {\n\t\treturn {\n\t\t\tquestions: this.questions,\n\t\t\titemsByTab: this.itemsByTab,\n\t\t\t...(this.chatAsOption ? { chatAsOption: true } : {}),\n\t\t};\n\t}\n\n\tprivate currentItem(): WrappingSelectItem | undefined {\n\t\tif (this.state.chatFocused) return { kind: \"chat\", label: ROW_INTENT_META.chat.label };\n\t\tconst arr = this.itemsByTab[this.state.currentTab] ?? [];\n\t\tif (this.state.optionIndex < arr.length) return arr[this.state.optionIndex];\n\t\treturn { kind: \"chat\", label: ROW_INTENT_META.chat.label };\n\t}\n}\n"]}
1
+ {"version":3,"file":"questionnaire-session.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/state/questionnaire-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAc,MAAM,wBAAwB,CAAC;AAK1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACtF,OAAO,EAA4B,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAE5E,OAAO,EAAkC,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5E,SAAS,eAAe,CAAC,KAAY;IACpC,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC/B,MAAM,GAAG,GAAG,OAAO,C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CAAC,EAAE,CAAC;SACpD,CAAC;IACH,CAAC;IAEO,WAAW;QAClB,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW;YAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QACvF,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QACzD,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,GAAG,CAAC,MAAM;YAAE,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IAC5D,CAAC;CACD","sourcesContent":["import { decodeKittyPrintable, getKeybindings, type Input } from \"@earendil-works/pi-tui\";\nimport type { Theme } from \"../../../../modes/interactive/theme/theme.js\";\nimport type { QuestionData, QuestionnaireResult, QuestionParams } from \"../tool/types.js\";\nimport type { WrappingSelectItem } from \"../view/components/wrapping-select.ts\";\nimport type { QuestionnairePropsAdapter } from \"../view/props-adapter.ts\";\nimport { buildQuestionnaire } from \"./build-questionnaire.ts\";\nimport { readInlineCaret, readInlineDraft, withInlineDraft } from \"./inline-input.ts\";\nimport { type QuestionnaireAction, routeKey } from \"./key-router.ts\";\nimport { ROW_INTENT_META } from \"./row-intent.ts\";\nimport { computeFocusedOptionHasPreview } from \"./selectors/derivations.ts\";\nimport type { QuestionnaireRuntime, QuestionnaireState } from \"./state.ts\";\nimport { type ApplyContext, type Effect, reduce } from \"./state-reducer.ts\";\n\nfunction readInputCursor(input: Input): number {\n\tconst value = input.getValue();\n\tconst raw = Reflect.get(input, \"cursor\");\n\treturn typeof raw === \"number\" && Number.isFinite(raw) ? Math.max(0, Math.min(raw, value.length)) : value.length;\n}\n\nfunction writeInputCursor(input: Input, cursor: number): void {\n\tconst value = input.getValue();\n\tReflect.set(input, \"cursor\", Math.max(0, Math.min(cursor, value.length)));\n}\n\nfunction inlineInputHandles(data: string): boolean {\n\tif (data.includes(\"\\x1b[200~\")) return true;\n\tif (data === \"\\n\") return true;\n\tconst keybindings = getKeybindings();\n\tconst inputActions: Array<Parameters<typeof keybindings.matches>[1]> = [\n\t\t\"tui.select.cancel\",\n\t\t\"tui.editor.undo\",\n\t\t\"tui.input.submit\",\n\t\t\"tui.editor.deleteCharBackward\",\n\t\t\"tui.editor.deleteCharForward\",\n\t\t\"tui.editor.deleteWordBackward\",\n\t\t\"tui.editor.deleteWordForward\",\n\t\t\"tui.editor.deleteToLineStart\",\n\t\t\"tui.editor.deleteToLineEnd\",\n\t\t\"tui.editor.yank\",\n\t\t\"tui.editor.yankPop\",\n\t\t\"tui.editor.cursorLeft\",\n\t\t\"tui.editor.cursorRight\",\n\t\t\"tui.editor.cursorLineStart\",\n\t\t\"tui.editor.cursorLineEnd\",\n\t\t\"tui.editor.cursorWordLeft\",\n\t\t\"tui.editor.cursorWordRight\",\n\t];\n\tif (inputActions.some((action) => keybindings.matches(data, action))) {\n\t\treturn true;\n\t}\n\tif (decodeKittyPrintable(data) !== undefined) return true;\n\treturn [...data].every((character) => {\n\t\tconst code = character.charCodeAt(0);\n\t\treturn code >= 32 && code !== 0x7f && !(code >= 0x80 && code <= 0x9f);\n\t});\n}\n\nexport interface QuestionnaireSessionConfig {\n\ttui: { terminal: { columns: number }; requestRender(): void };\n\ttheme: Theme;\n\tparams: QuestionParams;\n\titemsByTab: WrappingSelectItem[][];\n\tdone: (result: QuestionnaireResult) => void;\n\t/** When true, Chat about this is a plain option and does not open an inline editor. */\n\tchatAsOption?: boolean;\n}\n\nexport interface QuestionnaireSessionComponent {\n\trender(width: number): string[];\n\tinvalidate(): void;\n\thandleInput(data: string): boolean;\n}\n\nfunction initialState(): QuestionnaireState {\n\treturn {\n\t\tcurrentTab: 0,\n\t\toptionIndex: 0,\n\t\tinputMode: false,\n\t\tinlineInputOwner: null,\n\t\tnotesVisible: false,\n\t\tchatFocused: false,\n\t\tanswers: new Map(),\n\t\tmultiSelectChecked: new Set(),\n\t\tnotesByTab: new Map(),\n\t\tfocusedOptionHasPreview: false,\n\t\tsubmitChoiceIndex: 0,\n\t\tnotesDraft: \"\",\n\t\tcustomDraftByTab: new Map(),\n\t\tcustomCaretByTab: new Map(),\n\t\tchatDraftByTab: new Map(),\n\t\tchatCaretByTab: new Map(),\n\t};\n}\n\n/**\n * Slim runtime: owns the canonical state cell, the input-buffer cell, the\n * two-pass `notesVisible` dispatch loop, and the effect runner. State\n * transitions go through the pure `reduce` reducer; UI fan-out goes through\n * the `QuestionnairePropsAdapter` produced by `buildQuestionnaire`.\n */\nexport class QuestionnaireSession {\n\tprivate state: QuestionnaireState = initialState();\n\n\tprivate readonly questions: readonly QuestionData[];\n\tprivate readonly isMulti: boolean;\n\tprivate readonly itemsByTab: WrappingSelectItem[][];\n\tprivate readonly chatAsOption: boolean;\n\n\tprivate readonly notesInput: Input;\n\tprivate readonly inlineInput: Input;\n\tprivate readonly viewAdapter: QuestionnairePropsAdapter;\n\n\tprivate readonly tui: QuestionnaireSessionConfig[\"tui\"];\n\tprivate readonly done: QuestionnaireSessionConfig[\"done\"];\n\n\treadonly component: QuestionnaireSessionComponent;\n\n\tconstructor(config: QuestionnaireSessionConfig) {\n\t\tthis.tui = config.tui;\n\t\tthis.done = config.done;\n\t\tthis.questions = config.params.questions;\n\t\tthis.isMulti = this.questions.length > 1;\n\t\tthis.itemsByTab = config.itemsByTab;\n\t\tthis.chatAsOption = config.chatAsOption === true;\n\t\t// Seed from the focused option at start; the reducer keeps it in sync via withFocusedOptionHasPreview.\n\t\tthis.state = { ...this.state, focusedOptionHasPreview: computeFocusedOptionHasPreview(this.questions, 0, 0) };\n\n\t\tconst built = buildQuestionnaire({\n\t\t\ttui: this.tui,\n\t\t\ttheme: config.theme,\n\t\t\tquestions: this.questions,\n\t\t\titemsByTab: this.itemsByTab,\n\t\t\tisMulti: this.isMulti,\n\t\t\tinitialState: this.state,\n\t\t\t...(this.chatAsOption ? { chatAsOption: true } : {}),\n\t\t});\n\n\t\tthis.notesInput = built.notesInput;\n\t\tthis.inlineInput = built.inlineInput;\n\t\tthis.viewAdapter = built.adapter;\n\n\t\tthis.component = {\n\t\t\trender: built.render,\n\t\t\tinvalidate: built.invalidate,\n\t\t\thandleInput: (data) => this.dispatch(data),\n\t\t};\n\n\t\tthis.viewAdapter.apply(this.state);\n\t}\n\n\tdispatch(data: string): boolean {\n\t\tconst action = routeKey(data, this.state, this.runtime());\n\t\tif (action.kind === \"ignore\") {\n\t\t\tconst hasInlineInput = this.state.inputMode && this.state.inlineInputOwner !== null;\n\t\t\tthis.handleIgnoreInline(data);\n\t\t\treturn hasInlineInput && inlineInputHandles(data);\n\t\t}\n\t\tthis.commit(action);\n\t\treturn true;\n\t}\n\n\tprivate commit(action: QuestionnaireAction): void {\n\t\tthis.state = this.mirrorInlineInputDraft(this.state);\n\t\tconst result = reduce(this.state, action, this.applyContext());\n\t\tthis.state = result.state;\n\t\tfor (const effect of result.effects) this.runEffect(effect);\n\t\tthis.state = this.mirrorNotesDraft(this.state);\n\t\tthis.viewAdapter.apply(this.state);\n\t}\n\n\tprivate mirrorNotesDraft(s: QuestionnaireState): QuestionnaireState {\n\t\tconst draft = this.notesInput.getValue();\n\t\treturn s.notesDraft === draft ? s : { ...s, notesDraft: draft };\n\t}\n\n\tprivate mirrorInlineInputDraft(s: QuestionnaireState): QuestionnaireState {\n\t\tif (!s.inputMode || !s.inlineInputOwner) return s;\n\t\tconst owner = s.inlineInputOwner;\n\t\tconst value = this.inlineInput.getValue();\n\t\tconst caret = readInputCursor(this.inlineInput);\n\t\tif (readInlineDraft(s, owner) === value && readInlineCaret(s, owner) === caret) {\n\t\t\treturn s;\n\t\t}\n\t\treturn withInlineDraft(s, owner, value, caret);\n\t}\n\n\tprivate runEffect(effect: Effect): void {\n\t\tswitch (effect.kind) {\n\t\t\tcase \"set_input_buffer\":\n\t\t\t\tthis.inlineInput.setValue(effect.value);\n\t\t\t\twriteInputCursor(this.inlineInput, effect.caret);\n\t\t\t\treturn;\n\t\t\tcase \"set_notes_value\":\n\t\t\t\t// Same caret however the tab was reached; `Input.setValue` would keep the old one.\n\t\t\t\tthis.notesInput.setValue(effect.value);\n\t\t\t\twriteInputCursor(this.notesInput, effect.value.length);\n\t\t\t\treturn;\n\t\t\tcase \"set_notes_focused\":\n\t\t\t\tthis.notesInput.focused = effect.focused;\n\t\t\t\treturn;\n\t\t\tcase \"forward_notes_keystroke\":\n\t\t\t\tthis.notesInput.handleInput(effect.data);\n\t\t\t\treturn;\n\t\t\tcase \"done\":\n\t\t\t\tthis.done(effect.result);\n\t\t\t\treturn;\n\t\t}\n\t}\n\n\t/**\n\t * Per-keystroke `ignore` fast path: delegates to the headless `inlineInput`\n\t * Input so bracketed-paste accumulator (`input.js:33-63`) and Kitty CSI-u\n\t * decode (`input.js:155-163`) take effect. Cursor is NOT force-reset here —\n\t * doing so would corrupt split-chunk pastes (a `\\x05` byte mid-paste lands\n\t * verbatim in `pasteBuffer` and survives `handlePaste`'s narrow strip).\n\t * Cursor advances naturally via `insertCharacter` on typing/paste; cursor-\n\t * movement keys (Left/Right/Home/End/word-jumps) are now functional, and\n\t * the live buffer/caret are mirrored into canonical state so rendering can\n\t * draw the same thick cursor at the editing caret. `viewAdapter.apply` is\n\t * called directly without a reducer round-trip — preserves the D3 fast-path\n\t * latency profile from Phase 11.\n\t */\n\tprivate handleIgnoreInline(data: string): void {\n\t\tif (!this.state.inputMode || !this.state.inlineInputOwner) return;\n\t\tthis.inlineInput.handleInput(data);\n\t\tthis.state = this.mirrorInlineInputDraft(this.state);\n\t\tthis.viewAdapter.apply(this.state);\n\t}\n\n\tprivate runtime(): QuestionnaireRuntime {\n\t\treturn {\n\t\t\tkeybindings: getKeybindings(),\n\t\t\tinputBuffer: this.inlineInput.getValue(),\n\t\t\tquestions: this.questions,\n\t\t\tisMulti: this.isMulti,\n\t\t\tcurrentItem: this.currentItem(),\n\t\t\titems: this.itemsByTab[this.state.currentTab] ?? [],\n\t\t};\n\t}\n\n\tprivate applyContext(): ApplyContext {\n\t\treturn {\n\t\t\tquestions: this.questions,\n\t\t\titemsByTab: this.itemsByTab,\n\t\t\t...(this.chatAsOption ? { chatAsOption: true } : {}),\n\t\t};\n\t}\n\n\tprivate currentItem(): WrappingSelectItem | undefined {\n\t\tif (this.state.chatFocused) return { kind: \"chat\", label: ROW_INTENT_META.chat.label };\n\t\tconst arr = this.itemsByTab[this.state.currentTab] ?? [];\n\t\tif (this.state.optionIndex < arr.length) return arr[this.state.optionIndex];\n\t\treturn { kind: \"chat\", label: ROW_INTENT_META.chat.label };\n\t}\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import type { Theme, ThemeColor } from "../../../../../modes/interactive/theme/theme.js";
2
+ /**
3
+ * Display state of a text part of the dialog — the "Type something." answer, the
4
+ * "Chat about this" row, the notes field — and of the rows that hold an answer.
5
+ *
6
+ * - `editing`: the field has focus and takes keystrokes.
7
+ * - `answered`: the field holds text (or the row holds the chosen answer) but has no focus.
8
+ * - `placeholder`: the field is empty and unfocused, so it shows its prompt.
9
+ *
10
+ * Every renderer asks this module for both the tone and its color, so a field's color is a
11
+ * pure function of the state it is rendered from. Arriving at a question forward, with
12
+ * ←/Shift+Tab, or from the review tab cannot leave a stale color behind (#4741).
13
+ */
14
+ export type FieldTone = "editing" | "answered" | "placeholder";
15
+ /** Theme token per tone. `editing` is also bold: bold marks the focused selection. */
16
+ export declare const FIELD_TONE_COLOR: Readonly<Record<FieldTone, ThemeColor>>;
17
+ /** Tone of a text field: focused wins, then whether it holds non-blank text. */
18
+ export declare function fieldTone(focused: boolean, value: string): FieldTone;
19
+ /**
20
+ * Tone of an option row. A row is not a text field, so an unfocused row that holds no
21
+ * answer has no tone and keeps the ordinary text style.
22
+ */
23
+ export declare function rowTone(focused: boolean, answered: boolean): FieldTone | undefined;
24
+ /** Paint `text` in `tone`'s color. */
25
+ export declare function styleFieldTone(theme: Theme, tone: FieldTone, text: string): string;
26
+ //# sourceMappingURL=field-tone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-tone.d.ts","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/state/selectors/field-tone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,iDAAiD,CAAC;AAEzF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,CAAC;AAE/D,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAIpE,CAAC;AAEF,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAGpE;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAGlF;AAED,sCAAsC;AACtC,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAGlF"}
@@ -0,0 +1,27 @@
1
+ /** Theme token per tone. `editing` is also bold: bold marks the focused selection. */
2
+ export const FIELD_TONE_COLOR = {
3
+ editing: "accent",
4
+ answered: "text",
5
+ placeholder: "muted",
6
+ };
7
+ /** Tone of a text field: focused wins, then whether it holds non-blank text. */
8
+ export function fieldTone(focused, value) {
9
+ if (focused)
10
+ return "editing";
11
+ return value.trim().length > 0 ? "answered" : "placeholder";
12
+ }
13
+ /**
14
+ * Tone of an option row. A row is not a text field, so an unfocused row that holds no
15
+ * answer has no tone and keeps the ordinary text style.
16
+ */
17
+ export function rowTone(focused, answered) {
18
+ if (focused)
19
+ return "editing";
20
+ return answered ? "answered" : undefined;
21
+ }
22
+ /** Paint `text` in `tone`'s color. */
23
+ export function styleFieldTone(theme, tone, text) {
24
+ const color = FIELD_TONE_COLOR[tone];
25
+ return theme.fg(color, tone === "editing" ? theme.bold(text) : text);
26
+ }
27
+ //# sourceMappingURL=field-tone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-tone.js","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/state/selectors/field-tone.ts"],"names":[],"mappings":"AAgBA,sFAAsF;AACtF,MAAM,CAAC,MAAM,gBAAgB,GAA4C;IACxE,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,MAAM;IAChB,WAAW,EAAE,OAAO;CACpB,CAAC;AAEF,gFAAgF;AAChF,MAAM,UAAU,SAAS,CAAC,OAAgB,EAAE,KAAa;IACxD,IAAI,OAAO;QAAE,OAAO,SAAS,CAAC;IAC9B,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC;AAC7D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,OAAgB,EAAE,QAAiB;IAC1D,IAAI,OAAO;QAAE,OAAO,SAAS,CAAC;IAC9B,OAAO,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1C,CAAC;AAED,sCAAsC;AACtC,MAAM,UAAU,cAAc,CAAC,KAAY,EAAE,IAAe,EAAE,IAAY;IACzE,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACtE,CAAC","sourcesContent":["import type { Theme, ThemeColor } from \"../../../../../modes/interactive/theme/theme.js\";\n\n/**\n * Display state of a text part of the dialog — the \"Type something.\" answer, the\n * \"Chat about this\" row, the notes field — and of the rows that hold an answer.\n *\n * - `editing`: the field has focus and takes keystrokes.\n * - `answered`: the field holds text (or the row holds the chosen answer) but has no focus.\n * - `placeholder`: the field is empty and unfocused, so it shows its prompt.\n *\n * Every renderer asks this module for both the tone and its color, so a field's color is a\n * pure function of the state it is rendered from. Arriving at a question forward, with\n * ←/Shift+Tab, or from the review tab cannot leave a stale color behind (#4741).\n */\nexport type FieldTone = \"editing\" | \"answered\" | \"placeholder\";\n\n/** Theme token per tone. `editing` is also bold: bold marks the focused selection. */\nexport const FIELD_TONE_COLOR: Readonly<Record<FieldTone, ThemeColor>> = {\n\tediting: \"accent\",\n\tanswered: \"text\",\n\tplaceholder: \"muted\",\n};\n\n/** Tone of a text field: focused wins, then whether it holds non-blank text. */\nexport function fieldTone(focused: boolean, value: string): FieldTone {\n\tif (focused) return \"editing\";\n\treturn value.trim().length > 0 ? \"answered\" : \"placeholder\";\n}\n\n/**\n * Tone of an option row. A row is not a text field, so an unfocused row that holds no\n * answer has no tone and keeps the ordinary text style.\n */\nexport function rowTone(focused: boolean, answered: boolean): FieldTone | undefined {\n\tif (focused) return \"editing\";\n\treturn answered ? \"answered\" : undefined;\n}\n\n/** Paint `text` in `tone`'s color. */\nexport function styleFieldTone(theme: Theme, tone: FieldTone, text: string): string {\n\tconst color = FIELD_TONE_COLOR[tone];\n\treturn theme.fg(color, tone === \"editing\" ? theme.bold(text) : text);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"projections.d.ts","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/state/selectors/projections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAC3G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpE,eAAO,MAAM,sBAAsB,EAAE,cAAc,CAAC,oBAAoB,CAevE,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,mBAAmB,CAWrE,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAAC,iBAAiB,CAQrE,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,cAAc,CAAC,gBAAgB,CAIlE,CAAC;AAEH,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAAC,WAAW,CAazD,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAAC,gBAAgB,CAQ/D,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAAC,WAAW,CAGxD,CAAC"}
1
+ {"version":3,"file":"projections.d.ts","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/state/selectors/projections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAC3G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpE,eAAO,MAAM,sBAAsB,EAAE,cAAc,CAAC,oBAAoB,CAevE,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,mBAAmB,CAWrE,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAAC,iBAAiB,CAQrE,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,cAAc,CAAC,gBAAgB,CAKlE,CAAC;AAEH,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAAC,WAAW,CAazD,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAAC,gBAAgB,CAQ/D,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAAC,WAAW,CAGxD,CAAC"}
@@ -43,6 +43,7 @@ export const selectPreviewPaneProps = (state, ctx) => ({
43
43
  notesVisible: state.notesVisible,
44
44
  selectedIndex: state.optionIndex,
45
45
  focused: ctx.activeView === "options",
46
+ notes: state.notesByTab.get(state.currentTab) ?? state.answers.get(state.currentTab)?.notes ?? "",
46
47
  });
47
48
  export const selectTabBarProps = (state, ctx) => {
48
49
  const tabs = ctx.questions.map((q, i) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"projections.js","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/state/selectors/projections.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAA6B,MAAM,4CAA4C,CAAC;AAM3G,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAEpG,MAAM,CAAC,MAAM,sBAAsB,GAAyC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAC1F,MAAM,QAAQ,GAAG,GAAG,CAAC,SA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AAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAC/D,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9B,MAAM,EAAE,CAAC,KAAK,KAAK,CAAC,UAAU;KAC9B,CAAC,CAAC,CAAC;IACJ,OAAO;QACN,IAAI;QACJ,MAAM,EAAE;YACP,MAAM,EAAE,KAAK,CAAC,UAAU,KAAK,GAAG,CAAC,SAAS,CAAC,MAAM;YACjD,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,GAAG,CAAC,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;SACpF;KACD,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAqC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAClF,MAAM,WAAW,GAAG,oBAAoB,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC/F,OAAO;QACN,OAAO,EAAE,GAAG,CAAC,UAAU,KAAK,MAAM;QAClC,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC;QACxC,WAAW,EAAE,GAAG,CAAC,eAAe;QAChC,UAAU,EAAE,GAAG,CAAC,cAAc;KAC9B,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAgC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IAC9E,KAAK;IACL,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;CACxC,CAAC,CAAC","sourcesContent":["import type { ChatRowViewProps } from \"../../view/components/chat-row-view.ts\";\nimport { MULTI_SUBMIT_LABEL, type MultiSelectViewProps } from \"../../view/components/multi-select-view.ts\";\nimport type { OptionListViewProps } from \"../../view/components/option-list-view.ts\";\nimport type { PreviewPaneProps } from \"../../view/components/preview/preview-pane.ts\";\nimport type { SubmitPickerProps } from \"../../view/components/submit-picker.ts\";\nimport type { TabBarProps } from \"../../view/components/tab-bar.ts\";\nimport type { DialogProps } from \"../../view/dialog-builder.ts\";\nimport { ROW_INTENT_META } from \"../row-intent.ts\";\nimport type { GlobalSelector, PerTabSelector } from \"./contract.ts\";\nimport { chatNumberingFor, selectActiveTabItems, selectConfirmedIndicator } from \"./derivations.ts\";\n\nexport const selectMultiSelectProps: PerTabSelector<MultiSelectViewProps> = (state, ctx) => {\n\tconst question = ctx.questions[ctx.i];\n\tif (!question) return { rows: [], nextActive: false, nextLabel: ROW_INTENT_META.next.label };\n\tconst focused = ctx.activeView === \"options\";\n\tconst rows: { checked: boolean; active: boolean }[] = [];\n\tfor (let i = 0; i < question.options.length; i++) {\n\t\trows.push({\n\t\t\tchecked: state.multiSelectChecked.has(i),\n\t\t\tactive: focused && i === state.optionIndex,\n\t\t});\n\t}\n\tconst nextActive = focused && state.optionIndex === question.options.length;\n\tconst isLastQuestion = ctx.i === ctx.questions.length - 1;\n\tconst nextLabel = isLastQuestion ? MULTI_SUBMIT_LABEL : ROW_INTENT_META.next.label;\n\treturn { rows, nextActive, nextLabel };\n};\n\nexport const selectOptionListProps: PerTabSelector<OptionListViewProps> = (state, ctx) => {\n\tconst items = ctx.itemsByTab[ctx.i] ?? [];\n\tconst focused = ctx.activeView === \"options\";\n\tconst confirmed = selectConfirmedIndicator(ctx.questions, state.currentTab, state.answers, items);\n\treturn {\n\t\tselectedIndex: state.optionIndex,\n\t\tfocused,\n\t\tinputBuffer: ctx.inputBuffer,\n\t\tinputCaret: ctx.inputCaret,\n\t\t...(confirmed ? { confirmed } : {}),\n\t};\n};\n\nexport const selectSubmitPickerProps: GlobalSelector<SubmitPickerProps> = (state, ctx) => {\n\tconst focused = ctx.activeView === \"submit\";\n\treturn {\n\t\trows: [\n\t\t\t{ active: focused && state.submitChoiceIndex === 0 },\n\t\t\t{ active: focused && state.submitChoiceIndex === 1 },\n\t\t],\n\t};\n};\n\nexport const selectPreviewPaneProps: PerTabSelector<PreviewPaneProps> = (state, ctx) => ({\n\tnotesVisible: state.notesVisible,\n\tselectedIndex: state.optionIndex,\n\tfocused: ctx.activeView === \"options\",\n});\n\nexport const selectTabBarProps: GlobalSelector<TabBarProps> = (state, ctx) => {\n\tconst tabs = ctx.questions.map((q, i) => ({\n\t\tlabel: q.header && q.header.length > 0 ? q.header : `Q${i + 1}`,\n\t\tanswered: state.answers.has(i),\n\t\tactive: i === state.currentTab,\n\t}));\n\treturn {\n\t\ttabs,\n\t\tsubmit: {\n\t\t\tactive: state.currentTab === ctx.questions.length,\n\t\t\tallAnswered: state.answers.size === ctx.questions.length && ctx.questions.length > 0,\n\t\t},\n\t};\n};\n\nexport const selectChatRowProps: GlobalSelector<ChatRowViewProps> = (state, ctx) => {\n\tconst activeItems = selectActiveTabItems(ctx.itemsByTab, state.currentTab, ctx.totalQuestions);\n\treturn {\n\t\tfocused: ctx.activeView === \"chat\",\n\t\tnumbering: chatNumberingFor(activeItems),\n\t\tinputBuffer: ctx.chatInputBuffer,\n\t\tinputCaret: ctx.chatInputCaret,\n\t};\n};\n\nexport const selectDialogProps: GlobalSelector<DialogProps> = (state, ctx) => ({\n\tstate,\n\tactivePreviewPane: ctx.activePreviewPane,\n});\n"]}
1
+ {"version":3,"file":"projections.js","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/state/selectors/projections.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAA6B,MAAM,4CAA4C,CAAC;AAM3G,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAEpG,MAAM,CAAC,MAAM,sBAAsB,GAAyC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAC1F,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACtC,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ectViewProps } from \"../../view/components/multi-select-view.ts\";\nimport type { OptionListViewProps } from \"../../view/components/option-list-view.ts\";\nimport type { PreviewPaneProps } from \"../../view/components/preview/preview-pane.ts\";\nimport type { SubmitPickerProps } from \"../../view/components/submit-picker.ts\";\nimport type { TabBarProps } from \"../../view/components/tab-bar.ts\";\nimport type { DialogProps } from \"../../view/dialog-builder.ts\";\nimport { ROW_INTENT_META } from \"../row-intent.ts\";\nimport type { GlobalSelector, PerTabSelector } from \"./contract.ts\";\nimport { chatNumberingFor, selectActiveTabItems, selectConfirmedIndicator } from \"./derivations.ts\";\n\nexport const selectMultiSelectProps: PerTabSelector<MultiSelectViewProps> = (state, ctx) => {\n\tconst question = ctx.questions[ctx.i];\n\tif (!question) return { rows: [], nextActive: false, nextLabel: ROW_INTENT_META.next.label };\n\tconst focused = ctx.activeView === \"options\";\n\tconst rows: { checked: boolean; active: boolean }[] = [];\n\tfor (let i = 0; i < question.options.length; i++) {\n\t\trows.push({\n\t\t\tchecked: state.multiSelectChecked.has(i),\n\t\t\tactive: focused && i === state.optionIndex,\n\t\t});\n\t}\n\tconst nextActive = focused && state.optionIndex === question.options.length;\n\tconst isLastQuestion = ctx.i === ctx.questions.length - 1;\n\tconst nextLabel = isLastQuestion ? MULTI_SUBMIT_LABEL : ROW_INTENT_META.next.label;\n\treturn { rows, nextActive, nextLabel };\n};\n\nexport const selectOptionListProps: PerTabSelector<OptionListViewProps> = (state, ctx) => {\n\tconst items = ctx.itemsByTab[ctx.i] ?? [];\n\tconst focused = ctx.activeView === \"options\";\n\tconst confirmed = selectConfirmedIndicator(ctx.questions, state.currentTab, state.answers, items);\n\treturn {\n\t\tselectedIndex: state.optionIndex,\n\t\tfocused,\n\t\tinputBuffer: ctx.inputBuffer,\n\t\tinputCaret: ctx.inputCaret,\n\t\t...(confirmed ? { confirmed } : {}),\n\t};\n};\n\nexport const selectSubmitPickerProps: GlobalSelector<SubmitPickerProps> = (state, ctx) => {\n\tconst focused = ctx.activeView === \"submit\";\n\treturn {\n\t\trows: [\n\t\t\t{ active: focused && state.submitChoiceIndex === 0 },\n\t\t\t{ active: focused && state.submitChoiceIndex === 1 },\n\t\t],\n\t};\n};\n\nexport const selectPreviewPaneProps: PerTabSelector<PreviewPaneProps> = (state, ctx) => ({\n\tnotesVisible: state.notesVisible,\n\tselectedIndex: state.optionIndex,\n\tfocused: ctx.activeView === \"options\",\n\tnotes: state.notesByTab.get(state.currentTab) ?? state.answers.get(state.currentTab)?.notes ?? \"\",\n});\n\nexport const selectTabBarProps: GlobalSelector<TabBarProps> = (state, ctx) => {\n\tconst tabs = ctx.questions.map((q, i) => ({\n\t\tlabel: q.header && q.header.length > 0 ? q.header : `Q${i + 1}`,\n\t\tanswered: state.answers.has(i),\n\t\tactive: i === state.currentTab,\n\t}));\n\treturn {\n\t\ttabs,\n\t\tsubmit: {\n\t\t\tactive: state.currentTab === ctx.questions.length,\n\t\t\tallAnswered: state.answers.size === ctx.questions.length && ctx.questions.length > 0,\n\t\t},\n\t};\n};\n\nexport const selectChatRowProps: GlobalSelector<ChatRowViewProps> = (state, ctx) => {\n\tconst activeItems = selectActiveTabItems(ctx.itemsByTab, state.currentTab, ctx.totalQuestions);\n\treturn {\n\t\tfocused: ctx.activeView === \"chat\",\n\t\tnumbering: chatNumberingFor(activeItems),\n\t\tinputBuffer: ctx.chatInputBuffer,\n\t\tinputCaret: ctx.chatInputCaret,\n\t};\n};\n\nexport const selectDialogProps: GlobalSelector<DialogProps> = (state, ctx) => ({\n\tstate,\n\tactivePreviewPane: ctx.activePreviewPane,\n});\n"]}
@@ -176,7 +176,7 @@ const multiConfirmHandler = (state, action, ctx) => {
176
176
  return doneFor(synced, ctx, false);
177
177
  };
178
178
  const notesEnterHandler = (state, _action, _ctx) => {
179
- const value = state.answers.get(state.currentTab)?.notes ?? "";
179
+ const value = state.notesByTab.get(state.currentTab) ?? state.answers.get(state.currentTab)?.notes ?? "";
180
180
  return {
181
181
  state: { ...state, notesVisible: true, notesDraft: value },
182
182
  effects: [
@@ -1 +1 @@
1
- {"version":3,"file":"state-reducer.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/state/state-reducer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE9F,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AA4B5E,SAAS,cAAc,CAAC,KAAyB,EAAE,SAAkC;IACpF,MAAM,GAAG,GAAqB,EAAE,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC/B,IAAI,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,SAAS,2BAA2B,CACnC,KAAyB,EACzB,SAAkC;IAElC,MAAM,uBAAuB,GAAG,8BAA8B,CAAC,SAAS,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC/G,IAAI,KAAK,CAAC,uBAAuB,KAAK,uBAAuB;QAAE,OAAO,KAAK,CAAC;IAC5E,OAAO,EAAE,GAAG,KAAK,EAAE,uBAAuB,EAAE,CAAC;AAC9C,CAAC;AAED,SAAS,0BAA0B,CAClC,OAA4C,EAC5C,SAAkC,EAClC,GAAW;IAEX,MAAM,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,CAAC,CAAC,EAAE,WAAW;QAAE,OAAO,IAAI,GAAG,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC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IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC;AAC7G,MAAM,mBAAmB,GAA6B,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACpE,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,yBAAyB,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;CAC5D,CAAC,CAAC;AACH,MAAM,aAAa,GAAsB,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;AAEpF;;;;;GAKG;AACH,MAAM,QAAQ,GAAuD;IACpE,GAAG,EAAE,UAAU;IACf,UAAU,EAAE,gBAAgB;IAC5B,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,aAAa;IACrB,aAAa,EAAE,mBAAmB;IAClC,MAAM,EAAE,aAAa;IACrB,WAAW,EAAE,iBAAiB;IAC9B,UAAU,EAAE,gBAAgB;IAC5B,aAAa,EAAE,mBAAmB;IAClC,MAAM,EAAE,aAAa;IACrB,UAAU,EAAE,gBAAgB;IAC5B,UAAU,EAAE,gBAAgB;IAC5B,aAAa,EAAE,mBAAmB;IAClC,MAAM,EAAE,aAAa;CACrB,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,KAAyB,EAAE,MAA2B,EAAE,GAAiB;IAC/F,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAgC,CAAC;IACrE,OAAO,OAAO,CAAC,KAAK,EAAE,MAAe,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import type { QuestionAnswer, QuestionData, QuestionnaireResult } from \"../tool/types.js\";\nimport type { WrappingSelectItem } from \"../view/components/wrapping-select.ts\";\nimport { readInlineCaret, resolveInlineDraftValue, withInlineDraft } from \"./inline-input.ts\";\nimport type { QuestionnaireAction } from \"./key-router.ts\";\nimport { ROW_INTENT_META } from \"./row-intent.ts\";\nimport { computeFocusedOptionHasPreview } from \"./selectors/derivations.ts\";\nimport type { InlineInputOwner, QuestionnaireState } from \"./state.ts\";\n\n/** Session-lifetime constants. No live-component reads — peripheral values live on canonical state. */\nexport interface ApplyContext {\n\tquestions: readonly QuestionData[];\n\titemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>;\n\tchatAsOption?: boolean;\n}\n\n/**\n * Declarative side-effects emitted by `reduce`. The runtime executes them after\n * committing the new state, then asks the props-adapter to re-project. Closed set —\n * adding an effect requires updating both the union AND the runtime's `runEffect` switch\n * (compiler-enforced exhaustive). No string-keyed escape hatch.\n */\nexport type Effect =\n\t| { kind: \"set_input_buffer\"; value: string; caret: number }\n\t| { kind: \"set_notes_value\"; value: string }\n\t| { kind: \"set_notes_focused\"; focused: boolean }\n\t| { kind: \"forward_notes_keystroke\"; data: string }\n\t| { kind: \"done\"; result: QuestionnaireResult };\n\nexport interface ApplyResult {\n\tstate: QuestionnaireState;\n\teffects: readonly Effect[];\n}\n\nfunction orderedAnswers(state: QuestionnaireState, questions: readonly QuestionData[]): QuestionAnswer[] {\n\tconst out: QuestionAnswer[] = [];\n\tfor (let i = 0; i < questions.length; i++) {\n\t\tconst a = state.answers.get(i);\n\t\tif (a) out.push(a);\n\t}\n\treturn out;\n}\n\nfunction withFocusedOptionHasPreview(\n\tstate: QuestionnaireState,\n\tquestions: readonly QuestionData[],\n): QuestionnaireState {\n\tconst focusedOptionHasPreview = computeFocusedOptionHasPreview(questions, state.currentTab, state.optionIndex);\n\tif (state.focusedOptionHasPreview === focusedOptionHasPreview) return state;\n\treturn { ...state, focusedOptionHasPreview };\n}\n\nfunction syncMultiSelectFromAnswers(\n\tanswers: ReadonlyMap<number, QuestionAnswer>,\n\tquestions: readonly QuestionData[],\n\ttab: number,\n): ReadonlySet<number> {\n\tconst q = questions[tab];\n\tif (!q?.multiSelect) return new Set();\n\tconst saved = answers.get(tab);\n\tconst labels = saved?.selected ?? [];\n\tconst indices = new Set<number>();\n\tfor (let i = 0; i < q.options.length; i++) {\n\t\tif (labels.includes(q.options[i]!.label)) indices.add(i);\n\t}\n\treturn indices;\n}\n\nfunction persistMultiSelectAnswer(state: QuestionnaireState, ctx: ApplyContext): ReadonlyMap<number, QuestionAnswer> {\n\tconst q = ctx.questions[state.currentTab];\n\tif (!q?.multiSelect) return state.answers;\n\tconst selected: string[] = [];\n\tfor (let i = 0; i < q.options.length; i++) {\n\t\tif (state.multiSelectChecked.has(i)) selected.push(q.options[i]!.label);\n\t}\n\tconst out = new Map(state.answers);\n\tif (selected.length === 0) {\n\t\tout.delete(state.currentTab);\n\t\treturn out;\n\t}\n\tconst pendingNotes = state.notesByTab.get(state.currentTab);\n\tout.set(state.currentTab, {\n\t\tquestionIndex: state.currentTab,\n\t\tquestion: q.question,\n\t\tkind: \"multi\",\n\t\tanswer: null,\n\t\tselected,\n\t\t...(pendingNotes && pendingNotes.length > 0 ? { notes: pendingNotes } : {}),\n\t});\n\treturn out;\n}\n\nfunction clampCaret(value: string, caret: number | undefined): number {\n\tif (caret === undefined || !Number.isFinite(caret)) return value.length;\n\treturn Math.max(0, Math.min(caret, value.length));\n}\n\nfunction inlineOwnerForItem(item: WrappingSelectItem | undefined): InlineInputOwner | null {\n\tif (!item || !ROW_INTENT_META[item.kind].activatesInputMode) return null;\n\tswitch (item.kind) {\n\t\tcase \"other\":\n\t\tcase \"chat\":\n\t\t\treturn item.kind;\n\t\tcase \"option\":\n\t\tcase \"next\":\n\t\t\treturn null;\n\t}\n}\n\nfunction hydrateInlineInputResult(state: QuestionnaireState, owner: InlineInputOwner): ApplyResult {\n\tconst value = resolveInlineDraftValue(state, owner);\n\tconst caret = clampCaret(value, readInlineCaret(state, owner));\n\treturn {\n\t\tstate: withInlineDraft({ ...state, inputMode: true, inlineInputOwner: owner }, owner, value, caret),\n\t\teffects: [{ kind: \"set_input_buffer\", value, caret }],\n\t};\n}\n\nfunction switchTabResult(state: QuestionnaireState, nextTab: number, ctx: ApplyContext): ApplyResult {\n\tconst notesValue = state.notesByTab.get(nextTab) ?? state.answers.get(nextTab)?.notes ?? \"\";\n\tconst transitioned: QuestionnaireState = {\n\t\t...state,\n\t\tcurrentTab: nextTab,\n\t\toptionIndex: 0,\n\t\tinputMode: false,\n\t\tinlineInputOwner: null,\n\t\tnotesVisible: false,\n\t\tchatFocused: false,\n\t\tsubmitChoiceIndex: 0,\n\t\tmultiSelectChecked: syncMultiSelectFromAnswers(state.answers, ctx.questions, nextTab),\n\t\tnotesDraft: notesValue,\n\t};\n\tconst finalState = withFocusedOptionHasPreview(transitioned, ctx.questions);\n\treturn {\n\t\tstate: finalState,\n\t\teffects: [\n\t\t\t{ kind: \"set_notes_focused\", focused: false },\n\t\t\t{ kind: \"set_notes_value\", value: notesValue },\n\t\t],\n\t};\n}\n\nfunction doneFor(state: QuestionnaireState, ctx: ApplyContext, cancelled: boolean): ApplyResult {\n\tconst result: QuestionnaireResult = { answers: orderedAnswers(state, ctx.questions), cancelled };\n\treturn { state, effects: [{ kind: \"done\", result }] };\n}\n\n/**\n * Per-kind handler signature: action payload narrows to the matching union member\n * via `Extract`, so handlers consume fully-typed actions without `as` casts.\n */\ntype Handler<K extends QuestionnaireAction[\"kind\"]> = (\n\tstate: QuestionnaireState,\n\taction: Extract<QuestionnaireAction, { kind: K }>,\n\tctx: ApplyContext,\n) => ApplyResult;\n\nconst navHandler: Handler<\"nav\"> = (state, action, ctx) => {\n\tconst items = ctx.itemsByTab[state.currentTab] ?? [];\n\tconst item = items[action.nextIndex];\n\tconst owner = inlineOwnerForItem(item);\n\tconst next = withFocusedOptionHasPreview(\n\t\t{\n\t\t\t...state,\n\t\t\tchatFocused: false,\n\t\t\toptionIndex: action.nextIndex,\n\t\t\tinputMode: owner !== null,\n\t\t\tinlineInputOwner: owner,\n\t\t},\n\t\tctx.questions,\n\t);\n\treturn owner ? hydrateInlineInputResult(next, owner) : { state: next, effects: [] };\n};\n\nconst tabSwitchHandler: Handler<\"tab_switch\"> = (state, action, ctx) => switchTabResult(state, action.nextTab, ctx);\n\nconst confirmHandler: Handler<\"confirm\"> = (state, action, ctx) => {\n\tlet answer = action.answer;\n\tif (answer.kind === \"option\" && answer.answer) {\n\t\tconst q = ctx.questions[answer.questionIndex];\n\t\tconst matched = q?.options.find((o) => o.label === answer.answer);\n\t\tif (matched?.preview && matched.preview.length > 0) {\n\t\t\tanswer = { ...answer, preview: matched.preview };\n\t\t}\n\t}\n\tconst pendingNotes = state.notesByTab.get(answer.questionIndex);\n\tif (pendingNotes && pendingNotes.length > 0) {\n\t\tanswer = { ...answer, notes: pendingNotes };\n\t}\n\tconst answers = new Map(state.answers);\n\tanswers.set(answer.questionIndex, answer);\n\tconst next: QuestionnaireState = { ...state, answers };\n\tif (answer.kind === \"chat\") return doneFor(next, ctx, false);\n\tif (action.autoAdvanceTab !== undefined) return switchTabResult(next, action.autoAdvanceTab, ctx);\n\treturn doneFor(next, ctx, false);\n};\n\nconst toggleHandler: Handler<\"toggle\"> = (state, action, ctx) => {\n\tconst checked = new Set(state.multiSelectChecked);\n\tif (checked.has(action.index)) checked.delete(action.index);\n\telse checked.add(action.index);\n\tconst intermediate: QuestionnaireState = { ...state, multiSelectChecked: checked };\n\tconst answers = persistMultiSelectAnswer(intermediate, ctx);\n\treturn { state: { ...intermediate, answers }, effects: [] };\n};\n\nconst multiConfirmHandler: Handler<\"multi_confirm\"> = (state, action, ctx) => {\n\tconst q = ctx.questions[state.currentTab];\n\tif (!q) return { state, effects: [] };\n\tconst pendingNotes = state.notesByTab.get(state.currentTab);\n\tconst answers = new Map(state.answers);\n\tanswers.set(state.currentTab, {\n\t\tquestionIndex: state.currentTab,\n\t\tquestion: q.question,\n\t\tkind: \"multi\",\n\t\tanswer: null,\n\t\tselected: action.selected,\n\t\t...(pendingNotes && pendingNotes.length > 0 ? { notes: pendingNotes } : {}),\n\t});\n\tconst synced: QuestionnaireState = {\n\t\t...state,\n\t\tanswers,\n\t\tmultiSelectChecked: syncMultiSelectFromAnswers(answers, ctx.questions, state.currentTab),\n\t};\n\tif (action.autoAdvanceTab !== undefined) return switchTabResult(synced, action.autoAdvanceTab, ctx);\n\treturn doneFor(synced, ctx, false);\n};\n\nconst notesEnterHandler: Handler<\"notes_enter\"> = (state, _action, _ctx) => {\n\tconst value = state.answers.get(state.currentTab)?.notes ?? \"\";\n\treturn {\n\t\tstate: { ...state, notesVisible: true, notesDraft: value },\n\t\teffects: [\n\t\t\t{ kind: \"set_notes_value\", value },\n\t\t\t{ kind: \"set_notes_focused\", focused: true },\n\t\t],\n\t};\n};\n\nconst notesExitHandler: Handler<\"notes_exit\"> = (state, _action, _ctx) => {\n\tconst trimmed = state.notesDraft.trim();\n\tconst notes = new Map(state.notesByTab);\n\tconst answers = new Map(state.answers);\n\tif (trimmed.length === 0) {\n\t\tnotes.delete(state.currentTab);\n\t\tconst prev = answers.get(state.currentTab);\n\t\tif (prev?.notes) {\n\t\t\tconst stripped = { ...prev };\n\t\t\tdelete (stripped as { notes?: string }).notes;\n\t\t\tanswers.set(state.currentTab, stripped);\n\t\t}\n\t} else {\n\t\tnotes.set(state.currentTab, trimmed);\n\t\tconst prev = answers.get(state.currentTab);\n\t\tif (prev) answers.set(state.currentTab, { ...prev, notes: trimmed });\n\t}\n\treturn {\n\t\tstate: { ...state, notesByTab: notes, answers, notesVisible: false },\n\t\teffects: [{ kind: \"set_notes_focused\", focused: false }],\n\t};\n};\n\nconst focusOptionsHandler: Handler<\"focus_options\"> = (state, action, ctx) => {\n\tconst items = ctx.itemsByTab[state.currentTab] ?? [];\n\tconst focused = items[action.optionIndex];\n\tconst owner = inlineOwnerForItem(focused);\n\tconst next = withFocusedOptionHasPreview(\n\t\t{\n\t\t\t...state,\n\t\t\tchatFocused: false,\n\t\t\toptionIndex: action.optionIndex,\n\t\t\tinputMode: owner !== null,\n\t\t\tinlineInputOwner: owner,\n\t\t},\n\t\tctx.questions,\n\t);\n\treturn owner ? hydrateInlineInputResult(next, owner) : { state: next, effects: [] };\n};\n\nconst cancelHandler: Handler<\"cancel\"> = (s, _a, c) => doneFor(s, c, true);\nconst submitHandler: Handler<\"submit\"> = (s, _a, c) => doneFor(s, c, false);\nconst submitNavHandler: Handler<\"submit_nav\"> = (s, a, _c) => ({\n\tstate: { ...s, submitChoiceIndex: a.nextIndex },\n\teffects: [],\n});\nconst focusChatHandler: Handler<\"focus_chat\"> = (s, _a, ctx) =>\n\tctx.chatAsOption === true\n\t\t? { state: { ...s, chatFocused: true, inputMode: false, inlineInputOwner: null }, effects: [] }\n\t\t: hydrateInlineInputResult({ ...s, chatFocused: true, inputMode: true, inlineInputOwner: \"chat\" }, \"chat\");\nconst notesForwardHandler: Handler<\"notes_forward\"> = (s, a, _c) => ({\n\tstate: s,\n\teffects: [{ kind: \"forward_notes_keystroke\", data: a.data }],\n});\nconst ignoreHandler: Handler<\"ignore\"> = (s, _a, _c) => ({ state: s, effects: [] });\n\n/**\n * Compile-time-exhaustive dispatch table. `{ [K in Kind]: Handler<K> }` requires\n * an entry per union member — adding a new `QuestionnaireAction` variant fails to\n * compile here until a handler is registered, mirroring the `Record<RowKind, …>`\n * pattern used by `ROW_INTENT_META`.\n */\nconst HANDLERS: { [K in QuestionnaireAction[\"kind\"]]: Handler<K> } = {\n\tnav: navHandler,\n\ttab_switch: tabSwitchHandler,\n\tconfirm: confirmHandler,\n\ttoggle: toggleHandler,\n\tmulti_confirm: multiConfirmHandler,\n\tcancel: cancelHandler,\n\tnotes_enter: notesEnterHandler,\n\tnotes_exit: notesExitHandler,\n\tnotes_forward: notesForwardHandler,\n\tsubmit: submitHandler,\n\tsubmit_nav: submitNavHandler,\n\tfocus_chat: focusChatHandler,\n\tfocus_options: focusOptionsHandler,\n\tignore: ignoreHandler,\n};\n\n/**\n * Pure reducer: (state, action, ctx) → (state, Effect[]). Mirrors `rpiv-todo`'s `applyTaskMutation`.\n * Delegates to `HANDLERS` — per-kind handlers above are pure, named, and individually testable.\n * `ignore` is also handled outside the reducer by `handleIgnoreInline` in the runtime fast path.\n */\nexport function reduce(state: QuestionnaireState, action: QuestionnaireAction, ctx: ApplyContext): ApplyResult {\n\tconst handler = HANDLERS[action.kind] as Handler<typeof action.kind>;\n\treturn handler(state, action as never, ctx);\n}\n"]}
1
+ {"version":3,"file":"state-reducer.js","sourceRoot":"","sources":["../../../../../src/core/tools/ask-user-question/state/state-reducer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE9F,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AA4B5E,SAAS,cAAc,CAAC,KAAyB,EAAE,SAAkC;IACpF,MAAM,GAAG,GAAqB,EAAE,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC/B,IAAI,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,SAAS,2BAA2B,CACnC,KAAyB,EACzB,SAAkC;IAElC,MAAM,uBAAuB,GAAG,8BAA8B,CAAC,SAAS,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC/G,IAAI,KAAK,CAAC,uBAAuB,KAAK,uBAAuB;QAAE,OAAO,KAAK,CAAC;IAC5E,OAAO,EAAE,GAAG,KAAK,EAAE,uBAAuB,EAAE,CAAC;AAC9C,CAAC;AAED,SAAS,0BAA0B,CAClC,OAA4C,EAC5C,SAAkC,EAClC,GAAW;IAEX,MAAM,CAA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,IAAI,CAAgC,CAAC;IACrE,OAAO,OAAO,CAAC,KAAK,EAAE,MAAe,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import type { QuestionAnswer, QuestionData, QuestionnaireResult } from \"../tool/types.js\";\nimport type { WrappingSelectItem } from \"../view/components/wrapping-select.ts\";\nimport { readInlineCaret, resolveInlineDraftValue, withInlineDraft } from \"./inline-input.ts\";\nimport type { QuestionnaireAction } from \"./key-router.ts\";\nimport { ROW_INTENT_META } from \"./row-intent.ts\";\nimport { computeFocusedOptionHasPreview } from \"./selectors/derivations.ts\";\nimport type { InlineInputOwner, QuestionnaireState } from \"./state.ts\";\n\n/** Session-lifetime constants. No live-component reads — peripheral values live on canonical state. */\nexport interface ApplyContext {\n\tquestions: readonly QuestionData[];\n\titemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>;\n\tchatAsOption?: boolean;\n}\n\n/**\n * Declarative side-effects emitted by `reduce`. The runtime executes them after\n * committing the new state, then asks the props-adapter to re-project. Closed set —\n * adding an effect requires updating both the union AND the runtime's `runEffect` switch\n * (compiler-enforced exhaustive). No string-keyed escape hatch.\n */\nexport type Effect =\n\t| { kind: \"set_input_buffer\"; value: string; caret: number }\n\t| { kind: \"set_notes_value\"; value: string }\n\t| { kind: \"set_notes_focused\"; focused: boolean }\n\t| { kind: \"forward_notes_keystroke\"; data: string }\n\t| { kind: \"done\"; result: QuestionnaireResult };\n\nexport interface ApplyResult {\n\tstate: QuestionnaireState;\n\teffects: readonly Effect[];\n}\n\nfunction orderedAnswers(state: QuestionnaireState, questions: readonly QuestionData[]): QuestionAnswer[] {\n\tconst out: QuestionAnswer[] = [];\n\tfor (let i = 0; i < questions.length; i++) {\n\t\tconst a = state.answers.get(i);\n\t\tif (a) out.push(a);\n\t}\n\treturn out;\n}\n\nfunction withFocusedOptionHasPreview(\n\tstate: QuestionnaireState,\n\tquestions: readonly QuestionData[],\n): QuestionnaireState {\n\tconst focusedOptionHasPreview = computeFocusedOptionHasPreview(questions, state.currentTab, state.optionIndex);\n\tif (state.focusedOptionHasPreview === focusedOptionHasPreview) return state;\n\treturn { ...state, focusedOptionHasPreview };\n}\n\nfunction syncMultiSelectFromAnswers(\n\tanswers: ReadonlyMap<number, QuestionAnswer>,\n\tquestions: readonly QuestionData[],\n\ttab: number,\n): ReadonlySet<number> {\n\tconst q = questions[tab];\n\tif (!q?.multiSelect) return new Set();\n\tconst saved = answers.get(tab);\n\tconst labels = saved?.selected ?? [];\n\tconst indices = new Set<number>();\n\tfor (let i = 0; i < q.options.length; i++) {\n\t\tif (labels.includes(q.options[i]!.label)) indices.add(i);\n\t}\n\treturn indices;\n}\n\nfunction persistMultiSelectAnswer(state: QuestionnaireState, ctx: ApplyContext): ReadonlyMap<number, QuestionAnswer> {\n\tconst q = ctx.questions[state.currentTab];\n\tif (!q?.multiSelect) return state.answers;\n\tconst selected: string[] = [];\n\tfor (let i = 0; i < q.options.length; i++) {\n\t\tif (state.multiSelectChecked.has(i)) selected.push(q.options[i]!.label);\n\t}\n\tconst out = new Map(state.answers);\n\tif (selected.length === 0) {\n\t\tout.delete(state.currentTab);\n\t\treturn out;\n\t}\n\tconst pendingNotes = state.notesByTab.get(state.currentTab);\n\tout.set(state.currentTab, {\n\t\tquestionIndex: state.currentTab,\n\t\tquestion: q.question,\n\t\tkind: \"multi\",\n\t\tanswer: null,\n\t\tselected,\n\t\t...(pendingNotes && pendingNotes.length > 0 ? { notes: pendingNotes } : {}),\n\t});\n\treturn out;\n}\n\nfunction clampCaret(value: string, caret: number | undefined): number {\n\tif (caret === undefined || !Number.isFinite(caret)) return value.length;\n\treturn Math.max(0, Math.min(caret, value.length));\n}\n\nfunction inlineOwnerForItem(item: WrappingSelectItem | undefined): InlineInputOwner | null {\n\tif (!item || !ROW_INTENT_META[item.kind].activatesInputMode) return null;\n\tswitch (item.kind) {\n\t\tcase \"other\":\n\t\tcase \"chat\":\n\t\t\treturn item.kind;\n\t\tcase \"option\":\n\t\tcase \"next\":\n\t\t\treturn null;\n\t}\n}\n\nfunction hydrateInlineInputResult(state: QuestionnaireState, owner: InlineInputOwner): ApplyResult {\n\tconst value = resolveInlineDraftValue(state, owner);\n\tconst caret = clampCaret(value, readInlineCaret(state, owner));\n\treturn {\n\t\tstate: withInlineDraft({ ...state, inputMode: true, inlineInputOwner: owner }, owner, value, caret),\n\t\teffects: [{ kind: \"set_input_buffer\", value, caret }],\n\t};\n}\n\nfunction switchTabResult(state: QuestionnaireState, nextTab: number, ctx: ApplyContext): ApplyResult {\n\tconst notesValue = state.notesByTab.get(nextTab) ?? state.answers.get(nextTab)?.notes ?? \"\";\n\tconst transitioned: QuestionnaireState = {\n\t\t...state,\n\t\tcurrentTab: nextTab,\n\t\toptionIndex: 0,\n\t\tinputMode: false,\n\t\tinlineInputOwner: null,\n\t\tnotesVisible: false,\n\t\tchatFocused: false,\n\t\tsubmitChoiceIndex: 0,\n\t\tmultiSelectChecked: syncMultiSelectFromAnswers(state.answers, ctx.questions, nextTab),\n\t\tnotesDraft: notesValue,\n\t};\n\tconst finalState = withFocusedOptionHasPreview(transitioned, ctx.questions);\n\treturn {\n\t\tstate: finalState,\n\t\teffects: [\n\t\t\t{ kind: \"set_notes_focused\", focused: false },\n\t\t\t{ kind: \"set_notes_value\", value: notesValue },\n\t\t],\n\t};\n}\n\nfunction doneFor(state: QuestionnaireState, ctx: ApplyContext, cancelled: boolean): ApplyResult {\n\tconst result: QuestionnaireResult = { answers: orderedAnswers(state, ctx.questions), cancelled };\n\treturn { state, effects: [{ kind: \"done\", result }] };\n}\n\n/**\n * Per-kind handler signature: action payload narrows to the matching union member\n * via `Extract`, so handlers consume fully-typed actions without `as` casts.\n */\ntype Handler<K extends QuestionnaireAction[\"kind\"]> = (\n\tstate: QuestionnaireState,\n\taction: Extract<QuestionnaireAction, { kind: K }>,\n\tctx: ApplyContext,\n) => ApplyResult;\n\nconst navHandler: Handler<\"nav\"> = (state, action, ctx) => {\n\tconst items = ctx.itemsByTab[state.currentTab] ?? [];\n\tconst item = items[action.nextIndex];\n\tconst owner = inlineOwnerForItem(item);\n\tconst next = withFocusedOptionHasPreview(\n\t\t{\n\t\t\t...state,\n\t\t\tchatFocused: false,\n\t\t\toptionIndex: action.nextIndex,\n\t\t\tinputMode: owner !== null,\n\t\t\tinlineInputOwner: owner,\n\t\t},\n\t\tctx.questions,\n\t);\n\treturn owner ? hydrateInlineInputResult(next, owner) : { state: next, effects: [] };\n};\n\nconst tabSwitchHandler: Handler<\"tab_switch\"> = (state, action, ctx) => switchTabResult(state, action.nextTab, ctx);\n\nconst confirmHandler: Handler<\"confirm\"> = (state, action, ctx) => {\n\tlet answer = action.answer;\n\tif (answer.kind === \"option\" && answer.answer) {\n\t\tconst q = ctx.questions[answer.questionIndex];\n\t\tconst matched = q?.options.find((o) => o.label === answer.answer);\n\t\tif (matched?.preview && matched.preview.length > 0) {\n\t\t\tanswer = { ...answer, preview: matched.preview };\n\t\t}\n\t}\n\tconst pendingNotes = state.notesByTab.get(answer.questionIndex);\n\tif (pendingNotes && pendingNotes.length > 0) {\n\t\tanswer = { ...answer, notes: pendingNotes };\n\t}\n\tconst answers = new Map(state.answers);\n\tanswers.set(answer.questionIndex, answer);\n\tconst next: QuestionnaireState = { ...state, answers };\n\tif (answer.kind === \"chat\") return doneFor(next, ctx, false);\n\tif (action.autoAdvanceTab !== undefined) return switchTabResult(next, action.autoAdvanceTab, ctx);\n\treturn doneFor(next, ctx, false);\n};\n\nconst toggleHandler: Handler<\"toggle\"> = (state, action, ctx) => {\n\tconst checked = new Set(state.multiSelectChecked);\n\tif (checked.has(action.index)) checked.delete(action.index);\n\telse checked.add(action.index);\n\tconst intermediate: QuestionnaireState = { ...state, multiSelectChecked: checked };\n\tconst answers = persistMultiSelectAnswer(intermediate, ctx);\n\treturn { state: { ...intermediate, answers }, effects: [] };\n};\n\nconst multiConfirmHandler: Handler<\"multi_confirm\"> = (state, action, ctx) => {\n\tconst q = ctx.questions[state.currentTab];\n\tif (!q) return { state, effects: [] };\n\tconst pendingNotes = state.notesByTab.get(state.currentTab);\n\tconst answers = new Map(state.answers);\n\tanswers.set(state.currentTab, {\n\t\tquestionIndex: state.currentTab,\n\t\tquestion: q.question,\n\t\tkind: \"multi\",\n\t\tanswer: null,\n\t\tselected: action.selected,\n\t\t...(pendingNotes && pendingNotes.length > 0 ? { notes: pendingNotes } : {}),\n\t});\n\tconst synced: QuestionnaireState = {\n\t\t...state,\n\t\tanswers,\n\t\tmultiSelectChecked: syncMultiSelectFromAnswers(answers, ctx.questions, state.currentTab),\n\t};\n\tif (action.autoAdvanceTab !== undefined) return switchTabResult(synced, action.autoAdvanceTab, ctx);\n\treturn doneFor(synced, ctx, false);\n};\n\nconst notesEnterHandler: Handler<\"notes_enter\"> = (state, _action, _ctx) => {\n\tconst value = state.notesByTab.get(state.currentTab) ?? state.answers.get(state.currentTab)?.notes ?? \"\";\n\treturn {\n\t\tstate: { ...state, notesVisible: true, notesDraft: value },\n\t\teffects: [\n\t\t\t{ kind: \"set_notes_value\", value },\n\t\t\t{ kind: \"set_notes_focused\", focused: true },\n\t\t],\n\t};\n};\n\nconst notesExitHandler: Handler<\"notes_exit\"> = (state, _action, _ctx) => {\n\tconst trimmed = state.notesDraft.trim();\n\tconst notes = new Map(state.notesByTab);\n\tconst answers = new Map(state.answers);\n\tif (trimmed.length === 0) {\n\t\tnotes.delete(state.currentTab);\n\t\tconst prev = answers.get(state.currentTab);\n\t\tif (prev?.notes) {\n\t\t\tconst stripped = { ...prev };\n\t\t\tdelete (stripped as { notes?: string }).notes;\n\t\t\tanswers.set(state.currentTab, stripped);\n\t\t}\n\t} else {\n\t\tnotes.set(state.currentTab, trimmed);\n\t\tconst prev = answers.get(state.currentTab);\n\t\tif (prev) answers.set(state.currentTab, { ...prev, notes: trimmed });\n\t}\n\treturn {\n\t\tstate: { ...state, notesByTab: notes, answers, notesVisible: false },\n\t\teffects: [{ kind: \"set_notes_focused\", focused: false }],\n\t};\n};\n\nconst focusOptionsHandler: Handler<\"focus_options\"> = (state, action, ctx) => {\n\tconst items = ctx.itemsByTab[state.currentTab] ?? [];\n\tconst focused = items[action.optionIndex];\n\tconst owner = inlineOwnerForItem(focused);\n\tconst next = withFocusedOptionHasPreview(\n\t\t{\n\t\t\t...state,\n\t\t\tchatFocused: false,\n\t\t\toptionIndex: action.optionIndex,\n\t\t\tinputMode: owner !== null,\n\t\t\tinlineInputOwner: owner,\n\t\t},\n\t\tctx.questions,\n\t);\n\treturn owner ? hydrateInlineInputResult(next, owner) : { state: next, effects: [] };\n};\n\nconst cancelHandler: Handler<\"cancel\"> = (s, _a, c) => doneFor(s, c, true);\nconst submitHandler: Handler<\"submit\"> = (s, _a, c) => doneFor(s, c, false);\nconst submitNavHandler: Handler<\"submit_nav\"> = (s, a, _c) => ({\n\tstate: { ...s, submitChoiceIndex: a.nextIndex },\n\teffects: [],\n});\nconst focusChatHandler: Handler<\"focus_chat\"> = (s, _a, ctx) =>\n\tctx.chatAsOption === true\n\t\t? { state: { ...s, chatFocused: true, inputMode: false, inlineInputOwner: null }, effects: [] }\n\t\t: hydrateInlineInputResult({ ...s, chatFocused: true, inputMode: true, inlineInputOwner: \"chat\" }, \"chat\");\nconst notesForwardHandler: Handler<\"notes_forward\"> = (s, a, _c) => ({\n\tstate: s,\n\teffects: [{ kind: \"forward_notes_keystroke\", data: a.data }],\n});\nconst ignoreHandler: Handler<\"ignore\"> = (s, _a, _c) => ({ state: s, effects: [] });\n\n/**\n * Compile-time-exhaustive dispatch table. `{ [K in Kind]: Handler<K> }` requires\n * an entry per union member — adding a new `QuestionnaireAction` variant fails to\n * compile here until a handler is registered, mirroring the `Record<RowKind, …>`\n * pattern used by `ROW_INTENT_META`.\n */\nconst HANDLERS: { [K in QuestionnaireAction[\"kind\"]]: Handler<K> } = {\n\tnav: navHandler,\n\ttab_switch: tabSwitchHandler,\n\tconfirm: confirmHandler,\n\ttoggle: toggleHandler,\n\tmulti_confirm: multiConfirmHandler,\n\tcancel: cancelHandler,\n\tnotes_enter: notesEnterHandler,\n\tnotes_exit: notesExitHandler,\n\tnotes_forward: notesForwardHandler,\n\tsubmit: submitHandler,\n\tsubmit_nav: submitNavHandler,\n\tfocus_chat: focusChatHandler,\n\tfocus_options: focusOptionsHandler,\n\tignore: ignoreHandler,\n};\n\n/**\n * Pure reducer: (state, action, ctx) → (state, Effect[]). Mirrors `rpiv-todo`'s `applyTaskMutation`.\n * Delegates to `HANDLERS` — per-kind handlers above are pure, named, and individually testable.\n * `ignore` is also handled outside the reducer by `handleIgnoreInline` in the runtime fast path.\n */\nexport function reduce(state: QuestionnaireState, action: QuestionnaireAction, ctx: ApplyContext): ApplyResult {\n\tconst handler = HANDLERS[action.kind] as Handler<typeof action.kind>;\n\treturn handler(state, action as never, ctx);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"multi-select-view.d.ts","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/view/components/multi-select-view.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iDAAiD,CAAC;AAG7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAYxD,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAE3C,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,aAAa,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC3D,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,qBAAa,eAAgB,YAAW,YAAY,CAAC,oBAAoB,CAAC;IACzE,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,QAAQ,CAAkE;IAElF,iBAAyB,KAAK,CAAQ;IACtC,iBAAyB,QAAQ,CAAe;IAEhD,YAAY,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAI/C;IAED,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAE1C;IAED,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAG;IAEnC,UAAU,IAAI,IAAI,CAEjB;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAkC9B;IAED,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGnC;IAED,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,kBAAkB;CAW1B"}
1
+ {"version":3,"file":"multi-select-view.d.ts","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/view/components/multi-select-view.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iDAAiD,CAAC;AAI7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAYxD,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAE3C,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,aAAa,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC3D,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,qBAAa,eAAgB,YAAW,YAAY,CAAC,oBAAoB,CAAC;IACzE,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,QAAQ,CAAkE;IAElF,iBAAyB,KAAK,CAAQ;IACtC,iBAAyB,QAAQ,CAAe;IAEhD,YAAY,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAI/C;IAED,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAE1C;IAED,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAG;IAEnC,UAAU,IAAI,IAAI,CAEjB;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAkC9B;IAED,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGnC;IAED,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,kBAAkB;CAW1B"}
@@ -1,6 +1,7 @@
1
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 { rowTone, styleFieldTone } from "../../state/selectors/field-tone.js";
4
5
  const ACTIVE_POINTER = "❯ ";
5
6
  const INACTIVE_POINTER = " ";
6
7
  const CHECKED = "[✔]";
@@ -48,12 +49,11 @@ export class MultiSelectView {
48
49
  if (!opt || !row)
49
50
  continue;
50
51
  const pointer = row.active ? this.theme.fg("accent", ACTIVE_POINTER) : INACTIVE_POINTER;
51
- // Checked uses the same `accent` hue as the active-row label so checked rows read
52
- // as "selected" rather than "success" — matches the visual rhythm of the rest of
53
- // the dialog (active pointer, label, picker rows are all accent).
54
- const box = row.checked ? this.theme.fg("accent", CHECKED) : this.theme.fg("muted", UNCHECKED);
52
+ // A checked row holds part of the answer: `editing` while focused, `answered` otherwise.
53
+ const tone = rowTone(row.active, row.checked);
54
+ const box = row.checked && tone ? styleFieldTone(this.theme, tone, CHECKED) : this.theme.fg("muted", UNCHECKED);
55
55
  const label = truncateToWidth(opt.label, contentWidth, "…");
56
- const styledLabel = row.active ? this.theme.fg("accent", this.theme.bold(label)) : label;
56
+ const styledLabel = tone ? styleFieldTone(this.theme, tone, label) : label;
57
57
  const num = String(i + 1).padStart(numberWidth, " ");
58
58
  const line = `${pointer}${num}${NUMBER_SEPARATOR}${box}${BOX_LABEL_GAP}${styledLabel}`;
59
59
  const rendered = truncateToWidth(line, width, "");
@@ -67,7 +67,7 @@ export class MultiSelectView {
67
67
  }
68
68
  const nextPointer = this.props.nextActive ? this.theme.fg("accent", ACTIVE_POINTER) : INACTIVE_POINTER;
69
69
  const nextLabel = this.props.nextActive
70
- ? this.theme.fg("accent", this.theme.bold(this.props.nextLabel))
70
+ ? styleFieldTone(this.theme, "editing", this.props.nextLabel)
71
71
  : this.props.nextLabel;
72
72
  const rendered = truncateToWidth(`${nextPointer}${nextLabel}`, width, "");
73
73
  lines.push(`${rendered}${this.props.nextActive ? OVERLAY_ACTIVE_ROW_MARKER : ""}`);
@@ -1 +1 @@
1
- {"version":3,"file":"multi-select-view.js","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/view/components/multi-select-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEzF,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAI5D,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,OAAO,GAAG,KAAK,CAAC;AACtB,MAAM,SAAS,GAAG,KAAK,CAAC;AACxB,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,2FAA2F;AAC3F,gGAAgG;AAChG,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAQ3C;;;;;;;;;;GAUG;AACH,MAAM,OAAO,eAAe;IACnB,KAAK,CAAuB;IAC5B,QAAQ,CAAkE;IAKlF,YAAY,KAAY,EAAE,QAAsB;QAC/C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,EAAE,IAAI,EAAE,EAAE,E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CAAC,WAAW;YACvB,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;gBACrB,KAAK,IAAI,gBAAgB,CAAC,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,MAAM,CAAC;YACjE,CAAC;QACF,CAAC;QACD,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,mDAAmD;IACtE,CAAC;IAEO,kBAAkB;QACzB,6FAA6F;QAC7F,uFAAuF;QACvF,gGAAgG;QAChG,+FAA+F;QAC/F,+FAA+F;QAC/F,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;QAC7E,OAAO,CACN,YAAY,CAAC,gBAAgB,CAAC,GAAG,WAAW,GAAG,YAAY,CAAC,GAAG,gBAAgB,GAAG,SAAS,GAAG,aAAa,EAAE,CAAC,CAC9G,CAAC;IACH,CAAC;CACD","sourcesContent":["import { truncateToWidth, visibleWidth, wrapTextWithAnsi } from \"@earendil-works/pi-tui\";\nimport type { Theme } from \"../../../../../modes/interactive/theme/theme.js\";\nimport { OVERLAY_ACTIVE_ROW_MARKER } from \"../../../../extensions/ui-types.js\";\nimport { ROW_INTENT_META } from \"../../state/row-intent.ts\";\nimport type { QuestionData } from \"../../tool/types.js\";\nimport type { StatefulView } from \"../stateful-view.ts\";\n\nconst ACTIVE_POINTER = \"❯ \";\nconst INACTIVE_POINTER = \" \";\nconst CHECKED = \"[✔]\";\nconst UNCHECKED = \"[ ]\";\nconst NUMBER_SEPARATOR = \". \";\nconst BOX_LABEL_GAP = \" \";\n// CC parity: description continuation indents to col 2 (past the pointer slot), NOT to the\n// full prefix column. Wrap width still uses prefixVisibleWidth so naturalHeight matches render.\nconst CONTINUATION_INDENT = \" \";\n\nexport const MULTI_SUBMIT_LABEL = \"Submit\";\n\nexport interface MultiSelectViewProps {\n\trows: ReadonlyArray<{ checked: boolean; active: boolean }>;\n\tnextActive: boolean;\n\tnextLabel: string;\n}\n\n/**\n * Renders the multi-select option list (one row per option — pointer + checkbox + label —\n * plus zero or more wrapped continuation lines per description).\n *\n * `naturalHeight(width)` is state-INDEPENDENT (depends only on theme glyph widths,\n * question.options, and width) so the host can compute a stable globalContentHeight\n * without rendering. `naturalHeight(w) === render(w).length` for every props. It is\n * measured once per width.\n *\n * `setProps(props)` is a pure field reassignment — no render, no invalidate side effects.\n */\nexport class MultiSelectView implements StatefulView<MultiSelectViewProps> {\n\tprivate props: MultiSelectViewProps;\n\tprivate measured: { readonly width: number; readonly height: number } | undefined;\n\n\tprivate declare readonly theme: Theme;\n\tprivate declare readonly question: QuestionData;\n\n\tconstructor(theme: Theme, question: QuestionData) {\n\t\tthis.theme = theme;\n\t\tthis.question = question;\n\t\tthis.props = { rows: [], nextActive: false, nextLabel: ROW_INTENT_META.next.label };\n\t}\n\n\tsetProps(props: MultiSelectViewProps): void {\n\t\tthis.props = props;\n\t}\n\n\thandleInput(_data: string): void {}\n\n\tinvalidate(): void {\n\t\tthis.measured = undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tconst prefixWidth = this.prefixVisibleWidth();\n\t\tconst contentWidth = Math.max(1, width - prefixWidth);\n\t\tconst numberWidth = String(Math.max(1, this.question.options.length)).length;\n\t\tfor (let i = 0; i < this.question.options.length; i++) {\n\t\t\tconst opt = this.question.options[i];\n\t\t\tconst row = this.props.rows[i];\n\t\t\tif (!opt || !row) continue;\n\t\t\tconst pointer = row.active ? this.theme.fg(\"accent\", ACTIVE_POINTER) : INACTIVE_POINTER;\n\t\t\t// Checked uses the same `accent` hue as the active-row label so checked rows read\n\t\t\t// as \"selected\" rather than \"success\" — matches the visual rhythm of the rest of\n\t\t\t// the dialog (active pointer, label, picker rows are all accent).\n\t\t\tconst box = row.checked ? this.theme.fg(\"accent\", CHECKED) : this.theme.fg(\"muted\", UNCHECKED);\n\t\t\tconst label = truncateToWidth(opt.label, contentWidth, \"…\");\n\t\t\tconst styledLabel = row.active ? this.theme.fg(\"accent\", this.theme.bold(label)) : label;\n\t\t\tconst num = String(i + 1).padStart(numberWidth, \" \");\n\t\t\tconst line = `${pointer}${num}${NUMBER_SEPARATOR}${box}${BOX_LABEL_GAP}${styledLabel}`;\n\t\t\tconst rendered = truncateToWidth(line, width, \"\");\n\t\t\tlines.push(`${rendered}${row.active ? OVERLAY_ACTIVE_ROW_MARKER : \"\"}`);\n\t\t\tif (opt.description) {\n\t\t\t\tconst wrapped = wrapTextWithAnsi(opt.description, contentWidth);\n\t\t\t\tfor (const segment of wrapped) {\n\t\t\t\t\tlines.push(CONTINUATION_INDENT + this.theme.fg(\"muted\", segment));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst nextPointer = this.props.nextActive ? this.theme.fg(\"accent\", ACTIVE_POINTER) : INACTIVE_POINTER;\n\t\tconst nextLabel = this.props.nextActive\n\t\t\t? this.theme.fg(\"accent\", this.theme.bold(this.props.nextLabel))\n\t\t\t: this.props.nextLabel;\n\t\tconst rendered = truncateToWidth(`${nextPointer}${nextLabel}`, width, \"\");\n\t\tlines.push(`${rendered}${this.props.nextActive ? OVERLAY_ACTIVE_ROW_MARKER : \"\"}`);\n\t\treturn lines;\n\t}\n\n\tnaturalHeight(width: number): number {\n\t\tif (this.measured?.width !== width) this.measured = { width, height: this.measureHeight(width) };\n\t\treturn this.measured.height;\n\t}\n\n\tprivate measureHeight(width: number): number {\n\t\tconst contentWidth = Math.max(1, width - this.prefixVisibleWidth());\n\t\tlet total = 0;\n\t\tfor (const opt of this.question.options) {\n\t\t\tif (!opt) continue;\n\t\t\ttotal += 1; // row line\n\t\t\tif (opt.description) {\n\t\t\t\ttotal += wrapTextWithAnsi(opt.description, contentWidth).length;\n\t\t\t}\n\t\t}\n\t\treturn total + 1; // Next sentinel row (no description; never wraps).\n\t}\n\n\tprivate prefixVisibleWidth(): number {\n\t\t// Canonical prefix for OPTION rows: INACTIVE_POINTER + numberWidth digits + NUMBER_SEPARATOR\n\t\t// + UNCHECKED + BOX_LABEL_GAP. State-independent because ACTIVE/INACTIVE pointer share\n\t\t// visibleWidth, CHECKED/UNCHECKED share visibleWidth, and numberWidth is constant per question.\n\t\t// The Next sentinel uses a bare `pointer + \"Next\"` shape — its width never exceeds this prefix\n\t\t// at any reasonable terminal width, so it's safe to leave it out of the canonical computation.\n\t\tconst numberWidth = String(Math.max(1, this.question.options.length)).length;\n\t\treturn (\n\t\t\tvisibleWidth(INACTIVE_POINTER) + numberWidth + visibleWidth(`${NUMBER_SEPARATOR}${UNCHECKED}${BOX_LABEL_GAP}`)\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"multi-select-view.js","sourceRoot":"","sources":["../../../../../../src/core/tools/ask-user-question/view/components/multi-select-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEzF,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAI9E,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,OAAO,GAAG,KAAK,CAAC;AACtB,MAAM,SAAS,GAAG,KAAK,CAAC;AACxB,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,2FAA2F;AAC3F,gGAAgG;AAChG,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAQ3C;;;;;;;;;;GAUG;AACH,MAAM,OAAO,eAAe;IACnB,KAAK,CAAuB;IAC5B,QAAQ,CAAkE;IAKlF,YAAY,KAAY,EAAE,QAA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AAG,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACzC,IAAI,CAAC,GAAG;gBAAE,SAAS;YACnB,KAAK,IAAI,CAAC,CAAC,CAAC,WAAW;YACvB,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;gBACrB,KAAK,IAAI,gBAAgB,CAAC,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,MAAM,CAAC;YACjE,CAAC;QACF,CAAC;QACD,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,mDAAmD;IACtE,CAAC;IAEO,kBAAkB;QACzB,6FAA6F;QAC7F,uFAAuF;QACvF,gGAAgG;QAChG,+FAA+F;QAC/F,+FAA+F;QAC/F,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;QAC7E,OAAO,CACN,YAAY,CAAC,gBAAgB,CAAC,GAAG,WAAW,GAAG,YAAY,CAAC,GAAG,gBAAgB,GAAG,SAAS,GAAG,aAAa,EAAE,CAAC,CAC9G,CAAC;IACH,CAAC;CACD","sourcesContent":["import { truncateToWidth, visibleWidth, wrapTextWithAnsi } from \"@earendil-works/pi-tui\";\nimport type { Theme } from \"../../../../../modes/interactive/theme/theme.js\";\nimport { OVERLAY_ACTIVE_ROW_MARKER } from \"../../../../extensions/ui-types.js\";\nimport { ROW_INTENT_META } from \"../../state/row-intent.ts\";\nimport { rowTone, styleFieldTone } from \"../../state/selectors/field-tone.ts\";\nimport type { QuestionData } from \"../../tool/types.js\";\nimport type { StatefulView } from \"../stateful-view.ts\";\n\nconst ACTIVE_POINTER = \"❯ \";\nconst INACTIVE_POINTER = \" \";\nconst CHECKED = \"[✔]\";\nconst UNCHECKED = \"[ ]\";\nconst NUMBER_SEPARATOR = \". \";\nconst BOX_LABEL_GAP = \" \";\n// CC parity: description continuation indents to col 2 (past the pointer slot), NOT to the\n// full prefix column. Wrap width still uses prefixVisibleWidth so naturalHeight matches render.\nconst CONTINUATION_INDENT = \" \";\n\nexport const MULTI_SUBMIT_LABEL = \"Submit\";\n\nexport interface MultiSelectViewProps {\n\trows: ReadonlyArray<{ checked: boolean; active: boolean }>;\n\tnextActive: boolean;\n\tnextLabel: string;\n}\n\n/**\n * Renders the multi-select option list (one row per option — pointer + checkbox + label —\n * plus zero or more wrapped continuation lines per description).\n *\n * `naturalHeight(width)` is state-INDEPENDENT (depends only on theme glyph widths,\n * question.options, and width) so the host can compute a stable globalContentHeight\n * without rendering. `naturalHeight(w) === render(w).length` for every props. It is\n * measured once per width.\n *\n * `setProps(props)` is a pure field reassignment — no render, no invalidate side effects.\n */\nexport class MultiSelectView implements StatefulView<MultiSelectViewProps> {\n\tprivate props: MultiSelectViewProps;\n\tprivate measured: { readonly width: number; readonly height: number } | undefined;\n\n\tprivate declare readonly theme: Theme;\n\tprivate declare readonly question: QuestionData;\n\n\tconstructor(theme: Theme, question: QuestionData) {\n\t\tthis.theme = theme;\n\t\tthis.question = question;\n\t\tthis.props = { rows: [], nextActive: false, nextLabel: ROW_INTENT_META.next.label };\n\t}\n\n\tsetProps(props: MultiSelectViewProps): void {\n\t\tthis.props = props;\n\t}\n\n\thandleInput(_data: string): void {}\n\n\tinvalidate(): void {\n\t\tthis.measured = undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst lines: string[] = [];\n\t\tconst prefixWidth = this.prefixVisibleWidth();\n\t\tconst contentWidth = Math.max(1, width - prefixWidth);\n\t\tconst numberWidth = String(Math.max(1, this.question.options.length)).length;\n\t\tfor (let i = 0; i < this.question.options.length; i++) {\n\t\t\tconst opt = this.question.options[i];\n\t\t\tconst row = this.props.rows[i];\n\t\t\tif (!opt || !row) continue;\n\t\t\tconst pointer = row.active ? this.theme.fg(\"accent\", ACTIVE_POINTER) : INACTIVE_POINTER;\n\t\t\t// A checked row holds part of the answer: `editing` while focused, `answered` otherwise.\n\t\t\tconst tone = rowTone(row.active, row.checked);\n\t\t\tconst box =\n\t\t\t\trow.checked && tone ? styleFieldTone(this.theme, tone, CHECKED) : this.theme.fg(\"muted\", UNCHECKED);\n\t\t\tconst label = truncateToWidth(opt.label, contentWidth, \"…\");\n\t\t\tconst styledLabel = tone ? styleFieldTone(this.theme, tone, label) : label;\n\t\t\tconst num = String(i + 1).padStart(numberWidth, \" \");\n\t\t\tconst line = `${pointer}${num}${NUMBER_SEPARATOR}${box}${BOX_LABEL_GAP}${styledLabel}`;\n\t\t\tconst rendered = truncateToWidth(line, width, \"\");\n\t\t\tlines.push(`${rendered}${row.active ? OVERLAY_ACTIVE_ROW_MARKER : \"\"}`);\n\t\t\tif (opt.description) {\n\t\t\t\tconst wrapped = wrapTextWithAnsi(opt.description, contentWidth);\n\t\t\t\tfor (const segment of wrapped) {\n\t\t\t\t\tlines.push(CONTINUATION_INDENT + this.theme.fg(\"muted\", segment));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst nextPointer = this.props.nextActive ? this.theme.fg(\"accent\", ACTIVE_POINTER) : INACTIVE_POINTER;\n\t\tconst nextLabel = this.props.nextActive\n\t\t\t? styleFieldTone(this.theme, \"editing\", this.props.nextLabel)\n\t\t\t: this.props.nextLabel;\n\t\tconst rendered = truncateToWidth(`${nextPointer}${nextLabel}`, width, \"\");\n\t\tlines.push(`${rendered}${this.props.nextActive ? OVERLAY_ACTIVE_ROW_MARKER : \"\"}`);\n\t\treturn lines;\n\t}\n\n\tnaturalHeight(width: number): number {\n\t\tif (this.measured?.width !== width) this.measured = { width, height: this.measureHeight(width) };\n\t\treturn this.measured.height;\n\t}\n\n\tprivate measureHeight(width: number): number {\n\t\tconst contentWidth = Math.max(1, width - this.prefixVisibleWidth());\n\t\tlet total = 0;\n\t\tfor (const opt of this.question.options) {\n\t\t\tif (!opt) continue;\n\t\t\ttotal += 1; // row line\n\t\t\tif (opt.description) {\n\t\t\t\ttotal += wrapTextWithAnsi(opt.description, contentWidth).length;\n\t\t\t}\n\t\t}\n\t\treturn total + 1; // Next sentinel row (no description; never wraps).\n\t}\n\n\tprivate prefixVisibleWidth(): number {\n\t\t// Canonical prefix for OPTION rows: INACTIVE_POINTER + numberWidth digits + NUMBER_SEPARATOR\n\t\t// + UNCHECKED + BOX_LABEL_GAP. State-independent because ACTIVE/INACTIVE pointer share\n\t\t// visibleWidth, CHECKED/UNCHECKED share visibleWidth, and numberWidth is constant per question.\n\t\t// The Next sentinel uses a bare `pointer + \"Next\"` shape — its width never exceeds this prefix\n\t\t// at any reasonable terminal width, so it's safe to leave it out of the canonical computation.\n\t\tconst numberWidth = String(Math.max(1, this.question.options.length)).length;\n\t\treturn (\n\t\t\tvisibleWidth(INACTIVE_POINTER) + numberWidth + visibleWidth(`${NUMBER_SEPARATOR}${UNCHECKED}${BOX_LABEL_GAP}`)\n\t\t);\n\t}\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { MarkdownTheme } from "@earendil-works/pi-tui";
1
+ import { type MarkdownTheme } from "@earendil-works/pi-tui";
2
2
  import type { Theme } from "../../../../../../modes/interactive/theme/theme.js";
3
3
  import type { QuestionData } from "../../../tool/types.js";
4
4
  import type { PreviewLayoutMode } from "./preview-layout-decider.ts";
@@ -39,8 +39,10 @@ export declare class PreviewBlockRenderer {
39
39
  * Render the full preview block at `width`: bordered box + blank separator + affordance row.
40
40
  * `focused` and `notesVisible` together gate the affordance text (visible only when the
41
41
  * focused option carries a preview AND notes mode is inactive). The affordance row is ALWAYS
42
- * emitted (as an empty string when gated) so the row count is invariant.
42
+ * emitted (as an empty string when gated) so the row count is invariant. It shows the saved
43
+ * `notes` in the `answered` tone, or the add-notes prompt in the `placeholder` tone.
43
44
  */
44
- renderBlock(width: number, optionIndex: number, mode: PreviewLayoutMode, focused: boolean, notesVisible: boolean): string[];
45
+ renderBlock(width: number, optionIndex: number, mode: PreviewLayoutMode, focused: boolean, notesVisible: boolean, notes: string): string[];
46
+ private renderNotesAffordance;
45
47
  }
46
48
  //# sourceMappingURL=preview-block-renderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"preview-block-renderer.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/tools/ask-user-question/view/components/preview/preview-block-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oDAAoD,CAAC;AAChF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAc3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;GAGG;AACH,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAE1D,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,aAAa,EAAE,aAAa,CAAC;CAC7B;AAED;;;;;;;;;GASG;AACH,qBAAa,oBAAoB;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuB;IAE7C,YAAY,MAAM,EAAE,0BAA0B,EAG7C;IAED,aAAa,IAAI,OAAO,CAEvB;IAED,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAEhC;IAED,UAAU,IAAI,IAAI,CAEjB;IAED;;;;OAIG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAO/E;IAED;;;;;OAKG;IACH,WAAW,CACV,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,OAAO,GACnB,MAAM,EAAE,CAiBV;CACD"}
1
+ {"version":3,"file":"preview-block-renderer.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/tools/ask-user-question/view/components/preview/preview-block-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,wBAAwB,CAAC;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oDAAoD,CAAC;AAEhF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAc3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;GAGG;AACH,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAG1D,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,aAAa,EAAE,aAAa,CAAC;CAC7B;AAED;;;;;;;;;GASG;AACH,qBAAa,oBAAoB;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuB;IAE7C,YAAY,MAAM,EAAE,0BAA0B,EAG7C;IAED,aAAa,IAAI,OAAO,CAEvB;IAED,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAEhC;IAED,UAAU,IAAI,IAAI,CAEjB;IAED;;;;OAIG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAO/E;IAED;;;;;;OAMG;IACH,WAAW,CACV,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,OAAO,EACrB,KAAK,EAAE,MAAM,GACX,MAAM,EAAE,CAgBV;IAED,OAAO,CAAC,qBAAqB;CAM7B"}
@@ -1,3 +1,5 @@
1
+ import { truncateToWidth } from "@earendil-works/pi-tui";
2
+ import { fieldTone, styleFieldTone } from "../../../state/selectors/field-tone.js";
1
3
  import { MAX_PREVIEW_HEIGHT_SIDE_BY_SIDE, MAX_PREVIEW_HEIGHT_STACKED, MarkdownContentCache, NOTES_AFFORDANCE_OVERHEAD, } from "./markdown-content-cache.js";
2
4
  import { BORDER_HORIZONTAL_OVERHEAD, BORDER_INNER_PADDING_HORIZONTAL, BORDER_VERTICAL_OVERHEAD, computeBoxDimensions, renderBorderedBox, } from "./preview-box-renderer.js";
3
5
  /**
@@ -5,6 +7,7 @@ import { BORDER_HORIZONTAL_OVERHEAD, BORDER_INNER_PADDING_HORIZONTAL, BORDER_VER
5
7
  * Re-exported by `preview-pane.ts` for the existing test surface.
6
8
  */
7
9
  export const NOTES_AFFORDANCE_TEXT = "Notes: n add notes";
10
+ const NOTES_LABEL = "Notes: ";
8
11
  /**
9
12
  * Renders the bordered markdown preview block for a single question (one block per render call,
10
13
  * for the option at `optionIndex`). Owns a per-question `MarkdownContentCache`.
@@ -48,9 +51,10 @@ export class PreviewBlockRenderer {
48
51
  * Render the full preview block at `width`: bordered box + blank separator + affordance row.
49
52
  * `focused` and `notesVisible` together gate the affordance text (visible only when the
50
53
  * focused option carries a preview AND notes mode is inactive). The affordance row is ALWAYS
51
- * emitted (as an empty string when gated) so the row count is invariant.
54
+ * emitted (as an empty string when gated) so the row count is invariant. It shows the saved
55
+ * `notes` in the `answered` tone, or the add-notes prompt in the `placeholder` tone.
52
56
  */
53
- renderBlock(width, optionIndex, mode, focused, notesVisible) {
57
+ renderBlock(width, optionIndex, mode, focused, notesVisible, notes) {
54
58
  const cap = mode === "side-by-side" ? MAX_PREVIEW_HEIGHT_SIDE_BY_SIDE : MAX_PREVIEW_HEIGHT_STACKED;
55
59
  const contentBudget = Math.max(1, cap - BORDER_VERTICAL_OVERHEAD - NOTES_AFFORDANCE_OVERHEAD);
56
60
  const maxInnerWidth = Math.max(1, width - BORDER_HORIZONTAL_OVERHEAD - 2 * BORDER_INNER_PADDING_HORIZONTAL);
@@ -62,8 +66,14 @@ export class PreviewBlockRenderer {
62
66
  const colorFn = (s) => this.theme.fg("accent", s);
63
67
  const boxedLines = renderBorderedBox(contentLines, boxWidth, colorFn, hidden);
64
68
  const showAffordance = focused && !notesVisible && this.cache.has(optionIndex);
65
- const affordance = showAffordance ? this.theme.fg("muted", NOTES_AFFORDANCE_TEXT) : "";
66
- return [...boxedLines, "", affordance];
69
+ return [...boxedLines, "", showAffordance ? this.renderNotesAffordance(width, notes) : ""];
70
+ }
71
+ renderNotesAffordance(width, notes) {
72
+ const tone = fieldTone(false, notes);
73
+ if (tone === "placeholder")
74
+ return styleFieldTone(this.theme, tone, NOTES_AFFORDANCE_TEXT);
75
+ const line = `${this.theme.fg("muted", NOTES_LABEL)}${styleFieldTone(this.theme, tone, notes)}`;
76
+ return truncateToWidth(line, width, "…");
67
77
  }
68
78
  }
69
79
  //# sourceMappingURL=preview-block-renderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preview-block-renderer.js","sourceRoot":"","sources":["../../../../../../../src/core/tools/ask-user-question/view/components/preview/preview-block-renderer.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,+BAA+B,EAC/B,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,GACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,0BAA0B,EAC1B,+BAA+B,EAC/B,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,GACjB,MAAM,2BAA2B,CAAC;AAGnC;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAQ1D;;;;;;;;;GASG;AACH,MAAM,OAAO,oBAAoB;IACf,KAAK,CAAQ;IACb,KAAK,CAAuB;IAE7C,YAAY,MAAkC;QAC7C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,oBAAoB,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;IAC5F,CAAC;IAED,aAAa;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,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GAAG,+BAA+B,CAAC,CAAC;QAE5G,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAC3D,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,GAAG,aAAa,CAAC;QAC7C,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,MAAM,YAAY,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAEnE,MAAM,EAAE,QAAQ,EAAE,GAAG,oBAAoB,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;QACvE,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC1D,MAAM,UAAU,GAAG,iBAAiB,CAAC,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAE9E,MAAM,cAAc,GAAG,OAAO,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC/E,MAAM,UAAU,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACvF,OAAO,CAAC,GAAG,UAAU,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC;IACxC,CAAC;CACD","sourcesContent":["import type { MarkdownTheme } from \"@earendil-works/pi-tui\";\nimport type { Theme } from \"../../../../../../modes/interactive/theme/theme.js\";\nimport type { QuestionData } from \"../../../tool/types.js\";\nimport {\n\tMAX_PREVIEW_HEIGHT_SIDE_BY_SIDE,\n\tMAX_PREVIEW_HEIGHT_STACKED,\n\tMarkdownContentCache,\n\tNOTES_AFFORDANCE_OVERHEAD,\n} from \"./markdown-content-cache.ts\";\nimport {\n\tBORDER_HORIZONTAL_OVERHEAD,\n\tBORDER_INNER_PADDING_HORIZONTAL,\n\tBORDER_VERTICAL_OVERHEAD,\n\tcomputeBoxDimensions,\n\trenderBorderedBox,\n} from \"./preview-box-renderer.ts\";\nimport type { PreviewLayoutMode } from \"./preview-layout-decider.ts\";\n\n/**\n * Affordance text shown below the bordered preview when focused on a preview-bearing option.\n * Re-exported by `preview-pane.ts` for the existing test surface.\n */\nexport const NOTES_AFFORDANCE_TEXT = \"Notes: n add notes\";\n\nexport interface PreviewBlockRendererConfig {\n\tquestion: QuestionData;\n\ttheme: Theme;\n\tmarkdownTheme: MarkdownTheme;\n}\n\n/**\n * Renders the bordered markdown preview block for a single question (one block per render call,\n * for the option at `optionIndex`). Owns a per-question `MarkdownContentCache`.\n *\n * NOT a `Component` — pure render-and-measure helper consumed by `PreviewPane`. The layout mode\n * is threaded as an explicit param (never re-derived from column width post-split).\n *\n * The affordance row is always emitted (visually empty when gated) so the preview block's row\n * count is height-stable across affordance-state transitions.\n */\nexport class PreviewBlockRenderer {\n\tprivate readonly theme: Theme;\n\tprivate readonly cache: MarkdownContentCache;\n\n\tconstructor(config: PreviewBlockRendererConfig) {\n\t\tthis.theme = config.theme;\n\t\tthis.cache = new MarkdownContentCache(config.question, config.theme, config.markdownTheme);\n\t}\n\n\thasAnyPreview(): boolean {\n\t\treturn this.cache.hasAnyPreview();\n\t}\n\n\thas(optionIndex: number): boolean {\n\t\treturn this.cache.has(optionIndex);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.cache.invalidate();\n\t}\n\n\t/**\n\t * Height contribution of the preview block: `BORDER_VERTICAL_OVERHEAD + contentRows +\n\t * NOTES_AFFORDANCE_OVERHEAD`. Always returns the same value as `renderBlock(...).length`\n\t * — the affordance overhead is constant, not gated by `focused`/`notesVisible`.\n\t */\n\tblockHeight(width: number, optionIndex: number, mode: PreviewLayoutMode): number {\n\t\tconst cap = mode === \"side-by-side\" ? MAX_PREVIEW_HEIGHT_SIDE_BY_SIDE : MAX_PREVIEW_HEIGHT_STACKED;\n\t\tconst contentBudget = Math.max(1, cap - BORDER_VERTICAL_OVERHEAD - NOTES_AFFORDANCE_OVERHEAD);\n\t\tconst innerWidth = Math.max(1, width - BORDER_HORIZONTAL_OVERHEAD - 2 * BORDER_INNER_PADDING_HORIZONTAL);\n\t\tconst rawRows = this.cache.bodyFor(optionIndex, innerWidth).length;\n\t\tconst contentRows = Math.min(rawRows, contentBudget);\n\t\treturn BORDER_VERTICAL_OVERHEAD + contentRows + NOTES_AFFORDANCE_OVERHEAD;\n\t}\n\n\t/**\n\t * Render the full preview block at `width`: bordered box + blank separator + affordance row.\n\t * `focused` and `notesVisible` together gate the affordance text (visible only when the\n\t * focused option carries a preview AND notes mode is inactive). The affordance row is ALWAYS\n\t * emitted (as an empty string when gated) so the row count is invariant.\n\t */\n\trenderBlock(\n\t\twidth: number,\n\t\toptionIndex: number,\n\t\tmode: PreviewLayoutMode,\n\t\tfocused: boolean,\n\t\tnotesVisible: boolean,\n\t): string[] {\n\t\tconst cap = mode === \"side-by-side\" ? MAX_PREVIEW_HEIGHT_SIDE_BY_SIDE : MAX_PREVIEW_HEIGHT_STACKED;\n\t\tconst contentBudget = Math.max(1, cap - BORDER_VERTICAL_OVERHEAD - NOTES_AFFORDANCE_OVERHEAD);\n\t\tconst maxInnerWidth = Math.max(1, width - BORDER_HORIZONTAL_OVERHEAD - 2 * BORDER_INNER_PADDING_HORIZONTAL);\n\n\t\tconst raw = this.cache.bodyFor(optionIndex, maxInnerWidth);\n\t\tconst truncated = raw.length > contentBudget;\n\t\tconst hidden = truncated ? raw.length - contentBudget : 0;\n\t\tconst contentLines = truncated ? raw.slice(0, contentBudget) : raw;\n\n\t\tconst { boxWidth } = computeBoxDimensions(contentLines, maxInnerWidth);\n\t\tconst colorFn = (s: string) => this.theme.fg(\"accent\", s);\n\t\tconst boxedLines = renderBorderedBox(contentLines, boxWidth, colorFn, hidden);\n\n\t\tconst showAffordance = focused && !notesVisible && this.cache.has(optionIndex);\n\t\tconst affordance = showAffordance ? this.theme.fg(\"muted\", NOTES_AFFORDANCE_TEXT) : \"\";\n\t\treturn [...boxedLines, \"\", affordance];\n\t}\n}\n"]}
1
+ {"version":3,"file":"preview-block-renderer.js","sourceRoot":"","sources":["../../../../../../../src/core/tools/ask-user-question/view/components/preview/preview-block-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE7E,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAEnF,OAAO,EACN,+BAA+B,EAC/B,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,GACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,0BAA0B,EAC1B,+BAA+B,EAC/B,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,GACjB,MAAM,2BAA2B,CAAC;AAGnC;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAC1D,MAAM,WAAW,GAAG,SAAS,CAAC;AAQ9B;;;;;;;;;GASG;AACH,MAAM,OAAO,oBAAoB;IACf,KAAK,CAAQ;IACb,KAAK,CAAuB;IAE7C,YAAY,MAAkC;QAC7C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,oBAAoB,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;IAC5F,CAAC;IAED,aAAa;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;IACnC,CAAC;IAED,GAAG,CAAC,WAAmB;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,C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,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QAChG,OAAO,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;CACD","sourcesContent":["import { type MarkdownTheme, truncateToWidth } from \"@earendil-works/pi-tui\";\nimport type { Theme } from \"../../../../../../modes/interactive/theme/theme.js\";\nimport { fieldTone, styleFieldTone } from \"../../../state/selectors/field-tone.ts\";\nimport type { QuestionData } from \"../../../tool/types.js\";\nimport {\n\tMAX_PREVIEW_HEIGHT_SIDE_BY_SIDE,\n\tMAX_PREVIEW_HEIGHT_STACKED,\n\tMarkdownContentCache,\n\tNOTES_AFFORDANCE_OVERHEAD,\n} from \"./markdown-content-cache.ts\";\nimport {\n\tBORDER_HORIZONTAL_OVERHEAD,\n\tBORDER_INNER_PADDING_HORIZONTAL,\n\tBORDER_VERTICAL_OVERHEAD,\n\tcomputeBoxDimensions,\n\trenderBorderedBox,\n} from \"./preview-box-renderer.ts\";\nimport type { PreviewLayoutMode } from \"./preview-layout-decider.ts\";\n\n/**\n * Affordance text shown below the bordered preview when focused on a preview-bearing option.\n * Re-exported by `preview-pane.ts` for the existing test surface.\n */\nexport const NOTES_AFFORDANCE_TEXT = \"Notes: n add notes\";\nconst NOTES_LABEL = \"Notes: \";\n\nexport interface PreviewBlockRendererConfig {\n\tquestion: QuestionData;\n\ttheme: Theme;\n\tmarkdownTheme: MarkdownTheme;\n}\n\n/**\n * Renders the bordered markdown preview block for a single question (one block per render call,\n * for the option at `optionIndex`). Owns a per-question `MarkdownContentCache`.\n *\n * NOT a `Component` — pure render-and-measure helper consumed by `PreviewPane`. The layout mode\n * is threaded as an explicit param (never re-derived from column width post-split).\n *\n * The affordance row is always emitted (visually empty when gated) so the preview block's row\n * count is height-stable across affordance-state transitions.\n */\nexport class PreviewBlockRenderer {\n\tprivate readonly theme: Theme;\n\tprivate readonly cache: MarkdownContentCache;\n\n\tconstructor(config: PreviewBlockRendererConfig) {\n\t\tthis.theme = config.theme;\n\t\tthis.cache = new MarkdownContentCache(config.question, config.theme, config.markdownTheme);\n\t}\n\n\thasAnyPreview(): boolean {\n\t\treturn this.cache.hasAnyPreview();\n\t}\n\n\thas(optionIndex: number): boolean {\n\t\treturn this.cache.has(optionIndex);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.cache.invalidate();\n\t}\n\n\t/**\n\t * Height contribution of the preview block: `BORDER_VERTICAL_OVERHEAD + contentRows +\n\t * NOTES_AFFORDANCE_OVERHEAD`. Always returns the same value as `renderBlock(...).length`\n\t * — the affordance overhead is constant, not gated by `focused`/`notesVisible`.\n\t */\n\tblockHeight(width: number, optionIndex: number, mode: PreviewLayoutMode): number {\n\t\tconst cap = mode === \"side-by-side\" ? MAX_PREVIEW_HEIGHT_SIDE_BY_SIDE : MAX_PREVIEW_HEIGHT_STACKED;\n\t\tconst contentBudget = Math.max(1, cap - BORDER_VERTICAL_OVERHEAD - NOTES_AFFORDANCE_OVERHEAD);\n\t\tconst innerWidth = Math.max(1, width - BORDER_HORIZONTAL_OVERHEAD - 2 * BORDER_INNER_PADDING_HORIZONTAL);\n\t\tconst rawRows = this.cache.bodyFor(optionIndex, innerWidth).length;\n\t\tconst contentRows = Math.min(rawRows, contentBudget);\n\t\treturn BORDER_VERTICAL_OVERHEAD + contentRows + NOTES_AFFORDANCE_OVERHEAD;\n\t}\n\n\t/**\n\t * Render the full preview block at `width`: bordered box + blank separator + affordance row.\n\t * `focused` and `notesVisible` together gate the affordance text (visible only when the\n\t * focused option carries a preview AND notes mode is inactive). The affordance row is ALWAYS\n\t * emitted (as an empty string when gated) so the row count is invariant. It shows the saved\n\t * `notes` in the `answered` tone, or the add-notes prompt in the `placeholder` tone.\n\t */\n\trenderBlock(\n\t\twidth: number,\n\t\toptionIndex: number,\n\t\tmode: PreviewLayoutMode,\n\t\tfocused: boolean,\n\t\tnotesVisible: boolean,\n\t\tnotes: string,\n\t): string[] {\n\t\tconst cap = mode === \"side-by-side\" ? MAX_PREVIEW_HEIGHT_SIDE_BY_SIDE : MAX_PREVIEW_HEIGHT_STACKED;\n\t\tconst contentBudget = Math.max(1, cap - BORDER_VERTICAL_OVERHEAD - NOTES_AFFORDANCE_OVERHEAD);\n\t\tconst maxInnerWidth = Math.max(1, width - BORDER_HORIZONTAL_OVERHEAD - 2 * BORDER_INNER_PADDING_HORIZONTAL);\n\n\t\tconst raw = this.cache.bodyFor(optionIndex, maxInnerWidth);\n\t\tconst truncated = raw.length > contentBudget;\n\t\tconst hidden = truncated ? raw.length - contentBudget : 0;\n\t\tconst contentLines = truncated ? raw.slice(0, contentBudget) : raw;\n\n\t\tconst { boxWidth } = computeBoxDimensions(contentLines, maxInnerWidth);\n\t\tconst colorFn = (s: string) => this.theme.fg(\"accent\", s);\n\t\tconst boxedLines = renderBorderedBox(contentLines, boxWidth, colorFn, hidden);\n\n\t\tconst showAffordance = focused && !notesVisible && this.cache.has(optionIndex);\n\t\treturn [...boxedLines, \"\", showAffordance ? this.renderNotesAffordance(width, notes) : \"\"];\n\t}\n\n\tprivate renderNotesAffordance(width: number, notes: string): string {\n\t\tconst tone = fieldTone(false, notes);\n\t\tif (tone === \"placeholder\") return styleFieldTone(this.theme, tone, NOTES_AFFORDANCE_TEXT);\n\t\tconst line = `${this.theme.fg(\"muted\", NOTES_LABEL)}${styleFieldTone(this.theme, tone, notes)}`;\n\t\treturn truncateToWidth(line, width, \"…\");\n\t}\n}\n"]}
@@ -20,6 +20,8 @@ export interface PreviewPaneProps {
20
20
  notesVisible: boolean;
21
21
  selectedIndex: number;
22
22
  focused: boolean;
23
+ /** Saved notes for the active question; shown on the affordance row while notes mode is closed. */
24
+ notes: string;
23
25
  }
24
26
  export interface PreviewPaneConfig {
25
27
  question: QuestionData;
@@ -1 +1 @@
1
- {"version":3,"file":"preview-pane.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/tools/ask-user-question/view/components/preview/preview-pane.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS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CAAC,KAAK,CAAmB;IAChC;;;;OAIG;IACH,OAAO,CAAC,eAAe,CAErB;IAEF,YAAY,MAAM,EAAE,iBAAiB,EAMpC;IAED,kBAAkB,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAE9D;IAED,OAAO,CAAC,eAAe;IAIvB,QAAQ,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAEtC;IAED,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAG;IAEnC,UAAU,IAAI,IAAI,CAGjB;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAoB9B;IAED,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CActC;IAED,OAAO,CAAC,gBAAgB;IAmBxB,OAAO,CAAC,wBAAwB;CAYhC"}
1
+ {"version":3,"file":"preview-pane.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/tools/ask-user-question/view/components/preview/preview-pane.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAiC,MAAM,wBAAwB,CAAC;AACvF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAWxE,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,OAA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