@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,511 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import {
|
|
4
|
+
createActivityEventsController,
|
|
5
|
+
EVENT_DISPLAY_MODE_STORAGE_KEY,
|
|
6
|
+
EVENT_FILTER_STORAGE_KEY,
|
|
7
|
+
EVENT_FILTER_VALUES,
|
|
8
|
+
normalizeEventDisplayMode,
|
|
9
|
+
normalizeEventFilter,
|
|
10
|
+
} from "../public/activity-events-controller.mjs";
|
|
11
|
+
|
|
12
|
+
// Only the DOM operations used by the port are modeled. HTML parsing is forbidden
|
|
13
|
+
// so a renderer that switches from text nodes to markup fails these tests.
|
|
14
|
+
class FixtureNode extends EventTarget {
|
|
15
|
+
constructor(tagName = "", text = "") {
|
|
16
|
+
super();
|
|
17
|
+
this.tagName = tagName.toUpperCase();
|
|
18
|
+
this.nodeType = tagName ? 1 : 3;
|
|
19
|
+
this.data = text;
|
|
20
|
+
this.childNodes = [];
|
|
21
|
+
this.parentNode = null;
|
|
22
|
+
this.dataset = {};
|
|
23
|
+
this.attributes = new Map();
|
|
24
|
+
this.className = "";
|
|
25
|
+
this.hidden = false;
|
|
26
|
+
this.value = "";
|
|
27
|
+
this.classList = { contains: (name) => this.className.split(/\s+/).includes(name) };
|
|
28
|
+
this.clickListeners = new Set();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get children() { return this.childNodes.filter((node) => node.nodeType === 1); }
|
|
32
|
+
get childElementCount() { return this.children.length; }
|
|
33
|
+
get lastElementChild() { return this.children.at(-1) || null; }
|
|
34
|
+
get textContent() {
|
|
35
|
+
return this.nodeType === 3 ? this.data : this.childNodes.map((node) => node.textContent).join("");
|
|
36
|
+
}
|
|
37
|
+
set textContent(value) {
|
|
38
|
+
if (this.nodeType === 3) {
|
|
39
|
+
this.data = String(value);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
for (const node of this.childNodes) node.parentNode = null;
|
|
43
|
+
this.childNodes = [];
|
|
44
|
+
if (String(value)) this.append(new FixtureNode("", String(value)));
|
|
45
|
+
}
|
|
46
|
+
set innerHTML(_value) { throw new Error("Event content must use text nodes"); }
|
|
47
|
+
get selectedOptions() { return this.children.filter((option) => option.value === this.value); }
|
|
48
|
+
|
|
49
|
+
append(...nodes) {
|
|
50
|
+
for (const node of nodes) {
|
|
51
|
+
node.remove();
|
|
52
|
+
node.parentNode = this;
|
|
53
|
+
this.childNodes.push(node);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
prepend(node) {
|
|
57
|
+
node.remove();
|
|
58
|
+
node.parentNode = this;
|
|
59
|
+
this.childNodes.unshift(node);
|
|
60
|
+
}
|
|
61
|
+
remove() {
|
|
62
|
+
if (!this.parentNode) return;
|
|
63
|
+
const siblings = this.parentNode.childNodes;
|
|
64
|
+
siblings.splice(siblings.indexOf(this), 1);
|
|
65
|
+
this.parentNode = null;
|
|
66
|
+
}
|
|
67
|
+
setAttribute(name, value) { this.attributes.set(name, String(value)); }
|
|
68
|
+
getAttribute(name) { return this.attributes.get(name) ?? null; }
|
|
69
|
+
addEventListener(type, listener, options) {
|
|
70
|
+
super.addEventListener(type, listener, options);
|
|
71
|
+
if (type === "click") this.clickListeners.add(listener);
|
|
72
|
+
}
|
|
73
|
+
removeEventListener(type, listener, options) {
|
|
74
|
+
super.removeEventListener(type, listener, options);
|
|
75
|
+
if (type === "click") this.clickListeners.delete(listener);
|
|
76
|
+
}
|
|
77
|
+
click() {
|
|
78
|
+
const event = new Event("click");
|
|
79
|
+
Object.defineProperty(event, "target", { value: this });
|
|
80
|
+
for (let node = this; node; node = node.parentNode) node.dispatchEvent(event);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function fixture({ preferences = new Map(), denyReads = false, denyWrites = false } = {}) {
|
|
85
|
+
const document = {
|
|
86
|
+
createElement: (tag) => new FixtureNode(tag),
|
|
87
|
+
createTextNode: (text) => new FixtureNode("", String(text)),
|
|
88
|
+
};
|
|
89
|
+
const nodes = Object.fromEntries([
|
|
90
|
+
["eventLog", "div"], ["eventFilterSelect", "select"],
|
|
91
|
+
["eventFilterStatus", "span"], ["eventFilterEmpty", "p"],
|
|
92
|
+
["eventDisplayDetailedAction", "button"], ["eventDisplayCompactAction", "button"],
|
|
93
|
+
["eventsUnreadBadge", "span"],
|
|
94
|
+
].map(([key, tag]) => [key, document.createElement(tag)]));
|
|
95
|
+
for (const [value, text] of [
|
|
96
|
+
["all", "All events"], ["errors", "Errors / failures"], ["warnings", "Warnings"],
|
|
97
|
+
["tools", "Tool activity"], ["tree", "Tree available"],
|
|
98
|
+
]) {
|
|
99
|
+
const option = document.createElement("option");
|
|
100
|
+
option.value = value;
|
|
101
|
+
option.textContent = text;
|
|
102
|
+
nodes.eventFilterSelect.append(option);
|
|
103
|
+
}
|
|
104
|
+
const reads = [];
|
|
105
|
+
const writes = [];
|
|
106
|
+
const jumps = [];
|
|
107
|
+
const notices = [];
|
|
108
|
+
const unreadChanges = [];
|
|
109
|
+
let visible = false;
|
|
110
|
+
const controller = createActivityEventsController({
|
|
111
|
+
document,
|
|
112
|
+
nodes,
|
|
113
|
+
readPreference(key) {
|
|
114
|
+
reads.push(key);
|
|
115
|
+
if (denyReads) throw new Error("Storage access denied");
|
|
116
|
+
return preferences.get(key) ?? null;
|
|
117
|
+
},
|
|
118
|
+
writePreference(key, value) {
|
|
119
|
+
writes.push([key, value]);
|
|
120
|
+
if (denyWrites) throw new Error("Storage access denied");
|
|
121
|
+
preferences.set(key, value);
|
|
122
|
+
},
|
|
123
|
+
isVisible: () => visible,
|
|
124
|
+
onJump: (row) => jumps.push(row),
|
|
125
|
+
onNotice: (message, level) => notices.push([message, level]),
|
|
126
|
+
onUnreadChange: (count) => unreadChanges.push(count),
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
document, nodes, controller, reads, writes, jumps, notices, unreadChanges,
|
|
130
|
+
setVisible(value) { visible = value; },
|
|
131
|
+
rows: () => nodes.eventLog.children,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function summary(row) { return row.children[0].children[1].textContent; }
|
|
136
|
+
|
|
137
|
+
function assertDisplay(nodes, mode) {
|
|
138
|
+
assert.equal(nodes.eventLog.dataset.displayMode, mode);
|
|
139
|
+
assert.equal(nodes.eventDisplayDetailedAction.getAttribute("aria-checked"), String(mode === "detailed"));
|
|
140
|
+
assert.equal(nodes.eventDisplayCompactAction.getAttribute("aria-checked"), String(mode === "compact"));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
test("exports the exact preference keys, filter values, normalizers and controller API", () => {
|
|
144
|
+
assert.equal(EVENT_DISPLAY_MODE_STORAGE_KEY, "pi-webui-event-display-mode-v1");
|
|
145
|
+
assert.equal(EVENT_FILTER_STORAGE_KEY, "pi-webui-event-filter-v1");
|
|
146
|
+
assert.deepEqual([...EVENT_FILTER_VALUES], ["all", "errors", "warnings", "tools", "tree"]);
|
|
147
|
+
for (const value of EVENT_FILTER_VALUES) assert.equal(normalizeEventFilter(value), value);
|
|
148
|
+
for (const value of [null, undefined, "ERRORS", "unknown", 0]) assert.equal(normalizeEventFilter(value), "all");
|
|
149
|
+
assert.equal(normalizeEventDisplayMode("compact"), "compact");
|
|
150
|
+
for (const value of [null, undefined, "COMPACT", "unknown", "detailed"]) assert.equal(normalizeEventDisplayMode(value), "detailed");
|
|
151
|
+
const { controller } = fixture();
|
|
152
|
+
assert.deepEqual(Object.keys(controller).sort(), [
|
|
153
|
+
"add", "setFilter", "setDisplayMode", "syncUi", "clearUnread", "syncVisibility", "getSnapshot", "dispose",
|
|
154
|
+
].sort());
|
|
155
|
+
assert.deepEqual(controller.getSnapshot(), { filter: "all", displayMode: "detailed", unreadCount: 0 });
|
|
156
|
+
const snapshot = controller.getSnapshot();
|
|
157
|
+
snapshot.filter = "errors";
|
|
158
|
+
assert.equal(controller.getSnapshot().filter, "all");
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test("restores preferences, synchronizes existing controls and persists only requested changes", () => {
|
|
162
|
+
const f = fixture({ preferences: new Map([
|
|
163
|
+
[EVENT_FILTER_STORAGE_KEY, "tools"], [EVENT_DISPLAY_MODE_STORAGE_KEY, "compact"],
|
|
164
|
+
]) });
|
|
165
|
+
const { controller: c, nodes } = f;
|
|
166
|
+
assert.deepEqual(f.reads.sort(), [EVENT_FILTER_STORAGE_KEY, EVENT_DISPLAY_MODE_STORAGE_KEY].sort());
|
|
167
|
+
assert.equal(nodes.eventFilterSelect.value, "tools");
|
|
168
|
+
assertDisplay(nodes, "compact");
|
|
169
|
+
assert.equal(nodes.eventFilterStatus.textContent, "No events yet");
|
|
170
|
+
assert.equal(nodes.eventFilterEmpty.hidden, true);
|
|
171
|
+
assert.equal(nodes.eventsUnreadBadge.hidden, true);
|
|
172
|
+
assert.deepEqual(f.writes, []);
|
|
173
|
+
|
|
174
|
+
c.setFilter("errors");
|
|
175
|
+
c.setDisplayMode("detailed");
|
|
176
|
+
assert.deepEqual(f.writes, [[EVENT_FILTER_STORAGE_KEY, "errors"], [EVENT_DISPLAY_MODE_STORAGE_KEY, "detailed"]]);
|
|
177
|
+
c.setFilter("warnings", { persist: false });
|
|
178
|
+
c.setDisplayMode("compact", { persist: false });
|
|
179
|
+
assert.equal(f.writes.length, 2);
|
|
180
|
+
assert.equal(nodes.eventFilterSelect.value, "warnings");
|
|
181
|
+
assertDisplay(nodes, "compact");
|
|
182
|
+
|
|
183
|
+
nodes.eventFilterSelect.value = "tree";
|
|
184
|
+
nodes.eventLog.dataset.displayMode = "detailed";
|
|
185
|
+
nodes.eventDisplayCompactAction.setAttribute("aria-checked", "false");
|
|
186
|
+
c.syncUi();
|
|
187
|
+
assert.equal(nodes.eventFilterSelect.value, "warnings");
|
|
188
|
+
assertDisplay(nodes, "compact");
|
|
189
|
+
assert.equal(f.writes.length, 2);
|
|
190
|
+
c.setFilter("invalid");
|
|
191
|
+
c.setDisplayMode("invalid");
|
|
192
|
+
assert.equal(nodes.eventFilterSelect.value, "all");
|
|
193
|
+
assertDisplay(nodes, "detailed");
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test("denied or invalid preference reads fall back and denied writes retain page-local choices", () => {
|
|
197
|
+
for (const options of [
|
|
198
|
+
{ denyReads: true, denyWrites: true },
|
|
199
|
+
{ preferences: new Map([[EVENT_FILTER_STORAGE_KEY, "bad"], [EVENT_DISPLAY_MODE_STORAGE_KEY, "bad"]]), denyWrites: true },
|
|
200
|
+
]) {
|
|
201
|
+
const f = fixture(options);
|
|
202
|
+
assert.deepEqual(f.controller.getSnapshot(), { filter: "all", displayMode: "detailed", unreadCount: 0 });
|
|
203
|
+
f.controller.setFilter("errors");
|
|
204
|
+
f.controller.setDisplayMode("compact");
|
|
205
|
+
f.controller.add("failed", "error");
|
|
206
|
+
assert.deepEqual(f.controller.getSnapshot(), { filter: "errors", displayMode: "compact", unreadCount: 1 });
|
|
207
|
+
assert.equal(f.nodes.eventFilterStatus.textContent, "1 of 1");
|
|
208
|
+
assert.equal(f.rows()[0].hidden, false);
|
|
209
|
+
assertDisplay(f.nodes, "compact");
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test("renders safe text, exact navigation metadata, details and accessible tool rows", () => {
|
|
214
|
+
const f = fixture();
|
|
215
|
+
const occurredAt = 1_700_000_000_123;
|
|
216
|
+
const message = '<img src=x onerror="bad()">';
|
|
217
|
+
const target = '<script>bad()</script>';
|
|
218
|
+
f.controller.add(message, "error", {
|
|
219
|
+
toolCallId: " tool-id:<exact> ", toolEventPhase: "finish", occurredAt,
|
|
220
|
+
details: [
|
|
221
|
+
{ label: "target", value: target }, { label: "status", value: "failed", tone: "error" },
|
|
222
|
+
null, { label: "empty", value: "" }, { label: "", value: "skip" }, { label: "zero", value: 0 },
|
|
223
|
+
],
|
|
224
|
+
});
|
|
225
|
+
const row = f.rows()[0];
|
|
226
|
+
assert.equal(row.tagName, "BUTTON");
|
|
227
|
+
assert.equal(row.type, "button");
|
|
228
|
+
assert.equal(row.className, "event error");
|
|
229
|
+
assert.deepEqual(row.dataset, {
|
|
230
|
+
eventLevel: "error", chatEventTimestamp: String(occurredAt),
|
|
231
|
+
eventTreeAvailable: "true", chatToolCallId: "tool-id:<exact>", eventToolPhase: "finish",
|
|
232
|
+
});
|
|
233
|
+
assert.equal(row.getAttribute("aria-keyshortcuts"), "ContextMenu Shift+F10");
|
|
234
|
+
assert.equal(row.children[0].className, "event-main");
|
|
235
|
+
assert.equal(row.children[0].children[0].textContent, `[${new Date(occurredAt).toLocaleTimeString()}]`);
|
|
236
|
+
assert.equal(summary(row), message);
|
|
237
|
+
assert.equal(row.children[0].children[1].childElementCount, 0);
|
|
238
|
+
const details = row.children[1];
|
|
239
|
+
assert.equal(details.className, "event-details");
|
|
240
|
+
assert.equal(details.childElementCount, 2);
|
|
241
|
+
assert.equal(details.children[0].textContent, `target: ${target}`);
|
|
242
|
+
assert.equal(details.children[0].children[0].className, "event-detail-label");
|
|
243
|
+
assert.equal(details.children[0].childNodes[1].nodeType, 3);
|
|
244
|
+
assert.equal(details.children[1].className, "event-detail error");
|
|
245
|
+
assert.equal(row.title, "Jump to this event in the chat; open the context menu for display options and Tree navigation");
|
|
246
|
+
assert.equal(row.getAttribute("aria-label"), `${row.textContent.trim()}. Jump to this event in the chat. Context menu: display options and Tree navigation.`);
|
|
247
|
+
assert.deepEqual(f.notices, [[message, "error"]]);
|
|
248
|
+
|
|
249
|
+
row.click();
|
|
250
|
+
details.children[0].children[0].click();
|
|
251
|
+
assert.equal(f.jumps.length, 2);
|
|
252
|
+
assert.equal(f.jumps[0], row);
|
|
253
|
+
assert.equal(f.jumps[1], row);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
test("keeps tool phase and Tree eligibility distinct and skips invalid or empty details", () => {
|
|
257
|
+
const f = fixture();
|
|
258
|
+
for (const [options, expected] of [
|
|
259
|
+
[{ toolCallId: " id ", toolEventPhase: "start" }, { eventTreeAvailable: "true", chatToolCallId: "id", eventToolPhase: "start" }],
|
|
260
|
+
[{ toolCallId: "id", toolEventPhase: "update", details: "not an array" }, { eventTreeAvailable: "false", chatToolCallId: "id" }],
|
|
261
|
+
[{ toolEventPhase: "finish", details: [{ label: "missing value" }] }, { eventTreeAvailable: "false", eventToolPhase: "finish" }],
|
|
262
|
+
[{ toolCallId: " " }, { eventTreeAvailable: "false" }],
|
|
263
|
+
]) {
|
|
264
|
+
f.controller.add("row", "info", options);
|
|
265
|
+
const row = f.rows()[0];
|
|
266
|
+
const { eventLevel, chatEventTimestamp, ...metadata } = row.dataset;
|
|
267
|
+
assert.equal(eventLevel, "info");
|
|
268
|
+
assert.ok(Number.isFinite(Number(chatEventTimestamp)));
|
|
269
|
+
assert.deepEqual(metadata, expected);
|
|
270
|
+
assert.equal(row.childElementCount, 1);
|
|
271
|
+
assert.equal(row.title.includes("and Tree navigation"), expected.eventTreeAvailable === "true");
|
|
272
|
+
assert.equal(row.getAttribute("aria-label").includes("and Tree navigation"), expected.eventTreeAvailable === "true");
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
test("prepends arrivals, caps retained DOM at 120 and leaves no listeners on evicted rows", () => {
|
|
277
|
+
const f = fixture();
|
|
278
|
+
f.controller.add("oldest");
|
|
279
|
+
const oldest = f.rows()[0];
|
|
280
|
+
for (let i = 0; i < 120; i += 1) f.controller.add(`event ${i}`);
|
|
281
|
+
assert.equal(f.rows().length, 120);
|
|
282
|
+
assert.equal(summary(f.rows()[0]), "event 119");
|
|
283
|
+
assert.equal(summary(f.rows().at(-1)), "event 0");
|
|
284
|
+
assert.equal(f.nodes.eventFilterStatus.textContent, "120 events");
|
|
285
|
+
assert.equal(oldest.parentNode, null);
|
|
286
|
+
assert.equal(oldest.clickListeners.size, 0);
|
|
287
|
+
oldest.click();
|
|
288
|
+
assert.deepEqual(f.jumps, []);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
test("aggregates from retained DOM, promotes replacement rows and preserves latest metadata", () => {
|
|
292
|
+
const f = fixture();
|
|
293
|
+
const options = { aggregateKey: " warnings ", aggregateSingular: "warning", aggregatePlural: "warnings" };
|
|
294
|
+
f.controller.add("Received", "warn", { ...options, occurredAt: 10 });
|
|
295
|
+
const original = f.rows()[0];
|
|
296
|
+
assert.equal(summary(original), "Received 1 warning");
|
|
297
|
+
f.controller.add("unrelated");
|
|
298
|
+
f.controller.add("Received", "error", {
|
|
299
|
+
...options, aggregateIncrement: 2.9, occurredAt: 20, toolCallId: "latest-call", toolEventPhase: "finish",
|
|
300
|
+
});
|
|
301
|
+
const replacement = f.rows()[0];
|
|
302
|
+
assert.equal(f.rows().length, 2);
|
|
303
|
+
assert.equal(summary(replacement), "Received 3 warnings");
|
|
304
|
+
assert.equal(replacement.dataset.eventAggregateKey, "warnings");
|
|
305
|
+
assert.equal(replacement.dataset.eventAggregateCount, "3");
|
|
306
|
+
assert.equal(replacement.dataset.chatEventTimestamp, "20");
|
|
307
|
+
assert.equal(replacement.dataset.chatToolCallId, "latest-call");
|
|
308
|
+
assert.equal(replacement.dataset.eventLevel, "error");
|
|
309
|
+
assert.equal(original.parentNode, null);
|
|
310
|
+
assert.equal(original.clickListeners.size, 0);
|
|
311
|
+
original.click();
|
|
312
|
+
replacement.click();
|
|
313
|
+
assert.deepEqual(f.jumps, [replacement]);
|
|
314
|
+
assert.deepEqual(f.notices, [["Received 1 warning", "warn"], ["Received 3 warnings", "error"]]);
|
|
315
|
+
assert.deepEqual(f.unreadChanges, [1, 2]);
|
|
316
|
+
f.controller.setFilter("warnings");
|
|
317
|
+
assert.equal(replacement.hidden, true);
|
|
318
|
+
assert.equal(f.nodes.eventFilterStatus.textContent, "0 of 2");
|
|
319
|
+
|
|
320
|
+
// The DOM is the sole history. Removing it retires the aggregate count.
|
|
321
|
+
replacement.remove();
|
|
322
|
+
f.controller.add("Received", "info", { ...options, aggregateIncrement: -4 });
|
|
323
|
+
assert.equal(summary(f.rows()[0]), "Received 1 warning");
|
|
324
|
+
f.controller.add("Received", "info", { ...options, aggregateIncrement: "bad", aggregatePlural: "" });
|
|
325
|
+
assert.equal(summary(f.rows()[0]), "Received 2 warning");
|
|
326
|
+
f.controller.add("plain summary", "info", { aggregateKey: "warnings", aggregateIncrement: 0 });
|
|
327
|
+
assert.equal(summary(f.rows()[0]), "plain summary");
|
|
328
|
+
assert.equal(f.rows()[0].dataset.eventAggregateCount, "3");
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
test("all five filters use row metadata, update on arrivals and expose counts and empty states", () => {
|
|
332
|
+
const f = fixture();
|
|
333
|
+
const c = f.controller;
|
|
334
|
+
c.setFilter("errors");
|
|
335
|
+
assert.equal(f.nodes.eventFilterEmpty.hidden, true);
|
|
336
|
+
c.add("ordinary");
|
|
337
|
+
assert.equal(f.nodes.eventFilterStatus.textContent, "0 of 1");
|
|
338
|
+
assert.equal(f.nodes.eventFilterEmpty.hidden, false);
|
|
339
|
+
assert.equal(f.nodes.eventFilterEmpty.textContent, "No events match errors / failures.");
|
|
340
|
+
c.add("failure", "error", { notify: false });
|
|
341
|
+
c.add("warning", "warn", { notify: false });
|
|
342
|
+
c.add("started", "info", { toolCallId: "start-id", toolEventPhase: "start" });
|
|
343
|
+
c.add("finished", "error", { toolCallId: "finish-id", toolEventPhase: "finish", notify: false });
|
|
344
|
+
c.add("phase only", "info", { toolEventPhase: "start" });
|
|
345
|
+
c.add("id only", "info", { toolCallId: "not-a-boundary" });
|
|
346
|
+
c.add("normalized level", " ERROR ", { notify: false });
|
|
347
|
+
const expected = {
|
|
348
|
+
all: ["normalized level", "id only", "phase only", "finished", "started", "warning", "failure", "ordinary"],
|
|
349
|
+
errors: ["normalized level", "finished", "failure"],
|
|
350
|
+
warnings: ["warning"],
|
|
351
|
+
tools: ["phase only", "finished", "started"],
|
|
352
|
+
tree: ["finished", "started"],
|
|
353
|
+
};
|
|
354
|
+
const rows = f.rows();
|
|
355
|
+
for (const [filter, messages] of Object.entries(expected)) {
|
|
356
|
+
c.setFilter(filter);
|
|
357
|
+
assert.deepEqual(f.rows().filter((row) => !row.hidden).map(summary), messages);
|
|
358
|
+
assert.equal(f.nodes.eventFilterStatus.textContent, filter === "all" ? "8 events" : `${messages.length} of 8`);
|
|
359
|
+
assert.equal(f.nodes.eventFilterEmpty.hidden, true);
|
|
360
|
+
for (let i = 0; i < rows.length; i += 1) assert.equal(f.rows()[i], rows[i]);
|
|
361
|
+
}
|
|
362
|
+
for (const row of f.rows()) row.remove();
|
|
363
|
+
c.syncUi();
|
|
364
|
+
assert.equal(f.nodes.eventFilterStatus.textContent, "No events yet");
|
|
365
|
+
assert.equal(f.nodes.eventFilterEmpty.hidden, true);
|
|
366
|
+
c.setFilter("all");
|
|
367
|
+
c.add("one");
|
|
368
|
+
assert.equal(f.nodes.eventFilterStatus.textContent, "1 event");
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
test("unread uses actual host visibility only and notifies on count changes", () => {
|
|
372
|
+
const f = fixture();
|
|
373
|
+
const c = f.controller;
|
|
374
|
+
assert.equal(f.nodes.eventsUnreadBadge.textContent, "0");
|
|
375
|
+
c.add("info");
|
|
376
|
+
c.add("success", "success");
|
|
377
|
+
c.add("quiet error", "error", { notify: false });
|
|
378
|
+
c.add("quiet warning", "warn", { notify: false });
|
|
379
|
+
assert.deepEqual(f.unreadChanges, []);
|
|
380
|
+
assert.deepEqual(f.notices, []);
|
|
381
|
+
c.add("hidden warning", "warn");
|
|
382
|
+
assert.equal(f.nodes.eventsUnreadBadge.textContent, "1");
|
|
383
|
+
assert.equal(f.nodes.eventsUnreadBadge.hidden, false);
|
|
384
|
+
assert.equal(f.nodes.eventsUnreadBadge.getAttribute("aria-label"), "1 unread warning or errors");
|
|
385
|
+
c.syncVisibility();
|
|
386
|
+
assert.equal(c.getSnapshot().unreadCount, 1);
|
|
387
|
+
|
|
388
|
+
f.setVisible(true);
|
|
389
|
+
c.add("visible error", "error");
|
|
390
|
+
assert.equal(c.getSnapshot().unreadCount, 1);
|
|
391
|
+
c.syncVisibility();
|
|
392
|
+
assert.equal(c.getSnapshot().unreadCount, 0);
|
|
393
|
+
assert.equal(f.nodes.eventsUnreadBadge.hidden, true);
|
|
394
|
+
assert.equal(f.nodes.eventsUnreadBadge.getAttribute("aria-label"), "0 unread warnings or errors");
|
|
395
|
+
c.syncVisibility();
|
|
396
|
+
c.clearUnread();
|
|
397
|
+
assert.deepEqual(f.unreadChanges, [1, 0]);
|
|
398
|
+
assert.deepEqual(f.notices, [["hidden warning", "warn"], ["visible error", "error"]]);
|
|
399
|
+
|
|
400
|
+
// A stale Classic wrapper must not override the parent's focused-host answer.
|
|
401
|
+
f.nodes.eventLog.hidden = true;
|
|
402
|
+
c.add("focused warning", "warn");
|
|
403
|
+
assert.equal(c.getSnapshot().unreadCount, 0);
|
|
404
|
+
f.nodes.eventLog.hidden = false;
|
|
405
|
+
f.setVisible(false);
|
|
406
|
+
c.setFilter("tools");
|
|
407
|
+
c.add("filtered error", "error");
|
|
408
|
+
assert.equal(f.rows()[0].hidden, true);
|
|
409
|
+
assert.equal(c.getSnapshot().unreadCount, 1);
|
|
410
|
+
c.clearUnread();
|
|
411
|
+
assert.deepEqual(f.unreadChanges, [1, 0, 1, 0]);
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
test("unread counts arrivals beyond the history limit and caps only the badge label", () => {
|
|
415
|
+
const f = fixture();
|
|
416
|
+
for (let i = 0; i < 125; i += 1) f.controller.add(`failure ${i}`, "error");
|
|
417
|
+
assert.equal(f.rows().length, 120);
|
|
418
|
+
assert.equal(f.controller.getSnapshot().unreadCount, 125);
|
|
419
|
+
assert.equal(f.nodes.eventsUnreadBadge.textContent, "99+");
|
|
420
|
+
assert.equal(f.nodes.eventsUnreadBadge.getAttribute("aria-label"), "125 unread warnings or errors");
|
|
421
|
+
assert.deepEqual(f.unreadChanges, Array.from({ length: 125 }, (_, i) => i + 1));
|
|
422
|
+
f.setVisible(true);
|
|
423
|
+
f.controller.syncVisibility();
|
|
424
|
+
assert.equal(f.nodes.eventsUnreadBadge.textContent, "0");
|
|
425
|
+
assert.equal(f.unreadChanges.at(-1), 0);
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
test("canonical rows and click targets survive host moves and UI synchronization", () => {
|
|
429
|
+
const f = fixture();
|
|
430
|
+
f.controller.add("canonical", "info", { toolCallId: "kept-id", toolEventPhase: "start" });
|
|
431
|
+
const row = f.rows()[0];
|
|
432
|
+
const content = f.document.createElement("div");
|
|
433
|
+
content.append(f.nodes.eventLog);
|
|
434
|
+
const classic = f.document.createElement("section");
|
|
435
|
+
const focused = f.document.createElement("section");
|
|
436
|
+
classic.append(content);
|
|
437
|
+
focused.append(content);
|
|
438
|
+
f.controller.setDisplayMode("compact");
|
|
439
|
+
f.controller.syncUi();
|
|
440
|
+
row.children[0].children[1].click();
|
|
441
|
+
classic.append(content);
|
|
442
|
+
f.controller.setDisplayMode("detailed");
|
|
443
|
+
f.controller.syncUi();
|
|
444
|
+
row.click();
|
|
445
|
+
assert.equal(f.rows()[0], row);
|
|
446
|
+
assert.equal(row.dataset.chatToolCallId, "kept-id");
|
|
447
|
+
assert.deepEqual(f.jumps, [row, row]);
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
test("dispose removes only owned listeners, retains nodes and makes every mutation a no-op", () => {
|
|
451
|
+
const f = fixture();
|
|
452
|
+
const c = f.controller;
|
|
453
|
+
c.add("kept", "warn");
|
|
454
|
+
c.setFilter("errors");
|
|
455
|
+
c.setDisplayMode("compact");
|
|
456
|
+
const row = f.rows()[0];
|
|
457
|
+
const snapshot = c.getSnapshot();
|
|
458
|
+
const writes = [...f.writes];
|
|
459
|
+
const notices = [...f.notices];
|
|
460
|
+
const changes = [...f.unreadChanges];
|
|
461
|
+
const rowText = row.textContent;
|
|
462
|
+
let parentClicks = 0;
|
|
463
|
+
row.addEventListener("click", () => { parentClicks += 1; });
|
|
464
|
+
assert.equal(row.clickListeners.size, 1);
|
|
465
|
+
assert.equal(f.nodes.eventLog.clickListeners.size, 1);
|
|
466
|
+
c.dispose();
|
|
467
|
+
c.dispose();
|
|
468
|
+
assert.equal(row.clickListeners.size, 1);
|
|
469
|
+
assert.equal(f.nodes.eventLog.clickListeners.size, 0);
|
|
470
|
+
row.click();
|
|
471
|
+
assert.equal(parentClicks, 1);
|
|
472
|
+
assert.deepEqual(f.jumps, []);
|
|
473
|
+
f.setVisible(true);
|
|
474
|
+
c.add("ignored", "error", { aggregateKey: "ignored" });
|
|
475
|
+
c.setFilter("all");
|
|
476
|
+
c.setDisplayMode("detailed");
|
|
477
|
+
c.clearUnread();
|
|
478
|
+
c.syncVisibility();
|
|
479
|
+
c.syncUi();
|
|
480
|
+
assert.deepEqual(c.getSnapshot(), snapshot);
|
|
481
|
+
assert.deepEqual(f.writes, writes);
|
|
482
|
+
assert.deepEqual(f.notices, notices);
|
|
483
|
+
assert.deepEqual(f.unreadChanges, changes);
|
|
484
|
+
assert.equal(f.rows().length, 1);
|
|
485
|
+
assert.equal(f.rows()[0], row);
|
|
486
|
+
assert.equal(row.textContent, rowText);
|
|
487
|
+
assert.equal(row.hidden, true);
|
|
488
|
+
assert.equal(f.nodes.eventFilterSelect.value, "errors");
|
|
489
|
+
assertDisplay(f.nodes, "compact");
|
|
490
|
+
assert.equal(f.nodes.eventsUnreadBadge.textContent, "1");
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
test("delegated navigation ignores the log background and retains no listener on detached rows", () => {
|
|
494
|
+
const f = fixture();
|
|
495
|
+
f.nodes.eventLog.click();
|
|
496
|
+
assert.deepEqual(f.jumps, []);
|
|
497
|
+
f.controller.add("detached");
|
|
498
|
+
const detached = f.rows()[0];
|
|
499
|
+
// A detail tone may share a class name; navigation must still use the row.
|
|
500
|
+
f.controller.add("nested", "info", { details: [{ label: "target", value: "safe", tone: "event" }] });
|
|
501
|
+
const canonical = f.rows()[0];
|
|
502
|
+
canonical.children[1].children[0].click();
|
|
503
|
+
assert.deepEqual(f.jumps, [canonical]);
|
|
504
|
+
detached.remove();
|
|
505
|
+
assert.equal(detached.clickListeners.size, 0);
|
|
506
|
+
f.controller.dispose();
|
|
507
|
+
detached.click();
|
|
508
|
+
canonical.click();
|
|
509
|
+
assert.deepEqual(f.jumps, [canonical]);
|
|
510
|
+
assert.equal(f.nodes.eventLog.clickListeners.size, 0);
|
|
511
|
+
});
|
|
@@ -4,9 +4,9 @@ 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 [app,
|
|
7
|
+
const [app, runnerService] = await Promise.all([
|
|
8
8
|
readFile(join(root, "public", "app.js"), "utf8"),
|
|
9
|
-
readFile(join(root, "
|
|
9
|
+
readFile(join(root, "lib", "server", "app-runners.mjs"), "utf8"),
|
|
10
10
|
]);
|
|
11
11
|
|
|
12
12
|
assert.match(
|
|
@@ -20,7 +20,7 @@ assert.match(
|
|
|
20
20
|
"app-runner terminal lines should apply supported ANSI styling and hide unsupported ANSI controls",
|
|
21
21
|
);
|
|
22
22
|
assert.match(
|
|
23
|
-
|
|
23
|
+
runnerService,
|
|
24
24
|
/consumeAppRunnerTerminalChunk\([\s\S]*carriageReturnPending/,
|
|
25
25
|
"server should preserve terminal-style carriage-return state across app-runner chunks",
|
|
26
26
|
);
|
|
@@ -17,18 +17,19 @@ const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "
|
|
|
17
17
|
const serverScript = path.join(packageRoot, "bin", "pi-webui.mjs");
|
|
18
18
|
const fakePiFixture = path.join(packageRoot, "tests", "fixtures", "fake-pi.mjs");
|
|
19
19
|
const serverSource = await readFile(serverScript, "utf8");
|
|
20
|
+
const rpcTransportSource = await readFile(new URL("../lib/server/rpc-transports.mjs", import.meta.url), "utf8");
|
|
20
21
|
|
|
21
|
-
function sourceBetween(startMarker, endMarker) {
|
|
22
|
-
const start =
|
|
23
|
-
const end =
|
|
22
|
+
function sourceBetween(startMarker, endMarker, source = serverSource) {
|
|
23
|
+
const start = source.indexOf(startMarker);
|
|
24
|
+
const end = source.indexOf(endMarker, start);
|
|
24
25
|
assert.ok(start >= 0 && end > start, `${startMarker} should remain extractable for lifecycle regression coverage`);
|
|
25
|
-
return
|
|
26
|
+
return source.slice(start, end);
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
async function assertDirectProcessLifecycle() {
|
|
29
30
|
const children = [];
|
|
30
31
|
const PiRpcProcess = vm.runInNewContext(`
|
|
31
|
-
${sourceBetween("class PiRpcProcess {", "\n
|
|
32
|
+
${sourceBetween(" class PiRpcProcess {", "\n\n return { PiRpcProcess, SupervisorPiRpcProcess };", rpcTransportSource)}
|
|
32
33
|
PiRpcProcess;
|
|
33
34
|
`, {
|
|
34
35
|
Buffer,
|
|
@@ -39,7 +40,7 @@ async function assertDirectProcessLifecycle() {
|
|
|
39
40
|
PI_RPC_JSONL_LINE_MAX_BYTES: 1024,
|
|
40
41
|
process: { env: {} },
|
|
41
42
|
randomUUID: () => "rpc-id",
|
|
42
|
-
|
|
43
|
+
requestTimeoutMs: 1000,
|
|
43
44
|
sanitizeError: (error) => error?.message || String(error),
|
|
44
45
|
setTimeout,
|
|
45
46
|
spawn: () => children.shift(),
|
|
@@ -73,20 +73,20 @@ assert.match(selector, /result\.changed === true && result\.restartRequired ===
|
|
|
73
73
|
assert.doesNotMatch(selector, /sendPrompt\("prompt", "\/reload"/, "the selector body must not reload the tab directly");
|
|
74
74
|
|
|
75
75
|
const restartBody = app.slice(app.indexOf("async function confirmAppendSystemRestart"));
|
|
76
|
-
assert.match(restartBody, /appConfirmText\([\s\S]*?confirmLabel: "Restart
|
|
76
|
+
assert.match(restartBody, /appConfirmText\([\s\S]*?confirmLabel: "Restart thread"/, "restart must be gated behind an explicit confirmation");
|
|
77
77
|
assert.match(restartBody, /if \(!confirmed\) return;/, "cancelling the confirmation must not restart the tab");
|
|
78
78
|
assert.match(restartBody, /sendPrompt\("prompt", "\/reload", \{ targetTabId: tabId, throwOnError: true \}\)/, "confirmed restart must reuse the standard active-tab reload path");
|
|
79
|
-
assert.match(restartBody, /Append-system
|
|
80
|
-
assert.match(restartBody, /Cancel keeps it for the next manual reload or new
|
|
79
|
+
assert.match(restartBody, /Append-system thread restart failed:/, "reload errors must remain visible in the events log");
|
|
80
|
+
assert.match(restartBody, /Cancel keeps it for the next manual reload or new thread/, "cancellation must be described as keeping the saved choice");
|
|
81
81
|
|
|
82
82
|
assert.match(
|
|
83
83
|
app,
|
|
84
|
-
/\{ kind: "Pi", label: "\/append-system", description: "Choose the APPEND_SYSTEM\.md append prompt", keywords: "append system prompt settings global", run: \(\) => openNativeAppendSystemSelector\(\) \},/,
|
|
84
|
+
/\{ id: "native:append-system", scope: "server", destination: "settings", kind: "Pi", label: "\/append-system", description: "Choose the APPEND_SYSTEM\.md append prompt", keywords: "append system prompt settings global", run: \(\) => openNativeAppendSystemSelector\(\) \},/,
|
|
85
85
|
"the command palette must expose the append-system selector",
|
|
86
86
|
);
|
|
87
87
|
|
|
88
|
-
assert.match(selector, /one global APPEND_SYSTEM\.md append prompt for WebUI-managed Pi
|
|
89
|
-
assert.match(selector, /bounded scan uses the active
|
|
88
|
+
assert.match(selector, /one global APPEND_SYSTEM\.md append prompt for WebUI-managed Pi threads/i, "the dialog must label the choice as a global WebUI setting");
|
|
89
|
+
assert.match(selector, /bounded scan uses the active thread folder and ~\/\.pi up to depth 10/i, "the dialog must describe the bounded scan roots and depth");
|
|
90
90
|
assert.match(selector, /follows file and folder links even outside those roots/i, "the dialog must warn that followed links can leave the visible roots");
|
|
91
91
|
assert.match(selector, /never shows file contents/i, "the dialog must promise no prompt content exposure");
|
|
92
92
|
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
+
|
|
3
4
|
import { dirname, join } from "node:path";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
5
6
|
|
|
7
|
+
const gitMutations = await readFile(new URL("../lib/server/git-mutations.mjs", import.meta.url), "utf8");
|
|
8
|
+
const fileService = await readFile(new URL("../lib/server/workspace-files.mjs", import.meta.url), "utf8");
|
|
9
|
+
|
|
10
|
+
const fileOwner = await readFile(new URL("../public/project-file-viewer-controller.mjs", import.meta.url), "utf8");
|
|
6
11
|
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
12
|
const [app, css, pkg, server, payloadParser, optionalFeatureCatalog] = await Promise.all([
|
|
8
13
|
readFile(join(root, "public", "app.js"), "utf8"),
|
|
@@ -22,7 +27,7 @@ assert.match(payloadParser, /stagedPayload \? decision\.reviewedStagedContentHas
|
|
|
22
27
|
assert.match(payloadParser, /payload\.changedFiles\.length >= payload\.changedFileTotal/, "payload parsing should reject equality at the truncated-file boundary");
|
|
23
28
|
assert.match(app, /function renderAurReviewWidget\(\)[\s\S]*Review changes[\s\S]*Refresh[\s\S]*Approve[\s\S]*Decline[\s\S]*Close[\s\S]*openAurReviewReportInViewer\(reportPath, payload\.repoRoot\)/, "renderer should open reports against the payload's repo root rather than the tab cwd");
|
|
24
29
|
assert.match(app, /payload\.origin === "guided-git" && payload\.scope === "staged" && payload\.decision\.state === "approved"[\s\S]*return null/, "an approved Guided Git staged review should close its manual review card");
|
|
25
|
-
assert.match(
|
|
30
|
+
assert.match(fileOwner, /async function openReport\(path = "", repoRoot = ""\)[\s\S]*\/api\/aur-review\/report-content[\s\S]*readOnly: true/s, "report viewing must use the narrow read-only canonical-root endpoint");
|
|
26
31
|
assert.match(app, /viewer\.readOnly === true \|\| !viewer\.dirty[\s\S]*viewer\.readOnly === true \|\| !viewerPath/s, "repo-root report views must not enable generic save or default-editor actions");
|
|
27
32
|
assert.match(app, /function aurReviewActionButton\(label, action, className = ""\)[\s\S]*action === "review"[\s\S]*openGitChangesDialog\(\)[\s\S]*`\/aur-review \$\{action\}`/, "Review changes should reuse the current Git diff dialog and other controls should call canonical extension commands");
|
|
28
33
|
assert.match(app, /aurReviewActionButton\("Approve", "approve", "primary"\)/, "Approve should delegate to the extension slash command, which owns native confirmation");
|
|
@@ -34,7 +39,10 @@ assert.equal(JSON.parse(pkg).optionalDependencies?.["@firstpick/pi-extension-aur
|
|
|
34
39
|
assert.equal(JSON.parse(pkg).pi?.extensions?.some((entry) => String(entry).includes("pi-extension-aur-review")), false, "WebUI must not bundle an unpublished nested review extension path");
|
|
35
40
|
assert.match(optionalFeatureCatalog, /\["aurReview", "@firstpick\/pi-extension-aur-review", "\^0\.1\.1"\]/, "optional-feature catalog should retain the future/local review companion mapping without bundling it");
|
|
36
41
|
assert.match(server, /STATIC_PUBLIC_FILE_EXTENSIONS[\s\S]*"\.mjs"/, "server must serve typed browser modules from the public asset boundary");
|
|
37
|
-
assert.match(
|
|
38
|
-
assert.match(server, /
|
|
42
|
+
assert.match(gitMutations, /STAGED_CONTENT_HASH_DOMAIN = "firstpick\/aur-review\/staged-content\/v1\\0"[\s\S]*git diff --cached/, "Git mutation service must retain the bounded read-only staged-content hash helper");
|
|
43
|
+
assert.match(server, /case "\/api\/git-workflow\/staged-content":[\s\S]*stagedContentHashForTab\(tab\)/, "the read route must use the requested tab and canonical staged hash owner");
|
|
44
|
+
assert.match(fileService, /async function getAurReviewReportContentData\(tab, \{ path: requestedPath = "", repoRoot = "" \} = \{\}\)[\s\S]*repoRoot !== root[\s\S]*lstat\(targetPath\)[\s\S]*isSymbolicLink\(\)[\s\S]*readBoundedAurReviewReport/s, "server must bind report reads to the canonical Git root and reject symlinked paths in the Files owner");
|
|
45
|
+
assert.match(server, /url\.pathname === "\/api\/aur-review\/report-content" && req\.method === "GET"[\s\S]*getRequestedTab\(req, url\)[\s\S]*data: await getAurReviewReportContentData\(tab,/, "the read-only report route should call the Files owner with its requested tab");
|
|
39
46
|
assert.match(server, /entry\.name\.startsWith\("pi-"\)[\s\S]*packageNameForResourcePath\(path\.join\(candidate, "package\.json"\)\)/, "workspace optional-package discovery must recognize the pi-extension-aur-review sibling by manifest name");
|
|
47
|
+
assert.match(app, /const normalized = aurReviewSafePath\(path\);[\s\S]*projectFiles.openReport\(normalized, String\(repoRoot\)\)/);
|
|
40
48
|
console.log("aur review widget static tests passed");
|