@firstpick/pi-package-webui 0.11.1 → 0.11.2
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 +151 -12
- package/README.md +34 -6
- package/TECHNICAL.md +75 -8
- package/bin/pi-webui.mjs +5390 -11423
- package/index.ts +10 -3
- package/lib/component-update-state.mjs +2 -2
- package/lib/git-workflow-preference-values.mjs +122 -0
- package/lib/git-workflow-preferences.mjs +35 -563
- package/lib/package-updates.mjs +260 -0
- package/lib/rpc-supervisor-client.mjs +8 -4
- package/lib/server/app-runners.mjs +1667 -0
- package/lib/server/codex-fast-mode.mjs +161 -0
- package/lib/server/conversation-mode.mjs +218 -0
- package/lib/server/conversation-voice.mjs +318 -0
- package/lib/server/extension-ui-requests.mjs +114 -0
- package/lib/server/git-generation.mjs +459 -0
- package/lib/server/git-mutations.mjs +1827 -0
- package/lib/server/git-reads.mjs +608 -0
- package/lib/server/git-worktree-sessions.mjs +408 -0
- package/lib/server/helper-requests.mjs +82 -0
- package/lib/server/no-project-workspaces.mjs +103 -0
- package/lib/server/rpc-transports.mjs +394 -0
- package/lib/server/settings-store.mjs +544 -0
- package/lib/server/sse-delivery.mjs +138 -0
- package/lib/server/workspace-files.mjs +563 -0
- package/lib/update/supervisor.mjs +4 -0
- package/lib/webui-workspaces.mjs +2 -0
- package/package.json +4 -4
- package/public/activity-agents-controller.mjs +269 -0
- package/public/activity-events-controller.mjs +236 -0
- package/public/activity-intercom-controller.mjs +627 -0
- package/public/activity-queue-controller.mjs +534 -0
- package/public/activity-todo-view.mjs +89 -0
- package/public/activity-usage-controller.mjs +589 -0
- package/public/app.js +3761 -3886
- package/public/conversation-overview.css +84 -0
- package/public/conversation-overview.mjs +193 -0
- package/public/draft-conversations.mjs +135 -0
- package/public/focused-composer-controls.css +111 -0
- package/public/focused-composer-controls.mjs +143 -0
- package/public/focused-composer-disclosure.mjs +223 -0
- package/public/focused-shell-adapter.css +264 -0
- package/public/focused-shell-adapter.mjs +257 -0
- package/public/index.html +137 -80
- package/public/model-catalog-order.mjs +63 -0
- package/public/platform-event-stream.mjs +64 -0
- package/public/project-artifact-controller.mjs +218 -0
- package/public/project-file-viewer-controller.mjs +383 -0
- package/public/project-git-tools-controller.mjs +181 -0
- package/public/project-runners-controller.mjs +220 -0
- package/public/service-worker.js +52 -1
- package/public/session-attention-scheduler.mjs +182 -0
- package/public/session-composer-store.mjs +56 -0
- package/public/session-context.mjs +51 -0
- package/public/session-extension-requests.mjs +63 -0
- package/public/session-shelf-state.mjs +151 -0
- package/public/session-shelves.css +171 -0
- package/public/session-shelves.mjs +95 -0
- package/public/settings-navigation-controller.mjs +249 -0
- package/public/settings-navigation.css +61 -0
- package/public/settings-resource-controller.mjs +232 -0
- package/public/settings-workspace.css +19 -0
- package/public/settings-workspace.mjs +175 -0
- package/public/shell-actions.mjs +87 -0
- package/public/shell-attention-inbox.css +72 -0
- package/public/shell-attention-inbox.mjs +198 -0
- package/public/shell-context-actions.css +61 -0
- package/public/shell-context-actions.mjs +168 -0
- package/public/shell-inspector-resize.mjs +124 -0
- package/public/shell-navigation-resize.mjs +107 -0
- package/public/shell-navigation.mjs +127 -0
- package/public/shell-preferences.mjs +108 -0
- package/public/shell-surfaces.mjs +99 -0
- package/public/shell-tools-launcher.css +97 -0
- package/public/shell-tools-launcher.mjs +222 -0
- package/public/shell-view-host.mjs +115 -0
- package/public/shell-workspace.css +266 -0
- package/public/shell-workspace.mjs +402 -0
- package/public/sidebar-update-menu.css +190 -0
- package/public/sidebar-update-menu.mjs +512 -0
- package/public/styles.css +320 -169
- package/public/subagent-launch-slot-state.mjs +2 -2
- package/public/themed-selects.css +156 -0
- package/public/workspace-choices.mjs +104 -0
- package/tests/activity-agents-controller.test.mjs +652 -0
- package/tests/activity-events-controller.test.mjs +511 -0
- package/tests/app-runner-terminal-static.test.mjs +3 -3
- package/tests/append-system-http.test.mjs +7 -6
- package/tests/append-system-selector-static.test.mjs +6 -6
- package/tests/aur-review-widget-static.test.mjs +11 -3
- package/tests/boot-failure-diagnostics.test.mjs +8 -3
- package/tests/browser/activity-intercom-controller.spec.mjs +457 -0
- package/tests/browser/activity-navigation-integration.spec.mjs +45 -0
- package/tests/browser/activity-owner-integration.spec.mjs +201 -0
- package/tests/browser/activity-queue-controller.spec.mjs +405 -0
- package/tests/browser/activity-section-picker.spec.mjs +294 -0
- package/tests/browser/activity-todo-view.spec.mjs +60 -0
- package/tests/browser/activity-usage-controller.spec.mjs +416 -0
- package/tests/browser/compact-layout-integration.spec.mjs +58 -0
- package/tests/browser/composer-action-grid-reorder.spec.mjs +16 -0
- package/tests/browser/composer-disclosure.spec.mjs +389 -0
- package/tests/browser/composer-toolbar-polish.spec.mjs +343 -0
- package/tests/browser/control-deck-component-updates.spec.mjs +5 -14
- package/tests/browser/control-deck-side-panels.spec.mjs +27 -12
- package/tests/browser/control-visibility.spec.mjs +5 -0
- package/tests/browser/controls-layout.spec.mjs +21 -2
- package/tests/browser/conversation-overview.spec.mjs +251 -0
- package/tests/browser/draft-conversations.spec.mjs +276 -0
- package/tests/browser/empty-startup-fixture.mjs +135 -0
- package/tests/browser/empty-startup.spec.mjs +282 -0
- package/tests/browser/events-tree-context-menu.spec.mjs +1 -0
- package/tests/browser/focused-composer-more.spec.mjs +127 -0
- package/tests/browser/focused-model-shortcuts.spec.mjs +120 -0
- package/tests/browser/focused-navigation-fixture.mjs +32 -0
- package/tests/browser/focused-project-activity.spec.mjs +111 -0
- package/tests/browser/focused-shell-integration.spec.mjs +208 -0
- package/tests/browser/folder-picker-layout-fixture.mjs +13 -0
- package/tests/browser/folder-picker-layout.spec.mjs +302 -0
- package/tests/browser/footer-model-advanced-layout.spec.mjs +27 -14
- package/tests/browser/git-setup-cancel.spec.mjs +251 -0
- package/tests/browser/guided-git-fallback.spec.mjs +40 -21
- package/tests/browser/inspector-header.spec.mjs +221 -0
- package/tests/browser/inspector-overview-integration.spec.mjs +104 -0
- package/tests/browser/inspector-resize.spec.mjs +227 -0
- package/tests/browser/inspector-topic-overflow.spec.mjs +56 -0
- package/tests/browser/interaction-action-discovery.spec.mjs +332 -0
- package/tests/browser/interaction-attention-inbox.spec.mjs +364 -0
- package/tests/browser/interaction-attention-integration.spec.mjs +53 -0
- package/tests/browser/interaction-composer-controls.spec.mjs +267 -0
- package/tests/browser/interaction-composer-integration.spec.mjs +175 -0
- package/tests/browser/interaction-continuity.spec.mjs +50 -26
- package/tests/browser/interaction-model-picker.spec.mjs +86 -0
- package/tests/browser/last-terminal-close.spec.mjs +280 -0
- package/tests/browser/mobile-foundation.spec.mjs +172 -20
- package/tests/browser/model-catalog-groups.spec.mjs +104 -0
- package/tests/browser/more-row-menus.spec.mjs +258 -0
- package/tests/browser/new-tab-hit-target.spec.mjs +228 -0
- package/tests/browser/no-project-conversation.spec.mjs +113 -0
- package/tests/browser/optimistic-prompt.spec.mjs +3 -0
- package/tests/browser/overhaul-w7-accessibility.spec.mjs +227 -0
- package/tests/browser/overhaul-w7-capabilities.spec.mjs +298 -0
- package/tests/browser/overhaul-w7-companions.spec.mjs +290 -0
- package/tests/browser/overhaul-w7-focus-repairs.spec.mjs +210 -0
- package/tests/browser/overhaul-w7-layout-repairs.spec.mjs +183 -0
- package/tests/browser/overhaul-w7-parent-repairs.spec.mjs +97 -0
- package/tests/browser/overhaul-w7-pwa.spec.mjs +247 -0
- package/tests/browser/overhaul-w7-responsive.spec.mjs +450 -0
- package/tests/browser/overhaul-w7-update.spec.mjs +215 -0
- package/tests/browser/overhaul-w7-zoom.spec.mjs +243 -0
- package/tests/browser/overview-agent-ownership.spec.mjs +45 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +3 -0
- package/tests/browser/project-artifact-controller.spec.mjs +324 -0
- package/tests/browser/project-artifact-integration.spec.mjs +103 -0
- package/tests/browser/project-file-buffer-integration.spec.mjs +230 -0
- package/tests/browser/project-git-tools-integration.spec.mjs +369 -0
- package/tests/browser/session-fixture.mjs +118 -0
- package/tests/browser/session-ownership.spec.mjs +175 -0
- package/tests/browser/session-shelves-integration.spec.mjs +219 -0
- package/tests/browser/session-shelves.spec.mjs +340 -0
- package/tests/browser/session-sidebar-resize.spec.mjs +138 -0
- package/tests/browser/session-summary.spec.mjs +17 -12
- package/tests/browser/settings-complete-home.spec.mjs +463 -0
- package/tests/browser/settings-entrypoint.spec.mjs +104 -0
- package/tests/browser/settings-navigation-controller.spec.mjs +383 -0
- package/tests/browser/settings-navigation-integration.spec.mjs +348 -0
- package/tests/browser/settings-resource-lifetime.spec.mjs +349 -0
- package/tests/browser/settings-workspace-integration.spec.mjs +132 -0
- package/tests/browser/shell-ownership.spec.mjs +398 -0
- package/tests/browser/shell-rollout-fixture.mjs +259 -0
- package/tests/browser/shell-rollout.spec.mjs +357 -0
- package/tests/browser/shell-tools-launcher.spec.mjs +260 -0
- package/tests/browser/shell-workspace.spec.mjs +433 -0
- package/tests/browser/side-panel-section-reorder.spec.mjs +3 -1
- package/tests/browser/sidebar-floating-tooltips.spec.mjs +37 -0
- package/tests/browser/sidebar-update-integration.spec.mjs +277 -0
- package/tests/browser/sidebar-update-menu.spec.mjs +402 -0
- package/tests/browser/sidebar-update-progress.spec.mjs +472 -0
- package/tests/browser/stream-output-isolation.spec.mjs +6 -3
- package/tests/browser/themed-selects.spec.mjs +297 -0
- package/tests/browser/thread-start-flow.spec.mjs +481 -0
- package/tests/browser/ui-polish-activity-controls.spec.mjs +177 -0
- package/tests/browser/ui-polish-features.spec.mjs +85 -0
- package/tests/browser/ui-polish-file-header.spec.mjs +43 -0
- package/tests/browser/ui-polish-local-git.spec.mjs +183 -0
- package/tests/browser/ui-polish-mobile-recovery.spec.mjs +36 -0
- package/tests/browser/ui-polish-navigation.spec.mjs +127 -0
- package/tests/browser/ui-polish-session-actions.spec.mjs +282 -0
- package/tests/browser/user-noticeable-fixes.spec.mjs +10 -3
- package/tests/browser/windows-drive-parent.spec.mjs +4 -2
- package/tests/browser/workspace-draft-selection.spec.mjs +266 -0
- package/tests/codex-fast-mode-static.test.mjs +16 -11
- package/tests/codex-speed-mode-browser-state.test.mjs +6 -3
- package/tests/codex-usage-source.test.mjs +4 -3
- package/tests/component-update-api-static.test.mjs +2 -2
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-deck-component-updates-static.test.mjs +9 -4
- package/tests/control-visibility-static.test.mjs +3 -3
- package/tests/controls-layout-static.test.mjs +5 -5
- package/tests/conversation-overview-adapter.test.mjs +100 -0
- package/tests/document-artifact-static.test.mjs +2 -1
- package/tests/draft-conversations.test.mjs +205 -0
- package/tests/empty-startup-launcher.test.mjs +197 -0
- package/tests/events-tree-context-menu-static.test.mjs +22 -18
- package/tests/fake-pi-session-ownership.test.mjs +302 -0
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/feature-system-prompt-optional-feature-static.test.mjs +1 -1
- package/tests/file-viewer-image-static.test.mjs +15 -11
- package/tests/file-viewer-search-static.test.mjs +5 -5
- package/tests/fixtures/fake-pi.mjs +41 -9
- package/tests/footer-provider-usage-visual-static.test.mjs +7 -6
- package/tests/foreground-transcript-catch-up-static.test.mjs +7 -4
- package/tests/git-footer-context-menu-static.test.mjs +1 -1
- package/tests/git-panel-file-preview-static.test.mjs +41 -48
- package/tests/git-panel-live-updates-static.test.mjs +2 -1
- package/tests/git-workflow-dispatch.test.mjs +66 -0
- package/tests/git-workflow-preferences.test.mjs +9 -1
- package/tests/guided-git-activation-static.test.mjs +14 -11
- package/tests/guided-git-fallback-ui-static.test.mjs +8 -5
- package/tests/guided-git-message-reliability-static.test.mjs +10 -6
- package/tests/guided-git-publication-backend-static.test.mjs +16 -11
- package/tests/http-endpoints-harness.test.mjs +21 -9
- package/tests/interaction-state-stability-static.test.mjs +4 -3
- package/tests/intercom-conversation-viewer-static.test.mjs +29 -17
- package/tests/intercom-tag-layout-static.test.mjs +13 -12
- package/tests/intercom-tag-overflow-layout.test.mjs +11 -10
- package/tests/main-output-loading-static.test.mjs +4 -4
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-compact-layout.test.mjs +2 -2
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +10 -7
- package/tests/mobile-phone-experience-static.test.mjs +3 -2
- package/tests/mobile-static.test.mjs +173 -135
- package/tests/model-catalog-order.test.mjs +103 -0
- package/tests/native-parity.test.mjs +6 -4
- package/tests/native-session-choice-owner.test.mjs +102 -0
- package/tests/native-update-lifecycle.test.mjs +10 -5
- package/tests/no-project-http-harness.test.mjs +328 -0
- package/tests/no-project-navigation.test.mjs +54 -0
- package/tests/no-project-workspaces.test.mjs +77 -0
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/optional-feature-migration-frontend.test.mjs +4 -4
- package/tests/optional-feature-prompt-impact-static.test.mjs +3 -3
- package/tests/package-updates.test.mjs +630 -0
- package/tests/persistent-ui-layout-static.test.mjs +3 -3
- package/tests/platform-event-stream.test.mjs +253 -0
- package/tests/project-file-viewer-controller.test.mjs +652 -0
- package/tests/project-git-tools-adapter.test.mjs +103 -0
- package/tests/project-git-tools-controller.test.mjs +577 -0
- package/tests/project-runners-controller.test.mjs +453 -0
- package/tests/prompt-input-vertical-scroll-static.test.mjs +3 -3
- package/tests/prompt-routing-input-clear-static.test.mjs +2 -2
- package/tests/questionnaire-dialog.test.mjs +6 -6
- package/tests/queue-edit-reorder-static.test.mjs +48 -51
- package/tests/rpc-supervisor-host.test.mjs +4 -1
- package/tests/safety-guard-auto-review-static.test.mjs +1 -1
- package/tests/sampling-native-controls-user-flow.test.mjs +7 -1
- package/tests/server-app-runners.test.mjs +536 -0
- package/tests/server-codex-fast-mode.test.mjs +346 -0
- package/tests/server-conversation-mode.test.mjs +386 -0
- package/tests/server-conversation-voice.test.mjs +426 -0
- package/tests/server-extension-ui-requests.test.mjs +357 -0
- package/tests/server-git-generation.test.mjs +558 -0
- package/tests/server-git-mutations.test.mjs +729 -0
- package/tests/server-git-reads.test.mjs +381 -0
- package/tests/server-git-worktree-sessions.test.mjs +502 -0
- package/tests/server-helper-requests.test.mjs +364 -0
- package/tests/server-rpc-transports.test.mjs +553 -0
- package/tests/server-settings-store.test.mjs +132 -0
- package/tests/server-shell-rollout.test.mjs +478 -0
- package/tests/server-sse-delivery.test.mjs +410 -0
- package/tests/server-workspace-files.test.mjs +546 -0
- package/tests/session-attention-scheduler.test.mjs +514 -0
- package/tests/session-composer-store.test.mjs +153 -0
- package/tests/session-context.test.mjs +134 -0
- package/tests/session-extension-requests.test.mjs +193 -0
- package/tests/session-ownership-adapter.test.mjs +130 -0
- package/tests/session-sampling-ui-static.test.mjs +10 -4
- package/tests/session-send-lifetime.test.mjs +140 -0
- package/tests/session-shelf-state.test.mjs +348 -0
- package/tests/session-shelves-adapter.test.mjs +79 -0
- package/tests/session-summary-lifetime.test.mjs +54 -0
- package/tests/settings-resource-controller.test.mjs +548 -0
- package/tests/shell-action-adapter.test.mjs +169 -0
- package/tests/shell-actions.test.mjs +182 -0
- package/tests/shell-navigation.test.mjs +348 -0
- package/tests/shell-preferences.test.mjs +367 -0
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/stream-output-isolation-static.test.mjs +1 -1
- package/tests/subagent-gate-visibility.test.mjs +1 -1
- package/tests/subagent-launch-slot-state.test.mjs +2 -2
- package/tests/subagent-launch-slots-static.test.mjs +1 -1
- package/tests/subagent-observability-static.test.mjs +2 -2
- package/tests/subagent-reliability-integration.test.mjs +13 -30
- package/tests/syntax-highlighting-static.test.mjs +3 -3
- package/tests/tab-close-continuity-static.test.mjs +1 -1
- package/tests/tab-metadata-ordering.test.mjs +99 -0
- package/tests/terminal-cwd-grouping-static.test.mjs +2 -2
- package/tests/terminal-tab-prompt-tooltip-static.test.mjs +2 -0
- package/tests/terminal-tab-workspace-static.test.mjs +5 -4
- package/tests/terminal-tabs-resize-static.test.mjs +1 -1
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/thread-display-title.test.mjs +44 -0
- package/tests/update-api-harness.test.mjs +15 -14
- package/tests/update-tab-restore-harness.test.mjs +3 -0
- package/tests/webui-settings-locking.test.mjs +2 -2
- package/tests/windows-drive-cwd-picker-static.test.mjs +7 -9
- package/tests/workspace-choices.test.mjs +114 -0
- package/tests/workspace-save-load-static.test.mjs +7 -4
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
+
|
|
3
4
|
import { dirname, join } from "node:path";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
5
6
|
|
|
7
|
+
const codexSpeed = await readFile(new URL("../lib/server/codex-fast-mode.mjs", import.meta.url), "utf8");
|
|
8
|
+
|
|
6
9
|
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
10
|
const [server, app, html, styles, serviceWorker, technical, development, packageRaw, lockRaw, optionalFeatureCatalog] = await Promise.all([
|
|
8
11
|
readFile(join(root, "bin", "pi-webui.mjs"), "utf8"),
|
|
@@ -27,26 +30,26 @@ assert.equal(lock.packages?.[`node_modules/${packageName}`], undefined, "lockfil
|
|
|
27
30
|
assert.match(optionalFeatureCatalog, /\["codexFastMode", "@firstpick\/pi-extension-codex-fast-mode", "\^0\.1\.0"\]/, "Optional Features should retain the Pi-installable Fast-mode package mapping");
|
|
28
31
|
|
|
29
32
|
assert.match(server, /const OPTIONAL_FEATURE_PACKAGES = new Map\(OPTIONAL_FEATURE_CATALOG/, "server should derive Fast-mode installation from the shared Optional Features catalog");
|
|
30
|
-
assert.match(
|
|
31
|
-
assert.match(
|
|
32
|
-
assert.match(
|
|
33
|
-
assert.match(
|
|
34
|
-
assert.match(
|
|
35
|
-
assert.match(
|
|
36
|
-
assert.doesNotMatch(
|
|
33
|
+
assert.match(codexSpeed, /CODEX_FAST_MODE_STATUS_KEY = "codex-fast-mode"[\s\S]*?CODEX_FAST_MODE_COMMAND_NAME = "fast-mode"/, "server should use the extension-owned status and command contracts");
|
|
34
|
+
assert.match(codexSpeed, /function codexFastModeStatusState\(statusText\)[\s\S]*?codexSpeedModeFromStatus\(stripAnsi\(statusText\)\)/, "server should use the tested exact status parser");
|
|
35
|
+
assert.match(codexSpeed, /function codexFastModeSnapshot\(tab, patch = \{\}\)[\s\S]*?extensionStatusMap\(tab\)\.get\(CODEX_FAST_MODE_STATUS_KEY\)/, "server snapshots should come from remembered extension status");
|
|
36
|
+
assert.match(codexSpeed, /async function codexFastModeFeatureData[\s\S]*?codexFastModeSnapshot\(tab\)[\s\S]*?tabHasActiveOutput\(tab\)[\s\S]*?ultrafastModelEligible:[\s\S]*?CODEX_FAST_MODE_CREDIT_NOTICE/, "GET state should be tab-scoped, extension-owned, busy-aware, model-gated, and disclose credit use");
|
|
37
|
+
assert.match(codexSpeed, /async function waitForCodexFastModeStatus\(tab, desired\)[\s\S]*?snapshot\.statusKnown && snapshot\.mode === desired[\s\S]*?makeHttpError\(409,[\s\S]*?did not confirm/, "server should require bounded exact-mode confirmation");
|
|
38
|
+
assert.match(codexSpeed, /async function setCodexFastMode[\s\S]*?codexSpeedModeFromIntent\(body\)[\s\S]*?feature\.busy[\s\S]*?desired === "ultrafast" && !feature\.ultrafastModelEligible[\s\S]*?type: "prompt", message: `\/\$\{feature\.commandName\} \$\{argument\}`[\s\S]*?waitForCodexFastModeStatus\(tab, desired\)/, "PUT should validate intent, reject busy or ineligible tabs, invoke the extension, and require exact confirmed state");
|
|
39
|
+
assert.doesNotMatch(codexSpeed, /codexFastModeSnapshot\(tab, \{ enabled: desired/, "server must not infer effective Fast state from RPC success");
|
|
37
40
|
assert.match(server, /url\.pathname === "\/api\/codex-fast-mode" && req\.method === "GET"[\s\S]*?url\.pathname === "\/api\/codex-fast-mode" && req\.method === "PUT"/, "server should expose GET and PUT routes");
|
|
38
41
|
|
|
39
42
|
assert.match(html, /<label for="fastOutputModeSelect">Compact mode \(Experimental\)<\/label>[\s\S]*?<option value="compact-v1">Compact<\/option>/, "legacy output processing should be presented as Compact mode while retaining compact-v1");
|
|
40
43
|
assert.doesNotMatch(html, /<label for="fastOutputModeSelect">Fast mode/, "legacy output processing should no longer be presented as Fast mode");
|
|
41
44
|
assert.match(html, /data-side-panel-section="codex-usage"[\s\S]*?id="codexUsageBox"[\s\S]*?class="control-field codex-fast-mode-control"[\s\S]*?class="codex-fast-mode-row"[\s\S]*?id="codexFastModeLabel"[\s\S]*?id="codexFastModeSelect"[\s\S]*?<option value="normal">Normal<\/option>[\s\S]*?<option value="fast">Fast<\/option>[\s\S]*?<option value="ultrafast" disabled>Ultrafast<\/option>[\s\S]*?id="setCodexFastModeButton"[\s\S]*?id="codexFastModeStatus"/, "Codex Usage should render before the compact session Fast-mode row");
|
|
42
45
|
assert.match(styles, /\.codex-fast-mode-control \{[\s\S]*?margin-top: 0\.58rem[\s\S]*?padding: 0\.48rem 0\.55rem[\s\S]*?\.codex-fast-mode-row \{[\s\S]*?grid-template-columns: minmax\(0, 1fr\) minmax\(6\.5rem, 8rem\) auto/, "Codex Fast mode should use a compact horizontal control surface");
|
|
43
|
-
assert.match(app, /function codexFastModeStatusText\(\)[\s\S]*?codexSpeedModeLabel\(codexFastModeState\.mode\)[\s\S]*?return `\$\{label\} · This
|
|
46
|
+
assert.match(app, /function codexFastModeStatusText\(\)[\s\S]*?codexSpeedModeLabel\(codexFastModeState\.mode\)[\s\S]*?return `\$\{label\} · This thread`;/, "mode status should distinguish all three preferences concisely");
|
|
44
47
|
|
|
45
48
|
assert.match(app, /id: "codexFastMode"[\s\S]*?packageName: "@firstpick\/pi-extension-codex-fast-mode"[\s\S]*?capabilityLabel: "\/fast-mode"/, "browser Optional Features should catalog Fast mode");
|
|
46
49
|
assert.match(app, /OPTIONAL_FEATURE_DISABLE_PREREQUISITES = new Map\([\s\S]*?\["codexFastMode", \(\) => disableCodexFastModeIntegration\(\)\]/, "browser should register disable-off-first behavior");
|
|
47
50
|
assert.match(app, /if \(disabled\) \{[\s\S]*?OPTIONAL_FEATURE_DISABLE_PREREQUISITES\.get\(feature\.id\)[\s\S]*?await turnOff\(\)[\s\S]*?setOptionalFeatureDisabled\(feature\.id, disabled\)/, "Optional Features Disable should abort before hiding integration if turn-off fails");
|
|
48
51
|
assert.match(app, /function applyCodexFastModeStatus\(statusText\)[\s\S]*?codexSpeedModeFromStatus\(statusText\)[\s\S]*?if \(mode === null\) return false[\s\S]*?enabled: mode !== "normal"[\s\S]*?statusKnown: true/, "browser should consume only exact extension status values");
|
|
49
|
-
assert.match(app, /async function refreshCodexFastMode\(tabContext = activeTabContext\(\)\)[\s\S]*?api\("\/api\/codex-fast-mode", \{ tabId: tabContext\.tabId \}\)[\s\S]*?!featureEnabled && data\.available[\s\S]*?enabled: false[\s\S]*?isCurrentTabContext\(tabContext\)/, "browser status refresh should stay tab-scoped and disarm restored branches while the feature is hidden");
|
|
52
|
+
assert.match(app, /async function refreshCodexFastMode\(tabContext = activeTabContext\(\), \{ readOnly = false \} = \{\}\)[\s\S]*?api\("\/api\/codex-fast-mode", \{ tabId: tabContext\.tabId \}\)[\s\S]*?!readOnly && !featureEnabled && data\.available[\s\S]*?enabled: false[\s\S]*?isCurrentTabContext\(tabContext\)/, "browser status refresh should stay tab-scoped and disarm restored branches while the feature is hidden");
|
|
50
53
|
assert.match(app, /async function applyCodexFastMode\(\)[\s\S]*?await appConfirm\([\s\S]*?8x Standard included usage[\s\S]*?6x purchased-credit[\s\S]*?if \(!confirmed[\s\S]*?body: \{ mode \}, tabId: tabContext\.tabId/, "browser should confirm Ultrafast costs before applying explicit mode intent");
|
|
51
54
|
assert.match(app, /async function disableCodexFastModeIntegration\(\)[\s\S]*?tabs\.filter[\s\S]*?Promise\.all\(tabIds\.map[\s\S]*?data\.busy[\s\S]*?enabled: false[\s\S]*?codexFastModeConfirmedOff\(response\.data\)/, "browser-global Disable should preflight every live tab and require each mutation to confirm off");
|
|
52
55
|
assert.match(app, /refreshNaturalConversationMode\(tabContext\),[\s\S]*?refreshCodexFastMode\(tabContext\),/, "tab refreshes should reload branch-scoped Fast-mode state");
|
|
@@ -56,7 +59,9 @@ assert.match(technical, /## Normal and compact output[\s\S]*?select \*\*Compact\
|
|
|
56
59
|
assert.match(development, /### Codex subscription Fast mode[\s\S]*?service_tier: "priority"[\s\S]*?service_tier: "ultrafast"[\s\S]*?8× Standard included usage[\s\S]*?6×/, "development guide should document both tiers and cost semantics");
|
|
57
60
|
assert.match(technical, /Normal \/ Fast \/ Ultrafast[\s\S]*?Pro \$500/, "technical reference should document the third mode and subscription eligibility");
|
|
58
61
|
// Intent preserved: browser-asset changes must advance the coherent cache tuple.
|
|
59
|
-
assert.match(serviceWorker, /pi-webui-pwa-
|
|
60
|
-
assert.match(html, /data-app-src="\/app\.js\?v=
|
|
62
|
+
assert.match(serviceWorker, /pi-webui-pwa-v200[\s\S]*?"\/codex-speed-mode\.mjs"/, "PWA should refresh and cache the shared mode helper");
|
|
63
|
+
assert.match(html, /data-app-src="\/app\.js\?v=220"/, "browser module URL should be cache-busted for speed-mode wiring");
|
|
64
|
+
|
|
65
|
+
assert.match(server, /createCodexFastModeService\(\{[\s\S]*packageName: OPTIONAL_FEATURE_PACKAGES\.get\("codexFastMode"\)/, "server must wire the speed adapter to the canonical package catalog");
|
|
61
66
|
|
|
62
67
|
console.log("codex-fast-mode-static.test.mjs passed");
|
|
@@ -5,7 +5,7 @@ import * as modes from "../public/codex-speed-mode.mjs";
|
|
|
5
5
|
|
|
6
6
|
const source = await readFile(new URL("../public/app.js", import.meta.url), "utf8");
|
|
7
7
|
const start = source.indexOf("// Codex subscription Fast mode is owned");
|
|
8
|
-
const end = source.indexOf("
|
|
8
|
+
const end = source.indexOf("const SUBAGENT_LAUNCHER_LABELS", start);
|
|
9
9
|
assert.ok(start >= 0 && end > start, "execute the actual browser speed-control implementation");
|
|
10
10
|
const controlSource = source.slice(start, end);
|
|
11
11
|
|
|
@@ -13,6 +13,7 @@ function harness({ confirm = true, eligible = true, enabledFeature = true } = {}
|
|
|
13
13
|
const calls = [];
|
|
14
14
|
const confirmations = [];
|
|
15
15
|
const events = [];
|
|
16
|
+
let shellRenders = 0;
|
|
16
17
|
const ultrafastOption = { disabled: true };
|
|
17
18
|
const select = { value: "normal", disabled: true, querySelector: () => ultrafastOption };
|
|
18
19
|
let currentTab = "tab-one";
|
|
@@ -36,6 +37,7 @@ function harness({ confirm = true, eligible = true, enabledFeature = true } = {}
|
|
|
36
37
|
normalizeSelectedModel: (model) => model,
|
|
37
38
|
modelStateKey: (model) => `${model?.provider}/${model?.id}`,
|
|
38
39
|
renderStatus() {},
|
|
40
|
+
scheduleFocusedShellRender() { shellRenders++; },
|
|
39
41
|
requestGitFooterWebuiPayload() {},
|
|
40
42
|
queueMicrotask,
|
|
41
43
|
async appConfirm(options) {
|
|
@@ -57,14 +59,14 @@ function harness({ confirm = true, eligible = true, enabledFeature = true } = {}
|
|
|
57
59
|
context.applyCodexFastModeData(data("normal"));
|
|
58
60
|
vm.runInContext("codexFastModeLoaded = true", context);
|
|
59
61
|
context.renderCodexFastModeControl();
|
|
60
|
-
return { context, calls, confirmations, events, select, tabModes, ultrafastOption, data, setEligible(value) { eligible = value; } };
|
|
62
|
+
return { context, calls, confirmations, events, get shellRenders() { return shellRenders; }, select, tabModes, ultrafastOption, data, setEligible(value) { eligible = value; } };
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
{
|
|
64
66
|
const h = harness();
|
|
65
67
|
assert.equal(h.context.applyCodexFastModeStatus("ultrafast"), true);
|
|
66
68
|
assert.equal(h.select.value, "ultrafast");
|
|
67
|
-
assert.equal(h.context.codexFastModeStatusText(), "Ultrafast · This
|
|
69
|
+
assert.equal(h.context.codexFastModeStatusText(), "Ultrafast · This thread");
|
|
68
70
|
assert.equal(h.context.applyCodexFastModeStatus("ultrafast now"), false);
|
|
69
71
|
assert.equal(h.select.value, "ultrafast");
|
|
70
72
|
assert.equal(h.context.codexFastModeConfirmedOff({ statusKnown: true, mode: "ultrafast", enabled: false }), false);
|
|
@@ -98,6 +100,7 @@ function harness({ confirm = true, eligible = true, enabledFeature = true } = {}
|
|
|
98
100
|
h.select.value = "ultrafast";
|
|
99
101
|
await h.context.applyCodexFastMode();
|
|
100
102
|
assert.equal(h.calls.length, 0, "changing tabs during cost confirmation must cancel the mutation");
|
|
103
|
+
assert.equal(h.shellRenders, 1, "settling the old confirmation schedules current Settings controls");
|
|
101
104
|
}
|
|
102
105
|
{
|
|
103
106
|
const h = harness({ eligible: false });
|
|
@@ -117,18 +117,19 @@ test("the server gives a sanitized combined error when CLI and direct-flow Pi fa
|
|
|
117
117
|
});
|
|
118
118
|
|
|
119
119
|
test("the browser labels the usage account and redraws when source changes", async () => {
|
|
120
|
-
const source = await readFile(new URL("../public/
|
|
120
|
+
const source = await readFile(new URL("../public/activity-usage-controller.mjs", import.meta.url), "utf8");
|
|
121
121
|
const signatureStart = source.indexOf("function codexUsageStructureSignature(");
|
|
122
122
|
const signatureEnd = source.indexOf("function updateCodexUsageValues(", signatureStart);
|
|
123
123
|
const renderStart = source.indexOf("function renderCodexUsage(");
|
|
124
|
-
const renderEnd = source.indexOf("
|
|
124
|
+
const renderEnd = source.indexOf("function renderClaudeUsageWindow(", renderStart);
|
|
125
125
|
const nodes = [];
|
|
126
126
|
let rebuilds = 0;
|
|
127
127
|
const box = { replaceChildren: () => { nodes.length = 0; rebuilds++; }, classList: { toggle() {} }, append: (...items) => nodes.push(...items) };
|
|
128
128
|
const context = vm.createContext({
|
|
129
129
|
latestCodexUsage: { source: "codex-cli", planType: "plus" },
|
|
130
130
|
codexUsageLoading: false, codexUsageError: null, codexUsageRenderSignature: "",
|
|
131
|
-
|
|
131
|
+
nodes: { codexUsageBox: box },
|
|
132
|
+
disposed: false,
|
|
132
133
|
formatCodexPlanType: (value) => value,
|
|
133
134
|
codexUsageBuckets: () => [],
|
|
134
135
|
updateCodexUsageValues: () => true,
|
|
@@ -14,8 +14,8 @@ const [server, state, launcher, runner, trust] = await Promise.all([
|
|
|
14
14
|
assert.match(state, /validateUpdatePlanRequest[\s\S]*targets must contain exactly one value/);
|
|
15
15
|
assert.match(state, /validateUpdateApplyRequest[\s\S]*Apply accepts only transactionId and planDigest/);
|
|
16
16
|
assert.match(server, /url\.pathname === "\/api\/update\/plan"[\s\S]*requireLocalhostRoute[\s\S]*validateUpdatePlanRequest[\s\S]*sendJson\(res, 201/);
|
|
17
|
-
assert.match(server, /url\.pathname === "\/api\/update\/apply"[\s\S]*requireLocalhostRoute[\s\S]*validateUpdateApplyRequest[\s\S]*
|
|
18
|
-
assert.match(server, /
|
|
17
|
+
assert.match(server, /url\.pathname === "\/api\/update\/apply"[\s\S]*requireLocalhostRoute[\s\S]*validateUpdateApplyRequest[\s\S]*packageUpdates\.apply/);
|
|
18
|
+
assert.match(server, /packageUpdates\.plan\(validation\.targets\[0\]\)/);
|
|
19
19
|
assert.match(server, /validateNativePlan\(job\.plan, digest\)/);
|
|
20
20
|
assert.match(server, /url\.pathname === "\/api\/restart"[\s\S]*requireLocalhostRoute[\s\S]*assertNativeMutationAdmission\(\)/,
|
|
21
21
|
"ordinary server restarts must not race a native update fence");
|
|
@@ -57,8 +57,8 @@ assert.match(app, /function initializeComposerActionOrdering\(\)[\s\S]*MutationO
|
|
|
57
57
|
assert.match(app, /event\.key === COMPOSER_ACTION_ORDER_STORAGE_KEY\) restoreComposerActionOrder\(\)[\s\S]*event\.key === COMPOSER_ACTION_LAYOUT_STORAGE_KEY\) restoreComposerActionSlotLayout\(\)/, "other tabs should apply persisted composer order and sparse-layout changes");
|
|
58
58
|
assert.match(app, /initializeComposerActionOrdering\(\);[\s\S]*restoreSidePanelSectionOrder\(\);/, "composer ordering should initialize during guarded app startup");
|
|
59
59
|
|
|
60
|
-
assert.match(html, /styles\.css\?v=
|
|
61
|
-
assert.match(html, /app\.js\?v=
|
|
62
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
60
|
+
assert.match(html, /styles\.css\?v=167/, "changed composer styles should advance the stylesheet revision");
|
|
61
|
+
assert.match(html, /app\.js\?v=220/, "changed composer behavior should advance the app revision");
|
|
62
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v200"/, "changed browser assets should advance the PWA cache identity");
|
|
63
63
|
|
|
64
64
|
console.log("composer-action-grid-reorder-static.test.mjs passed");
|
|
@@ -10,6 +10,9 @@ const [html, css, app, development] = await Promise.all([
|
|
|
10
10
|
readFile(join(root, "public/app.js"), "utf8"),
|
|
11
11
|
readFile(join(root, "DEVELOPMENT.md"), "utf8"),
|
|
12
12
|
]);
|
|
13
|
+
assert.match(app, /const COMPONENT_UPDATE_TARGETS = \["all", "pi", "webui"\]/);
|
|
14
|
+
assert.match(app, /createSidebarUpdateMenu\(\{ button: elements\.sidebarUpdateButton, onSelect: startComponentUpdate \}\)/);
|
|
15
|
+
assert.match(html, /id="sidebarUpdateButton"[^>]*aria-label="Updates"/);
|
|
13
16
|
for (const target of ["pi", "webui"]) {
|
|
14
17
|
assert.match(app, new RegExp(`startComponentUpdate\\("${target}"\\)`));
|
|
15
18
|
assert.match(html, new RegExp(`id="${target}ComponentUpdateStatus"[^>]*aria-live="polite"`));
|
|
@@ -20,14 +23,16 @@ assert.doesNotMatch(html, /update-all|Update all|Pi \+ Web UI update/);
|
|
|
20
23
|
assert.doesNotMatch(app, /runPiUpdateAndRestart|managed Web UI activation|side-by-side managed runtime/);
|
|
21
24
|
assert.match(app, /body: \{ targets: \[target\] \}/);
|
|
22
25
|
assert.match(app, /body: \{ transactionId: plan.transactionId, planDigest: plan.digest \}/);
|
|
23
|
-
|
|
26
|
+
const startUpdate = app.slice(app.indexOf("async function startComponentUpdate(target)"), app.indexOf("async function openWebuiPackageDialog()"));
|
|
27
|
+
assert.doesNotMatch(startUpdate, /appConfirm|window\.confirm/);
|
|
28
|
+
assert.match(startUpdate, /plan\?\.requested !== target[\s\S]*!plan\.transactionId[\s\S]*!plan\.digest[\s\S]*!Array\.isArray\(plan\.targets\)/);
|
|
24
29
|
assert.match(app, /nativeJobs[\s\S]*nativeJobDiscoveryError/);
|
|
25
|
-
assert.match(app, /
|
|
30
|
+
assert.match(app, /sidebarUpdateError = "Update preview is incomplete; no command was launched\."/);
|
|
26
31
|
assert.match(app, /uncertainApplyJobs\[target\] = plan\.transactionId[\s\S]*phase: "launching"/);
|
|
27
32
|
assert.match(app, /if \(latestUpdateStatus\?\.nativeJobs && !latestUpdateStatus\.nativeJobDiscoveryError\) nativeJobPollError = ""/);
|
|
28
33
|
assert.match(app, /api\/update\/transactions\/\$\{encodeURIComponent\(job\.transactionId\)\}/);
|
|
29
|
-
assert.match(app, /case "unknown"[\s\S]*
|
|
30
|
-
assert.match(app, /case "partial"[\s\S]*
|
|
34
|
+
assert.match(app, /case "unknown"[\s\S]*Check the command output/);
|
|
35
|
+
assert.match(app, /case "partial"[\s\S]*Some commands failed/);
|
|
31
36
|
assert.match(css, /\.component-update-status\[data-update-running\]::before[\s\S]*component-update-spin/);
|
|
32
37
|
assert.match(development, /Native Pi and Web UI updates[\s\S]*GET \/api\/update\/transactions\/.*[\s\S]*Native lifecycle scripts are not sandboxed/);
|
|
33
38
|
console.log("control deck component update static tests passed");
|
|
@@ -348,10 +348,10 @@ assert.match(
|
|
|
348
348
|
|
|
349
349
|
assert.match(
|
|
350
350
|
serviceWorker,
|
|
351
|
-
/const CACHE_NAME = "pi-webui-pwa-
|
|
351
|
+
/const CACHE_NAME = "pi-webui-pwa-v200";/,
|
|
352
352
|
"browser asset changes should advance the PWA cache identity",
|
|
353
353
|
);
|
|
354
|
-
assert.match(html, /styles\.css\?v=
|
|
355
|
-
assert.match(html, /data-app-src="\/app\.js\?v=
|
|
354
|
+
assert.match(html, /styles\.css\?v=167/, "visibility styles should advance the stylesheet query revision");
|
|
355
|
+
assert.match(html, /data-app-src="\/app\.js\?v=220"/, "visibility behavior should advance the app query revision");
|
|
356
356
|
|
|
357
357
|
console.log("control-visibility-static.test.mjs passed");
|
|
@@ -9,14 +9,14 @@ const css = readFileSync(join(root, "public/styles.css"), "utf8");
|
|
|
9
9
|
const app = readFileSync(join(root, "public/app.js"), "utf8");
|
|
10
10
|
const serviceWorker = readFileSync(join(root, "public/service-worker.js"), "utf8");
|
|
11
11
|
|
|
12
|
-
assert.equal((html.match(/class="control-row(?:\s[^"]*)?"/g) || []).length,
|
|
12
|
+
assert.equal((html.match(/class="control-row(?:\s[^"]*)?"/g) || []).length, 16, "Controls should render one two-column row per setting, including optional remote-access settings");
|
|
13
13
|
assert.match(css, /\.control-row \{[\s\S]*grid-template-columns:\s*minmax\(6\.2rem, 0\.44fr\) minmax\(0, 1fr\)/, "Controls settings should use stable name and parameter columns");
|
|
14
|
-
assert.equal((html.match(/class="control-row-label"[^>]*data-tooltip=/g) || []).length,
|
|
14
|
+
assert.equal((html.match(/class="control-row-label"[^>]*data-tooltip=/g) || []).length, 16, "Every Controls setting name should provide user-friendly help");
|
|
15
15
|
assert.match(app, /function initializeControlSettingTooltips\(\)[\s\S]*#sidePanelSectionControls \.control-row-label\[data-tooltip\][\s\S]*bindStyledTooltipEvents\(label\)[\s\S]*showFooterTooltip\(label\)/, "Controls help should use the viewport-safe floating tooltip for hover and keyboard access");
|
|
16
16
|
assert.match(html, /class="control-row remote-auth-control-row" hidden[\s\S]*id="remoteAuthToggle"/, "optional PIN protection should retain its guarded visibility");
|
|
17
17
|
assert.match(app, /remoteAuthToggle\?\.closest\("\.remote-auth-control-row"\)[\s\S]*remoteAuthRow\.hidden = false/, "loading remote status should reveal the optional PIN protection setting");
|
|
18
|
-
assert.match(html, /styles\.css\?v=
|
|
19
|
-
assert.match(html, /app\.js\?v=
|
|
20
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
18
|
+
assert.match(html, /styles\.css\?v=167/, "Controls stylesheet changes should advance the cache query");
|
|
19
|
+
assert.match(html, /app\.js\?v=220/, "Controls tooltip wiring should advance the app cache query");
|
|
20
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v200"/, "Controls browser assets should advance the PWA cache identity");
|
|
21
21
|
|
|
22
22
|
console.log("controls-layout-static.test.mjs passed");
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import vm from 'node:vm';
|
|
4
|
+
import { test } from 'node:test';
|
|
5
|
+
import { checkActionTarget } from '../public/shell-actions.mjs';
|
|
6
|
+
|
|
7
|
+
const source = readFileSync(new URL('../public/app.js', import.meta.url), 'utf8');
|
|
8
|
+
const functions = ['threadDisplayTitle', 'focusedOverviewSnapshot', 'invokeOverviewAction'].map(name => {
|
|
9
|
+
const start = source.indexOf(`function ${name}(`);
|
|
10
|
+
assert.ok(start >= 0);
|
|
11
|
+
return source.slice(start, source.indexOf('\n}', start) + 2);
|
|
12
|
+
}).join('\n');
|
|
13
|
+
|
|
14
|
+
function fixture() {
|
|
15
|
+
const context = vm.createContext({ checkActionTarget });
|
|
16
|
+
vm.runInContext(`
|
|
17
|
+
let shellPreferenceState = {value:{overviewOpen:true}};
|
|
18
|
+
let enabled = true, dataReads = 0, focusedShellState = {destination:'conversation'};
|
|
19
|
+
let tab = {id:'tab-a',title:'A',cwd:'/a',gitWorkspace:{branch:'feature'}};
|
|
20
|
+
let target = {tabId:'tab-a',generation:1,sessionIdentity:'session-a',cwd:'/a'};
|
|
21
|
+
let payload = null, currentState = {pendingMessageCount:2}, runner = null;
|
|
22
|
+
let agentState = {data:null}, usageContext = null, events = [], invoked = [];
|
|
23
|
+
const activeTab = () => tab;
|
|
24
|
+
const shellActionTarget = () => ({...target});
|
|
25
|
+
const isFocusedShellRequested = () => enabled;
|
|
26
|
+
const parseGitFooterWebuiPayload = () => {dataReads++; return payload;};
|
|
27
|
+
const normalizeGitWorkspaceInfo = value => value;
|
|
28
|
+
const tabAppRunnerRun = () => runner;
|
|
29
|
+
const activityAgents = {getSnapshot:() => agentState};
|
|
30
|
+
const subagentOverviewGroups = data => data.groups;
|
|
31
|
+
const contextUsageSnapshot = () => usageContext;
|
|
32
|
+
const contextUsageDisplay = value => value ? '25% of 200k' : 'Context unknown';
|
|
33
|
+
const contextUsageDetail = () => 'Current session context';
|
|
34
|
+
const cleanStatusText = value => String(value || '');
|
|
35
|
+
const tabIndicator = () => ({label:'Working'});
|
|
36
|
+
const focusedToolsActions = () => ['files','git','runners','subagents','queue','session','codex-usage','claude-usage'].map(id => ({id:'view:'+id,scope:'browser',available:true}));
|
|
37
|
+
const addEvent = (message,level) => events.push({message,level});
|
|
38
|
+
const invokeFocusedTool = action => invoked.push(action);
|
|
39
|
+
${functions}
|
|
40
|
+
`, context);
|
|
41
|
+
return code => vm.runInContext(code, context);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
test('closed and noncompact overview read no feature data', () => {
|
|
45
|
+
const run = fixture();
|
|
46
|
+
run('shellPreferenceState.value.overviewOpen=false');
|
|
47
|
+
assert.equal(run('focusedOverviewSnapshot().open'), false);
|
|
48
|
+
run('shellPreferenceState.value.overviewOpen=true; enabled=false');
|
|
49
|
+
assert.equal(run('focusedOverviewSnapshot().open'), false);
|
|
50
|
+
assert.equal(run('dataReads'), 0);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('overview distinguishes unknown data and scopes agent counts to the selected session', () => {
|
|
54
|
+
const run = fixture();
|
|
55
|
+
assert.equal(run("focusedOverviewSnapshot().sections[1].items.find(row=>row.id==='agents').value"), 'Not loaded');
|
|
56
|
+
assert.equal(run("focusedOverviewSnapshot().sections[2].items.find(row=>row.id==='usage-unknown').value"), 'Not loaded');
|
|
57
|
+
run("agentState.data={groups:[{groupKind:'tab',tabId:'tab-a',runningAgents:1,agentCount:3},{groupKind:'tab',tabId:'tab-b',runningAgents:9,agentCount:20}]}");
|
|
58
|
+
assert.equal(run("focusedOverviewSnapshot().sections[1].items.find(row=>row.id==='agents').value"), '1 running · 3 total');
|
|
59
|
+
run("payload={meta:[{key:'git',value:'main'},{key:'changes',value:'+3 -1'}],providerUsage:{provider:'anthropic',capturedAt:1700000000000,secondary:{label:'Weekly',usedPercent:42}}}; usageContext={percent:25}");
|
|
60
|
+
assert.equal(run("focusedOverviewSnapshot().sections[0].items.find(row=>row.id==='branch').value"), 'main');
|
|
61
|
+
assert.equal(run("focusedOverviewSnapshot().sections[2].items.find(row=>row.id==='usage-secondary').progress"), 42);
|
|
62
|
+
assert.equal(run("focusedOverviewSnapshot().sections[2].items.find(row=>row.id==='usage-secondary').actionId"), 'view:claude-usage');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
for (const mutation of ["target.tabId='tab-b'", "target.generation=2", "target.sessionIdentity='replacement'", "target.cwd='/b'"]) {
|
|
66
|
+
test(`overview rejects a stale action after ${mutation}`, () => {
|
|
67
|
+
const run = fixture();
|
|
68
|
+
run('const captured=focusedOverviewSnapshot().target');
|
|
69
|
+
run(mutation);
|
|
70
|
+
run("invokeOverviewAction('view:git',captured)");
|
|
71
|
+
assert.equal(run('invoked.length'), 0);
|
|
72
|
+
assert.equal(run('events.length'), 1);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
test('current overview actions use the canonical catalog; no-session actions are unavailable', () => {
|
|
77
|
+
const run = fixture();
|
|
78
|
+
run("invokeOverviewAction('view:queue',focusedOverviewSnapshot().target)");
|
|
79
|
+
assert.equal(run('invoked[0].id'), 'view:queue');
|
|
80
|
+
run("invokeOverviewAction('made-up',focusedOverviewSnapshot().target)");
|
|
81
|
+
assert.equal(run('invoked.length'), 1);
|
|
82
|
+
run("tab=null;target={tabId:null,generation:2,sessionIdentity:'',cwd:''}");
|
|
83
|
+
assert.equal(run('focusedOverviewSnapshot().sections.flatMap(section=>section.items).filter(row=>row.actionId).every(row=>row.disabled)'), true);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
test('overview separates external agents, capability absence and stale observations', () => {
|
|
88
|
+
const run = fixture();
|
|
89
|
+
const value = () => run("focusedOverviewSnapshot().sections[1].items.find(row=>row.id==='agents').value");
|
|
90
|
+
run("agentState.data={tabs:[{tabId:'tab-a',available:true},{tabId:'tab-b',available:false}],groups:[{groupKind:'external',tabId:'tab-a',runningAgents:4,agentCount:4}]}");
|
|
91
|
+
assert.equal(value(), '0 running · 0 total');
|
|
92
|
+
run("tab={id:'tab-b'}");
|
|
93
|
+
assert.equal(value(), 'Reporting unavailable');
|
|
94
|
+
run("tab={id:'unknown'}");
|
|
95
|
+
assert.equal(value(), 'Not loaded');
|
|
96
|
+
run("tab={id:'tab-b'};agentState.data.groups.push({groupKind:'tab',tabId:'tab-b',runningAgents:1,agentCount:2})");
|
|
97
|
+
assert.equal(value(), '1 running · 2 total');
|
|
98
|
+
run("agentState.error='offline'");
|
|
99
|
+
assert.match(run("focusedOverviewSnapshot().sections[1].items.find(row=>row.id==='agents').detail"), /previous snapshot/);
|
|
100
|
+
});
|
|
@@ -3,6 +3,7 @@ import { readFile } from "node:fs/promises";
|
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
|
|
6
|
+
const artifactOwner = await readFile(new URL("../public/project-artifact-controller.mjs", import.meta.url), "utf8");
|
|
6
7
|
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
8
|
const [server, app, styles] = await Promise.all([
|
|
8
9
|
readFile(join(root, "bin", "pi-webui.mjs"), "utf8"),
|
|
@@ -12,7 +13,7 @@ const [server, app, styles] = await Promise.all([
|
|
|
12
13
|
|
|
13
14
|
for (const contract of ["pi.artifact/v1", "registerDocumentArtifact", "rewriteArtifactsForTab", "documentArtifactRecord", "sendDocumentArtifactFile", "/api/artifacts/"]) assert.ok(server.includes(contract), `server should contain ${contract}`);
|
|
14
15
|
for (const privateField of ["manifestPath", "downloadPath", "outputPath", "sourcePath", "stagedPath", "pdfPath", "workspace", "recoveryPath"]) assert.match(server, new RegExp(`PRIVATE_ARTIFACT_KEYS[^;]+[\\s\\S]*?${privateField}`), `artifact sanitizer should cover ${privateField}`);
|
|
15
|
-
for (const feature of ["openDocumentArtifact", "appendDocumentArtifact", "Send page to composer", "Previous", "Rotate", "Semantic structure, revisions, warnings, and diff"]) assert.ok(app.includes(feature), `browser viewer should contain ${feature}`);
|
|
16
|
+
for (const feature of ["openDocumentArtifact", "appendDocumentArtifact", "Send page to composer", "Previous", "Rotate", "Semantic structure, revisions, warnings, and diff"]) assert.ok((app + artifactOwner).includes(feature), `browser viewer should contain ${feature}`);
|
|
16
17
|
for (const selector of [".document-artifact-dialog", ".document-artifact-sidebar", ".document-artifact-page", "@media (max-width: 720px)"]) assert.ok(styles.includes(selector), `viewer stylesheet should contain ${selector}`);
|
|
17
18
|
assert.equal(/details\.artifact\s*=/.test(server), false, "server should replace details immutably rather than mutating raw RPC artifacts");
|
|
18
19
|
console.log("document-artifact-static.test.mjs passed");
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { test } from "node:test";
|
|
3
|
+
import { createDraftConversations, DRAFT_STORAGE_KEY, DRAFT_LIMITS } from "../public/draft-conversations.mjs";
|
|
4
|
+
|
|
5
|
+
function fixture(initial = null) {
|
|
6
|
+
let raw = initial;
|
|
7
|
+
let blocked = false;
|
|
8
|
+
let serial = 0;
|
|
9
|
+
const storage = {
|
|
10
|
+
getItem: () => raw,
|
|
11
|
+
setItem(key, value) {
|
|
12
|
+
assert.equal(key, DRAFT_STORAGE_KEY);
|
|
13
|
+
if (blocked) throw new Error("Storage denied");
|
|
14
|
+
raw = value;
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
const options = { storage: () => storage, randomId: () => `test-${++serial}`, now: () => 100 };
|
|
18
|
+
return { store: createDraftConversations(options), reload: () => createDraftConversations(options), raw: () => raw, block: value => { blocked = value; } };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
test("blank identities stay separate and only meaningful saved text enters the roster", () => {
|
|
22
|
+
const { store, reload } = fixture();
|
|
23
|
+
const first = store.create();
|
|
24
|
+
store.edit(first, " \n\t");
|
|
25
|
+
store.save(first);
|
|
26
|
+
assert.deepEqual(store.list(), []);
|
|
27
|
+
const second = store.create();
|
|
28
|
+
assert.notEqual(first, second);
|
|
29
|
+
store.edit(second, " Exact text\nwith λ ");
|
|
30
|
+
store.save(second);
|
|
31
|
+
assert.deepEqual(store.list().map(record => record.text), [" Exact text\nwith λ "]);
|
|
32
|
+
const restored = reload();
|
|
33
|
+
assert.equal(restored.activeId, second);
|
|
34
|
+
assert.equal(restored.get(second).text, " Exact text\nwith λ ");
|
|
35
|
+
assert.equal(restored.get(first), null);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("revisions detect edits back to original and returned records cannot mutate ownership", () => {
|
|
39
|
+
const { store } = fixture();
|
|
40
|
+
const id = store.create();
|
|
41
|
+
store.edit(id, "original");
|
|
42
|
+
const captured = store.get(id);
|
|
43
|
+
store.edit(id, "edit");
|
|
44
|
+
store.edit(id, "original");
|
|
45
|
+
assert.ok(store.get(id).revision > captured.revision);
|
|
46
|
+
captured.text = "external";
|
|
47
|
+
assert.equal(store.get(id).text, "original");
|
|
48
|
+
assert.equal(store.select("server-tab"), false);
|
|
49
|
+
assert.equal(store.edit("server-tab", "invalid"), false);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("saved draft edits persist, close discards only one identity, blank selection survives reload", () => {
|
|
53
|
+
const { store, reload } = fixture();
|
|
54
|
+
const first = store.create();
|
|
55
|
+
store.edit(first, "first");
|
|
56
|
+
store.save(first);
|
|
57
|
+
const second = store.create();
|
|
58
|
+
store.edit(second, "second");
|
|
59
|
+
store.save(second);
|
|
60
|
+
store.select(first);
|
|
61
|
+
store.edit(first, "updated");
|
|
62
|
+
assert.equal(reload().get(first).text, "updated");
|
|
63
|
+
store.remove(first);
|
|
64
|
+
assert.deepEqual(reload().list().map(record => record.id), [second]);
|
|
65
|
+
store.select(store.create());
|
|
66
|
+
assert.ok(reload().activeId);
|
|
67
|
+
store.select(null);
|
|
68
|
+
assert.equal(reload().activeId, null);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test("denied writes retain all edits in memory and expose failure until recovery", () => {
|
|
72
|
+
const f = fixture();
|
|
73
|
+
const id = f.store.create();
|
|
74
|
+
f.store.edit(id, "saved");
|
|
75
|
+
f.store.save(id);
|
|
76
|
+
const previous = f.raw();
|
|
77
|
+
f.block(true);
|
|
78
|
+
f.store.edit(id, "newer memory edit");
|
|
79
|
+
assert.match(f.store.error, /could not be saved.*Storage denied/);
|
|
80
|
+
assert.equal(f.store.get(id).text, "newer memory edit");
|
|
81
|
+
assert.equal(f.raw(), previous);
|
|
82
|
+
f.block(false);
|
|
83
|
+
assert.equal(f.store.persist(), true);
|
|
84
|
+
assert.equal(f.reload().get(id).text, "newer memory edit");
|
|
85
|
+
assert.equal(f.store.error, "");
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test("denied reads retain new memory drafts and report storage failure", () => {
|
|
89
|
+
const store = createDraftConversations({ storage: () => { throw new Error("Storage disabled"); }, randomId: () => "new" });
|
|
90
|
+
const id = store.create();
|
|
91
|
+
store.edit(id, "memory");
|
|
92
|
+
assert.equal(store.save(id), false);
|
|
93
|
+
assert.equal(store.get(id).text, "memory");
|
|
94
|
+
assert.match(store.error, /could not be loaded.*Storage disabled/);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
for (const raw of ["{broken", JSON.stringify({ version: 2, records: [], activeId: null }), JSON.stringify({ version: 1, records: [{ id: "backend-tab", text: "hello" }], activeId: null })]) {
|
|
98
|
+
test(`unreadable data remains untouched: ${raw.slice(0, 30)}`, () => {
|
|
99
|
+
const f = fixture(raw);
|
|
100
|
+
assert.match(f.store.error, /could not be loaded/);
|
|
101
|
+
const id = f.store.create();
|
|
102
|
+
f.store.edit(id, "new draft");
|
|
103
|
+
f.store.save(id);
|
|
104
|
+
assert.equal(f.raw(), raw);
|
|
105
|
+
assert.equal(f.store.get(id).text, "new draft");
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
test("oversized edits stay in memory without truncation or replacing stored drafts", () => {
|
|
110
|
+
const f = fixture();
|
|
111
|
+
const id = f.store.create();
|
|
112
|
+
f.store.edit(id, "stored");
|
|
113
|
+
f.store.save(id);
|
|
114
|
+
const previous = f.raw();
|
|
115
|
+
const oversized = "x".repeat(DRAFT_LIMITS.text + 1);
|
|
116
|
+
f.store.edit(id, oversized);
|
|
117
|
+
assert.equal(f.store.get(id).text, oversized);
|
|
118
|
+
assert.equal(f.raw(), previous);
|
|
119
|
+
assert.match(f.store.error, /storage limit/);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test("record count and total size limits preserve the last stored value and all in-memory drafts", () => {
|
|
123
|
+
const f = fixture();
|
|
124
|
+
for (let index = 0; index < DRAFT_LIMITS.records; index += 1) {
|
|
125
|
+
const id = f.store.create();
|
|
126
|
+
f.store.edit(id, `Draft ${index}`);
|
|
127
|
+
assert.equal(f.store.save(id), true);
|
|
128
|
+
}
|
|
129
|
+
const previous = f.raw();
|
|
130
|
+
const extra = f.store.create();
|
|
131
|
+
f.store.edit(extra, "One more draft");
|
|
132
|
+
assert.equal(f.store.save(extra), false);
|
|
133
|
+
assert.equal(f.raw(), previous);
|
|
134
|
+
assert.equal(f.store.list().length, DRAFT_LIMITS.records + 1);
|
|
135
|
+
f.store.remove(extra);
|
|
136
|
+
for (const record of f.store.list().slice(0, 11)) f.store.edit(record.id, "x".repeat(DRAFT_LIMITS.text));
|
|
137
|
+
assert.match(f.store.error, /storage limit/);
|
|
138
|
+
assert.equal(f.store.list().filter(record => record.text.length === DRAFT_LIMITS.text).length, 11);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("invalid revisions, duplicate identities and invalid selections preserve unreadable storage", () => {
|
|
142
|
+
const record = { id: "draft:example", text: "saved", revision: 1, updatedAt: 100 };
|
|
143
|
+
for (const value of [
|
|
144
|
+
{ version: 1, activeId: null, records: [record, record] },
|
|
145
|
+
{ version: 1, activeId: "draft:missing", records: [record] },
|
|
146
|
+
{ version: 1, activeId: null, records: [{ ...record, revision: -1 }] },
|
|
147
|
+
{ version: 1, activeId: null, records: [{ ...record, updatedAt: 1.5 }] },
|
|
148
|
+
{ version: 1, activeId: null, records: [{ ...record, text: "" }] },
|
|
149
|
+
{ version: 1, activeId: null, records: Array.from({ length: DRAFT_LIMITS.records + 1 }, (_, index) => ({ ...record, id: `draft:${index}` })) },
|
|
150
|
+
]) {
|
|
151
|
+
const raw = JSON.stringify(value);
|
|
152
|
+
const f = fixture(raw);
|
|
153
|
+
assert.match(f.store.error, /could not be loaded/);
|
|
154
|
+
assert.equal(f.store.persist(), false);
|
|
155
|
+
assert.equal(f.raw(), raw);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test("optional workspace survives saved draft navigation and version-1 reload without saving blanks", () => {
|
|
160
|
+
const f = fixture();
|
|
161
|
+
const blank = f.store.create();
|
|
162
|
+
assert.equal(f.store.setCwd(blank, "/tmp/blank workspace"), true);
|
|
163
|
+
assert.equal(f.store.save(blank), true);
|
|
164
|
+
assert.deepEqual(f.store.list(), []);
|
|
165
|
+
assert.deepEqual(JSON.parse(f.raw()).records, []);
|
|
166
|
+
f.store.edit(blank, "Text with a workspace");
|
|
167
|
+
f.store.save(blank);
|
|
168
|
+
const revision = f.store.get(blank).revision;
|
|
169
|
+
f.store.setCwd(blank, "/tmp/updated workspace");
|
|
170
|
+
assert.ok(f.store.get(blank).revision > revision);
|
|
171
|
+
f.store.select(f.store.create());
|
|
172
|
+
const restored = f.reload();
|
|
173
|
+
restored.select(blank);
|
|
174
|
+
assert.equal(restored.get(blank).text, "Text with a workspace");
|
|
175
|
+
assert.equal(restored.get(blank).cwd, "/tmp/updated workspace");
|
|
176
|
+
const copy = restored.get(blank);
|
|
177
|
+
copy.cwd = "/external";
|
|
178
|
+
assert.equal(restored.get(blank).cwd, "/tmp/updated workspace");
|
|
179
|
+
const beforeClear = restored.get(blank).revision;
|
|
180
|
+
assert.equal(restored.setCwd(blank, ""), true);
|
|
181
|
+
assert.equal(restored.get(blank).cwd, undefined, "clearing removes the folder so the draft starts a No Project thread");
|
|
182
|
+
assert.equal(Object.hasOwn(restored.get(blank), "cwd"), false);
|
|
183
|
+
assert.equal(restored.get(blank).revision, beforeClear + 1);
|
|
184
|
+
restored.setCwd(blank, "");
|
|
185
|
+
assert.equal(restored.get(blank).revision, beforeClear + 1, "clearing an unset folder is not an edit");
|
|
186
|
+
assert.equal(f.reload().get(blank).cwd, undefined);
|
|
187
|
+
assert.equal(Object.hasOwn(JSON.parse(f.raw()).records.find(record => record.id === blank), "cwd"), false);
|
|
188
|
+
assert.equal(restored.setCwd("draft:missing", "/tmp/valid"), false);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test("old version-1 drafts remain readable and invalid workspace metadata never replaces storage", () => {
|
|
192
|
+
const record = { id: "draft:legacy", text: "Legacy text", revision: 1, updatedAt: 100 };
|
|
193
|
+
const legacy = fixture(JSON.stringify({ version: 1, records: [record], activeId: record.id }));
|
|
194
|
+
assert.equal(legacy.store.error, "");
|
|
195
|
+
assert.equal(legacy.store.get(record.id).cwd, undefined);
|
|
196
|
+
for (const cwd of [null, 123, "x".repeat(DRAFT_LIMITS.cwd + 1), "/tmp/\u0000bad"]) {
|
|
197
|
+
const raw = JSON.stringify({ version: 1, records: [{ ...record, cwd }], activeId: record.id });
|
|
198
|
+
const f = fixture(raw);
|
|
199
|
+
assert.match(f.store.error, /could not be loaded/);
|
|
200
|
+
assert.equal(f.store.persist(), false);
|
|
201
|
+
assert.equal(f.raw(), raw);
|
|
202
|
+
assert.throws(() => legacy.store.setCwd(record.id, cwd), /invalid or too long/);
|
|
203
|
+
assert.equal(legacy.store.get(record.id).cwd, undefined);
|
|
204
|
+
}
|
|
205
|
+
});
|