@firstpick/pi-package-webui 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DEVELOPMENT.md +181 -12
- package/README.md +41 -9
- package/TECHNICAL.md +91 -8
- package/bin/pi-webui.mjs +5432 -11428
- package/index.ts +10 -3
- package/lib/codex-cli-usage.mjs +232 -0
- package/lib/codex-usage-auth.mjs +39 -3
- package/lib/codex-usage-source.mjs +36 -0
- package/lib/component-update-state.mjs +2 -2
- package/lib/git-workflow-preference-values.mjs +122 -0
- package/lib/git-workflow-preferences.mjs +35 -563
- package/lib/package-updates.mjs +260 -0
- package/lib/rpc-supervisor-client.mjs +8 -4
- package/lib/server/app-runners.mjs +1667 -0
- package/lib/server/codex-fast-mode.mjs +161 -0
- package/lib/server/conversation-mode.mjs +218 -0
- package/lib/server/conversation-voice.mjs +318 -0
- package/lib/server/extension-ui-requests.mjs +114 -0
- package/lib/server/git-generation.mjs +459 -0
- package/lib/server/git-mutations.mjs +1827 -0
- package/lib/server/git-reads.mjs +608 -0
- package/lib/server/git-worktree-sessions.mjs +408 -0
- package/lib/server/helper-requests.mjs +82 -0
- package/lib/server/no-project-workspaces.mjs +103 -0
- package/lib/server/rpc-transports.mjs +394 -0
- package/lib/server/settings-store.mjs +544 -0
- package/lib/server/sse-delivery.mjs +138 -0
- package/lib/server/workspace-files.mjs +563 -0
- package/lib/update/supervisor.mjs +4 -0
- package/lib/webui-workspaces.mjs +2 -0
- package/package.json +5 -5
- package/public/activity-agents-controller.mjs +269 -0
- package/public/activity-events-controller.mjs +236 -0
- package/public/activity-intercom-controller.mjs +627 -0
- package/public/activity-queue-controller.mjs +534 -0
- package/public/activity-todo-view.mjs +89 -0
- package/public/activity-usage-controller.mjs +589 -0
- package/public/app.js +3761 -3878
- package/public/conversation-overview.css +84 -0
- package/public/conversation-overview.mjs +193 -0
- package/public/draft-conversations.mjs +135 -0
- package/public/focused-composer-controls.css +111 -0
- package/public/focused-composer-controls.mjs +143 -0
- package/public/focused-composer-disclosure.mjs +223 -0
- package/public/focused-shell-adapter.css +264 -0
- package/public/focused-shell-adapter.mjs +257 -0
- package/public/index.html +137 -80
- package/public/model-catalog-order.mjs +63 -0
- package/public/platform-event-stream.mjs +64 -0
- package/public/project-artifact-controller.mjs +218 -0
- package/public/project-file-viewer-controller.mjs +383 -0
- package/public/project-git-tools-controller.mjs +181 -0
- package/public/project-runners-controller.mjs +220 -0
- package/public/service-worker.js +52 -1
- package/public/session-attention-scheduler.mjs +182 -0
- package/public/session-composer-store.mjs +56 -0
- package/public/session-context.mjs +51 -0
- package/public/session-extension-requests.mjs +63 -0
- package/public/session-shelf-state.mjs +151 -0
- package/public/session-shelves.css +171 -0
- package/public/session-shelves.mjs +95 -0
- package/public/settings-navigation-controller.mjs +249 -0
- package/public/settings-navigation.css +61 -0
- package/public/settings-resource-controller.mjs +232 -0
- package/public/settings-workspace.css +19 -0
- package/public/settings-workspace.mjs +175 -0
- package/public/shell-actions.mjs +87 -0
- package/public/shell-attention-inbox.css +72 -0
- package/public/shell-attention-inbox.mjs +198 -0
- package/public/shell-context-actions.css +61 -0
- package/public/shell-context-actions.mjs +168 -0
- package/public/shell-inspector-resize.mjs +124 -0
- package/public/shell-navigation-resize.mjs +107 -0
- package/public/shell-navigation.mjs +127 -0
- package/public/shell-preferences.mjs +108 -0
- package/public/shell-surfaces.mjs +99 -0
- package/public/shell-tools-launcher.css +97 -0
- package/public/shell-tools-launcher.mjs +222 -0
- package/public/shell-view-host.mjs +115 -0
- package/public/shell-workspace.css +266 -0
- package/public/shell-workspace.mjs +402 -0
- package/public/sidebar-update-menu.css +190 -0
- package/public/sidebar-update-menu.mjs +512 -0
- package/public/styles.css +320 -169
- package/public/subagent-launch-slot-state.mjs +2 -2
- package/public/theme-contract.mjs +1 -1
- package/public/themed-selects.css +156 -0
- package/public/workspace-choices.mjs +104 -0
- package/tests/activity-agents-controller.test.mjs +652 -0
- package/tests/activity-events-controller.test.mjs +511 -0
- package/tests/app-runner-terminal-static.test.mjs +3 -3
- package/tests/append-system-http.test.mjs +7 -6
- package/tests/append-system-selector-static.test.mjs +6 -6
- package/tests/aur-review-widget-static.test.mjs +11 -3
- package/tests/boot-failure-diagnostics.test.mjs +8 -3
- package/tests/browser/activity-intercom-controller.spec.mjs +457 -0
- package/tests/browser/activity-navigation-integration.spec.mjs +45 -0
- package/tests/browser/activity-owner-integration.spec.mjs +201 -0
- package/tests/browser/activity-queue-controller.spec.mjs +405 -0
- package/tests/browser/activity-section-picker.spec.mjs +294 -0
- package/tests/browser/activity-todo-view.spec.mjs +60 -0
- package/tests/browser/activity-usage-controller.spec.mjs +416 -0
- package/tests/browser/compact-layout-integration.spec.mjs +58 -0
- package/tests/browser/composer-action-grid-reorder.spec.mjs +16 -0
- package/tests/browser/composer-disclosure.spec.mjs +389 -0
- package/tests/browser/composer-toolbar-polish.spec.mjs +343 -0
- package/tests/browser/control-deck-component-updates.spec.mjs +5 -14
- package/tests/browser/control-deck-side-panels.spec.mjs +27 -12
- package/tests/browser/control-visibility.spec.mjs +5 -0
- package/tests/browser/controls-layout.spec.mjs +21 -2
- package/tests/browser/conversation-overview.spec.mjs +251 -0
- package/tests/browser/draft-conversations.spec.mjs +276 -0
- package/tests/browser/empty-startup-fixture.mjs +135 -0
- package/tests/browser/empty-startup.spec.mjs +282 -0
- package/tests/browser/events-tree-context-menu.spec.mjs +1 -0
- package/tests/browser/focused-composer-more.spec.mjs +127 -0
- package/tests/browser/focused-model-shortcuts.spec.mjs +120 -0
- package/tests/browser/focused-navigation-fixture.mjs +32 -0
- package/tests/browser/focused-project-activity.spec.mjs +111 -0
- package/tests/browser/focused-shell-integration.spec.mjs +208 -0
- package/tests/browser/folder-picker-layout-fixture.mjs +13 -0
- package/tests/browser/folder-picker-layout.spec.mjs +302 -0
- package/tests/browser/footer-model-advanced-layout.spec.mjs +27 -14
- package/tests/browser/git-setup-cancel.spec.mjs +251 -0
- package/tests/browser/guided-git-fallback.spec.mjs +40 -21
- package/tests/browser/inspector-header.spec.mjs +221 -0
- package/tests/browser/inspector-overview-integration.spec.mjs +104 -0
- package/tests/browser/inspector-resize.spec.mjs +227 -0
- package/tests/browser/inspector-topic-overflow.spec.mjs +56 -0
- package/tests/browser/interaction-action-discovery.spec.mjs +332 -0
- package/tests/browser/interaction-attention-inbox.spec.mjs +364 -0
- package/tests/browser/interaction-attention-integration.spec.mjs +53 -0
- package/tests/browser/interaction-composer-controls.spec.mjs +267 -0
- package/tests/browser/interaction-composer-integration.spec.mjs +175 -0
- package/tests/browser/interaction-continuity.spec.mjs +50 -26
- package/tests/browser/interaction-model-picker.spec.mjs +86 -0
- package/tests/browser/last-terminal-close.spec.mjs +280 -0
- package/tests/browser/mobile-foundation.spec.mjs +172 -20
- package/tests/browser/model-catalog-groups.spec.mjs +104 -0
- package/tests/browser/more-row-menus.spec.mjs +258 -0
- package/tests/browser/new-tab-hit-target.spec.mjs +228 -0
- package/tests/browser/no-project-conversation.spec.mjs +113 -0
- package/tests/browser/optimistic-prompt.spec.mjs +3 -0
- package/tests/browser/overhaul-w7-accessibility.spec.mjs +227 -0
- package/tests/browser/overhaul-w7-capabilities.spec.mjs +298 -0
- package/tests/browser/overhaul-w7-companions.spec.mjs +290 -0
- package/tests/browser/overhaul-w7-focus-repairs.spec.mjs +210 -0
- package/tests/browser/overhaul-w7-layout-repairs.spec.mjs +183 -0
- package/tests/browser/overhaul-w7-parent-repairs.spec.mjs +97 -0
- package/tests/browser/overhaul-w7-pwa.spec.mjs +247 -0
- package/tests/browser/overhaul-w7-responsive.spec.mjs +450 -0
- package/tests/browser/overhaul-w7-update.spec.mjs +215 -0
- package/tests/browser/overhaul-w7-zoom.spec.mjs +243 -0
- package/tests/browser/overview-agent-ownership.spec.mjs +45 -0
- package/tests/browser/persistent-ui-layout.spec.mjs +3 -0
- package/tests/browser/project-artifact-controller.spec.mjs +324 -0
- package/tests/browser/project-artifact-integration.spec.mjs +103 -0
- package/tests/browser/project-file-buffer-integration.spec.mjs +230 -0
- package/tests/browser/project-git-tools-integration.spec.mjs +369 -0
- package/tests/browser/session-fixture.mjs +118 -0
- package/tests/browser/session-ownership.spec.mjs +175 -0
- package/tests/browser/session-shelves-integration.spec.mjs +219 -0
- package/tests/browser/session-shelves.spec.mjs +340 -0
- package/tests/browser/session-sidebar-resize.spec.mjs +138 -0
- package/tests/browser/session-summary.spec.mjs +17 -12
- package/tests/browser/settings-complete-home.spec.mjs +463 -0
- package/tests/browser/settings-entrypoint.spec.mjs +104 -0
- package/tests/browser/settings-navigation-controller.spec.mjs +383 -0
- package/tests/browser/settings-navigation-integration.spec.mjs +348 -0
- package/tests/browser/settings-resource-lifetime.spec.mjs +349 -0
- package/tests/browser/settings-workspace-integration.spec.mjs +132 -0
- package/tests/browser/shell-ownership.spec.mjs +398 -0
- package/tests/browser/shell-rollout-fixture.mjs +259 -0
- package/tests/browser/shell-rollout.spec.mjs +357 -0
- package/tests/browser/shell-tools-launcher.spec.mjs +260 -0
- package/tests/browser/shell-workspace.spec.mjs +433 -0
- package/tests/browser/side-panel-section-reorder.spec.mjs +3 -1
- package/tests/browser/sidebar-floating-tooltips.spec.mjs +37 -0
- package/tests/browser/sidebar-update-integration.spec.mjs +277 -0
- package/tests/browser/sidebar-update-menu.spec.mjs +402 -0
- package/tests/browser/sidebar-update-progress.spec.mjs +472 -0
- package/tests/browser/stream-output-isolation.spec.mjs +6 -3
- package/tests/browser/themed-selects.spec.mjs +297 -0
- package/tests/browser/thread-start-flow.spec.mjs +481 -0
- package/tests/browser/ui-polish-activity-controls.spec.mjs +177 -0
- package/tests/browser/ui-polish-features.spec.mjs +85 -0
- package/tests/browser/ui-polish-file-header.spec.mjs +43 -0
- package/tests/browser/ui-polish-local-git.spec.mjs +183 -0
- package/tests/browser/ui-polish-mobile-recovery.spec.mjs +36 -0
- package/tests/browser/ui-polish-navigation.spec.mjs +127 -0
- package/tests/browser/ui-polish-session-actions.spec.mjs +282 -0
- package/tests/browser/user-noticeable-fixes.spec.mjs +10 -3
- package/tests/browser/windows-drive-parent.spec.mjs +4 -2
- package/tests/browser/workspace-draft-selection.spec.mjs +266 -0
- package/tests/codex-cli-usage.test.mjs +189 -0
- package/tests/codex-fast-mode-static.test.mjs +16 -11
- package/tests/codex-speed-mode-browser-state.test.mjs +6 -3
- package/tests/codex-usage-auth.test.mjs +168 -9
- package/tests/codex-usage-http.test.mjs +124 -0
- package/tests/codex-usage-source.test.mjs +146 -0
- package/tests/component-update-api-static.test.mjs +2 -2
- package/tests/composer-action-grid-reorder-static.test.mjs +3 -3
- package/tests/control-deck-component-updates-static.test.mjs +9 -4
- package/tests/control-visibility-static.test.mjs +3 -3
- package/tests/controls-layout-static.test.mjs +5 -5
- package/tests/conversation-overview-adapter.test.mjs +100 -0
- package/tests/document-artifact-static.test.mjs +2 -1
- package/tests/draft-conversations.test.mjs +205 -0
- package/tests/empty-startup-launcher.test.mjs +197 -0
- package/tests/events-tree-context-menu-static.test.mjs +22 -18
- package/tests/fake-pi-session-ownership.test.mjs +302 -0
- package/tests/fast-mode-client-static.test.mjs +1 -1
- package/tests/feature-decision-output-popup-static.test.mjs +2 -2
- package/tests/feature-system-prompt-optional-feature-static.test.mjs +1 -1
- package/tests/file-viewer-image-static.test.mjs +15 -11
- package/tests/file-viewer-search-static.test.mjs +5 -5
- package/tests/fixtures/fake-codex-app-server.mjs +61 -0
- package/tests/fixtures/fake-pi.mjs +41 -9
- package/tests/footer-provider-usage-visual-static.test.mjs +7 -6
- package/tests/foreground-transcript-catch-up-static.test.mjs +7 -4
- package/tests/git-footer-context-menu-static.test.mjs +1 -1
- package/tests/git-panel-file-preview-static.test.mjs +41 -48
- package/tests/git-panel-live-updates-static.test.mjs +2 -1
- package/tests/git-workflow-dispatch.test.mjs +66 -0
- package/tests/git-workflow-preferences.test.mjs +9 -1
- package/tests/guided-git-activation-static.test.mjs +14 -11
- package/tests/guided-git-fallback-ui-static.test.mjs +8 -5
- package/tests/guided-git-message-reliability-static.test.mjs +10 -6
- package/tests/guided-git-publication-backend-static.test.mjs +16 -11
- package/tests/http-endpoints-harness.test.mjs +29 -9
- package/tests/interaction-state-stability-static.test.mjs +4 -3
- package/tests/intercom-conversation-viewer-static.test.mjs +29 -17
- package/tests/intercom-tag-layout-static.test.mjs +13 -12
- package/tests/intercom-tag-overflow-layout.test.mjs +11 -10
- package/tests/main-output-loading-static.test.mjs +4 -4
- package/tests/middle-button-drag-scroll-static.test.mjs +3 -3
- package/tests/mobile-compact-layout.test.mjs +2 -2
- package/tests/mobile-continuity-tablet-static.test.mjs +3 -3
- package/tests/mobile-foundation-static.test.mjs +10 -7
- package/tests/mobile-phone-experience-static.test.mjs +3 -2
- package/tests/mobile-static.test.mjs +173 -135
- package/tests/model-catalog-order.test.mjs +103 -0
- package/tests/native-parity.test.mjs +6 -4
- package/tests/native-session-choice-owner.test.mjs +102 -0
- package/tests/native-update-lifecycle.test.mjs +10 -5
- package/tests/no-project-http-harness.test.mjs +328 -0
- package/tests/no-project-navigation.test.mjs +54 -0
- package/tests/no-project-workspaces.test.mjs +77 -0
- package/tests/open-issue-wizard-static.test.mjs +1 -1
- package/tests/optional-feature-migration-frontend.test.mjs +4 -4
- package/tests/optional-feature-prompt-impact-static.test.mjs +3 -3
- package/tests/package-updates.test.mjs +630 -0
- package/tests/persistent-ui-layout-static.test.mjs +3 -3
- package/tests/platform-event-stream.test.mjs +253 -0
- package/tests/project-file-viewer-controller.test.mjs +652 -0
- package/tests/project-git-tools-adapter.test.mjs +103 -0
- package/tests/project-git-tools-controller.test.mjs +577 -0
- package/tests/project-runners-controller.test.mjs +453 -0
- package/tests/prompt-input-vertical-scroll-static.test.mjs +3 -3
- package/tests/prompt-routing-input-clear-static.test.mjs +2 -2
- package/tests/questionnaire-dialog.test.mjs +6 -6
- package/tests/queue-edit-reorder-static.test.mjs +48 -51
- package/tests/rpc-supervisor-host.test.mjs +4 -1
- package/tests/safety-guard-auto-review-static.test.mjs +1 -1
- package/tests/sampling-native-controls-user-flow.test.mjs +7 -1
- package/tests/server-app-runners.test.mjs +536 -0
- package/tests/server-codex-fast-mode.test.mjs +346 -0
- package/tests/server-conversation-mode.test.mjs +386 -0
- package/tests/server-conversation-voice.test.mjs +426 -0
- package/tests/server-extension-ui-requests.test.mjs +357 -0
- package/tests/server-git-generation.test.mjs +558 -0
- package/tests/server-git-mutations.test.mjs +729 -0
- package/tests/server-git-reads.test.mjs +381 -0
- package/tests/server-git-worktree-sessions.test.mjs +502 -0
- package/tests/server-helper-requests.test.mjs +364 -0
- package/tests/server-rpc-transports.test.mjs +553 -0
- package/tests/server-settings-store.test.mjs +132 -0
- package/tests/server-shell-rollout.test.mjs +478 -0
- package/tests/server-sse-delivery.test.mjs +410 -0
- package/tests/server-workspace-files.test.mjs +546 -0
- package/tests/session-attention-scheduler.test.mjs +514 -0
- package/tests/session-composer-store.test.mjs +153 -0
- package/tests/session-context.test.mjs +134 -0
- package/tests/session-extension-requests.test.mjs +193 -0
- package/tests/session-ownership-adapter.test.mjs +130 -0
- package/tests/session-sampling-ui-static.test.mjs +10 -4
- package/tests/session-send-lifetime.test.mjs +140 -0
- package/tests/session-shelf-state.test.mjs +348 -0
- package/tests/session-shelves-adapter.test.mjs +79 -0
- package/tests/session-summary-lifetime.test.mjs +54 -0
- package/tests/settings-resource-controller.test.mjs +548 -0
- package/tests/shell-action-adapter.test.mjs +169 -0
- package/tests/shell-actions.test.mjs +182 -0
- package/tests/shell-navigation.test.mjs +348 -0
- package/tests/shell-preferences.test.mjs +367 -0
- package/tests/side-panel-section-height-removal-static.test.mjs +3 -3
- package/tests/stream-output-isolation-static.test.mjs +1 -1
- package/tests/subagent-gate-visibility.test.mjs +1 -1
- package/tests/subagent-launch-slot-state.test.mjs +2 -2
- package/tests/subagent-launch-slots-static.test.mjs +1 -1
- package/tests/subagent-observability-static.test.mjs +2 -2
- package/tests/subagent-reliability-integration.test.mjs +13 -30
- package/tests/syntax-highlighting-static.test.mjs +3 -3
- package/tests/tab-close-continuity-static.test.mjs +1 -1
- package/tests/tab-metadata-ordering.test.mjs +99 -0
- package/tests/terminal-cwd-grouping-static.test.mjs +2 -2
- package/tests/terminal-tab-prompt-tooltip-static.test.mjs +2 -0
- package/tests/terminal-tab-workspace-static.test.mjs +5 -4
- package/tests/terminal-tabs-resize-static.test.mjs +1 -1
- package/tests/theme-contract.test.mjs +10 -3
- package/tests/theme-customizer-static.test.mjs +1 -1
- package/tests/thread-display-title.test.mjs +44 -0
- package/tests/update-api-harness.test.mjs +15 -14
- package/tests/update-tab-restore-harness.test.mjs +3 -0
- package/tests/webui-settings-locking.test.mjs +2 -2
- package/tests/windows-drive-cwd-picker-static.test.mjs +7 -9
- package/tests/workspace-choices.test.mjs +114 -0
- package/tests/workspace-save-load-static.test.mjs +7 -4
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
.conversation-overview {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
width: var(--overview-width, 288px);
|
|
6
|
+
max-width: 100%;
|
|
7
|
+
max-height: none;
|
|
8
|
+
min-width: 0;
|
|
9
|
+
min-height: 0;
|
|
10
|
+
pointer-events: auto;
|
|
11
|
+
overflow: visible;
|
|
12
|
+
color: var(--text);
|
|
13
|
+
background: var(--panel-3);
|
|
14
|
+
border: 1px solid var(--border);
|
|
15
|
+
border-radius: 10px;
|
|
16
|
+
box-shadow: 0 8px 24px var(--shadow, rgba(0, 0, 0, 0.18));
|
|
17
|
+
backdrop-filter: blur(14px);
|
|
18
|
+
font-family: inherit;
|
|
19
|
+
font-size: var(--text-xs, 0.75rem);
|
|
20
|
+
line-height: 1.45;
|
|
21
|
+
text-align: left;
|
|
22
|
+
overflow-wrap: anywhere;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.conversation-overview-header {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: flex-start;
|
|
28
|
+
flex: 0 0 auto;
|
|
29
|
+
gap: 8px;
|
|
30
|
+
padding: 10px 10px 8px 12px;
|
|
31
|
+
border-bottom: 1px solid var(--border);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.conversation-overview-heading { flex: 1; min-width: 0; }
|
|
35
|
+
.conversation-overview-title { display: block; font-size: var(--text-sm, 0.875rem); font-weight: 600; }
|
|
36
|
+
.conversation-overview-context { display: block; margin-top: 2px; color: var(--muted); }
|
|
37
|
+
|
|
38
|
+
.conversation-overview .conversation-overview-close,
|
|
39
|
+
.conversation-overview .conversation-overview-action {
|
|
40
|
+
display: inline-flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
justify-content: center;
|
|
43
|
+
flex: 0 0 auto;
|
|
44
|
+
min-width: 28px;
|
|
45
|
+
min-height: 28px;
|
|
46
|
+
margin: 0;
|
|
47
|
+
padding: 2px 6px;
|
|
48
|
+
border: 1px solid transparent;
|
|
49
|
+
border-radius: 6px;
|
|
50
|
+
background: transparent;
|
|
51
|
+
color: var(--muted);
|
|
52
|
+
box-shadow: none;
|
|
53
|
+
font: inherit;
|
|
54
|
+
line-height: 1;
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
transform: none;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.conversation-overview .conversation-overview-close { font-size: 1.125rem; }
|
|
60
|
+
.conversation-overview button:hover:not(:disabled) { background: var(--panel-2); color: var(--text); border-color: var(--border); }
|
|
61
|
+
.conversation-overview button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
|
|
62
|
+
.conversation-overview button:disabled { cursor: default; opacity: 0.55; }
|
|
63
|
+
.conversation-overview-content { min-height: 0; overflow: visible; }
|
|
64
|
+
.conversation-overview-wide .conversation-overview-content { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
65
|
+
.conversation-overview-wide .conversation-overview-section { border-top: 0; }
|
|
66
|
+
.conversation-overview-wide .conversation-overview-section:nth-child(even) { border-left: 1px solid var(--border); }
|
|
67
|
+
/* Only screen constraints may scroll the whole card; its rows have no height cap. */
|
|
68
|
+
html[data-desktop-shell="focused"] #focusedWorkspace .focused-overview-host { overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
|
|
69
|
+
html[data-desktop-shell="focused"] #focusedWorkspace .focused-overview-host::-webkit-scrollbar { display: none; }
|
|
70
|
+
.conversation-overview-section { padding: 10px 12px; }
|
|
71
|
+
.conversation-overview-section + .conversation-overview-section { border-top: 1px solid var(--border); }
|
|
72
|
+
.conversation-overview-section-title { margin: 0 0 6px; color: var(--muted); font-size: inherit; font-weight: 600; }
|
|
73
|
+
.conversation-overview-items { display: grid; gap: 8px; }
|
|
74
|
+
.conversation-overview-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; column-gap: 6px; }
|
|
75
|
+
.conversation-overview-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
|
|
76
|
+
.conversation-overview-label { flex: 1 1 auto; color: var(--muted); }
|
|
77
|
+
.conversation-overview-value { min-width: 0; color: var(--text); }
|
|
78
|
+
.conversation-overview-detail,
|
|
79
|
+
.conversation-overview-reason { grid-column: 1 / -1; display: block; color: var(--muted); margin-top: 2px; }
|
|
80
|
+
.conversation-overview-progress { grid-column: 1 / -1; height: 4px; margin-top: 6px; overflow: hidden; border-radius: 2px; background: var(--panel-2); }
|
|
81
|
+
.conversation-overview-progress-fill { display: block; height: 100%; background: var(--accent); }
|
|
82
|
+
|
|
83
|
+
.conversation-overview [hidden],
|
|
84
|
+
.conversation-overview[hidden] { display: none; }
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/** Creates a nonmodal summary. The caller supplies snapshots and authorizes actions. */
|
|
2
|
+
export function createConversationOverview({ document, onClose, onAction }) {
|
|
3
|
+
let disposed = false;
|
|
4
|
+
let open = false;
|
|
5
|
+
let target;
|
|
6
|
+
const sections = new Map();
|
|
7
|
+
const actions = new WeakMap();
|
|
8
|
+
|
|
9
|
+
function node(tag, className, text) {
|
|
10
|
+
const result = document.createElement(tag);
|
|
11
|
+
result.className = className;
|
|
12
|
+
if (text !== undefined) result.textContent = text;
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const element = node('section', 'conversation-overview');
|
|
17
|
+
element.setAttribute('role', 'region');
|
|
18
|
+
element.setAttribute('aria-label', 'Conversation overview');
|
|
19
|
+
element.hidden = true;
|
|
20
|
+
element.inert = true;
|
|
21
|
+
const header = node('header', 'conversation-overview-header');
|
|
22
|
+
const heading = node('div', 'conversation-overview-heading');
|
|
23
|
+
const title = node('strong', 'conversation-overview-title');
|
|
24
|
+
const context = node('span', 'conversation-overview-context');
|
|
25
|
+
heading.append(title, context);
|
|
26
|
+
const close = node('button', 'conversation-overview-close', '×');
|
|
27
|
+
close.type = 'button';
|
|
28
|
+
close.setAttribute('aria-label', 'Close conversation overview');
|
|
29
|
+
header.append(heading, close);
|
|
30
|
+
const content = node('div', 'conversation-overview-content');
|
|
31
|
+
element.append(header, content);
|
|
32
|
+
|
|
33
|
+
function interactive() {
|
|
34
|
+
return !disposed && open && element.isConnected && !element.closest('[hidden], [inert]');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function hide() {
|
|
38
|
+
open = false;
|
|
39
|
+
element.hidden = true;
|
|
40
|
+
element.inert = true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function requestClose() {
|
|
44
|
+
if (!interactive()) return;
|
|
45
|
+
hide();
|
|
46
|
+
onClose?.();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function handleClick(event) {
|
|
50
|
+
if (!interactive()) return;
|
|
51
|
+
const button = event.target.closest('button');
|
|
52
|
+
if (!button || button.disabled || button.closest('[hidden], [inert]')) return;
|
|
53
|
+
if (button === close) return requestClose();
|
|
54
|
+
const item = actions.get(button);
|
|
55
|
+
if (item?.actionId) onAction?.(item.actionId, target);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function handleKeydown(event) {
|
|
59
|
+
if (event.key !== 'Escape' || event.defaultPrevented || !interactive()) return;
|
|
60
|
+
if (!element.contains(document.activeElement)) return;
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
event.stopPropagation();
|
|
63
|
+
requestClose();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
element.addEventListener('click', handleClick);
|
|
67
|
+
element.addEventListener('keydown', handleKeydown);
|
|
68
|
+
|
|
69
|
+
function createItem() {
|
|
70
|
+
const row = node('div', 'conversation-overview-item');
|
|
71
|
+
const summary = node('div', 'conversation-overview-summary');
|
|
72
|
+
const label = node('span', 'conversation-overview-label');
|
|
73
|
+
const value = node('span', 'conversation-overview-value');
|
|
74
|
+
summary.append(label, value);
|
|
75
|
+
const action = node('button', 'conversation-overview-action', '↗');
|
|
76
|
+
action.type = 'button';
|
|
77
|
+
const detail = node('span', 'conversation-overview-detail');
|
|
78
|
+
const reason = node('span', 'conversation-overview-reason');
|
|
79
|
+
const progress = node('div', 'conversation-overview-progress');
|
|
80
|
+
progress.setAttribute('role', 'progressbar');
|
|
81
|
+
progress.setAttribute('aria-valuemin', '0');
|
|
82
|
+
progress.setAttribute('aria-valuemax', '100');
|
|
83
|
+
const fill = node('span', 'conversation-overview-progress-fill');
|
|
84
|
+
progress.append(fill);
|
|
85
|
+
row.append(summary, action, detail, reason, progress);
|
|
86
|
+
const item = { row, label, value, action, detail, reason, progress, fill, actionId: null };
|
|
87
|
+
actions.set(action, item);
|
|
88
|
+
return item;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function setOptionalText(element, text) {
|
|
92
|
+
element.textContent = text ?? '';
|
|
93
|
+
element.hidden = !element.textContent;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function updateItem(item, snapshot) {
|
|
97
|
+
item.label.textContent = snapshot.label || 'Unknown';
|
|
98
|
+
item.value.textContent = snapshot.value === '' || snapshot.value == null ? 'Unknown' : snapshot.value;
|
|
99
|
+
setOptionalText(item.detail, snapshot.detail);
|
|
100
|
+
setOptionalText(item.reason, snapshot.reason);
|
|
101
|
+
item.actionId = snapshot.actionId;
|
|
102
|
+
item.action.hidden = !snapshot.actionId;
|
|
103
|
+
item.action.disabled = !!snapshot.disabled;
|
|
104
|
+
item.action.setAttribute('aria-label', `Open ${item.label.textContent}`);
|
|
105
|
+
if (snapshot.disabled && snapshot.reason) item.action.setAttribute('aria-description', snapshot.reason);
|
|
106
|
+
else item.action.removeAttribute('aria-description');
|
|
107
|
+
const hasProgress = Number.isFinite(snapshot.progress);
|
|
108
|
+
item.progress.hidden = !hasProgress;
|
|
109
|
+
if (hasProgress) {
|
|
110
|
+
const percent = Math.min(100, Math.max(0, snapshot.progress));
|
|
111
|
+
item.progress.setAttribute('aria-label', item.label.textContent);
|
|
112
|
+
item.progress.setAttribute('aria-valuenow', String(percent));
|
|
113
|
+
item.fill.style.width = `${percent}%`;
|
|
114
|
+
} else {
|
|
115
|
+
item.progress.removeAttribute('aria-valuenow');
|
|
116
|
+
item.fill.style.width = '';
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function place(parent, child, index) {
|
|
121
|
+
const next = parent.children[index] ?? null;
|
|
122
|
+
if (next === child) return;
|
|
123
|
+
// Native moves retain focus without needing a focus call on modern browsers.
|
|
124
|
+
if (parent.moveBefore && child.parentNode === parent) parent.moveBefore(child, next);
|
|
125
|
+
else parent.insertBefore(child, next);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function update(snapshot = {}) {
|
|
129
|
+
if (disposed) return;
|
|
130
|
+
const focused = element.contains(document.activeElement) ? document.activeElement : null;
|
|
131
|
+
target = snapshot.target;
|
|
132
|
+
title.textContent = snapshot.title || 'Overview';
|
|
133
|
+
setOptionalText(context, snapshot.context);
|
|
134
|
+
const activeSections = new Set();
|
|
135
|
+
for (const [sectionIndex, data] of (snapshot.sections ?? []).entries()) {
|
|
136
|
+
activeSections.add(data.id);
|
|
137
|
+
let section = sections.get(data.id);
|
|
138
|
+
if (!section) {
|
|
139
|
+
const root = node('section', 'conversation-overview-section');
|
|
140
|
+
const label = node('h3', 'conversation-overview-section-title');
|
|
141
|
+
const items = node('div', 'conversation-overview-items');
|
|
142
|
+
root.append(label, items);
|
|
143
|
+
section = { root, label, items, entries: new Map() };
|
|
144
|
+
sections.set(data.id, section);
|
|
145
|
+
}
|
|
146
|
+
setOptionalText(section.label, data.label);
|
|
147
|
+
const activeItems = new Set();
|
|
148
|
+
for (const [itemIndex, dataItem] of (data.items ?? []).entries()) {
|
|
149
|
+
activeItems.add(dataItem.id);
|
|
150
|
+
let item = section.entries.get(dataItem.id);
|
|
151
|
+
if (!item) {
|
|
152
|
+
item = createItem();
|
|
153
|
+
section.entries.set(dataItem.id, item);
|
|
154
|
+
}
|
|
155
|
+
updateItem(item, dataItem);
|
|
156
|
+
place(section.items, item.row, itemIndex);
|
|
157
|
+
}
|
|
158
|
+
for (const [id, item] of section.entries) {
|
|
159
|
+
if (activeItems.has(id)) continue;
|
|
160
|
+
actions.delete(item.action);
|
|
161
|
+
item.row.remove();
|
|
162
|
+
section.entries.delete(id);
|
|
163
|
+
}
|
|
164
|
+
place(content, section.root, sectionIndex);
|
|
165
|
+
}
|
|
166
|
+
for (const [id, section] of sections) {
|
|
167
|
+
if (activeSections.has(id)) continue;
|
|
168
|
+
for (const item of section.entries.values()) actions.delete(item.action);
|
|
169
|
+
section.root.remove();
|
|
170
|
+
sections.delete(id);
|
|
171
|
+
}
|
|
172
|
+
open = !!snapshot.open;
|
|
173
|
+
element.hidden = !open;
|
|
174
|
+
element.inert = !open;
|
|
175
|
+
// Only repair focus lost by a DOM move, never focus a newly opened card.
|
|
176
|
+
if (open && focused?.isConnected && document.activeElement === document.body && !focused.disabled && !focused.hidden) {
|
|
177
|
+
focused.focus({ preventScroll: true });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function dispose() {
|
|
182
|
+
if (disposed) return;
|
|
183
|
+
disposed = true;
|
|
184
|
+
hide();
|
|
185
|
+
target = undefined;
|
|
186
|
+
element.removeEventListener('click', handleClick);
|
|
187
|
+
element.removeEventListener('keydown', handleKeydown);
|
|
188
|
+
sections.clear();
|
|
189
|
+
element.remove();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return { element, update, dispose };
|
|
193
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
export const DRAFT_STORAGE_KEY = "pi-webui-draft-conversations-v1";
|
|
2
|
+
export const DRAFT_LIMITS = Object.freeze({ records: 100, text: 200_000, cwd: 4096, serialized: 2_000_000 });
|
|
3
|
+
|
|
4
|
+
const validId = id => typeof id === "string" && /^draft:[a-zA-Z0-9-]{1,80}$/.test(id);
|
|
5
|
+
const validCwd = cwd => typeof cwd === "string" && cwd.length <= DRAFT_LIMITS.cwd && !cwd.includes("\u0000");
|
|
6
|
+
|
|
7
|
+
function browserDraftId() {
|
|
8
|
+
return globalThis.crypto?.randomUUID?.() || `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function decode(raw) {
|
|
12
|
+
if (raw.length > DRAFT_LIMITS.serialized) throw new Error("Saved drafts exceed this version's storage limit.");
|
|
13
|
+
const value = JSON.parse(raw);
|
|
14
|
+
if (value?.version !== 1 || !Array.isArray(value.records) || value.records.length > DRAFT_LIMITS.records) {
|
|
15
|
+
throw new Error("Saved drafts have an unsupported or invalid format.");
|
|
16
|
+
}
|
|
17
|
+
const ids = new Set();
|
|
18
|
+
for (const record of value.records) {
|
|
19
|
+
if (!validId(record?.id) || ids.has(record.id) || typeof record.text !== "string"
|
|
20
|
+
|| record.text.length > DRAFT_LIMITS.text || !record.text.trim()
|
|
21
|
+
|| (record.cwd !== undefined && !validCwd(record.cwd))
|
|
22
|
+
|| !Number.isSafeInteger(record.revision) || record.revision < 0
|
|
23
|
+
|| !Number.isSafeInteger(record.updatedAt) || record.updatedAt < 0) {
|
|
24
|
+
throw new Error("A saved draft is invalid. The saved data was kept unchanged.");
|
|
25
|
+
}
|
|
26
|
+
ids.add(record.id);
|
|
27
|
+
}
|
|
28
|
+
if (value.activeId !== null && value.activeId !== "blank" && !ids.has(value.activeId)) {
|
|
29
|
+
throw new Error("The saved draft selection is invalid.");
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Browser drafts have no server identity. Failed writes never discard memory or overwrite unreadable data. */
|
|
35
|
+
export function createDraftConversations({ storage = () => globalThis.localStorage, randomId = browserDraftId, now = Date.now } = {}) {
|
|
36
|
+
const records = new Map();
|
|
37
|
+
let activeId = null;
|
|
38
|
+
let error = "";
|
|
39
|
+
let unreadable = false;
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const raw = storage().getItem(DRAFT_STORAGE_KEY);
|
|
43
|
+
if (raw !== null) {
|
|
44
|
+
const stored = decode(raw);
|
|
45
|
+
for (const record of stored.records) records.set(record.id, { ...record, saved: true });
|
|
46
|
+
activeId = stored.activeId;
|
|
47
|
+
}
|
|
48
|
+
} catch (cause) {
|
|
49
|
+
unreadable = true;
|
|
50
|
+
error = `Browser drafts could not be loaded. ${cause.message || cause} Existing storage is unchanged; edits remain in this page only.`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function create() {
|
|
54
|
+
const id = `draft:${randomId()}`;
|
|
55
|
+
if (!validId(id) || records.has(id)) throw new Error("Could not allocate a unique browser draft.");
|
|
56
|
+
records.set(id, { id, text: "", revision: 0, updatedAt: now(), saved: false });
|
|
57
|
+
activeId = id;
|
|
58
|
+
return id;
|
|
59
|
+
}
|
|
60
|
+
if (activeId === "blank") create();
|
|
61
|
+
|
|
62
|
+
function persist() {
|
|
63
|
+
if (unreadable) return false;
|
|
64
|
+
const saved = [...records.values()].filter(record => record.saved && record.text.trim());
|
|
65
|
+
try {
|
|
66
|
+
if (saved.length > DRAFT_LIMITS.records || saved.some(record => record.text.length > DRAFT_LIMITS.text)) {
|
|
67
|
+
throw new Error("The browser draft storage limit was reached.");
|
|
68
|
+
}
|
|
69
|
+
const serialized = JSON.stringify({
|
|
70
|
+
version: 1,
|
|
71
|
+
activeId: activeId ? saved.some(record => record.id === activeId) ? activeId : "blank" : null,
|
|
72
|
+
records: saved.map(({ id, text, revision, updatedAt, cwd }) => ({ id, text, revision, updatedAt, ...(cwd ? { cwd } : {}) })),
|
|
73
|
+
});
|
|
74
|
+
if (serialized.length > DRAFT_LIMITS.serialized) throw new Error("The browser draft storage limit was reached.");
|
|
75
|
+
storage().setItem(DRAFT_STORAGE_KEY, serialized);
|
|
76
|
+
error = "";
|
|
77
|
+
return true;
|
|
78
|
+
} catch (cause) {
|
|
79
|
+
error = `Browser drafts could not be saved. ${cause.message || cause} Edits remain in this page only; copy them before closing or reloading.`;
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
get activeId() { return activeId; },
|
|
86
|
+
get error() { return error; },
|
|
87
|
+
create,
|
|
88
|
+
get(id) { const record = records.get(id); return record ? { ...record } : null; },
|
|
89
|
+
list() { return [...records.values()].filter(record => record.saved).map(record => ({ ...record })); },
|
|
90
|
+
/** Sets the draft folder; an empty string clears it so the draft starts a No Project thread. */
|
|
91
|
+
setCwd(id, cwd) {
|
|
92
|
+
if (!validCwd(cwd)) throw new Error("The draft workspace path is invalid or too long.");
|
|
93
|
+
const record = records.get(id);
|
|
94
|
+
if (!record) return false;
|
|
95
|
+
if ((record.cwd || "") !== cwd) {
|
|
96
|
+
if (cwd) record.cwd = cwd;
|
|
97
|
+
else delete record.cwd;
|
|
98
|
+
record.revision += 1;
|
|
99
|
+
record.updatedAt = now();
|
|
100
|
+
}
|
|
101
|
+
if (record.saved) persist();
|
|
102
|
+
return true;
|
|
103
|
+
},
|
|
104
|
+
edit(id, text) {
|
|
105
|
+
const record = records.get(id);
|
|
106
|
+
if (!record) return false;
|
|
107
|
+
const next = String(text);
|
|
108
|
+
if (record.text !== next) {
|
|
109
|
+
record.text = next;
|
|
110
|
+
record.revision += 1;
|
|
111
|
+
record.updatedAt = now();
|
|
112
|
+
}
|
|
113
|
+
if (record.saved) persist();
|
|
114
|
+
return true;
|
|
115
|
+
},
|
|
116
|
+
save(id) {
|
|
117
|
+
const record = records.get(id);
|
|
118
|
+
if (record) record.saved = Boolean(record.text.trim());
|
|
119
|
+
return persist();
|
|
120
|
+
},
|
|
121
|
+
select(id) {
|
|
122
|
+
if (id !== null && !records.has(id)) return false;
|
|
123
|
+
activeId = id;
|
|
124
|
+
persist();
|
|
125
|
+
return true;
|
|
126
|
+
},
|
|
127
|
+
remove(id) {
|
|
128
|
+
const removed = records.delete(id);
|
|
129
|
+
if (activeId === id) activeId = null;
|
|
130
|
+
persist();
|
|
131
|
+
return removed;
|
|
132
|
+
},
|
|
133
|
+
persist,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
.focused-composer-controls {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-wrap: wrap;
|
|
4
|
+
align-items: flex-start;
|
|
5
|
+
gap: 8px;
|
|
6
|
+
min-width: 0;
|
|
7
|
+
max-width: 100%;
|
|
8
|
+
color: var(--text);
|
|
9
|
+
font-size: var(--text-xs, 0.75rem);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.focused-composer-controls * { box-sizing: border-box; min-width: 0; }
|
|
13
|
+
.focused-composer-controls [hidden] { display: none !important; }
|
|
14
|
+
.focused-composer-scope { padding-block: 13px; color: var(--muted); }
|
|
15
|
+
.focused-composer-setting { flex: 0 1 auto; max-width: 100%; }
|
|
16
|
+
.focused-composer-controls .focused-composer-setting-button {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: baseline;
|
|
19
|
+
gap: 6px;
|
|
20
|
+
min-height: 44px;
|
|
21
|
+
max-width: 100%;
|
|
22
|
+
padding: 8px 10px;
|
|
23
|
+
border: 1px solid var(--border);
|
|
24
|
+
border-radius: 6px;
|
|
25
|
+
background: var(--panel);
|
|
26
|
+
color: var(--text);
|
|
27
|
+
font: inherit;
|
|
28
|
+
text-align: left;
|
|
29
|
+
overflow-wrap: anywhere;
|
|
30
|
+
box-shadow: none;
|
|
31
|
+
transform: none;
|
|
32
|
+
}
|
|
33
|
+
.focused-composer-caption { flex-shrink: 0; color: var(--muted); }
|
|
34
|
+
.focused-composer-model-value, .focused-composer-effort-value { font-weight: 550; }
|
|
35
|
+
.focused-composer-setting-button:disabled { cursor: not-allowed; opacity: 0.65; }
|
|
36
|
+
.focused-composer-reason {
|
|
37
|
+
max-width: 32em;
|
|
38
|
+
margin: 4px 0 0;
|
|
39
|
+
color: var(--warning);
|
|
40
|
+
overflow-wrap: anywhere;
|
|
41
|
+
}
|
|
42
|
+
.focused-composer-busy { flex: 1 1 230px; max-width: 100%; }
|
|
43
|
+
.focused-composer-behavior-label { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; color: var(--muted); }
|
|
44
|
+
.focused-composer-controls .focused-composer-behavior {
|
|
45
|
+
flex: 0 1 auto;
|
|
46
|
+
min-width: 0;
|
|
47
|
+
min-height: 44px;
|
|
48
|
+
max-width: 100%;
|
|
49
|
+
border-radius: 6px;
|
|
50
|
+
background: var(--panel);
|
|
51
|
+
color: var(--text);
|
|
52
|
+
font: inherit;
|
|
53
|
+
appearance: auto;
|
|
54
|
+
-webkit-appearance: auto;
|
|
55
|
+
padding: 8px;
|
|
56
|
+
}
|
|
57
|
+
.focused-composer-description { margin: 4px 0 0; color: var(--muted); overflow-wrap: anywhere; }
|
|
58
|
+
.focused-composer-controls :is(button, select):focus-visible {
|
|
59
|
+
outline: 2px solid var(--accent-2, var(--accent));
|
|
60
|
+
outline-offset: -2px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
html[data-desktop-shell="focused"] #focusedWorkspace .focused-composer-controls {
|
|
64
|
+
align-items: flex-start;
|
|
65
|
+
gap: 4px 8px;
|
|
66
|
+
margin-top: 6px;
|
|
67
|
+
}
|
|
68
|
+
html[data-desktop-shell="focused"] #focusedWorkspace .focused-composer-scope {
|
|
69
|
+
display: inline-flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
min-height: 30px;
|
|
72
|
+
padding: 0 2px;
|
|
73
|
+
}
|
|
74
|
+
html[data-desktop-shell="focused"] #focusedWorkspace .focused-composer-setting {
|
|
75
|
+
max-width: min(100%, 26rem);
|
|
76
|
+
}
|
|
77
|
+
html[data-desktop-shell="focused"] #focusedWorkspace .focused-composer-setting-button {
|
|
78
|
+
align-items: center;
|
|
79
|
+
min-height: 30px;
|
|
80
|
+
padding: 4px 7px;
|
|
81
|
+
border-color: transparent;
|
|
82
|
+
background: transparent;
|
|
83
|
+
line-height: 20px;
|
|
84
|
+
}
|
|
85
|
+
html[data-desktop-shell="focused"] #focusedWorkspace .focused-composer-setting-button:not(:disabled):hover {
|
|
86
|
+
border-color: var(--border);
|
|
87
|
+
background: var(--panel-2);
|
|
88
|
+
}
|
|
89
|
+
html[data-desktop-shell="focused"] #focusedWorkspace :is(.focused-composer-model-value, .focused-composer-effort-value) {
|
|
90
|
+
overflow: hidden;
|
|
91
|
+
text-overflow: ellipsis;
|
|
92
|
+
white-space: nowrap;
|
|
93
|
+
}
|
|
94
|
+
html[data-desktop-shell="focused"] #focusedWorkspace .focused-composer-busy {
|
|
95
|
+
flex: 1 1 17rem;
|
|
96
|
+
}
|
|
97
|
+
html[data-desktop-shell="focused"] #focusedWorkspace .focused-composer-behavior {
|
|
98
|
+
min-height: 30px;
|
|
99
|
+
padding: 3px 6px;
|
|
100
|
+
border: 1px solid var(--border);
|
|
101
|
+
background: transparent;
|
|
102
|
+
}
|
|
103
|
+
html[data-desktop-shell="focused"] #focusedWorkspace :is(.focused-composer-description, .focused-composer-reason) {
|
|
104
|
+
margin-top: 2px;
|
|
105
|
+
line-height: 1.4;
|
|
106
|
+
}
|
|
107
|
+
@media (pointer: coarse) {
|
|
108
|
+
html[data-desktop-shell="focused"] #focusedWorkspace :is(.focused-composer-setting-button, .focused-composer-behavior, .focused-composer-scope) {
|
|
109
|
+
min-height: 44px;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
let nextControlId = 0;
|
|
2
|
+
|
|
3
|
+
/** Project the caller's submission state without owning submission or run controls. */
|
|
4
|
+
export function composerSubmissionPresentation({ runActive = false, behavior = 'followUp' } = {}) {
|
|
5
|
+
if (!runActive) return { label: 'Send', description: 'Send a message to this session.' };
|
|
6
|
+
if (behavior === 'steer') {
|
|
7
|
+
return { label: 'Steer run', description: 'Send guidance to Pi during this run.' };
|
|
8
|
+
}
|
|
9
|
+
return { label: 'Queue message', description: 'Queue this message for after the current run.' };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Display caller-owned effective settings. Picker callbacks receive their stable trigger button. */
|
|
13
|
+
export function createFocusedComposerControls({ document, onBehaviorChange, onModel, onEffort, onScopedModels, showSettings = true }) {
|
|
14
|
+
const id = `focusedComposerControls${++nextControlId}`;
|
|
15
|
+
const node = (tag, className, text) => {
|
|
16
|
+
const element = document.createElement(tag);
|
|
17
|
+
element.className = className;
|
|
18
|
+
if (text !== undefined) element.textContent = text;
|
|
19
|
+
return element;
|
|
20
|
+
};
|
|
21
|
+
const element = node('div', 'focused-composer-controls');
|
|
22
|
+
element.setAttribute('role', 'group');
|
|
23
|
+
element.setAttribute('aria-label', 'Session composer controls');
|
|
24
|
+
element.tabIndex = -1;
|
|
25
|
+
const scope = node('span', 'focused-composer-scope', 'Session');
|
|
26
|
+
|
|
27
|
+
function setting(kind, label) {
|
|
28
|
+
const group = node('div', 'focused-composer-setting');
|
|
29
|
+
const button = node('button', 'focused-composer-setting-button');
|
|
30
|
+
button.type = 'button';
|
|
31
|
+
const caption = node('span', 'focused-composer-caption', `${label}:`);
|
|
32
|
+
const value = node('span', `focused-composer-${kind}-value`);
|
|
33
|
+
const reason = node('p', 'focused-composer-reason');
|
|
34
|
+
reason.id = `${id}-${kind}-reason`;
|
|
35
|
+
button.append(caption, value);
|
|
36
|
+
group.append(button, reason);
|
|
37
|
+
return { group, button, value, reason };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const model = setting('model', 'Model');
|
|
41
|
+
const effort = setting('effort', 'Effort');
|
|
42
|
+
const scopedModels = node('button', 'focused-composer-setting-button focused-composer-scoped-models', 'Scoped models');
|
|
43
|
+
scopedModels.type = 'button';
|
|
44
|
+
scopedModels.hidden = !showSettings || typeof onScopedModels !== 'function';
|
|
45
|
+
scope.hidden = !showSettings;
|
|
46
|
+
model.group.hidden = !showSettings;
|
|
47
|
+
effort.group.hidden = !showSettings;
|
|
48
|
+
scopedModels.setAttribute('aria-haspopup', 'listbox');
|
|
49
|
+
scopedModels.setAttribute('aria-expanded', 'false');
|
|
50
|
+
scopedModels.title = 'Choose from your saved model scope';
|
|
51
|
+
const busy = node('div', 'focused-composer-busy');
|
|
52
|
+
const behaviorLabel = node('label', 'focused-composer-behavior-label', 'During this run');
|
|
53
|
+
const select = node('select', 'focused-composer-behavior');
|
|
54
|
+
for (const [value, text] of [['steer', 'Steer run'], ['followUp', 'Queue message']]) {
|
|
55
|
+
const option = node('option', '', text);
|
|
56
|
+
option.value = value;
|
|
57
|
+
select.append(option);
|
|
58
|
+
}
|
|
59
|
+
const description = node('p', 'focused-composer-description');
|
|
60
|
+
description.id = `${id}-description`;
|
|
61
|
+
select.setAttribute('aria-describedby', description.id);
|
|
62
|
+
behaviorLabel.append(select);
|
|
63
|
+
busy.append(behaviorLabel, description);
|
|
64
|
+
element.append(scope, model.group);
|
|
65
|
+
if (!scopedModels.hidden) element.append(scopedModels);
|
|
66
|
+
element.append(effort.group, busy);
|
|
67
|
+
|
|
68
|
+
let disposed = false;
|
|
69
|
+
let state = {
|
|
70
|
+
runActive: false, behavior: 'followUp', modelLabel: 'Not selected', effortLabel: 'Not available',
|
|
71
|
+
modelDisabled: false, effortDisabled: false, modelReason: '', effortReason: '',
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
function renderSetting(control, label, disabled, reason, fallbackReason) {
|
|
75
|
+
control.value.textContent = label;
|
|
76
|
+
control.button.disabled = Boolean(disabled);
|
|
77
|
+
control.reason.hidden = !disabled;
|
|
78
|
+
control.reason.textContent = disabled ? reason || fallbackReason : '';
|
|
79
|
+
control.button.title = disabled ? control.reason.textContent : label;
|
|
80
|
+
if (disabled) control.button.setAttribute('aria-describedby', control.reason.id);
|
|
81
|
+
else control.button.removeAttribute('aria-describedby');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function update(snapshot = {}) {
|
|
85
|
+
if (disposed) return;
|
|
86
|
+
for (const key of Object.keys(state)) {
|
|
87
|
+
if (snapshot[key] !== undefined) state[key] = snapshot[key];
|
|
88
|
+
}
|
|
89
|
+
state.behavior = state.behavior === 'steer' ? 'steer' : 'followUp';
|
|
90
|
+
const focused = document.activeElement;
|
|
91
|
+
renderSetting(model, state.modelLabel, state.modelDisabled, state.modelReason,
|
|
92
|
+
'Model selection is unavailable for this session.');
|
|
93
|
+
renderSetting(effort, state.effortLabel, state.effortDisabled, state.effortReason,
|
|
94
|
+
'Effort selection is unavailable for this session.');
|
|
95
|
+
scopedModels.disabled = Boolean(state.modelDisabled);
|
|
96
|
+
if (scopedModels.disabled) scopedModels.setAttribute('aria-describedby', model.reason.id);
|
|
97
|
+
else scopedModels.removeAttribute('aria-describedby');
|
|
98
|
+
select.value = state.behavior;
|
|
99
|
+
busy.hidden = !state.runActive;
|
|
100
|
+
select.disabled = !state.runActive;
|
|
101
|
+
description.textContent = composerSubmissionPresentation(state).description;
|
|
102
|
+
// Hidden or newly disabled controls cannot retain useful keyboard focus.
|
|
103
|
+
if ((focused === select && !state.runActive)
|
|
104
|
+
|| (focused === model.button && model.button.disabled)
|
|
105
|
+
|| (focused === scopedModels && scopedModels.disabled)
|
|
106
|
+
|| (focused === effort.button && effort.button.disabled)) {
|
|
107
|
+
const target = [...(showSettings ? [model.button, effort.button] : []), select].find((control) => !control.disabled) || element;
|
|
108
|
+
target.focus({ preventScroll: true });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function changeBehavior() {
|
|
113
|
+
if (disposed || !state.runActive || select.value === state.behavior) return;
|
|
114
|
+
state.behavior = select.value;
|
|
115
|
+
description.textContent = composerSubmissionPresentation(state).description;
|
|
116
|
+
onBehaviorChange?.(state.behavior);
|
|
117
|
+
}
|
|
118
|
+
function openModel() {
|
|
119
|
+
if (!disposed && !model.button.disabled) onModel?.(model.button);
|
|
120
|
+
}
|
|
121
|
+
function openScopedModels() {
|
|
122
|
+
if (!disposed && !scopedModels.disabled) onScopedModels?.(scopedModels);
|
|
123
|
+
}
|
|
124
|
+
function openEffort() {
|
|
125
|
+
if (!disposed && !effort.button.disabled) onEffort?.(effort.button);
|
|
126
|
+
}
|
|
127
|
+
function dispose() {
|
|
128
|
+
if (disposed) return;
|
|
129
|
+
disposed = true;
|
|
130
|
+
select.removeEventListener('change', changeBehavior);
|
|
131
|
+
model.button.removeEventListener('click', openModel);
|
|
132
|
+
scopedModels.removeEventListener('click', openScopedModels);
|
|
133
|
+
effort.button.removeEventListener('click', openEffort);
|
|
134
|
+
element.remove();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
select.addEventListener('change', changeBehavior);
|
|
138
|
+
model.button.addEventListener('click', openModel);
|
|
139
|
+
scopedModels.addEventListener('click', openScopedModels);
|
|
140
|
+
effort.button.addEventListener('click', openEffort);
|
|
141
|
+
update();
|
|
142
|
+
return { element, update, dispose };
|
|
143
|
+
}
|