@juicesharp/rpiv-ask-user-question 2.14.2 → 2.15.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 CHANGED
@@ -52,6 +52,7 @@ Optional. Settings live in `~/.config/rpiv-ask-user-question/config.json`; the f
52
52
  | Setting | What it does | Default |
53
53
  | --- | --- | --- |
54
54
  | `collapseKey` | Key that collapses and expands the dialog. Accepts Pi keybinding ids such as `alt+o`; `"off"` disables the shortcut. | `"ctrl+]"` |
55
+ | `notesKey` | Key that opens the notes editor. Any single character, including non-Latin ones such as `т`, or a Pi keybinding id such as `ctrl+n`. | `"n"` |
55
56
  | `guidance.description` | Full replacement for the tool description the model sees. A non-empty string replaces the built-in text entirely — no merging. | built-in description |
56
57
  | `guidance.promptSnippet` | One-line description of the tool in the system prompt — tune how eagerly the model asks. | built-in snippet |
57
58
  | `guidance.promptGuidelines` | Usage guidelines given to the model, as a list of strings. | 4 built-in guidelines |
@@ -6,6 +6,7 @@ import {
6
6
  formatKeySpecForDisplay,
7
7
  loadConfig,
8
8
  resolveCollapseKey,
9
+ resolveNotesKey,
9
10
  validateGuidanceFields,
10
11
  } from "./config.ts";
