vc-extras 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -71
- package/agent-install.mjs +159 -0
- package/agents/tester.md +23 -23
- package/install-extras.mjs +41 -109
- package/install-menu.mjs +22 -43
- package/install-skills.mjs +112 -112
- package/package.json +72 -28
- package/plugin-registry.mjs +73 -0
- package/plugins/config-ui/index.ts +159 -159
- package/plugins/config-ui/lib/arguments.mjs +24 -24
- package/plugins/config-ui/lib/documents.mjs +67 -67
- package/plugins/config-ui/lib/frontmatter.mjs +91 -91
- package/plugins/config-ui/lib/open.mjs +16 -16
- package/plugins/config-ui/lib/ownership.mjs +99 -99
- package/plugins/config-ui/lib/page.mjs +11 -11
- package/plugins/config-ui/lib/patch.mjs +35 -35
- package/plugins/config-ui/lib/paths.mjs +14 -14
- package/plugins/config-ui/lib/plugin-fields.mjs +86 -86
- package/plugins/config-ui/lib/plugin-validation.mjs +28 -28
- package/plugins/config-ui/lib/redaction.mjs +8 -8
- package/plugins/config-ui/lib/registry.mjs +282 -282
- package/plugins/config-ui/lib/secrets.mjs +44 -44
- package/plugins/config-ui/lib/server.mjs +250 -250
- package/plugins/config-ui/lib/sources.mjs +96 -96
- package/plugins/config-ui/lib/state.mjs +156 -156
- package/plugins/config-ui/lib/themes.mjs +113 -113
- package/plugins/config-ui/lib/writer.mjs +690 -690
- package/plugins/config-ui/project-local-owner.ts +106 -106
- package/plugins/config-ui/vc-extras.plugin.json +13 -0
- package/plugins/config-ui/web/app.mjs +997 -997
- package/plugins/config-ui/web/index.html +342 -342
- package/plugins/pi-blackhole/vc-extras.plugin.json +12 -0
- package/plugins/pi-btw/vc-extras.plugin.json +12 -0
- package/plugins/pi-claude-code/vc-extras.plugin.json +12 -0
- package/plugins/pi-fff/vc-extras.plugin.json +12 -0
- package/plugins/pi-jev-auto-mode/vc-extras.plugin.json +12 -0
- package/plugins/pi-mcp-adapter/vc-extras.plugin.json +12 -0
- package/plugins/pi-web-access/vc-extras.plugin.json +12 -0
- package/plugins/vc-ask/claude-hook.mjs +37 -0
- package/plugins/vc-ask/codex-native.mjs +28 -0
- package/plugins/vc-ask/host-channel.mjs +75 -0
- package/plugins/vc-ask/index.ts +57 -0
- package/plugins/vc-ask/native-questions.mjs +33 -0
- package/plugins/vc-ask/package.json +10 -0
- package/plugins/vc-ask/payload.ts +170 -0
- package/plugins/vc-ask/questionnaire/LICENSE.ask-user-question +21 -0
- package/plugins/vc-ask/questionnaire/UPSTREAM.md +104 -0
- package/plugins/vc-ask/questionnaire/answer-channel.ts +135 -0
- package/plugins/vc-ask/questionnaire/config.ts +180 -0
- package/plugins/vc-ask/questionnaire/events.ts +154 -0
- package/plugins/vc-ask/questionnaire/execute.ts +688 -0
- package/plugins/vc-ask/questionnaire/i18n.ts +73 -0
- package/plugins/vc-ask/questionnaire/inline-entry.ts +312 -0
- package/plugins/vc-ask/questionnaire/locales/de.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/en.json +42 -0
- package/plugins/vc-ask/questionnaire/locales/es.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/fr.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/pt-BR.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/pt.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/ru.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/uk.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/zh.json +46 -0
- package/plugins/vc-ask/questionnaire/presentation.ts +11 -0
- package/plugins/vc-ask/questionnaire/question-preview.ts +6 -0
- package/plugins/vc-ask/questionnaire/rpc.ts +221 -0
- package/plugins/vc-ask/questionnaire/session-timeout.ts +67 -0
- package/plugins/vc-ask/questionnaire/state/build-questionnaire.ts +144 -0
- package/plugins/vc-ask/questionnaire/state/external-editor.ts +62 -0
- package/plugins/vc-ask/questionnaire/state/geometry.ts +131 -0
- package/plugins/vc-ask/questionnaire/state/key-router.ts +382 -0
- package/plugins/vc-ask/questionnaire/state/panel-router.ts +32 -0
- package/plugins/vc-ask/questionnaire/state/questionnaire-session.ts +642 -0
- package/plugins/vc-ask/questionnaire/state/row-intent.ts +143 -0
- package/plugins/vc-ask/questionnaire/state/selectors/contract.ts +24 -0
- package/plugins/vc-ask/questionnaire/state/selectors/derivations.ts +40 -0
- package/plugins/vc-ask/questionnaire/state/selectors/focus.ts +17 -0
- package/plugins/vc-ask/questionnaire/state/selectors/projections.ts +99 -0
- package/plugins/vc-ask/questionnaire/state/state-reducer.ts +455 -0
- package/plugins/vc-ask/questionnaire/state/state.ts +90 -0
- package/plugins/vc-ask/questionnaire/state/vertical.ts +158 -0
- package/plugins/vc-ask/questionnaire/timeout.ts +59 -0
- package/plugins/vc-ask/questionnaire/tool/external-answer.ts +103 -0
- package/plugins/vc-ask/questionnaire/tool/format-answer.ts +24 -0
- package/plugins/vc-ask/questionnaire/tool/normalize-params.ts +37 -0
- package/plugins/vc-ask/questionnaire/tool/response-envelope.ts +75 -0
- package/plugins/vc-ask/questionnaire/tool/types.ts +74 -0
- package/plugins/vc-ask/questionnaire/tool/validate-questionnaire.ts +75 -0
- package/plugins/vc-ask/questionnaire/view/card-theme.ts +245 -0
- package/plugins/vc-ask/questionnaire/view/components/inline-input.ts +66 -0
- package/plugins/vc-ask/questionnaire/view/components/multi-select-view.ts +177 -0
- package/plugins/vc-ask/questionnaire/view/components/option-list-view.ts +65 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/markdown-content-cache.ts +101 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/preview-block-renderer.ts +130 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/preview-box-renderer.ts +86 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/preview-layout-decider.ts +204 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/preview-pane.ts +257 -0
- package/plugins/vc-ask/questionnaire/view/components/submit-picker.ts +65 -0
- package/plugins/vc-ask/questionnaire/view/components/tab-bar.ts +57 -0
- package/plugins/vc-ask/questionnaire/view/components/wrapping-select.ts +269 -0
- package/plugins/vc-ask/questionnaire/view/dialog-builder.ts +319 -0
- package/plugins/vc-ask/questionnaire/view/document-theme.ts +53 -0
- package/plugins/vc-ask/questionnaire/view/document-view.ts +306 -0
- package/plugins/vc-ask/questionnaire/view/panel-chrome.ts +133 -0
- package/plugins/vc-ask/questionnaire/view/props-adapter.ts +77 -0
- package/plugins/vc-ask/questionnaire/view/stateful-view.ts +24 -0
- package/plugins/vc-ask/questionnaire/view/tab-components.ts +16 -0
- package/plugins/vc-ask/questionnaire/view/tab-content-strategy.ts +280 -0
- package/plugins/vc-ask/questionnaire/view/vertical-view.ts +218 -0
- package/plugins/vc-ask/user-input-events.ts +34 -0
- package/plugins/vc-ask/vc-extras.plugin.json +18 -0
- package/plugins/vc-footer/agents/claude-code/adapter.mjs +29 -0
- package/plugins/vc-footer/agents/claude-code/cli.mjs +23 -0
- package/plugins/vc-footer/agents/claude-code/renderer.mjs +1 -0
- package/plugins/vc-footer/agents/claude-code/types.d.ts +38 -0
- package/plugins/vc-footer/agents/codex/adapter.mjs +13 -0
- package/plugins/vc-footer/agents/codex/mcp.mjs +45 -0
- package/plugins/vc-footer/agents/codex/native.mjs +19 -0
- package/plugins/vc-footer/agents/codex/renderer.mjs +2 -0
- package/plugins/vc-footer/agents/pi/adapter.mjs +23 -0
- package/plugins/vc-footer/agents/pi/index.js +84 -0
- package/plugins/vc-footer/agents/pi/project-local-owner.mjs +97 -0
- package/plugins/vc-footer/agents/pi/renderer.mjs +5 -0
- package/plugins/vc-footer/core/data.mjs +218 -0
- package/plugins/vc-footer/core/render.mjs +291 -0
- package/plugins/vc-footer/core/types.d.ts +29 -0
- package/plugins/vc-footer/package.json +22 -0
- package/plugins/vc-footer/vc-extras.plugin.json +32 -0
- package/skills/animate/LICENSE +21 -21
- package/skills/animate/RECIPES.md +324 -324
- package/skills/animate/SKILL.md +208 -208
- package/skills/animate/UPSTREAM.md +19 -19
- package/skills/animation-performance/LICENSE +21 -21
- package/skills/animation-performance/SKILL.md +223 -223
- package/skills/animation-performance/UPSTREAM.md +19 -19
- package/skills/answer-me-with-html/SKILL.md +174 -174
- package/skills/answer-me-with-html/scripts/am.mjs +12896 -12896
- package/skills/apple-design/LICENSE +21 -21
- package/skills/apple-design/SKILL.md +291 -291
- package/skills/apple-design/UPSTREAM.md +19 -19
- package/skills/bad-smell/SKILL.md +44 -44
- package/skills/commit/SKILL.md +90 -90
- package/skills/emil-design-eng/LICENSE +21 -21
- package/skills/emil-design-eng/SKILL.md +677 -677
- package/skills/emil-design-eng/UPSTREAM.md +19 -19
- package/skills/find-the-truth/SKILL.md +38 -38
- package/skills/find-the-truth/references/trace-method.md +48 -48
- package/skills/find-the-truth/references/truth-method.md +39 -39
- package/skills/gestures/LICENSE +21 -21
- package/skills/gestures/SKILL.md +107 -107
- package/skills/gestures/UPSTREAM.md +19 -19
- package/skills/humanizer-zh/LICENSE +21 -21
- package/skills/humanizer-zh/SKILL.md +409 -409
- package/skills/humanizer-zh/UPSTREAM.md +7 -7
- package/skills/impeccable/LICENSE +191 -191
- package/skills/impeccable/NOTICE.md +11 -11
- package/skills/impeccable/SKILL.md +89 -89
- package/skills/impeccable/licenses/modern-screenshot-MIT.txt +8 -8
- package/skills/impeccable/licenses/platform-design-skills-MIT.txt +21 -21
- package/skills/impeccable/reference/adapt.md +318 -318
- package/skills/impeccable/reference/adapt.native.md +58 -58
- package/skills/impeccable/reference/android.md +46 -46
- package/skills/impeccable/reference/animate.md +89 -89
- package/skills/impeccable/reference/audit.md +139 -139
- package/skills/impeccable/reference/audit.native.md +139 -139
- package/skills/impeccable/reference/bolder.md +33 -33
- package/skills/impeccable/reference/clarify.md +94 -94
- package/skills/impeccable/reference/colorize.md +86 -86
- package/skills/impeccable/reference/component-review.md +63 -63
- package/skills/impeccable/reference/craft-floor.md +44 -44
- package/skills/impeccable/reference/craft.md +5 -5
- package/skills/impeccable/reference/critique.md +819 -819
- package/skills/impeccable/reference/degraded/asset-producer.md +41 -41
- package/skills/impeccable/reference/degraded/documenter.md +23 -23
- package/skills/impeccable/reference/degraded/finish-reviewer.md +37 -37
- package/skills/impeccable/reference/degraded/manual-edit-applier.md +92 -92
- package/skills/impeccable/reference/delight.md +70 -70
- package/skills/impeccable/reference/distill.md +111 -111
- package/skills/impeccable/reference/doctor.md +54 -54
- package/skills/impeccable/reference/document.md +416 -416
- package/skills/impeccable/reference/extract.md +69 -69
- package/skills/impeccable/reference/generate.md +101 -101
- package/skills/impeccable/reference/harden.md +362 -362
- package/skills/impeccable/reference/hooks.md +114 -114
- package/skills/impeccable/reference/init.md +131 -131
- package/skills/impeccable/reference/ios.md +51 -51
- package/skills/impeccable/reference/layout.md +84 -84
- package/skills/impeccable/reference/live-setup.md +104 -104
- package/skills/impeccable/reference/live.md +327 -327
- package/skills/impeccable/reference/mode-operate.md +21 -21
- package/skills/impeccable/reference/mode-persuade.md +19 -19
- package/skills/impeccable/reference/mode-read.md +21 -21
- package/skills/impeccable/reference/new-work.md +152 -152
- package/skills/impeccable/reference/onboard.md +234 -234
- package/skills/impeccable/reference/operate.md +61 -61
- package/skills/impeccable/reference/optimize.md +257 -257
- package/skills/impeccable/reference/overdrive.md +127 -127
- package/skills/impeccable/reference/polish.md +105 -105
- package/skills/impeccable/reference/quieter.md +99 -99
- package/skills/impeccable/reference/region-map.md +26 -26
- package/skills/impeccable/reference/routing.md +24 -24
- package/skills/impeccable/reference/shape.md +59 -59
- package/skills/impeccable/reference/typeset.md +90 -90
- package/skills/impeccable/reference/visualize.md +47 -47
- package/skills/impeccable/scripts/VERSION +1 -1
- package/skills/impeccable/scripts/command-metadata.json +98 -98
- package/skills/impeccable/scripts/data/font-index-failures.json +120 -120
- package/skills/impeccable/scripts/engine-checksums.txt +9 -9
- package/skills/impeccable/scripts/impeccable +249 -249
- package/skills/impeccable/scripts/impeccable.cmd +278 -278
- package/skills/impeccable/scripts/live-browser-dom.js +320 -320
- package/skills/impeccable/scripts/live-browser-ignores.js +246 -246
- package/skills/impeccable/scripts/live-browser-session.js +183 -183
- package/skills/impeccable/scripts/live-browser.js +13862 -13862
- package/skills/impeccable/scripts/modern-screenshot.umd.js +14 -14
- package/skills/improve-animations/AUDIT.md +115 -115
- package/skills/improve-animations/LICENSE +21 -21
- package/skills/improve-animations/PLAN-TEMPLATE.md +73 -73
- package/skills/improve-animations/SKILL.md +110 -110
- package/skills/improve-animations/UPSTREAM.md +19 -19
- package/skills/pick-ui-library/LICENSE +21 -21
- package/skills/pick-ui-library/SKILL.md +85 -85
- package/skills/pick-ui-library/UPSTREAM.md +19 -19
- package/skills/review-animations/LICENSE +21 -21
- package/skills/review-animations/SKILL.md +120 -120
- package/skills/review-animations/STANDARDS.md +187 -187
- package/skills/review-animations/UPSTREAM.md +19 -19
- package/skills/test/SKILL.md +29 -29
- package/skills/test/references/test-method.md +60 -60
- package/skills/write-doc/SKILL.md +115 -115
- package/skills/write-doc/examples/result-report.md +53 -53
- package/skills/write-doc/examples/task-summary.md +45 -45
- package/skills/write-doc/references/terminology.md +147 -147
- package/specs/ask-host-protocol-v1.md +58 -0
- package/specs/design-demo.md +1102 -1102
- package/specs/frontend-immersive.md +28 -28
- package/specs/plugin-install-v2.md +123 -0
- package/specs/plugin-install.md +38 -0
- package/specs/web-modes/explore.md +31 -31
- package/specs/web-modes/risk.md +15 -15
- package/specs/web-modes/verify.md +16 -16
- package/vc-extras.mjs +46 -62
- package/plugins/essrj/context.ts +0 -47
- package/plugins/essrj/data.ts +0 -190
- package/plugins/essrj/index.ts +0 -139
- package/plugins/essrj/package.json +0 -12
- package/plugins/essrj/project-local-owner.ts +0 -106
- package/plugins/essrj/render.ts +0 -217
- package/plugins/essrj/types.ts +0 -40
- package/plugins.json +0 -38
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { parseColor, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
2
|
+
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { PANEL_PADDING_X } from "../state/geometry.js";
|
|
4
|
+
|
|
5
|
+
const DEMO_TEXT = {
|
|
6
|
+
light: { text: parseColor("#292831"), muted: parseColor("#686571"), dim: parseColor("#686571") },
|
|
7
|
+
dark: { text: parseColor("#e8e8ec"), muted: parseColor("#92939f"), dim: parseColor("#92939f") },
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const ASK_PALETTES = ["blue", "purple", "orange"] as const;
|
|
11
|
+
export type AskPalette = typeof ASK_PALETTES[number];
|
|
12
|
+
export function randomAskPalette(): AskPalette { return ASK_PALETTES[Math.floor(Math.random() * ASK_PALETTES.length)]!; }
|
|
13
|
+
const PALETTES = {
|
|
14
|
+
blue: { light: { accent: "#37648c", border: "#819eb9", selected: "#e5eef6" }, dark: { accent: "#a8c9ed", border: "#617c98", selected: "#293541" } },
|
|
15
|
+
purple: { light: { accent: "#7050a6", border: "#9c8bb9", selected: "#eee8f6" }, dark: { accent: "#c4b5ed", border: "#766b8e", selected: "#332e40" } },
|
|
16
|
+
orange: { light: { accent: "#94512e", border: "#b48d72", selected: "#f7eae1" }, dark: { accent: "#edba9c", border: "#96765f", selected: "#3d302a" } },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Docked panels sit in the input area; floating panels are movable cards. */
|
|
20
|
+
export type PanelForm = "dock" | "float";
|
|
21
|
+
|
|
22
|
+
export interface PanelRow {
|
|
23
|
+
/** One-cell marker drawn in the left gutter; empty for plain rows. */
|
|
24
|
+
marker?: string;
|
|
25
|
+
text?: string;
|
|
26
|
+
/** Dimmed continuation of `text`, truncated with it. */
|
|
27
|
+
tail?: string;
|
|
28
|
+
selected?: boolean;
|
|
29
|
+
/** Smaller/lighter right-aligned hint sharing this row, longest variant first. */
|
|
30
|
+
hint?: string | readonly string[];
|
|
31
|
+
colored?: boolean;
|
|
32
|
+
/** Scrollbar cell drawn just inside the right border. */
|
|
33
|
+
track?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Panel chrome: border, title, rows and dividers for one form. Colours resolve on
|
|
38
|
+
* every call so a mid-session theme switch repaints without rebuilding the view, and
|
|
39
|
+
* floating document panels use a card background. Vertical forms can preserve the
|
|
40
|
+
* host terminal background independently of their floating geometry.
|
|
41
|
+
*/
|
|
42
|
+
export class PanelChrome {
|
|
43
|
+
constructor(private readonly theme: Theme, private readonly form: PanelForm, private readonly preserveHostBackground = false, private readonly palette: AskPalette = "purple") {}
|
|
44
|
+
|
|
45
|
+
/** Legacy token fallback for themes without literal-color styling. */
|
|
46
|
+
get colorToken(): "borderAccent" | "warning" {
|
|
47
|
+
return this.form === "dock" ? "borderAccent" : "warning";
|
|
48
|
+
}
|
|
49
|
+
private paint(text: string, border = false): string {
|
|
50
|
+
// style() treats strings as theme tokens; literal colors must be Color objects.
|
|
51
|
+
const palette = PALETTES[this.palette][this.theme.appearance === "light" ? "light" : "dark"];
|
|
52
|
+
const color = parseColor(border ? palette.border : palette.accent);
|
|
53
|
+
return this.theme.style ? this.theme.style(text, { fg: color }) : this.theme.fg(this.colorToken, text);
|
|
54
|
+
}
|
|
55
|
+
border(text: string): string { return this.paint(text, true); }
|
|
56
|
+
title(text: string): string { return this.paint(text); }
|
|
57
|
+
text(text: string): string { return this.formText(text); }
|
|
58
|
+
muted(text: string): string { return this.formText(text, "muted"); }
|
|
59
|
+
dim(text: string): string { return this.formText(text, "dim"); }
|
|
60
|
+
selected(text: string): string {
|
|
61
|
+
const bg = parseColor(PALETTES[this.palette][this.theme.appearance === "light" ? "light" : "dark"].selected);
|
|
62
|
+
return this.theme.style ? this.theme.style(this.text(text), { bg }) : this.theme.bg("selectedBg", this.text(text));
|
|
63
|
+
}
|
|
64
|
+
accent(text: string): string { return this.paint(text); }
|
|
65
|
+
/** Approved HTML demo foregrounds, resolved at paint time after theme changes. */
|
|
66
|
+
formText(text: string, role: "text" | "muted" | "dim" = "text"): string {
|
|
67
|
+
const color = DEMO_TEXT[this.theme.appearance === "light" ? "light" : "dark"][role];
|
|
68
|
+
return this.theme.style ? this.theme.style(text, { fg: color }) : this.theme.fg(role, text);
|
|
69
|
+
}
|
|
70
|
+
track(text: string): string { return this.theme.fg("scrollbarTrack", text); }
|
|
71
|
+
bold(text: string): string { return this.theme.bold(text); }
|
|
72
|
+
|
|
73
|
+
/** Exactly `width` cells, carrying the card background while floating. */
|
|
74
|
+
line(text: string, width: number): string {
|
|
75
|
+
const padded = truncateToWidth(text, width, "", true);
|
|
76
|
+
return this.form === "float" && !this.preserveHostBackground ? this.theme.bg("customMessageBg", padded) : padded;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** First hint variant that fits the leftover cells; never truncates mid-word. */
|
|
81
|
+
export function fitHint(hint: string | readonly string[] | undefined, available: number): string {
|
|
82
|
+
const variants = typeof hint === "string" ? [hint] : hint ?? [];
|
|
83
|
+
return variants.find(variant => visibleWidth(variant) <= available) ?? "";
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** `│ ... │` row of exactly `width` cells, with the scrollbar cell before the right border. */
|
|
87
|
+
export function panelRow(chrome: PanelChrome, width: number, row: PanelRow = {}): string {
|
|
88
|
+
const inner = Math.max(0, width - 2 - PANEL_PADDING_X * 2 - 1);
|
|
89
|
+
// Option rows carry the selection marker in the left gutter, so their text starts on
|
|
90
|
+
// the same column as body text while the marker never shifts the label.
|
|
91
|
+
const lead = row.marker !== undefined ? row.marker + " " : " ".repeat(PANEL_PADDING_X);
|
|
92
|
+
// The hint only uses leftover cells, and picks a shorter variant rather than
|
|
93
|
+
// cutting a word in half.
|
|
94
|
+
const head = truncateToWidth(row.text ?? "", inner, "", false);
|
|
95
|
+
const room = Math.max(0, inner - visibleWidth(head));
|
|
96
|
+
const tail = room > 2 && row.tail ? truncateToWidth(row.tail, room, "", false) : "";
|
|
97
|
+
const body = head + tail;
|
|
98
|
+
const hint = fitHint(row.hint, Math.max(0, inner - visibleWidth(body) - 1));
|
|
99
|
+
const fill = " ".repeat(Math.max(0, inner - visibleWidth(body) - (hint ? visibleWidth(hint) + 1 : 0)));
|
|
100
|
+
const painted = row.selected ? chrome.accent(body) : (row.colored ? chrome.text(body) : chrome.muted(body));
|
|
101
|
+
const track = row.track ? chrome.track(row.track) : " ";
|
|
102
|
+
return chrome.line(chrome.border("│") + lead + painted + chrome.text(fill) +
|
|
103
|
+
(hint ? " " + chrome.dim(hint) : "") + " ".repeat(PANEL_PADDING_X) + track + chrome.border("│"), width);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Blank row inside the panel, still carrying the card background while floating. */
|
|
107
|
+
export function panelBlank(chrome: PanelChrome, width: number): string {
|
|
108
|
+
return chrome.line(chrome.border("│") + " ".repeat(Math.max(0, width - 2)) + chrome.border("│"), width);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Top border with an embedded title and optional trailing label. */
|
|
112
|
+
export function panelTop(chrome: PanelChrome, width: number, title: string, button: string): string {
|
|
113
|
+
const trailing = button ? " " + button + " ─╮" : "╮";
|
|
114
|
+
const lead = "╭─ ";
|
|
115
|
+
const titleCells = Math.max(0, width - visibleWidth(lead + " " + trailing) - 1);
|
|
116
|
+
const shown = truncateToWidth(title, titleCells, "", false);
|
|
117
|
+
const fill = "─".repeat(Math.max(1, width - visibleWidth(lead + shown + " " + trailing)));
|
|
118
|
+
return chrome.line(chrome.border(lead) + chrome.title(shown) + chrome.border(" " + fill + trailing), width);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Plain bottom border. */
|
|
122
|
+
export function panelBottom(chrome: PanelChrome, width: number): string {
|
|
123
|
+
return chrome.line(chrome.border("╰" + "─".repeat(Math.max(0, width - 2)) + "╯"), width);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Thin theme-coloured divider, inset symmetrically so both sides stay equal. */
|
|
127
|
+
export function panelDivider(chrome: PanelChrome, width: number): string {
|
|
128
|
+
const inner = Math.max(0, width - 2);
|
|
129
|
+
const inset = Math.max(1, Math.floor((inner - Math.max(4, Math.round(inner * 0.94))) / 2));
|
|
130
|
+
const line = "─".repeat(Math.max(1, inner - inset * 2));
|
|
131
|
+
return chrome.line(
|
|
132
|
+
chrome.border("│") + " ".repeat(inset) + chrome.border(line) + " ".repeat(inset) + chrome.border("│"), width);
|
|
133
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Editor } from "@earendil-works/pi-tui";
|
|
2
|
+
import type { BindingContext, PerTabBindingContext } from "../state/selectors/contract.js";
|
|
3
|
+
import { selectActivePreviewPaneIndex } from "../state/selectors/derivations.js";
|
|
4
|
+
import { selectActiveView } from "../state/selectors/focus.js";
|
|
5
|
+
import {
|
|
6
|
+
selectDialogProps, selectMultiSelectProps, selectOptionListProps,
|
|
7
|
+
selectPreviewPaneProps, selectSubmitPickerProps, selectTabBarProps,
|
|
8
|
+
} from "../state/selectors/projections.js";
|
|
9
|
+
import type { QuestionnaireState } from "../state/state.js";
|
|
10
|
+
import type { QuestionData } from "../tool/types.js";
|
|
11
|
+
import type { SubmitPicker } from "./components/submit-picker.js";
|
|
12
|
+
import type { TabBar } from "./components/tab-bar.js";
|
|
13
|
+
import type { WrappingSelectItem } from "./components/wrapping-select.js";
|
|
14
|
+
import type { DialogView } from "./dialog-builder.js";
|
|
15
|
+
import type { TabComponents } from "./tab-components.js";
|
|
16
|
+
|
|
17
|
+
function getInputCursorOffset(input: Editor): number {
|
|
18
|
+
const lines = input.getLines();
|
|
19
|
+
const cursor = input.getCursor();
|
|
20
|
+
let offset = cursor.col;
|
|
21
|
+
for (let i = 0; i < cursor.line; i++) offset += (lines[i]?.length ?? 0) + 1;
|
|
22
|
+
return offset;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface QuestionnairePropsAdapterConfig {
|
|
26
|
+
tui: { requestRender(): void };
|
|
27
|
+
questions: readonly QuestionData[];
|
|
28
|
+
itemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>;
|
|
29
|
+
tabsByIndex: ReadonlyArray<TabComponents>;
|
|
30
|
+
inlineInput: Editor;
|
|
31
|
+
notesInput: Editor;
|
|
32
|
+
dialog: DialogView;
|
|
33
|
+
submitPicker?: SubmitPicker;
|
|
34
|
+
tabBar?: TabBar;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class QuestionnairePropsAdapter {
|
|
38
|
+
constructor(private readonly config: QuestionnairePropsAdapterConfig) {}
|
|
39
|
+
|
|
40
|
+
apply(state: QuestionnaireState): void {
|
|
41
|
+
const { questions, itemsByTab, tabsByIndex, inlineInput, dialog, submitPicker, tabBar, tui } = this.config;
|
|
42
|
+
const totalQuestions = questions.length;
|
|
43
|
+
const paneIndex = selectActivePreviewPaneIndex(state.currentTab, totalQuestions);
|
|
44
|
+
const ctx: BindingContext = {
|
|
45
|
+
questions, itemsByTab, totalQuestions,
|
|
46
|
+
activeView: selectActiveView(state, totalQuestions),
|
|
47
|
+
inputBuffer: inlineInput.getText(),
|
|
48
|
+
inputCursorOffset: getInputCursorOffset(inlineInput),
|
|
49
|
+
activePreviewPane: tabsByIndex[paneIndex]?.preview ?? tabsByIndex[0]!.preview,
|
|
50
|
+
};
|
|
51
|
+
dialog.setProps(selectDialogProps(state, ctx));
|
|
52
|
+
submitPicker?.setProps(selectSubmitPickerProps(state, ctx));
|
|
53
|
+
tabBar?.setProps(selectTabBarProps(state, ctx));
|
|
54
|
+
for (let i = 0; i < tabsByIndex.length; i++) {
|
|
55
|
+
const tab = tabsByIndex[i]!;
|
|
56
|
+
const tabCtx: PerTabBindingContext = { ...ctx, tab, i };
|
|
57
|
+
if (i === paneIndex) {
|
|
58
|
+
tab.optionList.setProps(selectOptionListProps(state, tabCtx));
|
|
59
|
+
tab.preview.setProps(selectPreviewPaneProps(state, tabCtx));
|
|
60
|
+
}
|
|
61
|
+
tab.multiSelect?.setProps(selectMultiSelectProps(state, tabCtx));
|
|
62
|
+
}
|
|
63
|
+
tui.requestRender();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
invalidate(): void {
|
|
67
|
+
const { dialog, submitPicker, tabBar, tabsByIndex, notesInput } = this.config;
|
|
68
|
+
dialog.invalidate();
|
|
69
|
+
submitPicker?.invalidate();
|
|
70
|
+
tabBar?.invalidate();
|
|
71
|
+
for (const tab of tabsByIndex) {
|
|
72
|
+
tab.preview.invalidate();
|
|
73
|
+
tab.multiSelect?.invalidate();
|
|
74
|
+
}
|
|
75
|
+
notesInput.invalidate();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Component } from "@earendil-works/pi-tui";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generic prop-driven component contract. Every renderable owns its own `P` shape;
|
|
5
|
+
* the adapter computes `P` from canonical state via per-component selectors and
|
|
6
|
+
* pushes it via `setProps`. `focused: boolean` is a field on `P` only where the
|
|
7
|
+
* component needs it.
|
|
8
|
+
*/
|
|
9
|
+
export interface StatefulView<P> extends Component {
|
|
10
|
+
setProps(props: P): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Discriminated focus union — encodes the three-cell focus invariant
|
|
15
|
+
* (`notesVisible`, submit-tab, options). Dispatcher cascade (`key-router.ts`)
|
|
16
|
+
* and reducer's defensive clears (`state-reducer.ts`) enforce mutual exclusion;
|
|
17
|
+
* this type makes it explicit so per-component `focused: boolean` flags
|
|
18
|
+
* derive from one equality check against this discriminant rather than
|
|
19
|
+
* parallel boolean reads.
|
|
20
|
+
*
|
|
21
|
+
* Priority order: notes > submit > options. Matches the dispatcher
|
|
22
|
+
* cascade exactly so the union is observably equivalent to today's reads.
|
|
23
|
+
*/
|
|
24
|
+
export type ActiveView = "notes" | "options" | "submit";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MultiSelectView } from "./components/multi-select-view.js";
|
|
2
|
+
import type { OptionListViewProps } from "./components/option-list-view.js";
|
|
3
|
+
import type { PreviewPane } from "./components/preview/preview-pane.js";
|
|
4
|
+
import type { StatefulView } from "./stateful-view.js";
|
|
5
|
+
|
|
6
|
+
export interface TabBodyHeights {
|
|
7
|
+
current: number;
|
|
8
|
+
max: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface TabComponents {
|
|
12
|
+
optionList: StatefulView<OptionListViewProps>;
|
|
13
|
+
preview: PreviewPane;
|
|
14
|
+
multiSelect?: MultiSelectView;
|
|
15
|
+
bodyHeights: (width: number) => TabBodyHeights;
|
|
16
|
+
}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { type Component, Container, type Editor, Spacer, Text, truncateToWidth } from "@earendil-works/pi-tui";
|
|
3
|
+
import { hasQuestionLevelPreview } from "../question-preview.js";
|
|
4
|
+
import { t } from "../i18n.js";
|
|
5
|
+
import { formatAnswerScalar } from "../tool/format-answer.js";
|
|
6
|
+
import type { QuestionData } from "../tool/types.js";
|
|
7
|
+
import type { PreviewPane, PreviewPaneProps } from "./components/preview/preview-pane.js";
|
|
8
|
+
import {
|
|
9
|
+
type DialogState,
|
|
10
|
+
HINT_PART_CANCEL,
|
|
11
|
+
HINT_PART_CLEAR,
|
|
12
|
+
HINT_PART_COLLAPSE,
|
|
13
|
+
HINT_PART_ENTER,
|
|
14
|
+
HINT_PART_NAV,
|
|
15
|
+
HINT_PART_NEW_LINE,
|
|
16
|
+
HINT_PART_NOTES,
|
|
17
|
+
HINT_PART_SCROLL,
|
|
18
|
+
HINT_PART_TAB,
|
|
19
|
+
HINT_PART_TOGGLE,
|
|
20
|
+
INCOMPLETE_WARNING_PREFIX,
|
|
21
|
+
READY_PROMPT,
|
|
22
|
+
REVIEW_HEADING,
|
|
23
|
+
} from "./dialog-builder.js";
|
|
24
|
+
import type { StatefulView } from "./stateful-view.js";
|
|
25
|
+
import type { TabComponents } from "./tab-components.js";
|
|
26
|
+
|
|
27
|
+
const NOTES_HEADER = "Notes:";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Single-row, width-clipped chrome cell. The footer row count is invariant
|
|
31
|
+
* (`QuestionTabStrategy.footerRowCount = 2`) — pi-tui's `Text` word-wraps when
|
|
32
|
+
* the styled hint exceeds `width`, inflating that row count and desyncing the
|
|
33
|
+
* `bodyHeight + footerRowCount` math in `DialogView.render`. Clipping with
|
|
34
|
+
* `truncateToWidth` (ANSI-aware, matches `multi-select-view.ts` usage) keeps
|
|
35
|
+
* the hint on one line; the collapse affordance falls off the right edge with
|
|
36
|
+
* `…` on terminals too narrow to advertise it.
|
|
37
|
+
*/
|
|
38
|
+
class OneLineClippedText implements Component {
|
|
39
|
+
constructor(
|
|
40
|
+
private readonly text: string,
|
|
41
|
+
private readonly paddingLeft: number = 0,
|
|
42
|
+
) {}
|
|
43
|
+
|
|
44
|
+
render(width: number): string[] {
|
|
45
|
+
const pad = " ".repeat(this.paddingLeft);
|
|
46
|
+
const avail = Math.max(0, width - this.paddingLeft);
|
|
47
|
+
return [pad + truncateToWidth(this.text, avail, "…", false)];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
invalidate(): void {}
|
|
51
|
+
|
|
52
|
+
handleInput(_data: string): void {}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Per-tab content provider. Pure functional — closes over construction-time
|
|
57
|
+
* config; per-tick state threads through method args. The chrome wrapper
|
|
58
|
+
* enforces height equality across tabs via `bodyHeight + footerRowCount`.
|
|
59
|
+
*/
|
|
60
|
+
export interface TabContentStrategy {
|
|
61
|
+
/** Total RENDERED footer rows — MUST equal what `footerRows()` actually emits. Drives residual math. */
|
|
62
|
+
readonly footerRowCount: number;
|
|
63
|
+
|
|
64
|
+
/** Variable rows above the body, after top chrome (border + tabBar + Spacer). */
|
|
65
|
+
headingRows(state: DialogState): Component[];
|
|
66
|
+
|
|
67
|
+
/** Body Component placed at the body slot. */
|
|
68
|
+
bodyComponent(state: DialogState): Component;
|
|
69
|
+
|
|
70
|
+
/** Natural rendered height of `bodyComponent(state)` at given width. */
|
|
71
|
+
bodyHeight(width: number, state: DialogState): number;
|
|
72
|
+
|
|
73
|
+
/** Optional rows between body's trailing Spacer and the bottom border. */
|
|
74
|
+
midRows(state: DialogState): Component[];
|
|
75
|
+
|
|
76
|
+
/** Footer rows below the bottom border. Rendered row count MUST equal `footerRowCount`. */
|
|
77
|
+
footerRows(state: DialogState, previewScrollable: boolean): Component[];
|
|
78
|
+
|
|
79
|
+
/** Row range of the focused item within the body's rendered output, or undefined if no interactive focus. */
|
|
80
|
+
focusedItemRowRange(width: number, state: DialogState): [number, number] | undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface QuestionTabStrategyConfig {
|
|
84
|
+
theme: Theme;
|
|
85
|
+
questions: readonly QuestionData[];
|
|
86
|
+
getPreviewPane: () => StatefulView<PreviewPaneProps>;
|
|
87
|
+
tabsByIndex: ReadonlyArray<TabComponents>;
|
|
88
|
+
notesInput: Editor;
|
|
89
|
+
isMulti: boolean;
|
|
90
|
+
getCurrentBodyHeight: (width: number) => number;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export class QuestionTabStrategy implements TabContentStrategy {
|
|
94
|
+
/** Spacer(1) + OneLineClippedText(hint, 1) = 2 rendered rows. */
|
|
95
|
+
readonly footerRowCount = 2;
|
|
96
|
+
|
|
97
|
+
constructor(private readonly config: QuestionTabStrategyConfig) {}
|
|
98
|
+
|
|
99
|
+
headingRows(state: DialogState): Component[] {
|
|
100
|
+
const out: Component[] = [];
|
|
101
|
+
const question = this.config.questions[state.currentTab];
|
|
102
|
+
// A border title replaces the heading rows only when the question-level preview
|
|
103
|
+
// carries the actual content (gate/plan dialogs). A plain `ask` has no preview, so
|
|
104
|
+
// the ≤16-char border title alone can never tell the user what is being asked —
|
|
105
|
+
// keep the question text visible in that case.
|
|
106
|
+
if (question?.title && hasQuestionLevelPreview(question)) return out;
|
|
107
|
+
// In multi-question mode the tab bar already shows the header; suppress the inline
|
|
108
|
+
// badge. For a single question the header moves into the box border title (see
|
|
109
|
+
// `dialog-builder.ts`), so it is not repeated as a row here either.
|
|
110
|
+
if (this.config.isMulti && question?.header && question.header.length > 0) {
|
|
111
|
+
out.push(new Text(this.config.theme.bg("selectedBg", ` ${question.header} `), 1, 0));
|
|
112
|
+
out.push(new Spacer(1));
|
|
113
|
+
}
|
|
114
|
+
if (question) {
|
|
115
|
+
out.push(new Text(this.config.theme.bold(question.question), 1, 0));
|
|
116
|
+
out.push(new Spacer(1));
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
bodyComponent(state: DialogState): Component {
|
|
122
|
+
const question = this.config.questions[state.currentTab];
|
|
123
|
+
const mso = this.config.tabsByIndex[state.currentTab]?.multiSelect;
|
|
124
|
+
if (question?.multiSelect === true && mso) return mso;
|
|
125
|
+
return this.config.getPreviewPane();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
bodyHeight(width: number, _state: DialogState): number {
|
|
129
|
+
return this.config.getCurrentBodyHeight(width);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
midRows(state: DialogState): Component[] {
|
|
133
|
+
if (!state.notesVisible) {
|
|
134
|
+
const notes = state.notesByTab.get(state.currentTab);
|
|
135
|
+
return notes?.trim()
|
|
136
|
+
? [new Text(this.config.theme.fg("muted", `${t("notes.header", NOTES_HEADER)} ${notes}`), 1, 0), new Spacer(1)]
|
|
137
|
+
: [];
|
|
138
|
+
}
|
|
139
|
+
return [
|
|
140
|
+
new Text(this.config.theme.fg("muted", t("notes.header", NOTES_HEADER)), 1, 0),
|
|
141
|
+
this.config.notesInput,
|
|
142
|
+
new Spacer(1),
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
footerRows(state: DialogState, previewScrollable: boolean): Component[] {
|
|
147
|
+
const question = this.config.questions[state.currentTab];
|
|
148
|
+
// OneLineClippedText (not pi-tui `Text`) — `buildHintText` includes the collapse
|
|
149
|
+
// affordance, pushing the rendered string past 80 columns; `Text` would wrap and
|
|
150
|
+
// break the strategy's `footerRowCount = 2` invariant. Clipping on narrow terminals
|
|
151
|
+
// drops the trailing parts (collapse hint first, then cancel) with `…`.
|
|
152
|
+
return [
|
|
153
|
+
new Spacer(1),
|
|
154
|
+
new OneLineClippedText(
|
|
155
|
+
this.config.theme.fg("dim", buildHintText(question, this.config.isMulti, state, previewScrollable)),
|
|
156
|
+
1,
|
|
157
|
+
),
|
|
158
|
+
];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
focusedItemRowRange(width: number, state: DialogState): [number, number] | undefined {
|
|
162
|
+
const question = this.config.questions[state.currentTab];
|
|
163
|
+
const mso = this.config.tabsByIndex[state.currentTab]?.multiSelect;
|
|
164
|
+
if (question?.multiSelect === true && mso) return mso.focusedItemRowRange(width);
|
|
165
|
+
return (this.config.getPreviewPane() as unknown as PreviewPane).focusedItemRowRange(width);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface SubmitTabStrategyConfig {
|
|
170
|
+
theme: Theme;
|
|
171
|
+
questions: readonly QuestionData[];
|
|
172
|
+
submitPicker: Component | undefined;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export class SubmitTabStrategy implements TabContentStrategy {
|
|
176
|
+
/** Spacer(1) + Text(prompt, 1) + Spacer(1) + submitPicker(2) = 5 rendered rows. Fallback path lands at 5 via 2 trailing Spacer(1)s. */
|
|
177
|
+
readonly footerRowCount = 5;
|
|
178
|
+
|
|
179
|
+
constructor(private readonly config: SubmitTabStrategyConfig) {}
|
|
180
|
+
|
|
181
|
+
headingRows(_state: DialogState): Component[] {
|
|
182
|
+
return [
|
|
183
|
+
new Text(this.config.theme.bold(this.config.theme.fg("accent", t("review.heading", REVIEW_HEADING))), 1, 0),
|
|
184
|
+
new Spacer(1),
|
|
185
|
+
];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
bodyComponent(state: DialogState): Component {
|
|
189
|
+
const c = new Container();
|
|
190
|
+
for (let i = 0; i < this.config.questions.length; i++) {
|
|
191
|
+
const q = this.config.questions[i];
|
|
192
|
+
const a = state.answers.get(i);
|
|
193
|
+
if (!a) continue;
|
|
194
|
+
const label = q.header && q.header.length > 0 ? q.header : `Q${i + 1}`;
|
|
195
|
+
const answerText = formatAnswerScalar(a);
|
|
196
|
+
c.addChild(new Text(this.config.theme.fg("muted", ` ● ${label}`), 1, 0));
|
|
197
|
+
c.addChild(
|
|
198
|
+
new Text(` ${this.config.theme.fg("muted", "→")} ${this.config.theme.fg("text", answerText)}`, 1, 0),
|
|
199
|
+
);
|
|
200
|
+
if (a.notes && a.notes.length > 0) {
|
|
201
|
+
c.addChild(new Text(this.config.theme.fg("dim", ` notes: ${a.notes}`), 1, 0));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return c;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
bodyHeight(width: number, state: DialogState): number {
|
|
208
|
+
return this.bodyComponent(state).render(width).length;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
midRows(_state: DialogState): Component[] {
|
|
212
|
+
return [];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
footerRows(state: DialogState, _previewScrollable: boolean): Component[] {
|
|
216
|
+
const missing: string[] = [];
|
|
217
|
+
for (let i = 0; i < this.config.questions.length; i++) {
|
|
218
|
+
const q = this.config.questions[i];
|
|
219
|
+
if (!state.answers.has(i)) {
|
|
220
|
+
missing.push(q.header && q.header.length > 0 ? q.header : `Q${i + 1}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const promptText =
|
|
224
|
+
missing.length === 0
|
|
225
|
+
? this.config.theme.fg("muted", t("review.ready", READY_PROMPT))
|
|
226
|
+
: this.config.theme.fg(
|
|
227
|
+
"warning",
|
|
228
|
+
`${t("review.incomplete", INCOMPLETE_WARNING_PREFIX)} ${missing.join(", ")}`,
|
|
229
|
+
);
|
|
230
|
+
const out: Component[] = [new Spacer(1), new Text(promptText, 1, 0), new Spacer(1)];
|
|
231
|
+
if (this.config.submitPicker) {
|
|
232
|
+
out.push(this.config.submitPicker);
|
|
233
|
+
} else {
|
|
234
|
+
// Padding when the picker isn't wired — keeps rendered row count at footerRowCount=5.
|
|
235
|
+
out.push(new Spacer(1));
|
|
236
|
+
out.push(new Spacer(1));
|
|
237
|
+
}
|
|
238
|
+
return out;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
focusedItemRowRange(_width: number, _state: DialogState): [number, number] | undefined {
|
|
242
|
+
return undefined;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Build the controls hint line. Order:
|
|
248
|
+
* Enter · ↑/↓ [· Space toggle] [· n notes] [· Tab switch] · Esc · Ctrl+] collapse
|
|
249
|
+
* [· Shift+Enter newline] [· Ctrl+U clear]
|
|
250
|
+
*
|
|
251
|
+
* `NOTES` is part of the resting (notes-closed) core — it drops while the notes
|
|
252
|
+
* editor or custom-answer input has the keyboard. Ctrl+G is Pi's global external-
|
|
253
|
+
* editor shortcut and needs no local hint; the context-specific clear shortcut is
|
|
254
|
+
* appended at the far right while input mode is active.
|
|
255
|
+
*/
|
|
256
|
+
export function buildHintText(
|
|
257
|
+
question: QuestionData | undefined,
|
|
258
|
+
isMulti: boolean,
|
|
259
|
+
state: DialogState,
|
|
260
|
+
previewScrollable: boolean,
|
|
261
|
+
): string {
|
|
262
|
+
const parts: string[] = [t("hint.enter", HINT_PART_ENTER), t("hint.navigate", HINT_PART_NAV)];
|
|
263
|
+
if (
|
|
264
|
+
previewScrollable &&
|
|
265
|
+
hasQuestionLevelPreview(question) &&
|
|
266
|
+
!state.collapsed &&
|
|
267
|
+
!state.notesVisible &&
|
|
268
|
+
!state.inputMode
|
|
269
|
+
) {
|
|
270
|
+
parts.push(t("hint.scroll", HINT_PART_SCROLL));
|
|
271
|
+
}
|
|
272
|
+
if (question?.multiSelect === true) parts.push(t("hint.toggle", HINT_PART_TOGGLE));
|
|
273
|
+
if (question && !state.notesVisible && !state.inputMode) parts.push(t("hint.notes", HINT_PART_NOTES));
|
|
274
|
+
if (isMulti) parts.push(t("hint.tab", HINT_PART_TAB));
|
|
275
|
+
parts.push(t("hint.cancel", HINT_PART_CANCEL));
|
|
276
|
+
parts.push(t("hint.collapse", HINT_PART_COLLAPSE));
|
|
277
|
+
if (state.notesVisible || state.inputMode) parts.push(t("hint.newline", HINT_PART_NEW_LINE));
|
|
278
|
+
if (state.inputMode) parts.push(t("hint.clear", HINT_PART_CLEAR));
|
|
279
|
+
return parts.join(" · ");
|
|
280
|
+
}
|