@firstpick/pi-package-webui 0.11.0 → 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 +181 -12
- package/README.md +41 -9
- package/TECHNICAL.md +91 -8
- package/bin/pi-webui.mjs +5432 -11428
- package/index.ts +10 -3
- package/lib/codex-cli-usage.mjs +232 -0
- package/lib/codex-usage-auth.mjs +39 -3
- package/lib/codex-usage-source.mjs +36 -0
- 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 +5 -5
- 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 -3878
- 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/theme-contract.mjs +1 -1
- 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-cli-usage.test.mjs +189 -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-auth.test.mjs +168 -9
- package/tests/codex-usage-http.test.mjs +124 -0
- package/tests/codex-usage-source.test.mjs +146 -0
- 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-codex-app-server.mjs +61 -0
- 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 +29 -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-contract.test.mjs +10 -3
- 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,66 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import test from "node:test";
|
|
4
|
+
import vm from "node:vm";
|
|
5
|
+
|
|
6
|
+
const server = await readFile(new URL("../bin/pi-webui.mjs", import.meta.url), "utf8");
|
|
7
|
+
const source = server.match(/^async function handleGitWorkflowRequest\([^\n]*\n[\s\S]*?^}/m)?.[0];
|
|
8
|
+
assert.ok(source, "the route adapter must remain inspectable");
|
|
9
|
+
|
|
10
|
+
function dispatcher(dependencies) {
|
|
11
|
+
return vm.runInNewContext(`(${source})`, {
|
|
12
|
+
options: { cwd: "/default" },
|
|
13
|
+
sanitizeError: (error) => error.message,
|
|
14
|
+
...dependencies,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
for (const [route, method, receivesBody] of [
|
|
19
|
+
["init", "initializeGitRepository", false],
|
|
20
|
+
["initial-commit", "initialGitCommit", false],
|
|
21
|
+
["main-branch", "renameGitMainBranch", false],
|
|
22
|
+
["remote", "addGitOrigin", true],
|
|
23
|
+
["init-push", "pushInitialGitMain", false],
|
|
24
|
+
["commit", "commitGitWorkflow", true],
|
|
25
|
+
["push", "pushGitWorkflow", true],
|
|
26
|
+
["publish", "publishGitRepository", true],
|
|
27
|
+
["create-pr", "createGitWorkflowPr", true],
|
|
28
|
+
]) {
|
|
29
|
+
test(`${route} retains the workflow envelope across an asynchronous service boundary`, async () => {
|
|
30
|
+
const body = { confirmed: true, expectedStagedContentHash: "approved" };
|
|
31
|
+
const tab = { id: "origin", cwd: "/origin" };
|
|
32
|
+
const payload = { ok: true, data: { marker: route } };
|
|
33
|
+
let reject = false;
|
|
34
|
+
const dispatch = dispatcher({
|
|
35
|
+
[method]: async (...args) => {
|
|
36
|
+
assert.deepEqual(args, receivesBody ? [tab.cwd, body] : [tab.cwd]);
|
|
37
|
+
await Promise.resolve();
|
|
38
|
+
if (reject) throw Object.assign(new Error("fixture validation refusal"), { status: 409 });
|
|
39
|
+
return payload;
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
assert.equal(await dispatch(`/api/git-workflow/${route}`, body, tab), payload);
|
|
43
|
+
reject = true;
|
|
44
|
+
const failure = await dispatch(`/api/git-workflow/${route}`, body, tab);
|
|
45
|
+
assert.equal(failure.ok, false);
|
|
46
|
+
assert.equal(failure.error, "fixture validation refusal");
|
|
47
|
+
assert.deepEqual(Object.keys(failure).sort(), ["error", "ok"]);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
test("cancel invokes both owners even when generation cancellation succeeds", async () => {
|
|
52
|
+
const tab = { id: "origin", cwd: "/origin" };
|
|
53
|
+
const calls = [];
|
|
54
|
+
const dispatch = dispatcher({
|
|
55
|
+
cancelGitWorkflowGeneration: (target) => {
|
|
56
|
+
assert.equal(target, tab);
|
|
57
|
+
calls.push("generation");
|
|
58
|
+
return true;
|
|
59
|
+
},
|
|
60
|
+
cancelGitWorkflowProcess: () => { calls.push("process"); return false; },
|
|
61
|
+
});
|
|
62
|
+
const result = await dispatch("/api/git-workflow/cancel", {}, tab);
|
|
63
|
+
assert.deepEqual(calls, ["generation", "process"]);
|
|
64
|
+
assert.equal(result.ok, true);
|
|
65
|
+
assert.equal(result.data.cancelled, true);
|
|
66
|
+
});
|
|
@@ -2,18 +2,26 @@ import assert from "node:assert/strict";
|
|
|
2
2
|
import { mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import * as compatibility from "../lib/git-workflow-preferences.mjs";
|
|
6
|
+
import * as preferenceValues from "../lib/git-workflow-preference-values.mjs";
|
|
5
7
|
import {
|
|
6
8
|
GIT_WORKFLOW_SETUP_VERSION,
|
|
7
9
|
gitWorkflowPreferencesSummary,
|
|
8
10
|
isGitWorkflowSetupComplete,
|
|
11
|
+
supportedGitWorkflowThinkingLevels,
|
|
12
|
+
} from "../lib/git-workflow-preference-values.mjs";
|
|
13
|
+
import {
|
|
9
14
|
normalizeInterfacePreferences,
|
|
10
15
|
readGitWorkflowPreferences,
|
|
11
16
|
readWebuiSettings,
|
|
12
|
-
supportedGitWorkflowThinkingLevels,
|
|
13
17
|
writeGitWorkflowPreferences,
|
|
14
18
|
writeWebuiSettings,
|
|
15
19
|
} from "../lib/git-workflow-preferences.mjs";
|
|
16
20
|
|
|
21
|
+
for (const [name, value] of Object.entries(preferenceValues)) {
|
|
22
|
+
assert.equal(compatibility[name], value, `${name} must retain its identity through the compatibility path`);
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
assert.deepEqual(supportedGitWorkflowThinkingLevels({ reasoning: false }), ["off"]);
|
|
18
26
|
assert.deepEqual(
|
|
19
27
|
supportedGitWorkflowThinkingLevels({ reasoning: true }),
|
|
@@ -4,6 +4,9 @@ import { readFile } from "node:fs/promises";
|
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
|
|
7
|
+
const gitGeneration = await readFile(new URL("../lib/server/git-generation.mjs", import.meta.url), "utf8");
|
|
8
|
+
const gitMutations = await readFile(new URL("../lib/server/git-mutations.mjs", import.meta.url), "utf8");
|
|
9
|
+
|
|
7
10
|
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
11
|
const [app, state, server, html, serviceWorker, readme, technical, development, fakePi] = await Promise.all([
|
|
9
12
|
readFile(join(root, "public", "app.js"), "utf8"),
|
|
@@ -71,27 +74,27 @@ test("native generation capabilities are extension-only and tab-local", () => {
|
|
|
71
74
|
});
|
|
72
75
|
|
|
73
76
|
test("server dispatch requires extension provenance and completes on a fresh native artifact", () => {
|
|
74
|
-
assert.match(
|
|
75
|
-
const dispatchStart =
|
|
76
|
-
const dispatchEnd =
|
|
77
|
+
assert.match(gitGeneration, /async function resolveGuidedGitNativeCommand[\s\S]*candidate\?\.source === "extension"[\s\S]*Same-named prompt templates are not used/u);
|
|
78
|
+
const dispatchStart = gitGeneration.indexOf("async function dispatchGitWorkflowGenerationAttempt");
|
|
79
|
+
const dispatchEnd = gitGeneration.indexOf("\n async function settleGitWorkflowGeneration", dispatchStart);
|
|
77
80
|
assert.notEqual(dispatchStart, -1);
|
|
78
81
|
assert.notEqual(dispatchEnd, -1);
|
|
79
|
-
const dispatch =
|
|
82
|
+
const dispatch = gitGeneration.slice(dispatchStart, dispatchEnd);
|
|
80
83
|
assert.match(dispatch, /record\.message = gitWorkflowGenerationPrompt\(record\.kind, record\.preferences, record\.nativeCommandName, profile\)/u);
|
|
81
|
-
assert.match(
|
|
84
|
+
assert.match(gitGeneration, /record\.primary = gitWorkflowGenerationProfile\(\s+preferences\.generation\.provider,\s+preferences\.generation\.modelId,\s+preferences\.generation\.thinkingLevel,/u, "generation records should retain the configured profile used by dispatch");
|
|
82
85
|
assert.doesNotMatch(dispatch, /set_model|set_thinking_level|setThinkingLevelForTab/u, "guided generation must not switch or restore the parent tab model or reasoning effort");
|
|
83
|
-
assert.match(
|
|
84
|
-
assert.match(
|
|
85
|
-
assert.match(
|
|
86
|
+
assert.match(gitGeneration, /function guidedGitNativeCommandErrorFromEvent[\s\S]*event\?\.type !== "extension_error"[\s\S]*event\.extensionPath !== `command:\$\{commandName\}`/u);
|
|
87
|
+
assert.match(gitGeneration, /if \(record\.nativeCommandError\) throw record\.nativeCommandError;[\s\S]*await assertGuidedGitNativeArtifactUpdated\(tab, record\);[\s\S]*finishGitWorkflowGeneration\(tab, record, \{ successful: true \}\)/u);
|
|
88
|
+
assert.match(gitMutations, /const target = path\.resolve\(base, `\$\{encodeURIComponent\(branch\)\}\.md`\)/u);
|
|
86
89
|
assert.match(development, /correlated `extension_error` event as the native command's terminal failure/u);
|
|
87
90
|
});
|
|
88
91
|
|
|
89
92
|
test("fixture, cache revisions, and layered docs expose the migration contract", () => {
|
|
90
93
|
assert.match(fakePi, /FAKE_PI_GUIDED_GIT_ACTIVATION/u);
|
|
91
94
|
assert.match(fakePi, /git-guided-workflow:webui-start/u);
|
|
92
|
-
assert.match(html, /styles\.css\?v=
|
|
93
|
-
assert.match(html, /app\.js\?v=
|
|
94
|
-
assert.match(serviceWorker, /pi-webui-pwa-
|
|
95
|
+
assert.match(html, /styles\.css\?v=167/u);
|
|
96
|
+
assert.match(html, /app\.js\?v=220/u);
|
|
97
|
+
assert.match(serviceWorker, /pi-webui-pwa-v200/u);
|
|
95
98
|
assert.match(serviceWorker, /"\/guided-git-command-state\.mjs"/u);
|
|
96
99
|
assert.match(readme, /pi-extension-git-guided-workflow/u);
|
|
97
100
|
assert.match(technical, /\/git-guided-workflow/u);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
+
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
5
6
|
|
|
7
|
+
const gitGeneration = await readFile(new URL("../lib/server/git-generation.mjs", import.meta.url), "utf8");
|
|
8
|
+
|
|
6
9
|
const testsDir = path.dirname(fileURLToPath(import.meta.url));
|
|
7
10
|
const packageDir = path.resolve(testsDir, "..");
|
|
8
11
|
const [app, server, html, serviceWorker, readme, technical, development] = await Promise.all([
|
|
@@ -33,7 +36,7 @@ assert.match(setup, /Guided Git setup saved\. Primary:[\s\S]*Fallback:/, "save c
|
|
|
33
36
|
|
|
34
37
|
const acceptedText = sourceBetween(app, "function gitWorkflowGenerationAcceptedText", "function gitWorkflowFallbackEventMatches", "immediate fallback copy");
|
|
35
38
|
assert.match(acceptedText, /fallbackUsed === true[\s\S]*primaryGeneration[\s\S]*continued with the fallback/, "immediate fallback responses should explain that primary failed and fallback continued");
|
|
36
|
-
assert.match(app, /gitWorkflowConfiguredGenerationText\(preferences\)[\s\S]*active
|
|
39
|
+
assert.match(app, /gitWorkflowConfiguredGenerationText\(preferences\)[\s\S]*active thread model and effort are restored/, "workflow startup should identify configured generation profiles and restoration");
|
|
37
40
|
|
|
38
41
|
const lifecycle = sourceBetween(app, "function gitWorkflowFallbackEventMatchesPendingRequest", "function formatGitCommandResult", "fallback lifecycle handler");
|
|
39
42
|
assert.match(lifecycle, /webui_git_workflow_generation_fallback_started/, "the browser should observe fallback start events");
|
|
@@ -43,9 +46,9 @@ assert.match(lifecycle, /pendingFallbackLifecycleEvents[\s\S]*slice\(-4\)/, "pre
|
|
|
43
46
|
assert.match(lifecycle, /flushPendingGitWorkflowFallbackLifecycleEvents[\s\S]*generationAccepted: true[\s\S]*flushPendingGitWorkflowFallbackLifecycleEvents\(tabId\)/, "buffered lifecycle events should flush only after response correlation");
|
|
44
47
|
assert.match(lifecycle, /generationId[\s\S]*workflow\.generationId/, "all lifecycle kinds should require the exact server generation ID");
|
|
45
48
|
assert.doesNotMatch(lifecycle, /\bapi\(|gitWorkflowRequest\(|fetch\(/, "browser lifecycle handling must never dispatch fallback or another request");
|
|
46
|
-
assert.match(
|
|
49
|
+
assert.match(gitGeneration, /lifecycle\.events = [\s\S]*\.slice\(-2\)/, "the server should retain a bounded per-tab lifecycle replay snapshot");
|
|
47
50
|
assert.match(server, /replayGitWorkflowFallbackLifecycle\(tab, client\)/, "EventSource reconnect should replay Guided Git lifecycle state");
|
|
48
|
-
assert.match(
|
|
51
|
+
assert.match(gitGeneration, /reason: boundedGitWorkflowGenerationError\("The primary Git-writing model ended with an error\."\)/, "lifecycle reason copy should be curated rather than exposing provider diagnostics");
|
|
49
52
|
assert.match(app, /handleGitWorkflowFallbackLifecycleEvent\(event\)\) return;[\s\S]*if \(!eventTargetsActiveTab\(event\)\)/, "tab-scoped fallback events should be handled before inactive-tab routing");
|
|
50
53
|
assert.match(app, /generationKind: "commit"[\s\S]*generationKind: "branch"[\s\S]*generationKind: "pr"/, "all three Guided Git generation kinds should register browser correlation state");
|
|
51
54
|
assert.match(app, /branch-name\$\{query\}[\s\S]*pr-description\$\{query\}/, "branch and PR artifact reads should send their exact generation IDs");
|
|
@@ -54,7 +57,7 @@ assert.match(readme, /fallback model and its own reasoning effort[\s\S]*tries th
|
|
|
54
57
|
assert.match(technical, /## Guided Git generation profiles[\s\S]*strict one-retry policy[\s\S]*active model and reasoning effort remain unchanged[\s\S]*dead Pi process cannot run the fallback/i, "technical reference should document configuration and operational limits");
|
|
55
58
|
assert.match(development, /### Fallback browser\/runtime contract[\s\S]*fallbackUsed: true[\s\S]*webui_git_workflow_generation_fallback_started[\s\S]*never sends a retry/, "development guide should preserve the response/event and browser ownership contract");
|
|
56
59
|
|
|
57
|
-
assert.match(html, /data-app-src="\/app\.js\?v=
|
|
58
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
60
|
+
assert.match(html, /data-app-src="\/app\.js\?v=220"/, "the changed browser app should use the next query revision");
|
|
61
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v200";/, "the PWA cache identity should advance with browser behavior");
|
|
59
62
|
|
|
60
63
|
console.log("guided-git-fallback-ui-static.test.mjs passed");
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
+
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
5
6
|
|
|
7
|
+
const gitGeneration = await readFile(new URL("../lib/server/git-generation.mjs", import.meta.url), "utf8");
|
|
8
|
+
const gitMutations = await readFile(new URL("../lib/server/git-mutations.mjs", import.meta.url), "utf8");
|
|
9
|
+
|
|
6
10
|
const testsDir = path.dirname(fileURLToPath(import.meta.url));
|
|
7
11
|
const packageDir = path.resolve(testsDir, "..");
|
|
8
12
|
const [app, server, artifacts] = await Promise.all([
|
|
@@ -11,13 +15,13 @@ const [app, server, artifacts] = await Promise.all([
|
|
|
11
15
|
readFile(path.join(packageDir, "lib", "git-message-artifacts.mjs"), "utf8"),
|
|
12
16
|
]);
|
|
13
17
|
|
|
14
|
-
assert.match(
|
|
15
|
-
assert.match(
|
|
16
|
-
assert.match(
|
|
17
|
-
assert.match(
|
|
18
|
+
assert.match(gitGeneration, /async function createGitWorkflowArtifactGeneration\(tab, generationId, kind\)[\s\S]*kind === "commit"[\s\S]*id: generationId[\s\S]*baseline: await readStableGitMessageArtifactPair\(commitMessagePaths\(cwd\)\)/, "commit generation must retain the shared server-owned ID and exact pre-primary baseline");
|
|
19
|
+
assert.match(gitMutations, /function gitWorkflowMessageCwd\(root, cwd\)[\s\S]*suppliedCwd !== repositoryRoot[\s\S]*return repositoryRoot;/, "commit and branch artifacts must resolve at repository root after validating a nested tab cwd");
|
|
20
|
+
assert.match(gitGeneration, /generationId: record\.generationId/, "generation dispatch must return one server-owned correlation ID across every kind and both attempts");
|
|
21
|
+
assert.match(gitGeneration, /tab\.gitWorkflowArtifactGeneration = record\.artifactGeneration/, "the artifact generation record must be owned by the originating tab");
|
|
18
22
|
assert.match(server, /case "\/api\/git-workflow\/message"[\s\S]*generationId[\s\S]*tab\?\.gitWorkflowArtifactGeneration/, "fresh message reads must resolve the correlated generation from the requested tab");
|
|
19
|
-
assert.match(
|
|
20
|
-
assert.match(
|
|
23
|
+
assert.match(gitMutations, /readGitWorkflowMessages\(cwd, \{ generationId = "", generation = null \} = \{\}\)[\s\S]*generation\.cwd !== messageCwd[\s\S]*!generation\.terminal[\s\S]*running: true[\s\S]*!generation\.successful/, "message readiness must reject wrong identity and terminal failure while identifying an active attempt");
|
|
24
|
+
assert.match(gitMutations, /gitMessageArtifactPairReadiness\(generation\.baseline, pair\)[\s\S]*GIT_WORKFLOW_MESSAGE_PAIR_SETTLE_MS[\s\S]*sameGitMessageArtifactPair\(pair, settledPair\)/, "the backend must require both changed artifacts and a stable settled pair");
|
|
21
25
|
assert.doesNotMatch(app, /newestMtime \+ 10000 < currentWorkflow\.messageRequestedAt/, "freshness must not use the previous wall-clock/mtime tolerance");
|
|
22
26
|
|
|
23
27
|
assert.match(app, /const gitWorkflowMessageLoadsByTab = new Map\(\)/, "browser message loading must have tab-scoped single-flight ownership");
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
|
|
4
|
+
const gitMutations = await readFile(new URL("../lib/server/git-mutations.mjs", import.meta.url), "utf8");
|
|
5
|
+
|
|
6
|
+
|
|
4
7
|
const server = await readFile(new URL("../bin/pi-webui.mjs", import.meta.url), "utf8");
|
|
5
8
|
|
|
6
9
|
assert.match(
|
|
7
|
-
|
|
10
|
+
gitMutations,
|
|
8
11
|
/if \(push && \/fatal:\\s\+no configured push destination\\\.\/\.test\(text\)\) \{\s*return \{ code: "NO_REMOTE", hint: NO_REMOTE_HINT \};/,
|
|
9
12
|
"only Git's explicit no-push-destination failure should receive NO_REMOTE classification",
|
|
10
13
|
);
|
|
11
14
|
assert.doesNotMatch(
|
|
12
|
-
|
|
15
|
+
gitMutations,
|
|
13
16
|
/does not appear to be a git repository[\s\S]{0,160}NO_REMOTE|NO_REMOTE[\s\S]{0,160}does not appear to be a git repository/,
|
|
14
17
|
"an invalid configured remote must not be reclassified as remote-less",
|
|
15
18
|
);
|
|
@@ -19,27 +22,29 @@ assert.match(
|
|
|
19
22
|
"publication must use the POST-only mutating workflow allowlist",
|
|
20
23
|
);
|
|
21
24
|
assert.match(
|
|
22
|
-
|
|
23
|
-
/
|
|
25
|
+
gitMutations,
|
|
26
|
+
/async function publishGitRepository\(cwd, body = \{\}\) \{[\s\S]*const root = await getGitRoot\(cwd\);[\s\S]*cleanGitHubRepoName\(path\.basename\(root\)\)[\s\S]*visibility !== "public" && visibility !== "private"[\s\S]*requireConfirmed\(body,[\s\S]*gitRemoteNames\(root\)[\s\S]*remotes\.length[\s\S]*currentGitBranch\(root\)/,
|
|
24
27
|
"the server must derive and validate the Git root directory name, validate visibility/confirmation, and refuse existing-remote repair before publication",
|
|
25
28
|
);
|
|
26
29
|
assert.doesNotMatch(
|
|
27
|
-
|
|
28
|
-
/
|
|
30
|
+
gitMutations,
|
|
31
|
+
/async function publishGitRepository\(cwd, body = \{\}\) \{[\s\S]*?cleanGitHubRepoName\(body\.repoName\)[\s\S]*?async function createGitWorkflowPr/,
|
|
29
32
|
"publication must not trust a client-selected repository name",
|
|
30
33
|
);
|
|
31
34
|
assert.match(
|
|
32
|
-
|
|
35
|
+
gitMutations,
|
|
33
36
|
/runGitHubWorkflowCommand\(\s*\["repo", "create", repoName, `--\$\{visibility\}`, "--source", "\.", "--remote", "origin", "--push"\],[\s\S]*\{ cwd: root, timeoutMs: 15 \* 60 \* 1000/,
|
|
34
37
|
"publication must run gh repo create from the Git root so system GitHub CLI configuration adds origin and pushes",
|
|
35
38
|
);
|
|
36
39
|
assert.match(
|
|
37
|
-
|
|
40
|
+
gitMutations,
|
|
38
41
|
/if \(payload\.ok\) Object\.assign\(payload\.data, \{ repoName, visibility, remote: "origin", branch, protectedBranch \}\);/,
|
|
39
42
|
"successful publication must extend the process envelope with the approved metadata",
|
|
40
43
|
);
|
|
41
|
-
assert.match(
|
|
42
|
-
assert.match(
|
|
43
|
-
assert.match(
|
|
44
|
+
assert.match(gitMutations, /payload\.code = "AUTH";[\s\S]*gh auth login/, "gh authentication failures should receive an actionable AUTH hint");
|
|
45
|
+
assert.match(gitMutations, /name already exists on this account\|repository \.\+ already exists[\s\S]*rename the local directory before retrying/, "name conflicts should explain how the directory-derived name can be changed");
|
|
46
|
+
assert.match(gitMutations, /GH_PROMPT_DISABLED: process\.env\.GH_PROMPT_DISABLED \|\| "1"/, "gh publication must inherit disabled interactive prompts");
|
|
47
|
+
|
|
48
|
+
assert.match(server, /case "\/api\/git-workflow\/publish":[\s\S]*return await publishGitRepository\(cwd, body\);/, "publication must dispatch the selected tab cwd and unchanged request to its service");
|
|
44
49
|
|
|
45
50
|
console.log("guided git publication backend static tests passed");
|
|
@@ -16,7 +16,13 @@ import { REQUIRED_THEME_TOKENS, serializeTheme } from "../public/theme-contract.
|
|
|
16
16
|
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
17
17
|
const serverScript = join(root, "bin", "pi-webui.mjs");
|
|
18
18
|
const fakePi = join(root, "tests", "fixtures", "fake-pi.mjs");
|
|
19
|
-
const
|
|
19
|
+
const portReservation = createServer();
|
|
20
|
+
await new Promise((resolve, reject) => {
|
|
21
|
+
portReservation.once("error", reject);
|
|
22
|
+
portReservation.listen(0, "0.0.0.0", resolve);
|
|
23
|
+
});
|
|
24
|
+
portReservation.unref();
|
|
25
|
+
const port = portReservation.address().port;
|
|
20
26
|
const optionalFeatureFocus = process.env.PI_WEBUI_OPTIONAL_FEATURES_FOCUS === "1";
|
|
21
27
|
|
|
22
28
|
function themeFixture(name, color = "#123456") {
|
|
@@ -37,12 +43,17 @@ function lanAddress() {
|
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
async function request(host, pathname, { method = "GET", body, headers = {}, timeoutMs = 5_000 } = {}) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
let response;
|
|
47
|
+
try {
|
|
48
|
+
response = await fetch(`http://${host}:${port}${pathname}`, {
|
|
49
|
+
method,
|
|
50
|
+
headers: body === undefined ? headers : { "Content-Type": "application/json", ...headers },
|
|
51
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
52
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
53
|
+
});
|
|
54
|
+
} catch (error) {
|
|
55
|
+
throw new Error(`HTTP fixture ${method} ${pathname} failed after a ${timeoutMs}ms request budget`, { cause: error });
|
|
56
|
+
}
|
|
46
57
|
let payload;
|
|
47
58
|
try {
|
|
48
59
|
payload = await response.json();
|
|
@@ -159,6 +170,9 @@ await writeFile(artifactManifest, JSON.stringify({ artifact: { schema: "pi.artif
|
|
|
159
170
|
await mkdir(managedThemeDir, { recursive: true });
|
|
160
171
|
await writeFile(path.join(managedThemePackageRoot, "package.json"), JSON.stringify({ name: "@firstpick/pi-themes-bundle", version: "0.0.0-test", pi: { themes: ["./themes"] } }));
|
|
161
172
|
await writeFile(path.join(managedThemeDir, "managed-fixture.json"), serializeTheme(themeFixture("managed-fixture")));
|
|
173
|
+
await writeFile(path.join(managedThemePackageRoot, "webui-backgrounds.json"), JSON.stringify({
|
|
174
|
+
"managed-fixture": { backgroundImage: "url(\"/matrix-background.webp\")", backgroundSize: "cover", pageBg: "#ffffff", arbitrary: "ignored" },
|
|
175
|
+
}));
|
|
162
176
|
await writeFile(path.join(workflowPolicyAgentDir, "trust.json"), `${JSON.stringify({ [cwd]: true }, null, 2)}\n`);
|
|
163
177
|
await chmod(fakePi, 0o755);
|
|
164
178
|
await mkdir(fakeOpenBinDir, { recursive: true });
|
|
@@ -274,6 +288,7 @@ for (const [producerId, status, updatedAt] of [
|
|
|
274
288
|
}, { recordId: `${producerId}-record` });
|
|
275
289
|
}
|
|
276
290
|
|
|
291
|
+
await new Promise((resolve, reject) => portReservation.close(error => error ? reject(error) : resolve()));
|
|
277
292
|
const child = spawn(process.execPath, [serverScript, "--cwd", cwd, "--host", "0.0.0.0", "--port", String(port), "--pi", fakePiCli], {
|
|
278
293
|
stdio: ["ignore", "pipe", "pipe"],
|
|
279
294
|
env: {
|
|
@@ -355,7 +370,7 @@ async function runOptionalFeatureFocus() {
|
|
|
355
370
|
|
|
356
371
|
const manifest = JSON.parse(await readFile(path.join(root, "package.json"), "utf8"));
|
|
357
372
|
assert.deepEqual(manifest.optionalDependencies, { "node-pty": "^1.1.0" });
|
|
358
|
-
assert.equal(manifest.dependencies?.["@firstpick/pi-utils"], "^0.2
|
|
373
|
+
assert.equal(manifest.dependencies?.["@firstpick/pi-utils"], "^0.3.2");
|
|
359
374
|
assert.equal(JSON.stringify(manifest.pi).includes("node_modules/@firstpick"), false);
|
|
360
375
|
|
|
361
376
|
const initial = await request("127.0.0.1", "/api/optional-features");
|
|
@@ -513,6 +528,11 @@ try {
|
|
|
513
528
|
assert.deepEqual(managedThemesResponse.body?.data?.themes?.map(({ name }) => name), ["managed-fixture"], "themes installed only under PI_CODING_AGENT_DIR/npm/node_modules should be exposed to the browser");
|
|
514
529
|
assert.equal(managedThemesResponse.body?.data?.themes?.[0]?.colors?.accent, "#123456");
|
|
515
530
|
assert.equal(managedThemesResponse.body?.data?.themes?.[0]?.scope, "bundled");
|
|
531
|
+
const managedExport = managedThemesResponse.body.data.themes[0].export;
|
|
532
|
+
assert.equal(managedExport.backgroundImage, "url(\"/matrix-background.webp\")", "separate WebUI metadata must preserve bundled backgrounds");
|
|
533
|
+
assert.equal(managedExport.backgroundSize, "cover");
|
|
534
|
+
assert.notEqual(managedExport.pageBg, "#ffffff", "background metadata must not replace native Pi export colors");
|
|
535
|
+
assert.equal(Object.hasOwn(managedExport, "arbitrary"), false, "only supported background fields may enter the catalog");
|
|
516
536
|
|
|
517
537
|
const themeTabs = await request("127.0.0.1", "/api/tabs");
|
|
518
538
|
const themeTabId = themeTabs.body?.data?.tabs?.[0]?.id;
|
|
@@ -1321,7 +1341,7 @@ try {
|
|
|
1321
1341
|
|
|
1322
1342
|
const webuiManifest = JSON.parse(await readFile(path.join(root, "package.json"), "utf8"));
|
|
1323
1343
|
assert.deepEqual(webuiManifest.optionalDependencies, { "node-pty": "^1.1.0" }, "node-pty should be the only optional dependency");
|
|
1324
|
-
assert.equal(webuiManifest.dependencies?.["@firstpick/pi-utils"], "^0.2
|
|
1344
|
+
assert.equal(webuiManifest.dependencies?.["@firstpick/pi-utils"], "^0.3.2", "the required pi-utils runtime dependency must remain regular");
|
|
1325
1345
|
assert.equal(JSON.stringify(webuiManifest.pi).includes("node_modules/@firstpick"), false, "the WebUI manifest must not claim optional companion resources");
|
|
1326
1346
|
|
|
1327
1347
|
const optionalFeatures = await request("127.0.0.1", "/api/optional-features");
|
|
@@ -5,6 +5,7 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
|
|
6
6
|
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
7
|
const app = await readFile(join(root, "public", "app.js"), "utf8");
|
|
8
|
+
const queue = await readFile(join(root, "public", "activity-queue-controller.mjs"), "utf8");
|
|
8
9
|
const renderer = await readFile(join(root, "public", "transcript-renderer.mjs"), "utf8");
|
|
9
10
|
|
|
10
11
|
function functionBody(name, source = app) {
|
|
@@ -53,7 +54,7 @@ const renderWidgets = functionBody("renderWidgets");
|
|
|
53
54
|
const renderSubagents = functionBody("renderSubagents");
|
|
54
55
|
const renderGitWorkflow = functionBody("renderGitWorkflow");
|
|
55
56
|
const renderGitPanel = functionBody("renderGitPanel");
|
|
56
|
-
const renderQueue = functionBody("
|
|
57
|
+
const renderQueue = functionBody("render", queue);
|
|
57
58
|
const captureChatText = functionBody("captureChatTextSelection");
|
|
58
59
|
const matchChatText = functionBody("chatTextSelectionMatch");
|
|
59
60
|
const restoreChatText = functionBody("restoreChatTextSelection");
|
|
@@ -119,12 +120,12 @@ assert.match(renderGitWorkflow, /captureGitWorkflowInputFocus\(\)[\s\S]*deferUiR
|
|
|
119
120
|
|
|
120
121
|
assert.match(captureAppRunnerInput, /activeTabContext\(\)[\s\S]*selectionDirection:[\s\S]*scrollTop:[\s\S]*scrollLeft:/, "app-runner input capture must include its tab context and complete text-control state");
|
|
121
122
|
assert.match(restoreAppRunnerInput, /isCurrentTabContext\(state\.context\) \|\| state\.source\?\.isConnected/, "app-runner input restore must reject stale tab contexts and connected sources");
|
|
122
|
-
assert.match(restoreAppRunnerInput, /isMeaningfulConnectedFocus\(document\.activeElement\)[\s\S]*
|
|
123
|
+
assert.match(restoreAppRunnerInput, /isMeaningfulConnectedFocus\(document\.activeElement\)[\s\S]*featureWidgetElements\("\.app-runner-stdin-input"\)[\s\S]*candidate\.dataset\.runId === state\.runId/, "app-runner input restore must stay inside canonical feature widget roots and match runner identity");
|
|
123
124
|
assert.match(captureGitInput, /activeTabContext\(\)[\s\S]*selectionDirection:[\s\S]*scrollTop:[\s\S]*scrollLeft:/, "Guided Git input capture must include its context and complete text-control state");
|
|
124
125
|
assert.match(restoreGitInput, /state\.tabId !== activeTabId \|\| state\.runId !== gitWorkflow\?\.runId \|\| !isCurrentTabContext\(state\.context\) \|\| state\.source\?\.isConnected/, "Guided Git input restore must require the exact tab, run, and current context");
|
|
125
126
|
|
|
126
127
|
assert.match(renderGitPanel, /captureScopedControlContinuity\(elements\.gitPanelGroups[\s\S]*data-git-panel-continuity-key[\s\S]*scrollTop = scrollTop/, "Git-panel rebuilds must preserve semantic focus and panel scroll");
|
|
127
|
-
assert.match(renderQueue, /
|
|
128
|
+
assert.match(renderQueue, /captureContinuity\(nodes\.queueBox[\s\S]*data-queue-continuity-key[\s\S]*restore\(\)/, "queue rebuilds must preserve semantic action focus and panel scroll");
|
|
128
129
|
assert.match(app, /dataset\.mobileContinuityKey = "context:paste-text"[\s\S]*dataset\.mobileDraftAuthority = "dom"/, "mobile paste text must have a stable DOM-authoritative continuity identity");
|
|
129
130
|
assert.match(captureMobileSurface, /mobileDraftAuthority === "dom"[\s\S]*selectionDirection:[\s\S]*scrollTop:[\s\S]*scrollLeft:/, "mobile DOM drafts must capture selection and scroll state");
|
|
130
131
|
assert.match(restoreMobileSurface, /target\.dataset\.mobileDraftAuthority === "dom"[\s\S]*target\.value = snapshot\.value[\s\S]*setSelectionRange[\s\S]*target\.focus\(\{ preventScroll: true \}\)/, "mobile DOM drafts must restore value, selection, scroll, and focus");
|
|
@@ -4,7 +4,7 @@ import { dirname, join } from "node:path";
|
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
|
|
6
6
|
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
-
const [html, app, css, serviceWorker, readme, technical, development] = await Promise.all([
|
|
7
|
+
const [html, app, css, serviceWorker, readme, technical, development, controller] = await Promise.all([
|
|
8
8
|
readFile(join(root, "public", "index.html"), "utf8"),
|
|
9
9
|
readFile(join(root, "public", "app.js"), "utf8"),
|
|
10
10
|
readFile(join(root, "public", "styles.css"), "utf8"),
|
|
@@ -12,6 +12,7 @@ const [html, app, css, serviceWorker, readme, technical, development] = await Pr
|
|
|
12
12
|
readFile(join(root, "README.md"), "utf8"),
|
|
13
13
|
readFile(join(root, "TECHNICAL.md"), "utf8"),
|
|
14
14
|
readFile(join(root, "DEVELOPMENT.md"), "utf8"),
|
|
15
|
+
readFile(join(root, "public", "activity-intercom-controller.mjs"), "utf8"),
|
|
15
16
|
]);
|
|
16
17
|
|
|
17
18
|
function count(value, pattern) {
|
|
@@ -19,11 +20,18 @@ function count(value, pattern) {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
function functionSource(name) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const aliases = {
|
|
24
|
+
openIntercomConversation: "open", renderIntercomConversationTags: "renderTags",
|
|
25
|
+
refreshIntercomConversationSummaries: "refreshSummaries", refreshIntercomConversationDetail: "refreshDetail",
|
|
26
|
+
scheduleIntercomConversationDetailRefresh: "scheduleDetailRefresh", resetIntercomConversationDialog: "resetDetail",
|
|
27
|
+
};
|
|
28
|
+
const source = name === "setActiveTabId" ? app : controller;
|
|
29
|
+
const actualName = aliases[name] || name;
|
|
30
|
+
const start = source.indexOf(`function ${actualName}(`);
|
|
31
|
+
assert.ok(start >= 0, `${name} should exist in its owner`);
|
|
32
|
+
const next = source.slice(start + 1).match(/\n\s*(?:async )?function [A-Za-z0-9_$]+\(/);
|
|
33
|
+
const end = next ? start + 1 + next.index : source.length;
|
|
34
|
+
return source.slice(start, end);
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
for (const id of [
|
|
@@ -50,8 +58,8 @@ assert.match(
|
|
|
50
58
|
"the viewer should be a labelled native dialog with a live transcript and explicit close control",
|
|
51
59
|
);
|
|
52
60
|
assert.match(app, /installModalPrimitives\(\)/, "the native dialog should use the shared focus-management primitive");
|
|
53
|
-
assert.match(functionSource("openIntercomConversation"), /
|
|
54
|
-
assert.match(functionSource("setActiveTabId"), /
|
|
61
|
+
assert.match(functionSource("openIntercomConversation"), /onDialogOpen\(dialog\)[\s\S]*intercomConversationCloseButton\?\.focus/, "opening should use the modal primitive and establish an explicit keyboard target");
|
|
62
|
+
assert.match(functionSource("setActiveTabId"), /activityIntercom\.activate\(projectTargetFromContext\(\)\)/, "tab switching should close the old conversation without restoring focus into the old tab");
|
|
55
63
|
|
|
56
64
|
const tagsSource = functionSource("renderIntercomConversationTags");
|
|
57
65
|
assert.match(tagsSource, /const seenConversationIds = new Set\(\)/, "tag rendering should deduplicate conversation IDs defensively");
|
|
@@ -61,13 +69,13 @@ assert.match(tagsSource, /aria-haspopup", "dialog"[\s\S]*aria-controls", "interc
|
|
|
61
69
|
assert.match(tagsSource, /if \(!conversations\.length\)[\s\S]*container\.replaceChildren\(\)[\s\S]*container\.hidden = true/, "the tag list should disappear and clear stale disclosure state when there are no conversations");
|
|
62
70
|
|
|
63
71
|
const summarySource = functionSource("refreshIntercomConversationSummaries");
|
|
64
|
-
assert.match(summarySource, /api\("\/api\/intercom\/conversations", \{ tabId:
|
|
65
|
-
assert.match(summarySource, /
|
|
72
|
+
assert.match(summarySource, /api\("\/api\/intercom\/conversations", \{ tabId: target\.tabId \}\)/, "summary requests should stay scoped to the selected tab");
|
|
73
|
+
assert.match(summarySource, /serial !== intercomSummaryRequestSerial \|\| !current\(target\)/, "summary responses should be rejected after a newer request or tab switch");
|
|
66
74
|
const detailSource = functionSource("refreshIntercomConversationDetail");
|
|
67
75
|
assert.match(detailSource, /conversation=\$\{encodeURIComponent\(state\.conversationId\)\}/, "detail selection should send only an encoded opaque ID");
|
|
68
|
-
assert.match(detailSource, /
|
|
69
|
-
assert.match(app, /\["webui_connected", "agent_end", "message_end", "tool_execution_end"\][\s\S]*
|
|
70
|
-
assert.match(app, /
|
|
76
|
+
assert.match(detailSource, /serial !== intercomDetailRequestSerial \|\| !detailCurrent\(state\)/, "detail responses should be rejected after rapid selection or tab changes");
|
|
77
|
+
assert.match(app, /\["webui_connected", "agent_end", "message_end", "tool_execution_end"\][\s\S]*activityIntercom\.scheduleRefresh\(projectTargetFromContext\(tabContext\)\)/, "settlement and reconnect events should refresh conversation summaries");
|
|
78
|
+
assert.match(app, /function handleSessionStreamOpen\(event, tabContext\) \{[\s\S]*activityIntercom\.scheduleRefresh\(projectTargetFromContext\(tabContext\), 0\)/, "event-stream reconnection should authoritatively refetch tags");
|
|
71
79
|
|
|
72
80
|
const messageRenderSource = functionSource("renderIntercomConversationMessage");
|
|
73
81
|
const renderSource = functionSource("renderIntercomConversationDetail");
|
|
@@ -86,7 +94,11 @@ assert.match(renderSource, /const anchorOffset = anchor \? anchor\.getBoundingCl
|
|
|
86
94
|
|
|
87
95
|
assert.match(functionSource("scheduleIntercomConversationDetailRefresh"), /INTERCOM_DETAIL_REFRESH_MS/, "an open dialog should use the bounded detail refresh interval");
|
|
88
96
|
assert.match(functionSource("resetIntercomConversationDialog"), /intercomDetailRequestSerial \+= 1[\s\S]*clearTimeout\(intercomDetailRefreshTimer\)[\s\S]*intercomConversationDialogState = null/, "dialog close should invalidate requests, cancel polling, and clear selection state");
|
|
89
|
-
assert.match(app, /elements\.intercomConversationDialog\?\.addEventListener\("close",
|
|
97
|
+
assert.match(app, /elements\.intercomConversationDialog\?\.addEventListener\("close",[\s\S]*if \(!elements\.intercomConversationDialog\.open\) activityIntercom\.reset\(\)/, "native Escape and close-button paths should share polling cleanup");
|
|
98
|
+
|
|
99
|
+
assert.match(controller, /state === intercomConversationDialogState && nodes\.intercomConversationDialog\?\.open && current\(state\)/, "detail acceptance checks the selected owner, open dialog and current session");
|
|
100
|
+
assert.match(app, /onDialogOpen\(dialog\) \{ if \(!dialog\.open\) dialog\.showModal\(\); \}/, "the parent opens the canonical native dialog");
|
|
101
|
+
assert.match(controller, /function activate[\s\S]*close\(\{ restoreFocus: false \}\)/, "activation closes the old detail without restoring old focus");
|
|
90
102
|
|
|
91
103
|
assert.match(css, /\.composer-intercom-tags \{[\s\S]*display: inline-flex;[\s\S]*flex: 0 1 50%;[\s\S]*max-width: 50%;[\s\S]*overflow: hidden;/, "conversation tags should use up to half the desktop input width without a horizontal scroller");
|
|
92
104
|
assert.match(css, /\.composer-intercom-overflow-menu \{[\s\S]*position: absolute;[\s\S]*max-height:[\s\S]*overflow-y: auto;/, "hidden conversations should remain reachable in a bounded popup");
|
|
@@ -96,9 +108,9 @@ assert.match(css, /\.composer-intercom-tag:hover,[\s\S]*\.composer-intercom-tag:
|
|
|
96
108
|
assert.match(css, /\.extension-dialog\.intercom-conversation-dialog \{[\s\S]*width: min\(76rem,[\s\S]*height: min\(54rem,/, "the viewer should use a large in-app modal");
|
|
97
109
|
assert.match(css, /@media \(max-width: 720px\)[\s\S]*\.composer-intercom-tag \{ min-height: 44px;[\s\S]*\.extension-dialog\.intercom-conversation-dialog[\s\S]*width: calc\(100vw - 0\.7rem\)/, "tags and the dialog should remain reachable on narrow and coarse-pointer layouts");
|
|
98
110
|
|
|
99
|
-
assert.match(html, /\/styles\.css\?v=
|
|
100
|
-
assert.match(html, /data-app-src="\/app\.js\?v=
|
|
101
|
-
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-
|
|
111
|
+
assert.match(html, /\/styles\.css\?v=167/, "the stylesheet URL should advance for the bounded conversation tags");
|
|
112
|
+
assert.match(html, /data-app-src="\/app\.js\?v=220"/, "the guarded app URL should advance for current browser wiring");
|
|
113
|
+
assert.match(serviceWorker, /const CACHE_NAME = "pi-webui-pwa-v200"/, "the PWA cache identity should advance with browser assets");
|
|
102
114
|
|
|
103
115
|
assert.match(readme, /one compact tag per conversation appears beneath the composer/i, "the README should explain the user-visible entry point");
|
|
104
116
|
assert.match(technical, /## Agent conversation viewer[\s\S]*Attachments, tool calls and results, thinking, stdout\/stderr, filesystem paths, raw session records/i, "the advanced guide should document privacy exclusions");
|
|
@@ -4,9 +4,10 @@ import { dirname, join } from "node:path";
|
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
|
|
6
6
|
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
-
const [css, app] = await Promise.all([
|
|
7
|
+
const [css, app, controller] = await Promise.all([
|
|
8
8
|
readFile(join(root, "public", "styles.css"), "utf8"),
|
|
9
9
|
readFile(join(root, "public", "app.js"), "utf8"),
|
|
10
|
+
readFile(join(root, "public", "activity-intercom-controller.mjs"), "utf8"),
|
|
10
11
|
]);
|
|
11
12
|
|
|
12
13
|
function rule(selector, label) {
|
|
@@ -18,14 +19,14 @@ function rule(selector, label) {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
function functionSource(name, nextName) {
|
|
21
|
-
const start =
|
|
22
|
+
const start = controller.indexOf(`function ${name}(`);
|
|
22
23
|
const candidates = [
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
controller.indexOf(`\n function ${nextName}(`, start),
|
|
25
|
+
controller.indexOf(`\n async function ${nextName}(`, start),
|
|
25
26
|
].filter((index) => index > start);
|
|
26
27
|
const end = Math.min(...candidates);
|
|
27
28
|
assert.ok(start >= 0 && Number.isFinite(end), `${name} should remain a standalone frontend helper`);
|
|
28
|
-
return
|
|
29
|
+
return controller.slice(start, end);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
const container = rule(".composer-intercom-tags", "conversation tag container styles");
|
|
@@ -33,9 +34,9 @@ const tag = rule(".composer-intercom-tag", "conversation tag styles");
|
|
|
33
34
|
const label = rule(".composer-intercom-tag-label", "conversation tag label styles");
|
|
34
35
|
const icon = rule(".composer-intercom-tag-icon", "conversation tag icon styles");
|
|
35
36
|
const count = rule(".composer-intercom-tag-count", "conversation tag count styles");
|
|
36
|
-
const disclosure = functionSource("
|
|
37
|
-
const install = functionSource("
|
|
38
|
-
const render = functionSource("
|
|
37
|
+
const disclosure = functionSource("setOverflowOpen", "fitTags");
|
|
38
|
+
const install = functionSource("install", "updateIntercomConversationTag");
|
|
39
|
+
const render = functionSource("renderTags", "refreshSummaries");
|
|
39
40
|
|
|
40
41
|
assert.match(container, /position:\s*relative;/, "the overflow popup should anchor to the conversation tag strip");
|
|
41
42
|
assert.match(container, /display:\s*inline-flex;/, "conversation tags should remain on one measured row");
|
|
@@ -53,13 +54,13 @@ assert.match(icon, /flex:\s*0 0 auto;/, "the conversation icon should stay stabl
|
|
|
53
54
|
assert.match(count, /flex:\s*0 0 auto;/, "the conversation count should stay stable while the label shrinks");
|
|
54
55
|
|
|
55
56
|
assert.match(disclosure, /classList\.toggle\("overflow-open", expanded\)[\s\S]*aria-expanded[\s\S]*menu\.hidden = !expanded/, "the +X disclosure should synchronize visual, accessible, and hidden state");
|
|
56
|
-
assert.match(install, /ResizeObserver[\s\S]*event\.key !== "Escape"[\s\S]*restoreFocus: true[\s\S]*
|
|
57
|
+
assert.match(install, /ResizeObserver[\s\S]*event\.key !== "Escape"[\s\S]*restoreFocus: true[\s\S]*listen\(document, "pointerdown"/, "resize, Escape, and outside-click handling should keep the disclosure usable");
|
|
57
58
|
assert.match(render, /make\("button", "composer-intercom-tag overflow"[\s\S]*aria-haspopup[\s\S]*intercomConversationOverflowMenu[\s\S]*role", "dialog"/, "the hidden conversation count should render as an accessible popup button");
|
|
58
|
-
assert.match(
|
|
59
|
+
assert.match(install, /listen\(container, "click"[\s\S]*setOverflowOpen\(false, \{ restoreFocus: true \}\);[\s\S]*open\(button\.dataset\.intercomConversationId\)/, "hidden conversations should open through the existing conversation dialog");
|
|
59
60
|
assert.match(css, /\.composer-intercom-overflow-menu \{[\s\S]*position: absolute;[\s\S]*bottom: calc\(100% \+ 0\.42rem\);[\s\S]*max-height:[\s\S]*overflow-y: auto;/, "the bounded popup should expand upward above the compact strip");
|
|
60
61
|
assert.match(css, /@media \(max-width: 720px\)[\s\S]*?\.composer-intercom-tags \{ flex: 0 0 100%; width: 100%; min-width: 0; max-width: 100%; \}[\s\S]*?\.composer-intercom-overflow-menu \.composer-intercom-tag \{ min-height: 44px; \}/, "narrow disclosures should use the full row and keep hidden conversations touch-friendly");
|
|
61
62
|
assert.match(css, /body\.mobile-composer-disclosure \.composer-actions-panel > \.composer-context-tags \{[\s\S]*display: flex;[\s\S]*flex-wrap: wrap;/, "the narrow composer disclosure should give the full-width conversation strip its own row");
|
|
62
|
-
assert.match(app, /installSessionSkillTagResizeHandling\(\);\s*
|
|
63
|
-
assert.match(
|
|
63
|
+
assert.match(app, /installSessionSkillTagResizeHandling\(\);\s*activityIntercom\.install\(\);/, "startup should install responsive fitting for both compact tag groups");
|
|
64
|
+
assert.match(controller, /const visualSignature = JSON\.stringify\(\[label, conversation\.messageCount\]\);[\s\S]*tag\.replaceChildren\(\.\.\.children\);[\s\S]*tag\.dataset\.intercomVisualSignature = visualSignature;/, "unchanged tag visuals should retain their existing children inside the polite live region");
|
|
64
65
|
|
|
65
66
|
console.log("intercom-tag-layout-static.test.mjs passed");
|