feat(ask): refine inline answer and navigation UX

This commit is contained in:
Erik Kotsiuba
2026-04-18 21:14:06 +02:00
parent 87cbfa546e
commit 91f28752a4
12 changed files with 337 additions and 53 deletions
+51
View File
@@ -0,0 +1,51 @@
import assert from "node:assert/strict";
import test from "node:test";
import { applyNumberShortcut, createInitialState, enterQuestionNoteMode } from "../src/state.ts";
import { getInputCommand } from "../src/ui/input.ts";
function inputState() {
let state = createInitialState({
questions: [
{
id: "q1",
prompt: "Question?",
options: [{ value: "a", label: "A" }],
},
],
});
state = applyNumberShortcut(state, 2);
return state;
}
test("editing views let up and down move navigation", () => {
const input = inputState();
assert.deepEqual(getInputCommand(input, "\x1b[A"), {
kind: "editMoveOption",
delta: -1,
});
assert.deepEqual(getInputCommand(input, "\x1b[B"), {
kind: "editMoveOption",
delta: 1,
});
});
test("note editing views let up and down move navigation", () => {
const state = enterQuestionNoteMode(createInitialState({
questions: [
{
id: "q1",
prompt: "Question?",
options: [{ value: "a", label: "A" }],
},
],
}), "q1");
assert.deepEqual(getInputCommand(state, "\x1b[A"), {
kind: "editMoveOption",
delta: -1,
});
assert.deepEqual(getInputCommand(state, "\x1b[B"), {
kind: "editMoveOption",
delta: 1,
});
});