@firstpick/pi-package-webui 0.8.3 → 0.8.5

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 (35) hide show
  1. package/README.md +67 -16
  2. package/bin/pi-webui.mjs +777 -131
  3. package/lib/WEBUI_TUI_NATIVE_PARITY.json +26 -0
  4. package/lib/optional-feature-catalog.mjs +29 -0
  5. package/lib/optional-feature-migration.mjs +410 -0
  6. package/lib/session-summary-core.mjs +320 -0
  7. package/lib/session-summary-preferences.mjs +267 -0
  8. package/package.json +5 -42
  9. package/public/app.js +1325 -51
  10. package/public/index.html +43 -1
  11. package/public/service-worker.js +1 -1
  12. package/public/styles.css +345 -1
  13. package/session-summary.ts +403 -0
  14. package/tests/aur-review-widget-static.test.mjs +3 -2
  15. package/tests/boot-failure-diagnostics.test.mjs +2 -2
  16. package/tests/browser/session-summary.spec.mjs +271 -0
  17. package/tests/codex-fast-mode-static.test.mjs +10 -9
  18. package/tests/composer-action-grid-reorder-static.test.mjs +2 -2
  19. package/tests/fast-mode-client-static.test.mjs +1 -1
  20. package/tests/feature-decision-output-popup-static.test.mjs +1 -1
  21. package/tests/http-endpoints-harness.test.mjs +429 -3
  22. package/tests/mobile-continuity-tablet-static.test.mjs +2 -2
  23. package/tests/mobile-foundation-static.test.mjs +2 -2
  24. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  25. package/tests/mobile-static.test.mjs +91 -92
  26. package/tests/native-parity-harness.test.mjs +9 -1
  27. package/tests/native-parity.test.mjs +23 -1
  28. package/tests/open-issue-wizard-static.test.mjs +1 -1
  29. package/tests/optional-feature-migration-frontend.test.mjs +75 -0
  30. package/tests/optional-feature-migration.test.mjs +142 -0
  31. package/tests/persistent-ui-layout-static.test.mjs +2 -2
  32. package/tests/questionnaire-dialog.test.mjs +2 -2
  33. package/tests/session-summary-core.test.mjs +491 -0
  34. package/tests/session-summary-preferences.test.mjs +103 -0
  35. package/tests/side-panel-section-reorder-static.test.mjs +2 -2