11
12
  import {
@@ -200,14 +201,25 @@ function makeSessionFactory(config: {
200
201
  typed: QuestionParams;
201
202
  itemsByTab: WrappingSelectItem[][];
202
203
  collapseKey: string;
204
+ notesKey: string;
203
205
  canReopenWhileHidden: boolean;
204
206
  presentation: Presentation;
205
207
  sessionRef: SessionRef;
206
208
  open: OpenQuestionnaire;
207
209
  Session: SessionModule["QuestionnaireSession"];
208
210
  }) {
209
- const { ctx, typed, itemsByTab, collapseKey, canReopenWhileHidden, presentation, sessionRef, open, Session } =
210
- config;
211
+ const {
212
+ ctx,
213
+ typed,
214
+ itemsByTab,
215
+ collapseKey,
216
+ notesKey,
217
+ canReopenWhileHidden,
218
+ presentation,
219
+ sessionRef,
220
+ open,
221
+ Session,
222
+ } = config;
211
223
  return (
212
224
  tui: TUI,
213
225
  theme: Theme,
@@ -253,6 +265,7 @@ function makeSessionFactory(config: {
253
265
  }
254
266
  },
255
267
  collapseKey,
268
+ notesKey,
256
269
  canReopenWhileHidden,
257
270
  rowBudget: rowBudgetForHost(tui.terminal, presentation.rowBudget),
258
271
  });
@@ -280,6 +293,7 @@ async function mountQuestionnaire(config: {
280
293
  typed: QuestionParams;
281
294
  itemsByTab: WrappingSelectItem[][];
282
295
  collapseKey: string;
296
+ notesKey: string;
283
297
  presentation: Presentation;
284
298
  open: OpenQuestionnaire;
285
299
  Session: SessionModule["QuestionnaireSession"];
@@ -358,7 +372,9 @@ async function runTuiPath(pi: ExtensionAPI, ctx: ExtensionContext, typed: Questi
358
372
  // with non-US layouts (e.g. Latin American, where `]` is shifted) can override
359
373
  // via the `collapseKey` config field. `resolveCollapseKey` also accepts the
360
374
  // sentinel value `"off"` to disable the shortcut entirely.
361
- const collapseKey = resolveCollapseKey(loadConfig());
375
+ const config = loadConfig();
376
+ const collapseKey = resolveCollapseKey(config);
377
+ const notesKey = resolveNotesKey(config);
362
378
  const mount = (p: Presentation) =>
363
379
  Promise.race([
364
380
  mountQuestionnaire({
@@ -366,6 +382,7 @@ async function runTuiPath(pi: ExtensionAPI, ctx: ExtensionContext, typed: Questi
366
382
  typed,
367
383
  itemsByTab,
368
384
  collapseKey,
385
+ notesKey,
369
386
  presentation: p,
370
387
  open,
371
388
  Session: QuestionnaireSession,
package/config.ts CHANGED
@@ -6,6 +6,7 @@ export type CollapseKeySpec = string;
6
6
 
7
7
  export const DEFAULT_COLLAPSE_KEY: CollapseKeySpec = "ctrl+]";
8
8
  export const COLLAPSE_KEY_OFF: CollapseKeySpec = "off";
9
+ export const DEFAULT_NOTES_KEY = "n";
9
10
 
10
11
  export interface AskUserQuestionConfig {
11
12
  guidance?: GuidanceFields;
@@ -17,6 +18,12 @@ export interface AskUserQuestionConfig {
17
18
  * Pass `"off"` to disable the collapse shortcut entirely.
18
19
  */
19
20
  collapseKey?: CollapseKeySpec;
21
+ /**
22
+ * Key that opens the notes editor. Defaults to `"n"`. A single character of any
23
+ * script (e.g. `"т"` on a Cyrillic layout) matches as typed; anything else is a
24
+ * key spec in the `collapseKey` format, e.g. `"ctrl+n"`.
25
+ */
26
+ notesKey?: string;
20
27
  }
21
28
 
22
29
  // Named keys accepted by pi-tui's `matchesKey` (keys.js switch on the parsed base key).
@@ -68,6 +75,22 @@ export function resolveCollapseKey(config: Pick<AskUserQuestionConfig, "collapse
68
75
  return isValidCollapseKeySpec(raw) ? raw : DEFAULT_COLLAPSE_KEY;
69
76
  }
70
77
 
78
+ // Keys the questionnaire already navigates with — a notes key on one of them would shadow it.
79
+ const NOTES_KEY_RESERVED = new Set(["space", "enter", "return", "tab", "escape", "esc", "up", "down", "left", "right"]);
80
+
81
+ export function resolveNotesKey(config: Pick<AskUserQuestionConfig, "notesKey">): string {
82
+ const raw = config.notesKey?.trim();
83
+ if (!raw) return DEFAULT_NOTES_KEY;
84
+ if ([...raw].length === 1) return raw;
85
+ const spec = raw.toLowerCase();
86
+ return isValidCollapseKeySpec(spec) && !NOTES_KEY_RESERVED.has(spec) ? spec : DEFAULT_NOTES_KEY;
87
+ }
88
+
89
+ /** A single-character notes key shows as configured (`n`, not `N`); a spec is display-cased. */
90
+ export function formatNotesKeyForDisplay(notesKey: string): string {
91
+ return [...notesKey].length === 1 ? notesKey : formatKeySpecForDisplay(notesKey);
92
+ }
93
+
71
94
  // The only compound-word names in SPECIAL_KEYS — first-letter capitalization
72
95
  // alone would render them "Pageup"/"Pagedown".
73
96
  const COMPOUND_KEY_DISPLAY: Record<string, string> = {
@@ -59,6 +59,7 @@ type are likewise dropped back to their default without a warning.
59
59
  | Setting | What it does | Default |
60
60
  | --- | --- | --- |
61
61
  | `collapseKey` | Key that collapses and expands the dialog. | `"ctrl+]"` |
62
+ | `notesKey` | Key that opens the notes editor. | `"n"` |
62
63
  | `guidance.description` | Full text of the tool description the model sees. Replaces the built-in default entirely — no merging. | built-in description |
63
64
  | `guidance.promptSnippet` | One-line snippet describing the tool in the system prompt. | built-in snippet |
64
65
  | `guidance.promptGuidelines` | List of usage guidelines given to the model. | 4 built-in guidelines |
@@ -90,6 +91,20 @@ for `"alt+o"`), as do the collapsed one-line footer and the one-shot notificatio
90
91
  when the dialog is first hidden. With `"off"` the collapse hint is dropped from the
91
92
  footer entirely, since no shortcut can fire.
92
93
 
94
+ ### `notesKey`
95
+
96
+ A single character matches exactly as your keyboard types it, in any script. On a
97
+ Cyrillic layout, for example, the key that types `n` on a Latin layout types `т`, so set
98
+ `"т"`. Values are trimmed; a single character keeps its case.
99
+
100
+ Anything longer is a key spec in the `collapseKey` format, such as `"ctrl+n"` or `"alt+o"`.
101
+ In terminals that use the Kitty keyboard protocol, a modified spec like `"ctrl+n"` also
102
+ works on non-Latin layouts, because the terminal reports the key's Latin equivalent.
103
+
104
+ A spec that does not match the grammar, or that names a key the dialog already uses
105
+ (`space`, `enter`, `return`, `tab`, `escape`, `esc`, and the arrow keys), is rejected and
106
+ `"n"` is used. The notes hints in the dialog name whatever key you configure.
107
+
93
108
  ### `guidance.description`, `guidance.promptSnippet` and `guidance.promptGuidelines`
94
109
 
95
110
  `guidance.description` replaces the entire built-in description Pi registers for the
package/docs/keyboard.md CHANGED
@@ -12,8 +12,9 @@ adapts to the size of your terminal.
12
12
  | `Shift+Enter` | Insert a newline. | `Type something.` input, notes editor |
13
13
  | `Esc` | Cancel the whole questionnaire. | Everywhere except the notes editor, where it closes notes |
14
14
  | `Tab` / `Shift+Tab` | Next / previous tab, wrapping. `→` / `←` do the same. | Multi-question dialogs only |
15
+ | `1`–`9` | Act on the row with that number: answer with it on a single-select question, toggle it on a multi-select one, or move to `Type something.` (no digit reaches `Next`). Inside `Type something.` and the notes editor, digits are text. | Option list |
15
16
  | `Space` | Toggle the focused authored option. In `Type something.`, Space inserts text. | Multi-select questions |
16
- | `n` | Open the notes editor for the focused question — or, on the Submit tab, the global note for the whole questionnaire. | Every question tab; the Submit tab in multi-question dialogs |
17
+ | `n` | Open the notes editor for the focused question — or, on the Submit tab, the global note for the whole questionnaire. Configurable via `notesKey`. | Every question tab; the Submit tab in multi-question dialogs |
17
18
  | `Ctrl+G` | Open Pi's configured external editor with the current custom-answer draft. | `Type something.` input |
18
19
  | `Ctrl+U` | Clear the current custom-answer draft. | `Type something.` input |
19
20
  | `Ctrl+]` | Collapse or expand the dialog. Configurable via `collapseKey`. | Everywhere, including while collapsed |
package/locales/de.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "hint.newline": "Umschalt+Enter für neue Zeile",
13
13
  "hint.clear": "Ctrl+U zum Leeren",
14
14
  "hint.toggle": "Leertaste zum Umschalten",
15
- "hint.notes": "n für Notizen",
15
+ "hint.notes": "{key} für Notizen",
16
16
  "hint.tab": "Tab wechselt die Frage",
17
17
  "hint.cancel": "Esc zum Abbrechen",
18
18
 
@@ -21,8 +21,8 @@
21
21
  "review.incomplete": "⚠ Beantworte die verbleibenden Fragen vor dem Senden:",
22
22
 
23
23
  "preview.no_preview": "Keine Vorschau verfügbar",
24
- "preview.notes_affordance": "Notizen: drücke n, um Notizen hinzuzufügen",
25
- "preview.notes_edit_affordance": "Notiz gespeichert: drücke n zum Bearbeiten",
24
+ "preview.notes_affordance": "Notizen: drücke {key}, um Notizen hinzuzufügen",
25
+ "preview.notes_edit_affordance": "Notiz gespeichert: drücke {key} zum Bearbeiten",
26
26
  "notes.header": "Notizen:",
27
27
  "notes.saved_label": "Notiz zu dieser Antwort:",
28
28
 
package/locales/en.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "hint.newline": "Shift+Enter for newline",
11
11
  "hint.clear": "Ctrl+U to clear",
12
12
  "hint.toggle": "Space to toggle",
13
- "hint.notes": "n to add notes",
13
+ "hint.notes": "{key} to add notes",
14
14
  "hint.tab": "Tab to switch questions",
15
15
  "hint.collapse": "{key} to collapse",
16
16
  "hint.expand_line": "{key} to expand · Esc to cancel",
@@ -19,12 +19,12 @@
19
19
  "review.heading": "Review your answers",
20
20
  "review.ready": "Ready to submit your answers?",
21
21
  "review.incomplete": "⚠ Answer remaining questions before submitting:",
22
- "review.global_hint": "n to add a note",
22
+ "review.global_hint": "{key} to add a note",
23
23
  "review.note_label": "Note",
24
24
 
25
25
  "preview.no_preview": "No preview available",
26
- "preview.notes_affordance": "Notes: press n to add notes",
27
- "preview.notes_edit_affordance": "Note saved: press n to edit",
26
+ "preview.notes_affordance": "Notes: press {key} to add notes",
27
+ "preview.notes_edit_affordance": "Note saved: press {key} to edit",
28
28
  "notes.header": "Notes:",
29
29
  "notes.saved_label": "Note for this answer:",
30
30
  "notes.global_header": "Global note:",
package/locales/es.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "hint.newline": "Mayús+Enter para nueva línea",
13
13
  "hint.clear": "Ctrl+U para borrar",
14
14
  "hint.toggle": "Espacio para alternar",
15
- "hint.notes": "n para añadir notas",
15
+ "hint.notes": "{key} para añadir notas",
16
16
  "hint.tab": "Tab para cambiar de pregunta",
17
17
  "hint.cancel": "Esc para cancelar",
18
18
 
@@ -21,8 +21,8 @@
21
21
  "review.incomplete": "⚠ Responde las preguntas restantes antes de enviar:",
22
22
 
23
23
  "preview.no_preview": "Vista previa no disponible",
24
- "preview.notes_affordance": "Notas: pulsa n para añadir notas",
25
- "preview.notes_edit_affordance": "Nota guardada: pulsa n para editarla",
24
+ "preview.notes_affordance": "Notas: pulsa {key} para añadir notas",
25
+ "preview.notes_edit_affordance": "Nota guardada: pulsa {key} para editarla",
26
26
  "notes.header": "Notas:",
27
27
  "notes.saved_label": "Nota para esta respuesta:",
28
28
 
package/locales/fr.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "hint.newline": "Maj+Entrée pour une nouvelle ligne",
13
13
  "hint.clear": "Ctrl+U pour effacer",
14
14
  "hint.toggle": "Espace pour basculer",
15
- "hint.notes": "n pour ajouter des notes",
15
+ "hint.notes": "{key} pour ajouter des notes",
16
16
  "hint.tab": "Tab pour changer de question",
17
17
  "hint.cancel": "Échap pour annuler",
18
18
 
@@ -21,8 +21,8 @@
21
21
  "review.incomplete": "⚠ Répondez aux questions restantes avant d'envoyer :",
22
22
 
23
23
  "preview.no_preview": "Aucun aperçu disponible",
24
- "preview.notes_affordance": "Notes : appuyez sur n pour ajouter des notes",
25
- "preview.notes_edit_affordance": "Note enregistrée : appuyez sur n pour la modifier",
24
+ "preview.notes_affordance": "Notes : appuyez sur {key} pour ajouter des notes",
25
+ "preview.notes_edit_affordance": "Note enregistrée : appuyez sur {key} pour la modifier",
26
26
  "notes.header": "Notes :",
27
27
  "notes.saved_label": "Note pour cette réponse :",
28
28
 
@@ -12,7 +12,7 @@
12
12
  "hint.newline": "Shift+Enter para nova linha",
13
13
  "hint.clear": "Ctrl+U para limpar",
14
14
  "hint.toggle": "Espaço para alternar",
15
- "hint.notes": "n para adicionar notas",
15
+ "hint.notes": "{key} para adicionar notas",
16
16
  "hint.tab": "Tab para trocar de pergunta",
17
17
  "hint.cancel": "Esc para cancelar",
18
18
 
@@ -21,8 +21,8 @@
21
21
  "review.incomplete": "⚠ Responda as perguntas restantes antes de enviar:",
22
22
 
23
23
  "preview.no_preview": "Pré-visualização indisponível",
24
- "preview.notes_affordance": "Notas: pressione n para adicionar notas",
25
- "preview.notes_edit_affordance": "Nota salva: pressione n para editar",
24
+ "preview.notes_affordance": "Notas: pressione {key} para adicionar notas",
25
+ "preview.notes_edit_affordance": "Nota salva: pressione {key} para editar",
26
26
  "notes.header": "Notas:",
27
27
  "notes.saved_label": "Nota para esta resposta:",
28
28
 
package/locales/pt.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "hint.newline": "Shift+Enter para nova linha",
13
13
  "hint.clear": "Ctrl+U para limpar",
14
14
  "hint.toggle": "Espaço para alternar",
15
- "hint.notes": "n para adicionar notas",
15
+ "hint.notes": "{key} para adicionar notas",
16
16
  "hint.tab": "Tab para mudar de pergunta",
17
17
  "hint.cancel": "Esc para cancelar",
18
18
 
@@ -21,8 +21,8 @@
21
21
  "review.incomplete": "⚠ Responda às perguntas restantes antes de enviar:",
22
22
 
23
23
  "preview.no_preview": "Pré-visualização indisponível",
24
- "preview.notes_affordance": "Notas: prima n para adicionar notas",
25
- "preview.notes_edit_affordance": "Nota guardada: prima n para editar",
24
+ "preview.notes_affordance": "Notas: prima {key} para adicionar notas",
25
+ "preview.notes_edit_affordance": "Nota guardada: prima {key} para editar",
26
26
  "notes.header": "Notas:",
27
27
  "notes.saved_label": "Nota para esta resposta:",
28
28
 
package/locales/ru.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "hint.newline": "Shift+Enter — новая строка",
13
13
  "hint.clear": "Ctrl+U — очистить",
14
14
  "hint.toggle": "Space — переключить",
15
- "hint.notes": "n — добавить заметки",
15
+ "hint.notes": "{key} — добавить заметки",
16
16
  "hint.tab": "Tab — следующий вопрос",
17
17
  "hint.cancel": "Esc — отменить",
18
18
 
@@ -21,8 +21,8 @@
21
21
  "review.incomplete": "⚠ Ответьте на оставшиеся вопросы перед отправкой:",
22
22
 
23
23
  "preview.no_preview": "Предпросмотр недоступен",
24
- "preview.notes_affordance": "Заметки: нажмите n, чтобы добавить заметки",
25
- "preview.notes_edit_affordance": "Заметка сохранена: нажмите n, чтобы изменить",
24
+ "preview.notes_affordance": "Заметки: нажмите {key}, чтобы добавить заметки",
25
+ "preview.notes_edit_affordance": "Заметка сохранена: нажмите {key}, чтобы изменить",
26
26
  "notes.header": "Заметки:",
27
27
  "notes.saved_label": "Заметка к этому ответу:",
28
28
 
package/locales/uk.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "hint.newline": "Shift+Enter — новий рядок",
13
13
  "hint.clear": "Ctrl+U — очистити",
14
14
  "hint.toggle": "Space — перемкнути",
15
- "hint.notes": "n — додати нотатки",
15
+ "hint.notes": "{key} — додати нотатки",
16
16
  "hint.tab": "Tab — наступне питання",
17
17
  "hint.cancel": "Esc — скасувати",
18
18
 
@@ -21,8 +21,8 @@
21
21
  "review.incomplete": "⚠ Дайте відповіді на решту питань перед надсиланням:",
22
22
 
23
23
  "preview.no_preview": "Попередній перегляд недоступний",
24
- "preview.notes_affordance": "Нотатки: натисніть n, щоб додати нотатки",
25
- "preview.notes_edit_affordance": "Нотатку збережено: натисніть n, щоб змінити",
24
+ "preview.notes_affordance": "Нотатки: натисніть {key}, щоб додати нотатки",
25
+ "preview.notes_edit_affordance": "Нотатку збережено: натисніть {key}, щоб змінити",
26
26
  "notes.header": "Нотатки:",
27
27
  "notes.saved_label": "Нотатка до цієї відповіді:",
28
28
 
package/locales/zh.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "hint.newline": "Shift+Enter 换行",
13
13
  "hint.clear": "Ctrl+U 清空",
14
14
  "hint.toggle": "空格切换",
15
- "hint.notes": "按 n 添加备注",
15
+ "hint.notes": "按 {key} 添加备注",
16
16
  "hint.tab": "Tab 切换问题",
17
17
  "hint.collapse": "{key} 折叠",
18
18
  "hint.expand_line": "{key} 展开 · Esc 取消",
@@ -23,8 +23,8 @@
23
23
  "review.incomplete": "⚠ 提交前请先回答以下问题:",
24
24
 
25
25
  "preview.no_preview": "暂无预览",
26
- "preview.notes_affordance": "备注:按 n 添加",
27
- "preview.notes_edit_affordance": "备注已保存:按 n 编辑",
26
+ "preview.notes_affordance": "备注:按 {key} 添加",
27
+ "preview.notes_edit_affordance": "备注已保存:按 {key} 编辑",
28
28
  "notes.header": "备注:",
29
29
  "notes.saved_label": "此回答的备注:",
30
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juicesharp/rpiv-ask-user-question",
3
- "version": "2.14.2",
3
+ "version": "2.15.0",
4
4
  "description": "Pi extension. A structured questionnaire the model can put to you when it would otherwise guess, with typed options instead of free-form replies.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -102,6 +102,6 @@
102
102
  }
103
103
  },
104
104
  "dependencies": {
105
- "@juicesharp/rpiv-config": "^2.14.2"
105
+ "@juicesharp/rpiv-config": "^2.15.0"
106
106
  }
107
107
  }
@@ -47,6 +47,8 @@ export interface QuestionnaireBuildConfig {
47
47
  * of runtime context.
48
48
  */
49
49
  collapseKey: string;
50
+ /** Resolved notes key (`resolveNotesKey` output), threaded to the hints that name it. */
51
+ notesKey: string;
50
52
  /**
51
53
  * Maps `tui.terminal.rows` to the rows the dialog may render — identity for the
52
54
  * overlay, a capped share for the inline editor slot (`../presentation.ts`). Applied
@@ -123,6 +125,7 @@ class QuestionnaireBuilder {
123
125
  private readonly initialState: QuestionnaireState;
124
126
  private readonly getCurrentTab: () => number;
125
127
  private readonly collapseKey: string;
128
+ private readonly notesKey: string;
126
129
  private readonly rowBudget: (terminalRows: number) => number;
127
130
 
128
131
  private readonly selectTheme: WrappingSelectTheme;
@@ -141,6 +144,7 @@ class QuestionnaireBuilder {
141
144
  this.initialState = config.initialState;
142
145
  this.getCurrentTab = config.getCurrentTab;
143
146
  this.collapseKey = config.collapseKey;
147
+ this.notesKey = config.notesKey;
144
148
  this.rowBudget = config.rowBudget;
145
149
 
146
150
  this.selectTheme = this.makeSelectTheme();
@@ -191,6 +195,7 @@ class QuestionnaireBuilder {
191
195
  question,
192
196
  theme: this.theme,
193
197
  markdownTheme: this.markdownTheme,
198
+ notesKey: this.notesKey,
194
199
  });
195
200
  const preview = new PreviewPane({
196
201
  question,
@@ -277,6 +282,7 @@ class QuestionnaireBuilder {
277
282
  getCurrentBodyHeight: heights.current,
278
283
  getTerminalRows: this.getTerminalRows,
279
284
  collapseKey: this.collapseKey,
285
+ notesKey: this.notesKey,
280
286
  },
281
287
  { state: this.initialState, activePreviewPane: this.pickInitialActivePreview(tabs) },
282
288
  );
@@ -16,6 +16,17 @@ const KEYBIND_EXTERNAL_EDITOR = "app.editor.external";
16
16
 
17
17
  const NOTES_ACTIVATE_KEY = "n";
18
18
 
19
+ /**
20
+ * The notes shortcut. A single-character key matches the character as typed, so a
21
+ * non-Latin one works (pi-tui's key parser knows only ASCII); anything else matches as
22
+ * a pi-tui key spec. A non-string key — a stale outer module, as with `collapseKey`
23
+ * below — falls back to `n`.
24
+ */
25
+ function matchesNotesKey(data: string, notesKey: unknown): boolean {
26
+ const key = typeof notesKey === "string" ? notesKey : NOTES_ACTIVATE_KEY;
27
+ return data === key || matchesKey(data, key as Parameters<typeof matchesKey>[1]);
28
+ }
29
+
19
30
  export type QuestionnaireAction =
20
31
  | { kind: "nav"; nextIndex: number; inputValue: string }
21
32
  | { kind: "input_clear" }
@@ -224,19 +235,37 @@ function routeSubmitTab(
224
235
  // answers flow through `orderedAnswers()` in the host.
225
236
  return state.submitChoiceIndex === 1 ? { kind: "cancel" } : { kind: "submit" };
226
237
  }
227
- // Global note (#182): `n` on the Submit tab opens the notes editor scoped to the whole
238
+ // Global note (#182): the notes key on the Submit tab opens the notes editor scoped to the whole
228
239
  // questionnaire at the pseudo-index (`questions.length` in notesByTab). Reachable only
229
240
  // with the editor closed — `routeKey` dispatches notesVisible traffic to
230
241
  // `routeNotesMode` before the submit-tab block runs. The branch shadows nothing above
231
- // it (cancel, tab switch, submit-nav, confirm): an `n` key matches none of them
242
+ // it (cancel, tab switch, submit-nav, confirm): the default `n` matches none of them
232
243
  // under default bindings, and a user who deliberately binds one of those actions to
233
244
  // `n` keeps that mapping because the earlier branch still wins (Enter still submits).
234
- if (matchesKey(data, NOTES_ACTIVATE_KEY)) {
245
+ if (matchesNotesKey(data, runtime.notesKey)) {
235
246
  return { kind: "notes_enter" };
236
247
  }
237
248
  return { kind: "ignore" };
238
249
  }
239
250
 
251
+ const DIGIT_KEYS = ["1", "2", "3", "4", "5", "6", "7", "8", "9"] as const;
252
+
253
+ /**
254
+ * The row a digit hotkey names: `1`-`9` follow the list's numbering, so the
255
+ * unnumbered Next row has no digit. One key per keystroke — a pasted `"12"`
256
+ * matches none. Checked after every keybinding, so a digit bound to an action
257
+ * keeps that action.
258
+ */
259
+ function digitRow(
260
+ data: string,
261
+ runtime: QuestionnaireRuntime,
262
+ ): { index: number; activatesInputMode: boolean } | undefined {
263
+ const index = DIGIT_KEYS.findIndex((digit) => matchesKey(data, digit));
264
+ const item = runtime.items[index];
265
+ if (!item || !ROW_INTENT_META[item.kind].numbered) return undefined;
266
+ return { index, activatesInputMode: ROW_INTENT_META[item.kind].activatesInputMode };
267
+ }
268
+
240
269
  function routeMultiSelectTab(
241
270
  kb: QuestionnaireKeybindings,
242
271
  data: string,
@@ -265,7 +294,11 @@ function routeMultiSelectTab(
265
294
  return buildMultiConfirmAction(state, runtime);
266
295
  }
267
296
  if (kb.matches(data, KEYBIND_CANCEL)) return { kind: "cancel" };
268
- return { kind: "ignore" };
297
+ // A digit toggles its row; the Type something. row's digit focuses it instead.
298
+ const row = digitRow(data, runtime);
299
+ if (!row) return { kind: "ignore" };
300
+ if (row.activatesInputMode) return { kind: "nav", nextIndex: row.index, inputValue: runtime.inputBuffer };
301
+ return { kind: "toggle", index: row.index };
269
302
  }
270
303
 
271
304
  function routeSingleSelectTab(
@@ -280,7 +313,16 @@ function routeSingleSelectTab(
280
313
  return { kind: "confirm", answer, autoAdvanceTab: computeAutoAdvanceTab(state, runtime) };
281
314
  }
282
315
  if (kb.matches(data, KEYBIND_CANCEL)) return { kind: "cancel" };
283
- return { kind: "ignore" };
316
+ // A digit answers with its row, as Enter on it would; the Type something. row's digit focuses it instead.
317
+ const row = digitRow(data, runtime);
318
+ if (!row) return { kind: "ignore" };
319
+ if (row.activatesInputMode) return { kind: "nav", nextIndex: row.index, inputValue: runtime.inputBuffer };
320
+ const answer = buildSingleSelectAnswer(
321
+ { ...state, optionIndex: row.index },
322
+ { ...runtime, currentItem: runtime.items[row.index] },
323
+ );
324
+ if (!answer) return { kind: "ignore" };
325
+ return { kind: "confirm", answer, autoAdvanceTab: computeAutoAdvanceTab(state, runtime) };
284
326
  }
285
327
 
286
328
  export function routeKey(data: string, state: QuestionnaireState, runtime: QuestionnaireRuntime): QuestionnaireAction {
@@ -341,7 +383,7 @@ export function routeKey(data: string, state: QuestionnaireState, runtime: Quest
341
383
  // "Type something.") is irrelevant: the gate sits ABOVE the multi-select
342
384
  // toggle block and the Next sentinel never activates inputMode, so `n` is
343
385
  // neither swallowed earlier nor blocked by `blocksMultiToggle`.
344
- if (matchesKey(data, NOTES_ACTIVATE_KEY)) {
386
+ if (matchesNotesKey(data, runtime.notesKey)) {
345
387
  return { kind: "notes_enter" };
346
388
  }
347
389
 
@@ -22,6 +22,8 @@ export interface QuestionnaireSessionConfig {
22
22
  editInput: (value: string) => Promise<string | undefined>;
23
23
  /** Key spec for the collapse/expand shortcut, e.g. `"ctrl+]"` or `"alt+o"`. */
24
24
  collapseKey: string;
25
+ /** Key that opens the notes editor (`resolveNotesKey` output). */
26
+ notesKey: string;
25
27
  /**
26
28
  * True iff `execute()` registered the raw `ctx.ui.onTerminalInput` listener — the only
27
29
  * path that can reach a hidden overlay. Gates the `set_overlay_hidden` effect: a host
@@ -75,6 +77,7 @@ export class QuestionnaireSession {
75
77
  private readonly keybindings: QuestionnaireRuntime["keybindings"];
76
78
  private readonly editInput: QuestionnaireSessionConfig["editInput"];
77
79
  private readonly collapseKey: string;
80
+ private readonly notesKey: string;
78
81
  private readonly canReopenWhileHidden: boolean;
79
82
  private inputEditorOpen = false;
80
83
 
@@ -98,6 +101,7 @@ export class QuestionnaireSession {
98
101
  this.keybindings = config.keybindings;
99
102
  this.editInput = config.editInput;
100
103
  this.collapseKey = config.collapseKey;
104
+ this.notesKey = config.notesKey;
101
105
  this.canReopenWhileHidden = config.canReopenWhileHidden;
102
106
 
103
107
  const built = buildQuestionnaire({
@@ -109,6 +113,7 @@ export class QuestionnaireSession {
109
113
  initialState: this.state,
110
114
  getCurrentTab: () => this.state.currentTab,
111
115
  collapseKey: this.collapseKey,
116
+ notesKey: this.notesKey,
112
117
  rowBudget: config.rowBudget,
113
118
  });
114
119
 
@@ -251,6 +256,7 @@ export class QuestionnaireSession {
251
256
  currentItem: this.currentItem(),
252
257
  items: this.itemsByTab[this.state.currentTab] ?? [],
253
258
  collapseKey: this.collapseKey,
259
+ notesKey: this.notesKey,
254
260
  };
255
261
  }
256
262
 
package/state/state.ts CHANGED
@@ -62,4 +62,6 @@ export interface QuestionnaireRuntime {
62
62
  * the collapse shortcut is disabled.
63
63
  */
64
64
  collapseKey: string;
65
+ /** Key that opens the notes editor (`resolveNotesKey` output: `"n"` by default). */
66
+ notesKey: string;
65
67
  }
@@ -1,7 +1,9 @@
1
1
  import type { Theme } from "@earendil-works/pi-coding-agent";
2
2
  import type { MarkdownTheme } from "@earendil-works/pi-tui";
3
+ import { DEFAULT_NOTES_KEY, formatNotesKeyForDisplay } from "../../../config.ts";
3
4
  import { t } from "../../../state/i18n-bridge.ts";
4
5
  import type { QuestionData } from "../../../tool/types.ts";
6
+ import { KEY_PLACEHOLDER } from "../../dialog-copy.ts";
5
7
  import {
6
8
  MAX_PREVIEW_HEIGHT_SIDE_BY_SIDE,
7
9
  MAX_PREVIEW_HEIGHT_STACKED,
@@ -21,9 +23,12 @@ import type { PreviewLayoutMode } from "./preview-layout-decider.ts";
21
23
  * Affordance text shown below the bordered preview when focused on a preview-bearing option.
22
24
  * Re-exported by `preview-pane.ts` for the existing test surface.
23
25
  */
24
- export const NOTES_AFFORDANCE_TEXT = "Notes: press n to add notes";
26
+ export const NOTES_AFFORDANCE_TEMPLATE = `Notes: press ${KEY_PLACEHOLDER} to add notes`;
25
27
  /** Affordance text once the question carries a saved note (#197). */
26
- export const NOTES_EDIT_AFFORDANCE_TEXT = "Note saved: press n to edit";
28
+ export const NOTES_EDIT_AFFORDANCE_TEMPLATE = `Note saved: press ${KEY_PLACEHOLDER} to edit`;
29
+ /** Default-key (`n`) renderings of the two affordance templates. */
30
+ export const NOTES_AFFORDANCE_TEXT = NOTES_AFFORDANCE_TEMPLATE.replace(KEY_PLACEHOLDER, DEFAULT_NOTES_KEY);
31
+ export const NOTES_EDIT_AFFORDANCE_TEXT = NOTES_EDIT_AFFORDANCE_TEMPLATE.replace(KEY_PLACEHOLDER, DEFAULT_NOTES_KEY);
27
32
 
28
33
  /**
29
34
  * Which notes affordance the block shows under the preview: `add` / `edit` (no note yet /
@@ -32,10 +37,12 @@ export const NOTES_EDIT_AFFORDANCE_TEXT = "Note saved: press n to edit";
32
37
  */
33
38
  export type NotesAffordance = "add" | "edit" | "none";
34
39
 
35
- function affordanceText(affordance: Exclude<NotesAffordance, "none">): string {
36
- return affordance === "edit"
37
- ? t("preview.notes_edit_affordance", NOTES_EDIT_AFFORDANCE_TEXT)
38
- : t("preview.notes_affordance", NOTES_AFFORDANCE_TEXT);
40
+ function affordanceText(affordance: Exclude<NotesAffordance, "none">, notesKey: string): string {
41
+ const text =
42
+ affordance === "edit"
43
+ ? t("preview.notes_edit_affordance", NOTES_EDIT_AFFORDANCE_TEMPLATE)
44
+ : t("preview.notes_affordance", NOTES_AFFORDANCE_TEMPLATE);
45
+ return text.replace(KEY_PLACEHOLDER, formatNotesKeyForDisplay(notesKey));
39
46
  }
40
47
 
41
48
  /** Content row budget for a layout mode: preview cap minus border + affordance overhead. */
@@ -73,6 +80,8 @@ export interface PreviewBlockRendererConfig {
73
80
  question: QuestionData;
74
81
  theme: Theme;
75
82
  markdownTheme: MarkdownTheme;
83
+ /** Resolved notes key (`resolveNotesKey` output), named by the affordance. */
84
+ notesKey: string;
76
85
  }
77
86
 
78
87
  /**
@@ -88,9 +97,11 @@ export interface PreviewBlockRendererConfig {
88
97
  export class PreviewBlockRenderer {
89
98
  private readonly theme: Theme;
90
99
  private readonly cache: MarkdownContentCache;
100
+ private readonly notesKey: string;
91
101
 
92
102
  constructor(config: PreviewBlockRendererConfig) {
93
103
  this.theme = config.theme;
104
+ this.notesKey = config.notesKey;
94
105
  this.cache = new MarkdownContentCache(config.question, config.theme, config.markdownTheme);
95
106
  }
96
107
 
@@ -143,7 +154,8 @@ export class PreviewBlockRenderer {
143
154
  const boxedLines = renderBorderedBox(contentLines, boxWidth, colorFn, hidden);
144
155
  if (!fit.affordance) return boxedLines;
145
156
 
146
- const text = affordance !== "none" && this.cache.has(optionIndex) ? affordanceText(affordance) : "";
157
+ const text =
158
+ affordance !== "none" && this.cache.has(optionIndex) ? affordanceText(affordance, this.notesKey) : "";
147
159
  return [...boxedLines, "", text ? this.theme.fg("muted", text) : ""];
148
160
  }
149
161
  }
@@ -87,6 +87,8 @@ export interface DialogConfig {
87
87
  * The footer hint interpolates it, and drops the collapse part when `"off"`.
88
88
  */
89
89
  collapseKey: string;
90
+ /** Resolved notes key (`resolveNotesKey` output), named by both tabs' notes hints. */
91
+ notesKey: string;
90
92
  }
91
93
 
92
94
  /**
@@ -116,6 +118,7 @@ export class DialogView implements StatefulView<DialogProps> {
116
118
  isMulti: config.isMulti,
117
119
  getCurrentBodyHeight: config.getCurrentBodyHeight,
118
120
  collapseKey: config.collapseKey,
121
+ notesKey: config.notesKey,
119
122
  });
120
123
  this.submitStrategy = config.isMulti
121
124
  ? new SubmitTabStrategy({
@@ -123,6 +126,7 @@ export class DialogView implements StatefulView<DialogProps> {
123
126
  questions: config.questions,
124
127
  submitPicker: config.submitPicker,
125
128
  notesInput: config.notesInput,
129
+ notesKey: config.notesKey,
126
130
  })
127
131
  : undefined;
128
132
  this.maxFooterRowCount = Math.max(this.questionStrategy.footerRowCount, this.submitStrategy?.footerRowCount ?? 0);
@@ -1,4 +1,9 @@
1
- import { DEFAULT_COLLAPSE_KEY, formatKeySpecForDisplay } from "../config.ts";
1
+ import {
2
+ DEFAULT_COLLAPSE_KEY,
3
+ DEFAULT_NOTES_KEY,
4
+ formatKeySpecForDisplay,
5
+ formatNotesKeyForDisplay,
6
+ } from "../config.ts";
2
7
 
3
8
  /** Leaf: imports nothing from `view/`, so `dialog-builder` and `tab-content-strategy` never form a runtime cycle (#208). */
4
9
 
@@ -7,7 +12,6 @@ export const HINT_PART_NAV = "↑/↓ to navigate";
7
12
  export const HINT_PART_NEW_LINE = "Shift+Enter for newline";
8
13
  export const HINT_PART_CLEAR = "Ctrl+U to clear";
9
14
  export const HINT_PART_TOGGLE = "Space to toggle";
10
- export const HINT_PART_NOTES = "n to add notes";
11
15
  export const HINT_PART_TAB = "Tab to switch questions";
12
16
  export const HINT_PART_CANCEL = "Esc to cancel";
13
17
  /**
@@ -20,6 +24,13 @@ export const HINT_PART_CANCEL = "Esc to cancel";
20
24
  export const KEY_PLACEHOLDER = "{key}";
21
25
  export const HINT_PART_COLLAPSE_TEMPLATE = `${KEY_PLACEHOLDER} to collapse`;
22
26
  export const HINT_PART_EXPAND_TEMPLATE = `${KEY_PLACEHOLDER} to expand`;
27
+ /** Notes hint, templated the same way on the configurable `notesKey`. */
28
+ export const HINT_PART_NOTES_TEMPLATE = `${KEY_PLACEHOLDER} to add notes`;
29
+ /** Default-key (`n`) rendering of the notes template. */
30
+ export const HINT_PART_NOTES = HINT_PART_NOTES_TEMPLATE.replace(
31
+ KEY_PLACEHOLDER,
32
+ formatNotesKeyForDisplay(DEFAULT_NOTES_KEY),
33
+ );
23
34
  /** Default-key (`Ctrl+]`) rendering of the collapse template, for tests and default-config assertions. */
24
35
  export const HINT_PART_COLLAPSE = HINT_PART_COLLAPSE_TEMPLATE.replace(
25
36
  KEY_PLACEHOLDER,
@@ -1,6 +1,6 @@
1
1
  import type { Theme } from "@earendil-works/pi-coding-agent";
2
2
  import { type Component, Container, type Editor, Spacer, Text, truncateToWidth } from "@earendil-works/pi-tui";
3
- import { COLLAPSE_KEY_OFF, formatKeySpecForDisplay } from "../config.ts";
3
+ import { COLLAPSE_KEY_OFF, formatKeySpecForDisplay, formatNotesKeyForDisplay } from "../config.ts";
4
4
  import { t } from "../state/i18n-bridge.ts";
5
5
  import { selectSavedNote } from "../state/selectors/derivations.ts";
6
6
  import { formatAnswerScalar } from "../tool/format-answer.ts";
@@ -14,7 +14,7 @@ import {
14
14
  HINT_PART_ENTER,
15
15
  HINT_PART_NAV,
16
16
  HINT_PART_NEW_LINE,
17
- HINT_PART_NOTES,
17
+ HINT_PART_NOTES_TEMPLATE,
18
18
  HINT_PART_TAB,
19
19
  HINT_PART_TOGGLE,
20
20
  INCOMPLETE_WARNING_PREFIX,
@@ -27,7 +27,7 @@ import type { TabComponents } from "./tab-components.ts";
27
27
 
28
28
  const NOTES_HEADER = "Notes:";
29
29
  const GLOBAL_NOTES_HEADER = "Global note:";
30
- const REVIEW_GLOBAL_HINT = "n to add a note";
30
+ const REVIEW_GLOBAL_HINT_TEMPLATE = `${KEY_PLACEHOLDER} to add a note`;
31
31
  const REVIEW_NOTE_LABEL = "Note";
32
32
  /** Label for a question's saved note — the question tab's resting row and the review entry (#197). */
33
33
  const SAVED_NOTE_LABEL = "Note for this answer:";
@@ -96,6 +96,8 @@ export interface QuestionTabStrategyConfig {
96
96
  getCurrentBodyHeight: (width: number) => number;
97
97
  /** Resolved collapse key spec (`"ctrl+]"`, `"alt+o"`, or `"off"`). Drives the footer's collapse hint. */
98
98
  collapseKey: string;
99
+ /** Resolved notes key (`resolveNotesKey` output). Named by the footer's notes hint. */
100
+ notesKey: string;
99
101
  }
100
102
 
101
103
  export class QuestionTabStrategy implements TabContentStrategy {
@@ -158,7 +160,10 @@ export class QuestionTabStrategy implements TabContentStrategy {
158
160
  return [
159
161
  new Spacer(1),
160
162
  new OneLineClippedText(
161
- this.config.theme.fg("dim", buildHintText(question, this.config.isMulti, state, this.config.collapseKey)),
163
+ this.config.theme.fg(
164
+ "dim",
165
+ buildHintText(question, this.config.isMulti, state, this.config.collapseKey, this.config.notesKey),
166
+ ),
162
167
  1,
163
168
  ),
164
169
  ];
@@ -178,6 +183,8 @@ export interface SubmitTabStrategyConfig {
178
183
  submitPicker: Component | undefined;
179
184
  /** Shared notes Editor — mounted into midRows while the global-note editor is open on this tab. */
180
185
  notesInput: Editor;
186
+ /** Resolved notes key (`resolveNotesKey` output). Named by the global-note hint. */
187
+ notesKey: string;
181
188
  }
182
189
 
183
190
  export class SubmitTabStrategy implements TabContentStrategy {
@@ -277,7 +284,9 @@ export class SubmitTabStrategy implements TabContentStrategy {
277
284
  // with no hint wedged between them. Always present so footerRowCount stays
278
285
  // exactly 5. OneLineClippedText (not pi-tui Text) — a wrapped hint would inflate
279
286
  // the footer past footerRowCount and desync the chrome's cross-tab height math.
280
- out.push(new OneLineClippedText(this.config.theme.fg("dim", buildSubmitHintText(state)), 1));
287
+ out.push(
288
+ new OneLineClippedText(this.config.theme.fg("dim", buildSubmitHintText(state, this.config.notesKey)), 1),
289
+ );
281
290
  return out;
282
291
  }
283
292
 
@@ -306,10 +315,12 @@ export function buildHintText(
306
315
  isMulti: boolean,
307
316
  state: DialogState,
308
317
  collapseKey: string,
318
+ notesKey: string,
309
319
  ): string {
310
320
  const parts: string[] = [t("hint.enter", HINT_PART_ENTER), t("hint.navigate", HINT_PART_NAV)];
311
321
  if (question?.multiSelect === true) parts.push(t("hint.toggle", HINT_PART_TOGGLE));
312
- if (question && !state.notesVisible && !state.inputMode) parts.push(t("hint.notes", HINT_PART_NOTES));
322
+ if (question && !state.notesVisible && !state.inputMode)
323
+ parts.push(notesHint("hint.notes", HINT_PART_NOTES_TEMPLATE, notesKey));
313
324
  if (isMulti) parts.push(t("hint.tab", HINT_PART_TAB));
314
325
  parts.push(t("hint.cancel", HINT_PART_CANCEL));
315
326
  if (collapseKey !== COLLAPSE_KEY_OFF) {
@@ -328,10 +339,15 @@ export function buildHintText(
328
339
  * open the note part drops (the editor is the affordance then) and the Shift+Enter
329
340
  * newline hint is appended after cancel, mirroring the question tabs' notes-open shape.
330
341
  */
331
- export function buildSubmitHintText(state: DialogState): string {
342
+ export function buildSubmitHintText(state: DialogState, notesKey: string): string {
332
343
  const parts: string[] = [t("hint.enter", HINT_PART_ENTER), t("hint.navigate", HINT_PART_NAV)];
333
- if (!state.notesVisible) parts.push(t("review.global_hint", REVIEW_GLOBAL_HINT));
344
+ if (!state.notesVisible) parts.push(notesHint("review.global_hint", REVIEW_GLOBAL_HINT_TEMPLATE, notesKey));
334
345
  parts.push(t("hint.cancel", HINT_PART_CANCEL));
335
346
  if (state.notesVisible) parts.push(t("hint.newline", HINT_PART_NEW_LINE));
336
347
  return parts.join(" · ");
337
348
  }
349
+
350
+ /** A notes hint with the configured key in place of `{key}`. */
351
+ function notesHint(key: string, template: string, notesKey: string): string {
352
+ return t(key, template).replace(KEY_PLACEHOLDER, formatNotesKeyForDisplay(notesKey));
353
+ }