@juicesharp/rpiv-ask-user-question 2.0.0 → 2.2.0
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.
- package/README.md +68 -86
- package/ask-user-question.ts +48 -9
- package/docs/configuration.md +112 -0
- package/docs/hosts.md +87 -0
- package/docs/keyboard.md +96 -0
- package/docs/localization.md +83 -0
- package/docs/tool-schema.md +121 -0
- package/events.ts +12 -0
- package/index.ts +4 -1
- package/locales/de.json +5 -1
- package/locales/en.json +4 -0
- package/locales/es.json +5 -1
- package/locales/fr.json +5 -1
- package/locales/pt-BR.json +5 -1
- package/locales/pt.json +5 -1
- package/locales/ru.json +5 -1
- package/locales/uk.json +5 -1
- package/locales/zh.json +4 -0
- package/package.json +7 -2
- package/state/build-questionnaire.ts +28 -12
- package/state/external-editor.ts +62 -0
- package/state/key-router.ts +53 -10
- package/state/questionnaire-session.ts +45 -33
- package/state/selectors/derivations.ts +0 -16
- package/state/state-reducer.ts +62 -23
- package/state/state.ts +4 -2
- package/tool/types.ts +2 -2
- package/view/components/inline-input.ts +20 -50
- package/view/components/multi-select-view.ts +70 -84
- package/view/components/option-list-view.ts +1 -1
- package/view/components/wrapping-select.ts +15 -18
- package/view/dialog-builder.ts +17 -10
- package/view/props-adapter.ts +11 -17
- package/view/tab-content-strategy.ts +12 -10
|
@@ -38,14 +38,21 @@ export interface MultiSelectViewProps {
|
|
|
38
38
|
* Renders the multi-select option list (one row per option — pointer + checkbox + label —
|
|
39
39
|
* plus zero or more wrapped continuation lines per description).
|
|
40
40
|
*
|
|
41
|
-
* `naturalHeight(width)` is
|
|
42
|
-
*
|
|
43
|
-
*
|
|
41
|
+
* `naturalHeight(width)` is the rendered height for the current props. It grows when
|
|
42
|
+
* the custom-answer editor contains logical or visually wrapped lines, allowing the
|
|
43
|
+
* dialog to reserve exactly the space the active draft needs.
|
|
44
44
|
*
|
|
45
|
-
*
|
|
45
|
+
* One width-keyed layout supplies rendering, height, and focused-row measurement;
|
|
46
|
+
* `setProps` and `invalidate` discard that derived cache.
|
|
46
47
|
*/
|
|
48
|
+
interface MultiSelectLayout {
|
|
49
|
+
lines: string[];
|
|
50
|
+
focusedRange: [number, number];
|
|
51
|
+
}
|
|
52
|
+
|
|
47
53
|
export class MultiSelectView implements StatefulView<MultiSelectViewProps> {
|
|
48
54
|
private props: MultiSelectViewProps;
|
|
55
|
+
private cachedLayout: { width: number; value: MultiSelectLayout } | undefined;
|
|
49
56
|
|
|
50
57
|
constructor(
|
|
51
58
|
private readonly theme: Theme,
|
|
@@ -61,118 +68,97 @@ export class MultiSelectView implements StatefulView<MultiSelectViewProps> {
|
|
|
61
68
|
|
|
62
69
|
setProps(props: MultiSelectViewProps): void {
|
|
63
70
|
this.props = props;
|
|
71
|
+
this.cachedLayout = undefined;
|
|
64
72
|
}
|
|
65
73
|
|
|
66
74
|
handleInput(_data: string): void {}
|
|
67
75
|
|
|
68
|
-
invalidate(): void {
|
|
76
|
+
invalidate(): void {
|
|
77
|
+
this.cachedLayout = undefined;
|
|
78
|
+
}
|
|
69
79
|
|
|
70
80
|
render(width: number): string[] {
|
|
81
|
+
return this.layout(width).lines;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
focusedItemRowRange(width: number): [number, number] {
|
|
85
|
+
return this.layout(width).focusedRange;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
naturalHeight(width: number): number {
|
|
89
|
+
return this.layout(width).lines.length;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private layout(width: number): MultiSelectLayout {
|
|
93
|
+
if (this.cachedLayout?.width === width) return this.cachedLayout.value;
|
|
94
|
+
|
|
71
95
|
const lines: string[] = [];
|
|
72
|
-
|
|
73
|
-
const contentWidth = Math.max(1, width -
|
|
96
|
+
let focusedRange: [number, number] = [0, 0];
|
|
97
|
+
const contentWidth = Math.max(1, width - this.prefixVisibleWidth());
|
|
74
98
|
const numberWidth = String(Math.max(1, this.question.options.length + 1)).length;
|
|
75
99
|
for (let i = 0; i < this.question.options.length; i++) {
|
|
76
100
|
const opt = this.question.options[i];
|
|
77
101
|
const row = this.props.rows[i];
|
|
78
102
|
if (!opt || !row) continue;
|
|
103
|
+
const start = lines.length;
|
|
79
104
|
const pointer = row.active ? this.theme.fg("accent", ACTIVE_POINTER) : INACTIVE_POINTER;
|
|
80
|
-
// Checked
|
|
81
|
-
// as "selected" rather than "success" — matches the visual rhythm of the rest of
|
|
82
|
-
// the dialog (active pointer, label, picker rows are all accent).
|
|
105
|
+
// Checked and active rows share the accent hue, matching the dialog's selection rhythm.
|
|
83
106
|
const box = row.checked ? this.theme.fg("accent", CHECKED) : this.theme.fg("muted", UNCHECKED);
|
|
84
107
|
const label = truncateToWidth(opt.label, contentWidth, "…");
|
|
85
108
|
const styledLabel = row.active ? this.theme.fg("accent", this.theme.bold(label)) : label;
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
109
|
+
const number = String(i + 1).padStart(numberWidth, " ");
|
|
110
|
+
lines.push(
|
|
111
|
+
truncateToWidth(`${pointer}${number}${NUMBER_SEPARATOR}${box}${BOX_LABEL_GAP}${styledLabel}`, width, ""),
|
|
112
|
+
);
|
|
89
113
|
if (opt.description) {
|
|
90
|
-
const
|
|
91
|
-
for (const segment of wrapped) {
|
|
114
|
+
for (const segment of wrapTextWithAnsi(opt.description, contentWidth)) {
|
|
92
115
|
lines.push(CONTINUATION_INDENT + this.theme.fg("muted", segment));
|
|
93
116
|
}
|
|
94
117
|
}
|
|
118
|
+
if (row.active) focusedRange = [start, lines.length];
|
|
95
119
|
}
|
|
96
120
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const other = this.props.other;
|
|
101
|
-
const otherPointer = other.active ? this.theme.fg("accent", ACTIVE_POINTER) : INACTIVE_POINTER;
|
|
102
|
-
const otherBox = this.theme.fg("muted", UNCHECKED);
|
|
103
|
-
const otherNum = String(this.question.options.length + 1).padStart(numberWidth, " ");
|
|
104
|
-
let otherLabel: string;
|
|
105
|
-
if (other.active && other.inputMode) {
|
|
106
|
-
const rendered = renderInlineInputRow({
|
|
107
|
-
buffer: other.inputBuffer,
|
|
108
|
-
cursorOffset: other.inputCursorOffset,
|
|
109
|
-
rowPrefix: "",
|
|
110
|
-
continuationPrefix: "",
|
|
111
|
-
contentWidth,
|
|
112
|
-
selectedText: (t) => this.theme.fg("accent", this.theme.bold(t)),
|
|
113
|
-
multiline: false,
|
|
114
|
-
});
|
|
115
|
-
otherLabel = rendered[0] ?? "";
|
|
116
|
-
} else {
|
|
117
|
-
const label = truncateToWidth(displayLabel("other"), contentWidth, "…");
|
|
118
|
-
otherLabel = other.active ? this.theme.fg("accent", this.theme.bold(label)) : label;
|
|
119
|
-
}
|
|
120
|
-
lines.push(
|
|
121
|
-
truncateToWidth(
|
|
122
|
-
`${otherPointer}${otherNum}${NUMBER_SEPARATOR}${otherBox}${BOX_LABEL_GAP}${otherLabel}`,
|
|
123
|
-
width,
|
|
124
|
-
"",
|
|
125
|
-
),
|
|
126
|
-
);
|
|
121
|
+
const otherStart = lines.length;
|
|
122
|
+
lines.push(...this.renderOtherRow(contentWidth, numberWidth));
|
|
123
|
+
if (this.props.other.active) focusedRange = [otherStart, lines.length];
|
|
127
124
|
|
|
125
|
+
const nextStart = lines.length;
|
|
128
126
|
const nextPointer = this.props.nextActive ? this.theme.fg("accent", ACTIVE_POINTER) : INACTIVE_POINTER;
|
|
129
127
|
const nextLabel = this.props.nextActive
|
|
130
128
|
? this.theme.fg("accent", this.theme.bold(this.props.nextLabel))
|
|
131
129
|
: this.props.nextLabel;
|
|
132
130
|
lines.push(truncateToWidth(`${nextPointer}${nextLabel}`, width, ""));
|
|
133
|
-
|
|
134
|
-
}
|
|
131
|
+
if (this.props.nextActive) focusedRange = [nextStart, lines.length];
|
|
135
132
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
*/
|
|
140
|
-
focusedItemRowRange(width: number): [number, number] {
|
|
141
|
-
const prefixWidth = this.prefixVisibleWidth();
|
|
142
|
-
const contentWidth = Math.max(1, width - prefixWidth);
|
|
143
|
-
let row = 0;
|
|
144
|
-
for (let i = 0; i < this.question.options.length; i++) {
|
|
145
|
-
const opt = this.question.options[i];
|
|
146
|
-
const r = this.props.rows[i];
|
|
147
|
-
if (!opt || !r) continue;
|
|
148
|
-
const itemHeight = 1 + (opt.description ? wrapTextWithAnsi(opt.description, contentWidth).length : 0);
|
|
149
|
-
if (r.active) {
|
|
150
|
-
return [row, row + itemHeight];
|
|
151
|
-
}
|
|
152
|
-
row += itemHeight;
|
|
153
|
-
}
|
|
154
|
-
// "Type something." row is always exactly 1 line (truncated, no description).
|
|
155
|
-
if (this.props.other.active) {
|
|
156
|
-
return [row, row + 1];
|
|
157
|
-
}
|
|
158
|
-
row += 1;
|
|
159
|
-
if (this.props.nextActive) {
|
|
160
|
-
return [row, row + 1];
|
|
161
|
-
}
|
|
162
|
-
return [0, 0];
|
|
133
|
+
const value = { lines, focusedRange };
|
|
134
|
+
this.cachedLayout = { width, value };
|
|
135
|
+
return value;
|
|
163
136
|
}
|
|
164
137
|
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
138
|
+
private renderOtherRow(contentWidth: number, numberWidth: number): string[] {
|
|
139
|
+
const other = this.props.other;
|
|
140
|
+
const pointer = other.active ? this.theme.fg("accent", ACTIVE_POINTER) : INACTIVE_POINTER;
|
|
141
|
+
const box = this.theme.fg("muted", UNCHECKED);
|
|
142
|
+
const number = String(this.question.options.length + 1).padStart(numberWidth, " ");
|
|
143
|
+
const rowPrefix = `${pointer}${number}${NUMBER_SEPARATOR}${box}${BOX_LABEL_GAP}`;
|
|
144
|
+
const continuationPrefix = " ".repeat(visibleWidth(rowPrefix));
|
|
145
|
+
const selectedText = (text: string) => this.theme.fg("accent", this.theme.bold(text));
|
|
146
|
+
|
|
147
|
+
if (other.active && other.inputMode) {
|
|
148
|
+
return renderInlineInputRow({
|
|
149
|
+
buffer: other.inputBuffer,
|
|
150
|
+
cursorOffset: other.inputCursorOffset,
|
|
151
|
+
rowPrefix,
|
|
152
|
+
continuationPrefix,
|
|
153
|
+
contentWidth,
|
|
154
|
+
selectedText,
|
|
155
|
+
});
|
|
174
156
|
}
|
|
175
|
-
|
|
157
|
+
|
|
158
|
+
return wrapTextWithAnsi(other.inputBuffer || displayLabel("other"), contentWidth).map((segment, index) => {
|
|
159
|
+
const line = `${index === 0 ? rowPrefix : continuationPrefix}${segment}`;
|
|
160
|
+
return other.active ? selectedText(line) : line;
|
|
161
|
+
});
|
|
176
162
|
}
|
|
177
163
|
|
|
178
164
|
private prefixVisibleWidth(): number {
|
|
@@ -15,7 +15,7 @@ export interface OptionListViewConfig {
|
|
|
15
15
|
/**
|
|
16
16
|
* Per-tick projection of OptionListView state. After Phase 11b, `inputBuffer`
|
|
17
17
|
* is part of the props bag — the session-owned `inlineInput` (a headless
|
|
18
|
-
* `pi-tui`
|
|
18
|
+
* `pi-tui` Editor instance) supplies its current `getText()` here per tick.
|
|
19
19
|
* `OptionListView` is purely props-driven; the imperative buffer surface and
|
|
20
20
|
* read-back getters are gone.
|
|
21
21
|
*/
|
|
@@ -12,7 +12,7 @@ import { renderInlineInputRow } from "./inline-input.js";
|
|
|
12
12
|
* Variant semantics:
|
|
13
13
|
* - `option`: a regular author-defined option row.
|
|
14
14
|
* - `other`: the inline free-text input row appended to every question
|
|
15
|
-
* (label is "Type something."). Renders
|
|
15
|
+
* (label is "Type something."). Renders the headless multiline editor when active.
|
|
16
16
|
* - `next`: the explicit commit-and-advance row appended to multi-select questions
|
|
17
17
|
* (label is "Next"). Renders without a number / checkbox.
|
|
18
18
|
*/
|
|
@@ -216,16 +216,20 @@ export class WrappingSelect implements Component {
|
|
|
216
216
|
return this.renderInlineInputRow(rowPrefix, continuationPrefix, contentWidth);
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
//
|
|
220
|
-
//
|
|
221
|
-
//
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
219
|
+
// Keep an in-flight custom draft visible even while the cursor browses another row.
|
|
220
|
+
// If it differs from a previously confirmed custom answer, omit the confirmation
|
|
221
|
+
// mark so the pending draft is not presented as committed.
|
|
222
|
+
const customDraft = item.kind === "other" ? this.inputBuffer : undefined;
|
|
223
|
+
const customDraftDiffersFromConfirmed =
|
|
224
|
+
item.kind === "other" &&
|
|
225
|
+
customDraft !== "" &&
|
|
226
|
+
index === this.confirmedIndex &&
|
|
227
|
+
customDraft !== (this.confirmedLabelOverride ?? "");
|
|
228
|
+
const isConfirmed = index === this.confirmedIndex && !customDraftDiffersFromConfirmed;
|
|
229
|
+
const baseLabel = customDraft ? customDraft : item.label;
|
|
226
230
|
const label = isConfirmed
|
|
227
|
-
? `${this.confirmedLabelOverride ??
|
|
228
|
-
:
|
|
231
|
+
? `${this.confirmedLabelOverride ?? baseLabel}${WrappingSelect.CONFIRMED_MARK}`
|
|
232
|
+
: baseLabel;
|
|
229
233
|
const applySelectedStyle = isActive || isConfirmed;
|
|
230
234
|
|
|
231
235
|
return [
|
|
@@ -245,13 +249,7 @@ export class WrappingSelect implements Component {
|
|
|
245
249
|
return item.kind === "other" && isActive;
|
|
246
250
|
}
|
|
247
251
|
|
|
248
|
-
/**
|
|
249
|
-
* Render the inline input row across one or more lines, wrapping at `contentWidth`.
|
|
250
|
-
* Delegates to the shared `renderInlineInputRow` helper (`./inline-input.ts`) so the
|
|
251
|
-
* single-select wrap path and the multi-select single-line path share one cursor-
|
|
252
|
-
* building core. The `multiline: true` path is byte-identical to the pre-extraction
|
|
253
|
-
* output (cursor rationale lives in `inline-input.ts`).
|
|
254
|
-
*/
|
|
252
|
+
/** Render the inline editor across logical and visually wrapped lines. */
|
|
255
253
|
private renderInlineInputRow(rowPrefix: string, continuationPrefix: string, contentWidth: number): string[] {
|
|
256
254
|
return renderInlineInputRow({
|
|
257
255
|
buffer: this.inputBuffer,
|
|
@@ -260,7 +258,6 @@ export class WrappingSelect implements Component {
|
|
|
260
258
|
continuationPrefix,
|
|
261
259
|
contentWidth,
|
|
262
260
|
selectedText: this.theme.selectedText,
|
|
263
|
-
multiline: true,
|
|
264
261
|
});
|
|
265
262
|
}
|
|
266
263
|
|
package/view/dialog-builder.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DynamicBorder, type Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { type Component, Container, type
|
|
2
|
+
import { type Component, Container, type Editor, Spacer } from "@earendil-works/pi-tui";
|
|
3
3
|
import type { QuestionnaireState } from "../state/state.js";
|
|
4
4
|
import type { QuestionData } from "../tool/types.js";
|
|
5
5
|
import type { PreviewPaneProps } from "./components/preview/preview-pane.js";
|
|
@@ -10,6 +10,8 @@ import { QuestionTabStrategy, SubmitTabStrategy, type TabContentStrategy } from
|
|
|
10
10
|
|
|
11
11
|
export const HINT_PART_ENTER = "Enter to select";
|
|
12
12
|
export const HINT_PART_NAV = "↑/↓ to navigate";
|
|
13
|
+
export const HINT_PART_NEW_LINE = "Shift+Enter for newline";
|
|
14
|
+
export const HINT_PART_CLEAR = "Ctrl+U to clear";
|
|
13
15
|
export const HINT_PART_TOGGLE = "Space to toggle";
|
|
14
16
|
export const HINT_PART_NOTES = "n to add notes";
|
|
15
17
|
export const HINT_PART_TAB = "Tab to switch questions";
|
|
@@ -17,15 +19,20 @@ export const HINT_PART_CANCEL = "Esc to cancel";
|
|
|
17
19
|
export const HINT_PART_COLLAPSE = "Ctrl+] to collapse";
|
|
18
20
|
export const HINT_PART_EXPAND = "Ctrl+] to expand";
|
|
19
21
|
/**
|
|
20
|
-
* `HINT_SINGLE` / `HINT_MULTI`
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* `HINT_SINGLE` / `HINT_MULTI` are the resting core hint for NON-multiSelect
|
|
23
|
+
* question tabs only: `buildHintText` drops `NOTES` while the notes editor is
|
|
24
|
+
* open (`state.notesVisible`) or the "Type something." row is capturing text
|
|
25
|
+
* (`state.inputMode`), and on multiSelect tabs it interleaves `TOGGLE` between
|
|
26
|
+
* `NAV` and `NOTES`, so neither composite is a substring there — assert on
|
|
27
|
+
* `HINT_PART_*` constants in those states instead. The collapse affordance is
|
|
28
|
+
* appended AFTER cancel by `buildHintText` so the resting core stays a contiguous
|
|
29
|
+
* prefix substring of the rendered line. On narrow terminals the collapse tail
|
|
30
|
+
* clips with `…` (`OneLineClippedText`); the core is preserved.
|
|
24
31
|
*/
|
|
25
|
-
export const HINT_SINGLE = [HINT_PART_ENTER, HINT_PART_NAV, HINT_PART_CANCEL].join(" · ");
|
|
26
|
-
export const HINT_MULTI = [HINT_PART_ENTER, HINT_PART_NAV, HINT_PART_TAB, HINT_PART_CANCEL].join(
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
export const HINT_SINGLE = [HINT_PART_ENTER, HINT_PART_NAV, HINT_PART_NOTES, HINT_PART_CANCEL].join(" · ");
|
|
33
|
+
export const HINT_MULTI = [HINT_PART_ENTER, HINT_PART_NAV, HINT_PART_NOTES, HINT_PART_TAB, HINT_PART_CANCEL].join(
|
|
34
|
+
" · ",
|
|
35
|
+
);
|
|
29
36
|
/** Single-line footer shown by `QuestionnaireSession` when `state.collapsed === true`. Bypasses `buildHintText`. */
|
|
30
37
|
export const COLLAPSED_HINT = [HINT_PART_EXPAND, HINT_PART_CANCEL].join(" · ");
|
|
31
38
|
export const REVIEW_HEADING = "Review your answers";
|
|
@@ -49,7 +56,7 @@ export interface DialogConfig {
|
|
|
49
56
|
theme: Theme;
|
|
50
57
|
questions: readonly QuestionData[];
|
|
51
58
|
tabBar: TabBar | undefined;
|
|
52
|
-
notesInput:
|
|
59
|
+
notesInput: Editor;
|
|
53
60
|
isMulti: boolean;
|
|
54
61
|
tabsByIndex: ReadonlyArray<TabComponents>;
|
|
55
62
|
/** Optional so single-question mode and non-submit tests can omit it; SubmitTabStrategy falls back to Spacer rows. */
|
package/view/props-adapter.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Editor } from "@earendil-works/pi-tui";
|
|
2
2
|
import type { BindingContext, PerTabBindingContext } from "../state/selectors/contract.js";
|
|
3
3
|
import { selectActivePreviewPaneIndex } from "../state/selectors/derivations.js";
|
|
4
4
|
import { selectActiveView } from "../state/selectors/focus.js";
|
|
@@ -13,18 +13,12 @@ interface Invalidatable {
|
|
|
13
13
|
invalidate(): void;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const raw = (input as unknown as { cursor?: unknown }).cursor;
|
|
23
|
-
if (typeof raw !== "number") return undefined;
|
|
24
|
-
if (!Number.isSafeInteger(raw)) return undefined;
|
|
25
|
-
const value = input.getValue();
|
|
26
|
-
if (raw < 0 || raw > value.length) return undefined;
|
|
27
|
-
return raw;
|
|
16
|
+
function getInputCursorOffset(input: Editor): number {
|
|
17
|
+
const lines = input.getLines();
|
|
18
|
+
const cursor = input.getCursor();
|
|
19
|
+
let offset = cursor.col;
|
|
20
|
+
for (let i = 0; i < cursor.line; i++) offset += (lines[i]?.length ?? 0) + 1;
|
|
21
|
+
return offset;
|
|
28
22
|
}
|
|
29
23
|
|
|
30
24
|
export interface QuestionnairePropsAdapterConfig {
|
|
@@ -32,12 +26,12 @@ export interface QuestionnairePropsAdapterConfig {
|
|
|
32
26
|
questions: readonly QuestionData[];
|
|
33
27
|
itemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>;
|
|
34
28
|
tabsByIndex: ReadonlyArray<TabComponents>;
|
|
35
|
-
inlineInput:
|
|
29
|
+
inlineInput: Editor;
|
|
36
30
|
globalBindings: ReadonlyArray<BoundGlobalBinding>;
|
|
37
31
|
perTabBindings: ReadonlyArray<BoundPerTabBinding>;
|
|
38
32
|
/**
|
|
39
33
|
* Renderables not reached by the binding registries (e.g. the notes
|
|
40
|
-
* `
|
|
34
|
+
* `Editor`, which is typed into directly and has no props). Walked by
|
|
41
35
|
* `invalidate()` after the binding-driven components.
|
|
42
36
|
*/
|
|
43
37
|
extraInvalidatables?: ReadonlyArray<Invalidatable>;
|
|
@@ -57,7 +51,7 @@ export class QuestionnairePropsAdapter {
|
|
|
57
51
|
private readonly questions: readonly QuestionData[];
|
|
58
52
|
private readonly itemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>;
|
|
59
53
|
private readonly tabsByIndex: ReadonlyArray<TabComponents>;
|
|
60
|
-
private readonly inlineInput:
|
|
54
|
+
private readonly inlineInput: Editor;
|
|
61
55
|
private readonly globalBindings: ReadonlyArray<BoundGlobalBinding>;
|
|
62
56
|
private readonly perTabBindings: ReadonlyArray<BoundPerTabBinding>;
|
|
63
57
|
private readonly extraInvalidatables: ReadonlyArray<Invalidatable>;
|
|
@@ -84,7 +78,7 @@ export class QuestionnairePropsAdapter {
|
|
|
84
78
|
itemsByTab: this.itemsByTab,
|
|
85
79
|
totalQuestions,
|
|
86
80
|
activeView,
|
|
87
|
-
inputBuffer: this.inlineInput.
|
|
81
|
+
inputBuffer: this.inlineInput.getText(),
|
|
88
82
|
inputCursorOffset: getInputCursorOffset(this.inlineInput),
|
|
89
83
|
activePreviewPane,
|
|
90
84
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { type Component, Container, type
|
|
2
|
+
import { type Component, Container, type Editor, Spacer, Text, truncateToWidth } from "@earendil-works/pi-tui";
|
|
3
3
|
import { t } from "../state/i18n-bridge.js";
|
|
4
4
|
import { formatAnswerScalar } from "../tool/format-answer.js";
|
|
5
5
|
import type { QuestionData } from "../tool/types.js";
|
|
@@ -7,9 +7,11 @@ import type { PreviewPane, PreviewPaneProps } from "./components/preview/preview
|
|
|
7
7
|
import {
|
|
8
8
|
type DialogState,
|
|
9
9
|
HINT_PART_CANCEL,
|
|
10
|
+
HINT_PART_CLEAR,
|
|
10
11
|
HINT_PART_COLLAPSE,
|
|
11
12
|
HINT_PART_ENTER,
|
|
12
13
|
HINT_PART_NAV,
|
|
14
|
+
HINT_PART_NEW_LINE,
|
|
13
15
|
HINT_PART_NOTES,
|
|
14
16
|
HINT_PART_TAB,
|
|
15
17
|
HINT_PART_TOGGLE,
|
|
@@ -81,7 +83,7 @@ export interface QuestionTabStrategyConfig {
|
|
|
81
83
|
questions: readonly QuestionData[];
|
|
82
84
|
getPreviewPane: () => StatefulView<PreviewPaneProps>;
|
|
83
85
|
tabsByIndex: ReadonlyArray<TabComponents>;
|
|
84
|
-
notesInput:
|
|
86
|
+
notesInput: Editor;
|
|
85
87
|
isMulti: boolean;
|
|
86
88
|
getCurrentBodyHeight: (width: number) => number;
|
|
87
89
|
}
|
|
@@ -227,21 +229,21 @@ export class SubmitTabStrategy implements TabContentStrategy {
|
|
|
227
229
|
/**
|
|
228
230
|
* Build the controls hint line. Order:
|
|
229
231
|
* Enter · ↑/↓ [· Space toggle] [· n notes] [· Tab switch] · Esc · Ctrl+] collapse
|
|
232
|
+
* [· Shift+Enter newline] [· Ctrl+U clear]
|
|
230
233
|
*
|
|
231
|
-
* `
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* and desync the height math in `DialogView.render`).
|
|
234
|
+
* `NOTES` is part of the resting (notes-closed) core — it drops while the notes
|
|
235
|
+
* editor or custom-answer input has the keyboard. Ctrl+G is Pi's global external-
|
|
236
|
+
* editor shortcut and needs no local hint; the context-specific clear shortcut is
|
|
237
|
+
* appended at the far right while input mode is active.
|
|
236
238
|
*/
|
|
237
239
|
export function buildHintText(question: QuestionData | undefined, isMulti: boolean, state: DialogState): string {
|
|
238
240
|
const parts: string[] = [t("hint.enter", HINT_PART_ENTER), t("hint.navigate", HINT_PART_NAV)];
|
|
239
241
|
if (question?.multiSelect === true) parts.push(t("hint.toggle", HINT_PART_TOGGLE));
|
|
240
|
-
if (question &&
|
|
241
|
-
parts.push(t("hint.notes", HINT_PART_NOTES));
|
|
242
|
-
}
|
|
242
|
+
if (question && !state.notesVisible && !state.inputMode) parts.push(t("hint.notes", HINT_PART_NOTES));
|
|
243
243
|
if (isMulti) parts.push(t("hint.tab", HINT_PART_TAB));
|
|
244
244
|
parts.push(t("hint.cancel", HINT_PART_CANCEL));
|
|
245
245
|
parts.push(t("hint.collapse", HINT_PART_COLLAPSE));
|
|
246
|
+
if (state.notesVisible || state.inputMode) parts.push(t("hint.newline", HINT_PART_NEW_LINE));
|
|
247
|
+
if (state.inputMode) parts.push(t("hint.clear", HINT_PART_CLEAR));
|
|
246
248
|
return parts.join(" · ");
|
|
247
249
|
}
|