@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.
Files changed (52) hide show
  1. package/README.md +76 -19
  2. package/bin/pi-webui.mjs +864 -140
  3. package/lib/WEBUI_TUI_NATIVE_PARITY.json +26 -0
  4. package/lib/git-workflow-preferences.mjs +246 -19
  5. package/lib/optional-feature-catalog.mjs +29 -0
  6. package/lib/optional-feature-migration.mjs +410 -0
  7. package/lib/session-summary-core.mjs +320 -0
  8. package/lib/session-summary-preferences.mjs +267 -0
  9. package/lib/thinking-stream-recovery.mjs +156 -0
  10. package/lib/ui-layout-settings.mjs +254 -0
  11. package/package.json +5 -40
  12. package/public/app.js +2898 -92
  13. package/public/index.html +77 -14
  14. package/public/service-worker.js +1 -1
  15. package/public/styles.css +669 -2
  16. package/session-summary.ts +403 -0
  17. package/tests/aur-review-widget-static.test.mjs +3 -2
  18. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  19. package/tests/browser/composer-action-grid-reorder.spec.mjs +303 -0
  20. package/tests/browser/feature-decision-output-popup.spec.mjs +156 -0
  21. package/tests/browser/interaction-continuity.spec.mjs +29 -0
  22. package/tests/browser/persistent-ui-layout.spec.mjs +744 -0
  23. package/tests/browser/session-summary.spec.mjs +271 -0
  24. package/tests/codex-fast-mode-static.test.mjs +10 -9
  25. package/tests/composer-action-grid-reorder-static.test.mjs +63 -0
  26. package/tests/fast-mode-client-static.test.mjs +2 -2
  27. package/tests/feature-decision-output-popup-static.test.mjs +172 -0
  28. package/tests/fixtures/fake-pi.mjs +51 -1
  29. package/tests/git-workflow-preferences.test.mjs +4 -2
  30. package/tests/http-endpoints-harness.test.mjs +507 -4
  31. package/tests/interaction-state-stability-static.test.mjs +3 -0
  32. package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
  33. package/tests/mobile-foundation-static.test.mjs +3 -3
  34. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  35. package/tests/mobile-static.test.mjs +118 -103
  36. package/tests/native-parity-harness.test.mjs +9 -1
  37. package/tests/native-parity.test.mjs +23 -1
  38. package/tests/open-issue-wizard-static.test.mjs +1 -1
  39. package/tests/optional-feature-migration-frontend.test.mjs +72 -0
  40. package/tests/optional-feature-migration.test.mjs +142 -0
  41. package/tests/persistent-ui-layout-static.test.mjs +267 -0
  42. package/tests/questionnaire-dialog.test.mjs +511 -0
  43. package/tests/queue-edit-reorder-static.test.mjs +1 -0
  44. package/tests/remote-auth-settings-harness.test.mjs +1 -1
  45. package/tests/session-summary-core.test.mjs +491 -0
  46. package/tests/session-summary-preferences.test.mjs +103 -0
  47. package/tests/side-panel-resize-static.test.mjs +1 -0
  48. package/tests/side-panel-section-reorder-static.test.mjs +3 -3
  49. package/tests/subagent-launch-slots.test.mjs +1 -1
  50. package/tests/thinking-stream-recovery.test.mjs +88 -0
  51. package/tests/ui-layout-settings.test.mjs +92 -0
  52. package/tests/webui-settings-locking.test.mjs +159 -0
@@ -349,6 +349,19 @@ function runTranscriptContinuityScenario(scenario) {
349
349
  { afterMs: 650, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "thinking_delta", delta: " survives" } })) },
350
350
  );
351
351
  finish({ role: "assistant", content: [{ type: "thinking", thinking: "thinking selection literal survives" }, { type: "text", text: "thinking final answer" }], timestamp: Date.now() }, 450);
