@firstpick/pi-package-webui 0.8.2 → 0.8.4
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 +76 -19
- package/bin/pi-webui.mjs +864 -140
- package/lib/WEBUI_TUI_NATIVE_PARITY.json +26 -0
- package/lib/git-workflow-preferences.mjs +246 -19
- package/lib/optional-feature-catalog.mjs +29 -0
- package/lib/optional-feature-migration.mjs +410 -0
- package/lib/session-summary-core.mjs +320 -0
- package/lib/session-summary-preferences.mjs +267 -0
- package/lib/thinking-stream-recovery.mjs +156 -0
- package/lib/ui-layout-settings.mjs +254 -0
- package/package.json +5 -40
- package/public/app.js +2898 -92
- package/public/index.html +77 -14
- package/public/service-worker.js +1 -1
- package/public/styles.css +669 -2
- package/session-summary.ts +403 -0
- package/tests/aur-review-widget-static.test.mjs +3 -2
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/composer-action-grid-reorder.spec.mjs +303 -0
- package/tests/browser/feature-decision-output-popup.spec.mjs +156 -0
- package/tests/browser/interaction-continuity.spec.mjs +29 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +744 -0
- package/tests/browser/session-summary.spec.mjs +271 -0
- package/tests/codex-fast-mode-static.test.mjs +10 -9
- package/tests/composer-action-grid-reorder-static.test.mjs +63 -0
- package/tests/fast-mode-client-static.test.mjs +2 -2
- package/tests/feature-decision-output-popup-static.test.mjs +172 -0
- package/tests/fixtures/fake-pi.mjs +51 -1
- package/tests/git-workflow-preferences.test.mjs +4 -2
- package/tests/http-endpoints-harness.test.mjs +507 -4
- package/tests/interaction-state-stability-static.test.mjs +3 -0
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +3 -3
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +118 -103
- package/tests/native-parity-harness.test.mjs +9 -1
- package/tests/native-parity.test.mjs +23 -1
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/optional-feature-migration-frontend.test.mjs +72 -0
- package/tests/optional-feature-migration.test.mjs +142 -0
- package/tests/persistent-ui-layout-static.test.mjs +267 -0
- package/tests/questionnaire-dialog.test.mjs +511 -0
- package/tests/queue-edit-reorder-static.test.mjs +1 -0
- package/tests/remote-auth-settings-harness.test.mjs +1 -1
- package/tests/session-summary-core.test.mjs +491 -0
- package/tests/session-summary-preferences.test.mjs +103 -0
- package/tests/side-panel-resize-static.test.mjs +1 -0
- package/tests/side-panel-section-reorder-static.test.mjs +3 -3
- package/tests/subagent-launch-slots.test.mjs +1 -1
- package/tests/thinking-stream-recovery.test.mjs +88 -0
- package/tests/ui-layout-settings.test.mjs +92 -0
- package/tests/webui-settings-locking.test.mjs +159 -0
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import vm from "node:vm";
|
|
4
|
+
|
|
5
|
+
const [app, css, html, serviceWorker] = await Promise.all([
|
|
6
|
+
readFile(new URL("../public/app.js", import.meta.url), "utf8"),
|
|
7
|
+
readFile(new URL("../public/styles.css", import.meta.url), "utf8"),
|
|
8
|
+
readFile(new URL("../public/index.html", import.meta.url), "utf8"),
|
|
9
|
+
readFile(new URL("../public/service-worker.js", import.meta.url), "utf8"),
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
function functionSource(name) {
|
|
13
|
+
const start = app.indexOf(`function ${name}(`);
|
|
14
|
+
assert.notEqual(start, -1, `${name} must exist in app.js`);
|
|
15
|
+
const tail = app.slice(start);
|
|
16
|
+
const end = tail.search(/^}\s*$/m);
|
|
17
|
+
assert.notEqual(end, -1, `${name} must have a complete declaration`);
|
|
18
|
+
return tail.slice(0, end + 1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function branchSource(startMarker, endMarker) {
|
|
22
|
+
const start = app.indexOf(startMarker);
|
|
23
|
+
assert.notEqual(start, -1, `missing branch marker: ${startMarker}`);
|
|
24
|
+
const bodyStart = start + startMarker.length;
|
|
25
|
+
const end = app.indexOf(endMarker, bodyStart);
|
|
26
|
+
assert.notEqual(end, -1, `missing branch end marker: ${endMarker}`);
|
|
27
|
+
return app.slice(bodyStart, end);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
class FakeClassList {
|
|
31
|
+
constructor(node) {
|
|
32
|
+
this.node = node;
|
|
33
|
+
this.values = new Set();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setFromString(value) {
|
|
37
|
+
this.values = new Set(String(value || "").split(/\s+/).filter(Boolean));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
add(...values) {
|
|
41
|
+
for (const value of values) this.values.add(value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
contains(value) {
|
|
45
|
+
return this.values.has(value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
toggle(value, force) {
|
|
49
|
+
const enabled = force === undefined ? !this.values.has(value) : Boolean(force);
|
|
50
|
+
if (enabled) this.values.add(value);
|
|
51
|
+
else this.values.delete(value);
|
|
52
|
+
return enabled;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
toString() {
|
|
56
|
+
return [...this.values].join(" ");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
class FakeNode {
|
|
61
|
+
constructor(tagName) {
|
|
62
|
+
this.tagName = String(tagName).toUpperCase();
|
|
63
|
+
this.children = [];
|
|
64
|
+
this.attributes = new Map();
|
|
65
|
+
this.listeners = new Map();
|
|
66
|
+
this.classList = new FakeClassList(this);
|
|
67
|
+
this.disabled = false;
|
|
68
|
+
this.textContent = "";
|
|
69
|
+
this.value = "";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
set className(value) {
|
|
73
|
+
this.classList.setFromString(value);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get className() {
|
|
77
|
+
return this.classList.toString();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setAttribute(name, value) {
|
|
81
|
+
this.attributes.set(name, String(value));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
getAttribute(name) {
|
|
85
|
+
return this.attributes.get(name) ?? null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
append(...children) {
|
|
89
|
+
this.children.push(...children);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
replaceChildren(...children) {
|
|
93
|
+
this.children = [...children];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
addEventListener(name, listener) {
|
|
97
|
+
const listeners = this.listeners.get(name) || [];
|
|
98
|
+
listeners.push(listener);
|
|
99
|
+
this.listeners.set(name, listeners);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
dispatch(name, event = {}) {
|
|
103
|
+
for (const listener of this.listeners.get(name) || []) listener(event);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
querySelectorAll(selector) {
|
|
107
|
+
assert.equal(selector, "button", "the focused dialog harness only queries buttons");
|
|
108
|
+
const matches = [];
|
|
109
|
+
const visit = (node) => {
|
|
110
|
+
if (node.tagName === "BUTTON") matches.push(node);
|
|
111
|
+
for (const child of node.children || []) visit(child);
|
|
112
|
+
};
|
|
113
|
+
for (const child of this.children) visit(child);
|
|
114
|
+
return matches;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
focus() {
|
|
118
|
+
this.focused = true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const document = { createElement: (tag) => new FakeNode(tag) };
|
|
123
|
+
const constantNames = [
|
|
124
|
+
"QUESTIONNAIRE_TITLE_PATTERN",
|
|
125
|
+
"QUESTIONNAIRE_ROW_PATTERN",
|
|
126
|
+
"QUESTIONNAIRE_STATE_PATTERN",
|
|
127
|
+
"QUESTIONNAIRE_MAX_QUESTIONS",
|
|
128
|
+
"QUESTIONNAIRE_MAX_OPTIONS",
|
|
129
|
+
];
|
|
130
|
+
const constants = constantNames.map((name) => {
|
|
131
|
+
const match = app.match(new RegExp(`^const ${name} = .+;$`, "m"));
|
|
132
|
+
assert.ok(match, `${name} must remain a bounded parser constant`);
|
|
133
|
+
return match[0];
|
|
134
|
+
});
|
|
135
|
+
const helperNames = [
|
|
136
|
+
"make",
|
|
137
|
+
"dialogInputEnterIntent",
|
|
138
|
+
"createDialogResponder",
|
|
139
|
+
"isQuestionnaireChangeOtherAction",
|
|
140
|
+
"questionnaireContinueCount",
|
|
141
|
+
"questionnaireActionKind",
|
|
142
|
+
"parseQuestionnaireOption",
|
|
143
|
+
"questionnaireActionSequenceMatches",
|
|
144
|
+
"questionnaireSelectParts",
|
|
145
|
+
"renderQuestionnaireOptionButton",
|
|
146
|
+
"renderQuestionnaireActionButton",
|
|
147
|
+
];
|
|
148
|
+
const helperSource = [...constants, ...helperNames.map(functionSource)].join("\n\n");
|
|
149
|
+
const context = { document, stripAnsi: (value) => String(value).replace(/\x1b\[[0-9;]*m/g, "") };
|
|
150
|
+
vm.runInNewContext(`${helperSource}\nglobalThis.questionnaireTestApi = { ${helperNames.join(", ")} };`, context, { filename: "questionnaire-app-helpers.js" });
|
|
151
|
+
const helpers = context.questionnaireTestApi;
|
|
152
|
+
|
|
153
|
+
function plain(value) {
|
|
154
|
+
return JSON.parse(JSON.stringify(value));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function keyEvent(overrides = {}) {
|
|
158
|
+
return {
|
|
159
|
+
key: "Enter",
|
|
160
|
+
repeat: false,
|
|
161
|
+
altKey: false,
|
|
162
|
+
ctrlKey: false,
|
|
163
|
+
metaKey: false,
|
|
164
|
+
shiftKey: false,
|
|
165
|
+
isComposing: false,
|
|
166
|
+
keyCode: 13,
|
|
167
|
+
defaultPrevented: false,
|
|
168
|
+
propagationStopped: false,
|
|
169
|
+
preventDefault() { this.defaultPrevented = true; },
|
|
170
|
+
stopPropagation() { this.propagationStopped = true; },
|
|
171
|
+
...overrides,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Exercise the actual input branch extracted from showNextDialog. This proves
|
|
176
|
+
// keyboard and click activation share the same one-shot transport closure.
|
|
177
|
+
const inputBranch = branchSource(' } else if (request.method === "input") {', ' } else if (isWorkflowScriptPreview) {');
|
|
178
|
+
const runInputBranch = new Function(
|
|
179
|
+
"make",
|
|
180
|
+
"elements",
|
|
181
|
+
"request",
|
|
182
|
+
"respondToDialog",
|
|
183
|
+
"dialogInputEnterIntent",
|
|
184
|
+
"addDialogButton",
|
|
185
|
+
"setTimeout",
|
|
186
|
+
"activeDialogCancel",
|
|
187
|
+
inputBranch,
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
function inputHarness(prefill = "") {
|
|
191
|
+
const elements = { dialogBody: new FakeNode("div"), dialogActions: new FakeNode("menu") };
|
|
192
|
+
const responses = [];
|
|
193
|
+
const addDialogButton = (label, handler, className) => {
|
|
194
|
+
const button = new FakeNode("button");
|
|
195
|
+
button.textContent = label;
|
|
196
|
+
button.className = className || "";
|
|
197
|
+
button.addEventListener("click", handler);
|
|
198
|
+
elements.dialogActions.append(button);
|
|
199
|
+
return button;
|
|
200
|
+
};
|
|
201
|
+
runInputBranch(
|
|
202
|
+
(tag, className, text) => {
|
|
203
|
+
const node = new FakeNode(tag);
|
|
204
|
+
node.className = className || "";
|
|
205
|
+
if (text !== undefined) node.textContent = text;
|
|
206
|
+
return node;
|
|
207
|
+
},
|
|
208
|
+
elements,
|
|
209
|
+
{ id: "input-request", tabId: "tab-one", prefill, placeholder: "Type exactly" },
|
|
210
|
+
helpers.createDialogResponder((response) => responses.push({
|
|
211
|
+
type: "extension_ui_response",
|
|
212
|
+
id: "input-request",
|
|
213
|
+
tabId: "tab-one",
|
|
214
|
+
...response,
|
|
215
|
+
})),
|
|
216
|
+
helpers.dialogInputEnterIntent,
|
|
217
|
+
addDialogButton,
|
|
218
|
+
(callback) => callback(),
|
|
219
|
+
null,
|
|
220
|
+
);
|
|
221
|
+
return {
|
|
222
|
+
elements,
|
|
223
|
+
input: elements.dialogBody.children[0],
|
|
224
|
+
cancel: elements.dialogActions.children[0],
|
|
225
|
+
submit: elements.dialogActions.children[1],
|
|
226
|
+
responses,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
{
|
|
231
|
+
const harness = inputHarness("initial");
|
|
232
|
+
harness.input.value = " exact Ω input ";
|
|
233
|
+
const enter = keyEvent();
|
|
234
|
+
harness.input.dispatch("keydown", enter);
|
|
235
|
+
harness.submit.dispatch("click");
|
|
236
|
+
harness.cancel.dispatch("click");
|
|
237
|
+
assert.equal(enter.defaultPrevented, true, "Enter must block method=dialog implicit submission");
|
|
238
|
+
assert.equal(enter.propagationStopped, true, "handled Enter must not activate another control");
|
|
239
|
+
assert.deepEqual(harness.responses, [{
|
|
240
|
+
type: "extension_ui_response",
|
|
241
|
+
id: "input-request",
|
|
242
|
+
tabId: "tab-one",
|
|
243
|
+
value: " exact Ω input ",
|
|
244
|
+
}], "Enter must send the current input exactly once even if click/cancel follow");
|
|
245
|
+
assert.equal(harness.input.disabled, true, "the one-shot guard must disable the input immediately");
|
|
246
|
+
assert.equal(harness.submit.disabled, true, "the one-shot guard must disable Submit immediately");
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
{
|
|
250
|
+
const harness = inputHarness();
|
|
251
|
+
harness.input.value = "click path exact";
|
|
252
|
+
harness.submit.dispatch("click");
|
|
253
|
+
harness.submit.dispatch("click");
|
|
254
|
+
harness.input.dispatch("keydown", keyEvent());
|
|
255
|
+
assert.deepEqual(harness.responses.map((response) => response.value), ["click path exact"], "Submit click must use the same one-shot exact-value guard");
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const cancelActiveExtensionDialogSource = functionSource("cancelActiveExtensionDialog");
|
|
259
|
+
const makeCancelActiveExtensionDialog = new Function(
|
|
260
|
+
"activeDialog",
|
|
261
|
+
"activeDialogCancel",
|
|
262
|
+
`${cancelActiveExtensionDialogSource}; return cancelActiveExtensionDialog;`,
|
|
263
|
+
);
|
|
264
|
+
{
|
|
265
|
+
let cancellationCount = 0;
|
|
266
|
+
let responseSent = false;
|
|
267
|
+
const cancelActiveExtensionDialog = makeCancelActiveExtensionDialog({ id: "active-request" }, () => {
|
|
268
|
+
if (responseSent) return false;
|
|
269
|
+
responseSent = true;
|
|
270
|
+
cancellationCount += 1;
|
|
271
|
+
return true;
|
|
272
|
+
});
|
|
273
|
+
const event = { defaultPrevented: false, preventDefault() { this.defaultPrevented = true; } };
|
|
274
|
+
assert.equal(cancelActiveExtensionDialog(event), true, "native dialog cancellation must route through the active one-shot responder");
|
|
275
|
+
assert.equal(cancelActiveExtensionDialog(event), false, "repeated native cancellation must not send twice");
|
|
276
|
+
assert.equal(event.defaultPrevented, true, "native Escape cancellation must prevent the browser from closing method=dialog directly");
|
|
277
|
+
assert.equal(cancellationCount, 1, "native Escape cancellation must send exactly once");
|
|
278
|
+
const inactiveEvent = { defaultPrevented: false, preventDefault() { this.defaultPrevented = true; } };
|
|
279
|
+
assert.equal(makeCancelActiveExtensionDialog(null, null)(inactiveEvent), false, "inactive dialogs must ignore stray cancel events");
|
|
280
|
+
assert.equal(inactiveEvent.defaultPrevented, false);
|
|
281
|
+
}
|
|
282
|
+
assert.match(app, /elements\.dialog\.addEventListener\("cancel", cancelActiveExtensionDialog\)/, "the native dialog cancel event must use the active response guard");
|
|
283
|
+
{
|
|
284
|
+
const responses = [];
|
|
285
|
+
const respondToDialog = helpers.createDialogResponder((response) => responses.push(response));
|
|
286
|
+
assert.equal(respondToDialog({ value: "first" }), true);
|
|
287
|
+
assert.equal(respondToDialog({ cancelled: true }), false, "all actions for one request must share the same response guard");
|
|
288
|
+
assert.deepEqual(plain(responses), [{ value: "first" }]);
|
|
289
|
+
}
|
|
290
|
+
assert.ok((app.match(/activeDialogCancel = null;/g) || []).length >= 4, "active cancellation state must reset on cleanup, removal, completion, and new render");
|
|
291
|
+
|
|
292
|
+
for (const [label, overrides, intent, prevented] of [
|
|
293
|
+
["composition", { isComposing: true }, "ignore", false],
|
|
294
|
+
["legacy IME", { keyCode: 229 }, "ignore", false],
|
|
295
|
+
["repeat", { repeat: true }, "suppress", true],
|
|
296
|
+
["Alt", { altKey: true }, "suppress", true],
|
|
297
|
+
["Control", { ctrlKey: true }, "suppress", true],
|
|
298
|
+
["Meta", { metaKey: true }, "suppress", true],
|
|
299
|
+
["Shift", { shiftKey: true }, "suppress", true],
|
|
300
|
+
["non-Enter", { key: "a" }, "ignore", false],
|
|
301
|
+
]) {
|
|
302
|
+
const event = keyEvent(overrides);
|
|
303
|
+
assert.equal(helpers.dialogInputEnterIntent(event), intent, `${label} intent must be classified correctly`);
|
|
304
|
+
const harness = inputHarness();
|
|
305
|
+
harness.input.dispatch("keydown", event);
|
|
306
|
+
assert.equal(harness.responses.length, 0, `${label} must not accidentally submit`);
|
|
307
|
+
assert.equal(event.defaultPrevented, prevented, `${label} prevention must match its intent`);
|
|
308
|
+
assert.equal(event.propagationStopped, prevented, `${label} propagation must match its intent`);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const singleOptions = [
|
|
312
|
+
"01. Alpha — First description",
|
|
313
|
+
"02. 同じ — Unicode description",
|
|
314
|
+
"Other… (enter a custom answer)",
|
|
315
|
+
"Ask Pi to clarify…",
|
|
316
|
+
"Cancel questionnaire",
|
|
317
|
+
];
|
|
318
|
+
const single = helpers.questionnaireSelectParts({ title: "Question 1 of 2: Scope" }, singleOptions);
|
|
319
|
+
assert.equal(single?.mode, "single");
|
|
320
|
+
assert.deepEqual(plain(single.rows.slice(0, 2)), [
|
|
321
|
+
{ kind: "option", marker: "none", number: "01", label: "Alpha", description: "First description", value: singleOptions[0] },
|
|
322
|
+
{ kind: "option", marker: "none", number: "02", label: "同じ", description: "Unicode description", value: singleOptions[1] },
|
|
323
|
+
]);
|
|
324
|
+
assert.deepEqual(plain(single.rows.slice(2).map((row) => row.action)), ["other", "clarify", "cancel"], "single actions must receive distinct semantics");
|
|
325
|
+
|
|
326
|
+
const multiOptions = [
|
|
327
|
+
"01. [ ] Alpha — First description",
|
|
328
|
+
"02. [x] Beta",
|
|
329
|
+
"03. [selected] Legacy",
|
|
330
|
+
'Change Other… (currently "quoted \\"value\\"")',
|
|
331
|
+
"Remove Other answer",
|
|
332
|
+
"Ask Pi to clarify…",
|
|
333
|
+
"Continue with 3 selection(s)",
|
|
334
|
+
"Cancel questionnaire",
|
|
335
|
+
];
|
|
336
|
+
const multi = helpers.questionnaireSelectParts({ title: "Question 2 of 2: Features" }, multiOptions);
|
|
337
|
+
assert.equal(multi?.mode, "multi");
|
|
338
|
+
assert.deepEqual(plain(multi.rows.slice(0, 3).map((row) => row.marker)), ["unselected", "selected", "selected"], "[x] and legacy [selected] must preserve selected semantics");
|
|
339
|
+
assert.deepEqual(plain(multi.rows.slice(3).map((row) => row.action)), ["other", "remove-other", "clarify", "continue", "cancel"], "multi actions must remain explicitly classified");
|
|
340
|
+
for (const count of [0, 51]) {
|
|
341
|
+
assert.equal(helpers.questionnaireContinueCount(`Continue with ${count} selection(s)`), count, `runtime boundary count ${count} must be accepted`);
|
|
342
|
+
}
|
|
343
|
+
for (const count of [52, "999999999999999999999999999999999999"]) {
|
|
344
|
+
assert.equal(helpers.questionnaireContinueCount(`Continue with ${count} selection(s)`), null, `impossible count ${count} must be rejected`);
|
|
345
|
+
assert.equal(helpers.questionnaireActionKind(`Continue with ${count} selection(s)`), null);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const singleButton = helpers.renderQuestionnaireOptionButton(single.rows[0], single.mode);
|
|
349
|
+
assert.equal(singleButton.classList.contains("questionnaire-option-single"), true);
|
|
350
|
+
assert.equal(singleButton.getAttribute("aria-label"), singleOptions[0], "semantic rendering must retain the exact native accessible label");
|
|
351
|
+
assert.equal(singleButton.getAttribute("aria-pressed"), null, "single answers must not advertise toggle state");
|
|
352
|
+
assert.deepEqual(singleButton.children.map((child) => child.className), ["questionnaire-option-number", "questionnaire-option-text"]);
|
|
353
|
+
assert.deepEqual(singleButton.children[1].children.map((child) => child.className), ["questionnaire-option-label", "questionnaire-option-description"]);
|
|
354
|
+
|
|
355
|
+
const unselectedButton = helpers.renderQuestionnaireOptionButton(multi.rows[0], multi.mode);
|
|
356
|
+
const selectedButton = helpers.renderQuestionnaireOptionButton(multi.rows[1], multi.mode);
|
|
357
|
+
assert.equal(unselectedButton.getAttribute("aria-pressed"), "false");
|
|
358
|
+
assert.equal(selectedButton.getAttribute("aria-pressed"), "true");
|
|
359
|
+
assert.equal(selectedButton.classList.contains("is-selected"), true);
|
|
360
|
+
assert.deepEqual(selectedButton.children.map((child) => child.className), ["questionnaire-option-number", "questionnaire-option-state", "questionnaire-option-text"]);
|
|
361
|
+
assert.equal(selectedButton.children[1].getAttribute("aria-hidden"), "true", "the decorative check must not duplicate the exact accessible name");
|
|
362
|
+
for (const row of multi.rows.slice(3)) {
|
|
363
|
+
const button = helpers.renderQuestionnaireActionButton(row);
|
|
364
|
+
assert.equal(button.classList.contains(`questionnaire-action-${row.action}`), true, `${row.action} requires a semantic class`);
|
|
365
|
+
assert.equal(button.classList.contains("primary"), row.action === "continue", "only Continue is the primary questionnaire action");
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
for (const [name, title, options] of [
|
|
369
|
+
["non-question title", "Choose a feature", singleOptions],
|
|
370
|
+
["out-of-range progress", "Question 3 of 2: Scope", singleOptions],
|
|
371
|
+
["bad numbering", "Question 1 of 2: Scope", ["02. Alpha", ...singleOptions.slice(2)]],
|
|
372
|
+
["mixed modes", "Question 1 of 2: Scope", ["01. Alpha", "02. [ ] Beta", "Ask Pi to clarify…", "Cancel questionnaire"]],
|
|
373
|
+
["unknown action", "Question 1 of 2: Scope", ["01. Alpha", "Do something", "Ask Pi to clarify…", "Cancel questionnaire"]],
|
|
374
|
+
["missing action tail", "Question 1 of 2: Scope", ["01. Alpha", "Cancel questionnaire"]],
|
|
375
|
+
["noncanonical Other JSON", "Question 1 of 2: Scope", ["01. [ ] Alpha", 'Change Other… (currently "\\u0041")', "Remove Other answer", "Ask Pi to clarify…", "Continue with 1 selection(s)", "Cancel questionnaire"]],
|
|
376
|
+
]) {
|
|
377
|
+
assert.equal(helpers.questionnaireSelectParts({ title }, options), null, `${name} must use generic select rendering`);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// Execute the actual questionnaire response branch to prove exact option
|
|
381
|
+
// transport and its click/cancel race guard, not just parser output.
|
|
382
|
+
const questionnaireBranch = branchSource(" if (questionnaire) {", ' } else if (request.method === "select") {');
|
|
383
|
+
const runQuestionnaireBranch = new Function(
|
|
384
|
+
"make",
|
|
385
|
+
"elements",
|
|
386
|
+
"request",
|
|
387
|
+
"questionnaire",
|
|
388
|
+
"respondToDialog",
|
|
389
|
+
"renderQuestionnaireActionButton",
|
|
390
|
+
"renderQuestionnaireOptionButton",
|
|
391
|
+
"addDialogButton",
|
|
392
|
+
"activeDialogCancel",
|
|
393
|
+
questionnaireBranch,
|
|
394
|
+
);
|
|
395
|
+
|
|
396
|
+
{
|
|
397
|
+
const elements = { dialogBody: new FakeNode("div"), dialogActions: new FakeNode("menu") };
|
|
398
|
+
const responses = [];
|
|
399
|
+
const addDialogButton = (label, handler, className) => {
|
|
400
|
+
const button = new FakeNode("button");
|
|
401
|
+
button.textContent = label;
|
|
402
|
+
button.className = className || "";
|
|
403
|
+
button.addEventListener("click", handler);
|
|
404
|
+
elements.dialogActions.append(button);
|
|
405
|
+
return button;
|
|
406
|
+
};
|
|
407
|
+
runQuestionnaireBranch(
|
|
408
|
+
(tag, className, text) => {
|
|
409
|
+
const node = new FakeNode(tag);
|
|
410
|
+
node.className = className || "";
|
|
411
|
+
if (text !== undefined) node.textContent = text;
|
|
412
|
+
return node;
|
|
413
|
+
},
|
|
414
|
+
elements,
|
|
415
|
+
{ id: "select-request", tabId: "tab-two", options: multiOptions },
|
|
416
|
+
multi,
|
|
417
|
+
helpers.createDialogResponder((response) => responses.push({
|
|
418
|
+
type: "extension_ui_response",
|
|
419
|
+
id: "select-request",
|
|
420
|
+
tabId: "tab-two",
|
|
421
|
+
...response,
|
|
422
|
+
})),
|
|
423
|
+
helpers.renderQuestionnaireActionButton,
|
|
424
|
+
helpers.renderQuestionnaireOptionButton,
|
|
425
|
+
addDialogButton,
|
|
426
|
+
null,
|
|
427
|
+
);
|
|
428
|
+
const optionButtons = elements.dialogBody.children[0].children;
|
|
429
|
+
optionButtons[2].dispatch("click");
|
|
430
|
+
optionButtons[6].dispatch("click");
|
|
431
|
+
elements.dialogActions.children[0].dispatch("click");
|
|
432
|
+
assert.deepEqual(responses, [{
|
|
433
|
+
type: "extension_ui_response",
|
|
434
|
+
id: "select-request",
|
|
435
|
+
tabId: "tab-two",
|
|
436
|
+
value: "03. [selected] Legacy",
|
|
437
|
+
}], "parsed option clicks must send the untouched native string exactly once");
|
|
438
|
+
assert.equal(optionButtons.every((button) => button.disabled), true, "one response must disable every questionnaire option/action");
|
|
439
|
+
assert.equal(elements.dialogActions.children[0].disabled, true, "one response must disable footer Cancel");
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// Non-questionnaire selects still follow the generic exact-string branch.
|
|
443
|
+
const genericSelectBranch = branchSource(' } else if (request.method === "select") {', ' } else if (request.method === "confirm") {');
|
|
444
|
+
const runGenericSelectBranch = new Function(
|
|
445
|
+
"make",
|
|
446
|
+
"elements",
|
|
447
|
+
"request",
|
|
448
|
+
"isGuardrailDialog",
|
|
449
|
+
"isReleaseDialog",
|
|
450
|
+
"respondToDialog",
|
|
451
|
+
"addDialogButton",
|
|
452
|
+
"cancel",
|
|
453
|
+
genericSelectBranch,
|
|
454
|
+
);
|
|
455
|
+
{
|
|
456
|
+
const elements = { dialogBody: new FakeNode("div"), dialogActions: new FakeNode("menu") };
|
|
457
|
+
const responses = [];
|
|
458
|
+
const addDialogButton = (label, handler) => {
|
|
459
|
+
const button = new FakeNode("button");
|
|
460
|
+
button.textContent = label;
|
|
461
|
+
button.addEventListener("click", handler);
|
|
462
|
+
elements.dialogActions.append(button);
|
|
463
|
+
};
|
|
464
|
+
const options = ["plain choice", "01. lookalike — unchanged"];
|
|
465
|
+
const respondToDialog = helpers.createDialogResponder((response) => responses.push({
|
|
466
|
+
type: "extension_ui_response",
|
|
467
|
+
id: "generic-request",
|
|
468
|
+
tabId: "tab-three",
|
|
469
|
+
...response,
|
|
470
|
+
}));
|
|
471
|
+
runGenericSelectBranch(
|
|
472
|
+
(tag, className, text) => {
|
|
473
|
+
const node = new FakeNode(tag);
|
|
474
|
+
node.className = className || "";
|
|
475
|
+
if (text !== undefined) node.textContent = text;
|
|
476
|
+
return node;
|
|
477
|
+
},
|
|
478
|
+
elements,
|
|
479
|
+
{ id: "generic-request", tabId: "tab-three", options },
|
|
480
|
+
false,
|
|
481
|
+
false,
|
|
482
|
+
respondToDialog,
|
|
483
|
+
addDialogButton,
|
|
484
|
+
() => respondToDialog({ cancelled: true }),
|
|
485
|
+
);
|
|
486
|
+
assert.deepEqual(elements.dialogBody.children[0].children.map((button) => button.textContent), options, "generic select labels must remain unsplit");
|
|
487
|
+
elements.dialogBody.children[0].children[1].dispatch("click");
|
|
488
|
+
elements.dialogActions.children[0].dispatch("click");
|
|
489
|
+
assert.equal(responses[0].value, options[1], "generic fallback must retain exact transport");
|
|
490
|
+
assert.equal(responses.length, 1, "generic option click and Escape/Cancel must share the one-shot responder");
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
assert.equal((app.match(/sendDialogResponse\(/g) || []).length, 2, "all dialog actions must route through the one per-request responder");
|
|
494
|
+
assert.match(app, /elements\.dialog\.classList\.toggle\("questionnaire-dialog", !!questionnaire\)/, "each render must add or remove questionnaire scope");
|
|
495
|
+
assert.doesNotMatch(app, /request\.method\s*===\s*["']questionnaire["']|method\s*:\s*["']questionnaire["']/, "presentation must not introduce a questionnaire RPC method");
|
|
496
|
+
assert.match(html, /<dialog id="extensionDialog" class="extension-dialog" aria-labelledby="dialogTitle" aria-describedby="dialogMessage">/, "the native extension dialog needs an explicit accessible name and description");
|
|
497
|
+
|
|
498
|
+
assert.match(css, /\.extension-dialog\.questionnaire-dialog\s*\{[\s\S]*?max-height:[\s\S]*?overflow:\s*hidden/, "desktop questionnaire layout must have bounded scrolling");
|
|
499
|
+
assert.match(css, /\.questionnaire-option-single\s*\{\s*grid-template-columns:\s*2\.55rem minmax\(0, 1fr\)/, "single rows must separate number and label columns");
|
|
500
|
+
assert.match(css, /\.questionnaire-option-multi\s*\{\s*grid-template-columns:\s*2\.55rem 2rem minmax\(0, 1fr\)/, "multi rows must separate number, state, and label columns");
|
|
501
|
+
assert.match(css, /\.questionnaire-option-multi\.is-selected[\s\S]*?var\(--ctp-green\)/, "selected multi rows need a non-marker visual state");
|
|
502
|
+
assert.match(css, /\.questionnaire-action:focus-visible,[\s\S]*?outline:\s*3px solid/, "questionnaire actions need visible keyboard focus");
|
|
503
|
+
assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(pointer: coarse\) and \(hover: none\)[\s\S]*?\.extension-dialog\.questionnaire-dialog[\s\S]*?width:\s*100vw[\s\S]*?\.questionnaire-dialog form \{[\s\S]*?2\.5rem[\s\S]*?\.questionnaire-dialog #dialogActions[\s\S]*?grid-template-columns:\s*minmax\(0, 1fr\)[\s\S]*?env\(safe-area-inset-bottom\)/, "phone/coarse-pointer questionnaires must use a safe-area-aware one-column bottom sheet with content-box headroom");
|
|
504
|
+
assert.match(css, /\.questionnaire-options button\s*\{\s*min-height:\s*3\.35rem/, "mobile questionnaire targets must exceed the 44px floor");
|
|
505
|
+
assert.match(css, /@media \(prefers-reduced-motion: reduce\)\s*\{[\s\S]*?\*, \*::before, \*::after[\s\S]*?transition-duration:\s*1ms !important/, "global reduced-motion rules must cover questionnaire transitions");
|
|
506
|
+
|
|
507
|
+
assert.match(html, /styles\.css\?v=98/, "questionnaire CSS needs the current stylesheet revision");
|
|
508
|
+
assert.match(html, /app\.js\?v=112/, "questionnaire behavior needs the current app revision");
|
|
509
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v71"/, "questionnaire public assets need a coherent PWA cache revision");
|
|
510
|
+
|
|
511
|
+
console.log("questionnaire-dialog.test.mjs passed");
|
|
@@ -17,6 +17,7 @@ assert.match(
|
|
|
17
17
|
"the composer should expose a count trigger and accessible non-modal follow-up queue overlay",
|
|
18
18
|
);
|
|
19
19
|
assert.match(css, /\.follow-up-queue-overlay \{[\s\S]*position:\s*absolute;[\s\S]*bottom:\s*calc\(100% \+ 0\.42rem\);[\s\S]*max-height:\s*min\(32rem, calc\(var\(--visual-viewport-height, 100dvh\) - 2rem\)\)/, "the queue overlay should float upward without changing composer layout and be bounded by the visual viewport");
|
|
20
|
+
assert.match(css, /\.composer:has\(\.follow-up-queue-overlay:not\(\[hidden\]\)\) \{\s*z-index:\s*80;\s*\}/, "an open queue should raise the composer stacking context above transcript copy buttons and normal interface controls");
|
|
20
21
|
assert.match(css, /\.follow-up-queue-trigger \{[\s\S]*justify-content:\s*center;[\s\S]*min-width:\s*5\.25rem;/, "the queue trigger should reserve a predictable width for its label and three-digit count");
|
|
21
22
|
assert.match(css, /body:not\(\.mobile-keyboard-open\) \.composer-input-row:has\(\.composer-workflow-mode-dock:not\(\[hidden\]\)\) \.follow-up-queue-trigger \{\s*right:\s*calc\(3\.55rem \+ 2\.25rem \+ 0\.4rem\);\s*\}/, "the queue trigger should move left of the visible Workflow control instead of overlapping it");
|
|
22
23
|
assert.match(css, /\.composer-input-row:has\(\.follow-up-queue-trigger:not\(\[hidden\]\)\) \.composer-context-tags \{\s*max-width:\s*max\(0px, calc\(100% - 9\.7rem\)\);\s*\}/, "visible queues should reserve prompt-frame space so feature and context tags cannot overlap the queue trigger");
|
|
@@ -136,7 +136,7 @@ try {
|
|
|
136
136
|
const disableAuth = await request("/api/remote-auth/settings", { method: "POST", body: { enabled: false } });
|
|
137
137
|
assert.equal(disableAuth.status, 200);
|
|
138
138
|
const savedAfterDisable = JSON.parse(await readFile(settingsFile, "utf8"));
|
|
139
|
-
assert.equal(savedAfterDisable.version,
|
|
139
|
+
assert.equal(savedAfterDisable.version, 6, "Web UI settings should retain the current private settings envelope version");
|
|
140
140
|
assert.equal(savedAfterDisable.remoteAuthEnabled, false, "disabling Remote PIN auth should persist the off preference");
|
|
141
141
|
assert.equal(savedAfterDisable.gitWorkflow?.generation?.modelId, "fake-model", "Remote PIN updates should preserve guided Git preferences");
|
|
142
142
|
|