@firstpick/pi-package-webui 0.9.2 → 0.9.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 (78) hide show
  1. package/README.md +14 -8
  2. package/bin/pi-webui.mjs +256 -39
  3. package/index.ts +266 -1
  4. package/lib/git-workflow-preferences.mjs +8 -25
  5. package/lib/intercom-conversations.mjs +491 -0
  6. package/lib/intercom-transcript-filter.mjs +99 -0
  7. package/lib/resource-selection.mjs +140 -0
  8. package/package.json +2 -2
  9. package/public/app.js +1061 -119
  10. package/public/index.html +31 -6
  11. package/public/service-worker.js +2 -1
  12. package/public/stream-output-controller.mjs +15 -0
  13. package/public/styles.css +426 -1
  14. package/public/syntax-highlight.mjs +622 -0
  15. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  16. package/tests/browser/interaction-continuity.spec.mjs +34 -0
  17. package/tests/browser/intercom-conversation-viewer.spec.mjs +357 -0
  18. package/tests/browser/persistent-ui-layout.spec.mjs +61 -0
  19. package/tests/browser/resource-profiles.spec.mjs +200 -0
  20. package/tests/browser/subagent-observability.spec.mjs +29 -0
  21. package/tests/codex-fast-mode-static.test.mjs +7 -6
  22. package/tests/common-options-submenus-interaction-static.test.mjs +2 -0
  23. package/tests/common-options-submenus-markup-static.test.mjs +1 -0
  24. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  25. package/tests/composer-skill-tag-layout.test.mjs +32 -2
  26. package/tests/control-deck-component-updates-static.test.mjs +4 -0
  27. package/tests/controls-layout-static.test.mjs +3 -3
  28. package/tests/fast-mode-client-static.test.mjs +2 -2
  29. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  30. package/tests/feature-system-prompt-optional-feature-static.test.mjs +5 -5
  31. package/tests/file-viewer-image-static.test.mjs +69 -0
  32. package/tests/fixtures/fake-pi.mjs +105 -6
  33. package/tests/foreground-transcript-catch-up-static.test.mjs +1 -1
  34. package/tests/git-panel-file-preview-static.test.mjs +5 -5
  35. package/tests/git-panel-live-updates-static.test.mjs +3 -3
  36. package/tests/git-workflow-preferences.test.mjs +4 -4
  37. package/tests/http-endpoints-harness.test.mjs +124 -2
  38. package/tests/intercom-conversation-viewer-static.test.mjs +106 -0
  39. package/tests/intercom-conversations-http.test.mjs +252 -0
  40. package/tests/intercom-conversations.test.mjs +374 -0
  41. package/tests/intercom-main-transcript-suppression-static.test.mjs +52 -0
  42. package/tests/intercom-tag-layout-static.test.mjs +46 -0
  43. package/tests/intercom-transcript-filter.test.mjs +98 -0
  44. package/tests/main-output-loading-static.test.mjs +59 -0
  45. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  46. package/tests/mobile-compact-layout.test.mjs +2 -3
  47. package/tests/mobile-continuity-tablet-static.test.mjs +6 -6
  48. package/tests/mobile-foundation-static.test.mjs +3 -3
  49. package/tests/mobile-phone-experience-static.test.mjs +1 -1
  50. package/tests/mobile-static.test.mjs +66 -42
  51. package/tests/native-parity.test.mjs +8 -7
  52. package/tests/open-issue-wizard-static.test.mjs +1 -1
  53. package/tests/optional-feature-migration-frontend.test.mjs +5 -5
  54. package/tests/optional-feature-resource-setup-static.test.mjs +29 -0
  55. package/tests/persistent-ui-layout-static.test.mjs +3 -3
  56. package/tests/questionnaire-dialog.test.mjs +3 -3
  57. package/tests/remote-auth-settings-harness.test.mjs +1 -1
  58. package/tests/resource-defaults-helper.test.mjs +60 -6
  59. package/tests/resource-selection.test.mjs +114 -0
  60. package/tests/resource-tui-extension.test.mjs +23 -0
  61. package/tests/session-sampling-ui-static.test.mjs +3 -3
  62. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  63. package/tests/stream-output-controller.test.mjs +8 -0
  64. package/tests/stream-output-isolation-static.test.mjs +2 -2
  65. package/tests/streaming-ui-coupling.test.mjs +5 -0
  66. package/tests/subagent-gate-visibility.test.mjs +1 -1
  67. package/tests/subagent-launch-slots.test.mjs +1 -1
  68. package/tests/subagent-observability-static.test.mjs +5 -3
  69. package/tests/subagent-reliability-integration.test.mjs +23 -1
  70. package/tests/subagent-workflow-section-static.test.mjs +67 -0
  71. package/tests/subagents-helper.test.mjs +313 -1
  72. package/tests/syntax-highlight.test.mjs +235 -0
  73. package/tests/syntax-highlighting-static.test.mjs +84 -0
  74. package/tests/terminal-cwd-grouping-static.test.mjs +22 -0
  75. package/tests/theme-customizer-static.test.mjs +5 -5
  76. package/tests/thinking-format-parser.test.mjs +64 -0
  77. package/tests/webui-settings-locking.test.mjs +1 -1
  78. package/webui-rpc-helper.mjs +417 -74
@@ -4,13 +4,14 @@ import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
6
6
  const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
