@firstpick/pi-package-webui 0.11.1 → 0.11.3
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 +322 -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/action-feedback-gutter.spec.mjs +251 -0
- 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
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { stripVTControlCharacters } from "node:util";
|
|
4
|
+
import * as adapter from "../lib/server/codex-fast-mode.mjs";
|
|
5
|
+
|
|
6
|
+
const packageName = "@fixture/codex-fast-mode";
|
|
7
|
+
const eligibleModel = { provider: "openai-codex", api: "openai-codex-responses", id: "gpt-6-astra" };
|
|
8
|
+
const serviceFunctions = [
|
|
9
|
+
"codexFastModeCommandBaseName", "codexFastModeStatusState", "codexFastModeSnapshot",
|
|
10
|
+
"resetCodexFastMode", "codexFastModePackageStatus", "codexFastModeCommandState",
|
|
11
|
+
"codexFastModeFeatureData", "waitForCodexFastModeStatus", "setCodexFastMode",
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
function fixture(t) {
|
|
15
|
+
const calls = { packages: [], commands: [], states: [], busy: [], statuses: [], prompts: [], sleeps: [] };
|
|
16
|
+
const tab = { id: "speed-tab", extensionStatuses: new Map(), lastState: {}, busy: false };
|
|
17
|
+
const f = {
|
|
18
|
+
tab,
|
|
19
|
+
calls,
|
|
20
|
+
now: 1_000,
|
|
21
|
+
packageStatus: { featureId: "codexFastMode", packageName, installed: true },
|
|
22
|
+
commandData: { commands: [{ name: "fast-mode:7" }], rpcRunning: true },
|
|
23
|
+
state: { model: { ...eligibleModel } },
|
|
24
|
+
send: async () => ({ success: true }),
|
|
25
|
+
onSleep: async () => {},
|
|
26
|
+
};
|
|
27
|
+
t.mock.method(Date, "now", () => f.now);
|
|
28
|
+
tab.rpc = {
|
|
29
|
+
send: async (command, timeoutMs) => {
|
|
30
|
+
calls.prompts.push({ command, timeoutMs });
|
|
31
|
+
return f.send(command);
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
f.dependencies = {
|
|
35
|
+
packageName,
|
|
36
|
+
optionalFeaturePackageStatus: async (featureId) => {
|
|
37
|
+
calls.packages.push(featureId);
|
|
38
|
+
if (f.packageError) throw f.packageError;
|
|
39
|
+
return f.packageStatus;
|
|
40
|
+
},
|
|
41
|
+
getCommandData: async (target, options) => {
|
|
42
|
+
calls.commands.push({ target, options });
|
|
43
|
+
if (f.commandError) throw f.commandError;
|
|
44
|
+
return f.commandData;
|
|
45
|
+
},
|
|
46
|
+
currentSessionState: async (target) => {
|
|
47
|
+
calls.states.push(target);
|
|
48
|
+
if (f.stateError) throw f.stateError;
|
|
49
|
+
return f.state;
|
|
50
|
+
},
|
|
51
|
+
tabHasActiveOutput: (target) => {
|
|
52
|
+
calls.busy.push(target);
|
|
53
|
+
return target.busy;
|
|
54
|
+
},
|
|
55
|
+
extensionStatusMap: (target) => {
|
|
56
|
+
calls.statuses.push(target);
|
|
57
|
+
return target.extensionStatuses;
|
|
58
|
+
},
|
|
59
|
+
stripAnsi: stripVTControlCharacters,
|
|
60
|
+
makeHttpError: (statusCode, message) => Object.assign(new Error(message), { statusCode }),
|
|
61
|
+
sanitizeError: (error) => `sanitized: ${error.message}`,
|
|
62
|
+
sleepMs: async (ms) => {
|
|
63
|
+
calls.sleeps.push(ms);
|
|
64
|
+
assert.ok(calls.sleeps.length <= 40, "status polling must stop after its one-second deadline");
|
|
65
|
+
f.now += ms;
|
|
66
|
+
await f.onSleep();
|
|
67
|
+
},
|
|
68
|
+
requestTimeoutMs: 12_345,
|
|
69
|
+
};
|
|
70
|
+
f.service = adapter.createCodexFastModeService(f.dependencies);
|
|
71
|
+
return f;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function httpError(statusCode, message) {
|
|
75
|
+
return (error) => error.statusCode === statusCode && message.test(error.message);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
test("import and factory expose the fixed API without invoking dependencies", () => {
|
|
79
|
+
assert.deepEqual(Object.keys(adapter), ["createCodexFastModeService"]);
|
|
80
|
+
const unexpected = () => assert.fail("factory must not invoke dependencies");
|
|
81
|
+
const service = adapter.createCodexFastModeService({
|
|
82
|
+
packageName,
|
|
83
|
+
optionalFeaturePackageStatus: unexpected,
|
|
84
|
+
getCommandData: unexpected,
|
|
85
|
+
currentSessionState: unexpected,
|
|
86
|
+
tabHasActiveOutput: unexpected,
|
|
87
|
+
extensionStatusMap: unexpected,
|
|
88
|
+
stripAnsi: unexpected,
|
|
89
|
+
makeHttpError: unexpected,
|
|
90
|
+
sanitizeError: unexpected,
|
|
91
|
+
sleepMs: unexpected,
|
|
92
|
+
requestTimeoutMs: 12_345,
|
|
93
|
+
});
|
|
94
|
+
assert.deepEqual(Object.keys(service).sort(), [...serviceFunctions].sort());
|
|
95
|
+
for (const fn of Object.values(service)) assert.equal(typeof fn, "function");
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test("command suffixes and ANSI status normalize while non-status text stays unknown", (t) => {
|
|
99
|
+
const { service } = fixture(t);
|
|
100
|
+
for (const [input, expected] of [
|
|
101
|
+
[" FAST-MODE:12 ", "fast-mode"], ["fast-mode", "fast-mode"],
|
|
102
|
+
[undefined, ""], ["fast-mode:abc", "fast-mode:abc"],
|
|
103
|
+
["fast-mode:2:3", "fast-mode:2"], ["/fast-mode", "/fast-mode"],
|
|
104
|
+
]) assert.equal(service.codexFastModeCommandBaseName(input), expected);
|
|
105
|
+
for (const [input, mode] of [
|
|
106
|
+
[" OFF ", "normal"], ["\u001b[32mOn\u001b[0m", "fast"], [" UltraFast ", "ultrafast"],
|
|
107
|
+
["", null], ["enabled", null], ["Fast mode: on", null], ["on (busy)", null],
|
|
108
|
+
]) {
|
|
109
|
+
assert.deepEqual(service.codexFastModeStatusState(input), {
|
|
110
|
+
known: mode !== null, enabled: mode !== null && mode !== "normal", mode,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test("snapshots preserve remembered state, exact status and patch precedence on the tab", (t) => {
|
|
116
|
+
const { service, tab } = fixture(t);
|
|
117
|
+
const unknown = service.codexFastModeSnapshot(tab, { updatedAt: "fixed" });
|
|
118
|
+
assert.deepEqual(unknown, {
|
|
119
|
+
featureId: "codexFastMode", mode: null, enabled: false, statusKnown: false, updatedAt: "fixed",
|
|
120
|
+
});
|
|
121
|
+
assert.equal(tab.codexFastMode, undefined, "snapshot reads must not store a separate record");
|
|
122
|
+
tab.codexFastMode = { ...unknown, mode: "fast", enabled: true, statusKnown: true };
|
|
123
|
+
tab.extensionStatuses.set("codex-fast-mode", "not a status");
|
|
124
|
+
assert.equal(service.codexFastModeSnapshot(tab).mode, "fast");
|
|
125
|
+
assert.equal(service.codexFastModeSnapshot(tab).statusKnown, true);
|
|
126
|
+
tab.extensionStatuses.set("codex-fast-mode", "off");
|
|
127
|
+
assert.equal(service.codexFastModeSnapshot(tab).mode, "normal");
|
|
128
|
+
assert.deepEqual(service.codexFastModeSnapshot(tab, { mode: "ultrafast", statusKnown: false, updatedAt: "patch" }), {
|
|
129
|
+
featureId: "codexFastMode", mode: "ultrafast", enabled: true, statusKnown: false, updatedAt: "patch",
|
|
130
|
+
});
|
|
131
|
+
tab.codexFastModeCommandName = "fast-mode:7";
|
|
132
|
+
service.resetCodexFastMode(tab);
|
|
133
|
+
service.resetCodexFastMode(null);
|
|
134
|
+
assert.equal(tab.codexFastMode, null);
|
|
135
|
+
assert.equal(tab.codexFastModeCommandName, "");
|
|
136
|
+
assert.equal(tab.extensionStatuses.get("codex-fast-mode"), "off", "status lifecycle remains caller-owned");
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test("package probes preserve results and sanitize failures using the injected catalog name", async (t) => {
|
|
140
|
+
const f = fixture(t);
|
|
141
|
+
assert.equal(await f.service.codexFastModePackageStatus(), f.packageStatus);
|
|
142
|
+
f.packageError = new Error("package probe failed");
|
|
143
|
+
assert.deepEqual(await f.service.codexFastModePackageStatus(), {
|
|
144
|
+
featureId: "codexFastMode", packageName, installed: false, error: "sanitized: package probe failed",
|
|
145
|
+
});
|
|
146
|
+
assert.deepEqual(f.calls.packages, ["codexFastMode", "codexFastMode"]);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test("command discovery caches the original suffixed name and exposes RPC failures", async (t) => {
|
|
150
|
+
const f = fixture(t);
|
|
151
|
+
f.commandData = {
|
|
152
|
+
commands: [{ name: "fast-mode-extra" }, { name: " FAST-MODE:12 " }, { name: "fast-mode" }],
|
|
153
|
+
rpcRunning: false, error: "RPC stopped",
|
|
154
|
+
};
|
|
155
|
+
assert.deepEqual(await f.service.codexFastModeCommandState(f.tab), {
|
|
156
|
+
commandName: " FAST-MODE:12 ", rpcRunning: false, error: "RPC stopped",
|
|
157
|
+
});
|
|
158
|
+
assert.deepEqual(f.calls.commands, [{ target: f.tab, options: { annotateSkills: false } }]);
|
|
159
|
+
assert.deepEqual(await f.service.codexFastModeCommandState(f.tab, { refreshCommands: false }), {
|
|
160
|
+
commandName: " FAST-MODE:12 ", rpcRunning: true, error: "",
|
|
161
|
+
});
|
|
162
|
+
assert.equal(f.calls.commands.length, 1);
|
|
163
|
+
f.commandError = new Error("command lookup failed");
|
|
164
|
+
assert.deepEqual(await f.service.codexFastModeCommandState(f.tab), {
|
|
165
|
+
commandName: "", rpcRunning: false, error: "sanitized: command lookup failed",
|
|
166
|
+
});
|
|
167
|
+
assert.equal(f.tab.codexFastModeCommandName, "");
|
|
168
|
+
delete f.commandError;
|
|
169
|
+
f.commandData = {};
|
|
170
|
+
assert.deepEqual(await f.service.codexFastModeCommandState(f.tab), {
|
|
171
|
+
commandName: "", rpcRunning: true, error: "",
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test("feature payload distinguishes loaded command availability from package installation", async (t) => {
|
|
176
|
+
const f = fixture(t);
|
|
177
|
+
f.packageStatus.installed = false;
|
|
178
|
+
f.tab.extensionStatuses.set("codex-fast-mode", "ultrafast");
|
|
179
|
+
const data = await f.service.codexFastModeFeatureData(f.tab);
|
|
180
|
+
const { updatedAt } = f.tab.codexFastMode;
|
|
181
|
+
assert.ok(Number.isFinite(Date.parse(updatedAt)));
|
|
182
|
+
assert.deepEqual(data, {
|
|
183
|
+
featureId: "codexFastMode", packageName, available: true, packageInstalled: false,
|
|
184
|
+
packageStatus: f.packageStatus, commandName: "fast-mode:7", enabled: true, mode: "ultrafast",
|
|
185
|
+
statusKnown: true, busy: false, model: eligibleModel, modelEligible: true,
|
|
186
|
+
ultrafastModelEligible: true,
|
|
187
|
+
creditNotice: "Fast mode increases Codex usage; current rates depend on the model and billing plan. Ultrafast requires GPT-6 Astra and Pro $500 or eligible Enterprise/Edu access, using 8x Standard included usage or 6x purchased-credit/pay-as-you-go usage. Workspace terms may differ. Only subscription-backed openai-codex requests are changed; upstream eligibility stays authoritative.",
|
|
188
|
+
rpcRunning: true, unavailableReason: "", error: undefined,
|
|
189
|
+
});
|
|
190
|
+
assert.deepEqual(f.tab.codexFastMode, {
|
|
191
|
+
featureId: "codexFastMode", mode: "ultrafast", enabled: true, statusKnown: true, updatedAt,
|
|
192
|
+
});
|
|
193
|
+
f.commandData.commands = [];
|
|
194
|
+
let unavailable = await f.service.codexFastModeFeatureData(f.tab);
|
|
195
|
+
assert.equal(unavailable.available, false);
|
|
196
|
+
assert.match(unavailable.unavailableReason, /not installed or not visible/);
|
|
197
|
+
f.packageStatus.installed = true;
|
|
198
|
+
unavailable = await f.service.codexFastModeFeatureData(f.tab);
|
|
199
|
+
assert.equal(unavailable.packageInstalled, true);
|
|
200
|
+
assert.equal(unavailable.available, false);
|
|
201
|
+
assert.match(unavailable.unavailableReason, /installed, but \/fast-mode is not loaded/);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test("feature reads expose busy state, fall back to lastState and preserve exact model eligibility", async (t) => {
|
|
205
|
+
const f = fixture(t);
|
|
206
|
+
f.stateError = new Error("state unavailable");
|
|
207
|
+
f.tab.busy = true;
|
|
208
|
+
f.tab.lastState.model = { ...eligibleModel };
|
|
209
|
+
assert.equal((await f.service.codexFastModeFeatureData(f.tab)).ultrafastModelEligible, true);
|
|
210
|
+
assert.equal((await f.service.codexFastModeFeatureData(f.tab)).busy, true);
|
|
211
|
+
delete f.stateError;
|
|
212
|
+
for (const [model, modelEligible, ultrafastModelEligible] of [
|
|
213
|
+
[{ ...eligibleModel, provider: "openai" }, false, false],
|
|
214
|
+
[{ ...eligibleModel, api: "openai-responses" }, true, false],
|
|
215
|
+
[{ ...eligibleModel, id: "gpt-6-sol" }, true, false],
|
|
216
|
+
[{ ...eligibleModel, id: "GPT-6-ASTRA" }, true, false],
|
|
217
|
+
[{ ...eligibleModel, api: undefined }, true, false],
|
|
218
|
+
[{ provider: "openai-codex" }, false, false],
|
|
219
|
+
[null, false, false],
|
|
220
|
+
]) {
|
|
221
|
+
f.state = { model };
|
|
222
|
+
const data = await f.service.codexFastModeFeatureData(f.tab);
|
|
223
|
+
assert.equal(data.modelEligible, modelEligible);
|
|
224
|
+
assert.equal(data.ultrafastModelEligible, ultrafastModelEligible);
|
|
225
|
+
assert.deepEqual(data.model, model?.provider && model?.id ? { ...model, api: model.api || "" } : null);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test("a successful prompt waits for delayed exact status instead of acknowledging the request", async (t) => {
|
|
230
|
+
const f = fixture(t);
|
|
231
|
+
f.tab.extensionStatuses.set("codex-fast-mode", "off");
|
|
232
|
+
let settled = false;
|
|
233
|
+
f.onSleep = async () => {
|
|
234
|
+
assert.equal(settled, false);
|
|
235
|
+
assert.equal(f.tab.codexFastMode.mode, "normal", "RPC acknowledgment must not update mode");
|
|
236
|
+
if (f.calls.sleeps.length === 1) f.tab.extensionStatuses.set("codex-fast-mode", "on (busy)");
|
|
237
|
+
if (f.calls.sleeps.length === 2) f.tab.extensionStatuses.set("codex-fast-mode", "\u001b[32mON\u001b[0m");
|
|
238
|
+
};
|
|
239
|
+
const data = await f.service.setCodexFastMode(f.tab, { mode: "fast" }).then((value) => {
|
|
240
|
+
settled = true;
|
|
241
|
+
return value;
|
|
242
|
+
});
|
|
243
|
+
assert.equal(data.mode, "fast");
|
|
244
|
+
assert.equal(data.enabled, true);
|
|
245
|
+
assert.equal(data.statusKnown, true);
|
|
246
|
+
assert.equal(data.requested, "fast");
|
|
247
|
+
assert.deepEqual(f.calls.sleeps, [25, 25]);
|
|
248
|
+
assert.deepEqual(f.calls.prompts, [{ command: { type: "prompt", message: "/fast-mode:7 on" }, timeoutMs: 12_345 }]);
|
|
249
|
+
assert.equal(f.calls.commands.length, 1, "response reuses the tab's loaded command");
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
test("status timeout rejects RPC success and retains the last confirmed preference", async (t) => {
|
|
253
|
+
for (const [mode, originalStatus, label] of [["normal", "on", "off"], ["fast", "off", "on"], ["ultrafast", "on", "ultrafast"]]) {
|
|
254
|
+
const f = fixture(t);
|
|
255
|
+
f.tab.extensionStatuses.set("codex-fast-mode", originalStatus);
|
|
256
|
+
await assert.rejects(f.service.setCodexFastMode(f.tab, { mode }), httpError(409, new RegExp(`did not confirm ${label}\\.`)));
|
|
257
|
+
assert.equal(f.now, 2_000);
|
|
258
|
+
assert.equal(f.calls.sleeps.length, 40);
|
|
259
|
+
assert.equal(f.calls.prompts.length, 1);
|
|
260
|
+
assert.equal(f.tab.codexFastMode.mode, originalStatus === "on" ? "fast" : "normal");
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
test("busy, unavailable and Ultrafast model guards reject before sending prompts", async (t) => {
|
|
265
|
+
const f = fixture(t);
|
|
266
|
+
f.tab.busy = true;
|
|
267
|
+
await assert.rejects(f.service.setCodexFastMode(f.tab, { mode: "normal" }), httpError(409, /This tab is busy/));
|
|
268
|
+
f.tab.busy = false;
|
|
269
|
+
f.commandData.commands = [];
|
|
270
|
+
await assert.rejects(f.service.setCodexFastMode(f.tab, { mode: "fast" }), httpError(404, /installed, but/));
|
|
271
|
+
f.packageStatus.installed = false;
|
|
272
|
+
await assert.rejects(f.service.setCodexFastMode(f.tab, { mode: "fast" }), httpError(404, /not installed/));
|
|
273
|
+
f.commandData.commands = [{ name: "fast-mode" }];
|
|
274
|
+
for (const model of [
|
|
275
|
+
{ ...eligibleModel, provider: "openai" }, { ...eligibleModel, api: "openai-responses" },
|
|
276
|
+
{ ...eligibleModel, id: "gpt-6-sol" }, null,
|
|
277
|
+
]) {
|
|
278
|
+
f.state = { model };
|
|
279
|
+
await assert.rejects(f.service.setCodexFastMode(f.tab, { mode: "ultrafast" }), httpError(400, /Select GPT-6 Astra/));
|
|
280
|
+
}
|
|
281
|
+
assert.deepEqual(f.calls.prompts, []);
|
|
282
|
+
assert.deepEqual(f.calls.sleeps, []);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
test("invalid or conflicting intent rejects before probing package, commands or state", async (t) => {
|
|
286
|
+
const f = fixture(t);
|
|
287
|
+
for (const body of [undefined, {}, null, { enabled: "true" }, { mode: "turbo" }, { mode: "fast", enabled: false }, { mode: "normal", enabled: true }]) {
|
|
288
|
+
await assert.rejects(f.service.setCodexFastMode(f.tab, body), httpError(400, /Codex speed/));
|
|
289
|
+
}
|
|
290
|
+
for (const calls of Object.values(f.calls)) assert.deepEqual(calls, []);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
test("prompt failure preserves HTTP errors and thrown transport errors without polling", async (t) => {
|
|
294
|
+
const f = fixture(t);
|
|
295
|
+
f.send = async () => ({ success: false, error: "extension refused" });
|
|
296
|
+
await assert.rejects(f.service.setCodexFastMode(f.tab, { mode: "fast" }), httpError(400, /^extension refused$/));
|
|
297
|
+
f.send = async () => ({ success: false });
|
|
298
|
+
await assert.rejects(f.service.setCodexFastMode(f.tab, { mode: "normal" }), httpError(400, /^Failed to select Codex speed normal$/));
|
|
299
|
+
const transportError = new Error("RPC deadline exceeded");
|
|
300
|
+
f.send = async () => { throw transportError; };
|
|
301
|
+
await assert.rejects(f.service.setCodexFastMode(f.tab, { mode: "fast" }), (error) => error === transportError);
|
|
302
|
+
assert.deepEqual(f.calls.sleeps, []);
|
|
303
|
+
assert.equal(f.tab.codexFastMode.mode, null);
|
|
304
|
+
assert.equal(f.tab.codexFastMode.statusKnown, false);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
test("legacy enabled writes retain boolean requested responses and explicit modes stay strings", async (t) => {
|
|
308
|
+
const f = fixture(t);
|
|
309
|
+
f.send = async (command) => {
|
|
310
|
+
f.tab.extensionStatuses.set("codex-fast-mode", command.message.split(" ").at(-1));
|
|
311
|
+
return { success: true };
|
|
312
|
+
};
|
|
313
|
+
// Normal/Fast preserve the extension's provider policy; only Ultrafast has a WebUI write guard.
|
|
314
|
+
f.state.model = { provider: "other", id: "other-model", api: "other-api" };
|
|
315
|
+
for (const [body, mode, argument, requested] of [
|
|
316
|
+
[{ enabled: true }, "fast", "on", true], [{ enabled: false }, "normal", "off", false],
|
|
317
|
+
[{ mode: "fast", enabled: true }, "fast", "on", "fast"],
|
|
318
|
+
]) {
|
|
319
|
+
const data = await f.service.setCodexFastMode(f.tab, body);
|
|
320
|
+
assert.equal(data.mode, mode);
|
|
321
|
+
assert.equal(data.enabled, mode !== "normal");
|
|
322
|
+
assert.equal(data.statusKnown, true);
|
|
323
|
+
assert.equal(data.requested, requested);
|
|
324
|
+
assert.equal(f.calls.prompts.at(-1).command.message, `/fast-mode:7 ${argument}`);
|
|
325
|
+
}
|
|
326
|
+
f.state.model = { ...eligibleModel };
|
|
327
|
+
assert.equal((await f.service.setCodexFastMode(f.tab, { mode: "ultrafast" })).requested, "ultrafast");
|
|
328
|
+
assert.equal(f.calls.prompts.at(-1).command.message, "/fast-mode:7 ultrafast");
|
|
329
|
+
assert.deepEqual(f.calls.sleeps, []);
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
test("multiple adapters share only the supplied tab records and keep other tabs isolated", async (t) => {
|
|
333
|
+
const f = fixture(t);
|
|
334
|
+
const second = adapter.createCodexFastModeService(f.dependencies);
|
|
335
|
+
const other = { id: "other", extensionStatuses: new Map([["codex-fast-mode", "off"]]), busy: false };
|
|
336
|
+
f.tab.extensionStatuses.set("codex-fast-mode", "on");
|
|
337
|
+
await f.service.codexFastModeFeatureData(f.tab);
|
|
338
|
+
assert.equal(second.codexFastModeSnapshot(f.tab).mode, "fast");
|
|
339
|
+
assert.equal(second.codexFastModeSnapshot(other).mode, "normal");
|
|
340
|
+
assert.equal(other.codexFastMode, undefined);
|
|
341
|
+
assert.equal(other.codexFastModeCommandName, undefined);
|
|
342
|
+
assert.equal((await second.codexFastModeCommandState(f.tab, { refreshCommands: false })).commandName, "fast-mode:7");
|
|
343
|
+
second.resetCodexFastMode(f.tab);
|
|
344
|
+
assert.equal((await f.service.codexFastModeCommandState(f.tab, { refreshCommands: false })).commandName, "");
|
|
345
|
+
assert.equal(second.codexFastModeSnapshot(other).mode, "normal");
|
|
346
|
+
});
|