352
+ } else if (scenario === "order") {
353
+ const toolCallId = `continuity-order-${run}`;
354
+ const toolCall = { type: "toolCall", id: toolCallId, name: "read", arguments: { path: "order.txt" } };
355
+ start();
356
+ steps.push(
357
+ { afterMs: 120, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "thinking_delta", delta: "ordering thinking" } })) },
358
+ { afterMs: 500, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: "ordering assistant output" } })) },
359
+ { afterMs: 1_000, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "toolcall_start", contentIndex: 2, name: "read", toolCall } })) },
360
+ { afterMs: 100, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "toolcall_delta", contentIndex: 2, name: "read", toolCall, delta: "" } })) },
361
+ { afterMs: 200, run: () => emitScriptedEvent(tagged({ type: "webui_supervisor_reconnected", supervisorScopeId: `continuity-order-${run}`, supervisorEpoch: "1", supervisorSeq: "1" })) },
362
+ { afterMs: 800, run: () => emitScriptedEvent(tagged({ type: "message_update", assistantMessageEvent: { type: "toolcall_end", contentIndex: 2, name: "read", toolCall } })) },
363
+ );
364
+ finish({ role: "assistant", content: [{ type: "thinking", thinking: "ordering thinking" }, toolCall], timestamp: Date.now() }, 700);
352
365
  } else if (scenario === "tool") {
353
366
  const toolCallId = `continuity-tool-${run}`;
354
367
  const toolOutput = (revision) => [
@@ -414,7 +427,7 @@ function runTranscriptContinuityScenario(scenario) {
414
427
 
415
428
  function handleTranscriptContinuityPrompt(command, base) {
416
429
  if (!continuityModeEnabled) return false;
417
- const match = String(command.message || "").trim().match(/^fixture transcript continuity (reverse|duplicate|pointer|thinking|tool|authoritative|cadence|dwell|mode|mermaid)$/);
430
+ const match = String(command.message || "").trim().match(/^fixture transcript continuity (reverse|duplicate|pointer|thinking|order|tool|authoritative|cadence|dwell|mode|mermaid)$/);
418
431
  if (!match) return false;
419
432
  appendDynamicMessage({ role: "user", content: String(command.message), timestamp: Date.now() });
420
433
  respond({ ...base, data: { output: `fake transcript continuity ${match[1]} accepted`, pid: process.pid } });
@@ -1005,6 +1018,42 @@ function statsPromptContextFixturePayload({ malformedSnapshot = false } = {}) {
1005
1018
  return payload;
1006
1019
  }
1007
1020
 
1021
+ const FEATURE_DECISION_FIXTURE_REASONS = {
1022
+ lightweight: "One localized WebUI slice with no migration or rollout work.",
1023
+ complex: "Crosses the classifier extension and the WebUI status consumer.",
1024
+ };
1025
+
1026
+ function featureDecisionFixturePayload(mode) {
1027
+ if (mode === "lightweight" || mode === "complex") {
1028
+ return {
1029
+ output: JSON.stringify({ kind: `feature_${mode}`, reason: FEATURE_DECISION_FIXTURE_REASONS[mode] }),
1030
+ category: `${mode}-feature`,
1031
+ };
1032
+ }
1033
+ // Legacy exact-label payload from a classifier build that predates the structured contract.
1034
+ if (mode === "legacy") return { output: "feature_complex", category: "complex-feature" };
1035
+ // Structured decision whose kind contradicts the category; the popup must stay unavailable.
1036
+ if (mode === "mismatch") {
1037
+ return {
1038
+ output: JSON.stringify({ kind: "feature_lightweight", reason: FEATURE_DECISION_FIXTURE_REASONS.lightweight }),
1039
+ category: "complex-feature",
1040
+ };
1041
+ }
1042
+ if (mode === "malformed") return { output: '{"kind":"feature_complex"}', category: "complex-feature" };
1043
+ return { output: undefined, category: undefined };
1044
+ }
1045
+
1046
+ function handleFeatureDecisionFixturePrompt(command, base) {
1047
+ const match = String(command.message || "").trim().match(/^fixture feature decision (lightweight|complex|legacy|mismatch|malformed|clear)$/);
1048
+ if (!match) return false;
1049
+ const mode = match[1];
1050
+ const { output, category } = featureDecisionFixturePayload(mode);
1051
+ respond({ ...base, data: { output: `fake feature decision ${mode} emitted` } });
1052
+ emitEvent({ type: "extension_ui_request", id: randomUUID(), method: "setStatus", statusKey: "feature-decision-output", statusText: output });
1053
+ emitEvent({ type: "extension_ui_request", id: randomUUID(), method: "setStatus", statusKey: "feature-category", statusText: category });
1054
+ return true;
1055
+ }
1056
+
1008
1057
  function handleStatsPromptContextFixturePrompt(command, base) {
1009
1058
  if (!statsPromptContextEnabled) return false;
1010
1059
  const message = String(command.message || "").trim();
@@ -1110,6 +1159,7 @@ rl.on("line", (line) => {
1110
1159
  return;
1111
1160
  }
1112
1161
  case "prompt":
1162
+ if (handleFeatureDecisionFixturePrompt(command, base)) return;
1113
1163
  if (handleStatsPromptContextFixturePrompt(command, base)) return;
1114
1164
  if (handleWebuiHelperPrompt(command, base)) return;
1115
1165
  if (handleFastModeFixturePrompt(command, base)) return;
@@ -36,7 +36,7 @@ const settingsFile = path.join(root, "settings.json");
36
36
  try {
37
37
  await writeFile(settingsFile, `${JSON.stringify({ version: 1, remoteAuthEnabled: true }, null, 2)}\n`, "utf8");
38
38
  const migrated = await readWebuiSettings(settingsFile);
39
- assert.equal(migrated.version, 4);
39
+ assert.equal(migrated.version, 6);
40
40
  assert.equal(migrated.remoteAuthEnabled, true, "legacy Remote PIN state should survive schema migration");
41
41
  assert.equal(migrated.outputModeDefault, "normal", "legacy settings should default browser output to normal");
42
42
  assert.equal(isGitWorkflowSetupComplete(migrated.gitWorkflow), false);
@@ -44,6 +44,8 @@ try {
44
44
  assert.equal(migrated.resourceDefaults.skills.enabledSkills, null, "legacy settings should inherit Pi's normal skill defaults");
45
45
  assert.equal(migrated.gitWorkflow.stagingPolicy, "review");
46
46
  assert.equal(migrated.gitWorkflow.generation.thinkingLevel, "low");
47
+ assert.equal(migrated.uiLayout.version, 1);
48
+ assert.equal(migrated.uiLayout.sidePanel.sectionOrder, null);
47
49
 
48
50
  await writeFile(settingsFile, `${JSON.stringify({ version: 4, remoteAuthEnabled: true, outputModeDefault: "unsupported" }, null, 2)}\n`, "utf8");
49
51
  assert.equal((await readWebuiSettings(settingsFile)).outputModeDefault, "normal", "invalid persisted output modes must fail closed to normal");
@@ -76,7 +78,7 @@ try {
76
78
  assert.equal(partiallyUpdated.deliveryMode, "current");
77
79
 
78
80
  const persisted = JSON.parse(await readFile(settingsFile, "utf8"));
79
- assert.equal(persisted.version, 4);
81
+ assert.equal(persisted.version, 6);
80
82
  assert.equal(persisted.remoteAuthEnabled, true);
81
83
  assert.equal(persisted.outputModeDefault, "compact-v1", "output-mode default should persist beside existing Web UI settings");
82
84
  assert.equal(persisted.gitWorkflow.generation.provider, "fake");