@firstpick/pi-package-webui 0.9.6 → 0.9.7

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 +7 -3
  2. package/bin/pi-webui.mjs +367 -72
  3. package/lib/git-workflow-preferences.mjs +21 -1
  4. package/lib/session-tree-event-targets.mjs +70 -0
  5. package/lib/subagent-launch-policy.mjs +375 -0
  6. package/lib/subagent-launch-slots.mjs +2 -1
  7. package/package.json +1 -1
  8. package/public/app.js +721 -35
  9. package/public/index.html +38 -2
  10. package/public/service-worker.js +1 -1
  11. package/public/styles.css +254 -3
  12. package/tests/boot-failure-diagnostics.test.mjs +3 -3
  13. package/tests/browser/control-visibility.spec.mjs +141 -2
  14. package/tests/browser/events-tree-context-menu.spec.mjs +240 -0
  15. package/tests/browser/guided-git-fallback.spec.mjs +153 -0
  16. package/tests/codex-fast-mode-static.test.mjs +2 -2
  17. package/tests/compact-sections-static.test.mjs +4 -0
  18. package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
  19. package/tests/control-visibility-static.test.mjs +66 -3
  20. package/tests/controls-layout-static.test.mjs +3 -3
  21. package/tests/events-tree-context-menu-static.test.mjs +131 -0
  22. package/tests/fast-mode-client-static.test.mjs +5 -2
  23. package/tests/feature-decision-output-popup-static.test.mjs +2 -2
  24. package/tests/file-viewer-image-static.test.mjs +3 -3
  25. package/tests/git-workflow-preferences.test.mjs +30 -1
  26. package/tests/guided-git-fallback-runtime.test.mjs +418 -0
  27. package/tests/guided-git-fallback-ui-static.test.mjs +60 -0
  28. package/tests/guided-git-message-reliability-static.test.mjs +8 -7
  29. package/tests/intercom-conversation-viewer-static.test.mjs +3 -3
  30. package/tests/main-output-loading-static.test.mjs +3 -3
  31. package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
  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 +7 -5
  36. package/tests/open-issue-wizard-static.test.mjs +1 -1
  37. package/tests/persistent-ui-layout-static.test.mjs +3 -3
  38. package/tests/prompt-input-vertical-scroll-static.test.mjs +3 -3
  39. package/tests/questionnaire-dialog.test.mjs +3 -3
  40. package/tests/remote-auth-settings-harness.test.mjs +23 -0
  41. package/tests/resource-defaults-helper.test.mjs +12 -0
  42. package/tests/session-sampling-helper.test.mjs +1 -0
  43. package/tests/session-sampling-ui-static.test.mjs +3 -3
  44. package/tests/session-tree-event-targets.test.mjs +106 -0
  45. package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
  46. package/tests/subagent-launch-policy.test.mjs +532 -0
  47. package/tests/subagent-observability-static.test.mjs +2 -2
  48. package/tests/subagents-helper.test.mjs +211 -1
  49. package/tests/syntax-highlighting-static.test.mjs +3 -3
  50. package/tests/tab-close-continuity-static.test.mjs +23 -0
  51. package/tests/theme-customizer-static.test.mjs +1 -1
  52. package/webui-rpc-helper.mjs +220 -3
