@firstpick/pi-package-webui 0.11.1 → 0.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DEVELOPMENT.md +151 -12
- package/README.md +34 -6
- package/TECHNICAL.md +75 -8
- package/bin/pi-webui.mjs +5390 -11423
- package/index.ts +10 -3
- package/lib/component-update-state.mjs +2 -2
- package/lib/git-workflow-preference-values.mjs +122 -0
- package/lib/git-workflow-preferences.mjs +35 -563
- package/lib/package-updates.mjs +260 -0
- package/lib/rpc-supervisor-client.mjs +8 -4
- package/lib/server/app-runners.mjs +1667 -0
- package/lib/server/codex-fast-mode.mjs +161 -0
- package/lib/server/conversation-mode.mjs +218 -0
- package/lib/server/conversation-voice.mjs +318 -0
- package/lib/server/extension-ui-requests.mjs +114 -0
- package/lib/server/git-generation.mjs +459 -0
- package/lib/server/git-mutations.mjs +1827 -0
- package/lib/server/git-reads.mjs +608 -0
- package/lib/server/git-worktree-sessions.mjs +408 -0
- package/lib/server/helper-requests.mjs +82 -0
- package/lib/server/no-project-workspaces.mjs +103 -0
- package/lib/server/rpc-transports.mjs +394 -0
- package/lib/server/settings-store.mjs +544 -0
- package/lib/server/sse-delivery.mjs +138 -0
- package/lib/server/workspace-files.mjs +563 -0
- package/lib/update/supervisor.mjs +4 -0
- package/lib/webui-workspaces.mjs +2 -0
- package/package.json +4 -4
- package/public/activity-agents-controller.mjs +269 -0
- package/public/activity-events-controller.mjs +236 -0
- package/public/activity-intercom-controller.mjs +627 -0
- package/public/activity-queue-controller.mjs +534 -0
- package/public/activity-todo-view.mjs +89 -0
- package/public/activity-usage-controller.mjs +589 -0
- package/public/app.js +3761 -3886
- package/public/conversation-overview.css +84 -0
- package/public/conversation-overview.mjs +193 -0
- package/public/draft-conversations.mjs +135 -0
- package/public/focused-composer-controls.css +111 -0
- package/public/focused-composer-controls.mjs +143 -0
- package/public/focused-composer-disclosure.mjs +223 -0
- package/public/focused-shell-adapter.css +264 -0
- package/public/focused-shell-adapter.mjs +257 -0
- package/public/index.html +137 -80
- package/public/model-catalog-order.mjs +63 -0
- package/public/platform-event-stream.mjs +64 -0
- package/public/project-artifact-controller.mjs +218 -0
- package/public/project-file-viewer-controller.mjs +383 -0
- package/public/project-git-tools-controller.mjs +181 -0
- package/public/project-runners-controller.mjs +220 -0
- package/public/service-worker.js +52 -1
- package/public/session-attention-scheduler.mjs +182 -0
- package/public/session-composer-store.mjs +56 -0
- package/public/session-context.mjs +51 -0
- package/public/session-extension-requests.mjs +63 -0
- package/public/session-shelf-state.mjs +151 -0
- package/public/session-shelves.css +171 -0
- package/public/session-shelves.mjs +95 -0
- package/public/settings-navigation-controller.mjs +249 -0
- package/public/settings-navigation.css +61 -0
- package/public/settings-resource-controller.mjs +232 -0
- package/public/settings-workspace.css +19 -0
- package/public/settings-workspace.mjs +175 -0
- package/public/shell-actions.mjs +87 -0
- package/public/shell-attention-inbox.css +72 -0
- package/public/shell-attention-inbox.mjs +198 -0
- package/public/shell-context-actions.css +61 -0
- package/public/shell-context-actions.mjs +168 -0
- package/public/shell-inspector-resize.mjs +124 -0
- package/public/shell-navigation-resize.mjs +107 -0
- package/public/shell-navigation.mjs +127 -0
- package/public/shell-preferences.mjs +108 -0
- package/public/shell-surfaces.mjs +99 -0
- package/public/shell-tools-launcher.css +97 -0
- package/public/shell-tools-launcher.mjs +222 -0
- package/public/shell-view-host.mjs +115 -0
- package/public/shell-workspace.css +266 -0
- package/public/shell-workspace.mjs +402 -0
- package/public/sidebar-update-menu.css +190 -0
- package/public/sidebar-update-menu.mjs +512 -0
- package/public/styles.css +322 -169
- package/public/subagent-launch-slot-state.mjs +2 -2
- package/public/themed-selects.css +156 -0
- package/public/workspace-choices.mjs +104 -0
- package/tests/activity-agents-controller.test.mjs +652 -0
- package/tests/activity-events-controller.test.mjs +511 -0
- package/tests/app-runner-terminal-static.test.mjs +3 -3
- package/tests/append-system-http.test.mjs +7 -6
- package/tests/append-system-selector-static.test.mjs +6 -6
- package/tests/aur-review-widget-static.test.mjs +11 -3
- package/tests/boot-failure-diagnostics.test.mjs +8 -3
- package/tests/browser/action-feedback-gutter.spec.mjs +251 -0
- package/tests/browser/activity-intercom-controller.spec.mjs +457 -0
- package/tests/browser/activity-navigation-integration.spec.mjs +45 -0
- package/tests/browser/activity-owner-integration.spec.mjs +201 -0
- package/tests/browser/activity-queue-controller.spec.mjs +405 -0
- package/tests/browser/activity-section-picker.spec.mjs +294 -0
- package/tests/browser/activity-todo-view.spec.mjs +60 -0
- package/tests/browser/activity-usage-controller.spec.mjs +416 -0
- package/tests/browser/compact-layout-integration.spec.mjs +58 -0
- package/tests/browser/composer-action-grid-reorder.spec.mjs +16 -0
- package/tests/browser/composer-disclosure.spec.mjs +389 -0
- package/tests/browser/composer-toolbar-polish.spec.mjs +343 -0
- package/tests/browser/control-deck-component-updates.spec.mjs +5 -14
- package/tests/browser/control-deck-side-panels.spec.mjs +27 -12
- package/tests/browser/control-visibility.spec.mjs +5 -0
- package/tests/browser/controls-layout.spec.mjs +21 -2
- package/tests/browser/conversation-overview.spec.mjs +251 -0
- package/tests/browser/draft-conversations.spec.mjs +276 -0
- package/tests/browser/empty-startup-fixture.mjs +135 -0
- package/tests/browser/empty-startup.spec.mjs +282 -0
- package/tests/browser/events-tree-context-menu.spec.mjs +1 -0
- package/tests/browser/focused-composer-more.spec.mjs +127 -0
- package/tests/browser/focused-model-shortcuts.spec.mjs +120 -0
- package/tests/browser/focused-navigation-fixture.mjs +32 -0
- package/tests/browser/focused-project-activity.spec.mjs +111 -0
- package/tests/browser/focused-shell-integration.spec.mjs +208 -0
- package/tests/browser/folder-picker-layout-fixture.mjs +13 -0
- package/tests/browser/folder-picker-layout.spec.mjs +302 -0
- package/tests/browser/footer-model-advanced-layout.spec.mjs +27 -14
- package/tests/browser/git-setup-cancel.spec.mjs +251 -0
- package/tests/browser/guided-git-fallback.spec.mjs +40 -21
- package/tests/browser/inspector-header.spec.mjs +221 -0
- package/tests/browser/inspector-overview-integration.spec.mjs +104 -0
- package/tests/browser/inspector-resize.spec.mjs +227 -0
- package/tests/browser/inspector-topic-overflow.spec.mjs +56 -0
- package/tests/browser/interaction-action-discovery.spec.mjs +332 -0
- package/tests/browser/interaction-attention-inbox.spec.mjs +364 -0
- package/tests/browser/interaction-attention-integration.spec.mjs +53 -0
- package/tests/browser/interaction-composer-controls.spec.mjs +267 -0
- package/tests/browser/interaction-composer-integration.spec.mjs +175 -0
- package/tests/browser/interaction-continuity.spec.mjs +50 -26
- package/tests/browser/interaction-model-picker.spec.mjs +86 -0
- package/tests/browser/last-terminal-close.spec.mjs +280 -0
- package/tests/browser/mobile-foundation.spec.mjs +172 -20
- package/tests/browser/model-catalog-groups.spec.mjs +104 -0
- package/tests/browser/more-row-menus.spec.mjs +258 -0
- package/tests/browser/new-tab-hit-target.spec.mjs +228 -0
- package/tests/browser/no-project-conversation.spec.mjs +113 -0
- package/tests/browser/optimistic-prompt.spec.mjs +3 -0
- package/tests/browser/overhaul-w7-accessibility.spec.mjs +227 -0
- package/tests/browser/overhaul-w7-capabilities.spec.mjs +298 -0
- package/tests/browser/overhaul-w7-companions.spec.mjs +290 -0
- package/tests/browser/overhaul-w7-focus-repairs.spec.mjs +210 -0
- package/tests/browser/overhaul-w7-layout-repairs.spec.mjs +183 -0
- package/tests/browser/overhaul-w7-parent-repairs.spec.mjs +97 -0
- package/tests/browser/overhaul-w7-pwa.spec.mjs +247 -0
- package/tests/browser/overhaul-w7-responsive.spec.mjs +450 -0
- package/tests/browser/overhaul-w7-update.spec.mjs +215 -0
- package/tests/browser/overhaul-w7-zoom.spec.mjs +243 -0
- package/tests/browser/overview-agent-ownership.spec.mjs +45 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +3 -0
- package/tests/browser/project-artifact-controller.spec.mjs +324 -0
- package/tests/browser/project-artifact-integration.spec.mjs +103 -0
- package/tests/browser/project-file-buffer-integration.spec.mjs +230 -0
- package/tests/browser/project-git-tools-integration.spec.mjs +369 -0
- package/tests/browser/session-fixture.mjs +118 -0
- package/tests/browser/session-ownership.spec.mjs +175 -0
- package/tests/browser/session-shelves-integration.spec.mjs +219 -0
- package/tests/browser/session-shelves.spec.mjs +340 -0
- package/tests/browser/session-sidebar-resize.spec.mjs +138 -0
- package/tests/browser/session-summary.spec.mjs +17 -12
- package/tests/browser/settings-complete-home.spec.mjs +463 -0
- package/tests/browser/settings-entrypoint.spec.mjs +104 -0
- package/tests/browser/settings-navigation-controller.spec.mjs +383 -0
- package/tests/browser/settings-navigation-integration.spec.mjs +348 -0
- package/tests/browser/settings-resource-lifetime.spec.mjs +349 -0
- package/tests/browser/settings-workspace-integration.spec.mjs +132 -0
- package/tests/browser/shell-ownership.spec.mjs +398 -0
- package/tests/browser/shell-rollout-fixture.mjs +259 -0
- package/tests/browser/shell-rollout.spec.mjs +357 -0
- package/tests/browser/shell-tools-launcher.spec.mjs +260 -0
- package/tests/browser/shell-workspace.spec.mjs +433 -0
- package/tests/browser/side-panel-section-reorder.spec.mjs +3 -1
- package/tests/browser/sidebar-floating-tooltips.spec.mjs +37 -0
- package/tests/browser/sidebar-update-integration.spec.mjs +277 -0
- package/tests/browser/sidebar-update-menu.spec.mjs +402 -0
- package/tests/browser/sidebar-update-progress.spec.mjs +472 -0
- package/tests/browser/stream-output-isolation.spec.mjs +6 -3
- package/tests/browser/themed-selects.spec.mjs +297 -0
- package/tests/browser/thread-start-flow.spec.mjs +481 -0
- package/tests/browser/ui-polish-activity-controls.spec.mjs +177 -0
- package/tests/browser/ui-polish-features.spec.mjs +85 -0
- package/tests/browser/ui-polish-file-header.spec.mjs +43 -0
- package/tests/browser/ui-polish-local-git.spec.mjs +183 -0
- package/tests/browser/ui-polish-mobile-recovery.spec.mjs +36 -0
- package/tests/browser/ui-polish-navigation.spec.mjs +127 -0
- package/tests/browser/ui-polish-session-actions.spec.mjs +282 -0
- package/tests/browser/user-noticeable-fixes.spec.mjs +10 -3
- package/tests/browser/windows-drive-parent.spec.mjs +4 -2
- package/tests/browser/workspace-draft-selection.spec.mjs +266 -0
- package/tests/codex-fast-mode-static.test.mjs +16 -11
- package/tests/codex-speed-mode-browser-state.test.mjs +6 -3
- package/tests/codex-usage-source.test.mjs +4 -3
- package/tests/component-update-api-static.test.mjs +2 -2
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-deck-component-updates-static.test.mjs +9 -4
- package/tests/control-visibility-static.test.mjs +3 -3
- package/tests/controls-layout-static.test.mjs +5 -5
- package/tests/conversation-overview-adapter.test.mjs +100 -0
- package/tests/document-artifact-static.test.mjs +2 -1
- package/tests/draft-conversations.test.mjs +205 -0
- package/tests/empty-startup-launcher.test.mjs +197 -0
- package/tests/events-tree-context-menu-static.test.mjs +22 -18
- package/tests/fake-pi-session-ownership.test.mjs +302 -0
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/feature-system-prompt-optional-feature-static.test.mjs +1 -1
- package/tests/file-viewer-image-static.test.mjs +15 -11
- package/tests/file-viewer-search-static.test.mjs +5 -5
- package/tests/fixtures/fake-pi.mjs +41 -9
- package/tests/footer-provider-usage-visual-static.test.mjs +7 -6
- package/tests/foreground-transcript-catch-up-static.test.mjs +7 -4
- package/tests/git-footer-context-menu-static.test.mjs +1 -1
- package/tests/git-panel-file-preview-static.test.mjs +41 -48
- package/tests/git-panel-live-updates-static.test.mjs +2 -1
- package/tests/git-workflow-dispatch.test.mjs +66 -0
- package/tests/git-workflow-preferences.test.mjs +9 -1
- package/tests/guided-git-activation-static.test.mjs +14 -11
- package/tests/guided-git-fallback-ui-static.test.mjs +8 -5
- package/tests/guided-git-message-reliability-static.test.mjs +10 -6
- package/tests/guided-git-publication-backend-static.test.mjs +16 -11
- package/tests/http-endpoints-harness.test.mjs +21 -9
- package/tests/interaction-state-stability-static.test.mjs +4 -3
- package/tests/intercom-conversation-viewer-static.test.mjs +29 -17
- package/tests/intercom-tag-layout-static.test.mjs +13 -12
- package/tests/intercom-tag-overflow-layout.test.mjs +11 -10
- package/tests/main-output-loading-static.test.mjs +4 -4
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-compact-layout.test.mjs +2 -2
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +10 -7
- package/tests/mobile-phone-experience-static.test.mjs +3 -2
- package/tests/mobile-static.test.mjs +173 -135
- package/tests/model-catalog-order.test.mjs +103 -0
- package/tests/native-parity.test.mjs +6 -4
- package/tests/native-session-choice-owner.test.mjs +102 -0
- package/tests/native-update-lifecycle.test.mjs +10 -5
- package/tests/no-project-http-harness.test.mjs +328 -0
- package/tests/no-project-navigation.test.mjs +54 -0
- package/tests/no-project-workspaces.test.mjs +77 -0
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/optional-feature-migration-frontend.test.mjs +4 -4
- package/tests/optional-feature-prompt-impact-static.test.mjs +3 -3
- package/tests/package-updates.test.mjs +630 -0
- package/tests/persistent-ui-layout-static.test.mjs +3 -3
- package/tests/platform-event-stream.test.mjs +253 -0
- package/tests/project-file-viewer-controller.test.mjs +652 -0
- package/tests/project-git-tools-adapter.test.mjs +103 -0
- package/tests/project-git-tools-controller.test.mjs +577 -0
- package/tests/project-runners-controller.test.mjs +453 -0
- package/tests/prompt-input-vertical-scroll-static.test.mjs +3 -3
- package/tests/prompt-routing-input-clear-static.test.mjs +2 -2
- package/tests/questionnaire-dialog.test.mjs +6 -6
- package/tests/queue-edit-reorder-static.test.mjs +48 -51
- package/tests/rpc-supervisor-host.test.mjs +4 -1
- package/tests/safety-guard-auto-review-static.test.mjs +1 -1
- package/tests/sampling-native-controls-user-flow.test.mjs +7 -1
- package/tests/server-app-runners.test.mjs +536 -0
- package/tests/server-codex-fast-mode.test.mjs +346 -0
- package/tests/server-conversation-mode.test.mjs +386 -0
- package/tests/server-conversation-voice.test.mjs +426 -0
- package/tests/server-extension-ui-requests.test.mjs +357 -0
- package/tests/server-git-generation.test.mjs +558 -0
- package/tests/server-git-mutations.test.mjs +729 -0
- package/tests/server-git-reads.test.mjs +381 -0
- package/tests/server-git-worktree-sessions.test.mjs +502 -0
- package/tests/server-helper-requests.test.mjs +364 -0
- package/tests/server-rpc-transports.test.mjs +553 -0
- package/tests/server-settings-store.test.mjs +132 -0
- package/tests/server-shell-rollout.test.mjs +478 -0
- package/tests/server-sse-delivery.test.mjs +410 -0
- package/tests/server-workspace-files.test.mjs +546 -0
- package/tests/session-attention-scheduler.test.mjs +514 -0
- package/tests/session-composer-store.test.mjs +153 -0
- package/tests/session-context.test.mjs +134 -0
- package/tests/session-extension-requests.test.mjs +193 -0
- package/tests/session-ownership-adapter.test.mjs +130 -0
- package/tests/session-sampling-ui-static.test.mjs +10 -4
- package/tests/session-send-lifetime.test.mjs +140 -0
- package/tests/session-shelf-state.test.mjs +348 -0
- package/tests/session-shelves-adapter.test.mjs +79 -0
- package/tests/session-summary-lifetime.test.mjs +54 -0
- package/tests/settings-resource-controller.test.mjs +548 -0
- package/tests/shell-action-adapter.test.mjs +169 -0
- package/tests/shell-actions.test.mjs +182 -0
- package/tests/shell-navigation.test.mjs +348 -0
- package/tests/shell-preferences.test.mjs +367 -0
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/stream-output-isolation-static.test.mjs +1 -1
- package/tests/subagent-gate-visibility.test.mjs +1 -1
- package/tests/subagent-launch-slot-state.test.mjs +2 -2
- package/tests/subagent-launch-slots-static.test.mjs +1 -1
- package/tests/subagent-observability-static.test.mjs +2 -2
- package/tests/subagent-reliability-integration.test.mjs +13 -30
- package/tests/syntax-highlighting-static.test.mjs +3 -3
- package/tests/tab-close-continuity-static.test.mjs +1 -1
- package/tests/tab-metadata-ordering.test.mjs +99 -0
- package/tests/terminal-cwd-grouping-static.test.mjs +2 -2
- package/tests/terminal-tab-prompt-tooltip-static.test.mjs +2 -0
- package/tests/terminal-tab-workspace-static.test.mjs +5 -4
- package/tests/terminal-tabs-resize-static.test.mjs +1 -1
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/thread-display-title.test.mjs +44 -0
- package/tests/update-api-harness.test.mjs +15 -14
- package/tests/update-tab-restore-harness.test.mjs +3 -0
- package/tests/webui-settings-locking.test.mjs +2 -2
- package/tests/windows-drive-cwd-picker-static.test.mjs +7 -9
- package/tests/workspace-choices.test.mjs +114 -0
- package/tests/workspace-save-load-static.test.mjs +7 -4
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { expect, test } from '@playwright/test';
|
|
3
|
+
|
|
4
|
+
test.use({ video: 'off' });
|
|
5
|
+
if (process.env.PI_WEBUI_TEST_CHROMIUM) {
|
|
6
|
+
test.use({ launchOptions: { executablePath: process.env.PI_WEBUI_TEST_CHROMIUM } });
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const sources = new Map(await Promise.all([
|
|
10
|
+
'conversation-overview.mjs', 'conversation-overview.css', 'styles.css',
|
|
11
|
+
].map(async name => [`/${name}`, await readFile(new URL(`../../public/${name}`, import.meta.url), 'utf8')])));
|
|
12
|
+
|
|
13
|
+
const fixture = `<!doctype html><html lang="en"><head><title>Conversation overview component fixture</title>
|
|
14
|
+
<link rel="stylesheet" href="/styles.css"><link rel="stylesheet" href="/conversation-overview.css">
|
|
15
|
+
<style>
|
|
16
|
+
body { background: var(--bg); background-image: none; }
|
|
17
|
+
body::before, body::after { display: none; }
|
|
18
|
+
#conversation { position: relative; width: 100%; height: 100dvh; padding: 18px; }
|
|
19
|
+
#host { position: absolute; inset: 12px 12px 90px; pointer-events: none; display: flex; justify-content: flex-end; align-items: flex-start; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
|
|
20
|
+
#draft { position: absolute; bottom: 12px; left: 12px; width: calc(100% - 24px); height: 60px;
|
|
21
|
+
min-height: 0; background: var(--panel-3); color: var(--text); }
|
|
22
|
+
html[data-fixture-theme="light"] { --bg: #eff1f5; --text: #4c4f69; --muted: #5c5f77;
|
|
23
|
+
--panel-2: rgba(204, 208, 218, 0.78); --panel-3: rgba(230, 233, 239, 0.94);
|
|
24
|
+
--border: rgba(92, 95, 119, 0.26); --accent: #8839ef; --shadow: rgba(76, 79, 105, 0.16); }
|
|
25
|
+
</style></head><body><main id="conversation"><div id="host"></div>
|
|
26
|
+
<textarea id="draft" aria-label="Message Pi">Keep this unfinished prompt.</textarea></main>
|
|
27
|
+
<script type="module">
|
|
28
|
+
import { createConversationOverview } from '/conversation-overview.mjs';
|
|
29
|
+
window.events = [];
|
|
30
|
+
window.closeCount = 0;
|
|
31
|
+
window.overview = createConversationOverview({ document,
|
|
32
|
+
onAction: (actionId, target) => events.push({ actionId, target }), onClose: () => closeCount++ });
|
|
33
|
+
document.getElementById('host').append(overview.element);
|
|
34
|
+
window.state = { open: true, title: 'Overview', context: 'Isolated component fixture', target: { session: 'fixture-a' }, sections: [
|
|
35
|
+
{ id: 'workspace', label: 'Workspace & Git', items: [
|
|
36
|
+
{ id: 'directory', label: 'Workspace', value: 'Fixture workspace', actionId: 'workspace' },
|
|
37
|
+
{ id: 'branch', label: 'Branch', value: 'fixture/overview', detail: 'Git status unavailable in this fixture' }] },
|
|
38
|
+
{ id: 'runners', label: 'Runners', items: [
|
|
39
|
+
{ id: 'runner', label: 'Preview', value: 'Unavailable', actionId: 'runners', disabled: true, reason: 'No runner supplied' }] },
|
|
40
|
+
{ id: 'agents', label: 'Agents', items: [
|
|
41
|
+
{ id: 'agent', label: 'Agents', value: 'Unknown', actionId: 'agents' }] },
|
|
42
|
+
{ id: 'usage', label: 'Usage', items: [
|
|
43
|
+
{ id: 'context', label: 'Context', value: '32%', progress: 32 },
|
|
44
|
+
{ id: 'quota', label: 'Quota', value: null, detail: 'No provider usage supplied' }] }] };
|
|
45
|
+
window.render = patch => { state = { ...state, ...patch }; overview.update(state); };
|
|
46
|
+
document.getElementById('draft').focus();
|
|
47
|
+
render({});
|
|
48
|
+
window.ready = true;
|
|
49
|
+
</script></body></html>`;
|
|
50
|
+
|
|
51
|
+
test.beforeEach(async ({ page }) => {
|
|
52
|
+
await page.route('http://overview.test/**', async route => {
|
|
53
|
+
const pathname = new URL(route.request().url()).pathname;
|
|
54
|
+
const source = sources.get(pathname);
|
|
55
|
+
await route.fulfill({
|
|
56
|
+
status: source || pathname === '/' ? 200 : 404,
|
|
57
|
+
contentType: pathname.endsWith('.mjs') ? 'text/javascript' : pathname.endsWith('.css') ? 'text/css' : 'text/html',
|
|
58
|
+
body: source ?? (pathname === '/' ? fixture : 'Not found'),
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
await page.goto('http://overview.test/');
|
|
62
|
+
await page.waitForFunction(() => window.ready);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('nonmodal labelled card preserves draft focus, reports unknown data and disabled reasons', async ({ page }) => {
|
|
66
|
+
const region = page.getByRole('region', { name: 'Conversation overview', exact: true });
|
|
67
|
+
await expect(region).toBeVisible();
|
|
68
|
+
await expect(page.getByRole('dialog')).toHaveCount(0);
|
|
69
|
+
await expect(page.getByRole('textbox', { name: 'Message Pi' })).toBeFocused();
|
|
70
|
+
await expect(region.getByText('Unknown', { exact: true })).toHaveCount(2);
|
|
71
|
+
await expect(page.getByRole('button', { name: 'Open Preview', exact: true })).toBeDisabled();
|
|
72
|
+
await expect(region.getByText('No runner supplied', { exact: true })).toBeVisible();
|
|
73
|
+
await expect(page.getByRole('button', { name: 'Open Preview' })).toHaveAttribute('aria-description', 'No runner supplied');
|
|
74
|
+
await expect(region.getByRole('button')).toHaveCount(4);
|
|
75
|
+
await page.getByRole('button', { name: 'Open Preview' }).dispatchEvent('click');
|
|
76
|
+
expect(await page.evaluate(() => events)).toEqual([]);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('keyed updates and reordering preserve focused nodes, with the latest action and target', async ({ page }) => {
|
|
80
|
+
await page.getByRole('button', { name: 'Open Agents', exact: true }).focus();
|
|
81
|
+
await page.evaluate(() => {
|
|
82
|
+
window.originalAction = document.activeElement;
|
|
83
|
+
window.originalSection = originalAction.closest('.conversation-overview-section');
|
|
84
|
+
render({ target: { session: 'fixture-b' }, sections: [...state.sections].reverse().map(section => ({
|
|
85
|
+
...section, items: [...section.items].reverse().map(item => item.id === 'agent'
|
|
86
|
+
? { ...item, value: 'Updated', actionId: 'inspect-agents' } : item),
|
|
87
|
+
})) });
|
|
88
|
+
});
|
|
89
|
+
await expect(page.getByRole('button', { name: 'Open Agents', exact: true })).toBeFocused();
|
|
90
|
+
expect(await page.evaluate(() => originalAction === document.activeElement
|
|
91
|
+
&& originalSection === originalAction.closest('.conversation-overview-section'))).toBe(true);
|
|
92
|
+
await page.keyboard.press('Enter');
|
|
93
|
+
expect(await page.evaluate(() => events)).toEqual([{ actionId: 'inspect-agents', target: { session: 'fixture-b' } }]);
|
|
94
|
+
await page.getByRole('textbox').focus();
|
|
95
|
+
await page.evaluate(() => render({ context: 'Another update' }));
|
|
96
|
+
await expect(page.getByRole('textbox')).toBeFocused();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('fallback DOM reordering preserves focus without stealing it from outside', async ({ page }) => {
|
|
100
|
+
await page.evaluate(() => { Element.prototype.moveBefore = undefined; });
|
|
101
|
+
await page.getByRole('button', { name: 'Open Workspace', exact: true }).focus();
|
|
102
|
+
await page.evaluate(() => render({ sections: [...state.sections].reverse().map(section => ({
|
|
103
|
+
...section, items: [...section.items].reverse(),
|
|
104
|
+
})) }));
|
|
105
|
+
await expect(page.getByRole('button', { name: 'Open Workspace', exact: true })).toBeFocused();
|
|
106
|
+
await page.getByRole('textbox').focus();
|
|
107
|
+
await page.evaluate(() => render({ sections: [...state.sections].reverse() }));
|
|
108
|
+
await expect(page.getByRole('textbox')).toBeFocused();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('Escape belongs to the focused card, respects handled events, and close never steals draft focus', async ({ page }) => {
|
|
112
|
+
await page.keyboard.press('Escape');
|
|
113
|
+
expect(await page.evaluate(() => closeCount)).toBe(0);
|
|
114
|
+
await page.getByRole('button', { name: 'Open Workspace', exact: true }).focus();
|
|
115
|
+
await page.evaluate(() => {
|
|
116
|
+
const event = new KeyboardEvent('keydown', { key: 'Escape', bubbles: true, cancelable: true });
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
document.activeElement.dispatchEvent(event);
|
|
119
|
+
});
|
|
120
|
+
expect(await page.evaluate(() => closeCount)).toBe(0);
|
|
121
|
+
await page.keyboard.press('Escape');
|
|
122
|
+
await expect(page.getByRole('region', { name: 'Conversation overview' })).toHaveCount(0);
|
|
123
|
+
expect(await page.evaluate(() => closeCount)).toBe(1);
|
|
124
|
+
await page.getByRole('textbox').focus();
|
|
125
|
+
await page.evaluate(() => render({ open: true }));
|
|
126
|
+
await expect(page.getByRole('textbox')).toBeFocused();
|
|
127
|
+
await page.getByRole('button', { name: 'Close conversation overview' }).focus();
|
|
128
|
+
await page.keyboard.press('Space');
|
|
129
|
+
expect(await page.evaluate(() => closeCount)).toBe(2);
|
|
130
|
+
await page.getByRole('textbox').focus();
|
|
131
|
+
await page.evaluate(() => render({ open: false }));
|
|
132
|
+
await expect(page.getByRole('textbox')).toBeFocused();
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('hidden, inert, removed and disposed controls cannot dispatch, and disposal is final', async ({ page }) => {
|
|
136
|
+
await page.evaluate(() => {
|
|
137
|
+
const action = overview.element.querySelector('.conversation-overview-action');
|
|
138
|
+
const close = overview.element.querySelector('.conversation-overview-close');
|
|
139
|
+
render({ open: false });
|
|
140
|
+
action.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
141
|
+
close.click();
|
|
142
|
+
render({ open: true });
|
|
143
|
+
document.getElementById('host').inert = true;
|
|
144
|
+
action.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
145
|
+
close.click();
|
|
146
|
+
document.getElementById('host').inert = false;
|
|
147
|
+
document.getElementById('host').hidden = true;
|
|
148
|
+
action.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
149
|
+
close.click();
|
|
150
|
+
document.getElementById('host').hidden = false;
|
|
151
|
+
action.closest('.conversation-overview-item').hidden = true;
|
|
152
|
+
action.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
153
|
+
action.closest('.conversation-overview-item').hidden = false;
|
|
154
|
+
action.closest('.conversation-overview-item').inert = true;
|
|
155
|
+
action.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
156
|
+
action.closest('.conversation-overview-item').inert = false;
|
|
157
|
+
render({ sections: [] });
|
|
158
|
+
overview.element.append(action);
|
|
159
|
+
action.click();
|
|
160
|
+
overview.dispose();
|
|
161
|
+
document.getElementById('host').append(overview.element);
|
|
162
|
+
overview.update(state);
|
|
163
|
+
action.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
164
|
+
close.click();
|
|
165
|
+
overview.dispose();
|
|
166
|
+
});
|
|
167
|
+
expect(await page.evaluate(() => ({ events, closeCount, hidden: overview.element.hidden, inert: overview.element.inert })))
|
|
168
|
+
.toEqual({ events: [], closeCount: 0, hidden: true, inert: true });
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test('text stays literal, missing values are honest, stale sections and actions disappear', async ({ page }) => {
|
|
172
|
+
const unsafe = '<img src=x onerror="window.injected=true">';
|
|
173
|
+
await page.evaluate(unsafe => render({ title: unsafe, context: unsafe, sections: [{ id: 'literal', label: unsafe,
|
|
174
|
+
items: [{ id: 'value', label: unsafe, value: unsafe, detail: unsafe, reason: unsafe, actionId: 'literal' },
|
|
175
|
+
{ id: 'empty', label: 'Missing', value: '' }, { id: 'zero', label: 'Count', value: 0 }] }] }), unsafe);
|
|
176
|
+
await expect(page.locator('.conversation-overview img')).toHaveCount(0);
|
|
177
|
+
await expect(page.locator('.conversation-overview-title')).toHaveText(unsafe);
|
|
178
|
+
await expect(page.locator('.conversation-overview-value')).toHaveText([unsafe, 'Unknown', '0']);
|
|
179
|
+
await expect(page.locator('.conversation-overview-section')).toHaveCount(1);
|
|
180
|
+
expect(await page.evaluate(() => window.injected)).toBeUndefined();
|
|
181
|
+
await page.evaluate(() => render({ context: '', sections: [{ id: 'literal', items: [{ id: 'value', label: 'Read only', value: 'Retained' }] }] }));
|
|
182
|
+
await expect(page.locator('.conversation-overview-section-title')).toBeHidden();
|
|
183
|
+
await expect(page.locator('.conversation-overview-context')).toBeHidden();
|
|
184
|
+
await expect(page.getByRole('button')).toHaveCount(1);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test('progress accepts finite numbers only, clamps bounds, and clears stale semantics', async ({ page }) => {
|
|
188
|
+
await page.evaluate(() => render({ sections: [{ id: 'progress', items: [
|
|
189
|
+
{ id: 'low', label: 'Low', progress: -10 }, { id: 'high', label: 'High', progress: 150 },
|
|
190
|
+
{ id: 'fraction', label: 'Fraction', progress: 45.5 }, { id: 'nan', label: 'NaN', progress: NaN },
|
|
191
|
+
{ id: 'infinity', label: 'Infinity', progress: Infinity }, { id: 'string', label: 'String', progress: '60' },
|
|
192
|
+
] }] }));
|
|
193
|
+
const bars = page.getByRole('progressbar');
|
|
194
|
+
await expect(bars).toHaveCount(3);
|
|
195
|
+
expect(await bars.evaluateAll(nodes => nodes.map(node => [node.getAttribute('aria-valuenow'), node.firstChild.style.width])))
|
|
196
|
+
.toEqual([['0', '0%'], ['100', '100%'], ['45.5', '45.5%']]);
|
|
197
|
+
await page.evaluate(() => render({ sections: [{ id: 'progress', items: [{ id: 'low', label: 'Low', progress: null }] }] }));
|
|
198
|
+
await expect(bars).toHaveCount(0);
|
|
199
|
+
await expect(page.locator('.conversation-overview-progress')).not.toHaveAttribute('aria-valuenow');
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
for (const theme of ['dark', 'light']) {
|
|
203
|
+
for (const scenario of [
|
|
204
|
+
{ name: 'desktop', width: 1100, height: 800, text: 100 },
|
|
205
|
+
{ name: 'narrow-short', width: 320, height: 400, text: 100 },
|
|
206
|
+
{ name: 'narrow-host', width: 320, height: 400, text: 100, hostWidth: 196 },
|
|
207
|
+
{ name: 'double-text', width: 320, height: 500, text: 200 },
|
|
208
|
+
]) {
|
|
209
|
+
test(`${theme} ${scenario.name} grows with content and retains access in constrained windows`, async ({ page }, testInfo) => {
|
|
210
|
+
await page.setViewportSize({ width: scenario.width, height: scenario.height });
|
|
211
|
+
await page.evaluate(({ theme, text, hostWidth }) => {
|
|
212
|
+
document.documentElement.dataset.fixtureTheme = theme;
|
|
213
|
+
document.documentElement.style.fontSize = text + '%';
|
|
214
|
+
if (hostWidth) {
|
|
215
|
+
const host = document.getElementById('host');
|
|
216
|
+
host.style.left = 'auto';
|
|
217
|
+
host.style.width = hostWidth + 'px';
|
|
218
|
+
}
|
|
219
|
+
}, { theme, text: scenario.text, hostWidth: scenario.hostWidth });
|
|
220
|
+
const geometry = await page.locator('.conversation-overview').evaluate(card => {
|
|
221
|
+
const content = card.querySelector('.conversation-overview-content');
|
|
222
|
+
const host = card.parentElement;
|
|
223
|
+
const rect = card.getBoundingClientRect();
|
|
224
|
+
const bounds = host.getBoundingClientRect();
|
|
225
|
+
return { width: rect.width, aboveDraft: bounds.bottom <= document.getElementById('draft').getBoundingClientRect().top,
|
|
226
|
+
bounded: rect.left >= bounds.left && rect.right <= bounds.right
|
|
227
|
+
&& rect.top >= bounds.top,
|
|
228
|
+
cardScrolls: card.scrollHeight > card.clientHeight + 1,
|
|
229
|
+
contentScrolls: content.scrollHeight > content.clientHeight + 1,
|
|
230
|
+
hostScrolls: host.scrollHeight > host.clientHeight + 1,
|
|
231
|
+
horizontal: card.scrollWidth > card.clientWidth + 1 || content.scrollWidth > content.clientWidth + 1,
|
|
232
|
+
pointer: getComputedStyle(card).pointerEvents };
|
|
233
|
+
});
|
|
234
|
+
expect(geometry.bounded).toBe(true);
|
|
235
|
+
expect(geometry.aboveDraft).toBe(true);
|
|
236
|
+
expect(geometry.width).toBeLessThanOrEqual(288);
|
|
237
|
+
expect(geometry.horizontal).toBe(false);
|
|
238
|
+
expect(geometry.cardScrolls).toBe(false);
|
|
239
|
+
expect(geometry.contentScrolls).toBe(false);
|
|
240
|
+
expect(geometry.hostScrolls).toBe(scenario.name !== 'desktop');
|
|
241
|
+
expect(geometry.pointer).toBe('auto');
|
|
242
|
+
await page.getByRole('button', { name: 'Open Agents', exact: true }).click();
|
|
243
|
+
expect(await page.evaluate(() => events.at(-1).actionId)).toBe('agents');
|
|
244
|
+
await page.locator('#host').evaluate(node => { node.scrollTop = 0; });
|
|
245
|
+
await page.getByRole('textbox').focus();
|
|
246
|
+
await page.screenshot({ path: testInfo.outputPath(`overview-${theme}-${scenario.name}.png`) });
|
|
247
|
+
await page.getByRole('button', { name: 'Close conversation overview' }).click();
|
|
248
|
+
await expect(page.locator('.conversation-overview')).toBeHidden();
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { expect } from '@playwright/test';
|
|
2
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
3
|
+
import { test } from './empty-startup-fixture.mjs';
|
|
4
|
+
|
|
5
|
+
const storageKey = 'pi-webui-draft-conversations-v1';
|
|
6
|
+
test.use({ video: 'off', serviceWorkers: 'block', viewport: { width: 1440, height: 900 } });
|
|
7
|
+
|
|
8
|
+
async function ready(page, fixture) {
|
|
9
|
+
await page.addInitScript(() => localStorage.setItem('pi-webui-shell-preferences-v1', JSON.stringify({ v: 1, desktopLayout: 'focused' })));
|
|
10
|
+
await page.goto(fixture.baseURL);
|
|
11
|
+
await expect(page.locator('#emptyStartTitle')).toHaveText('Start a conversation');
|
|
12
|
+
await expect(page.locator('#promptInput')).toBeEditable();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function capture(page, info, name) {
|
|
16
|
+
const path = info.outputPath(`${name}.png`);
|
|
17
|
+
await page.screenshot({ path, fullPage: true });
|
|
18
|
+
await info.attach(name, { path, contentType: 'image/png' });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function track(page) {
|
|
22
|
+
const requests = [];
|
|
23
|
+
page.on('request', request => {
|
|
24
|
+
const url = new URL(request.url());
|
|
25
|
+
if (url.pathname.startsWith('/api/')) requests.push({ path: url.pathname, tab: url.searchParams.get('tab'), method: request.method(), body: request.postData() });
|
|
26
|
+
});
|
|
27
|
+
return requests;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function promote(page, fixture, text) {
|
|
31
|
+
await page.locator('#promptInput').fill(text);
|
|
32
|
+
await page.locator('#sendButton').click();
|
|
33
|
+
await expect.poll(async () => (await fixture.commands()).filter(item => item.type === 'prompt' && item.message === text.trim()).length).toBe(1);
|
|
34
|
+
const tabs = (await fixture.api('/api/tabs')).tabs;
|
|
35
|
+
return tabs.at(-1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function holdCreation(page) {
|
|
39
|
+
let created;
|
|
40
|
+
let release;
|
|
41
|
+
const pending = new Promise(resolve => { created = resolve; });
|
|
42
|
+
const released = new Promise(resolve => { release = resolve; });
|
|
43
|
+
let held = false;
|
|
44
|
+
await page.route('**/api/tabs', async route => {
|
|
45
|
+
if (route.request().method() !== 'POST' || held) return route.continue();
|
|
46
|
+
held = true;
|
|
47
|
+
const response = await route.fetch();
|
|
48
|
+
created((await response.json()).data.tab);
|
|
49
|
+
await Promise.race([released, delay(5000)]);
|
|
50
|
+
await route.fulfill({ response });
|
|
51
|
+
});
|
|
52
|
+
return { created: pending, release };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function openNoProjectMenu(page) {
|
|
56
|
+
await page.locator('#newTabButton').click();
|
|
57
|
+
await page.locator('#newThreadList').getByRole('option', { name: /No project/ }).click();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
test('blank openings allocate nothing; leaving text creates an Inbox draft that resumes, reloads, and closes locally', async ({ page, emptyStartup }, info) => {
|
|
61
|
+
const requests = track(page);
|
|
62
|
+
await ready(page, emptyStartup);
|
|
63
|
+
await page.locator('.focused-brand').click();
|
|
64
|
+
await openNoProjectMenu(page);
|
|
65
|
+
await expect(page.locator('[data-draft-id]')).toHaveCount(0);
|
|
66
|
+
expect((await emptyStartup.api('/api/tabs')).tabs).toEqual([]);
|
|
67
|
+
expect(await emptyStartup.starts()).toEqual([]);
|
|
68
|
+
expect(await emptyStartup.ownedDirectories()).toEqual([]);
|
|
69
|
+
await capture(page, info, 'empty-state-no-new-tabs');
|
|
70
|
+
const original = 'Local draft before choosing a project\nsecond line λ';
|
|
71
|
+
await page.locator('#promptInput').fill(original);
|
|
72
|
+
await page.locator('.focused-brand').click();
|
|
73
|
+
const row = page.locator('[data-session-shelf="inbox"] [data-draft-id]');
|
|
74
|
+
await expect(row).toHaveCount(1);
|
|
75
|
+
await expect(row).toContainText('Draft · browser only');
|
|
76
|
+
await expect(row.locator('[data-settlement-action], [data-tab-id], .terminal-tab-actions')).toHaveCount(0);
|
|
77
|
+
await expect(page.locator('#promptInput')).toHaveValue('');
|
|
78
|
+
await capture(page, info, 'saved-draft');
|
|
79
|
+
await row.getByRole('tab').click();
|
|
80
|
+
await expect(page.locator('#promptInput')).toHaveValue(original);
|
|
81
|
+
await page.locator('#promptInput').fill(`${original}\nedited after resume`);
|
|
82
|
+
await capture(page, info, 'resume-draft');
|
|
83
|
+
await page.reload();
|
|
84
|
+
await expect(page.locator('#promptInput')).toHaveValue(`${original}\nedited after resume`);
|
|
85
|
+
await expect(row).toHaveCount(1);
|
|
86
|
+
await row.getByRole('button', { name: /^Close draft:/ }).click();
|
|
87
|
+
await expect(row).toHaveCount(0);
|
|
88
|
+
await expect(page.locator('#promptInput')).toHaveValue('');
|
|
89
|
+
await page.reload();
|
|
90
|
+
await expect(row).toHaveCount(0);
|
|
91
|
+
expect((await emptyStartup.api('/api/tabs')).tabs).toEqual([]);
|
|
92
|
+
expect(await emptyStartup.starts()).toEqual([]);
|
|
93
|
+
expect(requests.filter(item => item.method !== 'GET' && !['/api/interface-preferences'].includes(item.path))).toEqual([]);
|
|
94
|
+
expect(requests.filter(item => item.tab?.startsWith('draft:'))).toEqual([]);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('saved draft promotes once to its real No Project session and disappears from local storage', async ({ page, emptyStartup }, info) => {
|
|
98
|
+
const requests = track(page);
|
|
99
|
+
await ready(page, emptyStartup);
|
|
100
|
+
const text = ' Promote this saved draft\nwith its full text λ \n';
|
|
101
|
+
await page.locator('#promptInput').fill(text);
|
|
102
|
+
await page.locator('.focused-brand').click();
|
|
103
|
+
await page.getByRole('tab', { name: /^Draft: Promote this/ }).click();
|
|
104
|
+
const tab = await promote(page, emptyStartup, text);
|
|
105
|
+
expect(tab.workspaceKind).toBe('no-project');
|
|
106
|
+
await expect(page.locator('[data-draft-id]')).toHaveCount(0);
|
|
107
|
+
await expect(page.locator(`#tabBar [data-tab-id="${tab.id}"] .terminal-tab-button`)).toHaveAttribute('aria-selected', 'true');
|
|
108
|
+
await expect(page.locator('#promptInput')).toHaveValue('');
|
|
109
|
+
expect(JSON.parse(await page.evaluate(key => localStorage.getItem(key), storageKey)).records).toEqual([]);
|
|
110
|
+
expect(requests.filter(item => item.path === '/api/tabs' && item.method === 'POST').map(item => JSON.parse(item.body))).toEqual([{ workspaceKind: 'no-project' }]);
|
|
111
|
+
expect(requests.filter(item => item.path === '/api/prompt').map(item => item.tab)).toEqual([tab.id]);
|
|
112
|
+
expect(JSON.parse(requests.find(item => item.path === '/api/prompt').body).message).toBe(text);
|
|
113
|
+
expect(requests.filter(item => item.tab?.startsWith('draft:'))).toEqual([]);
|
|
114
|
+
await capture(page, info, 'first-prompt-promotion');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('Home and + Thread leave existing sessions intact while selecting fresh blank client state', async ({ page, emptyStartup }) => {
|
|
118
|
+
await ready(page, emptyStartup);
|
|
119
|
+
const source = await promote(page, emptyStartup, 'Existing conversation');
|
|
120
|
+
await page.locator('#promptInput').fill('Existing session composer');
|
|
121
|
+
await page.locator('.focused-brand').click();
|
|
122
|
+
await expect(page.locator('#promptInput')).toHaveValue('');
|
|
123
|
+
await expect(page.locator('#emptyStartTitle')).toHaveText('Start a conversation');
|
|
124
|
+
await page.locator('#promptInput').fill('First browser draft');
|
|
125
|
+
await openNoProjectMenu(page);
|
|
126
|
+
await expect(page.locator('#promptInput')).toHaveValue('');
|
|
127
|
+
await expect(page.getByRole('tab', { name: 'Draft: First browser draft', exact: true })).toBeVisible();
|
|
128
|
+
await page.reload();
|
|
129
|
+
await expect(page.locator('#promptInput')).toHaveValue('');
|
|
130
|
+
await expect(page.locator('#emptyStartTitle')).toHaveText('Start a conversation');
|
|
131
|
+
await page.locator(`#tabBar [data-tab-id="${source.id}"] .terminal-tab-button`).click();
|
|
132
|
+
await expect(page.locator('#promptInput')).toHaveValue('Existing session composer');
|
|
133
|
+
await page.getByRole('tab', { name: 'Draft: First browser draft', exact: true }).click();
|
|
134
|
+
await expect(page.locator('#promptInput')).toHaveValue('First browser draft');
|
|
135
|
+
expect((await emptyStartup.api('/api/tabs')).tabs.map(tab => tab.id)).toEqual([source.id]);
|
|
136
|
+
expect(await emptyStartup.ownedDirectories()).toEqual([source.noProjectId]);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
for (const mode of ['denied', 'failed writes', 'malformed', 'future']) test(`draft storage ${mode} is exposed and memory edits remain reopenable`, async ({ page, emptyStartup }) => {
|
|
140
|
+
await page.addInitScript(({ mode, storageKey }) => {
|
|
141
|
+
if (mode === 'denied') {
|
|
142
|
+
Object.defineProperty(window, 'localStorage', { get() { throw new Error('Storage disabled for this browser'); } });
|
|
143
|
+
} else if (mode === 'failed writes') {
|
|
144
|
+
const original = Storage.prototype.setItem;
|
|
145
|
+
Storage.prototype.setItem = function(key, value) {
|
|
146
|
+
if (key === storageKey) throw new Error('Draft quota exceeded');
|
|
147
|
+
return original.call(this, key, value);
|
|
148
|
+
};
|
|
149
|
+
} else {
|
|
150
|
+
localStorage.setItem(storageKey, mode === 'malformed' ? '{invalid' : JSON.stringify({ version: 9, records: [], activeId: null }));
|
|
151
|
+
}
|
|
152
|
+
}, { mode, storageKey });
|
|
153
|
+
if (mode === 'denied') {
|
|
154
|
+
await page.goto(emptyStartup.baseURL);
|
|
155
|
+
// Storage-denied startup falls back to the default shell; the composer and
|
|
156
|
+
// canonical roster remain the same owners in both layouts.
|
|
157
|
+
await expect(page.locator('#emptyStartTitle')).toHaveText('Start a conversation');
|
|
158
|
+
await expect(page.locator('#draftStorageStatus')).toBeVisible();
|
|
159
|
+
await expect(page.locator('#promptInput')).toBeEditable();
|
|
160
|
+
} else await ready(page, emptyStartup);
|
|
161
|
+
const text = `Keep this ${mode} draft`;
|
|
162
|
+
await page.locator('#promptInput').fill(text);
|
|
163
|
+
if (mode === 'denied') {
|
|
164
|
+
// The focused brand is absent in the classic fallback layout.
|
|
165
|
+
await openNoProjectMenu(page);
|
|
166
|
+
} else await page.locator('.focused-brand').click();
|
|
167
|
+
await expect(page.locator('#draftStorageStatus')).toContainText(/Browser drafts could not be (?:saved|loaded)/);
|
|
168
|
+
await page.getByRole('tab', { name: `Draft: ${text}`, exact: true }).click();
|
|
169
|
+
await expect(page.locator('#promptInput')).toHaveValue(text);
|
|
170
|
+
expect((await emptyStartup.api('/api/tabs')).tabs).toEqual([]);
|
|
171
|
+
if (mode === 'malformed' || mode === 'future') {
|
|
172
|
+
const raw = await page.evaluate(key => localStorage.getItem(key), storageKey);
|
|
173
|
+
expect(raw).toBe(mode === 'malformed' ? '{invalid' : JSON.stringify({ version: 9, records: [], activeId: null }));
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
for (const navigation of ['selected', 'another blank']) test(`failed first dispatch retains captured and newer text after ${navigation}, retry reuses its real session`, async ({ page, emptyStartup }) => {
|
|
178
|
+
await ready(page, emptyStartup);
|
|
179
|
+
const hold = await holdCreation(page);
|
|
180
|
+
const captured = 'Captured submission';
|
|
181
|
+
await page.route('**/api/prompt?*', route => route.fulfill({ status: 503, json: { success: false, error: 'Dispatch unavailable' } }));
|
|
182
|
+
await page.locator('#promptInput').fill(captured);
|
|
183
|
+
await page.locator('#sendButton').click();
|
|
184
|
+
const tab = await hold.created;
|
|
185
|
+
await page.locator('#promptInput').fill('Newer edit');
|
|
186
|
+
if (navigation === 'another blank') {
|
|
187
|
+
await page.locator('.focused-brand').click();
|
|
188
|
+
await page.locator('#promptInput').fill('Other blank stays selected');
|
|
189
|
+
}
|
|
190
|
+
hold.release();
|
|
191
|
+
if (navigation === 'another blank') {
|
|
192
|
+
await expect(page.getByText('Dispatch unavailable').first()).toBeAttached();
|
|
193
|
+
await expect(page.locator('#promptInput')).toHaveValue('Other blank stays selected');
|
|
194
|
+
await page.locator(`#tabBar [data-tab-id="${tab.id}"] .terminal-tab-button`).click();
|
|
195
|
+
}
|
|
196
|
+
await expect(page.locator('#promptInput')).toHaveValue(`${captured}\n\nNewer edit`);
|
|
197
|
+
await expect(page.getByRole('tab', { name: 'Draft: Captured submission', exact: true })).toHaveCount(0);
|
|
198
|
+
expect((await emptyStartup.api('/api/tabs')).tabs.map(item => item.id)).toEqual([tab.id]);
|
|
199
|
+
await page.unroute('**/api/prompt?*');
|
|
200
|
+
await page.locator('#sendButton').click();
|
|
201
|
+
await expect.poll(async () => (await emptyStartup.commands()).filter(item => item.type === 'prompt' && item.message === `${captured}\n\nNewer edit`).length).toBe(1);
|
|
202
|
+
expect((await emptyStartup.api('/api/tabs')).tabs).toHaveLength(1);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
test('crossed promotion responses and newer navigation keep both exact server targets', async ({ page, emptyStartup }) => {
|
|
206
|
+
await ready(page, emptyStartup);
|
|
207
|
+
const hold = await holdCreation(page);
|
|
208
|
+
await page.locator('#promptInput').fill('First delayed promotion');
|
|
209
|
+
await page.locator('#sendButton').click();
|
|
210
|
+
const first = await hold.created;
|
|
211
|
+
await page.locator('.focused-brand').click();
|
|
212
|
+
const second = await promote(page, emptyStartup, 'Second promotion');
|
|
213
|
+
expect(second.id).not.toBe(first.id);
|
|
214
|
+
await page.locator('#promptInput').fill('Newer real session draft');
|
|
215
|
+
hold.release();
|
|
216
|
+
await expect.poll(async () => (await emptyStartup.commands()).filter(item => item.type === 'prompt' && item.message === 'First delayed promotion').length).toBe(1);
|
|
217
|
+
await expect(page.locator('#promptInput')).toHaveValue('Newer real session draft');
|
|
218
|
+
await expect(page.locator(`#tabBar [data-tab-id="${second.id}"] .terminal-tab-button`)).toHaveAttribute('aria-selected', 'true');
|
|
219
|
+
const commands = await emptyStartup.commands();
|
|
220
|
+
expect(commands.find(item => item.message === 'First delayed promotion').cwd).toBe(first.cwd);
|
|
221
|
+
expect(commands.find(item => item.message === 'Second promotion').cwd).toBe(second.cwd);
|
|
222
|
+
expect((await emptyStartup.api('/api/tabs')).tabs).toHaveLength(2);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test('closing a pending draft never redirects its submitted prompt or revives its local entry', async ({ page, emptyStartup }) => {
|
|
226
|
+
await ready(page, emptyStartup);
|
|
227
|
+
const hold = await holdCreation(page);
|
|
228
|
+
await page.locator('#promptInput').fill('Submitted before closing');
|
|
229
|
+
await page.locator('#sendButton').click();
|
|
230
|
+
const first = await hold.created;
|
|
231
|
+
await page.locator('.focused-brand').click();
|
|
232
|
+
await page.getByRole('button', { name: 'Close draft: Submitted before closing', exact: true }).click();
|
|
233
|
+
await page.locator('#promptInput').fill('Unrelated blank text');
|
|
234
|
+
hold.release();
|
|
235
|
+
await expect.poll(async () => (await emptyStartup.commands()).filter(item => item.type === 'prompt' && item.message === 'Submitted before closing').length).toBe(1);
|
|
236
|
+
expect((await emptyStartup.commands()).find(item => item.message === 'Submitted before closing').cwd).toBe(first.cwd);
|
|
237
|
+
await expect(page.locator('#promptInput')).toHaveValue('Unrelated blank text');
|
|
238
|
+
await expect(page.getByRole('tab', { name: /^Draft: Submitted before/ })).toHaveCount(0);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test('deferred native selectors retain both the command and newer edits in their real session', async ({ page, emptyStartup }) => {
|
|
242
|
+
await ready(page, emptyStartup);
|
|
243
|
+
const hold = await holdCreation(page);
|
|
244
|
+
await page.locator('#promptInput').fill('/name');
|
|
245
|
+
await page.locator('#sendButton').click();
|
|
246
|
+
const tab = await hold.created;
|
|
247
|
+
await page.locator('#promptInput').fill('Newer unsent text');
|
|
248
|
+
await page.locator('.focused-brand').click();
|
|
249
|
+
hold.release();
|
|
250
|
+
await expect(page.getByText(/Its command is saved in that conversation's draft\./).first()).toBeAttached();
|
|
251
|
+
await expect(page.locator('#nativeCommandDialog')).not.toBeVisible();
|
|
252
|
+
await page.locator(`#tabBar [data-tab-id="${tab.id}"] .terminal-tab-button`).click();
|
|
253
|
+
await expect(page.locator('#promptInput')).toHaveValue('/name\n\nNewer unsent text');
|
|
254
|
+
expect((await emptyStartup.commands()).filter(item => item.type === 'prompt' && item.message === '/name')).toEqual([]);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
for (const width of [1200, 1024]) test(`draft actions stay visible and keyboard reachable at ${width}px`, async ({ page, emptyStartup }, info) => {
|
|
258
|
+
await page.setViewportSize({ width, height: 768 });
|
|
259
|
+
await ready(page, emptyStartup);
|
|
260
|
+
await page.locator('#promptInput').fill('Draft with a long title that must truncate without covering its close action');
|
|
261
|
+
if (await page.locator('.focused-brand').isVisible()) await page.locator('.focused-brand').click();
|
|
262
|
+
else await openNoProjectMenu(page);
|
|
263
|
+
const row = page.locator('#tabBar [data-draft-id]');
|
|
264
|
+
const close = row.getByRole('button', { name: /^Close draft:/ });
|
|
265
|
+
const resume = row.getByRole('tab');
|
|
266
|
+
await expect(close).toBeInViewport();
|
|
267
|
+
await expect(resume).toBeInViewport();
|
|
268
|
+
await resume.focus();
|
|
269
|
+
await page.keyboard.press('Enter');
|
|
270
|
+
await expect(page.locator('#promptInput')).toHaveValue('Draft with a long title that must truncate without covering its close action');
|
|
271
|
+
await close.focus();
|
|
272
|
+
await capture(page, info, `narrow-draft-actions-${width}`);
|
|
273
|
+
await page.keyboard.press('Enter');
|
|
274
|
+
await expect(row).toHaveCount(0);
|
|
275
|
+
expect((await emptyStartup.api('/api/tabs')).tabs).toEqual([]);
|
|
276
|
+
});
|