@@ -0,0 +1,103 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import {
6
+ DEFAULT_SUMMARY_PROMPT,
7
+ DEFAULT_TITLE_PROMPT,
8
+ SESSION_SUMMARY_PROMPT_MAX_CHARS,
9
+ defaultSessionSummaryPreferences,
10
+ mergeSessionSummaryPreferences,
11
+ normalizeSessionSummaryPreferences,
12
+ readSessionSummaryPreferences,
13
+ sessionSummaryConfigFile,
14
+ supportedSessionSummaryThinkingLevels,
15
+ writeSessionSummaryPreferences,
16
+ } from "../lib/session-summary-preferences.mjs";
17
+
18
+ const defaults = defaultSessionSummaryPreferences();
19
+ assert.deepEqual(defaults.model, { provider: "openai-codex", modelId: "gpt-5.6-luna", thinkingLevel: "low" });
20
+ assert.equal(defaults.configured, false);
21
+ assert.equal(defaults.enabled, false);
22
+ assert.equal(defaults.context.injectLatest, false);
23
+ assert.deepEqual(defaults.title, { enabled: true, minSettledTurns: 3 });
24
+ assert.equal(defaults.input.scope, "text-and-tool-names");
25
+
26
+ const normalized = normalizeSessionSummaryPreferences({
27
+ version: 7,
28
+ configured: true,
29
+ enabled: true,
30
+ futureTopLevel: { retained: true },
31
+ model: { provider: " custom ", modelId: " model ", thinkingLevel: "invalid", futureModel: 42 },
32
+ prompts: { title: " ", summary: "x".repeat(SESSION_SUMMARY_PROMPT_MAX_CHARS + 10), futurePrompt: true },
33
+ input: { scope: "unsafe", futureInput: true },
34
+ context: { injectLatest: true, futureContext: true },
35
+ title: { enabled: false, minSettledTurns: 99, futureTitle: true },
36
+ });
37
+ assert.equal(normalized.version, 7, "newer config versions survive normalization");
38
+ assert.equal(normalized.configured, false, "newer config versions fail closed");
39
+ assert.equal(normalized.enabled, false, "newer config versions cannot trigger generation");
40
+ assert.deepEqual(normalized.futureTopLevel, { retained: true });
41
+ assert.equal(normalized.model.provider, "custom");
42
+ assert.equal(normalized.model.modelId, "model");
43
+ assert.equal(normalized.model.thinkingLevel, "low");
44
+ assert.equal(normalized.model.futureModel, 42);
45
+ assert.equal(normalized.prompts.title, DEFAULT_TITLE_PROMPT);
46
+ assert.equal(normalized.prompts.summary.length, SESSION_SUMMARY_PROMPT_MAX_CHARS);
47
+ assert.equal(normalized.prompts.futurePrompt, true);
48
+ assert.equal(normalized.input.scope, "text-and-tool-names", "privacy scope is immutable");
49
+ assert.equal(normalized.context.injectLatest, true);
50
+ assert.deepEqual(normalized.title, { enabled: false, minSettledTurns: 20, futureTitle: true });
51
+
52
+ assert.equal(normalizeSessionSummaryPreferences({ configured: false, enabled: true }).enabled, false, "automatic generation fails closed until configured");
53
+ const merged = mergeSessionSummaryPreferences(normalized, { model: { modelId: "next" }, title: { minSettledTurns: 1 } });
54
+ assert.equal(merged.model.provider, "custom");
55
+ assert.equal(merged.model.modelId, "next");
56
+ assert.equal(merged.model.futureModel, 42);
57
+ assert.equal(merged.title.minSettledTurns, 1);
58
+ assert.equal(merged.title.futureTitle, true);
59
+
60
+ assert.deepEqual(supportedSessionSummaryThinkingLevels({ reasoning: false }), ["off"]);
61
+ assert.deepEqual(
62
+ supportedSessionSummaryThinkingLevels({ reasoning: true, thinkingLevelMap: { xhigh: null, max: "max" } }),
63
+ ["off", "minimal", "low", "medium", "high", "max"],
64
+ );
65
+
66
+ const directory = await mkdtemp(join(tmpdir(), "session-summary-preferences-"));
67
+ try {
68
+ const storageFile = join(directory, "nested", "summary.json");
69
+ assert.equal(sessionSummaryConfigFile({ PI_SESSION_SUMMARY_CONFIG_FILE: storageFile }), storageFile);
70
+ assert.equal((await readSessionSummaryPreferences(storageFile)).configured, false);
71
+
72
+ await writeSessionSummaryPreferences({
73
+ configured: true,
74
+ enabled: true,
75
+ model: { provider: "openai-codex", modelId: "gpt-5.6-luna", thinkingLevel: "low" },
76
+ unknown: "keep",
77
+ prompts: { title: "One", summary: "Two", unknownPrompt: "keep" },
78
+ }, storageFile);
79
+ let persisted = JSON.parse(await readFile(storageFile, "utf8"));
80
+ assert.equal(persisted.unknown, "keep");
81
+ assert.equal(persisted.prompts.unknownPrompt, "keep");
82
+ if (process.platform !== "win32") assert.equal((await stat(storageFile)).mode & 0o777, 0o600);
83
+
84
+ await Promise.all([
85
+ writeSessionSummaryPreferences({ context: { injectLatest: true } }, storageFile),
86
+ writeSessionSummaryPreferences({ title: { minSettledTurns: 5 } }, storageFile),
87
+ ]);
88
+ persisted = JSON.parse(await readFile(storageFile, "utf8"));
89
+ assert.equal(persisted.context.injectLatest, true, "serialized updates preserve concurrent patches");
90
+ assert.equal(persisted.title.minSettledTurns, 5);
91
+ assert.equal(persisted.unknown, "keep");
92
+
93
+ const malformedFile = join(directory, "malformed.json");
94
+ await writeFile(malformedFile, "{not json", { mode: 0o600 });
95
+ await assert.rejects(readSessionSummaryPreferences(malformedFile), { code: "SESSION_SUMMARY_CONFIG_READ_FAILED" });
96
+ await assert.rejects(writeSessionSummaryPreferences({ configured: true }, malformedFile), { code: "SESSION_SUMMARY_CONFIG_READ_FAILED" });
97
+ assert.equal(await readFile(malformedFile, "utf8"), "{not json", "malformed configuration is never overwritten");
98
+ } finally {
99
+ await rm(directory, { recursive: true, force: true });
100
+ }
101
+
102
+ assert.equal(typeof DEFAULT_SUMMARY_PROMPT, "string");
103
+ console.log("session-summary preferences tests passed");
@@ -62,7 +62,7 @@ assert.match(
62
62
  "section headers should expose model-picker-style grab, dragging, and insertion-marker affordances",
63
63
  );
64
64
  assert.match(html, /styles\.css\?v=98/, "changed side-panel styles should advance the stylesheet revision");
65
- assert.match(html, /app\.js\?v=112/, "changed side-panel behavior should advance the app revision");
66
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v71"/, "changed browser assets should advance the PWA cache identity");
65
+ assert.match(html, /app\.js\?v=113/, "changed side-panel behavior should advance the app revision");
66
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v72"/, "changed browser assets should advance the PWA cache identity");
67
67
 
68
68
  console.log("side-panel-section-reorder-static.test.mjs passed");