@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,481 @@
|
|
|
1
|
+
import { expect } from '@playwright/test';
|
|
2
|
+
import { mkdir } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
5
|
+
import { test } from './empty-startup-fixture.mjs';
|
|
6
|
+
|
|
7
|
+
const storageKey = 'pi-webui-draft-conversations-v1';
|
|
8
|
+
test.use({ video: 'off', serviceWorkers: 'block', viewport: { width: 1440, height: 900 } });
|
|
9
|
+
|
|
10
|
+
/** Opens a real thread in `current` and pins `pinned`, so the palette lists Current, No project, pinned, Browse and Branch worktree. */
|
|
11
|
+
async function readyWithThread(page, fixture) {
|
|
12
|
+
const current = join(fixture.root, 'current-project');
|
|
13
|
+
const pinned = join(fixture.root, 'pinned-project');
|
|
14
|
+
await Promise.all([mkdir(current), mkdir(pinned)]);
|
|
15
|
+
await fixture.api('/api/path-fast-picks', { picks: [{ cwd: pinned, displayCwd: pinned }] });
|
|
16
|
+
const thread = (await fixture.api('/api/tabs', { cwd: current })).tab;
|
|
17
|
+
await page.addInitScript(() => localStorage.setItem('pi-webui-shell-preferences-v1', JSON.stringify({ v: 1, desktopLayout: 'focused' })));
|
|
18
|
+
await page.goto(`${fixture.baseURL}/?tab=${encodeURIComponent(thread.id)}`);
|
|
19
|
+
await expect(page.locator(`#tabBar [data-tab-id="${thread.id}"] .terminal-tab-button`)).toHaveAttribute('aria-selected', 'true');
|
|
20
|
+
await expect(page.locator('#promptInput')).toBeEditable();
|
|
21
|
+
return { thread, current, pinned };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function trackCreations(page) {
|
|
25
|
+
const creations = [];
|
|
26
|
+
page.on('request', request => {
|
|
27
|
+
if (new URL(request.url()).pathname === '/api/tabs' && request.method() === 'POST') creations.push(request.postDataJSON());
|
|
28
|
+
});
|
|
29
|
+
return creations;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const paletteOptions = page => page.locator('#newThreadList [role="option"]');
|
|
33
|
+
const paletteOption = (page, name) => page.locator('#newThreadList').getByRole('option', { name });
|
|
34
|
+
const pickerOptions = page => page.locator('#draftWorkspacePickerList [role="option"]');
|
|
35
|
+
const pickerOption = (page, name) => page.locator('#draftWorkspacePickerList').getByRole('option', { name });
|
|
36
|
+
const workspaceButton = page => page.locator('.empty-start-workspace-button');
|
|
37
|
+
|
|
38
|
+
async function openPalette(page) {
|
|
39
|
+
await page.locator('#newTabButton').click();
|
|
40
|
+
await expect(page.locator('#newThreadDialog')).toBeVisible();
|
|
41
|
+
await expect(page.locator('#newThreadInput')).toBeFocused();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function expectDraftFolder(page, label) {
|
|
45
|
+
await expect(page.locator('#emptyStartTitle')).toHaveText('Start a conversation');
|
|
46
|
+
await expect(workspaceButton(page)).toHaveText(label);
|
|
47
|
+
await expect(page.locator('.focused-context')).toHaveText(label);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function directPath(page, cwd) {
|
|
51
|
+
await page.locator('#pathPickerPathInput').fill(cwd);
|
|
52
|
+
await page.locator('#pathPickerPathInput').press('Enter');
|
|
53
|
+
await expect(page.locator('#pathPickerCurrent')).toHaveAttribute('title', cwd);
|
|
54
|
+
await expect(page.locator('#pathPickerChooseButton')).toBeEnabled();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function holdCreation(page) {
|
|
58
|
+
let release;
|
|
59
|
+
let notify;
|
|
60
|
+
const released = new Promise(resolve => { release = resolve; });
|
|
61
|
+
const created = new Promise(resolve => { notify = resolve; });
|
|
62
|
+
let held = false;
|
|
63
|
+
await page.route('**/api/tabs', async route => {
|
|
64
|
+
if (route.request().method() !== 'POST' || held) return route.continue();
|
|
65
|
+
held = true;
|
|
66
|
+
const response = await route.fetch();
|
|
67
|
+
notify((await response.json()).data.tab);
|
|
68
|
+
await Promise.race([released, delay(5000)]);
|
|
69
|
+
await route.fulfill({ response });
|
|
70
|
+
});
|
|
71
|
+
return { created, release };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function capture(page, info, name) {
|
|
75
|
+
const path = info.outputPath(`${name}.png`);
|
|
76
|
+
await page.screenshot({ path });
|
|
77
|
+
await info.attach(name, { path, contentType: 'image/png' });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
test('the sidebar compose button opens the palette; Current, pinned, No project and Browse open drafts without creating threads', async ({ page, emptyStartup }, info) => {
|
|
81
|
+
const { thread, current, pinned } = await readyWithThread(page, emptyStartup);
|
|
82
|
+
const creations = trackCreations(page);
|
|
83
|
+
await expect(page.locator('#newTabButton')).toHaveAccessibleName('New thread');
|
|
84
|
+
await openPalette(page);
|
|
85
|
+
await expect(page.locator('#newThreadDialog')).toHaveAccessibleName('New thread');
|
|
86
|
+
await expect(paletteOptions(page).locator('.command-palette-item-label')).toHaveText(['current-project', 'No project', 'pinned-project', 'Browse…', 'Branch worktree…']);
|
|
87
|
+
await expect(paletteOptions(page).locator('.command-palette-item-kind')).toHaveText(['Current', 'Isolated', 'Pinned', 'Action', 'Git']);
|
|
88
|
+
await capture(page, info, 'palette');
|
|
89
|
+
|
|
90
|
+
await paletteOption(page, /current-project/).click();
|
|
91
|
+
await expect(page.locator('#newThreadDialog')).toBeHidden();
|
|
92
|
+
await expectDraftFolder(page, current);
|
|
93
|
+
await expect(page.locator('#promptInput')).toBeFocused();
|
|
94
|
+
await expect(page.locator('#promptInput')).toHaveValue('');
|
|
95
|
+
|
|
96
|
+
await openPalette(page);
|
|
97
|
+
await paletteOption(page, /pinned-project/).click();
|
|
98
|
+
await expectDraftFolder(page, pinned);
|
|
99
|
+
await expect(page.locator('[data-draft-id]'), 'a blank draft is reused, never listed').toHaveCount(0);
|
|
100
|
+
|
|
101
|
+
const text = 'Pinned folder draft text';
|
|
102
|
+
await page.locator('#promptInput').fill(text);
|
|
103
|
+
await openPalette(page);
|
|
104
|
+
await paletteOption(page, /No project/).click();
|
|
105
|
+
await expectDraftFolder(page, 'No Project');
|
|
106
|
+
await expect(page.locator('#promptInput')).toHaveValue('');
|
|
107
|
+
const saved = page.getByRole('tab', { name: `Draft: ${text}`, exact: true });
|
|
108
|
+
await expect(saved, 'a draft with text is kept, not reused').toBeVisible();
|
|
109
|
+
await saved.click();
|
|
110
|
+
await expect(page.locator('#promptInput')).toHaveValue(text);
|
|
111
|
+
await expectDraftFolder(page, pinned);
|
|
112
|
+
|
|
113
|
+
const browsed = join(emptyStartup.root, 'browsed-project');
|
|
114
|
+
await mkdir(browsed);
|
|
115
|
+
await page.locator(`#tabBar [data-tab-id="${thread.id}"] .terminal-tab-button`).click();
|
|
116
|
+
await openPalette(page);
|
|
117
|
+
await paletteOption(page, /Browse…/).click();
|
|
118
|
+
await expect(page.locator('#pathPickerDialog')).toBeVisible();
|
|
119
|
+
await directPath(page, browsed);
|
|
120
|
+
await page.locator('#pathPickerChooseButton').click();
|
|
121
|
+
await expect(page.locator('#pathPickerDialog')).toBeHidden();
|
|
122
|
+
await expectDraftFolder(page, browsed);
|
|
123
|
+
await capture(page, info, 'draft-with-folder');
|
|
124
|
+
|
|
125
|
+
expect(creations).toEqual([]);
|
|
126
|
+
expect((await emptyStartup.api('/api/tabs')).tabs.map(tab => tab.id)).toEqual([thread.id]);
|
|
127
|
+
expect(await emptyStartup.starts()).toHaveLength(1);
|
|
128
|
+
expect(await emptyStartup.ownedDirectories()).toEqual([]);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('palette keyboard: arrows wrap, Home/End jump, typing filters, Enter selects, Escape returns focus', async ({ page, emptyStartup }) => {
|
|
132
|
+
const { pinned } = await readyWithThread(page, emptyStartup);
|
|
133
|
+
const creations = trackCreations(page);
|
|
134
|
+
const input = page.locator('#newThreadInput');
|
|
135
|
+
const options = paletteOptions(page);
|
|
136
|
+
await page.locator('#newTabButton').focus();
|
|
137
|
+
await page.keyboard.press('Enter');
|
|
138
|
+
await expect(input).toBeFocused();
|
|
139
|
+
await expect(options.first()).toHaveAttribute('aria-selected', 'true');
|
|
140
|
+
await expect(input).toHaveAttribute('aria-activedescendant', await options.first().getAttribute('id'));
|
|
141
|
+
await page.keyboard.press('ArrowDown');
|
|
142
|
+
await expect(options.nth(1)).toHaveAttribute('aria-selected', 'true');
|
|
143
|
+
await expect(options.first()).toHaveAttribute('aria-selected', 'false');
|
|
144
|
+
await expect(input).toHaveAttribute('aria-activedescendant', await options.nth(1).getAttribute('id'));
|
|
145
|
+
await page.keyboard.press('End');
|
|
146
|
+
await expect(options.last()).toHaveAttribute('aria-selected', 'true');
|
|
147
|
+
await page.keyboard.press('ArrowDown');
|
|
148
|
+
await expect(options.first()).toHaveAttribute('aria-selected', 'true');
|
|
149
|
+
await page.keyboard.press('ArrowUp');
|
|
150
|
+
await expect(options.last()).toHaveAttribute('aria-selected', 'true');
|
|
151
|
+
await page.keyboard.press('Home');
|
|
152
|
+
await expect(options.first()).toHaveAttribute('aria-selected', 'true');
|
|
153
|
+
await page.keyboard.press('Escape');
|
|
154
|
+
await expect(page.locator('#newThreadDialog')).toBeHidden();
|
|
155
|
+
await expect(page.locator('#newTabButton')).toBeFocused();
|
|
156
|
+
|
|
157
|
+
await page.keyboard.press('Enter');
|
|
158
|
+
await input.pressSequentially('PINNED');
|
|
159
|
+
await expect(options.locator('.command-palette-item-label')).toHaveText(['pinned-project', 'Browse…', 'Branch worktree…']);
|
|
160
|
+
await input.fill(emptyStartup.root.slice(-6));
|
|
161
|
+
await expect(options.locator('.command-palette-item-label')).toHaveText(['current-project', 'pinned-project', 'Browse…', 'Branch worktree…']);
|
|
162
|
+
await input.fill('pinned');
|
|
163
|
+
await page.keyboard.press('Enter');
|
|
164
|
+
await expectDraftFolder(page, pinned);
|
|
165
|
+
expect(creations).toEqual([]);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test('Branch worktree stays eager and opens its picker; the command palette offers New thread', async ({ page, emptyStartup }) => {
|
|
169
|
+
await readyWithThread(page, emptyStartup);
|
|
170
|
+
await openPalette(page);
|
|
171
|
+
await paletteOption(page, /Branch worktree…/).click();
|
|
172
|
+
await expect(page.locator('#newThreadDialog')).toBeHidden();
|
|
173
|
+
await expect(page.getByRole('listbox', { name: 'Git branches and worktrees' })).toBeVisible();
|
|
174
|
+
await page.keyboard.press('Escape');
|
|
175
|
+
await expect(page.getByRole('listbox', { name: 'Git branches and worktrees' })).toBeHidden();
|
|
176
|
+
|
|
177
|
+
await page.locator('#promptInput').focus();
|
|
178
|
+
await page.keyboard.press('Control+k');
|
|
179
|
+
const search = page.getByRole('combobox').filter({ visible: true }).first();
|
|
180
|
+
await search.fill('New thread');
|
|
181
|
+
await page.keyboard.press('Enter');
|
|
182
|
+
await expect(page.locator('#newThreadDialog')).toBeVisible();
|
|
183
|
+
await expect(page.locator('#newThreadInput')).toBeFocused();
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test('the card folder dropdown changes only the draft folder, with keyboard, filter, outside click and focus return', async ({ page, emptyStartup }, info) => {
|
|
187
|
+
const { current, pinned } = await readyWithThread(page, emptyStartup);
|
|
188
|
+
const creations = trackCreations(page);
|
|
189
|
+
await openPalette(page);
|
|
190
|
+
await paletteOption(page, /current-project/).click();
|
|
191
|
+
const trigger = workspaceButton(page);
|
|
192
|
+
await expect(trigger).toHaveAttribute('aria-haspopup', 'listbox');
|
|
193
|
+
await expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
194
|
+
await trigger.click();
|
|
195
|
+
const picker = page.getByRole('dialog', { name: 'Choose a folder for this draft' });
|
|
196
|
+
await expect(picker).toBeVisible();
|
|
197
|
+
await expect(trigger).toHaveAttribute('aria-expanded', 'true');
|
|
198
|
+
await expect(page.locator('.draft-workspace-picker-input')).toBeFocused();
|
|
199
|
+
await expect(pickerOptions(page).locator('.footer-model-option-main')).toHaveText(['current-project · selected', 'No project', 'pinned-project', 'Browse…']);
|
|
200
|
+
await expect(pickerOptions(page).first(), 'the draft folder starts highlighted').toHaveAttribute('aria-selected', 'true');
|
|
201
|
+
await capture(page, info, 'card-dropdown');
|
|
202
|
+
|
|
203
|
+
await page.keyboard.press('Escape');
|
|
204
|
+
await expect(picker).toBeHidden();
|
|
205
|
+
await expect(trigger).toBeFocused();
|
|
206
|
+
await expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
207
|
+
|
|
208
|
+
await page.keyboard.press('ArrowDown');
|
|
209
|
+
await expect(picker).toBeVisible();
|
|
210
|
+
await page.keyboard.press('ArrowDown');
|
|
211
|
+
await page.keyboard.press('ArrowDown');
|
|
212
|
+
await expect(pickerOption(page, /pinned-project/)).toHaveAttribute('aria-selected', 'true');
|
|
213
|
+
await page.keyboard.press('Enter');
|
|
214
|
+
await expect(picker).toBeHidden();
|
|
215
|
+
await expectDraftFolder(page, pinned);
|
|
216
|
+
await expect(workspaceButton(page)).toBeFocused();
|
|
217
|
+
|
|
218
|
+
await workspaceButton(page).click();
|
|
219
|
+
await page.locator('.draft-workspace-picker-input').fill('CURRENT-PRO');
|
|
220
|
+
await expect(pickerOptions(page).locator('.footer-model-option-main')).toHaveText(['current-project', 'Browse…']);
|
|
221
|
+
await page.keyboard.press('Home');
|
|
222
|
+
await page.keyboard.press('Enter');
|
|
223
|
+
await expectDraftFolder(page, current);
|
|
224
|
+
|
|
225
|
+
await workspaceButton(page).click();
|
|
226
|
+
await page.locator('#chat').click({ position: { x: 8, y: 8 } });
|
|
227
|
+
await expect(picker).toBeHidden();
|
|
228
|
+
await expectDraftFolder(page, current);
|
|
229
|
+
|
|
230
|
+
await workspaceButton(page).click();
|
|
231
|
+
await pickerOption(page, /No project/).click();
|
|
232
|
+
await expectDraftFolder(page, 'No Project');
|
|
233
|
+
await workspaceButton(page).click();
|
|
234
|
+
await expect(pickerOption(page, /No project/)).toHaveAttribute('aria-selected', 'true');
|
|
235
|
+
await workspaceButton(page).click();
|
|
236
|
+
await expect(picker, 'the trigger toggles the dropdown').toBeHidden();
|
|
237
|
+
|
|
238
|
+
expect(creations).toEqual([]);
|
|
239
|
+
expect((await emptyStartup.api('/api/tabs')).tabs).toHaveLength(1);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
test('the card dropdown fits a 360px viewport above scroll containers', async ({ page, emptyStartup }, info) => {
|
|
243
|
+
await page.setViewportSize({ width: 360, height: 740 });
|
|
244
|
+
await readyWithThread(page, emptyStartup);
|
|
245
|
+
await page.locator('#terminalTabsToggleButton').click();
|
|
246
|
+
await page.locator('#newTabButton').click();
|
|
247
|
+
await expect(page.locator('#newThreadDialog')).toBeVisible();
|
|
248
|
+
await paletteOption(page, /current-project/).click();
|
|
249
|
+
await workspaceButton(page).scrollIntoViewIfNeeded();
|
|
250
|
+
await workspaceButton(page).click();
|
|
251
|
+
const picker = page.locator('.draft-workspace-picker');
|
|
252
|
+
await expect(picker).toBeVisible();
|
|
253
|
+
const box = await picker.boundingBox();
|
|
254
|
+
expect(box.x).toBeGreaterThanOrEqual(0);
|
|
255
|
+
expect(box.y).toBeGreaterThanOrEqual(0);
|
|
256
|
+
expect(box.x + box.width).toBeLessThanOrEqual(360);
|
|
257
|
+
expect(box.y + box.height).toBeLessThanOrEqual(740);
|
|
258
|
+
expect(await picker.evaluate(node => node.matches(':popover-open'))).toBe(true);
|
|
259
|
+
for (const option of await pickerOptions(page).all()) await expect(option).toBeInViewport();
|
|
260
|
+
await capture(page, info, 'card-dropdown-360');
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test('the first prompt creates exactly one thread in the folder chosen from the card', async ({ page, emptyStartup }) => {
|
|
264
|
+
const { pinned } = await readyWithThread(page, emptyStartup);
|
|
265
|
+
const creations = trackCreations(page);
|
|
266
|
+
await openPalette(page);
|
|
267
|
+
await paletteOption(page, /current-project/).click();
|
|
268
|
+
await workspaceButton(page).click();
|
|
269
|
+
await pickerOption(page, /pinned-project/).click();
|
|
270
|
+
const text = 'Start in the pinned folder';
|
|
271
|
+
await page.locator('#promptInput').fill(text);
|
|
272
|
+
await page.locator('#sendButton').click();
|
|
273
|
+
await expect.poll(async () => (await emptyStartup.commands()).filter(item => item.type === 'prompt' && item.message === text)).toHaveLength(1);
|
|
274
|
+
expect(creations).toEqual([{ cwd: pinned }]);
|
|
275
|
+
const tabs = (await emptyStartup.api('/api/tabs')).tabs;
|
|
276
|
+
expect(tabs).toHaveLength(2);
|
|
277
|
+
expect(tabs.at(-1).cwd).toBe(pinned);
|
|
278
|
+
expect((await emptyStartup.commands()).find(item => item.message === text).cwd).toBe(pinned);
|
|
279
|
+
expect(JSON.parse(await page.evaluate(key => localStorage.getItem(key) || '{"records":[]}', storageKey)).records).toEqual([]);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
test('a dropdown change while the first prompt is pending never redirects it', async ({ page, emptyStartup }) => {
|
|
283
|
+
const { current, pinned } = await readyWithThread(page, emptyStartup);
|
|
284
|
+
await openPalette(page);
|
|
285
|
+
await paletteOption(page, /current-project/).click();
|
|
286
|
+
const hold = await holdCreation(page);
|
|
287
|
+
const text = 'Captured in the current folder';
|
|
288
|
+
await page.locator('#promptInput').fill(text);
|
|
289
|
+
await page.locator('#sendButton').click();
|
|
290
|
+
const created = await hold.created;
|
|
291
|
+
// The pending send shows the message at once, so the start card leaves.
|
|
292
|
+
await expect(page.locator('.message.user').first()).toContainText(text);
|
|
293
|
+
await expect(page.locator('#promptInput')).toHaveValue('');
|
|
294
|
+
await expect(workspaceButton(page)).toHaveCount(0);
|
|
295
|
+
// Returning to the pending draft brings the card back; its folder must still be locked.
|
|
296
|
+
await page.locator('#tabBar [role="tab"]').first().click();
|
|
297
|
+
await page.locator('[data-draft-id] [role="tab"]').click();
|
|
298
|
+
await expect(workspaceButton(page)).toBeVisible();
|
|
299
|
+
await workspaceButton(page).click();
|
|
300
|
+
await pickerOption(page, /pinned-project/).click();
|
|
301
|
+
await expect(page.getByText('The first message is already starting this thread; its folder stays unchanged.').first()).toBeAttached();
|
|
302
|
+
await expect(workspaceButton(page)).toHaveText(current);
|
|
303
|
+
hold.release();
|
|
304
|
+
await expect.poll(async () => (await emptyStartup.commands()).filter(item => item.type === 'prompt' && item.message === text)).toHaveLength(1);
|
|
305
|
+
expect(created.cwd).toBe(current);
|
|
306
|
+
expect((await emptyStartup.commands()).find(item => item.message === text).cwd).toBe(current);
|
|
307
|
+
const tabs = (await emptyStartup.api('/api/tabs')).tabs;
|
|
308
|
+
expect(tabs).toHaveLength(2);
|
|
309
|
+
expect(tabs.map(tab => tab.cwd)).not.toContain(pinned);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
test('a Browse choice that resolves after navigation does not pull the user into a new draft', async ({ page, emptyStartup }) => {
|
|
313
|
+
const { thread } = await readyWithThread(page, emptyStartup);
|
|
314
|
+
const creations = trackCreations(page);
|
|
315
|
+
await page.locator('#promptInput').fill('Thread composer stays');
|
|
316
|
+
await openPalette(page);
|
|
317
|
+
await paletteOption(page, /Browse…/).click();
|
|
318
|
+
await directPath(page, emptyStartup.root);
|
|
319
|
+
// Resolve the picker and navigate in one task, before the picker continuation runs.
|
|
320
|
+
await page.evaluate(() => {
|
|
321
|
+
document.querySelector('#pathPickerChooseButton').click();
|
|
322
|
+
document.querySelector('.focused-brand').click();
|
|
323
|
+
});
|
|
324
|
+
await expectDraftFolder(page, 'No Project');
|
|
325
|
+
await page.locator(`#tabBar [data-tab-id="${thread.id}"] .terminal-tab-button`).click();
|
|
326
|
+
await expect(page.locator('#promptInput')).toHaveValue('Thread composer stays');
|
|
327
|
+
expect(creations).toEqual([]);
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
test('draft text and its palette-chosen folder survive navigation and reload', async ({ page, emptyStartup }) => {
|
|
331
|
+
const { thread, pinned } = await readyWithThread(page, emptyStartup);
|
|
332
|
+
await openPalette(page);
|
|
333
|
+
await paletteOption(page, /pinned-project/).click();
|
|
334
|
+
const text = 'Reload keeps this folder';
|
|
335
|
+
await page.locator('#promptInput').fill(text);
|
|
336
|
+
await page.locator(`#tabBar [data-tab-id="${thread.id}"] .terminal-tab-button`).click();
|
|
337
|
+
const draft = page.getByRole('tab', { name: `Draft: ${text}`, exact: true });
|
|
338
|
+
await draft.click();
|
|
339
|
+
await expectDraftFolder(page, pinned);
|
|
340
|
+
await page.reload();
|
|
341
|
+
// The page URL names the real thread, so reload selects it; the draft waits in the Inbox.
|
|
342
|
+
await expect(page.locator(`#tabBar [data-tab-id="${thread.id}"] .terminal-tab-button`)).toHaveAttribute('aria-selected', 'true');
|
|
343
|
+
await draft.click();
|
|
344
|
+
await expect(page.locator('#promptInput')).toHaveValue(text);
|
|
345
|
+
await expectDraftFolder(page, pinned);
|
|
346
|
+
expect(JSON.parse(await page.evaluate(key => localStorage.getItem(key), storageKey)).records[0].cwd).toBe(pinned);
|
|
347
|
+
expect((await emptyStartup.api('/api/tabs')).tabs).toHaveLength(1);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
test('a palette choice applies its folder only to the draft it opened, even if another draft is opened during the switch', async ({ page, emptyStartup }) => {
|
|
351
|
+
const { thread, current } = await readyWithThread(page, emptyStartup);
|
|
352
|
+
await openPalette(page);
|
|
353
|
+
await paletteOption(page, /current-project/).click();
|
|
354
|
+
await page.locator('#promptInput').fill('saved draft A');
|
|
355
|
+
await page.locator(`#tabBar [data-tab-id="${thread.id}"] .terminal-tab-button`).click();
|
|
356
|
+
await openPalette(page);
|
|
357
|
+
// Both clicks run in one task, so the draft switch lands while the palette's draft opening is still awaiting.
|
|
358
|
+
await page.evaluate(() => {
|
|
359
|
+
[...document.querySelectorAll('#newThreadList [role="option"]')].find(node => node.textContent.includes('pinned-project')).click();
|
|
360
|
+
document.querySelector('[data-draft-id] [role="tab"]').click();
|
|
361
|
+
});
|
|
362
|
+
await expect(page.locator('#promptInput')).toHaveValue('saved draft A');
|
|
363
|
+
await expect(workspaceButton(page)).toHaveText(current);
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
test('clicking the palette backdrop closes it and returns focus to the New thread button', async ({ page, emptyStartup }) => {
|
|
367
|
+
await readyWithThread(page, emptyStartup);
|
|
368
|
+
await openPalette(page);
|
|
369
|
+
await page.locator('#newThreadInput').click();
|
|
370
|
+
await expect(page.locator('#newThreadDialog')).toBeVisible();
|
|
371
|
+
await page.mouse.click(4, 4);
|
|
372
|
+
await expect(page.locator('#newThreadDialog')).toBeHidden();
|
|
373
|
+
await expect(page.locator('#newTabButton')).toBeFocused();
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
test('Browse from the card dropdown returns focus to the re-rendered folder button', async ({ page, emptyStartup }) => {
|
|
377
|
+
const { pinned } = await readyWithThread(page, emptyStartup);
|
|
378
|
+
await openPalette(page);
|
|
379
|
+
await paletteOption(page, /current-project/).click();
|
|
380
|
+
await workspaceButton(page).click();
|
|
381
|
+
await pickerOption(page, /Browse/).click();
|
|
382
|
+
await directPath(page, pinned);
|
|
383
|
+
await page.locator('#pathPickerChooseButton').click();
|
|
384
|
+
await expect(workspaceButton(page)).toHaveText(pinned);
|
|
385
|
+
await expect(workspaceButton(page)).toBeFocused();
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
test('Browse from a reusable blank draft on mobile returns to Chat', async ({ page, emptyStartup }) => {
|
|
389
|
+
await page.setViewportSize({ width: 390, height: 844 });
|
|
390
|
+
const folder = join(emptyStartup.root, 'chosen');
|
|
391
|
+
await mkdir(folder);
|
|
392
|
+
await page.goto(`${emptyStartup.baseURL}/?mobileShell=v2`);
|
|
393
|
+
await expect(page.locator('#promptInput')).toBeEditable();
|
|
394
|
+
await page.getByRole('button', { name: 'Sessions', exact: true }).click();
|
|
395
|
+
await page.locator('#mobileNewCurrentDirectoryButton').click();
|
|
396
|
+
await paletteOption(page, /Browse/).click();
|
|
397
|
+
await directPath(page, folder);
|
|
398
|
+
await page.locator('#pathPickerChooseButton').click();
|
|
399
|
+
await expect(page.locator('#pathPickerDialog')).toBeHidden();
|
|
400
|
+
await expect(workspaceButton(page)).toHaveText(folder);
|
|
401
|
+
await expect(page.locator('html')).toHaveAttribute('data-mobile-shell-route', 'chat');
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
test('a stored legacy title shows as a thread in All tools', async ({ page, emptyStartup }) => {
|
|
405
|
+
const current = join(emptyStartup.root, 'current');
|
|
406
|
+
await mkdir(current);
|
|
407
|
+
const thread = (await emptyStartup.api('/api/tabs', { cwd: current, title: 'Terminal 7' })).tab;
|
|
408
|
+
await page.addInitScript(() => localStorage.setItem('pi-webui-shell-preferences-v1', JSON.stringify({ v: 1, desktopLayout: 'focused' })));
|
|
409
|
+
await page.goto(`${emptyStartup.baseURL}/?tab=${encodeURIComponent(thread.id)}`);
|
|
410
|
+
await expect(page.locator('.focused-title')).toHaveText('Thread 7');
|
|
411
|
+
await page.getByRole('navigation', { name: 'Workspace destinations' }).getByRole('button', { name: 'All tools', exact: true }).click();
|
|
412
|
+
await expect(page.locator('.tools-launcher-context')).toHaveText('Thread 7');
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
test('a No project draft ignores the git footer cached by the previous thread', async ({ page, emptyStartup }) => {
|
|
416
|
+
const { current } = await readyWithThread(page, emptyStartup);
|
|
417
|
+
await page.evaluate(cwd => localStorage.setItem('pi-webui-git-footer-webui-payload-cache', JSON.stringify({
|
|
418
|
+
cwd,
|
|
419
|
+
raw: JSON.stringify({ type: 'firstpick.git-footer-status.footer', version: 1, main: [{ key: 'cwd', label: 'CWD', value: 'stale-previous-thread' }], meta: [] }),
|
|
420
|
+
})), current);
|
|
421
|
+
await openPalette(page);
|
|
422
|
+
await paletteOption(page, /No project/).click();
|
|
423
|
+
await expectDraftFolder(page, 'No Project');
|
|
424
|
+
await expect(page.locator('#statusBar')).toContainText('Ready for your first message');
|
|
425
|
+
await expect(page.locator('#statusBar')).not.toContainText('stale-previous-thread');
|
|
426
|
+
await expect(page.locator('#statusBar')).not.toHaveClass(/statusbar-git-footer/);
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
test('the first prompt shows at once and is sent before the new thread finishes loading its UI', async ({ page, emptyStartup }) => {
|
|
430
|
+
await readyWithThread(page, emptyStartup);
|
|
431
|
+
await openPalette(page);
|
|
432
|
+
await paletteOption(page, /current-project/).click();
|
|
433
|
+
const hold = await holdCreation(page);
|
|
434
|
+
const timeline = [];
|
|
435
|
+
// A freshly started Pi answers its first reads slowly; the prompt must not wait for them.
|
|
436
|
+
await page.route('**/api/state?*', async route => {
|
|
437
|
+
await delay(1500);
|
|
438
|
+
await route.continue().catch(() => {});
|
|
439
|
+
});
|
|
440
|
+
page.on('request', request => {
|
|
441
|
+
const path = new URL(request.url()).pathname;
|
|
442
|
+
if (path === '/api/prompt' || path === '/api/state') timeline.push(`start ${path}`);
|
|
443
|
+
});
|
|
444
|
+
page.on('requestfinished', request => {
|
|
445
|
+
if (new URL(request.url()).pathname === '/api/state') timeline.push('end /api/state');
|
|
446
|
+
});
|
|
447
|
+
const text = 'Show me before the thread exists';
|
|
448
|
+
await page.locator('#promptInput').fill(text);
|
|
449
|
+
await page.locator('#sendButton').click();
|
|
450
|
+
await hold.created;
|
|
451
|
+
await expect(page.locator('.message.user').first()).toContainText(text);
|
|
452
|
+
await expect(page.locator('#promptInput')).toHaveValue('');
|
|
453
|
+
hold.release();
|
|
454
|
+
await expect.poll(async () => (await emptyStartup.commands()).filter(item => item.type === 'prompt' && item.message === text)).toHaveLength(1);
|
|
455
|
+
const promptAt = timeline.indexOf('start /api/prompt');
|
|
456
|
+
expect(promptAt, timeline.join(', ')).toBeGreaterThanOrEqual(0);
|
|
457
|
+
const firstStateEnd = timeline.indexOf('end /api/state');
|
|
458
|
+
expect(firstStateEnd === -1 || promptAt < firstStateEnd, timeline.join(', ')).toBe(true);
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
test('a failed thread start puts the prompt back, followed by text typed while it was starting', async ({ page, emptyStartup }) => {
|
|
462
|
+
const { current } = await readyWithThread(page, emptyStartup);
|
|
463
|
+
await openPalette(page);
|
|
464
|
+
await paletteOption(page, /current-project/).click();
|
|
465
|
+
let release;
|
|
466
|
+
const released = new Promise(resolve => { release = resolve; });
|
|
467
|
+
await page.route('**/api/tabs', async route => {
|
|
468
|
+
if (route.request().method() !== 'POST') return route.continue();
|
|
469
|
+
await Promise.race([released, delay(5000)]);
|
|
470
|
+
await route.fulfill({ status: 500, json: { success: false, error: 'Pi could not start' } });
|
|
471
|
+
});
|
|
472
|
+
await page.locator('#promptInput').fill('Original first prompt');
|
|
473
|
+
await page.locator('#sendButton').click();
|
|
474
|
+
await expect(page.locator('.message.user').first()).toContainText('Original first prompt');
|
|
475
|
+
await page.locator('#promptInput').fill('typed while starting');
|
|
476
|
+
release();
|
|
477
|
+
await expect(page.locator('#promptInput')).toHaveValue('Original first prompt\n\ntyped while starting');
|
|
478
|
+
await expect(page.locator('.message.user')).toHaveCount(0);
|
|
479
|
+
await expectDraftFolder(page, current);
|
|
480
|
+
expect((await emptyStartup.api('/api/tabs')).tabs).toHaveLength(1);
|
|
481
|
+
});
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { expect } from '@playwright/test';
|
|
4
|
+
import { test } from './session-fixture.mjs';
|
|
5
|
+
import { navigateFocused } from './focused-navigation-fixture.mjs';
|
|
6
|
+
|
|
7
|
+
test.use({ video: 'off', serviceWorkers: 'block', launchOptions: { executablePath: '/usr/bin/chromium' }, viewport: { width: 1440, height: 900 } });
|
|
8
|
+
test.setTimeout(45_000);
|
|
9
|
+
|
|
10
|
+
test.beforeEach(async ({ page }) => {
|
|
11
|
+
await page.addInitScript(() => localStorage.setItem('pi-webui-shell-preferences-v1', JSON.stringify({ v: 1, desktopLayout: 'focused' })));
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
async function open(page, ownership) {
|
|
15
|
+
await page.goto(`${ownership.baseURL}/?tab=${encodeURIComponent(ownership.tabs[0].id)}`);
|
|
16
|
+
await expect(page.locator('#modelSelect')).not.toBeEmpty();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function topic(page, destination, name) {
|
|
20
|
+
await navigateFocused(page, destination);
|
|
21
|
+
await page.getByRole('combobox', { name: `${destination} section`, exact: true }).selectOption({ label: name });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
test('custom runner configuration, discovery and process lifecycle', async ({ page, ownership }, info) => {
|
|
25
|
+
const project = ownership.tabs[0].cwd;
|
|
26
|
+
await mkdir(join(project, 'tools'));
|
|
27
|
+
await writeFile(join(project, 'tools', 'interactive.sh'), '#!/bin/sh\nprintf "ready\\n"\nwhile IFS= read -r line; do printf "echo:%s\\n" "$line"; done\n');
|
|
28
|
+
await open(page, ownership);
|
|
29
|
+
await topic(page, 'Project', 'Runners');
|
|
30
|
+
await page.locator('#appRunnerInfoButton').click();
|
|
31
|
+
const dialog = page.locator('#appRunnerInfoDialog');
|
|
32
|
+
const paths = dialog.locator('.app-runner-search-path-section');
|
|
33
|
+
await paths.getByRole('button', { name: 'Browse…' }).click();
|
|
34
|
+
await paths.getByRole('button', { name: 'Use tools as a project discovery path' }).click();
|
|
35
|
+
await paths.getByRole('button', { name: 'Add path' }).click();
|
|
36
|
+
await expect(paths.getByRole('button', { name: 'Remove project discovery path tools' })).toBeVisible();
|
|
37
|
+
await paths.locator('#appRunnerSearchPathInput').fill('unused');
|
|
38
|
+
await paths.getByRole('button', { name: 'Reset', exact: true }).click();
|
|
39
|
+
await expect(paths.locator('#appRunnerSearchPathInput')).toHaveValue('');
|
|
40
|
+
const custom = dialog.locator('.app-runner-custom-section');
|
|
41
|
+
await custom.locator('#appRunnerCustomLabelInput').fill('Interactive fixture');
|
|
42
|
+
await custom.locator('#appRunnerCustomCommandInput').fill('sh');
|
|
43
|
+
await custom.locator('#appRunnerCustomPathInput').fill('tools/interactive.sh');
|
|
44
|
+
await custom.getByRole('button', { name: 'Add runner' }).click();
|
|
45
|
+
await expect(custom.locator('.app-runner-custom-item')).toContainText('Interactive fixture');
|
|
46
|
+
await custom.locator('.app-runner-custom-item').getByRole('button', { name: 'Edit' }).click();
|
|
47
|
+
await custom.locator('#appRunnerCustomLabelInput').fill('Edited fixture');
|
|
48
|
+
await custom.getByRole('button', { name: 'Save changes' }).click();
|
|
49
|
+
await expect(custom.locator('.app-runner-custom-item')).toContainText('Edited fixture');
|
|
50
|
+
await page.screenshot({ path: info.outputPath('runner-config.png') });
|
|
51
|
+
await dialog.getByRole('button', { name: 'Close', exact: true }).click();
|
|
52
|
+
await page.locator('#appRunnerMenuPanel button').filter({ hasText: 'Edited fixture' }).first().click();
|
|
53
|
+
const widget = page.locator('.app-runner-widget');
|
|
54
|
+
await expect(widget).toContainText('ready');
|
|
55
|
+
await widget.locator('.app-runner-stdin-input').fill('hello');
|
|
56
|
+
await widget.locator('.app-runner-stdin-input').press('Enter');
|
|
57
|
+
await expect(widget).toContainText('echo:hello');
|
|
58
|
+
await widget.getByRole('button', { name: 'Stop', exact: true }).click();
|
|
59
|
+
await expect(widget.getByRole('button', { name: 'Stop', exact: true })).toHaveCount(0);
|
|
60
|
+
await page.locator('#appRunnerInfoButton').click();
|
|
61
|
+
await custom.locator('.app-runner-custom-item').getByRole('button', { name: 'Delete' }).click();
|
|
62
|
+
await expect(custom).toContainText('No custom runners saved');
|
|
63
|
+
await paths.getByRole('button', { name: 'Remove project discovery path tools' }).click();
|
|
64
|
+
await expect(paths).toContainText('No project discovery paths configured');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('Agents Auto-Clear and populated retry gate render', async ({ page, ownership }, info) => {
|
|
68
|
+
const tab = ownership.tabs[0].id;
|
|
69
|
+
await ownership.api(`/api/prompt?tab=${encodeURIComponent(tab)}`, { message: 'fixture subagents running', requestId: 'activity-controls-gate' });
|
|
70
|
+
await open(page, ownership);
|
|
71
|
+
await topic(page, 'Activity', 'Agents');
|
|
72
|
+
const toggle = page.locator('#subagentsAutoClearButton');
|
|
73
|
+
await expect(toggle).toHaveAttribute('aria-pressed', 'false');
|
|
74
|
+
await toggle.click();
|
|
75
|
+
await expect(toggle).toHaveAttribute('aria-pressed', 'true');
|
|
76
|
+
await toggle.click();
|
|
77
|
+
await expect(toggle).toHaveAttribute('aria-pressed', 'false');
|
|
78
|
+
await expect(page.locator('#subagentsBox')).toContainText('reviewer');
|
|
79
|
+
await expect(page.locator('.subagent-gate-card')).toContainText('reviewer');
|
|
80
|
+
await page.locator('#subagentLaunchSlots summary').click();
|
|
81
|
+
await expect(page.locator('#subagentLaunchSlotsStatus')).not.toContainText('Loading');
|
|
82
|
+
await page.screenshot({ path: info.outputPath('agents.png') });
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('steering queue is displayed alongside editable follow-ups', async ({ page, ownership }, info) => {
|
|
86
|
+
const tab = ownership.tabs[0].id;
|
|
87
|
+
await open(page, ownership);
|
|
88
|
+
await topic(page, 'Activity', 'Queues');
|
|
89
|
+
await ownership.api(`/api/queue/mutate?tab=${encodeURIComponent(tab)}`, { source: 'pi-runtime', kind: 'followUp', expected: { steering: ['runtime steering'], followUp: ['runtime first', 'runtime second', 'runtime third'] }, operation: { type: 'edit', index: 0, expectedText: 'runtime first', text: 'runtime first' } });
|
|
90
|
+
await expect(page.locator('#queueBox')).toContainText('runtime steering');
|
|
91
|
+
await expect(page.locator('#queueBox')).toContainText('runtime first');
|
|
92
|
+
await page.screenshot({ path: info.outputPath('steering-queue.png') });
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
for (const viewport of [{ width: 390, height: 844 }, { width: 768, height: 1024 }]) {
|
|
96
|
+
test(`Classic queues and agents are reachable at ${viewport.width}px`, async ({ page, ownership }, info) => {
|
|
97
|
+
await page.setViewportSize(viewport);
|
|
98
|
+
await page.goto(ownership.baseURL);
|
|
99
|
+
await expect(page.locator('#modelSelect')).not.toBeEmpty();
|
|
100
|
+
const expand = page.locator('#sidePanelExpandButton');
|
|
101
|
+
if (await expand.isVisible()) await expand.click();
|
|
102
|
+
for (const name of ['Subagents', 'Queue', 'Events']) {
|
|
103
|
+
const control = page.locator(`#sidePanelSectionToggle${name}`);
|
|
104
|
+
if (await control.getAttribute('aria-expanded') !== 'true') await control.click();
|
|
105
|
+
await expect(control).toHaveAttribute('aria-expanded', 'true');
|
|
106
|
+
await control.click();
|
|
107
|
+
await expect(control).toHaveAttribute('aria-expanded', 'false');
|
|
108
|
+
}
|
|
109
|
+
await page.locator('#sidePanelSectionToggleSubagents').click();
|
|
110
|
+
await expect(page.locator('#subagentsAutoClearButton')).toBeVisible();
|
|
111
|
+
await page.screenshot({ path: info.outputPath(`agents-${viewport.width}.png`) });
|
|
112
|
+
await page.locator('#toggleSidePanelButton').click();
|
|
113
|
+
await expect(expand).toBeVisible();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
test('runner input failure keeps the draft and reports an event', async ({ page, ownership }) => {
|
|
118
|
+
const project = ownership.tabs[0].cwd;
|
|
119
|
+
await writeFile(join(project, 'fixture.sh'), '#!/bin/sh\nprintf "ready\\n"\nwhile IFS= read -r line; do printf "%s\\n" "$line"; done\n');
|
|
120
|
+
await page.route('**/api/app-runner/input?*', route => route.fulfill({ status: 500, json: { ok: false, error: 'fixture input failure' } }));
|
|
121
|
+
await open(page, ownership);
|
|
122
|
+
await topic(page, 'Project', 'Runners');
|
|
123
|
+
await page.locator('#appRunnerMenuPanel button').filter({ hasText: 'fixture.sh' }).first().click();
|
|
124
|
+
const widget = page.locator('.app-runner-widget');
|
|
125
|
+
await expect(widget).toContainText('ready');
|
|
126
|
+
const input = widget.locator('.app-runner-stdin-input');
|
|
127
|
+
await input.fill('unsent');
|
|
128
|
+
await input.press('Enter');
|
|
129
|
+
await expect(input).toHaveValue('unsent');
|
|
130
|
+
await topic(page, 'Activity', 'Events');
|
|
131
|
+
await expect(page.locator('#sidePanelSectionEvents')).toContainText('fixture input failure');
|
|
132
|
+
await topic(page, 'Project', 'Runners');
|
|
133
|
+
await widget.getByRole('button', { name: 'Stop', exact: true }).click();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('bash commands queue behind an active command and target the originating tab', async ({ page, ownership }) => {
|
|
137
|
+
const calls = [];
|
|
138
|
+
let release;
|
|
139
|
+
const held = new Promise(resolve => { release = resolve; });
|
|
140
|
+
await page.route('**/api/bash?*', async route => {
|
|
141
|
+
calls.push({ tab: new URL(route.request().url()).searchParams.get('tab'), body: route.request().postDataJSON() });
|
|
142
|
+
if (calls.length === 1) await held;
|
|
143
|
+
await route.fulfill({ json: { ok: true, data: { output: 'fixture output', exitCode: 0 } } });
|
|
144
|
+
});
|
|
145
|
+
await open(page, ownership);
|
|
146
|
+
const input = page.locator('#promptInput');
|
|
147
|
+
await input.fill('!printf first');
|
|
148
|
+
await page.locator('#sendButton').click();
|
|
149
|
+
await expect.poll(() => calls.length).toBe(1);
|
|
150
|
+
await input.fill('!printf second');
|
|
151
|
+
await page.locator('#sendButton').click();
|
|
152
|
+
await expect(page.locator('body')).toContainText('Queued behind the active bash command');
|
|
153
|
+
release();
|
|
154
|
+
await expect.poll(() => calls.length).toBe(2);
|
|
155
|
+
expect(calls).toEqual([{ tab: ownership.tabs[0].id, body: { command: 'printf first', excludeFromContext: false } }, { tab: ownership.tabs[0].id, body: { command: 'printf second', excludeFromContext: false } }]);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test('background workflow decision stays attached to its originating tab', async ({ page, ownership }) => {
|
|
159
|
+
const origin = ownership.tabs[0].id;
|
|
160
|
+
const other = ownership.tabs[1].id;
|
|
161
|
+
await open(page, ownership);
|
|
162
|
+
await page.locator(`#tabBar [data-tab-id="${other}"] .terminal-tab-button`).click();
|
|
163
|
+
const accepted = await ownership.api(`/api/prompt?tab=${encodeURIComponent(origin)}`, {
|
|
164
|
+
message: 'fixture activity model decision', requestId: 'activity-background-decision',
|
|
165
|
+
});
|
|
166
|
+
expect(accepted.output).toBe('activity decision fixture accepted');
|
|
167
|
+
await expect(page.locator(`#tabBar [data-tab-id="${origin}"] .terminal-tab-button`)).toHaveAttribute('aria-label', /Blocked/, { timeout: 16_000 });
|
|
168
|
+
await page.locator(`#tabBar [data-tab-id="${origin}"] .terminal-tab-button`).click();
|
|
169
|
+
await expect(page.locator('#dialogTitle')).toHaveText('Workflow model exception for fixture run');
|
|
170
|
+
const reply = page.waitForResponse(response => new URL(response.url()).pathname === '/api/extension-ui-response');
|
|
171
|
+
await page.getByRole('button', { name: 'Approve fixture model', exact: true }).click();
|
|
172
|
+
const response = await reply;
|
|
173
|
+
expect(response.ok()).toBe(true);
|
|
174
|
+
expect(new URL(response.url()).searchParams.get('tab')).toBe(origin);
|
|
175
|
+
expect(response.request().postDataJSON()).toEqual({ type: 'extension_ui_response', id: 'fixture-workflow-model-exception', value: 'Approve fixture model' });
|
|
176
|
+
await expect(page.locator('#dialog')).toBeHidden();
|
|
177
|
+
});
|