@firstpick/pi-package-webui 0.6.6 → 0.6.8

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.
@@ -25,6 +25,8 @@ const pkg = JSON.parse(pkgRaw);
25
25
  const manifest = JSON.parse(manifestRaw);
26
26
  const lock = JSON.parse(await readFile(join(root, "package-lock.json"), "utf8"));
27
27
  const helper = await readFile(join(root, "webui-rpc-helper.mjs"), "utf8");
28
+ const codexAuth = await readFile(join(root, "lib", "codex-usage-auth.mjs"), "utf8");
29
+ const nativeExportPayload = await readFile(join(root, "lib", "native-export-payload.mjs"), "utf8");
28
30
  const companionDependencies = {
29
31
  "@firstpick/pi-extension-bang-command-autocomplete": "^0.2.1",
30
32
  "@firstpick/pi-extension-btw": "^0.1.2",
@@ -39,7 +41,7 @@ const companionDependencies = {
39
41
  "@firstpick/pi-extension-tools": "^0.1.6",
40
42
  "@firstpick/pi-extension-workflows": "^0.1.2",
41
43
  "@firstpick/pi-package-remote-webui": "^0.1.5",
42
- "@firstpick/pi-prompts-git-pr": "^0.1.2",
44
+ "@firstpick/pi-prompts-git-pr": "^0.1.3",
43
45
  "@firstpick/pi-themes-bundle": "^0.1.4",
44
46
  };
45
47
 
@@ -78,6 +80,7 @@ assert.match(server, /const THINKING_LEVELS = \["off", "minimal", "low", "medium
78
80
  assert.match(html, /id="terminalTabsLayoutSelect"[\s\S]*<option value="left">Left sidebar<\/option>/, "side panel controls should expose a terminal-tabs layout selector");
79
81
  assert.match(html, /id="terminalTabsLayoutStatus"/, "terminal-tabs layout selector should expose status text");
80
82
  assert.match(html, /id="nativeCommandDialog"/, "native slash selector UI should have a dedicated dialog");
83
+ assert.match(html, /id="optionsSafetyGuardSetupButton"[\s\S]*data-command="\/safety-guard-setup"[\s\S]*Safety Guard Setup/, "Common Pi options should expose native Safety Guard Setup");
81
84
  assert.match(html, /id="optionsGitWorkflowSetupButton"[\s\S]*data-command="\/git-workflow-setup"[\s\S]*Guided Git Setup/, "Common Pi options should expose native Guided Git Setup");
82
85
  assert.match(html, /id="nativeCommandSearch"[^>]*type="search"/, "native slash selector dialog should expose a filter box");
83
86
  assert.match(html, /id="remoteQrDialog"[\s\S]*id="remoteQrBody"[\s\S]*id="remoteQrCopyButton"/, "remote WebUI should expose a dedicated QR popup dialog");
@@ -86,6 +89,8 @@ assert.match(html, /id="pathPickerCreateNameInput"[^>]*placeholder="New director
86
89
  assert.match(html, /id="pathPickerCreateButton"[^>]*>Create directory<\/button>/, "cwd picker should expose a create-directory action");
87
90
  assert.match(html, /id="pathPickerSearchInput"[^>]*type="search"[^>]*placeholder="Search current directory…"/, "cwd picker should expose a current-directory search box");
88
91
  assert.match(html, /id="pathPickerClearSearchButton"[^>]*hidden[^>]*>Clear<\/button>/, "cwd picker should expose a clear-search action");
92
+ assert.match(app, /function fileTreeGitStatusForEntry\(entry = \{\}\) \{\s+return fileTreeState\.gitStatusByPath\.get\(normalizeFileTreePath\(entry\.path \|\| ""\)\) \|\| null;\s+\}/, "file tree rendering should use the refreshed Git-status snapshot instead of stale status embedded in cached entries");
93
+ assert.match(app, /alternative: activeAgentTabs\.length[\s\S]*?count === 1[\s\S]*?"Cancel and keep this tab open\."[\s\S]*?confirmLabel: activeAgentTabs\.length \? "Close and stop work" : count === 1 \? "Close tab" : "Close tabs"/, "single-tab confirmation should use singular, non-contradictory close wording");
89
94
  assert.match(html, /id="optionalFeaturesBox"/, "side panel should expose optional feature status and controls");
90
95
  assert.match(html, /class="optional-features-description[\s\S]*href="https:\/\/github\.com\/Firstp1ck\/npm-packages\/issues\/new"[\s\S]*open a GitHub issue/, "optional features should link users to GitHub issues for additional feature requests");
91
96
  assert.doesNotMatch(html, /id="btwOverlayDialog"/, "/btw should not use a blocking modal overlay");
@@ -107,6 +112,12 @@ assert.match(html, /data-side-panel-section="controls"/, "side panel controls sh
107
112
  assert.match(html, /data-side-panel-section="commands"/, "side panel commands should live in a collapsible section");
108
113
  assert.match(html, /class="side-panel-section-toggle"[^>]*aria-controls="sidePanelSectionControls"/, "side panel section toggles should target their content panels");
109
114
  assert.match(html, /class="side-panel-section-label">Events<\/span>/, "side panel events should expose a section toggle label");
115
+ assert.match(app, /function addEvent\(message, level = "info", \{ toolCallId = "" \} = \{\}\)[\s\S]*?make\("button", `event \$\{level\}`[\s\S]*?chatEventTimestamp[\s\S]*?jumpToChatEvent\(line\)/, "event log entries should be keyboard-accessible controls that navigate into the chat");
116
+ assert.match(app, /function chatEventTargetForLine\(line\)[\s\S]*?chatToolCallId[\s\S]*?data-tool-call-id[\s\S]*?\.message\[data-chat-timestamp\]/, "event navigation should prefer exact tool cards and otherwise match the closest chat timestamp");
117
+ assert.match(app, /function jumpToChatEvent\(line\)[\s\S]*?setChatScrollTopInstant[\s\S]*?highlightChatEventTarget[\s\S]*?setSidePanelCollapsed\(true, \{ persist: false \}\)/, "event navigation should dismiss overlay sidebars, scroll the chat, and highlight its target");
118
+ assert.match(app, /function applyChatEventMetadata\(bubble, message\)[\s\S]*?bubble\.dataset\.chatTimestamp/, "rendered chat events should expose timestamps for sidebar navigation");
119
+ assert.match(app, /addEvent\(`tool \$\{event\.toolName\} started`, "info", \{ toolCallId: event\.toolCallId \}\)/, "tool start events should navigate to their exact tool card");
120
+ assert.match(css, /\.event:hover,[\s\S]*?\.message\.chat-event-target[\s\S]*?@keyframes chat-event-target-pulse/, "clickable events and highlighted chat targets should have visible interaction states");
110
121
  const sidePanelToggleStates = Array.from(
111
122
  html.matchAll(/class="side-panel-section-toggle"[^>]*aria-expanded="([^"]+)"/g),
112
123
  (match) => match[1],
@@ -173,6 +184,8 @@ assert.ok(
173
184
  );
174
185
  assert.match(html, /id="optionsConversationModeButton"[^>]*data-command="\/talk"[^>]*hidden[\s\S]*?<span>Start Conversation<\/span>/, "Options menu should include the feature-gated Natural Conversation toggle");
175
186
  assert.match(html, /id="conversationModeChip" class="composer-conversation-mode-chip"[\s\S]*hidden>Voice: off<\/button>/, "composer should expose a hidden-until-active conversation status chip");
187
+ assert.match(html, /id="workflowModeButton"[\s\S]*class="composer-workflow-mode-button"[\s\S]*aria-pressed="false"[\s\S]*hidden[\s\S]*<span>Workflow<\/span>/, "composer actions should expose a capability-gated Workflow Mode toggle");
188
+ assert.match(html, /id="workflowModeChip" class="composer-workflow-mode-chip"[\s\S]*hidden>Workflow: on<\/button>/, "composer should expose a hidden-until-active Workflow Mode chip");
176
189
  assert.match(html, /id="conversationModeEndButton" class="composer-conversation-end-button"[\s\S]*hidden>End conversation<\/button>/, "composer should expose a persistent End conversation button while active");
177
190
  assert.match(html, /id="conversationVoiceMenu" class="composer-publish-menu composer-conversation-voice-menu" hidden>[\s\S]*id="conversationVoiceButton"[\s\S]*id="conversationVoiceMenuPanel" class="composer-publish-menu-panel[\s\S]*id="conversationModeEndButton"/, "composer should expose the conversation voice menu (publish-menu pattern) next to the End conversation button");
178
191
  assert.match(app, /conversationVoiceMenuPanel: \$\("#conversationVoiceMenuPanel"\)/, "frontend should register the conversation voice menu panel");
@@ -209,7 +222,25 @@ assert.ok(
209
222
 
210
223
  assert.match(css, /--visual-viewport-height:\s*100dvh/, "CSS should define a visual viewport height fallback");
211
224
  assert.match(css, /color-scheme:\s*var\(--theme-color-scheme\)/, "CSS should allow JS-selected themes to update browser color-scheme");
212
- assert.match(css, /font-size:\s*80%/, "Web UI should render at 80% base scale for denser layout");
225
+ assert.match(css, /font-size:\s*100%/, "Web UI should preserve the browser base scale for accessible typography");
226
+ assert.match(css, /--text-xs:\s*0\.75rem/, "typography tokens should define a 12 px absolute floor");
227
+ assert.doesNotMatch(css, /font-size:\s*0\.(?:[0-6]\d*|7[0-4])rem/, "interface font declarations should not fall below the 0.75rem floor");
228
+ assert.match(html, /id="undoToast"[^>]*aria-live="polite"[^>]*aria-atomic="true"[^>]*hidden/, "reversible actions should expose a non-blocking live Undo notification");
229
+ assert.match(html, /id="undoToastButton"[^>]*>Undo<\/button>/, "Undo notification should expose an explicit Undo button");
230
+ assert.match(app, /function offerUndo\([\s\S]*?timeoutMs = 10000[\s\S]*?setTimeout\(dismissUndoToast, timeoutMs\)/, "Undo offers should expire after a clear bounded interval");
231
+ assert.match(app, /async function runOfferedUndo\(\)[\s\S]*?await pending\.undo\(\)[\s\S]*?settleUndoToast/, "Undo notification should execute asynchronous reversal callbacks and report the result");
232
+ assert.match(css, /\.undo-toast\.expiring \.undo-toast-progress \{ animation: undo-toast-expire var\(--undo-timeout\) linear forwards; \}/, "Undo notification should show its remaining lifetime visually");
233
+ assert.match(app, /message: `\$\{feature\.label\} was \$\{disabled \? "disabled" : "enabled"\}\.`,[\s\S]*?undo: \(\) => setOptionalFeatureDisabled/, "optional feature toggles should offer Undo");
234
+ assert.match(app, /message: `Deleted prompt list[\s\S]*?upsertStoredPromptList\(deleted\)/, "prompt-list deletion should offer restoration instead of only confirmation");
235
+ assert.match(app, /message: `Deleted custom app runner[\s\S]*?method: "POST", body: \{ runner: restoreRunner \}/, "custom runner deletion should offer restoration");
236
+ assert.match(app, /message: `Moved \$\{sourcePath\} to \$\{nextPath\}\.`,[\s\S]*?offerMoveUndo: false/, "file moves should offer a non-recursive move-back action");
237
+ assert.match(app, /message: "Remote access is open\."[\s\S]*?remoteWebuiCommand\("close", "\/remote close"\)/, "opening remote access should offer a quick return to local-only mode");
238
+ assert.doesNotMatch(app, /dashboardAction\("Start a conversation"/, "empty starter should not duplicate the already-focused conversation composer");
239
+ assert.match(app, /function emptyStartRecentWorkspaces\(\)[\s\S]*?typeof item\?\.cwd === "string"[\s\S]*?\^\\\[object Object\\\]\$[\s\S]*?filter\(Boolean\)\.slice\(0, 4\)/, "empty starter should normalize and reject invalid recent-workspace entries");
240
+ assert.match(app, /const recent = recentWorkspaces\.length \? make\("section", "empty-start-recent"\) : null/, "empty starter should omit the recent-workspaces section when no valid entries exist");
241
+ assert.match(app, /title: "Open workspace"[\s\S]*?title: "Resume session"[\s\S]*?title: "Branch worktree"/, "empty starter should prioritize the three useful workspace and session actions");
242
+ assert.match(css, /\.empty-start-actions \{ display: grid; grid-template-columns: repeat\(3, minmax\(0, 1fr\)\)/, "empty starter should present primary actions as a balanced desktop grid");
243
+ assert.match(css, /\.empty-start-action-copy span \{[\s\S]*?font-size: var\(--text-xs\)/, "empty starter actions should explain their outcome in readable supporting text");
213
244
  assert.match(css, /--background-glow-pink/, "CSS should expose theme-controlled page glow colors");
214
245
  assert.match(css, /--theme-background-image:\s*none/, "CSS should expose a theme-controlled page background image variable");
215
246
  assert.match(css, /var\(--theme-background-image\)/, "body background should include the selected theme background image layer");
@@ -243,7 +274,7 @@ assert.match(css, /\.skill-editor-dialog form \{[\s\S]*?height:\s*100%;[\s\S]*?m
243
274
  assert.match(css, /\.skill-editor-text \{[\s\S]*?overflow-x:\s*hidden;[\s\S]*?overflow-wrap:\s*anywhere;[\s\S]*?white-space:\s*pre-wrap/, "skill editor text should wrap long lines instead of horizontal scrolling");
244
275
  assert.match(css, /\.composer-busy-mode-menu \{[\s\S]*?bottom:\s*calc\(100% \+ 0\.22rem\);[\s\S]*?background:\s*var\(--ctp-crust\)/, "busy prompt behavior dropdown should expand above the tag with an opaque background");
245
276
  assert.match(css, /\.sticky-user-prompt-button \{[\s\S]*?grid-template-columns:\s*auto minmax\(0, 1fr\) auto/, "last-user-prompt jump control should render as a fixed transcript header");
246
- assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(pointer: coarse\) and \(hover: none\)[\s\S]*?\.sticky-user-prompt-button \{\n\s+grid-template-columns:\s*minmax\(0, 1fr\) auto;\n\s+min-height:\s*36px;[\s\S]*?\.sticky-user-prompt-text \{[\s\S]*?font-size:\s*0\.72rem/, "mobile last-user-prompt card should use compact height and text");
277
+ assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(pointer: coarse\) and \(hover: none\)[\s\S]*?\.sticky-user-prompt-button \{\n\s+grid-template-columns:\s*minmax\(0, 1fr\) auto;\n\s+min-height:\s*36px;[\s\S]*?\.sticky-user-prompt-text \{[\s\S]*?font-size:\s*var\(--text-xs\)/, "mobile last-user-prompt card should preserve compact height while respecting the text floor");
247
278
  assert.match(css, /\.message\.extension,[\s\S]*?\.message\.native/, "extension and native command output should have visible transcript styling");
248
279
  assert.match(app, /function remoteWebuiQrSvg\(qrLines = \[\]\)[\s\S]*?viewBox[\s\S]*?shape-rendering[\s\S]*?crispEdges/, "remote WebUI QR popup should render terminal QR output as square SVG modules");
249
280
  assert.match(app, /function showRemoteWebuiQrLoadingPopup\(message = "Opening Remote WebUI QR…"\)[\s\S]*?remote-qr-loading[\s\S]*?showModal\(\)/, "remote WebUI QR popup should show a loading state while QR generation is pending");
@@ -279,6 +310,11 @@ assert.match(css, /\.prompt-list-dialog \{[\s\S]*?width:\s*min\(58rem/, "prompt-
279
310
  assert.match(css, /\.prompt-list-editor-rows \{[\s\S]*?max-height:/, "prompt-list dialog should scroll long follow-up lists inside the editor");
280
311
  assert.match(css, /\.prompt-list-load-row \{[\s\S]*?grid-template-columns:\s*minmax\(0, 1fr\) auto auto/, "prompt-list load row should fit load and delete actions beside saved-list selection");
281
312
  assert.match(css, /\.side-panel-section-toggle \{[\s\S]*?justify-content:\s*space-between/, "side panel section toggles should align labels and chevrons");
313
+ assert.match(html, /id="stateDetails" class="session-details"[^>]*aria-label="Current session details"/, "session panel should expose a dedicated accessible details container");
314
+ assert.match(app, /function sessionCopyButton\([\s\S]*?await copyText\(value\)/, "session identifiers and files should be copyable");
315
+ assert.match(app, /function splitSessionFilePath\([\s\S]*?replace\(\/\^\\\/home/, "session file display should abbreviate home directories");
316
+ assert.match(css, /\.session-overview \{[\s\S]*?grid-template-columns:/, "session status and counts should have a scannable overview");
317
+ assert.match(css, /\.session-detail-value\.truncate[\s\S]*?text-overflow:\s*ellipsis/, "long session values should not overwhelm the side panel");
282
318
  assert.match(css, /\.server-restart-panel \{[\s\S]*?z-index:\s*62/, "server restart overlay should render above the offline shell");
283
319
  assert.match(css, /@keyframes server-restart-spin/, "server restart overlay should show a loading spinner");
284
320
  assert.match(css, /\.webui-version-badge,\n\.webui-dev-badge \{[\s\S]*?border-radius:\s*999px/, "Web UI version and dev indicators should render as compact title badges");
@@ -350,7 +386,7 @@ assert.match(css, /\.terminal-tabs-toggle-button \{ display: none; \}/, "termina
350
386
  assert.match(css, /@media \(max-width: 720px\) \{[\s\S]*?\.terminal-command-palette-button,\n\s+\.terminal-dashboard-button \{[\s\S]*?display:\s*inline-grid;/, "mobile header should keep the command palette button visible beside the dashboard button");
351
387
  assert.match(css, /\.command-palette-close-button \{[\s\S]*?min-width:\s*44px;[\s\S]*?min-height:\s*44px/, "command palette close button should meet touch-target sizing by default");
352
388
  assert.match(css, /@media \(max-width: 720px\) \{[\s\S]*?\.command-palette-dialog \{[\s\S]*?width:\s*min\(100vw - 0\.5rem, 42rem\)[\s\S]*?\.command-palette-list \{[\s\S]*?scrollbar-gutter:\s*auto;[\s\S]*?\.command-palette-item \{[\s\S]*?grid-template-columns:\s*minmax\(3\.4rem, 0\.26fr\) minmax\(0, 1fr\);[\s\S]*?min-height:\s*2\.72rem;/, "mobile command palette results should use compact two-column cards instead of tall one-column cards");
353
- assert.match(css, /@media \(max-width: 720px\) \{[\s\S]*?\.command-palette-item-kind \{[\s\S]*?font-size:\s*0\.56rem;[\s\S]*?\.command-palette-item-label \{ font-size:\s*0\.82rem; \}[\s\S]*?\.command-palette-item-description \{ font-size:\s*0\.6rem; \}/, "mobile command palette result text should be scaled down to fit compact cards");
389
+ assert.match(css, /@media \(max-width: 720px\) \{[\s\S]*?\.command-palette-item-kind \{[\s\S]*?font-size:\s*var\(--text-xs\);[\s\S]*?\.command-palette-item-label \{ font-size:\s*0\.82rem; \}[\s\S]*?\.command-palette-item-description \{ font-size:\s*var\(--text-xs\); \}/, "mobile command palette result text should respect the typography floor");
354
390
  assert.match(css, /body\.terminal-tabs-left \.chat-panel \{[\s\S]*?grid-template-columns:\s*clamp\(13rem, 18vw, 19rem\) minmax\(0, 1fr\)/, "terminal tabs left layout should split the chat panel into a sidebar and transcript area");
355
391
  assert.match(css, /body\.terminal-tabs-left \.terminal-tabs-shell \{[\s\S]*?grid-column:\s*1;[\s\S]*?grid-row:\s*1 \/ -1;[\s\S]*?flex-direction:\s*column/, "terminal tabs left layout should turn the top tab strip into a vertical sidebar");
356
392
  assert.match(css, /body\.terminal-tabs-left \.terminal-tabs \{[\s\S]*?flex-direction:\s*column/, "terminal tabs left layout should stack tabs vertically");
@@ -406,6 +442,9 @@ assert.match(css, /\.git-diff-grid \{[\s\S]*?grid-template-columns:\s*3\.8rem mi
406
442
  assert.match(html, /id="gitChangesDialog"[\s\S]*id="gitChangesRefreshButton"[\s\S]*id="gitChangesPullButton"[\s\S]*id="gitChangesBody"/, "git changes modal should expose refresh, pull controls, and a diff body");
407
443
  assert.match(app, /chip\.key === "changes"[\s\S]*?options\.onClick = openGitChangesDialog/, "footer CHANGES chip should open the git changes modal");
408
444
  assert.match(app, /async function loadGitChangesDialog[\s\S]*api\("\/api\/git-changes"/, "git changes modal should load diff data from the server endpoint");
445
+ assert.match(app, /"Resolve with agent"[\s\S]*api\("\/api\/git-operation\/resolve-with-agent", \{ method: "POST"[\s\S]*switchToResponseTab\(response\)/, "conflict panel should open the resolution agent in the new tab returned by the server");
446
+ assert.match(server, /function gitConflictResolutionAgentPrompt\(operation\)[\s\S]*Conflicted files:[\s\S]*Do not continue, skip, abort, commit, reset, or push[\s\S]*diff-filter=U is empty/, "server should build a bounded conflict handoff with operation safety and verification instructions");
447
+ assert.match(server, /"\/api\/git-operation\/resolve-with-agent"[\s\S]*openGitConflictResolutionAgentTab\(tab\)/, "server should expose conflict-resolution agent tab creation through the git operation routes");
409
448
  assert.match(app, /async function pullGitChangesDialog\(\)[\s\S]*api\("\/api\/git-changes\/pull", \{ method: "POST"/, "git changes modal should post to the pull endpoint from the Pull button");
410
449
  assert.match(app, /function gitDiffDisplayLine\(row, side\)[\s\S]*`-\$\{text\}`[\s\S]*`\+\$\{text\}`/, "git changes modal should render changed lines with +/- prefixes");
411
450
  assert.match(app, /function gitUntrackedEntryToDiffFile\(entry\)[\s\S]*?renderRowLimit:\s*Number\.POSITIVE_INFINITY[\s\S]*?type: "added"/, "untracked files should render as complete added-file diffs without the row preview cap");
@@ -433,7 +472,7 @@ assert.match(app, /async function createPathPickerDirectory\(\)/, "cwd picker sh
433
472
  assert.match(app, /function renderPathPickerDirectoryList\(\)[\s\S]*pathPickerDirectoryMatchesSearch/, "cwd picker should filter current-directory entries in the browser");
434
473
  assert.match(app, /elements\.pathPickerSearchInput\.addEventListener\("input", renderPathPickerDirectoryList\)/, "cwd picker should update directory matches as the user types");
435
474
  assert.match(app, /function shouldOpenCwdChangeInNewTab\(tab\) \{[\s\S]*!!tab\?\.conversationStarted[\s\S]*activeTabHasConversationMessages\(tab\)[\s\S]*stateHasVisibleWork\(currentState\)[\s\S]*tabHasActiveAgent\(tab\)/, "cwd changes for started conversations should be routed to a new tab");
436
- assert.match(app, /if \(shouldOpenCwdChangeInNewTab\(tab\)\) \{[\s\S]*await createTerminalTab\(cwd, \{ triggerButton: null \}\);[\s\S]*return;[\s\S]*window\.confirm\(`Restart/, "footer cwd changes should open a new tab before destructive cwd restarts once a session is active");
475
+ assert.match(app, /if \(shouldOpenCwdChangeInNewTab\(tab\)\) \{[\s\S]*await createTerminalTab\(cwd, \{ triggerButton: null \}\);[\s\S]*return;[\s\S]*await appConfirmText\(`Restart/, "footer cwd changes should open a new tab before app-confirmed cwd restarts once a session is active");
437
476
  assert.match(server, /async function createDirectoryPickerDirectory\(parentPath, nameValue, activeCwd\)/, "server should implement cwd picker directory creation");
438
477
  assert.match(server, /function directoryPickerActiveCwd\(req, url, body = \{\}\)/, "server should let the cwd picker run before any Pi tabs exist");
439
478
  assert.match(server, /url\.pathname === "\/api\/directories" && req\.method === "POST"/, "server should expose POST /api/directories for cwd picker directory creation");
@@ -500,7 +539,7 @@ assert.match(app, /backgroundClearButton\.addEventListener\("click"/, "side-pane
500
539
  assert.match(app, /initializeCustomBackground\(\)\.catch/, "startup should restore the saved custom background when theme loading fails");
501
540
  assert.match(app, /Restart Web UI to load themes/, "frontend should explain when a stale server cannot serve the themes endpoint");
502
541
  assert.match(app, /themeSelect\.addEventListener\("change"/, "side-panel theme selector should switch themes immediately");
503
- assert.match(app, /open \? "Close for network" : "Open to network"/, "network button should toggle from open to close action");
542
+ assert.match(app, /open \? "Close remote access" : "Open for remote access"/, "network button should use explicit remote-access labels for open and close actions");
504
543
  assert.match(app, /let networkStatusLoaded = false;/, "Remote WebUI QR auto-popup state should track the first loaded network status");
505
544
  assert.match(app, /const hadNetworkStatus = networkStatusLoaded;[\s\S]*if \(!hadNetworkStatus\) \{\n\s+remoteQrAutoPopupShown = true;\n\s+return;\n\s+\}[\s\S]*if \(!wasOpen && !remoteQrAutoPopupShown && isLocalWebuiBrowserOrigin\(\)\)/, "Remote WebUI QR should auto-open only after network access transitions open, not on initial refresh");
506
545
  assert.match(app, /remoteAuthToggle: \$\("#remoteAuthToggle"\)/, "Remote WebUI controls should bind the remote PIN auth toggle");
@@ -528,7 +567,7 @@ assert.match(server, /cwdExplicit: false/, "server should track whether startup
528
567
  assert.match(server, /return options\.cwdExplicit \? \[await createTab\(\)\] : \[\]/, "server should wait for UI cwd selection when no --cwd is supplied");
529
568
  assert.match(server, /async function resolvedPiCliScript\(\)[\s\S]*require\.resolve\.paths\(PI_CODING_AGENT_PACKAGE\)[\s\S]*nodeModulesRoot[\s\S]*dist[\s\S]*cli\.js/, "server should resolve the bundled Pi CLI through Node resolution roots so hoisted global installs can spawn RPC tabs");
530
569
  assert.match(server, /const bundledCli = await resolvedPiCliScript\(\)/, "standalone server should prefer the resolved Pi CLI script before falling back to PATH pi");
531
- assert.match(server, /if \(options\.piBinExplicit\) \{\n\s+const command = await resolvePiCommand\(updateArgs\)/, "explicit --pi JavaScript launchers should also work for update commands");
570
+ assert.match(server, /if \(options\.piBinExplicit\) \{\n\s+resolveCommand = \(args\) => resolvePiCommand\(args\)/, "explicit --pi JavaScript launchers should also work for capability checks and update commands");
532
571
  assert.match(app, /serverActionSelect\.addEventListener\("change", updateServerActionButton\)/, "Server action dropdown should control the guarded run button");
533
572
  assert.match(app, /runServerActionButton\.addEventListener\("click"[\s\S]*runSelectedServerAction/, "Server action run button should execute the selected action");
534
573
  assert.match(app, /api\("\/api\/restart", \{ method: "POST", scoped: false \}\)/, "Restart Server action should call the unscoped restart endpoint");
@@ -538,14 +577,15 @@ assert.match(app, /api\("\/api\/shutdown", \{ method: "POST", scoped: false \}\)
538
577
  assert.match(server, /url\.pathname === "\/api\/restart" && req\.method === "POST"/, "server should expose restart endpoint");
539
578
  assert.match(server, /PI_WEBUI_RESTORE_TABS: JSON\.stringify\(restorableTabs \|\| \[\]\)/, "server restart should preserve restorable tab metadata");
540
579
  assert.match(server, /if \(webuiDevServer\) env\.PI_WEBUI_DEV = "1";/, "server restart should explicitly preserve dev mode");
541
- assert.match(server, /const updateArgs = all \? \["update", "--all"\] : \["update"\]/, "server update should use pi update by default and pi update --all for package-inclusive updates");
542
- assert.match(server, /async function resolveUpdateTasks\(\{ all = false \} = \{\}\)[\s\S]*if \(!all\) return uniqueUpdateTasks\(\[piTask\]\)[\s\S]*currentWebuiPackageUpdateTask\(\)[\s\S]*agentPackageRootUpdateTask\(\)[\s\S]*projectPackageRootUpdateTasks\(\)[\s\S]*npmGlobalPackageRootUpdateTask\(\)[\s\S]*bunGlobalPackageRootUpdateTask\(\)/, "server all-update should run pi update plus detected local/global Pi package root tasks");
580
+ assert.match(server, /async function piUpdateCommandSupportsAll\(command\)[\s\S]*runCommand\(command\.command, command\.args \|\| \[\][\s\S]*piUpdateHelpSupportsAll/, "server should check the selected Pi executable's update help");
581
+ assert.match(server, /const supportsAll = all && await piUpdateCommandSupportsAll\(await resolveCommand\(\["update", "--help"\]\)\)[\s\S]*piUpdateCommandSteps\(\{ all, supportsAll \}\)/, "server should prefer --all only when the capability check succeeds");
582
+ assert.match(server, /async function resolveUpdateTasks\(\{ all = false \} = \{\}\)[\s\S]*const piTasks = await resolvePiUpdateCommands\(\{ all \}\)[\s\S]*if \(!all\) return uniqueUpdateTasks\(piTasks\)[\s\S]*currentWebuiPackageUpdateTask\(\)[\s\S]*agentPackageRootUpdateTask\(\)[\s\S]*projectPackageRootUpdateTasks\(\)[\s\S]*npmGlobalPackageRootUpdateTask\(\)[\s\S]*bunGlobalPackageRootUpdateTask\(\)/, "server all-update should run the selected Pi plan plus detected local/global Pi package root tasks");
543
583
  assert.match(server, /const UPDATE_PACKAGE_NAMES = \[\.\.\.new Set\(\[[\s\S]*WEBUI_CONTROLLED_PACKAGES[\s\S]*OPTIONAL_FEATURE_PACKAGES\.values\(\)/, "package-inclusive updates should include Web UI controlled Optional Feature packages");
544
- assert.match(app, /const command = all \? "pi update --all" : "pi update"/, "frontend update confirmation should describe self-only and all update commands");
584
+ assert.match(app, /const commandText = all \? '"pi update --all" when supported, otherwise "pi update --self" followed by "pi update --extensions"' : '"pi update --self"'/, "frontend update confirmation should describe capability selection and fallback");
545
585
  assert.match(app, /Optional Features, and detected Pi package roots/, "frontend all-update confirmation should describe optional-feature and detected-root coverage");
546
586
  assert.match(app, /api\(all \? "\/api\/update\?all=1" : "\/api\/update"/, "frontend all update should call the explicit all-mode endpoint");
547
- assert.match(html, /<option value="update-all">Update Pi \+ Packages &amp; Restart<\/option>/, "side panel should expose pi update --all as a separate server action");
548
- assert.match(readme, /`pi update` for Pi-only updates[\s\S]*`pi update --all` plus detected Web UI\/Optional Feature package-root updates/, "README should document self-only and expanded all update modes");
587
+ assert.match(html, /<option value="update-all">Update Pi \+ Packages &amp; Restart<\/option>/, "side panel should expose package-inclusive updates as a separate server action");
588
+ assert.match(readme, /first checks the selected Pi executable's `pi update --help`[\s\S]*uses `pi update --all` when advertised[\s\S]*otherwise falls back/, "README should document the checked preferred and fallback update modes");
549
589
  assert.match(server, /async function closeNetworkAccess\(\)/, "server should expose a local-only rebind helper for closing network access");
550
590
  assert.match(server, /url\.pathname === "\/api\/network\/close" && req\.method === "POST"/, "server should route network close requests");
551
591
  assert.match(server, /server\.closeAllConnections\?\.\(\)/, "network rebind should force-close long-lived clients so close-to-localhost can complete");
@@ -768,6 +808,27 @@ assert.match(app, /const conversationModeByTab = new Map\(\)/, "frontend should
768
808
  assert.match(app, /function defaultConversationModeState[\s\S]*allowedTools: \["read", "grep", "find", "ls"\]/, "frontend Natural Conversation defaults should mirror the read-only tool allowlist");
769
809
  assert.match(app, /function renderConversationModeControls\(\)[\s\S]*document\.body\.classList\.toggle\("conversation-mode-active", active\)[\s\S]*optionsConversationModeButton[\s\S]*conversationModeChip[\s\S]*conversationModeEndButton/, "frontend should render active Natural Conversation controls and page\/composer state");
770
810
  assert.match(app, /async function setNaturalConversationModeEnabled\(enabled\)[\s\S]*api\("\/api\/conversation-mode", \{ method: "POST"/, "frontend Natural Conversation toggle should use the WebUI shell endpoint");
811
+ assert.match(app, /const WORKFLOW_MODE_STATUS_KEY = "workflow-mode"/, "frontend should consume extension-owned Workflow Mode status");
812
+ assert.match(app, /const WORKFLOW_MODE_RPC_WIDGET_KEY = "workflow-mode:rpc"[\s\S]*WORKFLOW_MODE_RPC_PAYLOAD_PREFIX = "WORKFLOW_MODE_RPC_PAYLOAD "[\s\S]*WORKFLOW_MODE_RPC_PAYLOAD_VERSION = 1/, "frontend should recognize the versioned replayable Workflow Mode RPC payload");
813
+ assert.match(app, /function workflowModeStateFromRpcPayload\(lines\)[\s\S]*payload\?\.type !== WORKFLOW_MODE_RPC_PAYLOAD_TYPE[\s\S]*normalizeWorkflowModeState/, "frontend should strictly validate structured Workflow Mode payloads");
814
+ assert.match(app, /const workflowModeByTab = new Map\(\)/, "frontend should track Workflow Mode independently for each Pi tab");
815
+ assert.match(app, /function renderWorkflowModeControls\(\)[\s\S]*workflow-mode-active[\s\S]*workflowModeButton[\s\S]*workflowModeChip/, "frontend should render toggle, active chip, and composer state from extension status");
816
+ assert.match(app, /async function setWorkflowModeEnabled\(enabled\)[\s\S]*`\/\$\{commandName\} mode \$\{enabled \? "on" : "off"\}`/, "Workflow Mode toggle should send canonical extension commands rather than rewrite prompts locally");
817
+ assert.match(app, /if \(statusKey === WORKFLOW_MODE_STATUS_KEY\) handleWorkflowModeStatus/, "Workflow Mode should synchronize from replayable extension setStatus events");
818
+ assert.match(app, /if \(widgetKey === WORKFLOW_MODE_RPC_WIDGET_KEY\)[\s\S]*workflowModeStateFromRpcPayload\(request\.widgetLines\)[\s\S]*updateWorkflowModeForTab/, "Workflow Mode should consume structured replay state without rendering an opaque widget");
819
+ assert.match(app, /const WORKFLOW_INSPECTOR_WIDGET_KEY = "workflow:rpc"[\s\S]*WORKFLOW_INSPECTOR_PAYLOAD_PREFIX = "WORKFLOW_RPC_PAYLOAD "[\s\S]*WORKFLOW_INSPECTOR_PAYLOAD_VERSION = 1/, "frontend should recognize the versioned multi-run Workflow inspector payload");
820
+ assert.match(app, /function parseWorkflowInspectorPayload\(lines\)[\s\S]*payload\?\.type !== WORKFLOW_INSPECTOR_PAYLOAD_TYPE[\s\S]*Array\.isArray\(payload\.runs\)/, "frontend should validate Workflow inspector type, version, and run shape");
821
+ assert.match(app, /function renderWorkflowInspectorWidget\(\)[\s\S]*workflow-inspector-run-list[\s\S]*workflow-inspector-phase-tabs[\s\S]*renderWorkflowInspectorAgent/, "WebUI should render non-blocking active and historical run, phase, and agent drilldown");
822
+ assert.match(app, /function renderWorkflowInspectorAgent\(agent, run\)[\s\S]*Prompt[\s\S]*Recent activity[\s\S]*Result and usage[\s\S]*Retry agent/, "agent drilldown should expose prompt, activity, result, usage, and retry");
823
+ assert.match(app, /canPause[\s\S]*`\/workflow pause \$\{run\.runId\}`[\s\S]*canAbort[\s\S]*`\/workflow abort \$\{run\.runId\}`[\s\S]*Save user[\s\S]*Save project[\s\S]*Raw workflow script/, "WebUI Workflow controls should send canonical extension commands and expose raw scripts");
824
+ assert.match(app, /confirmMessage && !window\.confirm\(confirmMessage\)/, "destructive WebUI Workflow actions should require browser confirmation");
825
+ assert.match(app, /const workflowInspectorByTab = new Map\(\)[\s\S]*workflowInspectorSelectionByTab = new Map\(\)/, "Workflow inspector state and drilldown selection should be per tab");
826
+ assert.match(app, /handleInactiveTabEvent\(event\)[\s\S]*WORKFLOW_INSPECTOR_WIDGET_KEY[\s\S]*updateWorkflowInspectorForTab\(event\.tabId, inspector\)[\s\S]*renderTabs\(\)/, "inactive tabs should consume replayed Workflow inspector payloads for badges");
827
+ assert.match(app, /terminal-tab-workflow-indicator[\s\S]*workflowRunningCountForTab/, "terminal tabs should display Workflow Mode or active-run badges");
828
+ assert.match(css, /\.workflow-inspector-layout \{[\s\S]*grid-template-columns:[\s\S]*\.workflow-inspector-run-list[\s\S]*\.workflow-inspector-agent/, "Workflow inspector should have responsive run and agent layout styling");
829
+ assert.match(css, /\.terminal-tab-workflow-indicator \{[\s\S]*color: var\(--ctp-mauve\)/, "inactive-tab Workflow badges should have a distinct accessible style");
830
+ assert.match(css, /\.composer-workflow-mode-button\.active,[\s\S]*aria-pressed="true"/, "active Workflow Mode toggle should have persistent pressed styling");
831
+ assert.match(css, /\.composer\.workflow-mode-active[\s\S]*body\.workflow-mode-active \.composer::before/, "active Workflow Mode should visibly accent the composer");
771
832
  // Phase 3: browser voice loop (Web Speech STT/TTS) wiring.
772
833
  const voiceModule = await readFile(join(root, "public", "voice-conversation.mjs"), "utf8");
773
834
  assert.match(voiceModule, /export function createVoiceConversationController\(options = \{\}\)/, "voice loop should live in a dependency-injected module for Node tests");
@@ -851,6 +912,8 @@ assert.match(app, /async function runGitPrPrompt\(tabId = gitWorkflowActionTabId
851
912
  assert.match(app, /async function runGitMessagePrompt\([\s\S]*\/api\/git-workflow\/generate"[\s\S]*kind: "commit"/, "guided git workflow should generate commit messages with the configured model and effort");
852
913
  assert.match(app, /async function runGitBranchNamePrompt\([\s\S]*\/api\/git-workflow\/generate"[\s\S]*kind: "branch"/, "guided git workflow should generate branch names with the configured model and effort");
853
914
  assert.match(app, /async function acceptCurrentGitStaging\([\s\S]*summary\?\.staged[\s\S]*No staged files are available/, "review staging should require a non-empty current staged set");
915
+ assert.match(app, /function gitWorkflowRequest\([\s\S]*response\.hint \? `\\n\\nHint:/, "guided git failures should show actionable backend hints");
916
+ assert.match(server, /async function gitAddAllPayload\([\s\S]*platform\(\) === "win32"[\s\S]*findWindowsReservedGitPath\([\s\S]*windowsReservedGitPathFailure\(/, "guided git add should preflight Windows-reserved untracked paths before staging");
854
917
  assert.match(app, /Pre-commit verification reminder[\s\S]*Continue with this commit/, "configured verification reminders should run before committing");
855
918
  assert.match(server, /async function startGitWorkflowGeneration\([\s\S]*set_model[\s\S]*setThinkingLevelForTab[\s\S]*type: "prompt"/, "server should apply the configured generation profile before prompting Pi");
856
919
  assert.match(server, /event\?\.type === "agent_settled"[\s\S]*restoreGitWorkflowGenerationProfile\(tab\)/, "server should restore the active tab model and effort after generation settles");
@@ -863,7 +926,7 @@ assert.match(app, /function renderReleaseNpmOutputWidget\(\)/, "release-npm live
863
926
  assert.match(app, /async function refreshAppRunners\(tabContext = activeTabContext\(\)\)/, "frontend should load detected app runners for the active tab cwd");
864
927
  assert.match(app, /function renderAppRunnerWidget\(\)/, "frontend should render app runner output in the shared top widget area");
865
928
  assert.match(app, /function tabAppRunnerRunningRun\(tab\)[\s\S]*appRunnerIsRunning\(run\)/, "frontend should derive running app-runner state for terminal tab indicators");
866
- assert.match(app, /function appendTerminalTabContent\(button, \{ title, indicator, meta, count = null, appRunnerRun = null, conversationModeActive = false \}\)[\s\S]*terminal-tab-app-runner-indicator/, "terminal tab content should render a visible app-runner badge");
929
+ assert.match(app, /function appendTerminalTabContent\(button, \{ title, indicator, meta, count = null, appRunnerRun = null, conversationModeActive = false,[^}]*\}\)[\s\S]*terminal-tab-app-runner-indicator/, "terminal tab content should render a visible app-runner badge");
867
930
  assert.match(app, /function appendTerminalTabContent\(button,[\s\S]*terminal-tab-conversation-indicator/, "terminal tab content should render a visible Natural Conversation badge");
868
931
  assert.match(app, /function renderTerminalTab\(tab\)[\s\S]*conversation-mode-running/, "terminal tabs should indicate active Natural Conversation mode per tab");
869
932
  assert.match(css, /\.composer-conversation-mode-chip[\s\S]*\.composer-conversation-end-button/, "Natural Conversation composer controls should have dedicated styles");
@@ -1077,6 +1140,11 @@ assert.match(app, /setBusyPromptBehavior\(controls\.busyBehavior\.select\.value\
1077
1140
  assert.match(app, /sendPromptFromModeButton\("steer", elements\.steerButton\)/, "Steer should show tooltip instead of silently doing nothing when input is empty");
1078
1141
  assert.match(app, /sendPromptFromModeButton\("follow-up", elements\.followUpButton\)/, "Follow-up should show tooltip instead of silently doing nothing when input is empty");
1079
1142
  assert.match(app, /async function sendBtwQuestion\(question,[\s\S]*?`\/btw \$\{cleanQuestion\}`[\s\S]*?await sendPrompt\("prompt", message, \{ targetTabId, throwOnError: true \}\)/, "/btw helper should send text as an ephemeral slash command");
1143
+ assert.match(app, /const btwWidgetDismissedIdsByTab = new Map\(\)/, "/btw dismissals should be scoped to terminal tabs");
1144
+ assert.match(app, /function currentBtwWidgetPayload\(\)[\s\S]*?payload\.id === btwWidgetDismissedIdsByTab\.get\(activeTabId\)/, "/btw rendering should honor the active tab's dismissed payload ID");
1145
+ assert.match(app, /function closeBtwOutputWidget\(\)[\s\S]*?btwWidgetDismissedIdsByTab\.set\(activeTabId, payload\.id\)/, "closing /btw should remember the dismissed payload ID for its tab");
1146
+ const resetActiveTabUiSource = app.slice(app.indexOf("function resetActiveTabUi()"), app.indexOf("function tabGroupStatusRank"));
1147
+ assert.doesNotMatch(resetActiveTabUiSource, /btwWidgetDismissedIdsByTab/, "switching tabs should not clear remembered /btw dismissals");
1080
1148
  assert.match(app, /async function sendBtwPromptFromButton\(\)[\s\S]*?if \(!question\) \{\n\s+openBtwComposerWidget\(\);/, "empty /btw button should open the side-question widget input");
1081
1149
  assert.match(app, /function renderBtwComposerForm\(\)[\s\S]*?form\.requestSubmit\(\)[\s\S]*?sendBtwQuestion\(question\)/, "/btw widget input should submit each message as a /btw trigger");
1082
1150
  assert.match(app, /function makeBtwTransferIcon\(\)[\s\S]*?class", "btw-transfer-icon"[\s\S]*?function transferBtwContextToMain\(button, \{ transferMode = "full" \} = \{\}\)[\s\S]*?`\/btw-transfer \$\{encoded\}`[\s\S]*?streamingBehavior: "steer"[\s\S]*?Summarize & Steer/, "/btw widget should expose full-context and summary transfer actions that send steering context during active runs");
@@ -1087,6 +1155,13 @@ assert.match(app, /async function runNativeCommandMenu\(command\)[\s\S]*?sendPro
1087
1155
  assert.match(app, /function setOptionsMenuOpen\(open\)/, "Options menu should have explicit open state");
1088
1156
  assert.match(app, /function nativeToolOriginTag\(resource\)[\s\S]*?sourceInfo\?\.source === "builtin"[\s\S]*?label: "Pi Native"[\s\S]*?label: "External"/, "Tools Setup should classify built-in Pi tools separately from external tools");
1089
1157
  assert.match(app, /renderNativeResourceToggles\(tools, \{[\s\S]*?getResourceTag: nativeToolOriginTag/, "Tools Setup should render Pi Native\/External tags");
1158
+ assert.match(app, /function nativeResourceScopeControl\(scope,[\s\S]*Session only[\s\S]*Global default/, "Tools and Skills Setup should expose a visible session/global scope control");
1159
+ assert.match(app, /\/api\/tools\?scope=\$\{encodeURIComponent\(scope\)\}[\s\S]*enabledTools: \[\.\.\.enabledTools\], scope/, "Tools Setup should load and save the selected scope");
1160
+ assert.match(app, /\/api\/skills\?scope=\$\{encodeURIComponent\(scope\)\}[\s\S]*enabledSkills: \[\.\.\.enabledSkills\], scope/, "Skills Setup should load and save the selected scope");
1161
+ assert.match(server, /writeWebuiSettings\(\{ resourceDefaults: \{ tools: \{ enabledTools \} \} \}\)[\s\S]*writeWebuiSettings\(\{ resourceDefaults: \{ skills: \{ enabledSkills \} \} \}\)/, "server should persist global tool and skill defaults in the shared Web UI settings file");
1162
+ assert.match(helper, /const saved = lastBranchConfig\(ctx, TOOLS_CONFIG_TYPE\)\?\.enabledTools;[\s\S]*const selected = Array\.isArray\(saved\) \? saved : inherited/, "session tool entries should take precedence over global defaults");
1163
+ assert.match(helper, /const saved = lastBranchConfig\(ctx, SKILLS_CONFIG_TYPE\)\?\.disabledSkills;[\s\S]*if \(Array\.isArray\(saved\)\)/, "session skill entries should take precedence over global defaults");
1164
+ assert.match(readme, /Session only[\s\S]*Global default/, "README should document resource selector scopes");
1090
1165
  assert.match(app, /const tags = Array\.isArray\(item\.tags\)[\s\S]*?item\.badge, \.\.\.tags/, "native selector filtering should include extra resource tags");
1091
1166
  assert.match(app, /publishMenuContainer\?\.addEventListener\("pointerenter", \(\) => \{[\s\S]*?setPublishMenuOpen\(true\);[\s\S]*?\}\)/, "Publish menu should expand on hover");
1092
1167
  assert.match(app, /publishMenuContainer\?\.addEventListener\("pointerleave", \(\) => setPublishMenuOpen\(false\)\)/, "Publish menu should collapse after hover leaves");
@@ -1102,14 +1177,17 @@ for (const command of ["resume", "reload", "remote", "name", "clone", "settings"
1102
1177
  const id = command.replace(/^./, (letter) => letter.toUpperCase());
1103
1178
  assert.match(app, new RegExp(`options${id}Button\\.addEventListener\\("click", \\(\\) => runNativeCommandMenu\\("\\/${command}"\\)\\)`), `Options menu should launch /${command}`);
1104
1179
  }
1180
+ assert.match(app, /optionsSafetyGuardSetupButton\?\.addEventListener\("click", \(\) => runNativeCommandMenu\("\/safety-guard-setup"\)\)/, "Options menu should launch native Safety Guard Setup");
1105
1181
  assert.match(app, /optionsGitWorkflowSetupButton\?\.addEventListener\("click", \(\) => runNativeCommandMenu\("\/git-workflow-setup"\)\)/, "Options menu should launch native Guided Git Setup");
1106
1182
  assert.match(extension, /registerCommand\("git-workflow-setup"[\s\S]*runGitWorkflowSetup/, "Pi extension should register the reusable /git-workflow-setup command");
1183
+ assert.match(app, /async function openNativeSafetyGuardSetupDialog\([\s\S]*\/api\/safety-guard\/config/, "Web UI should implement Safety Guard Setup with the canonical persisted config API");
1184
+ assert.match(server, /url\.pathname === "\/api\/safety-guard\/config" && req\.method === "GET"[\s\S]*url\.pathname === "\/api\/safety-guard\/config" && req\.method === "POST"/, "server should expose native safety guard config read and save endpoints");
1107
1185
  assert.match(app, /async function openNativeGitWorkflowSetupDialog\([\s\S]*\/api\/git-workflow\/preferences/, "Web UI should implement Guided Git Setup with the persisted preferences API");
1108
1186
  assert.match(app, /async function sendPrompt\(kind = "prompt", explicitMessage, \{ targetTabId = activeTabId, throwOnError = false, streamingBehavior \} = \{\}\)/, "prompt sending should accept direct messages that bypass the input field and optional target tab");
1109
1187
  assert.match(app, /const rawMessage = usesPromptInput \? elements\.promptInput\.value : explicitMessage/, "direct prompt sends should not read the input textarea");
1110
1188
  assert.match(app, /if \(usesPromptInput\) \{[\s\S]*?if \(targetStillActive\) \{[\s\S]*?elements\.promptInput\.value = "";/, "direct prompt sends should preserve the input textarea draft");
1111
1189
  assert.match(app, /make\("button", "command-item"\)[\s\S]*?sendPrompt\("prompt", `\/\$\{command\.name\}`\)/, "side-panel command clicks should send the slash command directly");
1112
- assert.match(app, /const NATIVE_SELECTOR_COMMANDS = new Set\(\["model", "settings", "git-workflow-setup", "theme", "fork", "clone", "name", "resume", "tree", "login", "logout", "scoped-models", "tools", "skills"\]\)/, "frontend should route native slash commands, including Guided Git Setup, into selector UIs");
1190
+ assert.match(app, /const NATIVE_SELECTOR_COMMANDS = new Set\(\["model", "settings", "safety-guard-setup", "git-workflow-setup", "theme", "fork", "clone", "name", "resume", "tree", "login", "logout", "scoped-models", "tools", "skills"\]\)/, "frontend should route native slash commands, including safety and Guided Git setup, into selector UIs");
1113
1191
  assert.match(app, /async function handleNativeSlashSelectorCommand\(message/, "frontend should intercept exact native slash commands before prompt forwarding");
1114
1192
  assert.match(app, /kind === "prompt" && attachments\.length === 0 && await handleNativeSlashSelectorCommand/, "prompt sending should open native selector dialogs before marking a run active");
1115
1193
  assert.match(app, /function openNativeModelSelector\(\)[\s\S]*?nativeCommandApi\("\/api\/models"\)/, "native /model selector should load models through the active tab API");
@@ -1141,7 +1219,7 @@ assert.match(app, /const PROMPT_LIST_STORAGE_KEY = "pi-webui-prompt-lists"/, "fr
1141
1219
  assert.match(app, /async function runPromptList\(prompts,[\s\S]*sendPrompt\("prompt", listPrompts\[0\]/, "prompt-list runner should send the first item as the start prompt");
1142
1220
  assert.match(app, /for \(const prompt of listPrompts\.slice\(1\)\)[\s\S]*sendPrompt\("follow-up", prompt/, "prompt-list runner should send remaining items as follow-ups");
1143
1221
  assert.match(app, /async function runDisplayedPromptList\(\)[\s\S]*const saved = saveDisplayedPromptList\(\)[\s\S]*runPromptList\(saved\.prompts/, "Run List should persist the displayed prompt list before running it");
1144
- assert.match(app, /function deleteSelectedPromptList\(\)[\s\S]*window\.confirm[\s\S]*deleteStoredPromptList/, "prompt-list deletion should confirm before deleting saved browser storage");
1222
+ assert.match(app, /async function deleteSelectedPromptList\(\)[\s\S]*deleteStoredPromptList[\s\S]*offerUndo\(\{[\s\S]*upsertStoredPromptList\(deleted\)/, "prompt-list deletion should be immediately reversible through Undo");
1145
1223
  assert.match(app, /function loadSelectedPromptListIntoEditor\(\)[\s\S]*loadPromptListIntoEditor\(list, \{ updateLoaded: true \}\)[\s\S]*elements\.promptListDialog\?\.close\(\)/, "loading a saved prompt list from the popup should close the dialog");
1146
1224
  assert.match(app, /event\.altKey && key === "ArrowUp"[\s\S]*?restoreQueuedMessagesToComposerFromShortcut\(\)/, "Alt+Up should be handled by native shortcut routing");
1147
1225
  assert.match(app, /clearPromptFromShortcut\(\)/, "Ctrl+C should clear only through a guarded prompt helper");
@@ -1178,7 +1256,7 @@ assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(p
1178
1256
  assert.match(app, /let openTerminalTabGroupKey = null/, "frontend should track the open terminal tab group across tab bar rerenders");
1179
1257
  assert.match(app, /function updateTerminalTabGroupOpenState\(\)/, "frontend should be able to reapply open terminal tab group state after rerenders");
1180
1258
  assert.match(app, /classList\.toggle\("terminal-tabs-dense", tabs\.length >= 10\)/, "frontend should enable dense tab layout before tab names become unreadable");
1181
- assert.match(app, /appendTerminalTabContent\(button, \{ title: activeTitle,[\s\S]*?count: groupTabs\.length \}\)/, "group buttons should show the active terminal name instead of only the cwd label");
1259
+ assert.match(app, /appendTerminalTabContent\(button, \{ title: activeTitle,[\s\S]*?count: groupTabs\.length,[^}]*\}\)/, "group buttons should show the active terminal name instead of only the cwd label");
1182
1260
  assert.match(app, /wrapper\.addEventListener\("pointerenter", \(\) => setOpenTerminalTabGroup\(group\.key\)\)/, "terminal tab groups should mark themselves open while hovered");
1183
1261
  assert.match(app, /if \(openTerminalTabGroupKey\) \{\n\s+scheduleRefreshTabs\(600\);/, "tab polling should defer full tab refreshes while a group menu is open");
1184
1262
  assert.match(app, /function shouldRenderTerminalTabGroup\(group, groupCount\) \{\n\s+if \(group\.custom\) return group\.tabs\.length > 1;\n\s+return groupCount > 1 && group\.tabs\.length > 1 && Boolean\(group\.cwd\);\n\}/, "terminal tabs should always render custom groups while only collapsing cwd groups when multiple groups are available");
@@ -1267,14 +1345,15 @@ assert.ok(icon512.length > icon192.length, "PWA 512px icon should be present and
1267
1345
  assert.ok(matrixBackground.length > 100000, "Matrix background image should be present as an optimized WebP asset");
1268
1346
  assert.ok(mochaBackground.length > 8000, "Catppuccin Mocha background image should be present as a compact PNG asset");
1269
1347
 
1270
- assert.match(server, /AuthStorage, SessionManager/, "server should import AuthStorage for safe OAuth token refresh");
1348
+ assert.match(server, /resolveCodexUsageAuth/, "server should use the lock-safe Codex OAuth compatibility adapter");
1271
1349
  assert.match(server, /DefaultPackageManager/, "server should use Pi's package resolver when controlling Web UI tab extension loading");
1272
1350
  assert.match(server, /WEBUI_CONTROLLED_PACKAGES = new Set\(\[[\s\S]*WEBUI_PACKAGE[\s\S]*filter\(\(\[featureId\]\) => featureId !== NATURAL_CONVERSATION_FEATURE_ID\)/, "server should identify Web UI-controlled packages for de-duplicated feature loading while leaving Natural Conversation independently owned");
1273
1351
  assert.match(server, /const args = \["--mode", "rpc", "--no-extensions", "--no-skills", "--no-prompt-templates", "--no-themes"\]/, "Web UI tabs should disable implicit resource loading before adding curated resource paths");
1274
1352
  assert.match(server, /normalPiResourcePathsForTab[\s\S]*WEBUI_CONTROLLED_PACKAGES\.has\(packageName\)[\s\S]*continue/, "Web UI tab resource resolution should exclude separately installed Web UI feature packages");
1275
1353
  assert.match(server, /startedWebuiResourcePaths\(resourceType\)/, "Web UI tabs should load feature resources from the started Web UI package");
1276
1354
  assert.match(server, /resolveInstalledPackageSubpath\(nodeModulesRef\.packageName, nodeModulesRef\.subpath\)/, "Web UI should prefer workspace/global/package-root installed packages for node_modules manifest entries");
1277
- assert.match(server, /const CODEX_TOKEN_REFRESH_SKEW_MS = 5 \* 60 \* 1000/, "server should refresh Codex OAuth tokens before they expire");
1355
+ assert.match(codexAuth, /CODEX_TOKEN_REFRESH_SKEW_MS = 5 \* 60 \* 1000/, "Codex OAuth credentials should refresh five minutes before expiry");
1356
+ assert.match(server, /catch \{[\s\S]*OpenAI Codex OAuth token refresh failed/, "Codex auth failures should be redacted before reaching clients");
1278
1357
  assert.match(server, /url\.pathname === "\/api\/codex-usage" && req\.method === "GET"/, "server should expose a sanitized Codex usage endpoint");
1279
1358
  assert.match(server, /OPENAI_CODEX_USAGE_ENDPOINT/, "server should query Codex usage from the backend, not the browser");
1280
1359
  assert.match(server, /const NATIVE_SLASH_COMMANDS = nativeSlashCommandEntries\(nativeParityMatrix\)/, "server should define Pi native slash commands for autocomplete from the parity matrix");
@@ -1347,9 +1426,11 @@ assert.match(server, /function formatSessionOutput\(tab, state, stats\)/, "nativ
1347
1426
  assert.match(server, /case "session": \{[\s\S]*?formatSessionOutput\(tab, state\.data \|\| \{\}, stats\.success === false \? null : stats\.data\)/, "native /session should render state and stats through Web UI");
1348
1427
  assert.match(server, /case "copy": \{[\s\S]*?get_last_assistant_text[\s\S]*?copyText: text/, "native /copy should return text for browser clipboard handling");
1349
1428
  assert.match(server, /case "export": \{[\s\S]*?handleNativeExportCommand\(tab, parsed\.args, req\)/, "native /export should run through the Web UI export helper");
1429
+ assert.match(server, /nativeExportDownloadPayload\(\{[\s\S]*localRequest: isLocalRequest\(req\)/, "native /export should condition filesystem disclosure on localhost");
1430
+ assert.match(nativeExportPayload, /\.\.\.\(localRequest \? \{ serverPath: exportedPath, result: responseData \} : \{\}\)/, "remote no-path exports should omit server paths and raw RPC path data");
1350
1431
  assert.match(server, /url\.pathname\.startsWith\("\/api\/native-download\/"\) && req\.method === "GET"/, "native /export should expose short-lived opaque download URLs");
1351
1432
  assert.match(app, /function triggerNativeDownload\(download\)/, "frontend should be able to start native command downloads");
1352
- assert.match(app, /function openNativeExportDownloadPrompt\(download\)/, "frontend should prompt before opening /export HTML in the browser");
1433
+ assert.match(app, /function openNativeExportDownloadPrompt\(download, serverPath = ""\)[\s\S]*Copy path[\s\S]*copyText\(savedPath\)/, "frontend should show and copy the saved /export HTML path");
1353
1434
  assert.match(app, /function alternateLoopbackBrowserUrl\(value\)/, "frontend should avoid reopening exports inside the installed PWA when possible");
1354
1435
  assert.match(app, /function safeHttpUrl\(value/, "frontend should validate server-provided URLs through a shared helper");
1355
1436
  assert.match(app, /const url = safeHttpUrl\(download\?\.url\)/, "native downloads must reject non-http(s) URL schemes");
@@ -0,0 +1,26 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { nativeExportDownloadPayload } from "../lib/native-export-payload.mjs";
4
+
5
+ const exportedPath = "/private/server/session-export.html";
6
+ const download = {
7
+ fileName: "session-export.html",
8
+ url: "/api/native-download/opaque-token",
9
+ openUrl: "http://localhost/api/native-download/opaque-token?open=1",
10
+ expiresAt: "2030-01-01T00:00:00.000Z",
11
+ };
12
+
13
+ test("localhost export responses include the absolute server path", () => {
14
+ const payload = nativeExportDownloadPayload({ localRequest: true, exportedPath, download, responseData: { path: exportedPath } });
15
+ assert.equal(payload.serverPath, exportedPath);
16
+ assert.equal(payload.result.path, exportedPath);
17
+ assert.match(payload.message, /Saved to: \/private\/server\/session-export\.html/);
18
+ });
19
+
20
+ test("remote no-path exports disclose only the opaque download response", () => {
21
+ const payload = nativeExportDownloadPayload({ localRequest: false, exportedPath, download, responseData: { path: exportedPath } });
22
+ assert.equal("serverPath" in payload, false);
23
+ assert.equal("result" in payload, false);
24
+ assert.doesNotMatch(payload.message, /private|serverPath|Saved to/);
25
+ assert.equal(payload.download.url, "/api/native-download/opaque-token");
26
+ });
@@ -129,7 +129,7 @@ for (const target of ["state", "tabs", "commands", "themes", "workspace"]) {
129
129
  }
130
130
 
131
131
  const slashCommands = nativeSlashCommandEntries(parity);
132
- assert.equal(slashCommands.length, 25);
132
+ assert.equal(slashCommands.length, 26);
133
133
  assert.equal(slashCommands[0].name, "settings");
134
134
  assert.equal(slashCommands.at(-1).name, "quit");
135
135
 
@@ -53,6 +53,7 @@ const slashSurfaces = parity.surfaces.filter((surface) => surface.kind === "slas
53
53
  const slashCommandNames = slashSurfaces.map((surface) => surface.command?.name).filter(Boolean);
54
54
  const requiredNativeCommands = [
55
55
  "settings",
56
+ "safety-guard-setup",
56
57
  "git-workflow-setup",
57
58
  "model",
58
59
  "theme",
@@ -139,6 +140,13 @@ assert.match(server, /url\.pathname === "\/api\/tools" && req\.method === "GET"/
139
140
  assert.match(server, /url\.pathname === "\/api\/tools" && req\.method === "POST"/, "server should expose POST /api/tools for native /tools updates");
140
141
  assert.match(server, /url\.pathname === "\/api\/skills" && req\.method === "GET"/, "server should expose GET /api/skills for native /skills");
141
142
  assert.match(server, /url\.pathname === "\/api\/skills" && req\.method === "POST"/, "server should expose POST /api/skills for native /skills updates");
143
+ assert.match(server, /function requireResourceScope\(value\)[\s\S]*scope !== "session" && scope !== "global"/, "resource APIs should accept only session and global scopes");
144
+ assert.match(server, /writeWebuiSettings\(\{ resourceDefaults: \{ tools: \{ enabledTools \} \} \}\)/, "global tool choices should persist in Web UI settings");
145
+ assert.match(server, /writeWebuiSettings\(\{ resourceDefaults: \{ skills: \{ enabledSkills \} \} \}\)/, "global skill choices should persist in Web UI settings");
146
+ assert.match(app, /function nativeResourceScopeControl\(scope,[\s\S]*Session only[\s\S]*Global default/, "Tools and Skills Setup should expose session/global scope choices");
147
+ assert.match(app, /body: \{ enabledTools: \[\.\.\.enabledTools\], scope \}/, "Tools Setup should submit its selected persistence scope");
148
+ assert.match(app, /body: \{ enabledSkills: \[\.\.\.enabledSkills\], scope \}/, "Skills Setup should submit its selected persistence scope");
149
+ assert.match(app, /Future sessions inherit it; this session is unchanged\./, "global selector feedback should explain precedence");
142
150
  assert.match(app, /const HIDDEN_COMMAND_NAMES = new Set\(\["webui-tree-navigate", "webui-helper"\]\)/, "frontend should hide Web UI internal helper commands");
143
151
  assert.match(app, /"scoped-models", "tools", "skills"/, "frontend native selector commands should include /tools and /skills");
144
152
  assert.match(app, /return match \? match\[1\]\.toLowerCase\(\) : ""/, "frontend native slash command matching should be case-insensitive");
@@ -149,13 +157,14 @@ assert.match(server, /url\.pathname\.startsWith\("\/api\/native-download\/"\) &&
149
157
  assert.match(server, /case "export": \{\n\s+return handleNativeExportCommand\(tab, parsed\.args, req\);\n\s+\}/, "native /export should route through the native command adapter");
150
158
  assert.match(server, /tab\.rpc\.send\(\{ type: "export_html", outputPath \}\)/, "no-path /export should use RPC export_html into a controlled temp path");
151
159
  assert.match(server, /registerNativeDownload\(exportedPath/, "no-path /export should return a short-lived browser download token");
160
+ assert.match(server, /nativeExportDownloadPayload\(\{[\s\S]*localRequest: isLocalRequest\(req\)/, "no-path /export should disclose the saved HTML path only to localhost requests");
152
161
  assert.match(server, /openUrl: record\.contentType === MIME_TYPES\.get\("\.html"\)/, "HTML native downloads should expose a browser-open URL");
153
162
  assert.match(server, /url\.searchParams\.get\("disposition"\) === "inline"/, "native download endpoint should support inline HTML rendering");
154
163
  assert.match(server, /copyFile\(sessionFile, targetPath\)/, "explicit .jsonl /export should copy the active session file");
155
164
  assert.match(app, /function triggerNativeDownload\(download\)/, "frontend should know how to trigger native command downloads");
156
165
  assert.match(app, /function applyNativeSlashCommandEffects\(response, message, tabContext/, "frontend should apply centralized native slash-command adapter effects");
157
- assert.match(app, /data\.download && handleNativeDownloadResponse\(data\.download, data\.command\)/, "frontend should route native downloads through command-specific handling");
158
- assert.match(app, /function openNativeExportDownloadPrompt\(download\)[\s\S]*Open in browser/, "frontend should ask Web UI users to open /export results in the browser");
166
+ assert.match(app, /data\.download && handleNativeDownloadResponse\(data\.download, data\.command, data\.serverPath\)/, "frontend should route native downloads and their saved path through command-specific handling");
167
+ assert.match(app, /function openNativeExportDownloadPrompt\(download, serverPath = ""\)[\s\S]*Saved to:\\n[\s\S]*Copy path[\s\S]*copyText\(savedPath\)[\s\S]*Open in browser/, "frontend should show and copy the saved /export HTML path before offering browser open");
159
168
  assert.match(app, /function alternateLoopbackBrowserUrl\(value\)[\s\S]*hostname === "localhost"[\s\S]*127\.0\.0\.1/, "PWA export opens should escape same-origin app scope via alternate loopback host");
160
169
  assert.match(app, /for \(const warning of response\.warnings/, "frontend should surface remote bash trust warnings");
161
170
  assert.match(server, /case "\/api\/bash": \{[\s\S]*?return \{ type: "bash", command, excludeFromContext: body\.excludeFromContext === true \}/, "server should expose RPC bash with include/exclude context semantics");
@@ -0,0 +1,64 @@
1
+ import assert from "node:assert/strict";
2
+ import path from "node:path";
3
+ import { resolveNpmCommandInvocation } from "../lib/npm-command.mjs";
4
+
5
+ const windowsExecPath = "C:\\PortableNode\\node.exe";
6
+ const bundledCli = "C:\\PortableNode\\node_modules\\npm\\bin\\npm-cli.js";
7
+ const requestedArgs = ["install", "--prefix", "C:\\Pi Packages", "@firstpick/example@latest"];
8
+
9
+ const bundled = resolveNpmCommandInvocation(requestedArgs, {
10
+ platform: "win32",
11
+ execPath: windowsExecPath,
12
+ env: { PATH: "C:\\Windows\\System32;C:\\PortableNode" },
13
+ existsSync: (candidate) => path.win32.normalize(candidate) === path.win32.normalize(bundledCli),
14
+ });
15
+ assert.equal(bundled.command, windowsExecPath, "Windows npm should run through the current Node executable");
16
+ assert.deepEqual(bundled.args, [bundledCli, ...requestedArgs], "Windows npm should prefix arguments with bundled npm-cli.js");
17
+ assert.equal(bundled.displayCommand, "npm", "automatic resolution should keep readable npm command output");
18
+ assert.equal(bundled.source, "node-cli");
19
+
20
+ const pathCli = "D:\\NodeOnPath\\node_modules\\npm\\bin\\npm-cli.js";
21
+ const fromPath = resolveNpmCommandInvocation(["root", "-g"], {
22
+ platform: "win32",
23
+ execPath: windowsExecPath,
24
+ env: { PATH: "C:\\Windows\\System32;D:\\NodeOnPath" },
25
+ existsSync: (candidate) => path.win32.normalize(candidate) === path.win32.normalize(pathCli),
26
+ });
27
+ assert.deepEqual(fromPath.args, [pathCli, "root", "-g"], "Windows resolution should find npm-cli.js beside an npm directory on PATH");
28
+
29
+ const configuredShim = "E:\\CustomNode\\npm.cmd";
30
+ const configuredCli = "E:\\CustomNode\\node_modules\\npm\\bin\\npm-cli.js";
31
+ const configured = resolveNpmCommandInvocation(["--version"], {
32
+ platform: "win32",
33
+ execPath: windowsExecPath,
34
+ env: { PI_WEBUI_NPM_BIN: configuredShim, PATH: "" },
35
+ existsSync: (candidate) => path.win32.normalize(candidate) === path.win32.normalize(configuredCli),
36
+ });
37
+ assert.equal(configured.command, windowsExecPath, "a configured npm.cmd shim should be normalized to its npm CLI");
38
+ assert.deepEqual(configured.args, [configuredCli, "--version"]);
39
+ assert.equal(configured.displayCommand, configuredShim);
40
+
41
+ const customExecutable = resolveNpmCommandInvocation(["install"], {
42
+ platform: "win32",
43
+ execPath: windowsExecPath,
44
+ env: { PI_WEBUI_NPM_BIN: "E:\\tools\\custom-npm.exe" },
45
+ existsSync: () => false,
46
+ });
47
+ assert.deepEqual(customExecutable, {
48
+ command: "E:\\tools\\custom-npm.exe",
49
+ args: ["install"],
50
+ displayCommand: "E:\\tools\\custom-npm.exe",
51
+ displayArgs: ["install"],
52
+ source: "configured-command",
53
+ }, "custom executable overrides should remain supported");
54
+
55
+ const fallback = resolveNpmCommandInvocation(["--version"], {
56
+ platform: "linux",
57
+ execPath: "/usr/bin/node",
58
+ env: { PATH: "/usr/bin" },
59
+ existsSync: () => false,
60
+ });
61
+ assert.equal(fallback.command, "npm", "non-bundled installations should retain PATH fallback behavior");
62
+ assert.deepEqual(fallback.args, ["--version"]);
63
+
64
+ console.log("npm command resolution tests passed");
@@ -13,6 +13,7 @@ const fakePi = join(root, "tests", "fixtures", "fake-pi.mjs");
13
13
  const port = 30000 + Math.floor(Math.random() * 20000);
14
14
  const cwd = await mkdtemp(path.join(tmpdir(), "pi-webui-remote-auth-settings-"));
15
15
  const settingsFile = path.join(cwd, "webui-settings.json");
16
+ const safetyGuardSettingsFile = path.join(cwd, "safety-guard.json");
16
17
 
17
18
  async function request(pathname, { method = "GET", body, timeoutMs = 5_000 } = {}) {
18
19
  const response = await fetch(`http://127.0.0.1:${port}${pathname}`, {
@@ -33,6 +34,7 @@ const child = spawn(process.execPath, [serverScript, "--cwd", cwd, "--host", "12
33
34
  env: {
34
35
  ...process.env,
35
36
  PI_WEBUI_SETTINGS_FILE: settingsFile,
37
+ PI_SAFETY_GUARD_CONFIG_FILE: safetyGuardSettingsFile,
36
38
  },
37
39
  });
38
40
  let serverOutput = "";
@@ -62,6 +64,36 @@ try {
62
64
  assert.equal(startupAuth.body?.data?.auth?.enabled, true, "saved Remote PIN auth setting should enable auth at next startup");
63
65
  assert.match(startupAuth.body?.data?.auth?.pin, /^\d{4}$/, "startup auth should generate a fresh PIN, not persist one");
64
66
 
67
+ const initialSafetyGuardSetup = await request("/api/safety-guard/config");
68
+ assert.equal(initialSafetyGuardSetup.status, 200);
69
+ assert.equal(initialSafetyGuardSetup.body?.data?.config?.enabled, true, "safety guard should default to enabled");
70
+ assert.deepEqual(initialSafetyGuardSetup.body?.data?.config?.contextLines, { before: 3, after: 3 });
71
+ assert.ok(initialSafetyGuardSetup.body?.data?.categories?.includes("database"));
72
+
73
+ const invalidSafetyGuardSetup = await request("/api/safety-guard/config", {
74
+ method: "POST",
75
+ body: { config: { contextLines: { before: 21 } } },
76
+ });
77
+ assert.equal(invalidSafetyGuardSetup.status, 400, "setup should reject context limits outside the canonical range");
78
+
79
+ const savedSafetyGuardSetup = await request("/api/safety-guard/config", {
80
+ method: "POST",
81
+ body: {
82
+ config: {
83
+ enabled: false,
84
+ categories: { docker: false },
85
+ protectedPaths: { edit: false },
86
+ contextLines: { before: 2, after: 4 },
87
+ },
88
+ },
89
+ });
90
+ assert.equal(savedSafetyGuardSetup.status, 200);
91
+ assert.equal(savedSafetyGuardSetup.body?.data?.config?.enabled, false);
92
+ assert.equal(savedSafetyGuardSetup.body?.data?.config?.categories?.docker, false);
93
+ assert.deepEqual(savedSafetyGuardSetup.body?.data?.config?.contextLines, { before: 2, after: 4 });
94
+ const persistedSafetyGuardSetup = JSON.parse(await readFile(safetyGuardSettingsFile, "utf8"));
95
+ assert.equal(persistedSafetyGuardSetup.protectedPaths?.edit, false);
96
+
65
97
  const initialGitSetup = await request("/api/git-workflow/preferences");
66
98
  assert.equal(initialGitSetup.status, 200);
67
99
  assert.equal(initialGitSetup.body?.data?.configured, false, "guided Git should require first-time model setup");
@@ -104,7 +136,7 @@ try {
104
136
  const disableAuth = await request("/api/remote-auth/settings", { method: "POST", body: { enabled: false } });
105
137
  assert.equal(disableAuth.status, 200);
106
138
  const savedAfterDisable = JSON.parse(await readFile(settingsFile, "utf8"));
107
- assert.equal(savedAfterDisable.version, 2, "Web UI settings should migrate to the guided Git schema version");
139
+ assert.equal(savedAfterDisable.version, 3, "Web UI settings should migrate to the resource-default schema version");
108
140
  assert.equal(savedAfterDisable.remoteAuthEnabled, false, "disabling Remote PIN auth should persist the off preference");
109
141
  assert.equal(savedAfterDisable.gitWorkflow?.generation?.modelId, "fake-model", "Remote PIN updates should preserve guided Git preferences");
110
142