@@ -0,0 +1,131 @@
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
+
6
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
7
+ const [html, app, styles, serviceWorker] = await Promise.all([
8
+ readFile(join(root, "public", "index.html"), "utf8"),
9
+ readFile(join(root, "public", "app.js"), "utf8"),
10
+ readFile(join(root, "public", "styles.css"), "utf8"),
11
+ readFile(join(root, "public", "service-worker.js"), "utf8"),
12
+ ]);
13
+
14
+ function functionSource(source, name) {
15
+ const start = source.indexOf(`function ${name}(`);
16
+ assert.ok(start >= 0, `${name} should exist`);
17
+ const next = source.slice(start + 1).match(/\n(?:async )?function [A-Za-z0-9_$]+\(/);
18
+ const end = next ? start + 1 + next.index : source.length;
19
+ return source.slice(start, end);
20
+ }
21
+
22
+ // Dedicated, labelled menu markup.
23
+ assert.match(html, /<div id="eventTreeContextMenu"[^>]*role="menu"[^>]*aria-labelledby="eventTreeContextMenuLabel"[^>]*hidden>/, "Events should own a labelled context menu");
24
+ assert.match(html, /id="eventDisplayDetailedAction"[^>]*role="menuitemradio"[^>]*aria-checked="true"[^>]*>Detailed<\/button>/, "the menu should expose Detailed as the default mode");
25
+ assert.match(html, /id="eventDisplayCompactAction"[^>]*role="menuitemradio"[^>]*aria-checked="false"[^>]*>Compact<\/button>/, "the menu should expose Compact mode");
26
+ assert.match(html, /role="separator"[\s\S]*id="eventTreeContextMenuAction"[^>]*role="menuitem"[^>]*>Tree…<\/button>[\s\S]*id="eventTreeContextMenuStatus"[^>]*role="status"/, "display choices should stay separate from Tree navigation and live feedback");
27
+ assert.match(html, /<label for="eventFilterSelect">Show<\/label>[\s\S]*id="eventFilterSelect"[\s\S]*value="all">All events<[\s\S]*value="errors">Errors \/ failures<[\s\S]*value="warnings">Warnings<[\s\S]*value="tools">Tool activity<[\s\S]*value="tree">Tree available</, "Events should expose the recommended native filter choices");
28
+ assert.match(html, /id="eventFilterStatus"[^>]*role="status"[^>]*aria-live="polite"[\s\S]*id="eventFilterEmpty"[^>]*hidden/, "the filter should expose live counts and an empty state");
29
+
30
+ const normalizeDisplaySource = functionSource(app, "normalizeEventDisplayMode");
31
+ assert.match(normalizeDisplaySource, /value === "compact" \? "compact" : "detailed"/, "unknown values should fall back to detailed mode");
32
+ assert.match(functionSource(app, "readStoredEventDisplayMode"), /localStorage\.getItem\(EVENT_DISPLAY_MODE_STORAGE_KEY\)/, "the display preference should restore from browser-local storage");
33
+ const setDisplaySource = functionSource(app, "setEventDisplayMode");
34
+ assert.match(setDisplaySource, /localStorage\.setItem\(EVENT_DISPLAY_MODE_STORAGE_KEY, eventDisplayMode\)/, "display choices should persist");
35
+ assert.match(functionSource(app, "syncEventDisplayModeUi"), /eventLog\.dataset\.displayMode = eventDisplayMode[\s\S]*eventDisplayDetailedAction[\s\S]*eventDisplayCompactAction/, "the current choice should update the log and radio menu state");
36
+
37
+ const normalizeFilterSource = functionSource(app, "normalizeEventFilter");
38
+ assert.match(normalizeFilterSource, /EVENT_FILTER_VALUES\.has\(value\) \? value : "all"/, "unknown filters should fall back to all events");
39
+ assert.match(functionSource(app, "readStoredEventFilter"), /localStorage\.getItem\(EVENT_FILTER_STORAGE_KEY\)/, "the event filter should restore from browser-local storage");
40
+ const filterMatchSource = functionSource(app, "eventRowMatchesFilter");
41
+ for (const contract of [
42
+ /filter === "errors"[\s\S]*eventLevel === "error"/,
43
+ /filter === "warnings"[\s\S]*eventLevel === "warn"/,
44
+ /filter === "tools"[\s\S]*eventToolPhase/,
45
+ /filter === "tree"[\s\S]*eventTreeAvailable === "true"/,
46
+ ]) assert.match(filterMatchSource, contract, "each visible filter should have an explicit row predicate");
47
+ const applyFilterSource = functionSource(app, "applyEventFilter");
48
+ assert.match(applyFilterSource, /line\.hidden = !matches[\s\S]*eventFilterStatus[\s\S]*eventFilterEmpty\.hidden/, "filtering should hide rows in place and update count and empty-state feedback");
49
+ const setFilterSource = functionSource(app, "setEventFilter");
50
+ assert.match(setFilterSource, /localStorage\.setItem\(EVENT_FILTER_STORAGE_KEY, eventFilter\)/, "filter choices should persist");
51
+ assert.match(app, /eventFilterSelect\?\.addEventListener\("change"[\s\S]*setEventFilter\(elements\.eventFilterSelect\.value\)/, "the native select should apply its selected filter");
52
+ assert.match(app, /event\.key === EVENT_FILTER_STORAGE_KEY[\s\S]*setEventFilter\(event\.newValue, \{ persist: false \}\)/, "filter changes should synchronize across same-origin tabs");
53
+
54
+ // Bounded event details: explicit target allowlist, status, duration, and shortened ID.
55
+ const targetSource = functionSource(app, "boundedToolEventTarget");
56
+ for (const toolName of ["read", "write", "edit", "grep", "find", "ls"]) {
57
+ assert.ok(app.includes(`["${toolName}", "path"]`), `${toolName} should be in the explicit path-target allowlist`);
58
+ }
59
+ assert.match(targetSource, /typeof value !== "string"/, "allowlisted details should accept only string fields");
60
+ assert.match(targetSource, /singleLine\.length > 96/, "allowlisted target text should be bounded");
61
+ assert.doesNotMatch(targetSource, /JSON\.stringify|\.result|\.output|Object\.values|Object\.entries/, "event details must not serialize arbitrary args or inspect output");
62
+ const detailsSource = functionSource(app, "toolLifecycleEventDetails");
63
+ for (const label of ["target", "status", "duration", "call"]) {
64
+ assert.ok(detailsSource.includes(`label: "${label}"`), `tool details should expose bounded ${label} metadata`);
65
+ }
66
+ assert.match(functionSource(app, "shortenedToolCallId"), /slice\(0, 7\)[\s\S]*slice\(-5\)/, "long call IDs should be visibly shortened");
67
+ const lifecycleArgumentsSource = functionSource(app, "toolLifecycleEventArguments");
68
+ assert.match(lifecycleArgumentsSource, /toolEventStartedAt\.set\(timerKey, \{ startedAt: occurredAt, target: boundedToolEventTarget\(event\) \}\)/, "start records should retain only timing and already bounded target text");
69
+ assert.doesNotMatch(lifecycleArgumentsSource, /args:|arguments:|invocation:|\.\.\.event|JSON\.stringify/, "start records must not retain raw tool arguments");
70
+ assert.match(lifecycleArgumentsSource, /toolLifecycleEventDetails[\s\S]*toolEventStartedAt\.delete/, "completion rows should consume and remove the matching bounded start record");
71
+ assert.match(detailsSource, /phase === "finish"[\s\S]*toolEventStartedAt\.get\(toolEventTimerKey\(event\)\)[\s\S]*boundedToolEventTarget\(event\) \|\| startRecord\?\.target/, "finish rows should reuse the matching bounded start target when completion args omit it");
72
+
73
+ // Every row exposes display choices; stable lifecycle rows alone expose Tree navigation.
74
+ const addEventSource = functionSource(app, "addEvent");
75
+ assert.match(addEventSource, /const toolLifecycle = \["start", "finish"\]\.includes\(toolEventPhase\)[\s\S]*stableToolCallId && toolLifecycle/, "only stable lifecycle rows should be Tree eligible");
76
+ assert.match(addEventSource, /line\.dataset\.eventLevel = String\(level[\s\S]*line\.dataset\.eventTreeAvailable = String\(!!treeEligible\)/, "rows should retain bounded filter metadata without copying payloads");
77
+ assert.match(addEventSource, /if \(toolLifecycle\) line\.dataset\.eventToolPhase = toolEventPhase/, "all tool lifecycle rows should remain visually identifiable in compact mode");
78
+ assert.match(addEventSource, /while \(elements\.eventLog\.children\.length > 120\)[\s\S]*applyEventFilter\(\)/, "new rows should apply the active filter after preserving the existing history bound");
79
+ assert.match(addEventSource, /setAttribute\("aria-keyshortcuts", "ContextMenu Shift\+F10"\)/, "every event row should expose keyboard display choices");
80
+ assert.match(addEventSource, /addEventListener\("click", \(\) => jumpToChatEvent\(line\)\)/, "event rows should preserve click-to-jump");
81
+ assert.match(
82
+ functionSource(app, "handleEvent"),
83
+ /case "tool_execution_start":[\s\S]*isIntercomTransportToolName\(event\.toolName\)[\s\S]*break;[\s\S]*toolLifecycleEventArguments\(event, "start"\)[\s\S]*case "tool_execution_end":[\s\S]*isIntercomTransportToolName\(event\.toolName\)[\s\S]*break;[\s\S]*toolLifecycleEventArguments\(event, "finish"\)/,
84
+ "hidden Intercom transport calls should still bypass event rows",
85
+ );
86
+
87
+ // Pointer and keyboard invocation, viewport clamping, focus, dismissal, and menu navigation.
88
+ assert.match(app, /eventLog\?\.addEventListener\("contextmenu"[\s\S]*closest\?\.\("\.event"\)[\s\S]*showEventTreeContextMenu\(event, line\)/, "every event row should support pointer display choices");
89
+ assert.match(app, /eventLog\?\.addEventListener\("keydown"[\s\S]*event\.key !== "ContextMenu"[\s\S]*event\.shiftKey && event\.key === "F10"[\s\S]*closest\?\.\("\.event"\)/, "every focused event row should support both keyboard invocations");
90
+ const showMenuSource = functionSource(app, "showEventTreeContextMenu");
91
+ assert.match(showMenuSource, /treeEligible = !!toolCallId[\s\S]*eventTreeContextMenuAction\.hidden = !treeEligible/, "Tree should appear only for eligible tool boundaries");
92
+ assert.match(showMenuSource, /window\.innerWidth - rect\.width[\s\S]*window\.innerHeight - rect\.height/, "the menu should clamp inside the viewport");
93
+ assert.match(showMenuSource, /eventDisplayCompactAction : elements\.eventDisplayDetailedAction[\s\S]*displayAction\?\.focus/, "the selected display choice should receive focus");
94
+ assert.match(functionSource(app, "closeOtherContextMenusForEventTree"), /closeFileContextMenu[\s\S]*closeGitPanelContextMenu[\s\S]*closeSidePanelContextMenu[\s\S]*closeVisibilityContextMenu[\s\S]*closeGitFooterContextMenu/, "opening Tree actions should close specialized context menus");
95
+ assert.match(app, /eventTreeContextMenu[^\n]*addEventListener\("keydown"[\s\S]*menuitemradio[\s\S]*"Escape"[\s\S]*"ArrowDown"[\s\S]*"ArrowUp"[\s\S]*"Home"[\s\S]*"End"/, "radio choices and Tree should share standard keyboard navigation");
96
+ assert.match(app, /eventTreeContextMenu && !elements\.eventTreeContextMenu\.hidden[\s\S]*event\.target\?\.closest\?\.\("\.event-tree-context-menu"\)[\s\S]*closeEventTreeContextMenu\(\)/, "outside pointer interaction should dismiss the menu");
97
+ assert.match(app, /window\.addEventListener\("resize", \(\) => closeEventTreeContextMenu\(\)/, "resize should dismiss the menu");
98
+ assert.match(app, /document\.addEventListener\("scroll"[\s\S]*closeEventTreeContextMenu\(\)/, "scroll should dismiss the menu");
99
+ assert.match(functionSource(app, "closeEventTreeContextMenu"), /trigger\?\.isConnected[\s\S]*trigger\.focus/, "closing should restore focus to a surviving event row");
100
+
101
+ // Action-time target resolution and exact no-summary navigation.
102
+ const targetEntrySource = functionSource(app, "eventTreeTargetEntryId");
103
+ assert.match(targetEntrySource, /data\?\.eventTargets/, "the action should use the minimal eventTargets contract");
104
+ assert.match(targetEntrySource, /state\.phase === "start" \? target\?\.startEntryId : target\?\.finishEntryId \|\| target\?\.startEntryId/, "start and finish boundaries should select the approved IDs");
105
+ assert.match(targetEntrySource, /nodes\.some\(\(node\) => node\?\.id === entryId\)/, "stale IDs should be rejected against current tree nodes");
106
+ const navigateSource = functionSource(app, "navigateEventTreeBoundary");
107
+ assert.match(navigateSource, /api\("\/api\/session-tree", \{ tabId: state\.tabContext\.tabId \}\)/, "targets should resolve from current session-tree data at action time");
108
+ assert.match(navigateSource, /appConfirm\(\{[\s\S]*Later entries stay in the tree[\s\S]*no automatic branch summary[\s\S]*Use \/tree to navigate back[\s\S]*danger: false/, "confirmation should explain branch effects and remain non-danger styled");
109
+ assert.match(navigateSource, /api\("\/api\/tree-navigate", \{[\s\S]*body: \{ entryId, summarize: false \}/, "acceptance should post the exact entry ID without summarization");
110
+ assert.ok(navigateSource.indexOf("if (!confirmed)") < navigateSource.indexOf('api("/api/tree-navigate"'), "cancel handling should return before any navigation POST");
111
+ const navigationPostIndex = navigateSource.indexOf('api("/api/tree-navigate"');
112
+ const postResponseSource = navigateSource.slice(navigationPostIndex);
113
+ assert.doesNotMatch(postResponseSource, /eventTreeContextMenuState !== state/, "post-confirmation response handling should not depend on menu visibility");
114
+ assert.match(postResponseSource, /if \(!isCurrentTabContext\(state\.tabContext\)\) return;[\s\S]*applyResponseTab\(result\)/, "successful responses should remain guarded by the originating tab generation");
115
+ assert.match(postResponseSource, /applyResponseTab\(result\)[\s\S]*title: "\/tree"[\s\S]*if \(eventTreeContextMenuState === state\) closeEventTreeContextMenu\(\)[\s\S]*await refreshAll\(state\.tabContext\)/, "success should apply response metadata, show /tree feedback, conditionally close the original menu, and refresh");
116
+ assert.match(navigateSource, /not available in the current persisted session tree[\s\S]*session was not changed/, "missing or stale targets should fail visibly without navigation");
117
+ assert.match(navigateSource, /state\.busy = true[\s\S]*action\.disabled = true[\s\S]*finally[\s\S]*action\.disabled = false/, "the action should preserve busy/error controls");
118
+
119
+ assert.match(styles, /\.event-filter-bar \{[\s\S]*grid-template-columns: auto minmax\(0, 1fr\) auto/, "the filter bar should keep its label, native select, and count aligned");
120
+ assert.match(styles, /\.event\[hidden\] \{ display: none; \}/, "filtered event rows should remain hidden despite the row display rule");
121
+ assert.match(styles, /\.event-details \{[\s\S]*flex-wrap: wrap/, "bounded details should wrap in detailed mode");
122
+ assert.match(styles, /\.event-log\[data-display-mode="compact"\] \.event-details \{ display: none; \}/, "compact mode should hide secondary metadata");
123
+ assert.match(styles, /\.event-log\[data-display-mode="compact"\] \.event\[data-event-tool-phase\][\s\S]*border-left:[\s\S]*\.event\[data-event-tool-phase="finish"\][\s\S]*border-left-color/, "compact tool events should retain visible lifecycle accents");
124
+ assert.match(styles, /\.event-tree-context-menu \{[\s\S]*max-width: calc\(100vw - 1rem\)/, "the dedicated menu should remain viewport bounded");
125
+
126
+ // Cache tuple for this browser-asset change.
127
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132";/, "the PWA cache identity should advance");
128
+ assert.match(html, /styles\.css\?v=137/, "compact-mode styles should advance the stylesheet revision");
129
+ assert.match(html, /data-app-src="\/app\.js\?v=166"/, "the app query revision should advance");
130
+
131
+ console.log("events-tree-context-menu-static.test.mjs passed");
@@ -47,6 +47,7 @@ const compactThinkingBubble = functionBody(app, "ensureCompactThinkingBubble");
47
47
  const compactToolShell = functionBody(app, "renderCompactToolShell");
48
48
  const clearCompactToolShells = functionBody(app, "clearCompactToolShells");
49
49
  const compactTranscript = functionBody(app, "renderCompactTranscriptBody");
50
+ const thinkingDisclosurePreviewText = functionBody(app, "thinkingDisclosurePreviewText");
50
51
  const compactThinkingDisclosureExpanded = functionBody(app, "compactThinkingDisclosureExpanded");
51
52
  const setCompactThinkingDisclosureExpanded = functionBody(app, "setCompactThinkingDisclosureExpanded");
52
53
  const clearCompactThinkingDisclosureState = functionBody(app, "clearCompactThinkingDisclosureState");
@@ -104,7 +105,9 @@ assert.match(appendTranscriptMessage, /compactTranscript && transcriptMessage\.r
104
105
  assert.match(compactThinkingSegments, /!thinkingOutputVisible\) return \[\][\s\S]*?message\?\.role === "thinking"[\s\S]*?assistantDisplayMessages\(message\)[\s\S]*?displayMessage\.role === "thinking"/, "fast mode should collect direct and embedded assistant thinking segments only when thinking output is enabled");
105
106
  assert.match(compactStoredTranscriptItems, /pendingThinking\.segments\.join\("\\n\\n"\)[\s\S]*?compactThinkingAggregate: true[\s\S]*?pendingThinking\.segments\.push\(\.\.\.thinkingSegments\)/, "thinking separated by tool calls should reconcile into one aggregate Markdown payload");
106
107
  assert.match(compactStoredTranscriptItems, /message\?\.role === "user"\) flushThinking\(\)[\s\S]*?message\?\.role === "assistant"\) flushThinking\(\)/, "aggregate thinking should stay bounded to one user turn and end before its final assistant output");
107
- assert.match(createMessageBubble, /compactThinkingAggregate = compactOutputActive\(\)[\s\S]*?message\.compactThinkingAggregate === true[\s\S]*?isCollapsibleOutput = compactThinkingAggregate[\s\S]*?defaultExpanded = message\.compactThinkingDefaultExpanded === true[\s\S]*?details\.open = compactThinkingDisclosureExpanded\(message\.compactThinkingKey, defaultExpanded\)[\s\S]*?setCompactThinkingDisclosureExpanded\(message\.compactThinkingKey, details\.open, defaultExpanded\)[\s\S]*?else if \(shouldOpenMessageCollapseByDefault/, "aggregate thinking should use a native disclosure with role-specific defaults and preserve explicit toggles across reconciliation");
108
+ assert.match(createMessageBubble, /compactThinkingAggregate = compactOutputActive\(\)[\s\S]*?message\.compactThinkingAggregate === true[\s\S]*?isCollapsibleOutput = compactThinkingAggregate[\s\S]*?defaultExpanded = message\.compactThinkingDefaultExpanded === true[\s\S]*?details\.open = compactThinkingDisclosureExpanded\(message\.compactThinkingKey, defaultExpanded\)[\s\S]*?setCompactThinkingDisclosureExpanded\(message\.compactThinkingKey, details\.open, defaultExpanded\)[\s\S]*?thinkingDisclosurePreviewText\(message\)[\s\S]*?else if \(shouldOpenMessageCollapseByDefault/, "thinking disclosures should preserve their defaults and use the cleaned preview helper");
109
+ assert.match(thinkingDisclosurePreviewText, /visibleThinkingText\(message\?\.thinking \|\| textFromContent\(message\?\.content\)\)[\s\S]*?speakableTextFromMarkdown\(raw\)\.slice\(0, Math\.max\(0, charLimit\)\)/, "collapsed thinking previews should strip Markdown before applying the length limit");
110
+ assert.match(styles, /\.thinking-disclosure > \.message-header \{[\s\S]*?display: grid;[\s\S]*?"role timestamp disclosure"[\s\S]*?"preview preview preview"[\s\S]*?\.thinking-disclosure > \.message-header::after \{ grid-area: disclosure; margin-left: 0; \}/, "collapsed thinking should keep the disclosure arrow in the top header row");
108
111
  assert.match(compactThinkingDisclosureExpanded, /compactThinkingDisclosureStateByTab\.get\(activeTabId \|\| "default"\)[\s\S]*?disclosureState\?\.has\(key\)[\s\S]*?!!defaultExpanded/, "aggregate disclosure state should be isolated per terminal tab and fall back to the role-specific default");
109
112
  assert.match(setCompactThinkingDisclosureExpanded, /expanded === defaultExpanded[\s\S]*?disclosureState\?\.delete\(key\)[\s\S]*?disclosureState = new Map\(\)[\s\S]*?disclosureState\.set\(key, !!expanded\)/, "aggregate disclosure state should store only explicit overrides from the role-specific default");
110
113
  assert.match(clearCompactThinkingDisclosureState, /disclosureState\?\.delete\(key\)[\s\S]*?compactThinkingDisclosureStateByTab\.delete\(tabId\)/, "stream resets should remove a live disclosure override without changing its expanded default");
@@ -156,7 +159,7 @@ assert.match(worker, /pi-webui-pwa-v\d+[\s\S]*?"\/fast-output-live\.mjs"/, "PWA
156
159
  assert.match(html, /<label for="fastOutputModeSelect">Compact mode \(Experimental\)<\/label>/, "the sidebar should mark compact mode as experimental");
157
160
  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
161
  // 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=157"/, "the guarded PWA entry point should cache-bust browser wiring");
162
+ assert.match(html, /id="webuiBootLoader"[^>]*data-app-src="\/app\.js\?v=166"/, "the guarded PWA entry point should cache-bust browser wiring");
160
163
  assert.match(JSON.parse(packageRaw).scripts.check, /node --check public\/fast-output-live\.mjs/, "package checks should parse the compact helper");
161
164
 
162
165
  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=132/, "integrated stylesheet changes should advance the cache query");
170
- assert.match(html, /\/app\.js\?v=157/, "integrated app changes should advance the cache query");
169
+ assert.match(html, /\/styles\.css\?v=137/, "integrated stylesheet changes should advance the cache query");
170
+ assert.match(html, /\/app\.js\?v=166/, "integrated app changes should advance the cache query");
171
171
 
172
172
  console.log("feature decision-output popup static checks passed");
@@ -62,8 +62,8 @@ assert.match(css, /\.file-viewer-image img \{[\s\S]*max-width: 100%;[\s\S]*max-h
62
62
  assert.match(readme, /PNG, JPEG, GIF, WebP, and AVIF/i, "the Files panel guide should list supported image formats");
63
63
  assert.match(technical, /supported raster images[\s\S]*2 MiB/i, "the advanced reference should document image support and its size limit");
64
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-v123"/, "changed viewer assets should advance the PWA cache identity");
66
- assert.match(html, /styles\.css\?v=132/, "changed image styles should advance the stylesheet revision");
67
- assert.match(html, /app\.js\?v=157/, "changed image rendering should advance the app revision");
65
+ assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v132"/, "changed viewer assets should advance the PWA cache identity");
66
+ assert.match(html, /styles\.css\?v=137/, "changed image styles should advance the stylesheet revision");
67
+ assert.match(html, /app\.js\?v=166/, "changed image rendering should advance the app revision");
68
68
 
69
69
  console.log("file viewer image static tests passed");
@@ -69,6 +69,12 @@ try {
69
69
  assert.equal(migrated.gitWorkflow.stagingPolicy, "review");
70
70
  assert.equal(migrated.gitWorkflow.reviewProcessEnabled, true, "legacy settings should preserve the existing review-process behavior");
71
71
  assert.equal(migrated.gitWorkflow.generation.thinkingLevel, "low");
72
+ assert.deepEqual(migrated.gitWorkflow.generation.fallback, {
73
+ provider: "",
74
+ modelId: "",
75
+ thinkingLevel: "low",
76
+ }, "legacy settings should keep fallback explicitly disabled");
77
+ assert.equal(isGitWorkflowSetupComplete({ ...migrated.gitWorkflow, generation: { provider: "fake", modelId: "fake-model", thinkingLevel: "off" } }), true, "fallback must remain optional for setup completeness");
72
78
  assert.equal(migrated.uiLayout.version, 3);
73
79
  assert.equal(migrated.uiLayout.sidePanel.placement, "right");
74
80
  assert.deepEqual(migrated.uiLayout.sidePanel.sectionLayout, { order: ["files", "controls", "git"], leftSectionIds: [] });
@@ -97,7 +103,13 @@ try {
97
103
  assert.equal((await readWebuiSettings(settingsFile)).outputModeDefault, "normal", "invalid persisted output modes must fail closed to normal");
98
104
 
99
105
  const saved = await writeGitWorkflowPreferences({
100
- generation: { provider: "fake", modelId: "fake-model", thinkingLevel: "off", unavailablePolicy: "ask" },
106
+ generation: {
107
+ provider: "fake",
108
+ modelId: "fake-model",
109
+ thinkingLevel: "off",
110
+ unavailablePolicy: "ask",
111
+ fallback: { provider: "other", modelId: "other-model", thinkingLevel: "medium" },
112
+ },
101
113
  commit: { language: "de", defaultVariant: "long", scope: "required" },
102
114
  stagingPolicy: "preserve",
103
115
  reviewProcessEnabled: false,
@@ -122,6 +134,17 @@ try {
122
134
 
123
135
  const partiallyUpdated = await writeGitWorkflowPreferences({ deliveryMode: "current" }, settingsFile);
124
136
  assert.equal(partiallyUpdated.generation.modelId, "fake-model", "partial updates should preserve the selected model");
137
+ assert.deepEqual(partiallyUpdated.generation.fallback, {
138
+ provider: "other",
139
+ modelId: "other-model",
140
+ thinkingLevel: "medium",
141
+ }, "unrelated partial updates should preserve the configured fallback");
142
+ const fallbackEffortOnly = await writeGitWorkflowPreferences({ generation: { fallback: { thinkingLevel: "high" } } }, settingsFile);
143
+ assert.deepEqual(fallbackEffortOnly.generation.fallback, {
144
+ provider: "other",
145
+ modelId: "other-model",
146
+ thinkingLevel: "high",
147
+ }, "nested fallback patches should preserve the selected fallback model");
125
148
  assert.equal(partiallyUpdated.commit.language, "de", "partial updates should preserve nested commit preferences");
126
149
  assert.equal(partiallyUpdated.deliveryMode, "current");
127
150
  assert.equal(partiallyUpdated.reviewProcessEnabled, false, "partial updates should preserve the review-process choice");
@@ -135,12 +158,18 @@ try {
135
158
  assert.equal(persisted.remoteAuthEnabled, true);
136
159
  assert.equal(persisted.outputModeDefault, "compact-v1", "output-mode default should persist beside existing Web UI settings");
137
160
  assert.equal(persisted.gitWorkflow.generation.provider, "fake");
161
+ assert.deepEqual(persisted.gitWorkflow.generation.fallback, {
162
+ provider: "other",
163
+ modelId: "other-model",
164
+ thinkingLevel: "high",
165
+ });
138
166
  assert.deepEqual(persisted.resourceDefaults.tools.enabledTools, ["read", "write"], "global tool defaults should be normalized and deduplicated");
139
167
  assert.deepEqual(persisted.resourceDefaults.skills.enabledSkills, ["repo-explorer", "code-security"], "global skill defaults should persist beside other Web UI settings");
140
168
  assert.equal(persisted.interfacePreferences.sidePanelWidth, 612, "the user-scoped Control Deck width should persist beside other Web UI settings");
141
169
  assert.equal((await readWebuiSettings(settingsFile)).interfacePreferences.sidePanelWidth, 612);
142
170
  const summary = gitWorkflowPreferencesSummary(await readGitWorkflowPreferences(settingsFile));
143
171
  assert.match(summary, /fake\/fake-model/);
172
+ assert.match(summary, /Fallback: other\/other-model · high/);
144
173
  assert.match(summary, /Review process: disabled/);
145
174
  if (process.platform !== "win32") assert.equal((await stat(settingsFile)).mode & 0o777, 0o600);
146
175