@firstpick/pi-package-webui 0.9.9 → 0.10.1
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.
- package/DEVELOPMENT.md +49 -15
- package/README.md +11 -9
- package/TECHNICAL.md +12 -8
- package/bin/pi-webui.mjs +202 -67
- package/index.ts +23 -33
- package/lib/git-workflow-preferences.mjs +51 -12
- package/lib/tui-model-profile-selector.mjs +183 -0
- package/lib/tui-resource-selector.mjs +173 -0
- package/package.json +1 -1
- package/public/app.js +365 -106
- package/public/index.html +10 -7
- package/public/service-worker.js +1 -1
- package/public/styles.css +114 -22
- package/tests/boot-failure-diagnostics.test.mjs +3 -3
- package/tests/browser/interaction-continuity.spec.mjs +9 -3
- package/tests/browser/intercom-conversation-viewer.spec.mjs +76 -53
- package/tests/browser/user-noticeable-fixes.spec.mjs +51 -0
- package/tests/codex-fast-mode-static.test.mjs +2 -2
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-visibility-static.test.mjs +3 -3
- package/tests/controls-layout-static.test.mjs +3 -3
- package/tests/durable-rpc-supervisor-harness.test.mjs +9 -0
- package/tests/events-tree-context-menu-static.test.mjs +3 -3
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/file-viewer-image-static.test.mjs +3 -3
- package/tests/fixtures/fake-pi.mjs +3 -3
- package/tests/guided-git-activation-static.test.mjs +24 -12
- package/tests/guided-git-fallback-runtime.test.mjs +209 -270
- package/tests/guided-git-fallback-ui-static.test.mjs +2 -2
- package/tests/guided-git-message-reliability-static.test.mjs +2 -1
- package/tests/guided-git-optional-feature.test.mjs +8 -5
- package/tests/guided-git-publication-backend-static.test.mjs +10 -5
- package/tests/http-endpoints-harness.test.mjs +27 -13
- package/tests/intercom-conversation-viewer-static.test.mjs +7 -6
- package/tests/intercom-tag-layout-static.test.mjs +35 -16
- package/tests/intercom-tag-overflow-layout.test.mjs +87 -0
- package/tests/main-output-loading-static.test.mjs +18 -12
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +3 -3
- package/tests/mobile-phone-experience-static.test.mjs +1 -1
- package/tests/mobile-static.test.mjs +19 -11
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/optional-feature-prompt-impact-static.test.mjs +67 -0
- package/tests/persistent-ui-layout-static.test.mjs +3 -3
- package/tests/prompt-input-vertical-scroll-static.test.mjs +3 -3
- package/tests/questionnaire-dialog.test.mjs +3 -3
- package/tests/remote-auth-settings-harness.test.mjs +18 -3
- package/tests/resource-tui-extension.test.mjs +2 -1
- package/tests/session-sampling-ui-static.test.mjs +3 -3
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/streaming-ui-coupling.test.mjs +2 -0
- package/tests/subagent-observability-static.test.mjs +2 -2
- package/tests/syntax-highlighting-static.test.mjs +3 -3
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/tui-model-profile-selector.test.mjs +102 -0
- package/tests/tui-resource-selector.test.mjs +74 -0
- package/tests/webui-settings-locking.test.mjs +32 -1
- package/tests/windows-drive-cwd-picker-static.test.mjs +3 -3
|
@@ -679,7 +679,7 @@ assert.match(css, /body\.mobile-tabs-expanded \.terminal-tabs \{[\s\S]*?position
|
|
|
679
679
|
assert.match(css, /\.terminal-tab-activity-indicator/, "terminal tabs should expose per-tab agent activity indicators");
|
|
680
680
|
assert.match(css, /\.terminal-tab-app-runner-indicator \{[\s\S]*?terminal-tab-app-runner-pulse/, "terminal tabs should expose animated app-runner indicators");
|
|
681
681
|
assert.match(css, /\.terminal-tab\.app-runner-running,\n\.terminal-tab-group-item\.app-runner-running/, "terminal tabs and grouped items should mark running app runners");
|
|
682
|
-
assert.match(css, /\.terminal-tab-group-menu \{[^}]*max-height:\s*
|
|
682
|
+
assert.match(css, /\.terminal-tab-group-menu \{[^}]*max-height:\s*min\(32rem, calc\(var\(--visual-viewport-height, 100dvh\) - 6rem\)\);[^}]*overflow-x:\s*hidden;[^}]*overflow-y:\s*auto;[^}]*overscroll-behavior:\s*contain;[^}]*scrollbar-gutter:\s*stable;/, "large grouped terminal tab menus should stay inside the viewport and scroll without dropping entries");
|
|
683
683
|
assert.match(css, /\.terminal-tab-group-item \{[\s\S]*?flex:\s*0 0 auto[\s\S]*?background:\s*var\(--ctp-crust\)/, "grouped terminal tab items should keep readable height and use opaque backgrounds");
|
|
684
684
|
assert.match(css, /\.terminal-tab-group-add \{[\s\S]*?flex:\s*0 0 auto/, "grouped terminal tab menus should keep the add-tab action at its natural height");
|
|
685
685
|
assert.match(css, /\.terminal-tab-group\.active \{[\s\S]*?background:[\s\S]*?var\(--ctp-crust\)/, "active terminal tab groups should keep opaque backgrounds");
|
|
@@ -1824,7 +1824,7 @@ assert.ok(pkg.scripts.check.includes("node --check public/voice-conversation.mjs
|
|
|
1824
1824
|
assert.match(app, /id: "bangCommandAutocomplete"[\s\S]*packageName: "@firstpick\/pi-extension-bang-command-autocomplete"[\s\S]*capabilityLabel: "\/bang-status or \/bang-refresh"/, "optional features should list bang-command autocomplete by loaded command capability");
|
|
1825
1825
|
assert.match(app, /id: "fishUserBash"[\s\S]*packageName: "@firstpick\/pi-extension-fish-user-bash"[\s\S]*capabilityLabel: "\/user-bash-shell"/, "optional features should list fish user-bash by loaded command capability");
|
|
1826
1826
|
assert.match(app, /OPTIONAL_COMMAND_FEATURES = new Map\(\[[\s\S]*\["bang-refresh", "bangCommandAutocomplete"\][\s\S]*\["bang-status", "bangCommandAutocomplete"\][\s\S]*\["user-bash-shell", "fishUserBash"\]/, "optional command mapping should gate bang and fish companion commands");
|
|
1827
|
-
assert.match(app, /function updateOptionalFeatureAvailability\(\)[\s\S]*hasAvailableCommand\("bang-status"\) \|\| hasAvailableCommand\("bang-refresh"\)[\s\S]*hasAvailableCommand\("user-bash-shell"\)[\s\S]*
|
|
1827
|
+
assert.match(app, /function updateOptionalFeatureAvailability\(\)[\s\S]*hasAvailableCommand\("bang-status"\) \|\| hasAvailableCommand\("bang-refresh"\)[\s\S]*hasAvailableCommand\("user-bash-shell"\)[\s\S]*hasLoadedGuidedGitNativeCommand\("git-staged-msg", activeTabId\)[\s\S]*hasAvailableCommand\("release-npm"\)[\s\S]*hasAvailableCommand\("release-aur"\)[\s\S]*hasAvailableCommand\("safety-guard"\)[\s\S]*hasLoadedRpcCommand\("skills"\)[\s\S]*hasAvailableCommand\("todo-progress-status"\)[\s\S]*hasLoadedRpcCommand\("tools"\)[\s\S]*hasAvailableCommand\("remote"\)[\s\S]*NATURAL_CONVERSATION_COMMAND_NAMES\.some\(\(name\) => hasAvailableCommand\(name\)\)/, "optional feature detection should require Guided Git extension provenance while distinguishing native resource selectors from TUI companions");
|
|
1828
1828
|
assert.match(app, /hasRemoteWebuiCommand = isOptionalFeatureEnabled\("remoteWebui"\) && hasAvailableCommand\("remote"\)[\s\S]*optionsRemoteButton\.hidden = !hasRemoteWebuiCommand[\s\S]*syncRemoteWebuiControlVisibility\(hasRemoteWebuiCommand\)/, "Options menu should track /remote availability and delegate network card visibility");
|
|
1829
1829
|
assert.match(app, /function syncRemoteWebuiControlVisibility[\s\S]*networkControlField\.hidden = !hasRemoteWebuiCommand/, "Remote WebUI network card should render whenever the optional feature and /remote command are enabled");
|
|
1830
1830
|
assert.match(app, /querySelector\("#remoteAccessControlsTitle"\)[\s\S]*heading\.textContent = payload\?\.title \|\| "Remote access"/, "Remote WebUI payload titles should update the group heading without replacing the nested PIN-auth label");
|
|
@@ -1838,7 +1838,7 @@ assert.match(app, /if \(!isOptionalFeatureDetected\("todoProgressWidget"\)\) ret
|
|
|
1838
1838
|
assert.match(app, /const releasePrompt = detectedReleasePrompt && isOptionalFeatureEnabled\(detectedReleasePrompt\.featureId\) \? detectedReleasePrompt : null/, "release confirmation dialogs should use specialized rendering only when their release optional feature is enabled");
|
|
1839
1839
|
assert.match(app, /case "webui_tab_reloaded":[\s\S]*resetOptionalFeatureAvailability\(\)/, "optional feature state should reset when the RPC tab reloads resources");
|
|
1840
1840
|
assert.match(app, /function runPublishWorkflow\(command\)[\s\S]*resolveAvailableCommandName\(commandName, \{ rpcOnly: true \}\)/, "publish workflow launch should guard on loaded slash commands, including duplicate-suffixed RPC command names");
|
|
1841
|
-
assert.match(app, /function
|
|
1841
|
+
assert.match(app, /function guidedGitNativeCommandsAvailable\(tabId\)[\s\S]*\["git-staged-msg", "git-branch-name", "pr"\]\.every[\s\S]*hasLoadedGuidedGitNativeCommand/, "guided Git must require all native extension commands in the originating tab");
|
|
1842
1842
|
assert.match(app, /function launchGuidedGitWorkflow\(tabId = activeTabId\)[\s\S]*resolveAvailableCommandName\("git-guided-workflow", \{ tabId, rpcOnly: true \}\)/, "guided Git visible entry points should prefer the tab-local extension command");
|
|
1843
1843
|
assert.doesNotMatch(html, /gitWorkflowProcessSelect/, "guided git workflow should not expose process selection as a dropdown");
|
|
1844
1844
|
assert.match(app, /const GIT_WORKFLOW_PROCESSES = \[[\s\S]*value: "stage", label: "Stage"[\s\S]*value: "message", label: "Message"[\s\S]*value: "commit", label: "Commit"[\s\S]*value: "push", label: "Push"/, "guided git workflow should define Stage/Message/Commit/Push process buttons");
|
|
@@ -1869,7 +1869,7 @@ assert.match(app, /const donePatch = variant === "input"[\s\S]*message: true, co
|
|
|
1869
1869
|
assert.match(server, /\["short", "long", "input"\][\s\S]*cleanGitCommitMessageInput\(body\.message\)[\s\S]*git commit -m <input message>/, "server should accept typed git workflow commit messages");
|
|
1870
1870
|
assert.match(css, /\.git-workflow-message-input-row \{[\s\S]*flex:\s*1 1 100%/, "manual git workflow commit input should span the Message stage actions row");
|
|
1871
1871
|
assert.match(css, /\.git-workflow-actions button\[data-tooltip\]::after \{[\s\S]*content:\s*attr\(data-tooltip\)[\s\S]*white-space:\s*pre-line/, "guided git workflow action tooltips should render multiline step lists");
|
|
1872
|
-
assert.match(app, /function gitBranchNamePromptMessage\(\)[\s\S]*
|
|
1872
|
+
assert.match(app, /function gitBranchNamePromptMessage\(tabId = gitWorkflowActionTabId\(\)\)[\s\S]*hasLoadedGuidedGitNativeCommand\("git-branch-name", tabId\)[\s\S]*"\/git-branch-name"/, "guided git workflow should invoke native PR branch-name generation only when the extension command is available");
|
|
1873
1873
|
assert.match(app, /async function loadGitWorkflowBranchName\([\s\S]*generationId[\s\S]*gitWorkflowRequest\(`\/api\/git-workflow\/branch-name\$\{query\}`/, "guided git workflow should load exactly correlated generated branch names before branch creation");
|
|
1874
1874
|
assert.match(app, /async function createGitPrBranchWithSuggestion\([\s\S]*appPromptText\(\{ title: "New PR branch worktree"[\s\S]*chooseGitWorktreeBase\(branch\)[\s\S]*assertGuidedGitStagedContentBinding\(tabId, "PR worktree creation"\)[\s\S]*gitWorkflowRequest\("\/api\/git-workflow\/branch", \{ body: \{ branch, baseRef, sessionMode: "fork-current", openTab: true, [\s\S]*expectedStagedContentHash/, "guided git worktrees should ask for a base ref before verifying and carrying staged content");
|
|
1875
1875
|
assert.match(app, /function syncGitWorkflowWorktreeTabs\(result\)[\s\S]*Array\.isArray\(result\?\.tabs\)[\s\S]*applyTabMetadata\(result\.tab\)/, "guided git workflow should merge worktree tab metadata returned by the branch endpoint");
|
|
@@ -1882,12 +1882,15 @@ assert.match(app, /async function acceptCurrentGitStaging\([\s\S]*summary\?\.sta
|
|
|
1882
1882
|
assert.match(app, /function gitWorkflowRequest\([\s\S]*response\.hint \? `\\n\\nHint:/, "guided git failures should show actionable backend hints");
|
|
1883
1883
|
assert.match(app, /function gitWorkflowRequest\([\s\S]*if \(response\.code\) failure\.code = response\.code;[\s\S]*if \(response\.hint\) failure\.hint = response\.hint;[\s\S]*if \(response\.data\) failure\.data = response\.data;[\s\S]*throw failure;/, "guided git request failures should preserve the structured backend code, hint, and process result");
|
|
1884
1884
|
assert.match(app, /async function pushGitWorkflow\([\s\S]*if \(error\?\.code === "NO_REMOTE"\) \{[\s\S]*await publishGitWorkflowRepository\(tabId, error\)/, "guided git push should offer GitHub publication only for structured NO_REMOTE failures");
|
|
1885
|
-
assert.match(app, /async function publishGitWorkflowRepository\(tabId, failure\)[\s\S]*Publish this repository to GitHub with the authenticated GitHub CLI \(gh\) account
|
|
1886
|
-
assert.match(app, /async function publishGitWorkflowRepository\([\s\S]*const confirmed = await appConfirmText\(\[[\s\S]*Repository name: \$\{repoName\}[\s\S]*Visibility: \$\{visibility\}[\s\S]*Branch to push: \$\{branch\}[\s\S]*Resulting remote: origin[\s\S]*if \(!confirmed\) return false;[\s\S]*gitWorkflowRequest\("\/api\/git-workflow\/publish", \{ body: \{
|
|
1885
|
+
assert.match(app, /async function publishGitWorkflowRepository\(tabId, failure\)[\s\S]*const repoName = cleanGitHubRepoNameInput\(failure\?\.data\?\.repoName \|\| defaultGitInitRepoName\(targetTab\)\);[\s\S]*Publish this repository to GitHub as \$\{repoName\} with the authenticated GitHub CLI \(gh\) account\?[\s\S]*if \(!publishRequested\) return false;[\s\S]*visibility = await promptGitPublishVisibility\(repoName\);[\s\S]*if \(!visibility\) return false;/, "guided git publication should derive the repository name and ask only for explicit visibility");
|
|
1886
|
+
assert.match(app, /async function publishGitWorkflowRepository\([\s\S]*const confirmed = await appConfirmText\(\[[\s\S]*Repository name: \$\{repoName\}[\s\S]*Visibility: \$\{visibility\}[\s\S]*Branch to push: \$\{branch\}[\s\S]*Resulting remote: origin[\s\S]*if \(!confirmed\) return false;[\s\S]*gitWorkflowRequest\("\/api\/git-workflow\/publish", \{ body: \{ visibility, confirmed: true \}/, "guided git publication should confirm the derived name and omit a client-controlled name from the publish request");
|
|
1887
1887
|
assert.match(app, /async function publishGitWorkflowRepository\([\s\S]*Published \$\{result\.repoName \|\| repoName\} as \$\{result\.visibility \|\| visibility\}\.[\s\S]*Remote: \$\{result\.remote \|\| "origin"\}[\s\S]*Branch: \$\{result\.branch \|\| branch\}[\s\S]*scheduleRefreshFooter\(\)/, "successful publication should report branch/remote metadata and refresh the footer");
|
|
1888
|
-
assert.
|
|
1889
|
-
assert.match(
|
|
1890
|
-
assert.match(
|
|
1888
|
+
assert.doesNotMatch(app, /function promptGitPublishRepoName\(/, "publication should not ask the user to name a repository");
|
|
1889
|
+
assert.match(server, /case "\/api\/git-workflow\/publish": \{[\s\S]*const root = await getGitRoot\(cwd\);[\s\S]*const repoName = cleanGitHubRepoName\(path\.basename\(root\)\);[\s\S]*\["repo", "create", repoName, `--\$\{visibility\}`, "--source", "\.", "--remote", "origin", "--push"\][\s\S]*\{ cwd: root, timeoutMs:/, "server publication should derive the Git root directory name and let gh use system configuration while adding origin and pushing");
|
|
1890
|
+
assert.match(html, /<select id="textPromptSelect" class="dialog-input" aria-labelledby="textPromptTitle" hidden><\/select>/, "the application prompt should provide a native dropdown control");
|
|
1891
|
+
assert.match(app, /function appPromptSelect\([\s\S]*placeholderOption\.disabled = true;[\s\S]*placeholderOption\.selected = true;[\s\S]*select\.value = "";/, "selection prompts should require an explicit choice with no preselected value");
|
|
1892
|
+
assert.match(app, /async function promptGitPublishVisibility\(repoName\) \{[\s\S]*await appPromptSelect\(\{[\s\S]*\{ value: "public", label: "Public" \}[\s\S]*\{ value: "private", label: "Private" \}[\s\S]*placeholder: "Choose visibility…"/, "repository visibility should use a public/private dropdown with no default");
|
|
1893
|
+
assert.doesNotMatch(app, /async function promptGitPublishVisibility\(repoName\) \{[\s\S]{0,500}window\.prompt/, "repository visibility should not use the browser text prompt");
|
|
1891
1894
|
assert.match(app, /function cleanGitPublishVisibilityInput\(value\)[\s\S]*if \(visibility !== "public" && visibility !== "private"\)[\s\S]*nothing was published/, "publication visibility must be exactly public or private");
|
|
1892
1895
|
assert.doesNotMatch(app, /visibility = "(?:public|private)"/, "publication visibility should never be defaulted in the frontend");
|
|
1893
1896
|
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");
|
|
@@ -2213,6 +2216,7 @@ assert.match(app, /function openNativeSettingsDialog\(\)[\s\S]*?\/api\/steering-
|
|
|
2213
2216
|
assert.match(app, /function openNativeNameDialog\(\)[\s\S]*?sendPrompt\("prompt", `\/name \$\{name\}`\)/, "native /name selector should prompt before running the slash command");
|
|
2214
2217
|
assert.match(app, /function openNativeForkSelector\(\)[\s\S]*?\/api\/fork-messages[\s\S]*?\/api\/fork/, "native /fork selector should pair fork-point loading with the fork action");
|
|
2215
2218
|
assert.match(app, /function openNativeResumeSelector\(scope = "current", \{ query = "" \} = \{\}\)[\s\S]*?\/api\/sessions\?scope=\$\{encodeURIComponent\(selectedScope\)\}/, "native /resume selector should list current-cwd or all sessions");
|
|
2219
|
+
assert.match(app, /nativeCommandApi\("\/api\/switch-session"[\s\S]*?const resumedTab = syncResponseTabs\(result\)[\s\S]*?await switchTab\(resumedTab\.id\)/, "native /resume should select the new terminal returned by the server");
|
|
2216
2220
|
assert.match(app, /\/api\/session-rename/, "native /resume selector should rename session metadata");
|
|
2217
2221
|
assert.match(app, /\/api\/session-delete/, "native /resume selector should delete sessions with confirmation");
|
|
2218
2222
|
assert.match(app, /function openNativeTreeSelector\(\)[\s\S]*?\/api\/session-tree[\s\S]*?\/api\/tree-navigate/, "native /tree selector should list tree entries and navigate through the backend helper");
|
|
@@ -2402,7 +2406,10 @@ assert.match(server, /function trackPendingExtensionUiRequest\(tab, event\)/, "s
|
|
|
2402
2406
|
assert.match(server, /pendingExtensionUiRequests: new Map\(\)/, "new tabs should initialize pending extension UI request storage");
|
|
2403
2407
|
assert.match(server, /extensionStatuses: new Map\(\)/, "new tabs should initialize replayable extension status storage");
|
|
2404
2408
|
assert.match(server, /extensionWidgets: new Map\(\)/, "new tabs should initialize replayable extension widget storage");
|
|
2405
|
-
assert.match(server, /
|
|
2409
|
+
assert.match(server, /const REPLAYABLE_CLEARED_EXTENSION_STATUS_KEYS = new Set\(\["feature-decision-output", "feature-category"\]\)/, "server should retain cleared feature-routing status keys as late-client capability evidence");
|
|
2410
|
+
assert.match(server, /function rememberExtensionStatusEvent\(tab, event\)[\s\S]*event\.statusText\) statuses\.set\(statusKey, String\(event\.statusText\)\)[\s\S]*REPLAYABLE_CLEARED_EXTENSION_STATUS_KEYS\.has\(statusKey\)\) statuses\.set\(statusKey, undefined\)[\s\S]*else statuses\.delete\(statusKey\)[\s\S]*scheduleSupervisorMetadataUpdate\(tab\)/, "server should replay feature-routing clears, persist first detection, and delete unrelated cleared statuses");
|
|
2411
|
+
assert.match(server, /function supervisedTabMetadata\(tab,[\s\S]*featureSystemPromptDetected: featureSystemPromptDetected\(tab\)/, "supervisor metadata should persist feature-routing capability evidence across server restarts");
|
|
2412
|
+
assert.match(server, /function hydrateManagedTabs\(snapshot\)[\s\S]*restoreFeatureSystemPromptDetection\(tab, metadata\?\.featureSystemPromptDetected === true\)/, "supervised tab hydration should restore feature-routing capability evidence before SSE replay");
|
|
2406
2413
|
assert.match(server, /function rememberExtensionWidgetEvent\(tab, event\)[\s\S]*event\.method !== "setWidget"[\s\S]*widgets\.set\(String\(widgetKey\)/, "server should retain extension widget events for reconnects");
|
|
2407
2414
|
assert.match(server, /rememberExtensionStatusEvent\(tab, scopedEvent\)[\s\S]*rememberExtensionWidgetEvent\(tab, scopedEvent\)[\s\S]*trackPendingExtensionUiRequest\(tab, scopedEvent\)/, "RPC events should retain extension statuses and widgets before broadcasting");
|
|
2408
2415
|
assert.match(server, /trackPendingExtensionUiRequest\(tab, scopedEvent\)/, "RPC events should populate pending extension UI storage before broadcasting");
|
|
@@ -2498,7 +2505,8 @@ assert.match(server, /url\.pathname === "\/api\/scoped-models" && req\.method ==
|
|
|
2498
2505
|
assert.match(server, /url\.pathname === "\/api\/fork-messages" && req\.method === "GET"/, "server should expose fork-point data for the native /fork selector");
|
|
2499
2506
|
assert.match(server, /url\.pathname === "\/api\/sessions" && req\.method === "GET"/, "server should expose session lists for the native /resume selector");
|
|
2500
2507
|
assert.match(server, /url\.pathname === "\/api\/session-tree" && req\.method === "GET"/, "server should expose session-tree data for the native /tree selector");
|
|
2501
|
-
assert.match(server, /url\.pathname === "\/api\/switch-session" && req\.method === "POST"/, "server should expose session
|
|
2508
|
+
assert.match(server, /url\.pathname === "\/api\/switch-session" && req\.method === "POST"/, "server should expose session resume for the native /resume selector");
|
|
2509
|
+
assert.match(server, /async function resumeSessionInNewTab\([\s\S]*?createTab\(\{[\s\S]*?sessionFile: manager\.getSessionFile\(\)[\s\S]*?sourceTab: tabMeta\(sourceTab\)/, "session resume should create a separate terminal and preserve source-tab metadata");
|
|
2502
2510
|
assert.match(server, /url\.pathname === "\/api\/tree-navigate" && req\.method === "POST"/, "server should expose tree navigation through the Web UI helper command");
|
|
2503
2511
|
assert.match(server, /function configuredSessionDir\(\)/, "server should honor forwarded --session-dir for session selectors");
|
|
2504
2512
|
assert.match(server, /SessionManager\.listAll\(sessionDir\) : await SessionManager\.list\(tab\.cwd, sessionDir\)/, "server should support current-cwd and all-session resume scopes");
|
|
@@ -68,7 +68,7 @@ assert.match(server, /STATIC_PUBLIC_FILE_EXTENSIONS[\s\S]*"\.mjs"/, "the server
|
|
|
68
68
|
assert.match(serviceWorker, /"\/issue-wizard-state\.mjs"/, "the PWA shell must keep caching the pure wizard module");
|
|
69
69
|
assert.match(serviceWorker, /"\/issue-bot-client\.mjs"/, "the PWA shell must cache the browser client module");
|
|
70
70
|
// Intent preserved: changing the public startup graph advances the PWA cache identity.
|
|
71
|
-
assert.match(serviceWorker, /pi-webui-pwa-
|
|
71
|
+
assert.match(serviceWorker, /pi-webui-pwa-v153/, "the PWA cache name must change with browser wiring updates");
|
|
72
72
|
assert.match(packageJson, /node --check public\/issue-wizard-state\.mjs/, "the package check must keep syntax-checking the pure wizard module");
|
|
73
73
|
assert.match(packageJson, /node --check public\/issue-bot-client\.mjs/, "the package check must syntax-check the browser client module");
|
|
74
74
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
|
|
4
|
+
const [app, css, html, serviceWorker, readme, technical, development] = await Promise.all([
|
|
5
|
+
readFile(new URL("../public/app.js", import.meta.url), "utf8"),
|
|
6
|
+
readFile(new URL("../public/styles.css", import.meta.url), "utf8"),
|
|
7
|
+
readFile(new URL("../public/index.html", import.meta.url), "utf8"),
|
|
8
|
+
readFile(new URL("../public/service-worker.js", import.meta.url), "utf8"),
|
|
9
|
+
readFile(new URL("../README.md", import.meta.url), "utf8"),
|
|
10
|
+
readFile(new URL("../TECHNICAL.md", import.meta.url), "utf8"),
|
|
11
|
+
readFile(new URL("../DEVELOPMENT.md", import.meta.url), "utf8"),
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
const expectedImpact = new Map([
|
|
15
|
+
["bangCommandAutocomplete", "none"],
|
|
16
|
+
["fishUserBash", "none"],
|
|
17
|
+
["btwCommand", "none"],
|
|
18
|
+
["gitWorkflow", "none"],
|
|
19
|
+
["releaseNpm", "none"],
|
|
20
|
+
["releaseAur", "initial"],
|
|
21
|
+
["aurReview", "none"],
|
|
22
|
+
["workflows", "initial"],
|
|
23
|
+
["featureSystemPrompt", "conditional"],
|
|
24
|
+
["safetyGuard", "none"],
|
|
25
|
+
["tuiSkillsCommand", "none"],
|
|
26
|
+
["todoProgressWidget", "initial"],
|
|
27
|
+
["tuiToolsCommand", "none"],
|
|
28
|
+
["remoteWebui", "none"],
|
|
29
|
+
["questionnaire", "initial"],
|
|
30
|
+
["naturalConversation", "conditional"],
|
|
31
|
+
["gitFooterStatus", "none"],
|
|
32
|
+
["statsCommand", "none"],
|
|
33
|
+
["codexFastMode", "none"],
|
|
34
|
+
["themeBundle", "none"],
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
function optionalFeatureBlock(featureId) {
|
|
38
|
+
const match = app.match(new RegExp(`\\{\\n\\s+id: "${featureId}",[\\s\\S]*?\\n\\s+\\},`));
|
|
39
|
+
assert.ok(match, `optional feature ${featureId} should remain declared`);
|
|
40
|
+
return match[0];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
for (const [featureId, impact] of expectedImpact) {
|
|
44
|
+
assert.match(optionalFeatureBlock(featureId), new RegExp(`promptImpact: "${impact}"`), `${featureId} should declare ${impact} prompt impact`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const catalog = app.slice(app.indexOf("const OPTIONAL_FEATURES = ["), app.indexOf("const OPTIONAL_FEATURE_PROMPT_IMPACTS"));
|
|
48
|
+
const declaredImpacts = [...catalog.matchAll(/promptImpact: "(initial|conditional|none)"/g)];
|
|
49
|
+
assert.equal(declaredImpacts.length, expectedImpact.size, "every optional feature should declare exactly one recognized prompt-impact class");
|
|
50
|
+
|
|
51
|
+
assert.match(app, /initial: Object\.freeze\(\{ symbol: "\+", label: "Adds to the initial system prompt" \}\)/, "+ should describe initial system-prompt text");
|
|
52
|
+
assert.match(app, /conditional: Object\.freeze\(\{ symbol: "\+\.\.\.", label: "Can add system-prompt text while the session is running" \}\)/, "+... should describe conditional session-time prompt text");
|
|
53
|
+
assert.match(app, /none: Object\.freeze\(\{ symbol: "-", label: "No additional system-prompt text measured" \}\)/, "- should describe no measured system-prompt text");
|
|
54
|
+
assert.doesNotMatch(app, /renderOptionalFeaturePromptImpactLegend|optional-feature-prompt-impact-legend/, "the panel should not repeat a prompt-impact legend above the feature list");
|
|
55
|
+
assert.match(app, /function renderOptionalFeatureRow\(feature\)[\s\S]*?System prompt impact: \$\{impact\.label\}[\s\S]*?renderOptionalFeaturePromptImpactBadge\(feature\)/, "each feature row should expose the impact in its tooltip and visible heading");
|
|
56
|
+
assert.match(css, /\.optional-feature-prompt-impact \{[\s\S]*?width: 2\.8rem;[\s\S]*?min-width: 2\.8rem;[\s\S]*?\.optional-feature-prompt-impact\.initial[\s\S]*?\.optional-feature-prompt-impact\.conditional[\s\S]*?\.optional-feature-prompt-impact\.none/, "all three row indicator classes should use the same fixed width");
|
|
57
|
+
assert.doesNotMatch(css, /optional-feature-prompt-impact-legend/, "removed legend styles should not remain in the browser bundle");
|
|
58
|
+
assert.match(app, /const statusTags = make\("div", "optional-feature-status-tags"\);[\s\S]*?statusTags\.append\(renderOptionalFeaturePromptImpactBadge\(feature\), make\("span", `optional-feature-pill/, "the impact and feature-status badges should share one dedicated row");
|
|
59
|
+
assert.match(css, /\.optional-feature-title \{[\s\S]*?flex-direction: column;[\s\S]*?\.optional-feature-status-tags \{[\s\S]*?display: inline-flex;[\s\S]*?gap: 0\.34rem;[\s\S]*?\.optional-feature-pill \{[\s\S]*?flex: 0 0 auto;/, "title width should not stretch the feature-status badge or the gap between badges");
|
|
60
|
+
assert.match(readme, /\+.*initial system prompt[\s\S]*?\+\.\.\..*session is running[\s\S]*?-.*no measured system-prompt text/i, "README should explain the symbols in user language");
|
|
61
|
+
assert.match(technical, /prompt-impact indicators[\s\S]*?tool schemas and ordinary user or tool messages are not counted/i, "technical reference should state the measurement boundary");
|
|
62
|
+
assert.match(development, /reports\/pi-default-system-prompt-evaluation\.md[\s\S]*?promptImpact/, "contributor guide should identify the evidence source and catalog field");
|
|
63
|
+
assert.match(html, /styles\.css\?v=152/, "indicator styles should advance the stylesheet revision");
|
|
64
|
+
assert.match(html, /app\.js\?v=182/, "indicator rendering should advance the app revision");
|
|
65
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "browser asset changes should advance the PWA cache identity");
|
|
66
|
+
|
|
67
|
+
console.log("optional-feature-prompt-impact-static.test.mjs passed");
|
|
@@ -271,8 +271,8 @@ assert.match(
|
|
|
271
271
|
|
|
272
272
|
// --- Coherent browser asset revisions --------------------------------------
|
|
273
273
|
|
|
274
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
275
|
-
assert.match(html, /styles\.css\?v=
|
|
276
|
-
assert.match(html, /data-app-src="\/app\.js\?v=
|
|
274
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "changed browser assets should advance the PWA cache identity");
|
|
275
|
+
assert.match(html, /styles\.css\?v=152/, "the page should request the updated layout stylesheet revision");
|
|
276
|
+
assert.match(html, /data-app-src="\/app\.js\?v=182"/, "the boot loader should request the updated app module revision");
|
|
277
277
|
|
|
278
278
|
console.log("persistent-ui-layout-static.test.mjs passed");
|
|
@@ -19,8 +19,8 @@ const resizePromptInput = app.slice(resizeStart, resizeEnd);
|
|
|
19
19
|
assert.match(css, /#promptInput \{[\s\S]*--prompt-input-block-chrome: calc\(1\.8rem \+ 2px\);[\s\S]*max-height: calc\(6lh \+ var\(--prompt-input-block-chrome\)\);[\s\S]*overflow-y: auto;[\s\S]*overscroll-behavior-y: contain;/, "the prompt should show six complete lines before native vertical scrolling begins");
|
|
20
20
|
assert.match(resizePromptInput, /input\.style\.height = "auto";[\s\S]*borderTopWidth[\s\S]*borderBottomWidth[\s\S]*naturalHeight = input\.scrollHeight \+ borderBlock[\s\S]*isCapped \? "auto" : "hidden"/, "auto-resizing should include the textarea borders and enable vertical scrolling only after the six-line cap");
|
|
21
21
|
assert.doesNotMatch(resizePromptInput, /input\.style\.overflowY = "auto";/, "auto-resizing must not force a scrollbar below the six-line cap");
|
|
22
|
-
assert.match(html, /styles\.css\?v=
|
|
23
|
-
assert.match(html, /app\.js\?v=
|
|
24
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
22
|
+
assert.match(html, /styles\.css\?v=152/, "the page should request the six-line prompt stylesheet revision");
|
|
23
|
+
assert.match(html, /app\.js\?v=182/, "the page should request the current app revision");
|
|
24
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "the PWA cache identity should advance with the prompt scroll assets");
|
|
25
25
|
|
|
26
26
|
console.log("prompt-input-vertical-scroll-static.test.mjs passed");
|
|
@@ -504,8 +504,8 @@ assert.match(css, /@media \(max-width: 720px\), \(max-device-width: 720px\), \(p
|
|
|
504
504
|
assert.match(css, /\.questionnaire-options button\s*\{\s*min-height:\s*3\.35rem/, "mobile questionnaire targets must exceed the 44px floor");
|
|
505
505
|
assert.match(css, /@media \(prefers-reduced-motion: reduce\)\s*\{[\s\S]*?\*, \*::before, \*::after[\s\S]*?transition-duration:\s*1ms !important/, "global reduced-motion rules must cover questionnaire transitions");
|
|
506
506
|
|
|
507
|
-
assert.match(html, /styles\.css\?v=
|
|
508
|
-
assert.match(html, /app\.js\?v=
|
|
509
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
507
|
+
assert.match(html, /styles\.css\?v=152/, "questionnaire CSS needs the current stylesheet revision");
|
|
508
|
+
assert.match(html, /app\.js\?v=182/, "questionnaire behavior needs the current app revision");
|
|
509
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "questionnaire public assets need a coherent PWA cache revision");
|
|
510
510
|
|
|
511
511
|
console.log("questionnaire-dialog.test.mjs passed");
|
|
@@ -14,6 +14,7 @@ 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
16
|
const safetyGuardSettingsFile = path.join(cwd, "safety-guard.json");
|
|
17
|
+
const rpcLogFile = path.join(cwd, "rpc-commands.jsonl");
|
|
17
18
|
|
|
18
19
|
async function request(pathname, { method = "GET", body, timeoutMs = 5_000 } = {}) {
|
|
19
20
|
const response = await fetch(`http://127.0.0.1:${port}${pathname}`, {
|
|
@@ -35,6 +36,7 @@ const child = spawn(process.execPath, [serverScript, "--cwd", cwd, "--host", "12
|
|
|
35
36
|
...process.env,
|
|
36
37
|
PI_WEBUI_SETTINGS_FILE: settingsFile,
|
|
37
38
|
PI_SAFETY_GUARD_CONFIG_FILE: safetyGuardSettingsFile,
|
|
39
|
+
FAKE_PI_LOG_FILE: rpcLogFile,
|
|
38
40
|
},
|
|
39
41
|
});
|
|
40
42
|
let serverOutput = "";
|
|
@@ -140,6 +142,20 @@ try {
|
|
|
140
142
|
}, "existing settings should expose fallback as disabled until explicitly selected");
|
|
141
143
|
assert.equal(initialGitSetup.body?.data?.models?.[0]?.id, "fake-model");
|
|
142
144
|
|
|
145
|
+
const modelRpcCount = async () => (await readFile(rpcLogFile, "utf8"))
|
|
146
|
+
.trim()
|
|
147
|
+
.split("\n")
|
|
148
|
+
.filter(Boolean)
|
|
149
|
+
.map((line) => JSON.parse(line))
|
|
150
|
+
.filter((entry) => entry.direction === "command" && entry.type === "get_available_models")
|
|
151
|
+
.length;
|
|
152
|
+
const modelRpcCountBeforeLightweightRead = await modelRpcCount();
|
|
153
|
+
const lightweightGitSetup = await request("/api/git-workflow/preferences?includeModels=false");
|
|
154
|
+
assert.equal(lightweightGitSetup.status, 200);
|
|
155
|
+
assert.equal(lightweightGitSetup.body?.data?.configured, false);
|
|
156
|
+
assert.equal(lightweightGitSetup.body?.data?.models, undefined, "startup-only reads should not return the setup model catalog");
|
|
157
|
+
assert.equal(await modelRpcCount(), modelRpcCountBeforeLightweightRead, "startup-only reads must not issue get_available_models on Pi's control channel");
|
|
158
|
+
|
|
143
159
|
const unsupportedEffort = await request("/api/git-workflow/preferences", {
|
|
144
160
|
method: "POST",
|
|
145
161
|
body: { preferences: { generation: { provider: "fake", modelId: "fake-model", thinkingLevel: "low" } } },
|
|
@@ -195,9 +211,8 @@ try {
|
|
|
195
211
|
assert.equal(savedGitSetup.body?.data?.preferences?.reviewProcessEnabled, false);
|
|
196
212
|
|
|
197
213
|
const generation = await request("/api/git-workflow/generate", { method: "POST", body: { kind: "commit" } });
|
|
198
|
-
assert.equal(generation.status,
|
|
199
|
-
assert.
|
|
200
|
-
assert.deepEqual(generation.body?.data?.generation, { provider: "fake", modelId: "fake-model", thinkingLevel: "off" });
|
|
214
|
+
assert.equal(generation.status, 409);
|
|
215
|
+
assert.match(generation.body?.error || "", /git-staged-msg extension command.*Same-named prompt templates are not used/iu);
|
|
201
216
|
|
|
202
217
|
const disableAuth = await request("/api/remote-auth/settings", { method: "POST", body: { enabled: false } });
|
|
203
218
|
assert.equal(disableAuth.status, 200);
|
|
@@ -15,7 +15,8 @@ assert.match(source, /pi\.on\("model_select"/);
|
|
|
15
15
|
assert.match(source, /await recompute\(ctx, event\.model\)/, "model selection should immediately recompute exact-model resources");
|
|
16
16
|
assert.match(source, /"Session only", "Global default", "Model default"/);
|
|
17
17
|
assert.match(source, /"Use inherited defaults"/);
|
|
18
|
-
assert.match(source, /ctx
|
|
18
|
+
assert.match(source, /selectTuiModelProfile\(ctx, \{/, "exact-model profiles should use the shared searchable model picker");
|
|
19
|
+
assert.match(source, /selectTuiResources\(ctx, \{/, "resource lists should use the shared keyboard-driven selector");
|
|
19
20
|
assert.match(source, /preserveUnavailableResourceNames\(/);
|
|
20
21
|
assert.match(source, /setExactModelProfile\(/);
|
|
21
22
|
assert.match(source, /skill\.disableModelInvocation !== true/);
|
|
@@ -57,10 +57,10 @@ assert.match(css, /\.sampling-parameter-control\.unsupported:hover:not\(\.sampli
|
|
|
57
57
|
assert.match(css, /\.sampling-parameter-control\.unsupported:focus-visible:not\(\.sampling-tooltip-dismissed\) > \.sampling-parameter-unsupported-tooltip/, "keyboard focus should reveal dismissible unsupported reasons");
|
|
58
58
|
assert.match(css, /\.sampling-parameter-unsupported-tooltip\.sampling-tooltip-below/, "bounded placement should support flipping below top-edge rows");
|
|
59
59
|
assert.match(css, /pointer-events: auto;/, "a visible unsupported tooltip should remain pointer-hoverable");
|
|
60
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
60
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "native-control assets should advance the cache identity");
|
|
61
61
|
assert.match(serviceWorker, /"\/sampling-parameter-controls\.mjs"/, "the pure sampling module should be part of the offline app shell");
|
|
62
|
-
assert.match(html, /styles\.css\?v=
|
|
63
|
-
assert.match(html, /app\.js\?v=
|
|
62
|
+
assert.match(html, /styles\.css\?v=152/, "the changed stylesheet should have a new revision");
|
|
63
|
+
assert.match(html, /app\.js\?v=182/, "the changed app module should have a new revision");
|
|
64
64
|
|
|
65
65
|
// --- Browser state behavior -------------------------------------------------
|
|
66
66
|
|
|
@@ -27,8 +27,8 @@ assert.doesNotMatch(layout, /sectionHeightMin|sectionHeightMax|validateSectionHe
|
|
|
27
27
|
assert.match(app, /const UI_LAYOUT_SIDE_PANEL_FIELDS = \["placement", "sectionLayout", "collapsedSectionIds", "hiddenSectionIds", "collapsedPanels", "panelWidths"\];/, "the browser durable layout field list should omit section heights");
|
|
28
28
|
assert.match(app, /function clearRemovedSidePanelSectionHeightState\(\)[\s\S]*localStorage\.removeItem\(REMOVED_SIDE_PANEL_SECTION_HEIGHT_STORAGE_KEY\)[\s\S]*record\.field === "sidePanel" && record\.subfield === "sectionHeights"/, "startup should remove the retired cache and pending mutations");
|
|
29
29
|
assert.match(app, /clearRemovedSidePanelSectionHeightState\(\);\s*restoreDurableUiLayoutPendingJournal\(\);/, "retired height state should be cleared before pending layout restoration");
|
|
30
|
-
assert.match(html, /styles\.css\?v=
|
|
31
|
-
assert.match(html, /app\.js\?v=
|
|
32
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
30
|
+
assert.match(html, /styles\.css\?v=152/, "removing section resize styles should advance the stylesheet revision");
|
|
31
|
+
assert.match(html, /app\.js\?v=182/, "removing section resize behavior should advance the app revision");
|
|
32
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "removing browser assets should advance the PWA cache identity");
|
|
33
33
|
|
|
34
34
|
console.log("side-panel-section-height-removal-static.test.mjs passed");
|
|
@@ -259,6 +259,8 @@ assert.match(findCaseBody(handleEvent, "tool_execution_end"), /claimToolBoundary
|
|
|
259
259
|
assert.match(findFunctionBody(app, "scheduleSemanticReconcile"), /mergeSemanticReconcileRequest\(semanticReconcilePending, dirty, tabContext\)[\s\S]*?semanticReconcileFrame !== null\) return;/, "WS2a: semantic reconciliation must coalesce partitioned requests to one pending flush");
|
|
260
260
|
assert.match(findFunctionBody(app, "mergeSemanticReconcileRequest"), /semanticReconcileContextKey\(tabContext\)[\s\S]*?pendingByContext\.set\(key, request\)/, "WS2a: semantic dirty flags must remain partitioned by tab generation");
|
|
261
261
|
assert.match(flushSemanticReconcile, /if \(dirty\.workflow\) reconcileGitWorkflowContinuation\(tabContext\.tabId\);[\s\S]*?if \(!isCurrentTabContext\(tabContext\)\) continue;/, "WS2a: originating workflow settlement must run before stale active-DOM work no-ops");
|
|
262
|
+
const reconcileGitWorkflowContinuation = findFunctionBody(app, "reconcileGitWorkflowContinuation");
|
|
263
|
+
assert.match(reconcileGitWorkflowContinuation, /workflow\.step === "readmeGenerating"[\s\S]*?prepareGitInitFiles\(\{ afterReadmePrompt: true,[\s\S]*?workflow\.step === "gitignoreGenerating"[\s\S]*?prepareGitInitFiles\(\{ afterGitignorePrompt: true,/, "WS2a: settlement must continue README and .gitignore initialization after Pi finishes");
|
|
262
264
|
for (const [caseLabel, flag] of [["agent_start", "state: true"], ["agent_end", "messages: true"], ["message_end", "messages: true"], ["agent_settled", "messages: true"]]) {
|
|
263
265
|
assert.match(findCaseBody(handleEvent, caseLabel), new RegExp(`scheduleSemanticReconcile\\(\\{[\\s\\S]*?${flag}`), `WS2a: ${caseLabel} must reconcile chrome through the coalesced semantic scheduler`);
|
|
264
266
|
}
|
|
@@ -28,7 +28,7 @@ assert.match(app, /const SUBAGENT_ASYNC_WIDGET_KEY = "subagent-async"[\s\S]*case
|
|
|
28
28
|
assert.match(app, /for \(const \[key, value\] of widgets\)[\s\S]*if \(key === SUBAGENT_ASYNC_WIDGET_KEY\) continue;/, "stale cached async-status widgets should remain hidden defensively");
|
|
29
29
|
assert.match(css, /\.subagent-source-badge[\s\S]*text-overflow: ellipsis[\s\S]*@media \(max-width: 720px\)/, "source badges should remain compact and responsive");
|
|
30
30
|
assert.match(html, /Managed and registered Pi agent runs[\s\S]*External agents/, "help should explain managed, registered, and external groups");
|
|
31
|
-
assert.match(html, /styles\.css\?v=
|
|
32
|
-
assert.match(worker, /pi-webui-pwa-
|
|
31
|
+
assert.match(html, /styles\.css\?v=152[\s\S]*app\.js\?v=182/, "browser assets should use the current subagent-observability revisions");
|
|
32
|
+
assert.match(worker, /pi-webui-pwa-v153/, "PWA cache identity should advance with subagent widget suppression");
|
|
33
33
|
|
|
34
34
|
console.log("subagent-observability-static.test.mjs passed");
|
|
@@ -60,9 +60,9 @@ assert.match(css, /\.markdown-code \.syntax-comment \{[^}]*font-style: italic;/,
|
|
|
60
60
|
|
|
61
61
|
// --- Offline/PWA startup closure and coherent revisions ---
|
|
62
62
|
assert.match(serviceWorker, /"\/syntax-highlight\.mjs",/, "the eagerly imported tokenizer must be part of the offline app shell");
|
|
63
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
64
|
-
assert.match(html, /styles\.css\?v=
|
|
65
|
-
assert.match(html, /data-app-src="\/app\.js\?v=
|
|
63
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "adding a startup module should advance the PWA cache identity");
|
|
64
|
+
assert.match(html, /styles\.css\?v=152/, "new token styles should advance the stylesheet revision");
|
|
65
|
+
assert.match(html, /data-app-src="\/app\.js\?v=182"/, "new renderer wiring should advance the app module revision");
|
|
66
66
|
assert.match(pkg, /node --check public\/syntax-highlight\.mjs/, "the package check should syntax-check the startup-critical tokenizer");
|
|
67
67
|
|
|
68
68
|
const appShell = serviceWorker.slice(serviceWorker.indexOf("const APP_SHELL"), serviceWorker.indexOf("];", serviceWorker.indexOf("const APP_SHELL")));
|
|
@@ -34,7 +34,7 @@ assert.match(html, /role="alert" hidden>[\s\S]*Replace this exact target\?/, "ov
|
|
|
34
34
|
|
|
35
35
|
assert.match(app, /from "\.\/theme-contract\.mjs"/, "frontend should consume the shared browser-safe theme contract");
|
|
36
36
|
assert.match(serviceWorker, /"\/theme-contract\.mjs"/, "the PWA app shell should cache the startup-critical theme contract");
|
|
37
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
37
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v153"/, "adding the theme contract to the startup graph should advance the PWA cache identity");
|
|
38
38
|
assert.match(pkg, /node --check public\/theme-contract\.mjs/, "the package check should syntax-check the startup-critical theme contract");
|
|
39
39
|
assert.match(app, /function themeDraftFromCatalog\(theme, name = theme\?\.name\)[\s\S]*colors: cloneThemeDraft\(theme\?\.colors \|\| \{\}\)/, "catalog metadata should be projected into a schema-only editable draft");
|
|
40
40
|
assert.match(app, /for \(const \{ name, label \} of group\.tokens\)/, "visual controls should render from the exact shared token inventory");
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { KeybindingsManager, setKeybindings, TUI_KEYBINDINGS } from "@earendil-works/pi-tui";
|
|
3
|
+
import { TuiModelProfileSelectorComponent } from "../lib/tui-model-profile-selector.mjs";
|
|
4
|
+
|
|
5
|
+
const theme = {
|
|
6
|
+
fg: (_color, text) => text,
|
|
7
|
+
bold: (text) => text,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function createSelector(config) {
|
|
11
|
+
const selected = [];
|
|
12
|
+
let cancelled = 0;
|
|
13
|
+
const selector = new TuiModelProfileSelectorComponent(
|
|
14
|
+
{
|
|
15
|
+
title: "Tools Model Profile",
|
|
16
|
+
subtitle: "Choose a profile to edit. This does not switch the active model.",
|
|
17
|
+
configuredModelKeys: [],
|
|
18
|
+
...config,
|
|
19
|
+
},
|
|
20
|
+
theme,
|
|
21
|
+
{
|
|
22
|
+
onSelect: (model) => selected.push(model),
|
|
23
|
+
onCancel: () => cancelled++,
|
|
24
|
+
},
|
|
25
|
+
);
|
|
26
|
+
return { selector, selected, cancelled: () => cancelled };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
setKeybindings(new KeybindingsManager(TUI_KEYBINDINGS));
|
|
30
|
+
|
|
31
|
+
{
|
|
32
|
+
const models = Array.from({ length: 15 }, (_, index) => ({
|
|
33
|
+
provider: index % 2 === 0 ? "alpha" : "beta",
|
|
34
|
+
id: `model-${String(index).padStart(2, "0")}`,
|
|
35
|
+
name: `Model ${index}`,
|
|
36
|
+
}));
|
|
37
|
+
const active = models[12];
|
|
38
|
+
const { selector, selected } = createSelector({
|
|
39
|
+
models,
|
|
40
|
+
activeModelKey: `${active.provider}\0${active.id}`,
|
|
41
|
+
configuredModelKeys: [`${active.provider}\0${active.id}`],
|
|
42
|
+
});
|
|
43
|
+
const rendered = selector.render(120).join("\n");
|
|
44
|
+
assert.match(rendered, /model-12 \[alpha\] \[active\] \[profile\]/, "the picker should open around the active model and mark configured profiles");
|
|
45
|
+
assert.match(rendered, /Model Name: Model 12 · Profile: configured/);
|
|
46
|
+
|
|
47
|
+
selector.handleInput("\x1b[B");
|
|
48
|
+
selector.handleInput("\r");
|
|
49
|
+
assert.equal(selected[0], models[13], "selection should return the exact model object rather than decoding its label");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
{
|
|
53
|
+
const models = Array.from({ length: 15 }, (_, index) => ({
|
|
54
|
+
provider: "alpha",
|
|
55
|
+
id: `model-${String(index).padStart(2, "0")}`,
|
|
56
|
+
name: `Model ${index}`,
|
|
57
|
+
}));
|
|
58
|
+
const active = models[12];
|
|
59
|
+
const { selector, selected } = createSelector({ models, activeModelKey: `${active.provider}\0${active.id}` });
|
|
60
|
+
for (const character of "model-00") selector.handleInput(character);
|
|
61
|
+
selector.handleInput("\r");
|
|
62
|
+
assert.equal(selected[0], models[0], "a narrowing search should select its first match instead of retaining a stale list index");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
{
|
|
66
|
+
const models = [
|
|
67
|
+
{ provider: "alpha", id: "shared-a", name: "Shared Model" },
|
|
68
|
+
{ provider: "beta", id: "shared-b", name: "Shared Model" },
|
|
69
|
+
{ provider: "gamma", id: "other", name: "Other" },
|
|
70
|
+
];
|
|
71
|
+
const { selector, selected } = createSelector({ models, activeModelKey: "" });
|
|
72
|
+
for (const character of "beta") selector.handleInput(character);
|
|
73
|
+
assert.equal(selector.getSearchInput().getValue(), "beta");
|
|
74
|
+
assert.doesNotMatch(selector.render(100).join("\n"), /\[alpha\]/);
|
|
75
|
+
selector.handleInput("\r");
|
|
76
|
+
assert.equal(selected[0], models[1], "provider search should disambiguate models with the same display name");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
{
|
|
80
|
+
const { selector, cancelled } = createSelector({
|
|
81
|
+
models: [{ provider: "alpha", id: "one", name: "One" }],
|
|
82
|
+
activeModelKey: "",
|
|
83
|
+
});
|
|
84
|
+
for (const character of "missing") selector.handleInput(character);
|
|
85
|
+
assert.match(selector.render(100).join("\n"), /No matching models/);
|
|
86
|
+
selector.handleInput("\x03");
|
|
87
|
+
assert.equal(selector.getSearchInput().getValue(), "", "Ctrl+C should clear search before cancelling");
|
|
88
|
+
assert.equal(cancelled(), 0);
|
|
89
|
+
selector.handleInput("\x03");
|
|
90
|
+
assert.equal(cancelled(), 1);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
{
|
|
94
|
+
const { selector, cancelled } = createSelector({
|
|
95
|
+
models: [{ provider: "alpha", id: "one", name: "One" }],
|
|
96
|
+
activeModelKey: "",
|
|
97
|
+
});
|
|
98
|
+
selector.handleInput("\x1b");
|
|
99
|
+
assert.equal(cancelled(), 1, "Escape should cancel model profile selection");
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
console.log("tui-model-profile-selector.test.mjs passed");
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { KeybindingsManager, setKeybindings, TUI_KEYBINDINGS } from "@earendil-works/pi-tui";
|
|
3
|
+
import { TuiResourceSelectorComponent } from "../lib/tui-resource-selector.mjs";
|
|
4
|
+
|
|
5
|
+
const theme = {
|
|
6
|
+
fg: (_color, text) => text,
|
|
7
|
+
bold: (text) => text,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function createSelector(enabledResourceNames = ["alpha", "gamma"]) {
|
|
11
|
+
const saved = [];
|
|
12
|
+
let cancelled = 0;
|
|
13
|
+
const selector = new TuiResourceSelectorComponent(
|
|
14
|
+
{
|
|
15
|
+
title: "Tools Configuration",
|
|
16
|
+
subtitle: "Session only. Changes apply only after Ctrl+S.",
|
|
17
|
+
resources: ["alpha", "beta", "gamma"],
|
|
18
|
+
enabledResourceNames,
|
|
19
|
+
},
|
|
20
|
+
theme,
|
|
21
|
+
{
|
|
22
|
+
onSave: (selection) => saved.push(selection),
|
|
23
|
+
onCancel: () => cancelled++,
|
|
24
|
+
},
|
|
25
|
+
);
|
|
26
|
+
return { selector, saved, cancelled: () => cancelled };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
setKeybindings(new KeybindingsManager(TUI_KEYBINDINGS));
|
|
30
|
+
|
|
31
|
+
{
|
|
32
|
+
const { selector, saved } = createSelector();
|
|
33
|
+
selector.handleInput("\x1b[B");
|
|
34
|
+
selector.handleInput("\r");
|
|
35
|
+
assert.match(selector.render(100).join("\n"), /3\/3 enabled.*\(unsaved\)/);
|
|
36
|
+
selector.handleInput("\x13");
|
|
37
|
+
assert.deepEqual(saved, [["alpha", "beta", "gamma"]], "Ctrl+S should save the current explicit selection");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
{
|
|
41
|
+
const { selector, saved } = createSelector();
|
|
42
|
+
selector.handleInput("b");
|
|
43
|
+
selector.handleInput("e");
|
|
44
|
+
assert.equal(selector.getSearchInput().getValue(), "be");
|
|
45
|
+
assert.doesNotMatch(selector.render(100).join("\n"), /alpha/);
|
|
46
|
+
|
|
47
|
+
selector.handleInput("\x18");
|
|
48
|
+
selector.handleInput("\x13");
|
|
49
|
+
assert.deepEqual(saved.at(-1), ["alpha", "gamma"], "Ctrl+X should clear only resources matching the active search");
|
|
50
|
+
|
|
51
|
+
selector.handleInput("\x01");
|
|
52
|
+
selector.handleInput("\x13");
|
|
53
|
+
assert.deepEqual(saved.at(-1), ["alpha", "beta", "gamma"], "Ctrl+A should enable only resources matching the active search");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
{
|
|
57
|
+
const { selector, cancelled } = createSelector();
|
|
58
|
+
selector.handleInput("z");
|
|
59
|
+
selector.handleInput("z");
|
|
60
|
+
assert.match(selector.render(100).join("\n"), /No matching resources/);
|
|
61
|
+
selector.handleInput("\x03");
|
|
62
|
+
assert.equal(selector.getSearchInput().getValue(), "", "Ctrl+C should clear a non-empty search before cancelling");
|
|
63
|
+
assert.equal(cancelled(), 0);
|
|
64
|
+
selector.handleInput("\x03");
|
|
65
|
+
assert.equal(cancelled(), 1, "Ctrl+C on an empty search should cancel");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
{
|
|
69
|
+
const { selector, cancelled } = createSelector();
|
|
70
|
+
selector.handleInput("\x1b");
|
|
71
|
+
assert.equal(cancelled(), 1, "Escape should cancel without saving");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
console.log("tui-resource-selector.test.mjs passed");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { execFile, spawn } from "node:child_process";
|
|
3
3
|
import { once } from "node:events";
|
|
4
|
-
import { mkdtemp, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
4
|
+
import { mkdtemp, readFile, readdir, rm, stat, utimes, writeFile } from "node:fs/promises";
|
|
5
5
|
import { homedir, tmpdir } from "node:os";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { promisify } from "node:util";
|
|
@@ -170,9 +170,40 @@ try {
|
|
|
170
170
|
assert.equal(JSON.parse(await readFile(liveLockRecord, "utf8")).token, "live");
|
|
171
171
|
await rm(liveLockRecord);
|
|
172
172
|
|
|
173
|
+
const liveIncompleteRecord = path.join(liveLockDirectory, `${process.pid}-${Date.now() - 100}-incomplete.json`);
|
|
174
|
+
await writeFile(liveIncompleteRecord, "", "utf8");
|
|
175
|
+
await assert.rejects(
|
|
176
|
+
withWebuiSettingsLock(liveLockTarget, () => true, { timeoutMs: 35, retryMs: 5 }),
|
|
177
|
+
(error) => error?.code === "WEBUI_SETTINGS_LOCK_TIMEOUT",
|
|
178
|
+
"a newly created incomplete record from a live owner must retain a short write grace period",
|
|
179
|
+
);
|
|
180
|
+
await rm(liveIncompleteRecord);
|
|
181
|
+
|
|
173
182
|
const exited = spawn(process.execPath, ["-e", "process.exit(0)"], { stdio: "ignore" });
|
|
174
183
|
const deadPid = exited.pid;
|
|
175
184
|
await once(exited, "exit");
|
|
185
|
+
const deadIncompleteRecord = path.join(liveLockDirectory, `${deadPid}-${Date.now()}-incomplete.json`);
|
|
186
|
+
await writeFile(deadIncompleteRecord, "", "utf8");
|
|
187
|
+
assert.equal(
|
|
188
|
+
await withWebuiSettingsLock(liveLockTarget, () => "recovered incomplete", { timeoutMs: 250, retryMs: 5 }),
|
|
189
|
+
"recovered incomplete",
|
|
190
|
+
"an incomplete record from a dead owner must not block future saves",
|
|
191
|
+
);
|
|
192
|
+
await assert.rejects(readFile(deadIncompleteRecord, "utf8"), { code: "ENOENT" });
|
|
193
|
+
|
|
194
|
+
await mkdir(liveLockDirectory, { recursive: true });
|
|
195
|
+
const malformedLockRecord = path.join(liveLockDirectory, "malformed.json");
|
|
196
|
+
await writeFile(malformedLockRecord, "{", "utf8");
|
|
197
|
+
const staleTime = new Date(Date.now() - 5_000);
|
|
198
|
+
await utimes(malformedLockRecord, staleTime, staleTime);
|
|
199
|
+
assert.equal(
|
|
200
|
+
await withWebuiSettingsLock(liveLockTarget, () => "recovered malformed", { timeoutMs: 250, retryMs: 5 }),
|
|
201
|
+
"recovered malformed",
|
|
202
|
+
"an old malformed record without owner metadata must not block future saves",
|
|
203
|
+
);
|
|
204
|
+
await assert.rejects(readFile(malformedLockRecord, "utf8"), { code: "ENOENT" });
|
|
205
|
+
|
|
206
|
+
await mkdir(liveLockDirectory, { recursive: true });
|
|
176
207
|
const deadLockRecord = path.join(liveLockDirectory, "dead.json");
|
|
177
208
|
await writeFile(deadLockRecord, `${JSON.stringify({ pid: deadPid, token: "dead", state: "active" })}\n`, "utf8");
|
|
178
209
|
assert.equal(await withWebuiSettingsLock(liveLockTarget, () => "recovered", { timeoutMs: 250, retryMs: 5 }), "recovered");
|