- const [server, app, html, styles, serviceWorker, readme, packageRaw, lockRaw, optionalFeatureCatalog] = await Promise.all([
7
+ const [server, app, html, styles, serviceWorker, technical, development, packageRaw, lockRaw, optionalFeatureCatalog] = await Promise.all([
8
8
  readFile(join(root, "bin", "pi-webui.mjs"), "utf8"),
9
9
  readFile(join(root, "public", "app.js"), "utf8"),
10
10
  readFile(join(root, "public", "index.html"), "utf8"),
11
11
  readFile(join(root, "public", "styles.css"), "utf8"),
12
12
  readFile(join(root, "public", "service-worker.js"), "utf8"),
13
- readFile(join(root, "README.md"), "utf8"),
13
+ readFile(join(root, "TECHNICAL.md"), "utf8"),
14
+ readFile(join(root, "DEVELOPMENT.md"), "utf8"),
14
15
  readFile(join(root, "package.json"), "utf8"),
15
16
  readFile(join(root, "package-lock.json"), "utf8"),
16
17
  readFile(join(root, "lib", "optional-feature-catalog.mjs"), "utf8"),
@@ -51,10 +52,10 @@ assert.match(app, /async function disableCodexFastModeIntegration\(\)[\s\S]*?tab
51
52
  assert.match(app, /refreshNaturalConversationMode\(tabContext\),[\s\S]*?refreshCodexFastMode\(tabContext\),/, "tab refreshes should reload branch-scoped Fast-mode state");
52
53
  assert.match(app, /statusKey === CODEX_FAST_MODE_STATUS_KEY[\s\S]*?applyCodexFastModeStatus\(request\.statusText\)/, "extension status events should refresh the active-tab selector");
53
54
 
54
- assert.match(readme, /### Compact live output mode[\s\S]*?select \*\*Compact\*\*[\s\S]*?`compact-v1`/, "README should document Compact mode with the stable wire identifier");
55
- assert.match(readme, /### Codex subscription Fast mode[\s\S]*?service_tier: "priority"[\s\S]*?1\.5× faster[\s\S]*?2× Standard credits[\s\S]*?2\.5×/, "README should separately document subscription Fast mode and its cost semantics");
55
+ assert.match(technical, /## Normal and compact output[\s\S]*?select \*\*Compact\*\*[\s\S]*?`compact-v1`/, "technical reference should document Compact mode with the stable identifier");
56
+ assert.match(development, /### Codex subscription Fast mode[\s\S]*?service_tier: "priority"[\s\S]*?1\.5× faster[\s\S]*?2× Standard credits[\s\S]*?2\.5×/, "development guide should document Fast-mode integration and cost semantics");
56
57
  // Intent preserved: browser-asset changes must advance the coherent cache tuple.
57
- assert.match(serviceWorker, /pi-webui-pwa-v94/, "PWA cache identity should be bumped for changed browser assets");
58
- assert.match(html, /data-app-src="\/app\.js\?v=132"/, "browser module URL should be cache-busted for Fast-mode wiring");
58
+ assert.match(serviceWorker, /pi-webui-pwa-v112/, "PWA cache identity should be bumped for changed browser assets");
59
+ assert.match(html, /data-app-src="\/app\.js\?v=148"/, "browser module URL should be cache-busted for Fast-mode wiring");
59
60
 
60
61
  console.log("codex-fast-mode-static.test.mjs passed");
@@ -153,6 +153,8 @@ for (const [id, handler] of [
153
153
  ["optionsWorkflowSetupButton", 'runNativeCommandMenu\\("/workflow-setup"\\)'],
154
154
  ["optionsSafetyGuardSetupButton", 'runNativeCommandMenu\\("/safety-guard-setup"\\)'],
155
155
  ["optionsGitWorkflowSetupButton", 'runNativeCommandMenu\\("/git-workflow-setup"\\)'],
156
+ ["optionsToolsSetupButton", 'runNativeCommandMenu\\("/tools"\\)'],
157
+ ["optionsSkillsSetupButton", 'runNativeCommandMenu\\("/skills"\\)'],
156
158
  ["optionsExportButton", 'runNativeCommandMenu\\("/export"\\)'],
157
159
  ["optionsForkButton", 'runNativeCommandMenu\\("/fork"\\)'],
158
160
  ["optionsTreeButton", 'runNativeCommandMenu\\("/tree"\\)'],
@@ -82,6 +82,7 @@ const menuEnd = html.indexOf('<div id="appRunnerMenu"', menuStart);
82
82
  assert.ok(menuStart >= 0 && menuEnd > menuStart, "the Common Pi options block should remain bounded by its stable IDs");
83
83
  const menuMarkup = html.slice(menuStart, menuEnd);
84
84
  assert.match(menuMarkup, /^<div id="optionsMenu"[^>]*role="menu"[^>]*aria-label="Common Pi options">/, "the root should remain a labelled menu");
85
+ assert.doesNotMatch(menuMarkup, /id="options(?:Tools|Skills)SetupButton"/, "Tools Setup and Skills Setup should not appear in Common Pi options");
85
86
 
86
87
  const allActionIds = Object.keys(actionContract);
87
88
  for (const [id, contract] of Object.entries(actionContract)) {
@@ -56,8 +56,8 @@ assert.match(app, /function initializeComposerActionOrdering\(\)[\s\S]*MutationO
56
56
  assert.match(app, /event\.key === COMPOSER_ACTION_ORDER_STORAGE_KEY\) restoreComposerActionOrder\(\)[\s\S]*event\.key === COMPOSER_ACTION_LAYOUT_STORAGE_KEY\) restoreComposerActionSlotLayout\(\)/, "other tabs should apply persisted composer order and sparse-layout changes");
57
57
  assert.match(app, /initializeComposerActionOrdering\(\);[\s\S]*restoreSidePanelSectionOrder\(\);/, "composer ordering should initialize during guarded app startup");
58
58
 
59
- assert.match(html, /styles\.css\?v=115/, "changed composer styles should advance the stylesheet revision");
60
- assert.match(html, /app\.js\?v=132/, "changed composer behavior should advance the app revision");
61
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v94"/, "changed browser assets should advance the PWA cache identity");
59
+ assert.match(html, /styles\.css\?v=126/, "changed composer styles should advance the stylesheet revision");
60
+ assert.match(html, /app\.js\?v=148/, "changed composer behavior should advance the app revision");
61
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "changed browser assets should advance the PWA cache identity");
62
62
 
63
63
  console.log("composer-action-grid-reorder-static.test.mjs passed");
@@ -6,6 +6,7 @@ import { fileURLToPath } from "node:url";
6
6
 
7
7
  const root = join(dirname(fileURLToPath(import.meta.url)), "..");
8
8
  const app = await readFile(join(root, "public", "app.js"), "utf8");
9
+ const css = await readFile(join(root, "public", "styles.css"), "utf8");
9
10
 
10
11
  function functionSource(name, nextName) {
11
12
  const start = app.indexOf(`function ${name}(`);
@@ -19,7 +20,11 @@ function chip(width) {
19
20
  hidden: false,
20
21
  textContent: "",
21
22
  title: "",
23
+ attributes: new Map(),
22
24
  measurements: 0,
25
+ setAttribute(name, value) {
26
+ this.attributes.set(name, value);
27
+ },
23
28
  getBoundingClientRect() {
24
29
  this.measurements += 1;
25
30
  return { width };
@@ -28,15 +33,23 @@ function chip(width) {
28
33
  }
29
34
 
30
35
  const tags = [chip(50), chip(60), chip(70)];
36
+ const menuItems = [chip(50), chip(60), chip(70)];
31
37
  const overflow = chip(22);
38
+ const overflowStateCalls = [];
32
39
  const container = {
33
40
  hidden: false,
34
41
  clientWidth: 150,
35
- querySelectorAll: (selector) => selector === "button.composer-skill-tag" ? tags : [],
36
- querySelector: (selector) => selector === ".composer-skill-tag.overflow" ? overflow : null,
42
+ querySelectorAll: (selector) => {
43
+ if (selector === ":scope > button.composer-skill-tag:not(.overflow)") return tags;
44
+ if (selector === ".composer-skill-overflow-menu-item") return menuItems;
45
+ return [];
46
+ },
47
+ querySelector: (selector) => selector === "button.composer-skill-tag.overflow" ? overflow : null,
37
48
  };
38
49
  const context = {
39
50
  elements: { sessionSkillTags: container },
51
+ sessionSkillOverflowOpen: false,
52
+ setSessionSkillOverflowOpen: (open) => overflowStateCalls.push(open),
40
53
  getComputedStyle: () => ({ columnGap: "5px", gap: "5px" }),
41
54
  };
42
55
  vm.runInNewContext(
@@ -46,18 +59,23 @@ vm.runInNewContext(
46
59
 
47
60
  context.fitSessionSkillTags();
48
61
  assert.deepEqual(tags.map((tag) => tag.hidden), [false, false, true], "the strip should show the maximum chip count that fits the measured width");
62
+ assert.deepEqual(menuItems.map((tag) => tag.hidden), [true, true, false], "the popup should contain only tags hidden from the strip");
49
63
  assert.equal(overflow.hidden, false, "the overflow chip should remain visible while tags are hidden");
50
64
  assert.equal(overflow.textContent, "+1", "the overflow chip should report the current hidden count");
65
+ assert.equal(overflow.attributes.get("aria-label"), "Show 1 more tracked skill", "the disclosure should announce its current hidden count");
51
66
  assert.equal(overflow.measurements, 1, "fitting should measure one overflow width per digit count rather than forcing layout for every candidate");
52
67
 
53
68
  container.clientWidth = 200;
54
69
  context.fitSessionSkillTags();
55
70
  assert.deepEqual(tags.map((tag) => tag.hidden), [false, false, false], "widening the input should reveal every tag without rerendering the session state");
71
+ assert.deepEqual(menuItems.map((tag) => tag.hidden), [true, true, true], "the popup should not duplicate tags visible in the strip");
56
72
  assert.equal(overflow.hidden, true, "the overflow chip should disappear when every tag fits");
73
+ assert.deepEqual(overflowStateCalls, [false], "revealing every tag should close an open overflow surface");
57
74
 
58
75
  container.clientWidth = 80;
59
76
  context.fitSessionSkillTags();
60
77
  assert.deepEqual(tags.map((tag) => tag.hidden), [false, true, true], "narrowing the input should compact the tag strip again");
78
+ assert.deepEqual(menuItems.map((tag) => tag.hidden), [true, false, false], "responsive compaction should update the selectable popup contents");
61
79
  assert.equal(overflow.textContent, "+2", "responsive compaction should keep the overflow count current");
62
80
 
63
81
  container.clientWidth = 0;
@@ -67,4 +85,16 @@ context.fitSessionSkillTags();
67
85
  assert.deepEqual(tags.map((tag) => tag.hidden), zeroWidthState, "a temporarily unmeasurable strip should preserve its last stable visibility state");
68
86
  assert.equal(overflow.textContent, zeroWidthOverflowText, "a zero-width pass should not expose a stale overflow count");
69
87
 
88
+ const disclosureSource = functionSource("setSessionSkillOverflowOpen", "fitSessionSkillTags");
89
+ const installSource = functionSource("installSessionSkillTagResizeHandling", "renderSessionSkillTags");
90
+ const renderStart = app.indexOf("function renderSessionSkillTags(");
91
+ const renderEnd = app.indexOf("\nconst INTERCOM_CONVERSATION_ID_PATTERN", renderStart);
92
+ const renderSource = app.slice(renderStart, renderEnd);
93
+ assert.match(disclosureSource, /classList\.toggle\("overflow-open", expanded\)[\s\S]*aria-expanded[\s\S]*menu\.hidden = !expanded/, "the disclosure should keep visual, accessible, and hidden state synchronized");
94
+ assert.match(installSource, /event\.key !== "Escape"[\s\S]*restoreFocus: true[\s\S]*document\.addEventListener\("pointerdown"/, "Escape and outside pointer interaction should dismiss the popup");
95
+ assert.match(renderSource, /make\("button", "composer-skill-tag overflow"[\s\S]*aria-haspopup[\s\S]*sessionSkillOverflowMenu[\s\S]*role", "dialog"/, "the overflow count should render as an accessible popup button");
96
+ assert.match(renderSource, /composer-skill-overflow-menu-item[\s\S]*setSessionSkillOverflowOpen\(false\);[\s\S]*openSkillEditor\(entry\)/, "every hidden tag should remain clickable through the existing editor action");
97
+ assert.match(css, /\.composer-skill-overflow-menu \{[\s\S]*position: absolute;[\s\S]*bottom: calc\(100% \+ 0\.42rem\);[\s\S]*max-height:[\s\S]*overflow-y: auto;/, "the bounded popup should expand upward above the compact strip");
98
+ assert.match(css, /\.composer-skill-overflow-menu \.composer-skill-tag \{[\s\S]*width: 100%;[\s\S]*max-width: none;/, "hidden tags should use the popup width instead of the compact-strip truncation limit");
99
+
70
100
  console.log("composer skill tag layout tests passed");
@@ -20,6 +20,10 @@ assert.match(app, /api\("\/api\/update\/apply", \{ method: "POST", body: \{ tran
20
20
  assert.match(app, /function piUpdateConfirmationText\(\{ all = false, plan = null \} = \{\}\)[\s\S]*Exact immutable plan digest/);
21
21
  assert.match(app, /const planTargets = Array\.isArray\(plan\?\.targets\)[\s\S]*planTargets\.length === 0[\s\S]*No update targets were accepted/);
22
22
  assert.match(app, /applyData\?\.state !== "activating"[\s\S]*completed without a Web UI restart[\s\S]*did not complete; no Web UI restart was requested/);
23
+ assert.match(html, /id="serverRestartPanel"[\s\S]*server-restart-spinner[\s\S]*id="serverRestartKicker"[\s\S]*id="serverRestartTitle"/);
24
+ assert.match(app, /function setServerRestartOverlay\(active[\s\S]*phase = "restarting"[\s\S]*phase === "updating"[\s\S]*Applying exact update/);
25
+ assert.match(app, /async function startComponentUpdate\(target\)[\s\S]*setServerRestartOverlay\(true, `Starting exact \$\{label\} update…`, \{ phase: "updating" \}\)[\s\S]*setServerRestartOverlay\(false\)/);
26
+ assert.match(app, /async function runPiUpdateAndRestart[\s\S]*setServerRestartOverlay\(true, progressMessage, \{ phase: "updating" \}\)/);
23
27
  assert.match(app, /will not re-resolve latest or scan package roots/);
24
28
  assert.match(app, /function separatePathPiPlanNotice\(plan\)[\s\S]*PATH Pi[\s\S]*separate installation[\s\S]*will remain untouched/);
25
29
  assert.match(app, /async function waitForServerRestart\(previousBootIdentity = serverBootIdentity\)[\s\S]*Date\.now\(\) \+ 90_000[\s\S]*health\.bootIdentity === previousBootIdentity/);
@@ -15,8 +15,8 @@ assert.equal((html.match(/class="control-row-label"[^>]*data-tooltip=/g) || []).
15
15
  assert.match(app, /function initializeControlSettingTooltips\(\)[\s\S]*#sidePanelSectionControls \.control-row-label\[data-tooltip\][\s\S]*bindStyledTooltipEvents\(label\)[\s\S]*showFooterTooltip\(label\)/, "Controls help should use the viewport-safe floating tooltip for hover and keyboard access");
16
16
  assert.match(html, /class="control-row remote-auth-control-row" hidden[\s\S]*id="remoteAuthToggle"/, "optional PIN protection should retain its guarded visibility");
17
17
  assert.match(app, /remoteAuthToggle\?\.closest\("\.remote-auth-control-row"\)[\s\S]*remoteAuthRow\.hidden = false/, "loading remote status should reveal the optional PIN protection setting");
18
- assert.match(html, /styles\.css\?v=115/, "Controls stylesheet changes should advance the cache query");
19
- assert.match(html, /app\.js\?v=132/, "Controls tooltip wiring should advance the app cache query");
20
- assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v94"/, "Controls browser assets should advance the PWA cache identity");
18
+ assert.match(html, /styles\.css\?v=126/, "Controls stylesheet changes should advance the cache query");
19
+ assert.match(html, /app\.js\?v=148/, "Controls tooltip wiring should advance the app cache query");
20
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "Controls browser assets should advance the PWA cache identity");
21
21
 
22
22
  console.log("controls-layout-static.test.mjs passed");
@@ -91,7 +91,7 @@ assert.match(resetCompactLiveOutput, /clearCompactThinkingDisclosureState\("live
91
91
  assert.match(compactFlush, /compactThinkingNode\?\._rawThinkingText !== compactLiveState\.thinking[\s\S]*?renderThinkingMarkdown\(compactThinkingNode, compactLiveState\.thinking\)/, "compact live thinking should preserve Markdown formatting");
92
92
  assert.doesNotMatch(compactFlush, /compactThinkingNode\.textContent|renderStreamingMarkdown|renderToolExecution|normalizeToolExecution/, "compact thinking must not fall back to plain text or invoke rich tool renderers");
93
93
  assert.doesNotMatch(compactToolShell, /normalizeToolExecution|toolExecutionRenderSignature|renderToolExecution|handleToolExecutionUpdate|JSON\.stringify/, "compact tool shells must defer rich bodies and raw serialization");
94
- assert.match(app, /applyToolExecutionUpdate: \(event\) => \{\s+if \(!compactOutputActive\(\)\) applyTranscriptToolExecutionUpdate\(event\);/, "compact mode should not build intermediate rich tool updates");
94
+ assert.match(app, /applyToolExecutionUpdate: \(event\) => \{\s+if \(!compactOutputActive\(\) && !isIntercomTransportToolName\(event\?\.toolName\)\) applyTranscriptToolExecutionUpdate\(event\);/, "compact mode and hidden Intercom transport should not build intermediate rich tool updates");
95
95
  assert.doesNotMatch(app, /case "tool_execution_update":/, "raw tool updates should have only the controller-owned dispatch path");
96
96
  assert.match(app, /case "tool_execution_end":[\s\S]*?compactLiveScheduler\.flushNow\(\)[\s\S]*?renderCompactToolShell\(event, \{ complete: true \}\)[\s\S]*?finishCompactLiveOutput\(tabContext\)/, "compact tool completion should remain lightweight and request final reconciliation");
97
97
  assert.match(resetStream, /resetCompactLiveOutput\(\{ remove: !preserveCompact \}\)/, "reset and tab changes should cancel compact pending work while exact compact settlement may retain its adopted owner");
@@ -156,7 +156,7 @@ assert.match(worker, /pi-webui-pwa-v\d+[\s\S]*?"\/fast-output-live\.mjs"/, "PWA
156
156
  assert.match(html, /<label for="fastOutputModeSelect">Compact mode \(Experimental\)<\/label>/, "the sidebar should mark compact mode as experimental");
157
157
  assert.match(html, /Lightweight browser rendering; Markdown final output; live thinking expanded; stored thinking grouped and collapsed/, "the sidebar should distinguish compact rendering from model inference");
158
158
  // Intent preserved: the guarded PWA entry point must advance whenever app wiring changes.
159
- assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=132"/, "the guarded PWA entry point should cache-bust browser wiring");
159
+ assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=148"/, "the guarded PWA entry point should cache-bust browser wiring");
160
160
  assert.match(JSON.parse(packageRaw).scripts.check, /node --check public\/fast-output-live\.mjs/, "package checks should parse the compact helper");
161
161
 
162
162
  const events = createFastModeOutputEvents();
@@ -166,7 +166,7 @@ assert.match(functionSource("closeTerminalTabs"), /clearFeatureDecisionStateForT
166
166
  assert.match(app, /case "webui_connected":[\s\S]*clearFeatureDecisionStateForTab\(connectedTabId, \{ render: true \}\)[\s\S]*scheduleForegroundReconcile\("event stream reconnect", 0\)/, "reconnect should clear local state before authoritative replay");
167
167
  assert.match(app, /statusKey === FEATURE_DECISION_OUTPUT_STATUS_KEY[\s\S]*handleFeatureDecisionOutputStatus[\s\S]*return;[\s\S]*statusKey === FEATURE_CATEGORY_STATUS_KEY[\s\S]*return;[\s\S]*statusEntries\.set/, "both feature statuses should be intercepted before generic footer storage while preserving category handling");
168
168
 
169
- assert.match(html, /\/styles\.css\?v=115/, "integrated stylesheet changes should advance the cache query");
170
- assert.match(html, /\/app\.js\?v=132/, "integrated app changes should advance the cache query");
169
+ assert.match(html, /\/styles\.css\?v=126/, "integrated stylesheet changes should advance the cache query");
170
+ assert.match(html, /\/app\.js\?v=148/, "integrated app changes should advance the cache query");
171
171
 
172
172
  console.log("feature decision-output popup static checks passed");
@@ -1,15 +1,15 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { readFile } from "node:fs/promises";
3
3
 
4
- const [catalog, app, readme, manifest] = await Promise.all([
4
+ const [catalog, app, development, manifest] = await Promise.all([
5
5
  readFile(new URL("../lib/optional-feature-catalog.mjs", import.meta.url), "utf8"),
6
6
  readFile(new URL("../public/app.js", import.meta.url), "utf8"),
7
- readFile(new URL("../README.md", import.meta.url), "utf8"),
7
+ readFile(new URL("../DEVELOPMENT.md", import.meta.url), "utf8"),
8
8
  readFile(new URL("../../pi-extension-feature-system-prompt/package.json", import.meta.url), "utf8").then(JSON.parse),
9
9
  ]);
10
10
 
11
11
  assert.equal(manifest.name, "@firstpick/pi-extension-feature-system-prompt");
12
- assert.equal(manifest.version, "0.1.3");
12
+ assert.equal(manifest.version, "0.1.5");
13
13
  assert.match(
14
14
  catalog,
15
15
  /\["featureSystemPrompt", "@firstpick\/pi-extension-feature-system-prompt", "\^0\.1\.3"\]/,
@@ -41,9 +41,9 @@ assert.match(
41
41
  "disabling the optional integration should clear replayed classifier state",
42
42
  );
43
43
  assert.match(
44
- readme,
44
+ development,
45
45
  /`@firstpick\/pi-extension-feature-system-prompt` — feature-request classification and routing/,
46
- "the optional companion list should document the new package",
46
+ "the contributor companion list should document the new package",
47
47
  );
48
48
 
49
49
  console.log("feature-system-prompt optional-feature static tests passed");
@@ -0,0 +1,69 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import vm from "node:vm";
6
+
7
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
8
+ const [app, css, html, server, readme, technical, development, serviceWorker] = await Promise.all([
9
+ readFile(join(root, "public", "app.js"), "utf8"),
10
+ readFile(join(root, "public", "styles.css"), "utf8"),
11
+ readFile(join(root, "public", "index.html"), "utf8"),
12
+ readFile(join(root, "bin", "pi-webui.mjs"), "utf8"),
13
+ readFile(join(root, "README.md"), "utf8"),
14
+ readFile(join(root, "TECHNICAL.md"), "utf8"),
15
+ readFile(join(root, "DEVELOPMENT.md"), "utf8"),
16
+ readFile(join(root, "public", "service-worker.js"), "utf8"),
17
+ ]);
18
+
19
+ function sourceBetween(source, startMarker, endMarker, label) {
20
+ const start = source.indexOf(startMarker);
21
+ const end = source.indexOf(endMarker, start);
22
+ assert.ok(start >= 0 && end > start, `${label} should remain independently inspectable`);
23
+ return source.slice(start, end);
24
+ }
25
+
26
+ const imageHelpers = sourceBetween(app, "const FILE_VIEWER_IMAGE_MIME_TYPES", "\n// Changes mode only exists", "image data helper");
27
+ const modeSource = sourceBetween(app, "function resolveFileViewerMode(", "\nfunction setFileViewerMode(", "image-aware mode resolver");
28
+ const openSource = sourceBetween(app, "async function openFileInViewer(", "\nasync function openAurReviewReportInViewer(", "file open flow");
29
+ const uiSource = sourceBetween(app, "function updateFileViewerUi(", "\nconst FILE_VIEWER_SEARCH_MATCH_LIMIT", "file viewer UI renderer");
30
+
31
+ const helperResults = JSON.parse(vm.runInNewContext(`${imageHelpers}\nJSON.stringify([
32
+ fileViewerImageDataUrl({ mimeType: "image/png", data: "AQ==" }),
33
+ fileViewerImageDataUrl({ mimeType: "image/svg+xml", data: "AQ==" }),
34
+ fileViewerImageDataUrl({ mimeType: "image/png", data: "" }),
35
+ ])`));
36
+ assert.deepEqual(helperResults, ["data:image/png;base64,AQ==", "", ""], "the browser should create data URLs only for supported non-empty raster payloads");
37
+
38
+ const modes = JSON.parse(vm.runInNewContext(`${modeSource}\nJSON.stringify([
39
+ resolveFileViewerMode({ kind: "image", mode: "image" }),
40
+ resolveFileViewerMode({ kind: "image", mode: "preview" }),
41
+ resolveFileViewerMode({ kind: "image", mode: "changes", gitChanges: { category: "unstaged" } }),
42
+ resolveFileViewerMode({ kind: "text", mode: "preview", language: "markdown" }),
43
+ ])`));
44
+ assert.deepEqual(modes, ["image", "image", "changes", "preview"], "supported images should default back to Image mode while preserving Git Changes mode");
45
+
46
+ assert.match(server, /const FILE_VIEWER_IMAGE_MIME_TYPES_BY_EXTENSION = Object\.freeze\(\{[\s\S]*"\.png": "image\/png"[\s\S]*"\.jpe?g": "image\/jpeg"[\s\S]*"\.gif": "image\/gif"[\s\S]*"\.webp": "image\/webp"[\s\S]*"\.avif": "image\/avif"/, "the server should use an explicit raster extension allowlist");
47
+ assert.doesNotMatch(server, /"\.svg": "image\/svg\+xml"/, "active SVG documents should remain outside image-viewer scope");
48
+ assert.match(server, /if \(imageMimeType\) \{\s*return \{ \.\.\.shared, kind: "image", mimeType: imageMimeType, data: buffer\.toString\("base64"\) \};\s*\}/, "the bounded content endpoint should return image bytes without UTF-8 reinterpretation");
49
+ assert.match(server, /resolved\.info\.size > FILE_VIEWER_MAX_BYTES[\s\S]*const buffer = await readFile\(resolved\.targetPath\);[\s\S]*const imageMimeType = fileViewerImageMimeType/, "image reads should stay behind the existing workspace file size limit");
50
+
51
+ assert.match(html, /id="fileViewerImage"[^>]*role="group"[^>]*aria-label="Image preview"[^>]*hidden>[\s\S]*<img id="fileViewerImageElement" alt="" \/>/, "the viewer should expose a labelled, initially hidden image surface");
52
+ assert.match(app, /fileViewerImage: \$\("#fileViewerImage"\)[\s\S]*fileViewerImageElement: \$\("#fileViewerImageElement"\)/, "the image surface should be registered in the frontend element map");
53
+ assert.match(openSource, /const kind = data\.kind === "image" \? "image" : "text";[\s\S]*const imageUrl = kind === "image" \? fileViewerImageDataUrl\(data\) : "";/, "the standard file-open flow should validate image payloads through the allowlisted data URL helper");
54
+ assert.match(openSource, /readOnly: kind === "image",\s*sourceAvailable: kind === "text"/, "images should be read-only and unavailable to the source editor");
55
+ assert.match(uiSource, /elements\.fileViewerImage\.hidden = mode !== "image"/, "the image surface should render only in image mode");
56
+ assert.match(uiSource, /elements\.fileViewerImageElement\.alt = `Preview of \$\{viewer\.name \|\| fileDisplayName\(viewer\.path\)\}`/, "rendered images should receive a useful filename-based alternative label");
57
+ assert.match(app, /if \(!activeFileViewer \|\| activeFileViewer\.kind === "image" \|\| !elements\.fileViewerSearchBar\) return;/, "text search should not open for image previews");
58
+ assert.match(app, /elements\.fileViewerImageElement\.removeAttribute\("src"\);\s*elements\.fileViewerImageElement\.alt = "";/, "closing or replacing a viewer should release stale image source state");
59
+
60
+ assert.match(css, /\.file-viewer-image \{[\s\S]*display: grid;[\s\S]*place-items: center;/, "the image surface should center its preview");
61
+ assert.match(css, /\.file-viewer-image img \{[\s\S]*max-width: 100%;[\s\S]*max-height: 100%;[\s\S]*object-fit: contain;/, "images should fit within the viewer without distortion");
62
+ assert.match(readme, /PNG, JPEG, GIF, WebP, and AVIF/i, "the Files panel guide should list supported image formats");
63
+ assert.match(technical, /supported raster images[\s\S]*2 MiB/i, "the advanced reference should document image support and its size limit");
64
+ assert.match(development, /kind: "image"[\s\S]*base64/i, "the contributor guide should document the image response contract");
65
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v112"/, "changed viewer assets should advance the PWA cache identity");
66
+ assert.match(html, /styles\.css\?v=126/, "changed image styles should advance the stylesheet revision");
67
+ assert.match(html, /app\.js\?v=148/, "changed image rendering should advance the app revision");
68
+
69
+ console.log("file viewer image static tests passed");
@@ -17,6 +17,10 @@
17
17
  // isStreaming=true while a scripted flow runs.
18
18
  // - FAKE_PI_STATS_PROMPT_CONTEXT=1: advertise /stats-webui and publish deterministic
19
19
  // structured or malformed-subsection Prompt/context dashboard payloads.
20
+ // - FAKE_PI_TRANSCRIPT_JSON=<JSON array>: replace only the three baseline get_messages
21
+ // records with an isolated transcript fixture; dynamic/scripted messages still append.
22
+ // - FAKE_PI_INTERCOM_LIVE=1: accept the isolated "fixture modal transport live"
23
+ // prompt and emit a generic Intercom tool stream with visible unrelated output.
20
24
  import { createHash, randomUUID } from "node:crypto";
21
25
  import { createInterface } from "node:readline";
22
26
  import { appendFileSync } from "node:fs";
@@ -88,6 +92,17 @@ const continuityModeEnabled = process.env.FAKE_PI_CONTINUITY_MODE === "1";
88
92
  const largePayloadsEnabled = process.env.FAKE_PI_LARGE_PAYLOADS === "1";
89
93
  const sseFloodEnabled = process.env.FAKE_PI_SSE_FLOOD === "1";
90
94
  const statsPromptContextEnabled = process.env.FAKE_PI_STATS_PROMPT_CONTEXT === "1";
95
+ const intercomLiveEnabled = process.env.FAKE_PI_INTERCOM_LIVE === "1";
96
+ const fakeTranscriptMessages = (() => {
97
+ const source = process.env.FAKE_PI_TRANSCRIPT_JSON;
98
+ if (!source) return null;
99
+ try {
100
+ const parsed = JSON.parse(source);
101
+ return Array.isArray(parsed) && parsed.every((message) => message && typeof message === "object" && !Array.isArray(message)) ? parsed : null;
102
+ } catch {
103
+ return null;
104
+ }
105
+ })();
91
106
  const streamIsolationEnabled = process.env.FAKE_PI_STREAM_ISOLATION === "1";
92
107
  const commandLogFile = process.env.FAKE_PI_LOG_FILE || "";
93
108
  const largeRpcText = "large-rpc-payload:" + "λ".repeat(70_000);
@@ -313,6 +328,56 @@ function runVoiceScriptFlow({ text, chunks, chunkSpacingMs = 60, toolPhase = fal
313
328
  runScriptedSteps(steps);
314
329
  }
315
330
 
331
+ function runIntercomLiveScript() {
332
+ scriptedStreaming = true;
333
+ const toolCallId = "live-intercom-call";
334
+ const normalText = "LIVE NORMAL OUTPUT VISIBLE";
335
+ const toolCall = {
336
+ type: "toolCall",
337
+ id: toolCallId,
338
+ name: "intercom",
339
+ arguments: { action: "send", to: "peer-live", message: "LIVEINTERCOMARGUMENTSECRET" },
340
+ };
341
+ const assistantMessage = { role: "assistant", content: [{ type: "text", text: normalText }, toolCall], timestamp: Date.now() };
342
+ const toolResult = {
343
+ role: "toolResult",
344
+ toolCallId,
345
+ toolName: "intercom",
346
+ content: [{ type: "text", text: "LIVEINTERCOMRESULTSECRET" }],
347
+ isError: false,
348
+ timestamp: Date.now() + 1,
349
+ };
350
+ runScriptedSteps([
351
+ { afterMs: 30, run: () => emitScriptedEvent({ type: "agent_start" }) },
352
+ { afterMs: 30, run: () => emitScriptedEvent({ type: "message_start", message: { role: "assistant" } }) },
353
+ { afterMs: 40, run: () => emitScriptedEvent({ type: "message_update", assistantMessageEvent: { type: "text_delta", delta: normalText } }) },
354
+ { afterMs: 40, run: () => emitScriptedEvent({ type: "message_update", assistantMessageEvent: { type: "toolcall_start", contentIndex: 1, name: "intercom", toolCall } }) },
355
+ { afterMs: 30, run: () => emitScriptedEvent({ type: "message_update", assistantMessageEvent: { type: "toolcall_delta", contentIndex: 1, name: "intercom", toolCall, delta: "" } }) },
356
+ { afterMs: 30, run: () => emitScriptedEvent({ type: "message_update", assistantMessageEvent: { type: "toolcall_end", contentIndex: 1, name: "intercom", toolCall } }) },
357
+ { afterMs: 30, run: () => emitScriptedEvent({ type: "tool_execution_start", toolCallId, toolName: "intercom", args: toolCall.arguments }) },
358
+ { afterMs: 40, run: () => emitScriptedEvent({ type: "tool_execution_update", toolCallId, toolName: "intercom", partialResult: { content: toolResult.content } }) },
359
+ { afterMs: 40, run: () => emitScriptedEvent({ type: "tool_execution_end", toolCallId, toolName: "intercom", isError: false, result: { content: toolResult.content } }) },
360
+ { afterMs: 40, run: () => {
361
+ appendDynamicMessage(assistantMessage);
362
+ appendDynamicMessage(toolResult);
363
+ emitScriptedEvent({ type: "message_end", message: assistantMessage });
364
+ } },
365
+ { afterMs: 40, run: () => emitScriptedEvent({ type: "agent_end" }) },
366
+ { afterMs: 10, run: () => {
367
+ scriptedStreaming = false;
368
+ emitScriptedEvent({ type: "agent_settled" });
369
+ } },
370
+ ]);
371
+ }
372
+
373
+ function handleIntercomLivePrompt(command, base) {
374
+ if (!intercomLiveEnabled || String(command.message || "").trim() !== "fixture modal transport live") return false;
375
+ appendDynamicMessage({ role: "user", content: String(command.message), timestamp: Date.now() });
376
+ respond({ ...base, data: { output: "fake live transport accepted", pid: process.pid } });
377
+ runIntercomLiveScript();
378
+ return true;
379
+ }
380
+
316
381
  function runContinuityDelayedStream() {
317
382
  scriptedStreaming = true;
318
383
  const text = "continuity stream complete";
@@ -631,7 +696,8 @@ function handleWebuiHelperPrompt(command, base) {
631
696
  respondHelper({ requestId, ok: true, data: { tools: fakeTools.map((tool) => ({ ...tool, enabled: enabledToolNames.has(tool.name) })) } });
632
697
  return true;
633
698
  case "tools-set": {
634
- if (Array.isArray(request.payload?.enabledTools)) enabledToolNames = new Set(request.payload.enabledTools.map(String));
699
+ if (request.payload?.mode === "inherit") enabledToolNames = new Set(fakeTools.map((tool) => tool.name));
700
+ else if (Array.isArray(request.payload?.enabledTools)) enabledToolNames = new Set(request.payload.enabledTools.map(String));
635
701
  else if (Array.isArray(request.payload?.disabledTools)) {
636
702
  const disabled = new Set(request.payload.disabledTools.map(String));
637
703
  enabledToolNames = new Set(fakeTools.map((tool) => tool.name).filter((name) => !disabled.has(name)));
@@ -642,8 +708,15 @@ function handleWebuiHelperPrompt(command, base) {
642
708
  case "skills-state":
643
709
  respondHelper({ requestId, ok: true, data: { skills: fakeSkills.map((skill) => ({ ...skill, enabled: enabledSkillNames.has(skill.name) })) } });
644
710
  return true;
711
+ case "resources-recompute":
712
+ respondHelper({ requestId, ok: true, data: {
713
+ tools: { tools: fakeTools.map((tool) => ({ ...tool, enabled: enabledToolNames.has(tool.name) })) },
714
+ skills: { skills: fakeSkills.map((skill) => ({ ...skill, enabled: enabledSkillNames.has(skill.name) })) },
715
+ } });
716
+ return true;
645
717
  case "skills-set": {
646
- if (Array.isArray(request.payload?.enabledSkills)) enabledSkillNames = new Set(request.payload.enabledSkills.map(String));
718
+ if (request.payload?.mode === "inherit") enabledSkillNames = new Set(fakeSkills.map((skill) => skill.name));
719
+ else if (Array.isArray(request.payload?.enabledSkills)) enabledSkillNames = new Set(request.payload.enabledSkills.map(String));
647
720
  else if (Array.isArray(request.payload?.disabledSkills)) {
648
721
  const disabled = new Set(request.payload.disabledSkills.map(String));
649
722
  enabledSkillNames = new Set(fakeSkills.map((skill) => skill.name).filter((name) => !disabled.has(name)));
@@ -1103,7 +1176,7 @@ function emitSubagentFixtureStatus({ legacyOnly = false } = {}) {
1103
1176
 
1104
1177
  function handleSubagentFixturePrompt(command, base) {
1105
1178
  const message = String(command.message || "").trim();
1106
- if (!["fixture subagents running", "fixture subagents old-helper", "fixture subagents clear", "fixture subagents retained"].includes(message)) return false;
1179
+ if (!["fixture subagents running", "fixture subagents old-helper", "fixture subagents workflow", "fixture subagents clear", "fixture subagents retained"].includes(message)) return false;
1107
1180
  const now = Date.now();
1108
1181
  fixtureSubagentRuns.splice(0, fixtureSubagentRuns.length);
1109
1182
  fixtureSubagentGates.splice(0, fixtureSubagentGates.length);
@@ -1133,6 +1206,29 @@ function handleSubagentFixturePrompt(command, base) {
1133
1206
  { id: "fixture-gate:1:1", taskIndex: 1, attempt: 1, maxAttempts: 2, agent: "reviewer", retrySafety: "read-only", runId: "fixture-review-2", model: "openrouter/moonshotai/kimi-k3", provider: "openrouter", status: "failed", failureKind: "transient-provider", error: "provider overloaded" },
1134
1207
  ],
1135
1208
  });
1209
+ } else if (message === "fixture subagents workflow") {
1210
+ fixtureSubagentRuns.push(
1211
+ {
1212
+ id: "fixture-workflow-controller",
1213
+ source: "recovered",
1214
+ mode: "single",
1215
+ status: "done",
1216
+ startedAt: now - 2500,
1217
+ agents: [
1218
+ { id: "fixture-workflow-controller:workflow", name: "workflow", status: "done", index: 0, nested: false },
1219
+ ],
1220
+ },
1221
+ {
1222
+ id: "fixture-workflow-worker",
1223
+ source: "recovered",
1224
+ mode: "single",
1225
+ status: "running",
1226
+ startedAt: now - 2450,
1227
+ agents: [
1228
+ { id: "fixture-workflow-worker:worker", name: "worker", status: "running", index: 0, model: "openai-codex/gpt-5.6-sol", thinking: "high", nested: false },
1229
+ ],
1230
+ },
1231
+ );
1136
1232
  } else if (message === "fixture subagents retained") {
1137
1233
  fixtureSubagentRuns.push(
1138
1234
  {
@@ -1410,9 +1506,11 @@ rl.on("line", (line) => {
1410
1506
  ...base,
1411
1507
  data: {
1412
1508
  messages: [
1413
- { role: "user", content: "fake prompt", timestamp: 1000 },
1414
- { role: "assistant", content: [{ type: "text", text: "fake answer" }], timestamp: 2000 },
1415
- { role: "user", content: "fake follow-up", timestamp: 3000 },
1509
+ ...(fakeTranscriptMessages || [
1510
+ { role: "user", content: "fake prompt", timestamp: 1000 },
1511
+ { role: "assistant", content: [{ type: "text", text: "fake answer" }], timestamp: 2000 },
1512
+ { role: "user", content: "fake follow-up", timestamp: 3000 },
1513
+ ]),
1416
1514
  ...dynamicMessages,
1417
1515
  ...(largeTranscriptEnabled ? [{ role: "assistant", content: [{ type: "text", text: largeRpcText }], timestamp: 4000 }] : []),
1418
1516
  ],
@@ -1452,6 +1550,7 @@ rl.on("line", (line) => {
1452
1550
  return;
1453
1551
  }
1454
1552
  case "prompt":
1553
+ if (handleIntercomLivePrompt(command, base)) return;
1455
1554
  if (handleFeatureDecisionFixturePrompt(command, base)) return;
1456
1555
  if (handleStatsPromptContextFixturePrompt(command, base)) return;
1457
1556
  if (handleWebuiHelperPrompt(command, base)) return;
@@ -28,7 +28,7 @@ function functionBody(source, name) {
28
28
  assert.fail(`${name} should close`);
29
29
  }
30
30
 
31
- assert.match(app, /import \{ classifyTranscriptStreamEvent, createStreamOutputController \} from "\.\/stream-output-controller\.mjs";/);
31
+ assert.match(app, /import \{[^}]*classifyTranscriptStreamEvent[^}]*createStreamOutputController[^}]*\} from "\.\/stream-output-controller\.mjs";/);
32
32
  assert.match(app, /let foregroundTranscriptCatchUpRequired = document\.visibilityState === "hidden";/);
33
33
 
34
34
  const beginCatchUp = functionBody(app, "beginForegroundTranscriptCatchUp");
@@ -115,7 +115,7 @@ assert.match(setModeSource, /if \(activeFileViewer\.mode === "changes" && previo
115
115
  assert.match(viewerUiSource, /const hasChanges = !!viewer\.gitChanges;/, "the viewer UI should derive Changes availability from the open-time snapshot");
116
116
  assert.match(viewerUiSource, /elements\.fileViewerChangesModeButton\.hidden = !hasChanges;\s*elements\.fileViewerChangesModeButton\.disabled = !hasChanges;/, "the Changes control should stay hidden and disabled for non-Git opens");
117
117
  assert.match(viewerUiSource, /elements\.fileViewerSourceModeButton\.disabled = !sourceAvailable;/, "Source should be disabled when the live file content is unavailable");
118
- assert.match(viewerUiSource, /elements\.fileViewerPreviewModeButton\.hidden = !isMarkdown;\s*elements\.fileViewerPreviewModeButton\.disabled = !isMarkdown \|\| !sourceAvailable;/, "Markdown Preview should stay hidden for non-Markdown and disabled when live source is unavailable");
118
+ assert.match(viewerUiSource, /elements\.fileViewerPreviewModeButton\.hidden = !isMarkdown && !isImage;\s*elements\.fileViewerPreviewModeButton\.disabled = \(!isMarkdown \|\| !sourceAvailable\) && !isImage;/, "Preview should be available for Markdown and supported images while remaining unavailable for other files");
119
119
  assert.match(viewerUiSource, /elements\.fileViewerEditor\.hidden = mode !== "source";/, "Source editing should remain bound to Source mode");
120
120
  assert.match(
121
121
  viewerUiSource,
@@ -171,10 +171,10 @@ assert.match(openFileSource, /const changesRequestSerial = category \? \+\+fileV
171
171
  assert.match(openFileSource, /const changesRequest = category \? loadGitFileChangesSnapshot\(changesPath, category, tabContext\.tabId\) : null;/, "only category-carrying opens should request a diff");
172
172
  assert.match(openFileSource, /const gitChanges = changesRequest \? gitFileChangesPlaceholder\(category, changesPath, changesRequestSerial\) : null;/, "normal File-section opens should carry no Git snapshot at all");
173
173
  assert.match(openFileSource, /applyGitFileChangesSnapshot\(changesRequest, tabContext, activeFileViewer\.path, changesRequestSerial\)/, "same-path Git requests should apply only through their captured request identity");
174
- assert.match(openFileSource, /mode: gitChanges \? "changes" : data\.language === "markdown" \? "preview" : "source",/, "Git opens should default to Changes while normal opens keep the Markdown/Source default");
174
+ assert.match(openFileSource, /mode: gitChanges \? "changes" : kind === "image" \? "image" : data\.language === "markdown" \? "preview" : "source",/, "Git opens should default to Changes while normal opens keep the Image/Markdown/Source default");
175
175
  assert.match(openFileSource, /if \(!isCurrentTabContext\(tabContext\) \|\| openRequestSerial !== fileViewerOpenRequestSerial\) return;/, "the source-success path should reject stale same-tab viewer opens");
176
176
  assert.match(openFileSource, /const gitChanges = changesRequest \? await changesRequest : null;\s*if \(!isCurrentTabContext\(tabContext\) \|\| openRequestSerial !== fileViewerOpenRequestSerial\) return;/, "the deleted-file fallback should reject stale same-tab viewer opens after awaiting the diff");
177
- assert.match(openFileSource, /readOnly: false,\s*sourceAvailable: true,/, "a live Git-originated file should stay editable");
177
+ assert.match(openFileSource, /readOnly: kind === "image",\s*sourceAvailable: kind === "text",/, "a live Git-originated text file should stay editable while image previews remain read-only");
178
178
  assert.match(
179
179
  openFileSource,
180
180
  /const gitChanges = changesRequest \? await changesRequest : null;\s*if \(!isCurrentTabContext\(tabContext\) \|\| openRequestSerial !== fileViewerOpenRequestSerial\) return;\s*if \(gitChanges && !gitChanges\.error\) \{/,
@@ -195,7 +195,7 @@ assert.match(viewerPersistenceSource, /fileViewersByTab\.set\(tabId, activeFileV
195
195
  assert.match(viewerPersistenceSource, /fileViewerSelectionsByTab\.set\(tabId, fileViewerSelection\)/, "caching a terminal should retain its active file selection");
196
196
  assert.match(viewerPersistenceSource, /activeFileViewer = activeTabId \? fileViewersByTab\.get\(activeTabId\) \|\| null : null;\s*fileViewerSelection = activeTabId \? fileViewerSelectionsByTab\.get\(activeTabId\) \|\| null : null;\s*updateFileViewerUi\(\);/, "activating a terminal should restore its own viewer and selection");
197
197
  assert.match(viewerPersistenceSource, /function closeFileViewer\(\) \{\s*if \(activeTabId\) \{\s*fileViewersByTab\.delete\(activeTabId\);\s*fileViewerSelectionsByTab\.delete\(activeTabId\);/, "explicitly closing a viewer should remove only the active terminal's cached state");
198
- assert.match(switchTabSource, /cacheActiveFileViewerForTab\(activeTabId\);\s*const tabContext = setActiveTabId\(tabId, \{ remember: true \}\);/, "switching terminals should cache the outgoing viewer before changing the active tab identity");
198
+ assert.match(switchTabSource, /cacheActiveFileViewerForTab\(activeTabId\);[\s\S]*?const tabContext = setActiveTabId\(tabId, \{ remember: true \}\);/, "switching terminals should cache the outgoing viewer before changing the active tab identity");
199
199
  assert.match(resetActiveTabUiSource, /resetFileViewerUi\(\);\s*resetFileTreeState\(\);\s*restoreFileViewerForActiveTab\(\);/, "resetting tab UI should restore the incoming terminal's viewer instead of closing it");
200
200
  assert.match(closeTabsSource, /fileViewersByTab\.delete\(id\);\s*fileViewerSelectionsByTab\.delete\(id\);/, "closing terminal tabs should discard their cached viewers and selections");
201
201
 
@@ -228,7 +228,7 @@ assert.match(changesRenderSource, /return renderGitDiffFile\(gitUntrackedEntryTo
228
228
  assert.match(changesRenderSource, /if \(entry\.contentMissing\) return fileViewerChangesNotice\("Untracked file content is unavailable\.", "error"\);/, "an untracked response without content should not pretend the file is empty");
229
229
  assert.doesNotMatch(changesRenderSource, /runGitFileAction|gitChangesFileActionsFor|gitFileActionButtons/, "the read-only changes surface must not expose staging or discard actions");
230
230
 
231
- assert.match(css, /\.file-viewer-editor,\n\.file-viewer-preview,\n\.file-viewer-changes \{/, "the changes surface should share the file viewer content frame");
231
+ assert.match(css, /\.file-viewer-editor,\n\.file-viewer-preview,\n\.file-viewer-image,\n\.file-viewer-changes \{/, "the text, image, and changes surfaces should share the file viewer content frame");
232
232
  assert.match(css, /\.file-viewer-changes \{\n\s*padding: 0\.72rem;\n\}/, "the changes surface should have its own padding inside the shared frame");
233
233
  assert.match(css, /\.file-viewer-changes \.git-diff-grid \{[\s\S]*grid-template-columns:[\s\S]*min-width: 30rem;[\s\S]*\}/, "the split diff grid should be narrowed for the file viewer pane");
234
234
  assert.match(css, /\.file-viewer-changes-notice \{[\s\S]*font-size: var\(--text-xs\);[\s\S]*\}\n\.file-viewer-changes-notice\.error \{ color: var\(--ctp-red\); \}/, "changes notices should be readable and mark errors distinctly");
@@ -4,11 +4,11 @@ import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
6
6
  const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
- const [app, server, watcher, readme] = await Promise.all([
7
+ const [app, server, watcher, development] = await Promise.all([
8
8
  readFile(join(root, "public", "app.js"), "utf8"),
9
9
  readFile(join(root, "bin", "pi-webui.mjs"), "utf8"),
10
10
  readFile(join(root, "lib", "git-live-watcher.mjs"), "utf8"),
11
- readFile(join(root, "README.md"), "utf8"),
11
+ readFile(join(root, "DEVELOPMENT.md"), "utf8"),
12
12
  ]);
13
13
 
14
14
  function functionBody(source, name) {
@@ -49,6 +49,6 @@ assert.match(invalidateRepository, /if \(!gitPanelSectionExpanded\(\)\) return;/
49
49
  assert.match(ensureVisibleFresh, /snapshot\?\.error/, "persistent Git read errors should not cause an unbounded render/reload loop");
50
50
  assert.match(ensureVisibleFresh, /gitPanelSnapshotFresh\(snapshot\)[\s\S]*loadGitPanelRepository\(card\)/, "visible stale repositories should refresh on render");
51
51
  assert.match(handleEvent, /case "webui_git_changed":[\s\S]*invalidateGitPanelRepository\(event\.root\)/, "the browser event stream should route Git invalidations to the cache");
52
- assert.match(readme, /live filesystem updates[\s\S]*SSE/, "README should document live watcher-driven Git refresh behavior");
52
+ assert.match(development, /live filesystem updates[\s\S]*SSE/, "development guide should document live watcher-driven Git refresh behavior");
53
53
 
54
54
  console.log("git-panel-live-updates-static.test.mjs passed");
@@ -60,7 +60,7 @@ try {
60
60
  uiLayout: completeV1Layout,
61
61
  }, null, 2)}\n`, "utf8");
62
62
  const migrated = await readWebuiSettings(settingsFile);
63
- assert.equal(migrated.version, 7);
63
+ assert.equal(migrated.version, 8);
64
64
  assert.equal(migrated.remoteAuthEnabled, true, "legacy Remote PIN state should survive schema migration");
65
65
  assert.equal(migrated.outputModeDefault, "normal", "legacy settings should default browser output to normal");
66
66
  assert.equal(isGitWorkflowSetupComplete(migrated.gitWorkflow), false);
@@ -84,7 +84,7 @@ try {
84
84
  );
85
85
  assert.deepEqual(migrated.uiLayout.composerActions, completeV1Layout.composerActions);
86
86
  assert.deepEqual(migrated.uiLayout.footerScopedModelOrder, completeV1Layout.footerScopedModelOrder);
87
- assert.deepEqual(migrated.uiLayout.terminalTabs, completeV1Layout.terminalTabs);
87
+ assert.deepEqual(migrated.uiLayout.terminalTabs, { ...completeV1Layout.terminalTabs, sidebarWidth: null });
88
88
  assert.equal(migrated.uiLayout.fileViewerWidth, 560);
89
89
 
90
90
  await writeFile(settingsFile, `${JSON.stringify({
@@ -127,11 +127,11 @@ try {
127
127
  assert.equal(partiallyUpdated.reviewProcessEnabled, false, "partial updates should preserve the review-process choice");
128
128
 
129
129
  const persisted = JSON.parse(await readFile(settingsFile, "utf8"));
130
- assert.equal(persisted.version, 7);
130
+ assert.equal(persisted.version, 8);
131
131
  assert.equal(persisted.uiLayout.version, 2, "the first unrelated locked write must persist the migrated v2 envelope");
132
132
  assert.deepEqual(persisted.uiLayout.sidePanel.sectionLayout, { order: ["files", "controls", "git"], leftSectionIds: [] });
133
133
  assert.deepEqual(persisted.uiLayout.composerActions, completeV1Layout.composerActions, "unchanged v1 composer fields must survive persistence");
134
- assert.deepEqual(persisted.uiLayout.terminalTabs, completeV1Layout.terminalTabs, "unchanged v1 terminal fields must survive persistence");
134
+ assert.deepEqual(persisted.uiLayout.terminalTabs, { ...completeV1Layout.terminalTabs, sidebarWidth: null }, "unchanged v1 terminal fields must survive persistence while new width state defaults safely");
135
135
  assert.equal(persisted.remoteAuthEnabled, true);
136
136
  assert.equal(persisted.outputModeDefault, "compact-v1", "output-mode default should persist beside existing Web UI settings");
137
137
  assert.equal(persisted.gitWorkflow.generation.provider, "fake");