mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
Merge remote-tracking branch 'origin/main' into AmethystLiang/i18n-editor-themes
# Conflicts: # src/renderer/src/hooks/composer-state/runtime-target-selection.ts # src/renderer/src/runtime/hosts/platform/execution-host-facts.ts
This commit is contained in:
@@ -627,12 +627,7 @@
|
||||
2 test-no-wall-clock:src/renderer/src/components/artifacts/ArtifactCollection.test.tsx
|
||||
1 test-no-wall-clock:src/renderer/src/components/browser-pane/assemble-chrome/browser-workspace-pane.adoption-chrome.test.tsx
|
||||
2 test-no-wall-clock:src/renderer/src/components/dashboard/useLiveDashboardSnapshot.test.ts
|
||||
1 test-no-wall-clock:src/renderer/src/components/native-chat/conversation/slots/NativeChatMessageList.opening-send.test.tsx
|
||||
1 test-no-wall-clock:src/renderer/src/components/native-chat/conversation/slots/NativeChatMessageList.queued-turn-order.test.tsx
|
||||
2 test-no-wall-clock:src/renderer/src/components/native-chat/conversation/turns/NativeChatMessageList.turn-indicator.test.tsx
|
||||
3 test-no-wall-clock:src/renderer/src/components/native-chat/conversation/turns/NativeChatResolvedView.turn-status.test.tsx
|
||||
1 test-no-wall-clock:src/renderer/src/components/native-chat/session/structured/delivery/NativeChatMessageList.unsent-message.test.tsx
|
||||
3 test-no-wall-clock:src/renderer/src/components/native-chat/surfaces/integration/NativeChatMessageList.test.tsx
|
||||
2 test-no-wall-clock:src/renderer/src/components/native-chat/tools/tasks/NativeChatStructuredSessionStatus.test.tsx
|
||||
1 test-no-wall-clock:src/renderer/src/components/sidebar/workspace-card/review/use-workspace-reference-details.test.tsx
|
||||
1 test-no-wall-clock:src/renderer/src/components/sidebar/worktree-list/listing/WorktreeList.lineage-agent-expansion-coupling.test.tsx
|
||||
@@ -643,9 +638,7 @@
|
||||
2 test-no-wall-clock:src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-removal.agent-stop.test.tsx
|
||||
1 test-no-wall-clock:src/renderer/src/components/worktree-jump/WorktreeJumpPalette.recent-tabs.behavior.test.tsx
|
||||
2 test-no-wall-clock:src/renderer/src/hooks/ipc-events/agent-status-terminal-title-tab-write.test.ts
|
||||
1 test-no-wall-clock:src/renderer/src/lib/paired-runtime-closed-tab-resume.test.ts
|
||||
2 test-no-wall-clock:src/renderer/src/lib/use-tab-agent-observed-signal-dispatch.test.tsx
|
||||
2 test-no-wall-clock:src/renderer/src/lib/wake-sleeping-agents-live-unmounted-pane.test.ts
|
||||
2 test-no-wall-clock:src/renderer/src/lib/agent-session/tab-identity/use-tab-agent-observed-signal-dispatch.test.tsx
|
||||
1 test-no-wall-clock:src/renderer/src/lib/workspace/ownership/workspace-terminal-host-authority.test.ts
|
||||
1 test-no-wall-clock:src/renderer/src/lib/workspace/activation/worktree-activation-emptied-workspace-reseed.test.ts
|
||||
2 test-no-wall-clock:src/renderer/src/store/github/pull-requests/github-pr-branch-linked-pr-divergence.test.ts
|
||||
|
||||
@@ -220,15 +220,15 @@
|
||||
1 src/renderer/src/lib/browser/navigation/http-link-localhost-route.ts # extracted from http-link-routing.ts
|
||||
1 src/renderer/src/lib/browser/navigation/http-link-routing.ts
|
||||
2 src/renderer/src/lib/browser/workspace/workspace-browser-tab-open.ts
|
||||
1 src/renderer/src/lib/client-creation-action-error.ts
|
||||
2 src/renderer/src/lib/client-creation-action-policy.ts
|
||||
1 src/renderer/src/lib/workspace/creation/surface-policy/client-creation-action-error.ts
|
||||
2 src/renderer/src/lib/workspace/creation/surface-policy/client-creation-action-policy.ts
|
||||
1 src/renderer/src/runtime/hosts/selection/default-creation-host.ts # the sanctioned reader of the default host
|
||||
1 src/renderer/src/lib/launch-ai-vault-session.ts
|
||||
1 src/renderer/src/lib/local-preflight-context.ts
|
||||
1 src/renderer/src/lib/agent-session/resume/history/launch-ai-vault-session.ts
|
||||
1 src/renderer/src/runtime/hosts/preflight/local-preflight-context.ts
|
||||
2 src/renderer/src/runtime/hosts/observations/provider-runtime-context.ts
|
||||
2 src/renderer/src/lib/workspace/ownership/repo-runtime-owner.ts
|
||||
1 src/renderer/src/lib/workspace/ownership/runtime-session-mirror-owners.ts
|
||||
1 src/renderer/src/lib/runtime-session-mirror-targets.ts
|
||||
1 src/renderer/src/runtime/web-session-tabs-sync/subscriptions/runtime-session-mirror-targets.ts
|
||||
1 src/renderer/src/lib/workspace/ownership/single-runtime-legacy-owner.ts
|
||||
1 src/renderer/src/lib/skills/runtime/skill-runtime-command.ts
|
||||
1 src/renderer/src/lib/workspace/ownership/terminal-close-route.ts
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -5099,7 +5099,6 @@
|
||||
"src/renderer/src/components/mobile/WindowsFirewallNotice.test.tsx": 691,
|
||||
"src/renderer/src/components/mobile/paired-mobile-devices.test.ts": 192,
|
||||
"src/renderer/src/components/mobile/use-mobile-page-paired-devices.test.ts": 475,
|
||||
"src/renderer/src/components/native-chat-recovery/integration/native-chat-resume-bulk-progress.test.tsx": 3261,
|
||||
"src/renderer/src/components/native-chat-recovery/offers/native-chat-resume-failed-chat-watch.test.ts": 1954,
|
||||
"src/renderer/src/components/native-chat-recovery/integration/native-chat-resume-finished-run.test.tsx": 4173,
|
||||
"src/renderer/src/components/native-chat/messages/rows/NativeChatAgentMessageCard.test.tsx": 3700,
|
||||
@@ -5121,27 +5120,15 @@
|
||||
"src/renderer/src/components/native-chat/media/visuals/NativeChatMarkdown.visual.test.tsx": 2860,
|
||||
"src/renderer/src/components/native-chat/messages/reasoning/NativeChatMessageList.live-reasoning.test.tsx": 20337,
|
||||
"src/renderer/src/components/native-chat/NativeChatMessageList.new-rows-marker.test.tsx": 4304,
|
||||
"src/renderer/src/components/native-chat/viewport/history/NativeChatMessageList.older-history.test.tsx": 12659,
|
||||
"src/renderer/src/components/native-chat/conversation/slots/NativeChatMessageList.opening-send.test.tsx": 3604,
|
||||
"src/renderer/src/components/native-chat/conversation/slots/NativeChatMessageList.queued-turn-order.test.tsx": 2949,
|
||||
"src/renderer/src/components/native-chat/viewport/navigation/NativeChatMessageList.rail-history-jump.test.tsx": 23851,
|
||||
"src/renderer/src/components/native-chat/viewport/scroll/NativeChatMessageList.scroll-behavior.test.tsx": 14260,
|
||||
"src/renderer/src/components/native-chat/subagents/NativeChatMessageList.subagent-sections.test.tsx": 7517,
|
||||
"src/renderer/src/components/native-chat/surfaces/integration/NativeChatMessageList.test.tsx": 4252,
|
||||
"src/renderer/src/components/native-chat/conversation/turns/NativeChatMessageList.turn-indicator.test.tsx": 4070,
|
||||
"src/renderer/src/components/native-chat/conversation/slots/NativeChatMessageList.turn-membership.test.tsx": 3527,
|
||||
"src/renderer/src/components/native-chat/session/structured/delivery/NativeChatMessageList.unsent-message.test.tsx": 3069,
|
||||
"src/renderer/src/components/native-chat/viewport/scroll/NativeChatMessageList.visual-scroll.test.tsx": 6691,
|
||||
"src/renderer/src/components/native-chat/viewport/virtualization/NativeChatMessageList.windowing.test.tsx": 20958,
|
||||
"src/renderer/src/components/native-chat/viewport/rail/NativeChatMessageRail.test.tsx": 1134,
|
||||
"src/renderer/src/components/native-chat/messages/rows/NativeChatMessageRow.test.tsx": 3533,
|
||||
"src/renderer/src/components/native-chat/NativeChatNewRowsMarker.test.tsx": 3019,
|
||||
"src/renderer/src/components/native-chat/usage/NativeChatNoticeRow.test.tsx": 3399,
|
||||
"src/renderer/src/components/native-chat/pane/actions/NativeChatPaneHeader.test.tsx": 2736,
|
||||
"src/renderer/src/components/native-chat/composer/editor/NativeChatPromptEditor.paragraph-selection.test.tsx": 652,
|
||||
"src/renderer/src/components/native-chat/composer/editor/NativeChatPromptEditor.test.tsx": 1110,
|
||||
"src/renderer/src/components/native-chat/prompts/NativeChatQuestionCard.test.tsx": 762,
|
||||
"src/renderer/src/components/native-chat/queue/NativeChatQueuedMessageList.in-flight.test.tsx": 1865,
|
||||
"src/renderer/src/components/native-chat/queue/NativeChatQueuedMessageRows.test.tsx": 2691,
|
||||
"src/renderer/src/components/native-chat/prompts/NativeChatResolutionReceipt.test.tsx": 912,
|
||||
"src/renderer/src/components/native-chat/media/images/NativeChatResolvedView.context-menu.test.tsx": 4025,
|
||||
@@ -5198,7 +5185,6 @@
|
||||
"src/renderer/src/components/native-chat/drafts/native-chat-draft-retention.test.ts": 1415,
|
||||
"src/renderer/src/components/native-chat/attachments/intake/native-chat-external-attachments-destination.test.tsx": 951,
|
||||
"src/renderer/src/components/native-chat/links/actions/native-chat-file-link-existence.test.ts": 1937,
|
||||
"src/renderer/src/components/native-chat/pane/actions/native-chat-header-ownership.test.tsx": 2796,
|
||||
"src/renderer/src/components/native-chat/links/actions/native-chat-host-file-open.test.ts": 895,
|
||||
"src/renderer/src/components/native-chat/links/previews/native-chat-hover-preview-cache.test.ts": 49,
|
||||
"src/renderer/src/components/native-chat/attachments/chips/native-chat-image-references.test.tsx": 2485,
|
||||
@@ -5242,8 +5228,6 @@
|
||||
"src/renderer/src/components/native-chat/viewport/rail/structured-agent-session-rail-outline.test.ts": 48,
|
||||
"src/renderer/src/components/native-chat/session/structured/read/structured-agent-session-read-transport.test.ts": 243,
|
||||
"src/renderer/src/components/native-chat/session/status/structured-agent-session-status-bridge-clock.test.tsx": 2070,
|
||||
"src/renderer/src/components/native-chat/session/status/structured-agent-session-status-bridge-failed-start.test.tsx": 2398,
|
||||
"src/renderer/src/components/native-chat/session/status/structured-agent-session-status-bridge-unconfirmed-start.test.tsx": 2328,
|
||||
"src/renderer/src/components/native-chat/conversation/projection/structured-agent-session-transcript-order.test.ts": 294,
|
||||
"src/renderer/src/components/native-chat/session/attention/structured-attention-dispatch.test.ts": 1974,
|
||||
"src/renderer/src/components/native-chat/session/status/structured-chat-sleep-startup.test.tsx": 2285,
|
||||
@@ -5465,7 +5449,6 @@
|
||||
"src/renderer/src/components/settings/repository/worktrees/SparsePresetSettingsSection.test.tsx": 744,
|
||||
"src/renderer/src/components/settings/ssh/server-actions/SshHostDeltaMoveDialog.test.tsx": 438,
|
||||
"src/renderer/src/components/settings/ssh/server-actions/SshHostRecoverServerAction.test.tsx": 669,
|
||||
"src/renderer/src/components/settings/ssh/SshPane.test.tsx": 1699,
|
||||
"src/renderer/src/components/settings/ssh/targets/SshTargetForm.test.tsx": 1014,
|
||||
"src/renderer/src/components/settings/ssh/targets/SshTargetList.test.tsx": 2093,
|
||||
"src/renderer/src/components/settings/tasks/TaskSourceSimpleSetup.test.tsx": 527,
|
||||
@@ -5628,7 +5611,6 @@
|
||||
"src/renderer/src/components/stats/usage-overview-model.test.ts": 364,
|
||||
"src/renderer/src/components/status-bar/ClaudeSwitcherMenu.owner-lifetime.test.tsx": 2317,
|
||||
|
||||
"src/renderer/src/components/status-bar/SshStatusSegment.large-host-list.test.tsx": 1838,
|
||||
"src/renderer/src/components/status-bar/StatusBarUsageChangeNotices.test.tsx": 785,
|
||||
"src/renderer/src/components/status-bar/UpdateStatusSegment.test.tsx": 2484,
|
||||
"src/renderer/src/components/status-bar/account-switch-row-keyboard.test.tsx": 2286,
|
||||
@@ -5763,7 +5745,6 @@
|
||||
"src/renderer/src/components/terminal-pane/pty-connection/agent-identity/foreground-process/pane-foreground-inspect-observation-identity.test.ts": 226,
|
||||
"src/renderer/src/components/terminal-pane/pty-connection/agent-identity/foreground-process/pane-foreground-process-exit-retire.test.ts": 329,
|
||||
"src/renderer/src/components/sidebar/workspace-card/activity/structured-chat-activity-status-live.test.tsx": 4146,
|
||||
"src/renderer/src/components/terminal-pane/parking/output-watchers/parked-terminal-byte-watcher.test.ts": 2837,
|
||||
"src/renderer/src/components/terminal-pane/parking/output-watchers/parked-terminal-command-status.test.ts": 352,
|
||||
"src/renderer/src/components/terminal-pane/layout/close/pending-pane-close-confirmation.test.ts": 4695,
|
||||
"src/renderer/src/components/terminal-pane/layout/close/pending-runtime-pane-close.test.ts": 3487,
|
||||
@@ -5853,7 +5834,6 @@
|
||||
"src/renderer/src/components/terminal-pane/pty-transport/remote-runtime/remote-runtime-pty-transport-activation-inventory-fallback.test.ts": 1311,
|
||||
"src/renderer/src/components/terminal-pane/pty-transport/remote-runtime/remote-runtime-pty-transport-create-handoff.test.ts": 14353,
|
||||
"src/renderer/src/components/terminal-pane/pty-transport/remote-runtime/remote-runtime-pty-transport-create-outcome-recovery.test.ts": 2041,
|
||||
"src/renderer/src/components/terminal-pane/pty-transport/remote-runtime/remote-runtime-pty-transport-empty-initial-snapshot.test.ts": 1491,
|
||||
"src/renderer/src/components/terminal-pane/pty-transport/remote-runtime/remote-runtime-pty-transport-end-verdict.test.ts": 942,
|
||||
"src/renderer/src/components/terminal-pane/pty-transport/remote-runtime/remote-runtime-pty-transport-expired-pane-recovery.test.ts": 1763,
|
||||
"src/renderer/src/components/terminal-pane/pty-transport/remote-runtime/remote-runtime-pty-transport-healthy-link-reattach.test.ts": 1595,
|
||||
@@ -5995,7 +5975,6 @@
|
||||
"src/renderer/src/components/terminal/active-terminal-repair-loop.react185.test.tsx": 1998,
|
||||
"src/renderer/src/components/terminal/background-terminal-worktree-mount.test.ts": 1707,
|
||||
"src/renderer/src/components/terminal/background-terminal-worktree-visibility.test.ts": 1790,
|
||||
"src/renderer/src/components/terminal/initial-terminal-admission-wait.test.tsx": 2444,
|
||||
"src/renderer/src/components/terminal/initial-terminal-structured-launch.test.tsx": 786,
|
||||
"src/renderer/src/components/terminal/running-terminal-close-guard.test.ts": 99,
|
||||
"src/renderer/src/components/terminal/startup-terminal-tab-hold.test.ts": 2118,
|
||||
@@ -6173,8 +6152,7 @@
|
||||
"src/renderer/src/i18n/plugin-pack-plurals.test.ts": 191,
|
||||
"src/renderer/src/i18n/relative-time-format.test.ts": 53,
|
||||
"src/renderer/src/i18n/ui-intl-formatters.test.ts": 208,
|
||||
"src/renderer/src/lib/activate-ai-vault-structured-session-host.test.ts": 589,
|
||||
"src/renderer/src/lib/activate-ai-vault-structured-session-reveal.test.ts": 2099,
|
||||
"src/renderer/src/lib/agent-session/open/activate-ai-vault-structured-session-reveal.test.ts": 2099,
|
||||
"src/renderer/src/lib/workspace/tabs/activate-tab-and-focus-pane.test.ts": 54,
|
||||
"src/renderer/src/lib/agent-session/messaging/terminal/active-agent-note-send-explicit-target.test.ts": 980,
|
||||
"src/renderer/src/lib/agent-session/messaging/terminal/active-agent-note-send-focused-session.test.ts": 536,
|
||||
@@ -6188,7 +6166,6 @@
|
||||
"src/renderer/src/lib/agent-session/hibernation/agent-hibernation-runtime-liveness-race.test.ts": 1914,
|
||||
"src/renderer/src/lib/agent-session/launch/pane/agent-launch-pane-verdict-application.test.ts": 1869,
|
||||
"src/renderer/src/lib/agent-session/launch/routing/agent-launch-route-input.test.ts": 1659,
|
||||
"src/renderer/src/lib/agent-session/launch/routing/agent-launch-route-registered-agents.test.ts": 1749,
|
||||
"src/renderer/src/lib/agent-session/launch/pane/agent-launch-tab-main-written.test.ts": 2084,
|
||||
"src/renderer/src/lib/agent-session/launch/pane/agent-launch-tab-publication.test.ts": 1855,
|
||||
"src/renderer/src/lib/agent-session/launch/pane/agent-launch-through-host.test.ts": 1975,
|
||||
@@ -6197,7 +6174,6 @@
|
||||
"src/renderer/src/lib/agent-session/messaging/paste/agent-paste-draft.test.ts": 445,
|
||||
"src/renderer/src/lib/agent-session/resume/agent-resume-launch-target.test.ts": 3911,
|
||||
"src/renderer/src/lib/agent-session/launch/structured-agent-session-launch-after-failure.test.ts": 870,
|
||||
"src/renderer/src/lib/agent-session/launch/structured-agent-session-launch-close-race.test.ts": 983,
|
||||
"src/renderer/src/lib/agent-session/launch/structured-agent-session-launch-create-message.test.ts": 2521,
|
||||
"src/renderer/src/lib/agent-session/launch/structured-agent-session-launch-different-request.test.ts": 885,
|
||||
"src/renderer/src/lib/agent-session/launch/structured-agent-session-launch-exited-owner.test.ts": 1289,
|
||||
@@ -6208,9 +6184,6 @@
|
||||
"src/renderer/src/lib/agent-session/launch/structured-agent-session-launch-prompt.test.ts": 710,
|
||||
"src/renderer/src/lib/agent-session/launch/structured-agent-session-launch-record.test.ts": 151,
|
||||
"src/renderer/src/lib/agent-session/launch/structured-agent-session-launch-resume-identity.test.ts": 828,
|
||||
"src/renderer/src/lib/agent-session/launch/structured-agent-session-launch-unconfirmed-or-retried.test.ts": 1085,
|
||||
"src/renderer/src/lib/agent-session/launch/structured-agent-session-launch.test.ts": 977,
|
||||
"src/renderer/src/lib/agent-session/launch/structured-agent-session-new-chat-own-launch.test.ts": 2177,
|
||||
"src/renderer/src/lib/agent-session/structured-agent-session-draft-position-lifetime.test.tsx": 3166,
|
||||
"src/renderer/src/lib/agent-session/structured-agent-session-ordinary-draft.test.tsx": 9907,
|
||||
"src/renderer/src/lib/agent-session/structured-agent-session-provisional-tab.test.ts": 3672,
|
||||
@@ -6234,7 +6207,6 @@
|
||||
"src/renderer/src/lib/bounded-generation-map.test.ts": 35,
|
||||
"src/renderer/src/lib/browser/history/browser-history-match.test.ts": 328,
|
||||
"src/renderer/src/lib/browser/navigation/browser-link-destination.test.ts": 1839,
|
||||
"src/renderer/src/lib/browser/navigation/browser-link-open-layout-owner.test.ts": 3133,
|
||||
"src/renderer/src/lib/browser/navigation/browser-link-open.test.ts": 2215,
|
||||
"src/renderer/src/lib/browser/navigation/browser-link-profile-isolation.test.ts": 2511,
|
||||
"src/renderer/src/lib/browser/palette/browser-page-palette-activation.test.ts": 1983,
|
||||
@@ -6248,11 +6220,11 @@
|
||||
"src/renderer/src/lib/workspace/search/palette/cmd-j-host-qualified-candidate-ownership.test.ts": 526,
|
||||
"src/renderer/src/lib/workspace/search/palette/cmd-j-linear-issue-intent.test.ts": 42,
|
||||
"src/renderer/src/lib/code-host-error-copy.test.ts": 297,
|
||||
"src/renderer/src/lib/codex-pane-selection-lane.test.ts": 543,
|
||||
"src/renderer/src/lib/agent-session/accounts/codex-pane-selection-lane.test.ts": 543,
|
||||
"src/renderer/src/lib/agent-session/accounts/codex/codex-session-restart-shell-flap.test.ts": 1745,
|
||||
"src/renderer/src/lib/agent-session/accounts/codex/codex-session-restart.test.ts": 2039,
|
||||
"src/renderer/src/lib/codex-stale-pane-account-identity.test.ts": 1823,
|
||||
"src/renderer/src/lib/codex-stale-pane-sweep.test.ts": 1817,
|
||||
"src/renderer/src/lib/agent-session/accounts/codex/codex-stale-pane-account-identity.test.ts": 1823,
|
||||
"src/renderer/src/lib/agent-session/accounts/codex/codex-stale-pane-sweep.test.ts": 1817,
|
||||
"src/renderer/src/lib/source-control/review/comments/comment-body-submit-state.test.ts": 55,
|
||||
"src/renderer/src/lib/composer-submit-cancellation.test.ts": 41,
|
||||
"src/renderer/src/lib/workspace/ownership/connection-context.test.ts": 1817,
|
||||
@@ -6267,13 +6239,9 @@
|
||||
"src/renderer/src/runtime/hosts/platform/execution-host-facts.test.ts": 1796,
|
||||
"src/renderer/src/components/sidebar/sidebar-feedback/feedback-image-attachments.test.ts": 557,
|
||||
"src/renderer/src/lib/files/search/file-search-selection.test.ts": 51,
|
||||
"src/renderer/src/lib/finished-agent-resume-resurrection.test.ts": 1872,
|
||||
"src/renderer/src/lib/agent-session/resume/finished-agent-resume-resurrection.test.ts": 1872,
|
||||
"src/renderer/src/components/terminal-pane/parking/retention/foreground-terminal-tabs.test.ts": 55,
|
||||
"src/renderer/src/lib/work-items/github/github-source-runtime-context.test.ts": 62,
|
||||
"src/renderer/src/lib/host-mirror-handle-gap-drain.test.ts": 1706,
|
||||
"src/renderer/src/lib/host-mirror-handle-gap-resume.test.ts": 1811,
|
||||
"src/renderer/src/lib/host-mirrored-pane-resume-replay.test.ts": 1814,
|
||||
"src/renderer/src/lib/browser/navigation/http-link-completion.test.ts": 1760,
|
||||
"src/renderer/src/lib/browser/navigation/http-link-routing-store.test.ts": 2211,
|
||||
"src/renderer/src/lib/text-input/ime/ime-composition-keyboard-event.test.ts": 274,
|
||||
"src/renderer/src/lib/text-input/ime/ime-text-field.test.tsx": 739,
|
||||
@@ -6294,7 +6262,6 @@
|
||||
"src/renderer/src/app-shell/startup/lazy-with-retry.never-landed-reload.test.ts": 194,
|
||||
"src/renderer/src/lib/work-items/linear/linear-board-drag-payload.test.ts": 58,
|
||||
"src/renderer/src/lib/work-items/linear/linear-issue-workspace-attachment.test.ts": 99,
|
||||
"src/renderer/src/lib/link-source-local-open-owner.test.ts": 433,
|
||||
"src/renderer/src/lib/work-items/linked-work-item-context.test.ts": 64,
|
||||
"src/renderer/src/lib/editor/monaco/monaco-editor-gutter-disposal.test.ts": 295,
|
||||
"src/renderer/src/lib/monaco-languages/markdown-heading-outline.test.ts": 70,
|
||||
@@ -6311,11 +6278,10 @@
|
||||
"src/renderer/src/lib/monaco-languages/textmate-token-provider.test.ts": 245,
|
||||
"src/renderer/src/lib/monaco-languages/zig-highlighting.test.ts": 7984,
|
||||
"src/renderer/src/lib/agent-session/resume/cli-fork/native-chat-cli-fork-preparation.test.ts": 2773,
|
||||
"src/renderer/src/lib/open-agent-message-sender.test.ts": 1497,
|
||||
"src/renderer/src/lib/simulator/launch/open-mobile-emulator-tab.test.ts": 545,
|
||||
"src/renderer/src/lib/workspace/search/palette/order-empty-query-worktrees.test.ts": 62,
|
||||
"src/renderer/src/lib/files/drop/os-file-drop-cancellation-guard.test.ts": 204,
|
||||
"src/renderer/src/lib/paired-runtime-closed-tab-resume.test.ts": 2008,
|
||||
"src/renderer/src/lib/agent-session/resume/paired-runtime-closed-tab-resume.test.ts": 2008,
|
||||
"src/renderer/src/lib/pane-manager/pane-close-focus-successor.test.ts": 1123,
|
||||
"src/renderer/src/lib/pane-manager/pane-container-listener-lifecycle.test.ts": 312,
|
||||
"src/renderer/src/lib/pane-manager/pane-cursor-blink-suspension.test.ts": 429,
|
||||
@@ -6377,7 +6343,6 @@
|
||||
"src/renderer/src/lib/workspace/creation/project-host-workspace-target.jira-mapping.test.ts": 76,
|
||||
"src/renderer/src/lib/workspace/creation/project-host-workspace-target.test.ts": 92,
|
||||
"src/renderer/src/lib/editor/file-operations/remap-open-editor-tabs-for-path-change.test.ts": 2178,
|
||||
"src/renderer/src/lib/rename-user-named-tab-access.test.ts": 2804,
|
||||
"src/renderer/src/lib/renderer-agent-status-observation-ingress.test.ts": 81,
|
||||
"src/renderer/src/diagnostics/memory/renderer-memory-profile.test.ts": 70,
|
||||
"src/renderer/src/lib/agent-session/resume/resume-sleeping-agent-session-deferred-pane.test.ts": 1747,
|
||||
@@ -6391,7 +6356,7 @@
|
||||
"src/renderer/src/lib/agent-session/resume/resume-sleeping-agent-session-suppress-navigation.test.ts": 1919,
|
||||
"src/renderer/src/lib/agent-session/resume/resume-sleeping-agent-session.test.ts": 2140,
|
||||
"src/renderer/src/lib/resume-stale-structured-agent-session.test.ts": 1774,
|
||||
"src/renderer/src/lib/retracted-host-pane-resume.test.ts": 2009,
|
||||
"src/renderer/src/lib/agent-session/resume/retracted-host-pane-resume.test.ts": 2009,
|
||||
"src/renderer/src/lib/review-owner.test.ts": 238,
|
||||
"src/renderer/src/lib/runtime-host-copy.test.ts": 317,
|
||||
"src/renderer/src/components/sidebar/sidebar-feed/sidebar-pending-layer.test.ts": 338,
|
||||
@@ -6402,21 +6367,16 @@
|
||||
"src/renderer/src/lib/simulator/tabs/simulator-tab-layout-owner.test.ts": 2398,
|
||||
"src/renderer/src/lib/simulator/tabs/simulator-tab-palette-activation.test.ts": 1903,
|
||||
"src/renderer/src/lib/source-control/remote/source-control-remote-error.test.ts": 340,
|
||||
"src/renderer/src/lib/ssh-config-passive-sync.test.ts": 1513,
|
||||
"src/renderer/src/runtime/hosts/ssh/ssh-config-passive-sync.test.ts": 1513,
|
||||
"src/renderer/src/diagnostics/memory/state-collection-byte-estimate.test.ts": 86,
|
||||
"src/renderer/src/lib/agent-session/launch/structured-agent-session-launch-draft.test.ts": 1042,
|
||||
"src/renderer/src/lib/agent-session/launch/structured-agent-session-launch-prerequisites.test.ts": 2427,
|
||||
"src/renderer/src/lib/agent-session/options/structured-agent-session-selection-lifetime.test.tsx": 2947,
|
||||
"src/renderer/src/lib/structured-chat-tab-index.test.ts": 45,
|
||||
"src/renderer/src/lib/structured-session-open-consumers.test.tsx": 2643,
|
||||
"src/renderer/src/lib/syntax-highlighting/incremental-syntax-tokenizer.test.ts": 665,
|
||||
"src/renderer/src/lib/syntax-highlighting/syntax-highlight-scheduler.test.ts": 149,
|
||||
"src/renderer/src/lib/syntax-highlighting/syntax-highlighter.test.ts": 539,
|
||||
"src/renderer/src/lib/syntax-highlighting/textmate-core.test.ts": 60,
|
||||
"src/renderer/src/lib/tab-agent-status-index.test.ts": 210,
|
||||
"src/renderer/src/lib/task-provider-error-copy.test.ts": 363,
|
||||
"src/renderer/src/app-shell/appearance/terminal-app-theme.test.ts": 301,
|
||||
"src/renderer/src/lib/terminal-input-activity-coalescing.test.ts": 43,
|
||||
"src/renderer/src/lib/text-input/paste/text-control-paste-ownership.test.ts": 217,
|
||||
"src/renderer/src/lib/text-input/paste/text-control-paste.test.ts": 222,
|
||||
"src/renderer/src/lib/text-generation-error-copy.test.ts": 466,
|
||||
@@ -6424,10 +6384,8 @@
|
||||
"src/renderer/src/lib/typing-latency/renderer-long-tasks.test.ts": 75,
|
||||
"src/renderer/src/lib/typing-latency/sample-window.test.ts": 77,
|
||||
"src/renderer/src/attention/unread/unread-badge-count-selector.test.ts": 1930,
|
||||
"src/renderer/src/lib/use-tab-agent-observed-signal-dispatch.test.tsx": 1971,
|
||||
"src/renderer/src/lib/use-tab-agent-opencode-native-title.test.ts": 2093,
|
||||
"src/renderer/src/lib/use-tab-agent.test.ts": 1961,
|
||||
"src/renderer/src/lib/wake-sleeping-agents-live-unmounted-pane.test.ts": 2432,
|
||||
"src/renderer/src/lib/agent-session/tab-identity/use-tab-agent-observed-signal-dispatch.test.tsx": 1971,
|
||||
"src/renderer/src/lib/agent-session/tab-identity/use-tab-agent.test.ts": 1961,
|
||||
"src/renderer/src/runtime/hosts/capabilities/windows-terminal-capabilities-race.test.ts": 450,
|
||||
"src/renderer/src/lib/workspace/activation/workspace-activation-path-gate.test.ts": 2107,
|
||||
"src/renderer/src/lib/browser/workspace/workspace-browser-tab-open-placement.test.ts": 1996,
|
||||
@@ -6483,7 +6441,6 @@
|
||||
"src/renderer/src/runtime/web-session-tabs-sync/closing/paired-terminal-tab-close-reload.test.ts": 1943,
|
||||
"src/renderer/src/runtime/workspace-layout/frames/pane-titles-drawn-from-frames.test.ts": 1988,
|
||||
"src/renderer/src/runtime/web-session-tabs-sync/agent-status/remote-agent-row-last-assistant-message.test.ts": 1776,
|
||||
"src/renderer/src/runtime/files/mutations/remote-host-file-delete-repro.test.ts": 1890,
|
||||
"src/renderer/src/runtime/web-session-tabs-sync/inventory/remote-runtime-session-tabs-inflight.test.ts": 55,
|
||||
"src/renderer/src/runtime/hosted-terminals/snapshots/remote-runtime-snapshot-outcome.test.ts": 233,
|
||||
"src/renderer/src/runtime/hosted-terminals/streams/remote-runtime-terminal-frame-drop-resync.test.ts": 266,
|
||||
@@ -6532,7 +6489,6 @@
|
||||
"src/renderer/src/runtime/sync-runtime-graph/terminal-group-grid-sizes.test.ts": 194,
|
||||
"src/renderer/src/runtime/browser/creation/web-runtime-browser-creation-placement.test.ts": 1927,
|
||||
"src/renderer/src/runtime/browser/creation/web-runtime-browser-link-open.test.ts": 2217,
|
||||
"src/renderer/src/runtime/browser/creation/web-runtime-browser-link-session.test.ts": 1964,
|
||||
"src/renderer/src/runtime/web-session-tabs-sync/closing/web-session-close-replay.test.ts": 1119,
|
||||
"src/renderer/src/runtime/web-session-tabs-sync/placement/web-session-open-files-batch-equivalence.test.ts": 1478,
|
||||
"src/renderer/src/runtime/web-session-tabs-sync/identity/web-session-restored-placeholder-identity.test.ts": 985,
|
||||
@@ -6552,7 +6508,6 @@
|
||||
"src/renderer/src/runtime/web-session-tabs-sync/agent-status/web-session-tabs-sync-remote-status-title-flap.test.ts": 1715,
|
||||
"src/renderer/src/runtime/web-session-tabs-sync/agent-status/web-session-tabs-sync-stale-spinner.test.ts": 921,
|
||||
"src/renderer/src/runtime/web-session-tabs-sync/tracking/web-session-tabs-sync-tracking-teardown.test.ts": 940,
|
||||
"src/renderer/src/runtime/web-session-tabs-sync/subscriptions/web-session-tabs-sync-unverifiable-host.test.tsx": 2424,
|
||||
"src/renderer/src/runtime/web-session-tabs-sync/subscriptions/web-session-tabs-sync-visibility-collision.test.tsx": 2699,
|
||||
"src/renderer/src/runtime/web-session-tabs-sync/subscriptions/web-session-tabs-sync-window-visibility.test.tsx": 2589,
|
||||
"src/renderer/src/runtime/web-session-tabs-sync/subscriptions/web-session-tabs-sync-worktree-switch.test.tsx": 2625,
|
||||
@@ -6569,7 +6524,6 @@
|
||||
"src/renderer/src/runtime/hosted-terminals/recovery/evidence/web-session-terminal-retirement-proof-ledger.test.ts": 685,
|
||||
"src/renderer/src/runtime/rpc/subscriptions/window-visibility-subscription-parking-stream-end.test.ts": 225,
|
||||
"src/renderer/src/runtime/workspace-layout/frames/workspace-layout-frame-binding.test.ts": 2155,
|
||||
"src/renderer/src/runtime/workspace-layout/frames/workspace-layout-frame-editor-views.test.ts": 2098,
|
||||
"src/renderer/src/runtime/workspace-layout/frames/workspace-layout-frame-held-tabs.test.ts": 2519,
|
||||
"src/renderer/src/runtime/workspace-layout/frames/workspace-layout-frame-sync.test.ts": 2282,
|
||||
"src/renderer/src/runtime/workspace-layout/frames/workspace-layout-frame-tab-props.test.ts": 2852,
|
||||
@@ -6584,7 +6538,6 @@
|
||||
"src/renderer/src/store/github/requests/provider-request-coalescing.test.ts": 969,
|
||||
"src/renderer/src/store/slices/hosted-review/refresh/visible-hosted-review-refresh-scheduler.test.ts": 97,
|
||||
"src/renderer/src/store/github/repositories/wsl-stopped-distro-poll-refusal.test.ts": 696,
|
||||
"src/renderer/src/store/workspaces/host-isolation/host-twin-isolation.test.ts": 1889,
|
||||
"src/renderer/src/store/workspaces/host-isolation/host-twin-worktree-purge.test.ts": 1945,
|
||||
"src/renderer/src/store/plugins/localization/plugin-language-packs-startup.test.ts": 435,
|
||||
"src/renderer/src/store/plugins/localization/plugin-language-packs.test.ts": 377,
|
||||
@@ -6631,7 +6584,6 @@
|
||||
"src/renderer/src/store/slices/browser/tabs/browser-tab-creation-placement.test.ts": 1886,
|
||||
"src/renderer/src/store/slices/browser/pages/browser-workspace-doc-location.test.ts": 2007,
|
||||
"src/renderer/src/store/slices/browser/browser.test.ts": 2001,
|
||||
"src/renderer/src/store/slices/worktrees/teardown/bulk-worktree-purge-terminal-maps-leak.test.ts": 1727,
|
||||
"src/renderer/src/store/terminals/codex-restart-notice-lifecycle.test.ts": 1685,
|
||||
"src/renderer/src/store/slices/tabs/content-tabs-from-main-frames.test.ts": 2025,
|
||||
"src/renderer/src/store/slices/tabs/content-tabs-paired-server-workspace.test.ts": 1923,
|
||||
@@ -6646,7 +6598,6 @@
|
||||
"src/renderer/src/store/slices/editor/checks/editor-check-details-tabs.test.ts": 1814,
|
||||
"src/renderer/src/store/slices/editor/closing/editor-close-background-file.test.ts": 893,
|
||||
"src/renderer/src/store/slices/editor/closing/editor-close-document-siblings.test.ts": 1317,
|
||||
"src/renderer/src/store/slices/editor/closing/editor-close-file-cleanup.test.ts": 2000,
|
||||
"src/renderer/src/store/slices/editor/closing/editor-close-file-stale-active.test.ts": 1806,
|
||||
"src/renderer/src/store/slices/editor/closing/editor-close-pinned-sibling.test.ts": 924,
|
||||
"src/renderer/src/store/slices/editor/closing/editor-close-workspace-selection.test.ts": 1850,
|
||||
@@ -6678,7 +6629,6 @@
|
||||
"src/renderer/src/store/github/pull-requests/github-linked-review-clear-ownership.test.ts": 891,
|
||||
"src/renderer/src/store/slices/editor/git/github-post-operation-owner.test.ts": 2062,
|
||||
"src/renderer/src/store/github/pull-requests/github-pr-branch-direct-refresh-scope.test.ts": 667,
|
||||
"src/renderer/src/store/github/pull-requests/github-pr-branch-fallback-results.test.ts": 658,
|
||||
"src/renderer/src/store/github/pull-requests/github-pr-branch-linked-pr-divergence.test.ts": 662,
|
||||
"src/renderer/src/store/github/comments/github-pr-comment-read-order.test.ts": 570,
|
||||
"src/renderer/src/store/github/comments/github-pr-comments.test.ts": 746,
|
||||
@@ -6747,10 +6697,8 @@
|
||||
"src/renderer/src/store/slices/worktrees/create/sparse-presets.test.ts": 217,
|
||||
"src/renderer/src/store/slices/ssh/ssh.test.ts": 1843,
|
||||
"src/renderer/src/lib/workspace/activation/active-worktree-removal-successor.test.ts": 1867,
|
||||
"src/renderer/src/store/slices/worktrees/session/store-active-worktree-selection.test.ts": 2039,
|
||||
"src/renderer/src/store/terminals/store-create-tab-start-in-main.test.ts": 1801,
|
||||
"src/renderer/src/store/slices/tabs/store-open-to-side-layout-owner.test.ts": 1919,
|
||||
"src/renderer/src/store/slices/browser/hydration/store-session-browser-hydration.test.ts": 1906,
|
||||
"src/renderer/src/store/repos/store-session-cascades.test.ts": 1775,
|
||||
"src/renderer/src/store/slices/editor/hydration/store-session-editor-hydration.test.ts": 1719,
|
||||
"src/renderer/src/store/terminals/store-session-terminal-reconnect.test.ts": 2279,
|
||||
@@ -6759,7 +6707,6 @@
|
||||
"src/renderer/src/store/terminals/store-sleep-exact-runtime-stop.test.ts": 1842,
|
||||
"src/renderer/src/store/terminals/store-sleep-pane-hibernation.test.ts": 1932,
|
||||
"src/renderer/src/store/terminals/store-sleep-runtime-convergence.test.ts": 1767,
|
||||
"src/renderer/src/store/terminals/store-sleep-twin-host-owner.test.ts": 1706,
|
||||
"src/renderer/src/store/slices/worktrees/teardown/store-worktree-removal-cascade.test.ts": 1786,
|
||||
"src/renderer/src/store/slices/worktrees/teardown/tab-worktree-orphan-map-purge-leak.test.ts": 1936,
|
||||
"src/renderer/src/store/slices/tabs/tabs-close-dangling-group.test.ts": 1849,
|
||||
@@ -7861,13 +7808,11 @@
|
||||
"tests/e2e/linear-store.unit.test.ts": 519,
|
||||
"tests/e2e/linear-write-lifetime.unit.test.ts": 5214,
|
||||
"tests/e2e/multi-workspace-typing-bench.unit.test.ts": 550,
|
||||
"tests/e2e/native-chat-image-runtime-context.unit.test.ts": 2124,
|
||||
"tests/e2e/native-chat-live-history.unit.test.ts": 3258,
|
||||
"tests/e2e/native-chat-rewind-boundary.unit.test.ts": 2977,
|
||||
"tests/e2e/native-chat-ssh-transcript.unit.test.ts": 1166,
|
||||
"tests/e2e/native-chat-startup-option-pickers.unit.test.ts": 9377,
|
||||
|
||||
"tests/e2e/native-chat-transcript-reasoning.unit.test.ts": 3341,
|
||||
"tests/e2e/nested-agent-idle-owner.unit.test.ts": 2469,
|
||||
"tests/e2e/omp-child-session-recovery.unit.test.ts": 2205,
|
||||
"tests/e2e/omp-retired-host-renderer.unit.test.ts": 2546,
|
||||
@@ -7891,7 +7836,6 @@
|
||||
"tests/e2e/source-control-action-phone-launch.unit.test.ts": 746,
|
||||
"tests/e2e/ssh-browser-network-execution-route.docker.unit.test.ts": 413,
|
||||
"tests/e2e/structured-agent-session-launch-admission.unit.test.ts": 4762,
|
||||
"tests/e2e/structured-agent-session-launch-continuation.unit.test.ts": 23572,
|
||||
"tests/e2e/structured-agent-session-read-owner.unit.test.ts": 6912,
|
||||
"tests/e2e/structured-attention-headless-delivery.unit.test.ts": 328,
|
||||
"tests/e2e/structured-attention-prompt-relay.unit.test.ts": 14045,
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ const EFFECT_BOUNDARIES = new Set([
|
||||
`${WATCHERS}terminal-parked-pty-watcher.ts#startParkedPtyWatcher`,
|
||||
`${RENDERER}components/terminal-pane/parking/capture/parked-terminal-buffer-capture.ts#captureParkedTerminalBuffers`,
|
||||
`${RENDERER}lib/agent-session/resume/sleeping-agent-session-launch.ts#launchSleepingAgentSession`,
|
||||
`${RENDERER}lib/host-mirror-handle-gap-wait.ts#parkUntilHostMirrorHandleLands`,
|
||||
`${RENDERER}lib/agent-session/resume/host-mirror-handle-gap-wait.ts#parkUntilHostMirrorHandleLands`,
|
||||
`${RENDERER}runtime/web-session-tabs-sync/hydration/host-session-mirror-hydration.ts#parkUntilHostSessionMirrorHydrates`
|
||||
])
|
||||
const ENUMERATORS = new Set(['entries', 'values', 'keys', 'assign'])
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ internal enum class MobileWebShellBridgeInstall {
|
||||
/** The prop is false, so nothing is registered and Phase B behaviour is byte-identical. */
|
||||
SKIP,
|
||||
INSTALL,
|
||||
/** The WebView provider is older than `WEB_MESSAGE_LISTENER` (Chromium 88). Terminal. */
|
||||
/** The WebView provider is older than `WEB_MESSAGE_LISTENER` (Chromium 83). Terminal. */
|
||||
UNAVAILABLE
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -201,7 +201,7 @@ internal class MobileWebShellDocument(private val context: Context) {
|
||||
view.destroy()
|
||||
}
|
||||
|
||||
// Keep explicit settings for the Chromium 83 floor, even where newer WebViews ignore deprecated options.
|
||||
// Keep explicit settings even where newer WebViews ignore deprecated options; the floor is Chromium 101.
|
||||
// B4 requires device proofs: no network, persistent state, file/content access, cleartext or navigation escape.
|
||||
@Suppress("DEPRECATION")
|
||||
private fun createWebView(): WebView {
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ internal val MOBILE_WEB_SHELL_NETWORK_API_BLOCKER = """
|
||||
})();
|
||||
""".trimIndent()
|
||||
|
||||
/** Query document-start-script capability (Chromium 83 floor), not version strings. */
|
||||
/** Query capability, not version strings; stable WebView has it from Chromium 101. */
|
||||
internal fun installMobileWebShellNetworkApiBlocker(
|
||||
webView: WebView,
|
||||
allowedOrigin: String
|
||||
|
||||
+13
@@ -8,6 +8,8 @@ import android.content.res.Configuration
|
||||
import android.net.Uri
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import androidx.webkit.WebViewCompat
|
||||
import androidx.webkit.WebViewFeature
|
||||
import expo.modules.kotlin.exception.CodedException
|
||||
import expo.modules.kotlin.exception.Exceptions
|
||||
import expo.modules.kotlin.functions.Queues
|
||||
@@ -68,6 +70,17 @@ class OrcaMobileWebShellModule : Module() {
|
||||
Uri.fromFile(directory).toString()
|
||||
}
|
||||
|
||||
// Lets isolation-unavailable name the WebView to update.
|
||||
Function("currentWebViewProvider") {
|
||||
val context = appContext.reactContext ?: return@Function null
|
||||
val info = WebViewCompat.getCurrentWebViewPackage(context) ?: return@Function null
|
||||
val version = info.versionName ?: return@Function null
|
||||
val name = info.applicationInfo?.loadLabel(context.packageManager)?.toString() ?: info.packageName
|
||||
val hasShellFeatures = WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT) &&
|
||||
WebViewFeature.isFeatureSupported(WebViewFeature.WEB_MESSAGE_LISTENER)
|
||||
mapOf("name" to name, "version" to version, "hasShellFeatures" to hasShellFeatures)
|
||||
}
|
||||
|
||||
AsyncFunction("prepareSpareDocument") { directory: String, sessionId: String ->
|
||||
val activity = appContext.currentActivity ?: return@AsyncFunction false
|
||||
MobileWebShellSparePool.prepare(activity, directory, sessionId)
|
||||
|
||||
@@ -18,7 +18,7 @@ export type OrcaMobileWebShellViewProps = ViewProps & {
|
||||
generationDirectory: string
|
||||
/** `[A-Za-z0-9_-]{1,128}`. Scopes the private origin, so every mount must mint a fresh one. */
|
||||
sessionId: string
|
||||
// Bridge is off by default with nothing registered. Opt-in on Android below WEB_MESSAGE_LISTENER/Chromium 88 fails isolation-unavailable instead of loading unfenced.
|
||||
// Bridge is off by default with nothing registered. Opt-in on Android below WEB_MESSAGE_LISTENER/Chromium 83 fails isolation-unavailable instead of loading unfenced.
|
||||
bridgeEnabled?: boolean
|
||||
onLoadState?: (event: NativeSyntheticEvent<MobileWebShellLoadStatePayload>) => void
|
||||
// Raw JSON from window.orcaBridge; native silently rejects other origins/frames/WebViews and envelopes above 640 KiB (MobileWebShellBridge.maxMessageByteCount).
|
||||
@@ -82,6 +82,23 @@ export function warmUpWebShell(): void {
|
||||
}
|
||||
}
|
||||
|
||||
export type WebViewProvider = { name: string; version: string; hasShellFeatures: boolean }
|
||||
|
||||
// Android only: the WebView provider and whether it has the shell's fences. Null when unknown.
|
||||
export function currentWebViewProvider(): WebViewProvider | null {
|
||||
if (Platform.OS !== 'android') {
|
||||
return null
|
||||
}
|
||||
const shell = requireOptionalNativeModule<{
|
||||
currentWebViewProvider?: () => WebViewProvider | null
|
||||
}>('OrcaMobileWebShell')
|
||||
try {
|
||||
return shell?.currentWebViewProvider?.() ?? null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
MOBILE_WEB_SHELL_FAILURE_REASONS,
|
||||
parseMobileWebShellLoadState,
|
||||
|
||||
@@ -820,6 +820,8 @@
|
||||
"webShell": {
|
||||
"shellStateScreen": {
|
||||
"isolationUnavailable": "This device's WebView is too old to open the workspace safely.",
|
||||
"isolationUnavailableAndroid": "Orca needs Android System WebView or Chrome 101 or newer. Update it from the Play Store, or pick a newer one in Developer options > WebView implementation.",
|
||||
"webViewInUse": "This device has {{name}} {{version}}.",
|
||||
"downloadFailed": "The latest app could not be downloaded from this host.",
|
||||
"hostProfileUnreadable": "Could not read this host on your device. Try again.",
|
||||
"statusUnreadable": "Could not read this host's status. Go back and reopen it.",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { Pressable, Text, View } from 'react-native'
|
||||
import { Platform, Pressable, Text, View } from 'react-native'
|
||||
import { currentWebViewProvider } from '../../modules/orca-mobile-web-shell/src'
|
||||
import { ProtocolBlockScreen } from '../components/ProtocolBlockScreen'
|
||||
import { colors, radii, spacing, typography } from '../theme/mobile-theme'
|
||||
import { themedStyleSheet } from '../theme/themed-styles'
|
||||
@@ -65,11 +66,30 @@ function Failed({
|
||||
useMobileColorScheme()
|
||||
// Retry cannot change a settled isolation gate or give an unsupported WebView the missing fence.
|
||||
const retryable = state.reason !== 'isolation-unavailable' && state.reason !== 'status-unreadable'
|
||||
const provider = state.reason === 'isolation-unavailable' ? currentWebViewProvider() : null
|
||||
// Unknown provider (older binary): a missing feature is still the likely cause.
|
||||
const webViewTooOld =
|
||||
Platform.OS === 'android' &&
|
||||
state.reason === 'isolation-unavailable' &&
|
||||
provider?.hasShellFeatures !== true
|
||||
return (
|
||||
<Centered>
|
||||
<Text style={styles.failedMessage} testID="mobile-web-shell-failed">
|
||||
{failureMessage(state.reason, t)}
|
||||
{webViewTooOld
|
||||
? t(
|
||||
'webShell.shellStateScreen.isolationUnavailableAndroid',
|
||||
'Orca needs Android System WebView or Chrome 101 or newer. Update it from the Play Store, or pick a newer one in Developer options > WebView implementation.'
|
||||
)
|
||||
: failureMessage(state.reason, t)}
|
||||
</Text>
|
||||
{webViewTooOld && provider ? (
|
||||
<Text style={styles.failedDetail}>
|
||||
{t('webShell.shellStateScreen.webViewInUse', 'This device has {{name}} {{version}}.', {
|
||||
name: provider.name,
|
||||
version: provider.version
|
||||
})}
|
||||
</Text>
|
||||
) : null}
|
||||
{retryable ? (
|
||||
<Pressable
|
||||
style={({ pressed }) => [styles.retryButton, pressed && styles.pressed]}
|
||||
@@ -160,6 +180,12 @@ const styles = themedStyleSheet(() => ({
|
||||
textAlign: 'center',
|
||||
marginBottom: spacing.lg
|
||||
},
|
||||
failedDetail: {
|
||||
fontSize: typography.metaSize,
|
||||
color: colors.textSecondary,
|
||||
textAlign: 'center',
|
||||
marginBottom: spacing.lg
|
||||
},
|
||||
retryButton: {
|
||||
backgroundColor: colors.bgRaised,
|
||||
paddingVertical: spacing.sm + 2,
|
||||
|
||||
@@ -15,9 +15,9 @@ export function createOrchestrationCompatibilityEnvelope(
|
||||
}
|
||||
}
|
||||
|
||||
/** The chat an agent launch came from, so the host can show the launched agent there.
|
||||
/** The chat a launch or browser command came from, so the host can show its agent or page there.
|
||||
* Only a same-host session can be named: host-stamped (WSL) environments send nothing. */
|
||||
export function createAgentLaunchCallerEvidence(
|
||||
export function createChatCallerEvidence(
|
||||
env: NodeJS.ProcessEnv
|
||||
): RuntimeOrchestrationEnvelope['orchestrationCompatibilityEvidence'] {
|
||||
const agentSessionId = readInjectedAgentSessionId(env)
|
||||
@@ -29,12 +29,16 @@ export function createAgentLaunchCallerEvidence(
|
||||
|
||||
const AGENT_LAUNCH_METHODS: ReadonlySet<string> = new Set(['agent.launch', 'agent.launchReplay'])
|
||||
|
||||
function namesChatCaller(method: string): boolean {
|
||||
return AGENT_LAUNCH_METHODS.has(method) || method.startsWith('browser.')
|
||||
}
|
||||
|
||||
/** The caller evidence one request carries, read from this process's environment once. */
|
||||
export class OrchestrationRequestEvidence {
|
||||
private readonly orchestration: RuntimeOrchestrationEnvelope
|
||||
// A chat's session id means nothing on another server, so reads there go like a shell's.
|
||||
private readonly remoteRead: RuntimeOrchestrationEnvelope
|
||||
private readonly agentLaunchCaller: RuntimeOrchestrationEnvelope['orchestrationCompatibilityEvidence']
|
||||
private readonly chatCaller: RuntimeOrchestrationEnvelope['orchestrationCompatibilityEvidence']
|
||||
|
||||
constructor(env: NodeJS.ProcessEnv) {
|
||||
this.orchestration = createOrchestrationCompatibilityEnvelope(env)
|
||||
@@ -44,7 +48,7 @@ export class OrchestrationRequestEvidence {
|
||||
...this.orchestration,
|
||||
orchestrationCompatibilityEvidence: Object.keys(shell).length > 0 ? shell : undefined
|
||||
}
|
||||
this.agentLaunchCaller = createAgentLaunchCallerEvidence(env)
|
||||
this.chatCaller = createChatCallerEvidence(env)
|
||||
}
|
||||
|
||||
envelopeFor(
|
||||
@@ -58,8 +62,8 @@ export class OrchestrationRequestEvidence {
|
||||
compatibilityInvocationId: request.requestId ?? base.compatibilityInvocationId
|
||||
}
|
||||
}
|
||||
return AGENT_LAUNCH_METHODS.has(method) && !request.remote && this.agentLaunchCaller
|
||||
? { orchestrationCompatibilityEvidence: this.agentLaunchCaller }
|
||||
return namesChatCaller(method) && !request.remote && this.chatCaller
|
||||
? { orchestrationCompatibilityEvidence: this.chatCaller }
|
||||
: {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,3 +26,18 @@ describe('caller evidence on requests to another server', () => {
|
||||
).toEqual({ agentSessionId: '11111111-1111-4111-8111-111111111111' })
|
||||
})
|
||||
})
|
||||
|
||||
describe('caller evidence on browser commands', () => {
|
||||
it('names the chat on this host, so its run can show the page it drove', () => {
|
||||
const evidence = new OrchestrationRequestEvidence(CHAT)
|
||||
const request = { mutation: false, requestId: undefined }
|
||||
expect(
|
||||
evidence.envelopeFor('browser.click', { ...request, remote: false })
|
||||
.orchestrationCompatibilityEvidence
|
||||
).toEqual({ agentSessionId: '11111111-1111-4111-8111-111111111111' })
|
||||
expect(
|
||||
evidence.envelopeFor('browser.click', { ...request, remote: true })
|
||||
.orchestrationCompatibilityEvidence
|
||||
).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
captureRemoteCliBrowserScope,
|
||||
runOutsideRemoteCliBrowserScope
|
||||
} from '../../../runtime/desktop-browser-bridge/remote-cli-browser-scope'
|
||||
import { getActiveRpcCaller } from '../../../runtime/rpc/rpc-active-caller'
|
||||
import { captureActiveRpcCall, getActiveRpcCaller } from '../../../runtime/rpc/rpc-active-caller'
|
||||
|
||||
export abstract class AgentBrowserBridgeQueue extends AgentBrowserBridgeActionEffects {
|
||||
// Serialize tab switches behind commands targeting the current tab.
|
||||
@@ -97,8 +97,10 @@ export abstract class AgentBrowserBridgeQueue extends AgentBrowserBridgeActionEf
|
||||
assertNoJavaScriptDialog(webContentsId, pageId, assertNotRevoked)
|
||||
const sessionName = `${ORCA_TAB_SESSION_PREFIX}${pageId}`
|
||||
const agentCommand = this.browserManager.beginAgentCommand(pageId)
|
||||
// Queued commands run under the caller ahead of them, so read this one's caller now.
|
||||
// Queued commands run under the caller ahead of them, so read this one's caller now
|
||||
// and re-enter its call, or what it marks would count as that other chat's.
|
||||
const caller = getActiveRpcCaller()
|
||||
const inThisCall = captureActiveRpcCall()
|
||||
// Decided at enqueue: a queued command runs under the caller of the command ahead of it.
|
||||
const reportEffects = options.reportEffects === true && agentCommand.agent
|
||||
const expectedUrl = getRequestedPageUrl()
|
||||
@@ -167,10 +169,12 @@ export abstract class AgentBrowserBridgeQueue extends AgentBrowserBridgeActionEf
|
||||
},
|
||||
options
|
||||
)
|
||||
return origin.run(() => {
|
||||
started = true
|
||||
return this.browserManager.runPageCommand(pageId, caller, () => agentCommand.run(run))
|
||||
})
|
||||
return inThisCall(() =>
|
||||
origin.run(() => {
|
||||
started = true
|
||||
return this.browserManager.runPageCommand(pageId, caller, () => agentCommand.run(run))
|
||||
})
|
||||
)
|
||||
},
|
||||
resolve: resolve as (value: unknown) => void,
|
||||
reject
|
||||
|
||||
+51
@@ -59,6 +59,10 @@ vi.mock('../../cdp/commands/cdp-bridge', async () => {
|
||||
})
|
||||
|
||||
import { AgentBrowserBridge } from '../agent-browser-bridge'
|
||||
import {
|
||||
getActiveRpcAgentSessionId,
|
||||
runWithActiveRpcCaller
|
||||
} from '../../../runtime/rpc/rpc-active-caller'
|
||||
import {
|
||||
answerAgentBrowserCommands,
|
||||
mockBrowserManager,
|
||||
@@ -125,4 +129,51 @@ describe('AgentBrowserBridge', () => {
|
||||
await b.click('@e2', 'wt-1')
|
||||
expect(clickSessions).toEqual(['orca-tab-tab-a', 'orca-tab-tab-b'])
|
||||
})
|
||||
|
||||
it("marks a tab switch queued behind another chat's command as the switching chat's", async () => {
|
||||
const chatA = '11111111-1111-4111-8111-111111111111'
|
||||
const chatB = '22222222-2222-4222-8222-222222222222'
|
||||
const tabs = new Map([
|
||||
['tab-a', 1],
|
||||
['tab-b', 2]
|
||||
])
|
||||
const worktrees = new Map([
|
||||
['tab-a', 'wt-1'],
|
||||
['tab-b', 'wt-1']
|
||||
])
|
||||
const wc1 = mockWebContents(1)
|
||||
const wc2 = mockWebContents(2)
|
||||
webContentsFromIdMock.mockImplementation((id: number) => (id === 1 ? wc1 : wc2))
|
||||
const marks: [string, string | undefined][] = []
|
||||
const b = new AgentBrowserBridge(
|
||||
mockBrowserManager(tabs, worktrees, {
|
||||
beginAgentCommand: (pageId: string) => {
|
||||
marks.push([pageId, getActiveRpcAgentSessionId()])
|
||||
return { agent: true, run: (execute) => execute(), end: () => {} }
|
||||
}
|
||||
})
|
||||
)
|
||||
b.setActiveTab(1, 'wt-1')
|
||||
const held: { releaseA?: () => void } = {}
|
||||
answerAgentBrowserCommands(execFileMock, stdinWrites, (_command, cb) => {
|
||||
const answer = (): void =>
|
||||
cb(null, JSON.stringify({ success: true, data: { snapshot: '' } }), '')
|
||||
if (held.releaseA) {
|
||||
answer()
|
||||
} else {
|
||||
held.releaseA = answer
|
||||
}
|
||||
})
|
||||
const inChat = <T>(chat: string, run: () => T): T =>
|
||||
runWithActiveRpcCaller({ kind: 'local-cli' }, run, chat)
|
||||
|
||||
const snapshot = inChat(chatA, () => b.snapshot('wt-1'))
|
||||
await vi.waitFor(() => expect(execFileMock).toHaveBeenCalled())
|
||||
const tabSwitch = inChat(chatB, () => b.tabSwitch(undefined, 'wt-1', 'tab-b'))
|
||||
held.releaseA?.()
|
||||
await Promise.all([snapshot, tabSwitch])
|
||||
|
||||
expect(marks).toContainEqual(['tab-b', chatB])
|
||||
expect(marks).not.toContainEqual(['tab-b', chatA])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -90,6 +90,18 @@ describe('BrowserAgentActivity', () => {
|
||||
expect(sent).toEqual([])
|
||||
})
|
||||
|
||||
it("names the chat whose agent's CLI sent the command", () => {
|
||||
const { activity, sent } = setup()
|
||||
const chat = '11111111-1111-4111-8111-111111111111'
|
||||
runWithActiveRpcCaller({ kind: 'local-cli' }, () => activity.beginCommand(PAGE), chat).end()
|
||||
expect(sent.at(-1)?.data).toEqual({
|
||||
browserPageId: PAGE,
|
||||
worktreeId: 'wt-1',
|
||||
active: true,
|
||||
agentSessionId: chat
|
||||
})
|
||||
})
|
||||
|
||||
it('clears the mark once the agent stays idle, and at once when the page closes', () => {
|
||||
const { activity, sent, agentCommand } = setup()
|
||||
agentCommand().end()
|
||||
|
||||
@@ -9,7 +9,10 @@ import {
|
||||
type BrowserAgentActivityEvent,
|
||||
type BrowserAgentCursorEvent
|
||||
} from '../../../../shared/browser-agent-activity-contract'
|
||||
import { getActiveRpcCaller } from '../../../runtime/rpc/rpc-active-caller'
|
||||
import {
|
||||
getActiveRpcAgentSessionId,
|
||||
getActiveRpcCaller
|
||||
} from '../../../runtime/rpc/rpc-active-caller'
|
||||
import {
|
||||
remoteCliBrowserScopeController,
|
||||
type RemoteCliBrowserController
|
||||
@@ -35,6 +38,8 @@ type PageActivity = {
|
||||
idleTimer: ReturnType<typeof setTimeout> | null
|
||||
/** The SSH host whose command marked the page last, if it came through the desktop bridge. */
|
||||
controller: RemoteCliBrowserController | null
|
||||
/** The chat whose agent marked the page last, when its CLI named one. */
|
||||
agentSessionId: string | undefined
|
||||
}
|
||||
|
||||
/** One page-targeted command, held from when it is queued until it settles. */
|
||||
@@ -80,12 +85,19 @@ export class BrowserAgentActivity {
|
||||
}
|
||||
let page = this.pages.get(browserPageId)
|
||||
if (!page) {
|
||||
page = { commands: 0, executing: false, idleTimer: null, controller: null }
|
||||
page = {
|
||||
commands: 0,
|
||||
executing: false,
|
||||
idleTimer: null,
|
||||
controller: null,
|
||||
agentSessionId: undefined
|
||||
}
|
||||
this.pages.set(browserPageId, page)
|
||||
}
|
||||
page.controller = remoteCliBrowserScopeController() ?? null
|
||||
page.agentSessionId = getActiveRpcAgentSessionId()
|
||||
// Every command republishes, so a reloaded or newly attached window catches up.
|
||||
this.publish(browserPageId, true, page.controller)
|
||||
this.publish(browserPageId, true, page)
|
||||
if (page.idleTimer) {
|
||||
clearTimeout(page.idleTimer)
|
||||
page.idleTimer = null
|
||||
@@ -122,20 +134,22 @@ export class BrowserAgentActivity {
|
||||
/** The agent continues on another page (a closed popup's opener), so its claim moves there. */
|
||||
handOver(fromPageId: string, toPageId: string): void {
|
||||
const existing = this.pages.get(toPageId)
|
||||
const from = this.pages.get(fromPageId)
|
||||
// A running command restarts the idle window itself when it settles.
|
||||
if (!this.pages.has(fromPageId) || (existing && existing.commands > 0)) {
|
||||
if (!from || (existing && existing.commands > 0)) {
|
||||
return
|
||||
}
|
||||
const page = existing ?? {
|
||||
commands: 0,
|
||||
executing: false,
|
||||
idleTimer: null,
|
||||
controller: this.pages.get(fromPageId)?.controller ?? null
|
||||
controller: from.controller,
|
||||
agentSessionId: from.agentSessionId
|
||||
}
|
||||
this.restartIdleWindow(toPageId, page)
|
||||
if (!existing) {
|
||||
this.pages.set(toPageId, page)
|
||||
this.publish(toPageId, true, page.controller)
|
||||
this.publish(toPageId, true, page)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +265,7 @@ export class BrowserAgentActivity {
|
||||
private publish(
|
||||
browserPageId: string,
|
||||
active: boolean,
|
||||
controller: RemoteCliBrowserController | null = null
|
||||
{ controller, agentSessionId }: Partial<PageActivity> = {}
|
||||
): void {
|
||||
const renderer = this.deps.rendererForPage(browserPageId)
|
||||
if (renderer && !renderer.isDestroyed()) {
|
||||
@@ -259,7 +273,8 @@ export class BrowserAgentActivity {
|
||||
browserPageId,
|
||||
worktreeId: this.deps.worktreeForPage(browserPageId),
|
||||
active,
|
||||
...(controller ? { controllerHostLabel: controller.hostLabel } : {})
|
||||
...(controller ? { controllerHostLabel: controller.hostLabel } : {}),
|
||||
...(agentSessionId ? { agentSessionId } : {})
|
||||
}
|
||||
renderer.send(BROWSER_AGENT_ACTIVITY_CHANNEL, event)
|
||||
}
|
||||
|
||||
@@ -131,18 +131,37 @@ describe('Claude profile refresh from the default home', () => {
|
||||
expect((await provision(f)).surfaces['settings.json']).toBe('user-owned')
|
||||
expect(f.read(elsewhere)).toEqual({ mine: true })
|
||||
})
|
||||
it('copies state except the login, caches and install ids, and never copies credentials', async () => {
|
||||
it('shares configuration while keeping profile runtime state and API authorizations private', async () => {
|
||||
const f = fixture()
|
||||
fs.writeFileSync(join(f.source, '.credentials.json'), 'SOURCE_CREDENTIAL_BYTES')
|
||||
const shared = {
|
||||
mcpServers: { local: { command: 'example' } },
|
||||
theme: 'dark',
|
||||
hasCompletedOnboarding: true,
|
||||
autoModeAccepted: true,
|
||||
bypassPermissionsModeAccepted: true,
|
||||
favoritePlugins: ['favorite@example'],
|
||||
preferTmuxOverIterm2: true,
|
||||
codeReviewLastEffort: 'high',
|
||||
codeReviewLastMaxFindings: 3,
|
||||
installMethod: 'global',
|
||||
autoUpdates: false,
|
||||
autoUpdatesProtectedForNative: false,
|
||||
customApiKeyResponses: { rejected: ['PERSONAL_REJECTED_SUFFIX'] },
|
||||
projects: { '/work': { hasTrustDialogAccepted: true } }
|
||||
}
|
||||
f.json(join(f.userHome, '.claude.json'), {
|
||||
const personal = {
|
||||
...shared,
|
||||
customApiKeyResponses: {
|
||||
approved: ['PERSONAL_APPROVED_SUFFIX'],
|
||||
rejected: ['PERSONAL_REJECTED_SUFFIX']
|
||||
},
|
||||
groveChoiceSeenAt: { personal: 1 },
|
||||
numStartups: 2,
|
||||
tipsHistory: { tip: 1 },
|
||||
seenNotifications: { notice: 1 },
|
||||
penguinModeOrgEnabled: false,
|
||||
futureRuntimeState: { personal: true },
|
||||
autoModeAccepted: true,
|
||||
oauthAccount: { emailAddress: 'source@example.com' },
|
||||
primaryApiKey: 'sk-source',
|
||||
userID: 'source-id',
|
||||
@@ -150,7 +169,6 @@ describe('Claude profile refresh from the default home', () => {
|
||||
firstStartTime: 'source-start',
|
||||
firstStartVersion: '1.0.0',
|
||||
groveConfigCache: { a: 1 },
|
||||
groveChoiceSeenAt: { 'account-a': 99, 'account-b': 10 },
|
||||
cachedArtifactRoster: [],
|
||||
clientDataCacheSlots: {},
|
||||
passesEligibilityCache: {},
|
||||
@@ -162,21 +180,32 @@ describe('Claude profile refresh from the default home', () => {
|
||||
lastSeenOrgDefaultUpdatedAt: 1,
|
||||
hasAvailableSubscription: true,
|
||||
subscriptionNoticeCount: 2
|
||||
})
|
||||
}
|
||||
f.json(join(f.userHome, '.claude.json'), personal)
|
||||
expect((await provision(f)).surfaces['.claude.json']).toBe('synced')
|
||||
expect(f.read(join(f.profileHome, '.claude.json'))).toEqual({
|
||||
...shared,
|
||||
groveChoiceSeenAt: { 'account-a': 99, 'account-b': 10 }
|
||||
})
|
||||
expect(f.read(join(f.profileHome, '.claude.json'))).toEqual(shared)
|
||||
expect(fs.readdirSync(f.profileHome).filter((name) => name.endsWith('.tmp'))).toEqual([])
|
||||
expect(fs.existsSync(join(f.profileHome, '.credentials.json'))).toBe(false)
|
||||
|
||||
fs.writeFileSync(join(f.profileHome, '.credentials.json'), 'PROFILE_CREDENTIAL_BYTES')
|
||||
const profileRuntime = {
|
||||
groveChoiceSeenAt: { profile: 20 },
|
||||
numStartups: 30,
|
||||
tipsHistory: { tip: 8 },
|
||||
seenNotifications: { profileNotice: 9 },
|
||||
penguinModeOrgEnabled: true,
|
||||
futureRuntimeState: { profile: true },
|
||||
customApiKeyResponses: {
|
||||
approved: ['PROFILE_APPROVED_SUFFIX', 'PERSONAL_REJECTED_SUFFIX'],
|
||||
rejected: ['PROFILE_REJECTED_SUFFIX', 'PERSONAL_APPROVED_SUFFIX'],
|
||||
profileOnly: true
|
||||
}
|
||||
}
|
||||
f.json(join(f.profileHome, '.claude.json'), {
|
||||
...profileRuntime,
|
||||
oauthAccount: { emailAddress: 'profile@example.com' },
|
||||
userID: 'profile-id',
|
||||
groveConfigCache: { b: 2 },
|
||||
groveChoiceSeenAt: { 'account-a': 120, 'account-b': 5 },
|
||||
theme: 'light',
|
||||
onlyHere: true
|
||||
})
|
||||
@@ -185,11 +214,30 @@ describe('Claude profile refresh from the default home', () => {
|
||||
oauthAccount: { emailAddress: 'profile@example.com' },
|
||||
userID: 'profile-id',
|
||||
groveConfigCache: { b: 2 },
|
||||
groveChoiceSeenAt: { 'account-a': 120, 'account-b': 10 },
|
||||
onlyHere: true,
|
||||
...shared
|
||||
...shared,
|
||||
...profileRuntime,
|
||||
hasCompletedOnboarding: true,
|
||||
customApiKeyResponses: {
|
||||
approved: ['PROFILE_APPROVED_SUFFIX', 'PERSONAL_REJECTED_SUFFIX'],
|
||||
rejected: [
|
||||
'PROFILE_REJECTED_SUFFIX',
|
||||
'PERSONAL_APPROVED_SUFFIX',
|
||||
'PERSONAL_REJECTED_SUFFIX'
|
||||
],
|
||||
profileOnly: true
|
||||
}
|
||||
})
|
||||
const reset = { ...f.read(join(f.profileHome, '.claude.json')), hasCompletedOnboarding: false }
|
||||
f.json(join(f.profileHome, '.claude.json'), reset)
|
||||
f.json(join(f.userHome, '.claude.json'), {
|
||||
...personal,
|
||||
numStartups: 1000,
|
||||
groveChoiceSeenAt: { personal: 1000 },
|
||||
futureRuntimeState: { changed: true }
|
||||
})
|
||||
expect((await provision(f)).surfaces['.claude.json']).toBe('unchanged')
|
||||
expect(f.read(join(f.profileHome, '.claude.json'))).toEqual(reset)
|
||||
expect(fs.readFileSync(join(f.source, '.credentials.json'), 'utf8')).toBe(
|
||||
'SOURCE_CREDENTIAL_BYTES'
|
||||
)
|
||||
@@ -202,7 +250,13 @@ describe('Claude profile refresh from the default home', () => {
|
||||
const f = fixture()
|
||||
f.json(join(f.userHome, '.claude.json'), {
|
||||
projects: {
|
||||
'/shared': { hasTrustDialogAccepted: false, allowedTools: ['Read'] },
|
||||
'/shared': {
|
||||
hasTrustDialogAccepted: false,
|
||||
allowedTools: ['Read'],
|
||||
lastSessionId: 'personal'
|
||||
},
|
||||
'/runtime-only': { lastSessionId: 'personal' },
|
||||
'/malformed': 'invalid',
|
||||
'/default-only': { hasTrustDialogAccepted: true }
|
||||
},
|
||||
mcpServers: { shared: { command: 'default' } }
|
||||
@@ -210,7 +264,15 @@ describe('Claude profile refresh from the default home', () => {
|
||||
f.json(join(f.profileHome, '.claude.json'), {
|
||||
oauthAccount: LOGIN,
|
||||
projects: {
|
||||
'/shared': { hasTrustDialogAccepted: true },
|
||||
'/shared': {
|
||||
hasTrustDialogAccepted: true,
|
||||
hasCompletedProjectOnboarding: true,
|
||||
projectOnboardingSeenCount: 4,
|
||||
lastSessionId: 'profile',
|
||||
exampleFiles: ['profile.ts'],
|
||||
futureProjectState: true
|
||||
},
|
||||
'/malformed': { lastSessionId: 'keep' },
|
||||
'/account-only': { hasTrustDialogAccepted: true, allowedTools: ['Bash'] }
|
||||
},
|
||||
mcpServers: { shared: { command: 'account' }, mine: { command: 'mine' } }
|
||||
@@ -219,7 +281,16 @@ describe('Claude profile refresh from the default home', () => {
|
||||
expect(f.read(join(f.profileHome, '.claude.json'))).toEqual({
|
||||
oauthAccount: LOGIN,
|
||||
projects: {
|
||||
'/shared': { hasTrustDialogAccepted: true, allowedTools: ['Read'] },
|
||||
'/shared': {
|
||||
hasTrustDialogAccepted: true,
|
||||
allowedTools: ['Read'],
|
||||
hasCompletedProjectOnboarding: true,
|
||||
projectOnboardingSeenCount: 4,
|
||||
lastSessionId: 'profile',
|
||||
exampleFiles: ['profile.ts'],
|
||||
futureProjectState: true
|
||||
},
|
||||
'/malformed': { lastSessionId: 'keep' },
|
||||
'/account-only': { hasTrustDialogAccepted: true, allowedTools: ['Bash'] },
|
||||
'/default-only': { hasTrustDialogAccepted: true }
|
||||
},
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
type ClaudeProfileSurfaceOutcome
|
||||
} from './claude-profile-report'
|
||||
import { syncClaudeProfileSettings } from './claude-profile-settings'
|
||||
import { mergeClaudeProfileState, selectSharedClaudeProfileState } from './claude-profile-state'
|
||||
import { copyClaudeProfileFile, linkClaudeProfileDirectory } from './claude-profile-sharing'
|
||||
|
||||
const CLAUDE_PROFILE_MEMORY_IMPORT = '@~/.claude/CLAUDE.md\n'
|
||||
@@ -108,88 +109,6 @@ function isSharedEntry(name: string): boolean {
|
||||
)
|
||||
}
|
||||
|
||||
// Claude 2.1.295 logout keys and subscription notices; onboarding remains shareable.
|
||||
const CLAUDE_LOGOUT_STATE_KEYS = [
|
||||
'oauthAccount',
|
||||
'additionalModelOptionsCache',
|
||||
'additionalModelOptionsAnsweredAt',
|
||||
'additionalModelCostsCache',
|
||||
'modelAccessCache',
|
||||
'orgModelDefaultCache',
|
||||
'cachedArtifactRoster',
|
||||
'artifactRosterDenied',
|
||||
'lastSeenOrgDefaultUpdatedAt',
|
||||
'clientDataCache',
|
||||
'clientDataCacheSlots',
|
||||
'autoCompactWindowsCache',
|
||||
'cachedUsageUtilization',
|
||||
'metricsStatusCache',
|
||||
'metricsStatusCacheByPrincipal',
|
||||
'githubWebConnectionStatusCache',
|
||||
'startupPrefetchedAt',
|
||||
'subscriptionNoticeCount',
|
||||
'hasAvailableSubscription'
|
||||
] as const
|
||||
|
||||
const ACCOUNT_BOUND_STATE_KEYS: ReadonlySet<string> = new Set<string>([
|
||||
...CLAUDE_LOGOUT_STATE_KEYS,
|
||||
'userID',
|
||||
'machineID',
|
||||
'firstStartTime',
|
||||
'firstStartVersion',
|
||||
// A copied Console key would override the account's own login.
|
||||
'primaryApiKey',
|
||||
// Claude never refetches this account-specific date.
|
||||
'claudeCodeFirstTokenDate'
|
||||
])
|
||||
|
||||
function isAccountBoundState(key: string): boolean {
|
||||
// Logout leaves additional account caches such as groveConfigCache and passes*.
|
||||
return (
|
||||
ACCOUNT_BOUND_STATE_KEYS.has(key) ||
|
||||
key.includes('Cache') ||
|
||||
key.startsWith('cached') ||
|
||||
key.startsWith('passes')
|
||||
)
|
||||
}
|
||||
|
||||
// Merge per entry so a profile keeps its own projects, servers, and Grove confirmations.
|
||||
const MERGED_BY_ENTRY: ReadonlySet<string> = new Set([
|
||||
'projects',
|
||||
'mcpServers',
|
||||
'groveChoiceSeenAt'
|
||||
])
|
||||
|
||||
function isPlainRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
||||
}
|
||||
|
||||
function mergeEntries(key: string, current: unknown, source: unknown): unknown {
|
||||
if (!isPlainRecord(current) || !isPlainRecord(source)) {
|
||||
return source
|
||||
}
|
||||
const merged: Record<string, unknown> = { ...current, ...source }
|
||||
if (key === 'projects') {
|
||||
for (const [path, entry] of Object.entries(source)) {
|
||||
const own = current[path]
|
||||
// Preserve trust granted in this account, including just before launch.
|
||||
if (isPlainRecord(own) && own.hasTrustDialogAccepted === true && isPlainRecord(entry)) {
|
||||
merged[path] = { ...entry, hasTrustDialogAccepted: true }
|
||||
}
|
||||
}
|
||||
}
|
||||
if (key === 'groveChoiceSeenAt') {
|
||||
// Claude trusts a confirmation only while it is fresh, so keep each account's newest one.
|
||||
for (const [account, seenAt] of Object.entries(current)) {
|
||||
const theirs = source[account]
|
||||
if (typeof seenAt === 'number' && (typeof theirs !== 'number' || seenAt > theirs)) {
|
||||
merged[account] = seenAt
|
||||
}
|
||||
}
|
||||
}
|
||||
return merged
|
||||
}
|
||||
|
||||
async function copyState(source: string, target: string): Promise<ClaudeProfileSurfaceOutcome> {
|
||||
if (lstatIfPresent(target)?.isSymbolicLink()) {
|
||||
return 'user-owned'
|
||||
@@ -201,11 +120,11 @@ async function copyState(source: string, target: string): Promise<ClaudeProfileS
|
||||
if (input.kind === 'absent') {
|
||||
return 'absent'
|
||||
}
|
||||
const shared = Object.entries(input.value).filter(([key]) => !isAccountBoundState(key))
|
||||
const shared = selectSharedClaudeProfileState(input.value)
|
||||
if (!lstatIfPresent(target)) {
|
||||
const staged = `${target}.${process.pid}.${randomUUID()}.tmp`
|
||||
try {
|
||||
writeFileSync(staged, `${JSON.stringify(Object.fromEntries(shared), null, 2)}\n`, {
|
||||
writeFileSync(staged, `${JSON.stringify(mergeClaudeProfileState({}, shared), null, 2)}\n`, {
|
||||
flag: 'wx',
|
||||
mode: 0o600
|
||||
})
|
||||
@@ -219,10 +138,7 @@ async function copyState(source: string, target: string): Promise<ClaudeProfileS
|
||||
}
|
||||
// Preserve keys Claude added only in this account folder.
|
||||
const outcome = await updateClaudeGlobalConfig(target, (current) => {
|
||||
const config = { ...current }
|
||||
for (const [key, value] of shared) {
|
||||
config[key] = MERGED_BY_ENTRY.has(key) ? mergeEntries(key, current[key], value) : value
|
||||
}
|
||||
const config = mergeClaudeProfileState(current, shared)
|
||||
return JSON.stringify(config) === JSON.stringify(current)
|
||||
? { kind: 'unchanged' }
|
||||
: { kind: 'changed', config }
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
// Unknown state belongs to the profile; only deliberate user configuration is shared.
|
||||
const SHARED_CONFIG_KEYS = [
|
||||
'apiKeyHelper',
|
||||
'installMethod',
|
||||
'autoUpdates',
|
||||
'autoUpdatesProtectedForNative',
|
||||
'theme',
|
||||
'verbose',
|
||||
'preferredNotifChannel',
|
||||
'shiftEnterKeyBindingInstalled',
|
||||
'editorMode',
|
||||
'hasUsedBackslashReturn',
|
||||
'autoCompactEnabled',
|
||||
'autoScrollEnabled',
|
||||
'showTurnDuration',
|
||||
'externalEditorContext',
|
||||
'showMessageTimestamps',
|
||||
'diffTool',
|
||||
'env',
|
||||
'todoFeatureEnabled',
|
||||
'showExpandedTodos',
|
||||
'briefTranscript',
|
||||
'diffSidebarOpen',
|
||||
'messageIdleNotifThresholdMs',
|
||||
'autoConnectIde',
|
||||
'autoInstallIdeExtension',
|
||||
'fileCheckpointingEnabled',
|
||||
'terminalProgressBarEnabled',
|
||||
'showStatusInTerminalTab',
|
||||
'taskCompleteNotifEnabled',
|
||||
'inputNeededNotifEnabled',
|
||||
'agentPushNotifEnabled',
|
||||
'respectGitignore',
|
||||
'claudeInChromeDefaultEnabled',
|
||||
'hasCompletedClaudeInChromeOnboarding',
|
||||
'lspRecommendationDisabled',
|
||||
'lspRecommendationNeverPlugins',
|
||||
'copyFullResponse',
|
||||
'copyOnSelect',
|
||||
'leftArrowOpensAgents',
|
||||
'defaultToAgentsView',
|
||||
'prStatusFooterEnabled',
|
||||
'remoteControlAtStartup',
|
||||
'autoUploadSessions',
|
||||
'autoAddRemoteControlDaemonWorker',
|
||||
'remoteDialogSeen',
|
||||
'workflowSizeGuideline',
|
||||
'favoritePlugins',
|
||||
'preferTmuxOverIterm2',
|
||||
'codeReviewLastEffort',
|
||||
'codeReviewLastMaxFindings',
|
||||
'bypassPermissionsModeAccepted',
|
||||
'mcpServers'
|
||||
] as const
|
||||
|
||||
const SHARED_PROJECT_KEYS = [
|
||||
'allowedTools',
|
||||
'mcpContextUris',
|
||||
'mcpServers',
|
||||
'enabledMcpjsonServers',
|
||||
'disabledMcpjsonServers',
|
||||
'hasClaudeMdExternalIncludesApproved',
|
||||
'hasTrustDialogAccepted'
|
||||
] as const
|
||||
|
||||
function isPlainRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
||||
}
|
||||
|
||||
function selectConfigFields(
|
||||
source: Record<string, unknown>,
|
||||
keys: readonly string[]
|
||||
): Record<string, unknown> {
|
||||
return Object.fromEntries(
|
||||
keys.filter((key) => Object.hasOwn(source, key)).map((key) => [key, source[key]])
|
||||
)
|
||||
}
|
||||
|
||||
export function selectSharedClaudeProfileState(
|
||||
source: Record<string, unknown>
|
||||
): Record<string, unknown> {
|
||||
const shared = selectConfigFields(source, SHARED_CONFIG_KEYS)
|
||||
if (isPlainRecord(source.projects)) {
|
||||
const projects: Record<string, unknown> = {}
|
||||
for (const [path, entry] of Object.entries(source.projects)) {
|
||||
if (isPlainRecord(entry)) {
|
||||
const selected = selectConfigFields(entry, SHARED_PROJECT_KEYS)
|
||||
if (Object.keys(selected).length > 0) {
|
||||
projects[path] = selected
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Object.keys(projects).length > 0) {
|
||||
shared.projects = projects
|
||||
}
|
||||
}
|
||||
if (source.hasCompletedOnboarding === true) {
|
||||
shared.hasCompletedOnboarding = true
|
||||
}
|
||||
if (
|
||||
isPlainRecord(source.customApiKeyResponses) &&
|
||||
Array.isArray(source.customApiKeyResponses.rejected)
|
||||
) {
|
||||
const rejected = source.customApiKeyResponses.rejected.filter(
|
||||
(value) => typeof value === 'string'
|
||||
)
|
||||
if (rejected.length > 0) {
|
||||
shared.customApiKeyResponses = { rejected }
|
||||
}
|
||||
}
|
||||
return shared
|
||||
}
|
||||
|
||||
function mergeProjects(current: unknown, source: Record<string, unknown>): unknown {
|
||||
if (current !== undefined && !isPlainRecord(current)) {
|
||||
return current
|
||||
}
|
||||
const projects: Record<string, unknown> = { ...current }
|
||||
for (const [path, entry] of Object.entries(source)) {
|
||||
const own = projects[path]
|
||||
if (isPlainRecord(entry) && (own === undefined || isPlainRecord(own))) {
|
||||
projects[path] = {
|
||||
...own,
|
||||
...entry,
|
||||
...(own?.hasTrustDialogAccepted === true ? { hasTrustDialogAccepted: true } : {})
|
||||
}
|
||||
}
|
||||
}
|
||||
return projects
|
||||
}
|
||||
|
||||
function mergeRejectedApiKeys(current: unknown, source: Record<string, unknown>): unknown {
|
||||
if (current !== undefined && !isPlainRecord(current)) {
|
||||
return current
|
||||
}
|
||||
const previous = current?.rejected
|
||||
if ((previous !== undefined && !Array.isArray(previous)) || !Array.isArray(source.rejected)) {
|
||||
return current
|
||||
}
|
||||
const rejected = [...(previous ?? [])]
|
||||
const seen = new Set(rejected)
|
||||
for (const value of source.rejected) {
|
||||
if (!seen.has(value)) {
|
||||
seen.add(value)
|
||||
rejected.push(value)
|
||||
}
|
||||
}
|
||||
return { ...current, rejected }
|
||||
}
|
||||
|
||||
export function mergeClaudeProfileState(
|
||||
current: Record<string, unknown>,
|
||||
shared: Record<string, unknown>
|
||||
): Record<string, unknown> {
|
||||
const config = { ...current }
|
||||
for (const [key, value] of Object.entries(shared)) {
|
||||
if (key === 'hasCompletedOnboarding') {
|
||||
if (!Object.hasOwn(current, key)) {
|
||||
config[key] = true
|
||||
}
|
||||
} else if (key === 'customApiKeyResponses' && isPlainRecord(value)) {
|
||||
config[key] = mergeRejectedApiKeys(current[key], value)
|
||||
} else if (key === 'projects' && isPlainRecord(value)) {
|
||||
config[key] = mergeProjects(current[key], value)
|
||||
} else if (key === 'mcpServers' && isPlainRecord(current[key]) && isPlainRecord(value)) {
|
||||
config[key] = { ...current[key], ...value }
|
||||
} else {
|
||||
config[key] = value
|
||||
}
|
||||
}
|
||||
return config
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { expect, it } from 'vitest'
|
||||
import { withoutRejectedClaudeApiKey } from './claude-rejected-api-key'
|
||||
|
||||
it('honors profile approval ahead of a shared rejection, while dropping rejected-only keys', async () => {
|
||||
const home = mkdtempSync(join(tmpdir(), 'claude-api-key-'))
|
||||
const config = join(home, 'claude')
|
||||
mkdirSync(config)
|
||||
const env = {
|
||||
HOME: home,
|
||||
CLAUDE_CONFIG_DIR: config,
|
||||
ANTHROPIC_API_KEY: 'fixture-prefix-0123456789abcdefghij'
|
||||
}
|
||||
try {
|
||||
writeFileSync(
|
||||
join(config, '.claude.json'),
|
||||
JSON.stringify({
|
||||
customApiKeyResponses: {
|
||||
approved: ['0123456789abcdefghij'],
|
||||
rejected: ['0123456789abcdefghij']
|
||||
}
|
||||
})
|
||||
)
|
||||
expect(await withoutRejectedClaudeApiKey({ ...env })).toEqual(env)
|
||||
writeFileSync(
|
||||
join(config, '.claude.json'),
|
||||
JSON.stringify({
|
||||
customApiKeyResponses: { approved: [], rejected: ['0123456789abcdefghij'] }
|
||||
})
|
||||
)
|
||||
expect(await withoutRejectedClaudeApiKey({ ...env })).toEqual({
|
||||
HOME: home,
|
||||
CLAUDE_CONFIG_DIR: config
|
||||
})
|
||||
} finally {
|
||||
rmSync(home, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
@@ -3,19 +3,27 @@ import { readFile } from 'node:fs/promises'
|
||||
import { homedir } from 'node:os'
|
||||
import { resolveClaudeGlobalConfigFile } from './claude-folder-trust-file'
|
||||
|
||||
async function readRejectedApiKeyIds(configFile: string): Promise<readonly unknown[]> {
|
||||
type ClaudeApiKeyResponses = { approved: readonly unknown[]; rejected: readonly unknown[] }
|
||||
|
||||
async function readApiKeyResponses(configFile: string): Promise<ClaudeApiKeyResponses> {
|
||||
const empty = { approved: [], rejected: [] }
|
||||
try {
|
||||
const parsed: unknown = JSON.parse(await readFile(configFile, 'utf8'))
|
||||
if (typeof parsed !== 'object' || parsed === null || !('customApiKeyResponses' in parsed)) {
|
||||
return []
|
||||
return empty
|
||||
}
|
||||
const responses = parsed.customApiKeyResponses
|
||||
if (typeof responses !== 'object' || responses === null || !('rejected' in responses)) {
|
||||
return []
|
||||
if (typeof responses !== 'object' || responses === null) {
|
||||
return empty
|
||||
}
|
||||
return {
|
||||
approved:
|
||||
'approved' in responses && Array.isArray(responses.approved) ? responses.approved : [],
|
||||
rejected:
|
||||
'rejected' in responses && Array.isArray(responses.rejected) ? responses.rejected : []
|
||||
}
|
||||
return Array.isArray(responses.rejected) ? responses.rejected : []
|
||||
} catch {
|
||||
return []
|
||||
return empty
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +46,10 @@ export async function withoutRejectedClaudeApiKey(
|
||||
style,
|
||||
exists: existsSync
|
||||
})
|
||||
const rejected = await readRejectedApiKeyIds(configFile)
|
||||
const responses = await readApiKeyResponses(configFile)
|
||||
// Claude records answers by the trimmed key's last 20 characters.
|
||||
if (rejected.includes(apiKey.trim().slice(-20))) {
|
||||
const suffix = apiKey.trim().slice(-20)
|
||||
if (!responses.approved.includes(suffix) && responses.rejected.includes(suffix)) {
|
||||
for (const name of keyNames) {
|
||||
delete env[name]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { normalizeForgeWebHost } from '../../../shared/git/remotes/git-remote-host-alias'
|
||||
import { getPublicForgeProviderForHost } from '../../../shared/git/remotes/public-forge-host'
|
||||
|
||||
// Scoped local fork of the hosted-git-info@9.0.3 behavior Orca used.
|
||||
// Keep only the provider parsing and file/commit URL construction needed by source links.
|
||||
@@ -23,14 +24,14 @@ const shorthandHosts: Record<string, { host: string; provider: HostedRemoteProvi
|
||||
|
||||
function providerForHost(host: string): HostedRemoteHost | null {
|
||||
const normalized = normalizeForgeWebHost(host)
|
||||
if (normalized === 'github.com') {
|
||||
return { host: 'github.com', provider: 'github' }
|
||||
}
|
||||
if (normalized === 'gitlab.com') {
|
||||
return { host: 'gitlab.com', provider: 'gitlab' }
|
||||
}
|
||||
if (normalized === 'bitbucket.org') {
|
||||
return { host: 'bitbucket.org', provider: 'bitbucket' }
|
||||
const provider = getPublicForgeProviderForHost(normalized)
|
||||
if (
|
||||
(normalized === 'github.com' ||
|
||||
normalized === 'gitlab.com' ||
|
||||
normalized === 'bitbucket.org') &&
|
||||
(provider === 'github' || provider === 'gitlab' || provider === 'bitbucket')
|
||||
) {
|
||||
return { host: normalized, provider }
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { expect, it } from 'vitest'
|
||||
import { parseGiteaRepoRef } from './repository-ref'
|
||||
|
||||
it('keeps Gitea endpoints available without claiming canonical foreign hosts', () => {
|
||||
for (const remote of [
|
||||
'git@ssh.github.com:team/repo.git',
|
||||
'ssh://git@altssh.gitlab.com:443/team/repo.git',
|
||||
'https://acme.ghe.com/team/repo.git'
|
||||
]) {
|
||||
expect(parseGiteaRepoRef(remote)).toBeNull()
|
||||
}
|
||||
expect(parseGiteaRepoRef('https://codeberg.org/team/repo.git')).toMatchObject({
|
||||
owner: 'team',
|
||||
repo: 'repo'
|
||||
})
|
||||
expect(parseGiteaRepoRef('https://git.acme.test/team/repo.git')).toMatchObject({
|
||||
owner: 'team',
|
||||
repo: 'repo'
|
||||
})
|
||||
})
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createRemoteRefProbeCache } from '../git/remotes/remote-ref-probe-cache'
|
||||
import { getPublicForgeProviderForHost } from '../../shared/git/remotes/public-forge-host'
|
||||
|
||||
export type GiteaRepoRef = {
|
||||
host: string
|
||||
@@ -12,14 +13,6 @@ type LocalGitExecOptions = {
|
||||
wslDistro?: string
|
||||
}
|
||||
|
||||
const KNOWN_NON_GITEA_HOSTS = new Set([
|
||||
'github.com',
|
||||
'gitlab.com',
|
||||
'bitbucket.org',
|
||||
'ssh.bitbucket.org',
|
||||
'dev.azure.com',
|
||||
'ssh.dev.azure.com'
|
||||
])
|
||||
const repoRefProbeCache = createRemoteRefProbeCache(parseGiteaRepoRef)
|
||||
|
||||
/** @internal - exposed for tests only */
|
||||
@@ -69,11 +62,8 @@ function apiBaseUrlFromWebBase(webBaseUrl: string): string {
|
||||
|
||||
function makeRepoRef(host: string, path: string, webOrigin: string): GiteaRepoRef | null {
|
||||
const normalizedHost = host.toLowerCase()
|
||||
if (
|
||||
!normalizedHost ||
|
||||
KNOWN_NON_GITEA_HOSTS.has(normalizedHost) ||
|
||||
normalizedHost.endsWith('.visualstudio.com')
|
||||
) {
|
||||
const owner = getPublicForgeProviderForHost(normalizedHost)
|
||||
if (!normalizedHost || (owner && owner !== 'gitea')) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,24 @@ describe('getEnterpriseGitHubRepoSlug', () => {
|
||||
_resetOriginGitHubApiRepositoryCache()
|
||||
})
|
||||
|
||||
it.each([
|
||||
['https://bitbucket.org/team/orca.git', 'bitbucket.org'],
|
||||
['ssh://git@altssh.gitlab.com:443/team/orca.git', 'altssh.gitlab.com'],
|
||||
['https://codeberg.org/team/orca.git', 'codeberg.org']
|
||||
])('does not promote a foreign public remote from gh inventory: %s', async (url, host) => {
|
||||
mockOriginRemote(url)
|
||||
mockHostAuthenticated(host)
|
||||
await expect(getEnterpriseGitHubRepoSlug('/repo')).resolves.toBeFalsy()
|
||||
await expect(isGitHubHostAuthenticated(host, '/repo')).resolves.toBe(false)
|
||||
})
|
||||
|
||||
it('uses the effective SSH hostname before admitting an Enterprise identity', async () => {
|
||||
mockOriginRemote('git@work-forge:team/orca.git')
|
||||
resolveWithSshGMock.mockResolvedValue({ hostname: 'bitbucket.org' })
|
||||
mockHostAuthenticated('bitbucket.org')
|
||||
await expect(getEnterpriseGitHubRepoSlug('/repo')).resolves.toBeNull()
|
||||
})
|
||||
|
||||
it.each([
|
||||
'https://ghe.acme.com:8443/team/orca.git',
|
||||
'https://ghe.acme.com:80/team/orca.git',
|
||||
|
||||
@@ -22,6 +22,7 @@ import { parseWslPath } from '../wsl/filesystem/unc-path-access'
|
||||
import { isStableMissingGitRemoteError } from '../git/remotes/stable-missing-git-remote-error'
|
||||
import { requireReachableGitRoute } from '../providers/execution-host-provider-dispatch'
|
||||
import { getConnectionExecutionHostId } from '../../shared/execution-host'
|
||||
import { getPublicForgeProviderForHost } from '../../shared/git/remotes/public-forge-host'
|
||||
|
||||
export type GitHubEnterpriseRepoSlug = GitHubOwnerRepo & { host: string }
|
||||
|
||||
@@ -131,6 +132,10 @@ async function resolveAuthenticatedGitHubHost(
|
||||
connectionId?: string | null,
|
||||
localGitOptions: LocalGitExecOptions = {}
|
||||
): Promise<string | null | undefined> {
|
||||
const owner = getPublicForgeProviderForHost(host)
|
||||
if (owner && owner !== 'github') {
|
||||
return null
|
||||
}
|
||||
const normalizedHost = normalizeGitHubHost(host)?.authority ?? host.trim().toLowerCase()
|
||||
const execOptions = ghRepoExecOptions(githubRepoContext(repoPath, connectionId, localGitOptions))
|
||||
const cacheKey = `${runtimeCacheKey(repoPath, connectionId, localGitOptions.wslDistro)}\0${normalizedHost}\0${githubReadExecutionScope(execOptions)}`
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { glabExecFileAsync } from '../git/runner'
|
||||
import type { GitAdmissionTier } from '../git/command-runner/git-exec-options'
|
||||
import { addWslEnvKeys } from '../../shared/wsl-env'
|
||||
import { normalizeForgeWebHost } from '../../shared/git/remotes/git-remote-host-alias'
|
||||
import { isTransientGitProbeError, readRemoteUrl } from '../git/remotes/remote-url-probe'
|
||||
import { NEGATIVE_ENTRY_TTL_MS } from '../git/remotes/remote-ref-probe-cache'
|
||||
import { readLocalGitConfigSignature } from '../github/local-git-config-signature'
|
||||
@@ -19,7 +18,7 @@ import {
|
||||
DEFAULT_GITLAB_HOSTS,
|
||||
normalizeGitLabHost,
|
||||
parseGitLabProjectRef,
|
||||
parseRemoteProjectRefCandidate,
|
||||
parseGitLabProjectRefCandidate,
|
||||
type ProjectRef
|
||||
} from './project-ref-parser'
|
||||
|
||||
@@ -154,19 +153,12 @@ async function resolveProjectRefForRemote(
|
||||
if (stdout === null) {
|
||||
return null
|
||||
}
|
||||
// Stray glab host entries for GitHub/Bitbucket hosts must not claim their remotes (#40386).
|
||||
// Match the real host only: `github:team/project` is an scp remote on an SSH alias named github.
|
||||
const remoteCandidate = parseRemoteProjectRefCandidate(stdout)
|
||||
const remoteHost = remoteCandidate && normalizeForgeWebHost(remoteCandidate.host)
|
||||
if (remoteHost === 'github.com' || remoteHost === 'bitbucket.org') {
|
||||
publish(null)
|
||||
return null
|
||||
}
|
||||
const result = parseGitLabProjectRef(stdout, knownHosts)
|
||||
if (result) {
|
||||
publish(result)
|
||||
return result
|
||||
}
|
||||
const remoteCandidate = parseGitLabProjectRefCandidate(stdout)
|
||||
if (
|
||||
remoteCandidate &&
|
||||
(await isGlabConfiguredForRemoteHost(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { parseGitLabProjectRef } from './project-ref-parser'
|
||||
import { parseGitLabProjectRef, parseRemoteProjectRefCandidate } from './project-ref-parser'
|
||||
|
||||
describe('gitlab project ref parsing', () => {
|
||||
it.each([
|
||||
@@ -43,4 +43,31 @@ describe('gitlab project ref parsing', () => {
|
||||
parseGitLabProjectRef('http://gitea.example.com:3030/team/api.git', knownHosts)
|
||||
).toBeNull()
|
||||
})
|
||||
|
||||
it('keeps public ownership authoritative without narrowing generic mirror parsing', () => {
|
||||
for (const [remote, host] of [
|
||||
['https://github.com:8443/team/project.git', 'github.com:8443'],
|
||||
['git@SSH.GITHUB.COM:team/project.git', 'ssh.github.com'],
|
||||
['git@acme.ghe.com:team/project.git', 'acme.ghe.com'],
|
||||
['git@ssh.bitbucket.org:team/project.git', 'ssh.bitbucket.org'],
|
||||
['https://dev.azure.com/acme/project/_git/repo', 'dev.azure.com'],
|
||||
['git@ssh.dev.azure.com:v3/acme/project/repo', 'ssh.dev.azure.com'],
|
||||
['https://acme.visualstudio.com/project/_git/repo', 'acme.visualstudio.com'],
|
||||
['https://codeberg.org/team/project.git', 'codeberg.org']
|
||||
]) {
|
||||
expect(parseGitLabProjectRef(remote, [host])).toBeNull()
|
||||
}
|
||||
expect(parseRemoteProjectRefCandidate('git@github.com:team/project.git')).toEqual({
|
||||
host: 'github.com',
|
||||
path: 'team/project'
|
||||
})
|
||||
expect(
|
||||
parseGitLabProjectRef('https://git.bitbucket.acme.com/team/project.git', [
|
||||
'git.bitbucket.acme.com'
|
||||
])
|
||||
).toEqual({
|
||||
host: 'git.bitbucket.acme.com',
|
||||
path: 'team/project'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { GitLabProjectRef } from '../../shared/gitlab-types'
|
||||
import { normalizeGitLabRemoteHost } from '../../shared/git/remotes/git-remote-host-alias'
|
||||
import { getPublicForgeProviderForHost } from '../../shared/git/remotes/public-forge-host'
|
||||
|
||||
export type ProjectRef = GitLabProjectRef
|
||||
|
||||
@@ -47,19 +48,6 @@ function knownHostMatches(urlHost: string, knownHost: string): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
function makeProjectRef(
|
||||
host: string,
|
||||
path: string,
|
||||
knownHosts: readonly string[]
|
||||
): ProjectRef | null {
|
||||
const normalizedHost = normalizeGitLabRemoteHost(host)
|
||||
const normalizedKnownHosts = knownHosts.map(normalizeGitLabHost)
|
||||
if (!normalizedKnownHosts.some((knownHost) => knownHostMatches(normalizedHost, knownHost))) {
|
||||
return null
|
||||
}
|
||||
return makeProjectRefForTrustedHost(normalizedHost, path)
|
||||
}
|
||||
|
||||
export function parseRemoteProjectRefCandidate(remoteUrl: string): ProjectRef | null {
|
||||
const trimmed = remoteUrl.trim()
|
||||
if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed)) {
|
||||
@@ -80,25 +68,24 @@ export function parseRemoteProjectRefCandidate(remoteUrl: string): ProjectRef |
|
||||
}
|
||||
}
|
||||
|
||||
export function parseGitLabProjectRefCandidate(remoteUrl: string): ProjectRef | null {
|
||||
const candidate = parseRemoteProjectRefCandidate(remoteUrl)
|
||||
if (!candidate) {
|
||||
return null
|
||||
}
|
||||
const owner = getPublicForgeProviderForHost(candidate.host)
|
||||
return owner && owner !== 'gitlab' ? null : candidate
|
||||
}
|
||||
|
||||
export function parseGitLabProjectRef(
|
||||
remoteUrl: string,
|
||||
knownHosts: readonly string[] = DEFAULT_GITLAB_HOSTS
|
||||
): ProjectRef | null {
|
||||
const trimmed = remoteUrl.trim()
|
||||
if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed)) {
|
||||
const scpLike = trimmed.match(/^(?:[^@/:]+@)?([^:\s/]+):([^\s]+?)(?:\.git)?$/)
|
||||
if (scpLike) {
|
||||
return makeProjectRef(scpLike[1], scpLike[2], knownHosts)
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const url = new URL(trimmed)
|
||||
if (!['http:', 'https:', 'ssh:', 'git:', 'git+ssh:'].includes(url.protocol.toLowerCase())) {
|
||||
return null
|
||||
}
|
||||
return makeProjectRef(hostIdentityFromUrl(url), url.pathname, knownHosts)
|
||||
} catch {
|
||||
const candidate = parseGitLabProjectRefCandidate(remoteUrl)
|
||||
if (!candidate) {
|
||||
return null
|
||||
}
|
||||
return knownHosts.some((host) => knownHostMatches(candidate.host, normalizeGitLabHost(host)))
|
||||
? candidate
|
||||
: null
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ vi.mock('../git/command-runner/gh-exec-file', async (importOriginal) => ({
|
||||
}))
|
||||
|
||||
import { listMergeRequests } from './merge-request-list'
|
||||
import { isTaskRepositoryIneligible } from '../git/task-repository-eligibility'
|
||||
import { rememberGlabKnownHosts } from './gitlab-known-host-probe'
|
||||
import { listIssues } from './issues'
|
||||
import { _resetProjectRefCache, _resetKnownHostsCache } from './gitlab-project-ref-resolution'
|
||||
import { _resetRemoteNameListingCache } from '../git/remotes/remote-name-listing'
|
||||
@@ -132,4 +134,9 @@ describe('GitLab task project admission', () => {
|
||||
expect(result.items).toEqual([])
|
||||
expect(glab.mock.calls.filter(([args]) => args[0] !== 'auth')).toEqual([])
|
||||
})
|
||||
|
||||
it('does not exclude GitHub tasks because glab remembers github.com', async () => {
|
||||
rememberGlabKnownHosts(['github.com'])
|
||||
await expect(isTaskRepositoryIneligible('/github', 'github')).resolves.toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,27 +1,6 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import type { Session } from 'electron'
|
||||
import { setMainHttpClient } from '../../../network/http-client'
|
||||
|
||||
const { fetchMock, sessionFromPartitionMock } = vi.hoisted(() => {
|
||||
const fetchMock = vi.fn()
|
||||
const cookiesSetMock = vi.fn(() => Promise.resolve())
|
||||
const clearStorageDataMock = vi.fn(() => Promise.resolve())
|
||||
const sessionFromPartitionMock = vi.fn(() => ({
|
||||
clearStorageData: clearStorageDataMock,
|
||||
cookies: { set: cookiesSetMock },
|
||||
fetch: fetchMock
|
||||
}))
|
||||
return { clearStorageDataMock, cookiesSetMock, fetchMock, sessionFromPartitionMock }
|
||||
})
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { redactMiniMaxSecret } from './minimax-request-context'
|
||||
|
||||
setMainHttpClient({
|
||||
fetch: fetchMock,
|
||||
proxySession: () => null,
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the code under test only calls clearStorageData, cookies.set and fetch, which the fake provides.
|
||||
partitionSession: sessionFromPartitionMock as unknown as (partition: string) => Session
|
||||
})
|
||||
|
||||
describe('redactMiniMaxSecret', () => {
|
||||
it('redacts _token values in header and quoted syntax', () => {
|
||||
const redacted = redactMiniMaxSecret('cookie _token=eyJhABCDEF and _token:"x.y"')
|
||||
|
||||
@@ -256,22 +256,26 @@ export class RpcDispatcher {
|
||||
legacyCoordinator?.mutationCallerFingerprint ?? fallbackCallerFingerprint
|
||||
const invoke = (mutation?: DurableMutationInvocation) => {
|
||||
const legacyCoordinatorRunId = legacyCoordinator?.revalidate()
|
||||
return runWithActiveRpcCaller(context.caller, () =>
|
||||
method.handler(effectiveParams, {
|
||||
...context,
|
||||
authenticatedCallerFingerprint: mutation?.identity.callerFingerprint ?? callerFingerprint,
|
||||
recordMutationReceipt: mutation?.recordReceipt,
|
||||
markWorkerDoneMutationEffectFree: mutation?.markWorkerDoneEffectFree,
|
||||
markMutationEffectPossible: mutation?.markEffectPossible,
|
||||
orchestrationMutation: mutation?.identity,
|
||||
replayedMutationReceipt: mutation?.replayedReceipt,
|
||||
legacyCoordinatorRunId,
|
||||
legacyCoordinatorAuthority: legacyCoordinator?.authority,
|
||||
revalidateLegacyCoordinator: legacyCoordinator?.revalidate,
|
||||
orchestrationCompatibilityCallerAuthority:
|
||||
compatibility.orchestrationCompatibilityCallerAuthority,
|
||||
orchestrationCompatibilityEvidence: request.orchestrationCompatibilityEvidence
|
||||
})
|
||||
return runWithActiveRpcCaller(
|
||||
context.caller,
|
||||
() =>
|
||||
method.handler(effectiveParams, {
|
||||
...context,
|
||||
authenticatedCallerFingerprint:
|
||||
mutation?.identity.callerFingerprint ?? callerFingerprint,
|
||||
recordMutationReceipt: mutation?.recordReceipt,
|
||||
markWorkerDoneMutationEffectFree: mutation?.markWorkerDoneEffectFree,
|
||||
markMutationEffectPossible: mutation?.markEffectPossible,
|
||||
orchestrationMutation: mutation?.identity,
|
||||
replayedMutationReceipt: mutation?.replayedReceipt,
|
||||
legacyCoordinatorRunId,
|
||||
legacyCoordinatorAuthority: legacyCoordinator?.authority,
|
||||
revalidateLegacyCoordinator: legacyCoordinator?.revalidate,
|
||||
orchestrationCompatibilityCallerAuthority:
|
||||
compatibility.orchestrationCompatibilityCallerAuthority,
|
||||
orchestrationCompatibilityEvidence: request.orchestrationCompatibilityEvidence
|
||||
}),
|
||||
request.orchestrationCompatibilityEvidence?.agentSessionId
|
||||
)
|
||||
}
|
||||
const result = await orchestrationMutations.run(
|
||||
|
||||
@@ -1,14 +1,40 @@
|
||||
import { AsyncLocalStorage } from 'node:async_hooks'
|
||||
import type { RpcCallerIdentity } from './rpc-caller-identity'
|
||||
import { isOrcaSessionId } from '../../../shared/orca-session-address'
|
||||
import { isAgentRpcCaller, type RpcCallerIdentity } from './rpc-caller-identity'
|
||||
|
||||
type ActiveRpcCall = {
|
||||
caller: RpcCallerIdentity | undefined
|
||||
agentSessionId: string | undefined
|
||||
}
|
||||
|
||||
// Lets code far below a handler tell an agent's CLI call from a person's relayed input.
|
||||
const activeCaller = new AsyncLocalStorage<RpcCallerIdentity | undefined>()
|
||||
const activeCall = new AsyncLocalStorage<ActiveRpcCall>()
|
||||
|
||||
export function runWithActiveRpcCaller<T>(caller: RpcCallerIdentity | undefined, run: () => T): T {
|
||||
return activeCaller.run(caller, run)
|
||||
export function runWithActiveRpcCaller<T>(
|
||||
caller: RpcCallerIdentity | undefined,
|
||||
run: () => T,
|
||||
claimedAgentSessionId?: string
|
||||
): T {
|
||||
// Only this host's CLI can name a chat here; as in the handoff card, other callers act for a person.
|
||||
const agentSessionId =
|
||||
isAgentRpcCaller(caller) && claimedAgentSessionId && isOrcaSessionId(claimedAgentSessionId)
|
||||
? claimedAgentSessionId
|
||||
: undefined
|
||||
return activeCall.run({ caller, agentSessionId }, run)
|
||||
}
|
||||
|
||||
/** The caller of the RPC handler this code runs under; undefined outside any handler. */
|
||||
export function getActiveRpcCaller(): RpcCallerIdentity | undefined {
|
||||
return activeCaller.getStore()
|
||||
return activeCall.getStore()?.caller
|
||||
}
|
||||
|
||||
/** The chat whose agent sent this call, as its CLI claims it: display attribution, never authority. */
|
||||
export function getActiveRpcAgentSessionId(): string | undefined {
|
||||
return activeCall.getStore()?.agentSessionId
|
||||
}
|
||||
|
||||
/** Re-enters this call later, for work a queue runs from inside another caller's call. */
|
||||
export function captureActiveRpcCall(): <T>(run: () => T) => T {
|
||||
const call = activeCall.getStore()
|
||||
return (run) => (call ? activeCall.run(call, run) : activeCall.exit(run))
|
||||
}
|
||||
|
||||
@@ -35,11 +35,6 @@ vi.mock('../git/command-runner/gh-exec-file', async (importOriginal) => ({
|
||||
ghExecFileAsync: ghExecFileAsyncMock
|
||||
}))
|
||||
|
||||
vi.mock('../git/exec-error', async (importOriginal) => ({
|
||||
...(await importOriginal<Record<string, unknown>>()),
|
||||
extractExecError: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../github/client', () => ({
|
||||
createGitHubPullRequest: vi.fn(),
|
||||
getRepoSlug: getRepoSlugMock,
|
||||
@@ -71,6 +66,8 @@ vi.mock('./hosted-review', () => ({
|
||||
import { _resetKnownHostsCache, _resetProjectRefCache } from '../gitlab/gl-utils'
|
||||
import { diagnoseAuth } from '../gitlab/client'
|
||||
import { getHostedReviewCreationEligibility } from './hosted-review-creation'
|
||||
import { detectHostedReviewProvider } from './forge-provider-detection'
|
||||
import { rememberGlabKnownHosts } from '../gitlab/gitlab-known-host-probe'
|
||||
|
||||
function resetMocks(): void {
|
||||
for (const mock of [
|
||||
@@ -167,4 +164,49 @@ describe('GitLab self-hosted hosted review creation eligibility', () => {
|
||||
blockedReason: null
|
||||
})
|
||||
})
|
||||
|
||||
it.each(['per-host failure', 'global inventory', 'remembered inventory'])(
|
||||
'keeps GitHub PR identity across repositories despite glab %s',
|
||||
async (evidence) => {
|
||||
gitExecFileAsyncMock.mockResolvedValue({ stdout: 'git@github.com:team/orca.git\n' })
|
||||
getRepoSlugMock.mockResolvedValue({ owner: 'team', repo: 'orca' })
|
||||
if (evidence === 'remembered inventory') {
|
||||
rememberGlabKnownHosts(['github.com'])
|
||||
}
|
||||
glabExecFileAsyncMock.mockImplementation(async (args: string[]) => {
|
||||
if (args.includes('--hostname')) {
|
||||
// Captured glab 1.115 output for a configured host without a token.
|
||||
throw Object.assign(new Error('glab auth status failed'), {
|
||||
stdout: '',
|
||||
stderr:
|
||||
'github.com\n x github.com: API call failed\n ! No token found (checked config file, keyring, and environment variables).\n'
|
||||
})
|
||||
}
|
||||
return {
|
||||
stdout:
|
||||
evidence === 'global inventory'
|
||||
? 'github.com\n ✓ Logged in to github.com as example-user (config file)\n'
|
||||
: 'gitlab.com\n ✓ Logged in to gitlab.com as example-user (config file)\n',
|
||||
stderr: ''
|
||||
}
|
||||
})
|
||||
for (const repoPath of ['/first-repo', '/second-repo']) {
|
||||
await expect(
|
||||
detectHostedReviewProvider({ repoPath, executionHostId: 'local' })
|
||||
).resolves.toBe('github')
|
||||
}
|
||||
|
||||
gitExecFileAsyncMock.mockResolvedValue({ stdout: 'https://forge.acme.test/team/orca.git\n' })
|
||||
glabExecFileAsyncMock.mockRejectedValue(
|
||||
Object.assign(new Error('glab auth status failed'), {
|
||||
stdout: '',
|
||||
stderr:
|
||||
'forge.acme.test\n x forge.acme.test: API call failed\n ! No token found (checked config file, keyring, and environment variables).\n'
|
||||
})
|
||||
)
|
||||
await expect(
|
||||
detectHostedReviewProvider({ repoPath: '/custom', executionHostId: 'local' })
|
||||
).resolves.toBe('gitlab')
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
@@ -13,9 +13,9 @@ import {
|
||||
} from '../components/sidebar/workspace-card/identity/child-workspaces-toggle-target'
|
||||
import { requestTerminalTabRename } from '../components/tab-bar/terminal-tab-rename-request'
|
||||
import {
|
||||
deleteHoveredWorkspaceImmediately,
|
||||
resolveHoveredWorkspaceDeleteTarget
|
||||
} from '../components/sidebar/workspace-actions/deletion/hovered-workspace-delete'
|
||||
deleteActiveWorkspaceFromShortcut,
|
||||
resolveActiveWorkspaceDeleteTarget
|
||||
} from '../components/sidebar/workspace-actions/deletion/active-workspace-delete'
|
||||
import { useAppStore } from '../store/index'
|
||||
import type { usePluginCommands } from '@/store/plugins/catalog/plugin-contribution-catalog'
|
||||
import { isGitRepoKind } from '../../../shared/repo-kind'
|
||||
@@ -230,12 +230,12 @@ export function createAppCommandHandlers(
|
||||
return false
|
||||
}
|
||||
const store = useAppStore.getState()
|
||||
const target = resolveHoveredWorkspaceDeleteTarget(store)
|
||||
const target = resolveActiveWorkspaceDeleteTarget(store)
|
||||
if (!target) {
|
||||
return false
|
||||
}
|
||||
return claim('workspace.delete', () => {
|
||||
deleteHoveredWorkspaceImmediately(store, target)
|
||||
deleteActiveWorkspaceFromShortcut(store, target)
|
||||
})
|
||||
}
|
||||
],
|
||||
|
||||
@@ -1,31 +1,22 @@
|
||||
import type { ITheme } from '@xterm/xterm'
|
||||
import type { GlobalSettings } from '../../../../shared/global-settings-types'
|
||||
import {
|
||||
completePluginAppThemeTokens,
|
||||
type PluginThemeTokenColorRule
|
||||
} from '../../../../shared/plugins/artifacts/plugin-theme-artifact'
|
||||
import { completePluginAppThemeTokens } from '../../../../shared/plugins/artifacts/plugin-theme-artifact'
|
||||
import type { PluginThemeTokenColorRule } from '../../../../shared/plugins/artifacts/plugin-theme-artifact'
|
||||
import { pluginAppThemeCssFallback } from '../../../../shared/plugins/artifacts/plugin-theme-css-fallbacks'
|
||||
import { MATCH_TERMINAL_APP_THEME } from '../../../../shared/plugin-theme-settings'
|
||||
import {
|
||||
resolveTerminalPalette,
|
||||
type TerminalPaletteSettings as TerminalAppThemeSettings
|
||||
} from '../../../../shared/terminal-themes/terminal-theme-selection'
|
||||
import type { AppThemePaint } from './document-theme'
|
||||
import { resolveTerminalPalette } from '../../../../shared/terminal-themes/terminal-theme-selection'
|
||||
import type { TerminalPaletteSettings as TerminalAppThemeSettings } from '../../../../shared/terminal-themes/terminal-theme-selection'
|
||||
import { hashThemeContent } from '../../lib/editor/appearance/plugin-monaco-theme'
|
||||
import type { ColorProbe } from './plugin-theme-tokens'
|
||||
import {
|
||||
contrastRatio,
|
||||
mix,
|
||||
readableOn,
|
||||
rgbaToHex,
|
||||
type Rgba
|
||||
} from '../../../../shared/color/rgba-contrast'
|
||||
import { getSystemPrefersDark } from '../../lib/terminal-theme'
|
||||
import { contrastRatio, mix, readableOn, rgbaToHex } from '../../../../shared/color/rgba-contrast'
|
||||
import type { Rgba } from '../../../../shared/color/rgba-contrast'
|
||||
import { getSystemPrefersDark } from '../../lib/terminal/appearance/terminal-theme'
|
||||
import {
|
||||
isTerminalBackgroundLight,
|
||||
resolveOpaqueTerminalBackground
|
||||
} from '../../../../shared/terminal-themes/terminal-title-contrast'
|
||||
import { terminalPaletteRgba } from '../../../../shared/terminal-themes/terminal-palette-rgba'
|
||||
import type { ITheme } from '@xterm/xterm'
|
||||
import type { GlobalSettings } from '../../../../shared/global-settings-types'
|
||||
import type { AppThemePaint } from './document-theme'
|
||||
import type { ColorProbe } from './plugin-theme-tokens'
|
||||
|
||||
export type TerminalAppTheme = AppThemePaint & {
|
||||
id: typeof MATCH_TERMINAL_APP_THEME
|
||||
|
||||
@@ -24,7 +24,7 @@ import { recoverFromDegradedStartup } from '../startup/startup-degraded-recovery
|
||||
import { restoreSshConnectionsForStartup } from '../startup/startup-ssh-connection-restore'
|
||||
import { collectActiveWorkspaceSshTargetIds } from '../startup/active-workspace-ssh-targets'
|
||||
import { publishTerminalViewAttributesAtAppStart } from '../components/terminal-pane/appearance/terminal-appearance'
|
||||
import { getSystemPrefersDark } from '../lib/terminal-theme'
|
||||
import { getSystemPrefersDark } from '../lib/terminal/appearance/terminal-theme'
|
||||
import {
|
||||
collectTerminalProviderSnapshotPtyIds,
|
||||
refreshTerminalProviderSnapshotCapabilities
|
||||
@@ -40,12 +40,12 @@ import { listRuntimeSessionHostsForStartup } from './startup-runtime-session-hos
|
||||
import { mapWithConcurrency } from '../../../shared/map-with-concurrency'
|
||||
import { collectWslMovedWorkspaceKeysFromSession } from '../store/repos/wsl-moved-projects'
|
||||
import { wslMovedSessionReadApi } from '../store/repos/wsl-moved-local-session-rows'
|
||||
import type { OnboardingState } from '../../../shared/onboarding-state-types'
|
||||
import { ensureLocalRuntimeCapabilities } from '../runtime/hosts/capabilities/local-runtime-capabilities'
|
||||
import {
|
||||
finishStartupWorktreeHydration,
|
||||
refreshStartupWorktrees
|
||||
} from '../startup/startup-worktree-refresh'
|
||||
import type { OnboardingState } from '../../../shared/onboarding-state-types'
|
||||
|
||||
/** Hydrate settings/UI/catalog/session, reconnect and restore terminals before unlocking saves. Failure boots in degraded no-save mode to protect disk state. */
|
||||
export function useAppStartupHydration(onOnboardingLoaded: (state: OnboardingState) => void): void {
|
||||
|
||||
@@ -99,6 +99,12 @@ export function useDocumentAppearance(): void {
|
||||
usePluginFontRegistration()
|
||||
const reduceEffects = useReduceVisualEffects(useAppStore((s) => s.settings?.reduceVisualEffects))
|
||||
const surfaceOpacity = useAppStore((s) => s.settings?.terminalBackgroundOpacity ?? 1)
|
||||
useEffect(() => {
|
||||
document.documentElement.style.setProperty(
|
||||
'--orca-window-surface-opacity',
|
||||
String(surfaceOpacity)
|
||||
)
|
||||
}, [surfaceOpacity])
|
||||
// Why re-parse: the theme list keeps the registration as received, and a newer host may send
|
||||
// a background this build cannot paint; it must drop to no image, never reach CSS.
|
||||
const registeredBackground = pluginTheme?.background
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useEffect } from 'react'
|
||||
import { getSystemPrefersDark } from '@/lib/terminal-theme'
|
||||
import { getSystemPrefersDark } from '@/lib/terminal/appearance/terminal-theme'
|
||||
import { publishTerminalViewAttributesAtAppStart } from '../components/terminal-pane/appearance/terminal-appearance'
|
||||
import { subscribeToPublishedTerminalViewAttributes } from '../components/terminal-pane/appearance/terminal-view-attributes-publisher'
|
||||
import { remoteRuntimeTerminalColorPush } from '../runtime/hosted-terminals/streams/remote-runtime-terminal-color-push'
|
||||
import { useAppStore } from '../store'
|
||||
import { useAppStore } from '../store/index'
|
||||
|
||||
/** Reports this window's terminal theme to its own host and to every paired host. */
|
||||
export function useTerminalViewerColorPublication(): void {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useMemo, type CSSProperties, type JSX, type ReactNode } from 'react'
|
||||
import { useMemo } from 'react'
|
||||
import type { CSSProperties, JSX, ReactNode } from 'react'
|
||||
import { ArrowUp, ChevronDown, Eye, Hand, Plus, X } from 'lucide-react'
|
||||
import type { GlobalSettings } from '../../../../../shared/global-settings-types'
|
||||
import { FlowDiagram } from '@/components/feature-tips/ChatUiHereFeatureTipVisual'
|
||||
import {
|
||||
CHAT_DEMO_FILE,
|
||||
@@ -18,8 +18,9 @@ import { useSystemPrefersDark } from '@/hooks/theme/use-system-prefers-dark'
|
||||
import { useIntlLocale, useTranslate } from '@/i18n/use-translate'
|
||||
import { AgentIcon } from '@/components/agent/icons/AgentIcon'
|
||||
import { buildFontFamily } from '../../../../../shared/monospace-font-family'
|
||||
import { resolveEffectiveTerminalAppearance } from '@/lib/terminal-theme'
|
||||
import { resolveEffectiveTerminalAppearance } from '@/lib/terminal/appearance/terminal-theme'
|
||||
import { cn } from '@/lib/class-names'
|
||||
import type { GlobalSettings } from '../../../../../shared/global-settings-types'
|
||||
|
||||
// The tip's chat miniature, finished and denser so it fits a tile; nothing here animates.
|
||||
const CHAT_SCALE: CSSProperties & { '--chat-font-size': string } = { '--chat-font-size': '10px' }
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { openExistingStructuredSession } from '@/lib/open-existing-structured-session'
|
||||
import { openExistingStructuredSession } from '@/lib/agent-session/open/open-existing-structured-session'
|
||||
import { ALL_TUI_AGENTS } from '../../../../../shared/agent-launch/catalog/tui-agent-display-names'
|
||||
import { isStructuredAgentSessionIdFor } from '../../../../../shared/agent-session/structured-agent-session-create'
|
||||
import type { AutomationRun } from '../../../../../shared/automations/history/automation-run'
|
||||
import { toast } from 'sonner'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import {
|
||||
activateAndRevealWorktree,
|
||||
activateAndRevealFolderWorkspace
|
||||
} from '@/lib/workspace/activation/worktree-activation'
|
||||
import type { ActivateAndRevealResult } from '@/lib/workspace/activation/worktree-activation-outcome'
|
||||
import { activateWslMovedWorkspace } from '@/lib/workspace/activation/wsl-moved-chat-activation'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import { activateTerminalTabOnOwner } from '@/lib/workspace/tabs/terminal-tab-owner-activation'
|
||||
@@ -17,6 +15,8 @@ import { resolveWebSessionVisibleTabId } from '@/runtime/web-session-tabs-sync/n
|
||||
import { parsePaneKey } from '../../../../../shared/workspace-layout/stable-pane-id'
|
||||
import { parseWorkspaceKey } from '../../../../../shared/workspace-scope'
|
||||
import { buildAutomationRunOpenLayout } from './automation-run-pane-layout'
|
||||
import type { AutomationRun } from '../../../../../shared/automations/history/automation-run'
|
||||
import type { ActivateAndRevealResult } from '@/lib/workspace/activation/worktree-activation-outcome'
|
||||
import type { AutomationsPageActionContext } from '../automations-page-action-context'
|
||||
|
||||
let cancelPendingReveal: (() => void) | undefined
|
||||
|
||||
+17
-7
@@ -14,7 +14,9 @@ type BrowserAgentActivityMark = { pageId: string; revision: number }
|
||||
const activePageIds = new Set<string>()
|
||||
/** The SSH host driving a page through the desktop browser bridge, by its label. */
|
||||
const controllerHostByPage = new Map<string, string>()
|
||||
const lastActivityByWorktree = new Map<string, BrowserAgentActivityMark>()
|
||||
/** Activity no chat claimed: older CLIs, remote hosts and terminal agents. */
|
||||
const lastUnclaimedActivityByWorktree = new Map<string, BrowserAgentActivityMark>()
|
||||
const lastActivityByChatSession = new Map<string, BrowserAgentActivityMark>()
|
||||
const lastCursorByPage = new Map<string, BrowserAgentCursorEvent>()
|
||||
const sinksByPage = new Map<string, BrowserAgentCursorSink>()
|
||||
const listeners = new Set<() => void>()
|
||||
@@ -37,7 +39,8 @@ export function setBrowserAgentPageActive(
|
||||
browserPageId: string,
|
||||
active: boolean,
|
||||
worktreeId: string | null,
|
||||
controllerHostLabel?: string
|
||||
controllerHostLabel?: string,
|
||||
agentSessionId?: string
|
||||
): void {
|
||||
if (active) {
|
||||
revision += 1
|
||||
@@ -47,8 +50,11 @@ export function setBrowserAgentPageActive(
|
||||
} else {
|
||||
controllerHostByPage.delete(browserPageId)
|
||||
}
|
||||
if (worktreeId) {
|
||||
lastActivityByWorktree.set(worktreeId, { pageId: browserPageId, revision })
|
||||
const mark = { pageId: browserPageId, revision }
|
||||
if (agentSessionId) {
|
||||
lastActivityByChatSession.set(agentSessionId, mark)
|
||||
} else if (worktreeId) {
|
||||
lastUnclaimedActivityByWorktree.set(worktreeId, mark)
|
||||
}
|
||||
} else {
|
||||
activePageIds.delete(browserPageId)
|
||||
@@ -112,11 +118,15 @@ export function useBrowserAgentControllerHost(
|
||||
return useSyncExternalStore(subscribe, read, read)
|
||||
}
|
||||
|
||||
/** What an agent in this worktree drove most recently, while this window has been open. */
|
||||
/** What this chat's agent drove most recently; until it has claimed any, what an unclaimed agent in its worktree did. */
|
||||
export function useLastBrowserAgentActivity(
|
||||
worktreeId: string | null
|
||||
worktreeId: string | null,
|
||||
chatSessionId: string | null
|
||||
): BrowserAgentActivityMark | null {
|
||||
// A chat that claimed activity names itself on this host, so unclaimed activity is another agent's.
|
||||
const read = (): BrowserAgentActivityMark | null =>
|
||||
worktreeId ? (lastActivityByWorktree.get(worktreeId) ?? null) : null
|
||||
(chatSessionId ? lastActivityByChatSession.get(chatSessionId) : undefined) ??
|
||||
(worktreeId ? lastUnclaimedActivityByWorktree.get(worktreeId) : undefined) ??
|
||||
null
|
||||
return useSyncExternalStore(subscribe, read, read)
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import type { AppState } from '@/store/types'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { findFirstIndexedWorktree } from '@/lib/workspace/ownership/worktree-runtime-owner-index'
|
||||
import type { Worktree } from '../../../../shared/worktree/types'
|
||||
import type { SshConnectionStatus } from '../../../../shared/ssh-types'
|
||||
import { getClientCreationActionPolicy } from '@/lib/client-creation-action-policy'
|
||||
import { getClientCreationActionPolicy } from '@/lib/workspace/creation/surface-policy/client-creation-action-policy'
|
||||
import {
|
||||
canRunNativeChatSplitTarget,
|
||||
resolveActiveNativeChatSplitTarget,
|
||||
runActiveNativeChatSplit
|
||||
} from '@/components/native-chat/pane/routing/native-chat-layout-actions'
|
||||
import type { NativeChatSplitDirection } from '@/components/native-chat/pane/routing/native-chat-pane-shortcut'
|
||||
import { selectWorktreesByRepo } from '@/store/workspaces/catalog/workspace-record-fields'
|
||||
import type { AppState } from '@/store/types'
|
||||
import type { Worktree } from '../../../../shared/worktree/types'
|
||||
import type { SshConnectionStatus } from '../../../../shared/ssh-types'
|
||||
import type { NativeChatSplitDirection } from '@/components/native-chat/pane/routing/native-chat-pane-shortcut'
|
||||
import type { TabSplitDirection } from '@/store/slices/tabs/tabs-slice-contract'
|
||||
|
||||
export type CmdJUnavailableReason =
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import type { PreviewTerminalLinkHandler } from './preview-terminal-links'
|
||||
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
||||
import type { ITheme, Terminal } from '@xterm/xterm'
|
||||
import { useShallow } from 'zustand/react/shallow'
|
||||
import { composeActiveTerminalTheme } from '@/components/terminal-pane/appearance/terminal-appearance'
|
||||
import { useSystemPrefersDark } from '@/hooks/theme/use-system-prefers-dark'
|
||||
@@ -13,29 +11,26 @@ import {
|
||||
previewAdvertisesKittyKeyboard
|
||||
} from './preview-terminal-options'
|
||||
import { syncPreviewTerminalLigatures } from './preview-terminal-ligatures'
|
||||
import type { DashboardCardTerminalInput } from '../../../../shared/dashboard-snapshot'
|
||||
import { terminalPreviewUnavailableMessage } from './terminal-preview-unavailable-message'
|
||||
import { resolveEffectiveTerminalAppearance } from '@/lib/terminal-theme'
|
||||
import { resolveEffectiveTerminalAppearance } from '@/lib/terminal/appearance/terminal-theme'
|
||||
import { cn } from '@/lib/class-names'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import { usePluginFontReady } from '@/store/plugins/appearance/plugin-fonts'
|
||||
import { createPreviewGridClaim } from './preview-grid-claim'
|
||||
import { createPreviewBoxFit } from './preview-terminal-box-fit'
|
||||
import {
|
||||
openStandaloneTerminal,
|
||||
type StandaloneTerminal
|
||||
} from '../standalone-terminal/open-standalone-terminal'
|
||||
import type { TerminalPreviewDataPayload } from '../../../../shared/terminal/replay/terminal-preview'
|
||||
import { openStandaloneTerminal } from '../standalone-terminal/open-standalone-terminal'
|
||||
import type { StandaloneTerminal } from '../standalone-terminal/open-standalone-terminal'
|
||||
import { terminalPreviewApiFor } from './terminal-preview-api'
|
||||
|
||||
import { LinkActionPopover } from '@/components/link-actions/LinkActionPopover'
|
||||
import {
|
||||
closeLinkActionRequest,
|
||||
type LinkActionRequest
|
||||
} from '@/components/link-actions/link-action-request'
|
||||
import { closeLinkActionRequest } from '@/components/link-actions/link-action-request'
|
||||
import type { LinkActionRequest } from '@/components/link-actions/link-action-request'
|
||||
import { installDashboardPreviewLinkInteraction } from './dashboard-preview-link-interaction'
|
||||
import type { DashboardPreviewLinkSource } from './dashboard-preview-http-actions'
|
||||
import { useTranslate } from '@/i18n/use-translate'
|
||||
import type { PreviewTerminalLinkHandler } from './preview-terminal-links'
|
||||
import type { ITheme, Terminal } from '@xterm/xterm'
|
||||
import type { DashboardCardTerminalInput } from '../../../../shared/dashboard-snapshot'
|
||||
import type { TerminalPreviewDataPayload } from '../../../../shared/terminal/replay/terminal-preview'
|
||||
import type { DashboardPreviewLinkSource } from './dashboard-preview-http-actions'
|
||||
|
||||
const PREVIEW_SCROLLBACK_ROWS = 24
|
||||
// Preview snapshots bound history; pane scrollback would only cost memory.
|
||||
|
||||
@@ -1,29 +1,31 @@
|
||||
import { toast } from 'sonner'
|
||||
import { intentPresentation } from '@/lib/browser/workspace/workspace-browser-tab-presentation'
|
||||
import type { DashboardCard } from '../../../../shared/dashboard-snapshot'
|
||||
import { parseAppSshPtyId } from '../../../../shared/ssh-pty-id'
|
||||
import { parseRoutableExecutionHostId } from '../../../../shared/execution-host'
|
||||
import {
|
||||
parseRemoteRuntimePtyId,
|
||||
isRemoteRuntimePtyId
|
||||
} from '../../../../shared/remote-runtime/remote-runtime-pty-id'
|
||||
import { useAppStore } from '@/store'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import { resolveOwner } from '@/lib/workspace/ownership/resolve-owner'
|
||||
import { resolveWorktreeOperationRoute } from '@/lib/workspace/ownership/worktree-operation-route'
|
||||
import { createBrowserLinkHostMatcher } from '@/lib/browser/navigation/browser-link-owner'
|
||||
import { getWorkspaceClientCreationActionPolicy } from '@/lib/client-creation-action-policy'
|
||||
import { getWorkspaceClientCreationActionPolicy } from '@/lib/workspace/creation/surface-policy/client-creation-action-policy'
|
||||
import {
|
||||
canOpenWorkspaceBrowserTabOnRuntime,
|
||||
canOpenWorkspaceBrowserTabOnSsh
|
||||
} from '@/lib/browser/workspace/workspace-browser-route-eligibility'
|
||||
import type { HttpLinkSourceOwner } from '@/lib/browser/navigation/http-link-routing'
|
||||
import {
|
||||
buildHttpLinkActions,
|
||||
httpLinkActionDestinationsFor,
|
||||
openRoutedHttpLink,
|
||||
type HttpLinkDestination,
|
||||
type HttpLinkActionDestinations
|
||||
openRoutedHttpLink
|
||||
} from '@/lib/browser/navigation/http-link-destinations'
|
||||
import type {
|
||||
HttpLinkDestination,
|
||||
HttpLinkActionDestinations
|
||||
} from '@/lib/browser/navigation/http-link-destinations'
|
||||
import type { DashboardCard } from '../../../../shared/dashboard-snapshot'
|
||||
import type { HttpLinkSourceOwner } from '@/lib/browser/navigation/http-link-routing'
|
||||
|
||||
export type DashboardPreviewLinkSource = Pick<
|
||||
DashboardCard,
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import { getAgentRowConversationName } from '../../../../shared/agent-status/presentation/agent-row-conversation-name'
|
||||
import { DASHBOARD_MAX_LABEL_LENGTH } from '../../../../shared/dashboard-snapshot'
|
||||
import { parsePaneKey } from '../../../../shared/workspace-layout/stable-pane-id'
|
||||
import type { TerminalLayoutSnapshot } from '../../../../shared/workspace-layout/terminal-tab-types'
|
||||
import { resolveAgentRowPaneLiveTitle } from './agent-row-pane-live-title'
|
||||
import { structuredChatTabById } from '@/lib/agent-session/tab-identity/structured-chat-tab-index'
|
||||
import { projectedStructuredChatTabName } from '@/runtime/native-chat/naming/structured-chat-tab-name'
|
||||
import type { StructuredChatTabNames } from '@/runtime/native-chat/naming/structured-chat-tab-name'
|
||||
import type { TerminalLayoutSnapshot } from '../../../../shared/workspace-layout/terminal-tab-types'
|
||||
import type { DashboardAgentRow } from './useDashboardData'
|
||||
import type { AppState } from '@/store/types'
|
||||
import { structuredChatTabById } from '@/lib/structured-chat-tab-index'
|
||||
import {
|
||||
projectedStructuredChatTabName,
|
||||
type StructuredChatTabNames
|
||||
} from '@/runtime/native-chat/naming/structured-chat-tab-name'
|
||||
|
||||
export function rowTask(row: DashboardAgentRow): string {
|
||||
return (row.entry.orchestration?.taskTitle ?? '').trim() || (row.entry.prompt ?? '').trim()
|
||||
|
||||
@@ -3,7 +3,7 @@ import { getAgentRowConversationName } from '../../../../shared/agent-status/pre
|
||||
import { parsePaneKey } from '../../../../shared/workspace-layout/stable-pane-id'
|
||||
import { structuredChatDisplayName } from '../../../../shared/structured-chat-row-name'
|
||||
import { resolveAgentRowPaneLiveTitle } from './agent-row-pane-live-title'
|
||||
import { structuredChatTabById } from '@/lib/structured-chat-tab-index'
|
||||
import { structuredChatTabById } from '@/lib/agent-session/tab-identity/structured-chat-tab-index'
|
||||
import { useStructuredChatTabConversationName } from '@/runtime/native-chat/naming/structured-conversation-name'
|
||||
import type { AppState } from '@/store/types'
|
||||
import type { DashboardAgentRow } from './useDashboardData'
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { joinPath } from '@/lib/path'
|
||||
import type { OpenFile } from '@/store/slices/editor/types/open-file'
|
||||
import { areLocalWindowsWslPathAliases } from '../../../../../shared/cross-platform-path'
|
||||
import { externalChangePathKeyFor } from '@/store/slices/editor/buffers/editor-buffer-identity'
|
||||
import { isLocalWindowsDesktopClient } from '@/app-shell/chrome/desktop-window-chrome'
|
||||
@@ -8,8 +7,9 @@ import {
|
||||
MAX_EDITOR_AUTO_SAVE_DELAY_MS,
|
||||
MIN_EDITOR_AUTO_SAVE_DELAY_MS
|
||||
} from '../../../../../shared/constants'
|
||||
import { clampNumber } from '@/lib/terminal-theme'
|
||||
import { clampNumber } from '@/lib/terminal/appearance/terminal-theme'
|
||||
import { isAutosavePausedForNonUtf8File } from './editor-non-utf8-autosave-pause'
|
||||
import type { OpenFile } from '@/store/slices/editor/types/open-file'
|
||||
|
||||
export const ORCA_EDITOR_QUIESCE_FILE_SAVES_EVENT = 'orca:editor-quiesce-file-saves'
|
||||
export const ORCA_EDITOR_EXTERNAL_FILE_CHANGE_EVENT = 'orca:editor-external-file-change'
|
||||
|
||||
@@ -1,35 +1,33 @@
|
||||
import type { EditorFileDropDestination } from './editor-file-drop-destination'
|
||||
import { toast } from 'sonner'
|
||||
import { detectLanguage } from '../../../../shared/editor-language/editor-language-detect'
|
||||
import {
|
||||
isPathInsideWorktree,
|
||||
toWorktreeRelativePath
|
||||
} from '../../../../shared/terminal/links/terminal-links'
|
||||
import { useAppStore } from '@/store'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import { getConnectionId } from '@/lib/workspace/ownership/connection-context'
|
||||
import { basename, joinPath } from '@/lib/path'
|
||||
import type { WorktreeRuntimeOwnerState } from '@/lib/workspace/ownership/worktree-runtime-owner-state'
|
||||
import { importExternalPathsToRuntime } from '@/runtime/files/imports/runtime-file-import-client'
|
||||
import type { RuntimeFileOperationArgs } from '@/runtime/files/runtime-file-client-types'
|
||||
import { runtimeTargetEnvironmentId } from '@/runtime/rpc/targets/runtime-client-target'
|
||||
import type { RuntimeClientTarget } from '../../../../shared/runtime-client-target'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { describeSharedDropFailureReason } from '@/lib/files/drop/drop-skip-reason-copy'
|
||||
import { captureWorktreeSshMutationExpectation } from '@/lib/ssh-mutation-expectation'
|
||||
import { captureWorktreeSshMutationExpectation } from '@/runtime/hosts/ssh/ssh-mutation-expectation'
|
||||
import { statUserOpenedPath } from '@/lib/files/access/user-opened-local-path'
|
||||
import { FLOATING_TERMINAL_WORKTREE_ID } from '../../../../shared/constants'
|
||||
import { DROP_STAGING_RELATIVE_DIR } from '../../../../shared/drop-staging-ignore'
|
||||
import { openDocumentInFloatingWorkspace } from '@/components/floating-terminal/open-document-in-floating-workspace'
|
||||
import { requireRuntimeTargetForFileOwner } from '@/lib/files/access/file-owner-runtime-target'
|
||||
import { parseExecutionHostId } from '../../../../shared/execution-host'
|
||||
import {
|
||||
isResolvedWorkspaceFileDragExecutionHost,
|
||||
type WorkspaceFileDragSource
|
||||
} from '@/lib/files/drop/workspace-file-drag'
|
||||
import { isResolvedWorkspaceFileDragExecutionHost } from '@/lib/files/drop/workspace-file-drag'
|
||||
import type { WorkspaceFileDragSource } from '@/lib/files/drop/workspace-file-drag'
|
||||
import {
|
||||
captureFileExplorerOperationGuard,
|
||||
getFileExplorerOperationOwner
|
||||
} from '../right-sidebar/file-explorer/navigation/file-explorer-operation-owner'
|
||||
import type { EditorFileDropDestination } from './editor-file-drop-destination'
|
||||
import type { WorktreeRuntimeOwnerState } from '@/lib/workspace/ownership/worktree-runtime-owner-state'
|
||||
import type { RuntimeFileOperationArgs } from '@/runtime/files/runtime-file-client-types'
|
||||
import type { RuntimeClientTarget } from '../../../../shared/runtime-client-target'
|
||||
|
||||
export function shouldUploadRemoteEditorFileDrop(
|
||||
target: RuntimeClientTarget,
|
||||
|
||||
@@ -268,15 +268,18 @@ export class GitGraphHistoryController {
|
||||
if (!current()) {
|
||||
return undefined
|
||||
}
|
||||
const result = error !== undefined ? previous : (accumulated ?? previous)
|
||||
const selection = this.view.getState().selectedId
|
||||
const selectedId =
|
||||
result?.items.find((item) => item.id === selection)?.id ?? result?.items[0]?.id
|
||||
const selectionGone = selection !== undefined && selection !== selectedId
|
||||
// A page that added nothing keeps the result identity, so viewport paging can't repeat it.
|
||||
const stalled =
|
||||
append && !recovered && accumulated?.hasMore && items.length === previous?.items.length
|
||||
const result = error !== undefined || stalled ? previous : (accumulated ?? previous)
|
||||
const selected = this.view.getState().selectedId
|
||||
const selectedId = result?.items.find(({ id }) => id === selected)?.id ?? result?.items[0]?.id
|
||||
const selectionGone = selected !== undefined && selected !== selectedId
|
||||
if (selectionGone) {
|
||||
this.actions.cancel()
|
||||
this.scrollOffset = 0
|
||||
}
|
||||
this.pending = undefined
|
||||
this.view.setState({
|
||||
result,
|
||||
error,
|
||||
|
||||
@@ -13,7 +13,11 @@ import * as commitSupport from '@/runtime/source-control/git/git-commit-actions-
|
||||
import { useGitGraphHistory } from './use-git-graph-history'
|
||||
import type { GitHistoryResult } from '../../../../../shared/git/history/git-history-types'
|
||||
|
||||
const { getHistory, getRefs } = vi.hoisted(() => ({ getHistory: vi.fn(), getRefs: vi.fn() }))
|
||||
const { getHistory, getRefs, viewport } = vi.hoisted(() => ({
|
||||
getHistory: vi.fn(),
|
||||
getRefs: vi.fn(),
|
||||
viewport: { rows: 20, rendered: Infinity }
|
||||
}))
|
||||
vi.mock('@/runtime/source-control/git/runtime-git-status-client', async (original) => ({
|
||||
...(await original<object>()),
|
||||
getRuntimeGitHistory: getHistory,
|
||||
@@ -27,7 +31,15 @@ vi.mock('@tanstack/react-virtual', () => ({
|
||||
useVirtualizer: (options: { count: number; getScrollElement: () => HTMLElement | null }) => ({
|
||||
getTotalSize: () => options.count * 28,
|
||||
getVirtualItems: () =>
|
||||
Array.from({ length: options.count }, (_, index) => ({ index, start: index * 28 })),
|
||||
Array.from({ length: Math.min(options.count, viewport.rendered) }, (_, index) => ({
|
||||
index,
|
||||
start: index * 28
|
||||
})),
|
||||
get range() {
|
||||
return options.count
|
||||
? { startIndex: 0, endIndex: Math.min(options.count, viewport.rows) - 1 }
|
||||
: null
|
||||
},
|
||||
measureElement: () => {},
|
||||
scrollToIndex: (index: number) => {
|
||||
const element = options.getScrollElement()
|
||||
@@ -53,6 +65,8 @@ beforeEach(() => {
|
||||
afterEach(async () => {
|
||||
await act(async () => root.unmount())
|
||||
root = createRoot(container)
|
||||
viewport.rows = 20
|
||||
viewport.rendered = Infinity
|
||||
disposeGitGraphHistory(`${workspaceId}::git-graph`)
|
||||
useAppStore.setState(initialState, true)
|
||||
vi.restoreAllMocks()
|
||||
@@ -520,3 +534,115 @@ it('keeps the confirm strip across tab switches, discarding it on navigation, fi
|
||||
await act(async () => root.render(render()))
|
||||
expect(container.textContent).not.toContain('Revert a?')
|
||||
})
|
||||
const longHistory = Array.from({ length: 200 }, (_, index) => ({
|
||||
id: `commit-${index}`,
|
||||
subject: `Commit ${index}`,
|
||||
message: `Commit ${index}`,
|
||||
parentIds: []
|
||||
}))
|
||||
const longPage = (skip: number): GitHistoryResult => ({
|
||||
...result,
|
||||
refs: 'all',
|
||||
historyToken: 'long',
|
||||
items: longHistory.slice(skip, skip + 50),
|
||||
hasMore: skip + 50 < longHistory.length
|
||||
})
|
||||
const renderTab = () =>
|
||||
act(async () =>
|
||||
root.render(
|
||||
<TooltipProvider>
|
||||
<GitGraphTab worktreeId={workspaceId} />
|
||||
</TooltipProvider>
|
||||
)
|
||||
)
|
||||
const loadedCount = () => gitGraphHistoryForTab(workspaceId).view.getState().result?.items.length
|
||||
|
||||
it('pages a pane taller than the loaded commits until they overflow it, and again when it grows', async () => {
|
||||
viewport.rows = 120
|
||||
getHistory.mockReset().mockImplementation(async (_owner, options) => longPage(options.skip))
|
||||
await renderTab()
|
||||
expect(loadedCount()).toBe(150)
|
||||
viewport.rows = 400
|
||||
await renderTab()
|
||||
expect(loadedCount()).toBe(200)
|
||||
expect(container.textContent).not.toContain('Load more')
|
||||
})
|
||||
|
||||
it('leaves a failed page to Load more, even after switching tabs away and back', async () => {
|
||||
viewport.rows = Infinity
|
||||
getHistory
|
||||
.mockReset()
|
||||
.mockResolvedValueOnce(longPage(0))
|
||||
.mockRejectedValueOnce(new Error('network down'))
|
||||
.mockImplementation(async (_owner, options) => longPage(options.skip))
|
||||
await renderTab()
|
||||
await act(async () => root.render(<div>Another tab</div>))
|
||||
await renderTab()
|
||||
expect(loadedCount()).toBe(50)
|
||||
expect(container.textContent).toContain('network down')
|
||||
await act(async () => {
|
||||
Array.from(container.querySelectorAll('button'))
|
||||
.find((button) => button.textContent === 'Load more')!
|
||||
.click()
|
||||
})
|
||||
expect(loadedCount()).toBe(200)
|
||||
})
|
||||
|
||||
it('stops paging on a page that adds no commits, and ends on an empty last page', async () => {
|
||||
viewport.rows = Infinity
|
||||
getHistory.mockReset().mockResolvedValue(longPage(0))
|
||||
await renderTab()
|
||||
await renderTab()
|
||||
expect(loadedCount()).toBe(50)
|
||||
expect(getHistory).toHaveBeenCalledTimes(2)
|
||||
getHistory.mockResolvedValue({ ...longPage(0), items: [], hasMore: false })
|
||||
await act(async () => {
|
||||
await gitGraphHistoryForTab(workspaceId).loadMore()
|
||||
})
|
||||
expect(container.textContent).not.toContain('Load more')
|
||||
})
|
||||
|
||||
it.each([50_000, 500_000])(
|
||||
'releases %i commits of replaced history while the pane stays mounted',
|
||||
async (count) => {
|
||||
viewport.rows = Infinity
|
||||
viewport.rendered = 40
|
||||
getHistory
|
||||
.mockReset()
|
||||
.mockImplementationOnce(async () => ({
|
||||
...result,
|
||||
refs: 'all',
|
||||
hasMore: true,
|
||||
items: Array.from({ length: count }, (_, index) => ({
|
||||
id: `old-${index}`,
|
||||
subject: `Old ${index}`,
|
||||
message: `Old ${index}`,
|
||||
parentIds: []
|
||||
}))
|
||||
}))
|
||||
.mockRejectedValueOnce(new Error('network down'))
|
||||
.mockResolvedValue({ ...result, refs: 'head' })
|
||||
await renderTab()
|
||||
const replaced = (() => {
|
||||
const loaded = gitGraphHistoryForTab(workspaceId).view.getState().result!
|
||||
expect(loaded.items).toHaveLength(count)
|
||||
return new WeakRef(loaded)
|
||||
})()
|
||||
await act(async () =>
|
||||
useAppStore.setState({ gitGraphFiltersByWorktree: { [workspaceId]: 'head' } })
|
||||
)
|
||||
await act(async () => {
|
||||
await gitGraphHistoryForTab(workspaceId).settledResult()
|
||||
})
|
||||
expect(loadedCount()).toBe(1)
|
||||
getHistory.mockReset()
|
||||
if (typeof globalThis.gc !== 'function') {
|
||||
throw new Error('Run with the repository Vitest --expose-gc config')
|
||||
}
|
||||
for (let round = 0; round < 3; round++) {
|
||||
await new Promise<void>((resolve) => setImmediate(resolve))
|
||||
globalThis.gc()
|
||||
}
|
||||
expect(replaced.deref()).toBeUndefined()
|
||||
}
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
GitGraphCommitActionControls,
|
||||
GitGraphCommitConfirmStrip
|
||||
} from './git-graph-commit-action-controls'
|
||||
import { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useSidebarResize } from '@/hooks/useSidebarResize'
|
||||
import { useVirtualizer } from '@tanstack/react-virtual'
|
||||
import { RefreshCw } from 'lucide-react'
|
||||
@@ -20,18 +20,21 @@ import {
|
||||
} from '../../../../../shared/git/history/git-history-graph'
|
||||
import { useGitGraphHistory, gitGraphFilterSupported } from './use-git-graph-history'
|
||||
import { GitGraphFilter } from './git-graph-filter'
|
||||
import { loadMoreInView } from './git-graph-viewport-paging'
|
||||
import { GitGraphDetails } from './git-graph-details'
|
||||
import { GitGraphRefs, useGitGraphWorkspaces } from './git-graph-ref-menu'
|
||||
import { cn } from '@/lib/class-names'
|
||||
import { useIntlLocale, useTranslate } from '@/i18n/use-translate'
|
||||
|
||||
const sameGroup = () => undefined
|
||||
// About 200px of rows, so scrolling fetches before the end shows.
|
||||
const PAGE_AHEAD_ROWS = 8
|
||||
|
||||
export function GitGraphTab({ worktreeId }: { worktreeId: string }) {
|
||||
const t = useTranslate()
|
||||
const intlLocale = useIntlLocale()
|
||||
const history = useGitGraphHistory(worktreeId)
|
||||
const { result, scope, selectedId, revealId, controller } = history
|
||||
const { result, scope, selectedId, revealId, controller, loading } = history
|
||||
const commitActionSupport = useGitCommitActionsSupport(
|
||||
scope?.target ?? null,
|
||||
scope?.route.executionHostId ?? undefined
|
||||
@@ -88,6 +91,16 @@ export function GitGraphTab({ worktreeId }: { worktreeId: string }) {
|
||||
overscan: 12,
|
||||
getItemKey: (index) => rows[index]!.historyItem.id
|
||||
})
|
||||
const virtualItems = virtualizer.getVirtualItems()
|
||||
// Null while the pane has no height; read after getVirtualItems() recomputes it.
|
||||
const lastVisibleIndex = virtualizer.range?.endIndex ?? -1
|
||||
const endInView = lastVisibleIndex >= 0 && lastVisibleIndex >= rows.length - 1 - PAGE_AHEAD_ROWS
|
||||
useEffect(() => {
|
||||
// Viewport demand, not scroll events: page whenever the end of loaded rows is in view.
|
||||
if (endInView) {
|
||||
loadMoreInView(controller, result)
|
||||
}
|
||||
}, [endInView, result, loading, controller])
|
||||
const selected = result?.items.find((item) => item.id === selectedId)
|
||||
useLayoutEffect(() => {
|
||||
if (scroll.current) {
|
||||
@@ -189,20 +202,13 @@ export function GitGraphTab({ worktreeId }: { worktreeId: string }) {
|
||||
if (element) {
|
||||
controller.scrollOffset = element.scrollTop
|
||||
}
|
||||
if (
|
||||
element &&
|
||||
element.scrollHeight - element.scrollTop - element.clientHeight < 200 &&
|
||||
!history.loading
|
||||
) {
|
||||
void history.loadMore()
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="relative min-w-max"
|
||||
style={{ height: virtualizer.getTotalSize(), minWidth: draftGraphWidth + 604 }}
|
||||
>
|
||||
{virtualizer.getVirtualItems().map((virtualRow) => {
|
||||
{virtualItems.map((virtualRow) => {
|
||||
const viewModel = rows[virtualRow.index]!
|
||||
const item = viewModel.historyItem
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { GitGraphHistoryController } from './git-graph-history-controller'
|
||||
import type { GitHistoryResult } from '../../../../../shared/git/history/git-history-types'
|
||||
|
||||
// Keyed by result so it outlives tab remounts without keeping replaced history alive.
|
||||
const pagedInView = new WeakSet<GitHistoryResult>()
|
||||
|
||||
/** Asks for the next page once per result; a failed or no-progress page keeps its result, so only Load more or Refresh retries it. */
|
||||
export function loadMoreInView(
|
||||
controller: GitGraphHistoryController,
|
||||
rendered: GitHistoryResult | undefined
|
||||
): void {
|
||||
const { result, loading } = controller.view.getState()
|
||||
// Only page the result whose rows were measured in view; a newer one gets its own check.
|
||||
if (result && result === rendered && result.hasMore && !loading && !pagedInView.has(result)) {
|
||||
pagedInView.add(result)
|
||||
void controller.loadMore()
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ import {
|
||||
isLocalPathOpenBlocked,
|
||||
showLocalPathOpenBlockedToast
|
||||
} from '@/lib/files/os-open/local-path-open-guard'
|
||||
import { getLinkSourceLocalOpenOwner } from '@/lib/link-source-local-open-owner'
|
||||
import { getLinkSourceLocalOpenOwner } from '@/lib/links/ownership/link-source-local-open-owner'
|
||||
import { openHttpLink } from '@/lib/browser/navigation/http-link-routing'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { requireRuntimeTargetForFileOwner } from '@/lib/files/access/file-owner-runtime-target'
|
||||
|
||||
+2
-2
@@ -5,19 +5,19 @@ import {
|
||||
showLocalPathOpenBlockedToast
|
||||
} from '@/lib/files/os-open/local-path-open-guard'
|
||||
import { openHttpLink } from '@/lib/browser/navigation/http-link-routing'
|
||||
import { getLinkSourceLocalOpenOwner } from '@/lib/link-source-local-open-owner'
|
||||
import { getLinkSourceLocalOpenOwner } from '@/lib/links/ownership/link-source-local-open-owner'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import {
|
||||
absolutePathToFileUri,
|
||||
resolveMarkdownLinkTarget
|
||||
} from '../../markdown/link-routing/markdown-internal-links'
|
||||
import { openMarkdownFileLinkWithSystemDefault } from '../../markdown/link-routing/markdown-file-link-system-open'
|
||||
import type { MarkdownPreviewLinkContext } from './markdown-preview-link-actions'
|
||||
import {
|
||||
getMarkdownPreviewLinkTarget,
|
||||
isMarkdownPreviewSystemBrowserModifier,
|
||||
resolveMarkdownPreviewHttpOpenOptions
|
||||
} from '../../markdown/link-routing/markdown-preview-links'
|
||||
import type { MarkdownPreviewLinkContext } from './markdown-preview-link-actions'
|
||||
|
||||
export function handleMarkdownPreviewSystemLinkClick({
|
||||
event,
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
import type { ITheme } from '@xterm/xterm'
|
||||
import { cn } from '@/lib/class-names'
|
||||
import '@/lib/terminal-theme'
|
||||
import { getTheme } from '@/lib/terminal-themes-data'
|
||||
import '@/lib/terminal/appearance/terminal-theme'
|
||||
import { getTheme } from '@/lib/terminal/appearance/terminal-themes-data'
|
||||
import {
|
||||
DEFAULT_TERMINAL_THEME_DARK,
|
||||
DEFAULT_TERMINAL_THEME_LIGHT
|
||||
} from '../../../../../../shared/terminal-themes/terminal-theme-selection'
|
||||
import { IpynbMarkdownCell } from '../cells/IpynbCellEditor'
|
||||
import { IpynbHtmlOutput } from './IpynbHtmlOutput'
|
||||
import { parseAnsiSegments, type AnsiColor } from './ipynb-ansi'
|
||||
import type { IpynbCell, IpynbOutput, IpynbOutputItem } from '../document/ipynb-parse'
|
||||
import { parseAnsiSegments } from './ipynb-ansi'
|
||||
import type { AnsiColor } from './ipynb-ansi'
|
||||
import { useDocumentDarkTheme } from '@/hooks/use-document-dark-theme'
|
||||
import type { ITheme } from '@xterm/xterm'
|
||||
import type { IpynbCell, IpynbOutput, IpynbOutputItem } from '../document/ipynb-parse'
|
||||
|
||||
const ANSI_PALETTE_KEYS = [
|
||||
'black',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
||||
import { useAppStore } from '@/store'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import { createStoreCascadesMockApi } from '@/store/testing/app-store-cascade-api.test-fixture'
|
||||
import {
|
||||
EDITOR_OWNER,
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
seedBrowserLinkTestStore,
|
||||
WORKSPACE
|
||||
} from '@/lib/browser/navigation/browser-link-open.test-fixture'
|
||||
import { beginLinkOpenRequest } from '@/lib/link-open-request'
|
||||
import { beginLinkOpenRequest } from '@/lib/links/link-open-request'
|
||||
import { registerEditorFrameFlush } from './save/flush/editor-pending-flush'
|
||||
import { openEditorHtmlPreview } from './open-editor-html-preview'
|
||||
|
||||
@@ -214,25 +214,6 @@ it('refuses a local preview when the file gains remote host evidence during its
|
||||
expect(useAppStore.getState().browserTabsByWorktree[WORKSPACE] ?? []).toEqual([])
|
||||
})
|
||||
|
||||
it.each(['refused', 'rejected'] as const)(
|
||||
'keeps the editor selected when its guest flush is %s',
|
||||
async (failure) => {
|
||||
const unregister = registerEditorFrameFlush('report', () =>
|
||||
failure === 'refused' ? Promise.resolve(false) : Promise.reject(new Error('flush failed'))
|
||||
)
|
||||
try {
|
||||
await openEditorHtmlPreview('report', 'source')
|
||||
const state = useAppStore.getState()
|
||||
expect(state.browserTabsByWorktree[WORKSPACE] ?? []).toEqual([])
|
||||
expect(
|
||||
state.groupsByWorktree[WORKSPACE]?.find((group) => group.id === 'a')?.activeTabId
|
||||
).toBe('source')
|
||||
} finally {
|
||||
unregister()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
it('cancels preview when its editor tab closes but the file stays open in another tab', async () => {
|
||||
useAppStore.setState((state) => ({
|
||||
unifiedTabsByWorktree: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { toast } from 'sonner'
|
||||
import { useAppStore } from '@/store'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import {
|
||||
editorViewPlacement,
|
||||
editorViewTab
|
||||
@@ -8,8 +8,8 @@ import { openFileInBrowserTab } from '@/lib/browser/documents/file-preview'
|
||||
import { resolveFileBrowserLinkExecutionHostId } from '@/lib/browser/documents/file-preview-link-open'
|
||||
import { captureBrowserLinkReveal } from '@/lib/browser/navigation/browser-link-reveal'
|
||||
import { createBrowserLinkHostMatcher } from '@/lib/browser/navigation/browser-link-owner'
|
||||
import { beginLinkOpenRequest, subscribeLinkOpenRequests } from '@/lib/link-open-request'
|
||||
import { captureLinkOpenIntent } from '@/lib/link-open-intent'
|
||||
import { beginLinkOpenRequest, subscribeLinkOpenRequests } from '@/lib/links/link-open-request'
|
||||
import { captureLinkOpenIntent } from '@/lib/links/placement/link-open-intent'
|
||||
import { flushEditorFrames } from './save/flush/editor-pending-flush'
|
||||
|
||||
export async function openEditorHtmlPreview(
|
||||
|
||||
+3
-3
@@ -1,4 +1,3 @@
|
||||
import type { Editor } from '@tiptap/react'
|
||||
import { toast } from 'sonner'
|
||||
import { dirname, basename } from '@/lib/path'
|
||||
import { getConnectionId } from '@/lib/workspace/ownership/connection-context'
|
||||
@@ -10,18 +9,19 @@ import {
|
||||
} from '@/lib/editor/file-operations/editor-file-operation-owner'
|
||||
import { editorTabDocumentFolderAccess } from '@/lib/files/access/local-file-access'
|
||||
import { requireRuntimeTargetForFileOwner } from '@/lib/files/access/file-owner-runtime-target'
|
||||
import { captureDirectSshMutationExpectation } from '@/lib/ssh-mutation-expectation'
|
||||
import { captureDirectSshMutationExpectation } from '@/runtime/hosts/ssh/ssh-mutation-expectation'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { parseWorkspaceKey } from '../../../../../../shared/workspace-scope'
|
||||
import { extractIpcErrorMessage } from './rich-markdown-ipc-error-message'
|
||||
import { buildRichMarkdownImageInsertContent } from './rich-markdown-image-insert-content'
|
||||
import { showRichMarkdownImageInsertionCanceled } from './rich-markdown-image-insertion-feedback'
|
||||
import type { RichMarkdownImageInsertionRange } from './rich-markdown-image-insertion-target'
|
||||
import { richMarkdownClipboardInsertionOrderKey } from '../clipboard/rich-markdown-clipboard-insertion-order'
|
||||
import {
|
||||
selectFolderWorkspaces,
|
||||
selectWorktreesByRepo
|
||||
} from '@/store/workspaces/catalog/workspace-record-fields'
|
||||
import type { Editor } from '@tiptap/react'
|
||||
import type { RichMarkdownImageInsertionRange } from './rich-markdown-image-insertion-target'
|
||||
import type { RuntimeFileOperationArgs } from '@/runtime/files/runtime-file-client-types'
|
||||
import type { LocalFileAccess } from '../../../../../../shared/file-access/local-file-access'
|
||||
|
||||
|
||||
+8
-10
@@ -1,8 +1,4 @@
|
||||
import type { MutableRefObject } from 'react'
|
||||
import type { Editor } from '@tiptap/react'
|
||||
import type { EditorView } from '@tiptap/pm/view'
|
||||
import { toast } from 'sonner'
|
||||
import type { HttpLinkSourceOwner } from '@/lib/browser/navigation/http-link-routing'
|
||||
import {
|
||||
httpLinkActionDestinationsFor,
|
||||
openRoutedHttpLink
|
||||
@@ -17,7 +13,7 @@ import {
|
||||
isLocalPathOpenBlocked,
|
||||
showLocalPathOpenBlockedToast
|
||||
} from '@/lib/files/os-open/local-path-open-guard'
|
||||
import { getLinkSourceLocalOpenOwner } from '@/lib/link-source-local-open-owner'
|
||||
import { getLinkSourceLocalOpenOwner } from '@/lib/links/ownership/link-source-local-open-owner'
|
||||
import {
|
||||
absolutePathToFileUri as toFileUrlForOsEscape,
|
||||
resolveMarkdownLinkTarget
|
||||
@@ -25,13 +21,15 @@ import {
|
||||
import { openMarkdownFileLinkWithSystemDefault } from '../../markdown/link-routing/markdown-file-link-system-open'
|
||||
import { scrollToAnchorInEditor } from '../../markdown/navigation/markdown-anchor-scroll'
|
||||
import { getRichMarkdownCommentAtPos } from '../review/rich-markdown-review-annotations'
|
||||
import type { DiffComment } from '../../../../../../shared/diff-comment-types'
|
||||
import { toRuntimeExecutionHostId } from '../../../../../../shared/execution-host'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import {
|
||||
classifyHtmlSuperscriptLinkAction,
|
||||
type RichMarkdownHtmlSuperscriptLinkContext
|
||||
} from '../citations/rich-markdown-html-superscript-link-context'
|
||||
import { classifyHtmlSuperscriptLinkAction } from '../citations/rich-markdown-html-superscript-link-context'
|
||||
import type { RichMarkdownHtmlSuperscriptLinkContext } from '../citations/rich-markdown-html-superscript-link-context'
|
||||
import type { MutableRefObject } from 'react'
|
||||
import type { Editor } from '@tiptap/react'
|
||||
import type { EditorView } from '@tiptap/pm/view'
|
||||
import type { HttpLinkSourceOwner } from '@/lib/browser/navigation/http-link-routing'
|
||||
import type { DiffComment } from '../../../../../../shared/diff-comment-types'
|
||||
|
||||
export type ActivateMarkdownLink = (
|
||||
href: string,
|
||||
|
||||
@@ -5,7 +5,6 @@ import { useOnboardingSkillRuntime } from '@/hooks/skills/runtime/use-onboarding
|
||||
import { FeatureSetupInlineTerminal } from '../onboarding/FeatureSetupInlineTerminal'
|
||||
import { buildAgentFeatureSkillInstallCommand } from '@/lib/skills/installation/agent-feature-install-commands'
|
||||
import { buildSkillCommandForRuntime } from '../../lib/skills/runtime/skill-runtime-command'
|
||||
import type { OnboardingFeatureSetupRuntimeContext } from '../onboarding/onboarding-feature-setup-runtime'
|
||||
import { useCallback, useState } from 'react'
|
||||
import { ArrowUpRight, Download, Loader2 } from 'lucide-react'
|
||||
import { toast } from 'sonner'
|
||||
@@ -22,14 +21,15 @@ import {
|
||||
import { BundledSkillInstallStatus } from '../skills/setup/BundledSkillInstallStatus'
|
||||
import {
|
||||
onboardingFeatureSetupRunTelemetry,
|
||||
runOnboardingFeatureSetup,
|
||||
type OnboardingFeatureSetupSelection
|
||||
runOnboardingFeatureSetup
|
||||
} from '../onboarding/onboarding-feature-setup'
|
||||
import type { OnboardingFeatureSetupSelection } from '../onboarding/onboarding-feature-setup'
|
||||
import {
|
||||
promptForSetupGuideProject,
|
||||
useSetupTargetWorktree
|
||||
} from './FeatureWallSetupWorkflowActions'
|
||||
import { getClientCreationActionPolicy } from '@/lib/client-creation-action-policy'
|
||||
import { getClientCreationActionPolicy } from '@/lib/workspace/creation/surface-policy/client-creation-action-policy'
|
||||
import type { OnboardingFeatureSetupRuntimeContext } from '../onboarding/onboarding-feature-setup-runtime'
|
||||
|
||||
export function BrowserAction(props: { done: boolean }): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
|
||||
+4
-3
@@ -1,9 +1,10 @@
|
||||
import { useEffect } from 'react'
|
||||
import type { FeatureWallWorkflow } from '../../../../shared/feature-wall-workflows'
|
||||
import { useAppStore } from '@/store'
|
||||
import { getLocalPreflightContext, localPreflightContextKey } from '@/lib/local-preflight-context'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import { getLocalPreflightContext } from '@/runtime/hosts/preflight/local-preflight-context'
|
||||
import { getProviderRuntimeContextKey } from '@/runtime/hosts/observations/provider-runtime-context'
|
||||
import { deriveIntegrationConnectionStatus } from './use-integration-connection-status'
|
||||
import type { FeatureWallWorkflow } from '../../../../shared/feature-wall-workflows'
|
||||
import { localPreflightContextKey } from '../../runtime/hosts/preflight/local-preflight-context-key'
|
||||
|
||||
export type FeatureWallTaskSourcePresentation = {
|
||||
workflow: FeatureWallWorkflow
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useAppStore } from '@/store'
|
||||
import { getLocalPreflightContext, localPreflightContextKey } from '@/lib/local-preflight-context'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import { getLocalPreflightContext } from '@/runtime/hosts/preflight/local-preflight-context'
|
||||
import { getProviderRuntimeContextKey } from '@/runtime/hosts/observations/provider-runtime-context'
|
||||
import { localPreflightContextKey } from '../../runtime/hosts/preflight/local-preflight-context-key'
|
||||
|
||||
export type IntegrationStepState = 'active' | 'done' | 'upcoming'
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { TabGroupSplitNodeTree } from '@/components/tab-group/TabGroupSplitNodeT
|
||||
import { WorkspaceTabDragLayer } from '@/components/tab-group/WorkspaceTabDragLayer'
|
||||
import { WorkspacePaneOverlayLayers } from '@/components/WorkspacePaneOverlayLayers'
|
||||
import { isTerminalImeInputContextRefreshing } from '@/components/terminal-pane/input/ime/terminal-ime-input-context-refresh'
|
||||
import { buildDuplicatedBrowserTabOptions } from '@/lib/duplicate-browser-tab-options'
|
||||
import { buildDuplicatedBrowserTabOptions } from '@/lib/browser/workspace/duplicate-browser-tab-options'
|
||||
import { FLOATING_TERMINAL_WORKTREE_ID } from '../../../../shared/constants'
|
||||
import { FloatingTerminalEmptyState } from './FloatingTerminalEmptyState'
|
||||
import { renderFloatingTerminalOrchestrationCard } from './FloatingTerminalOrchestrationCard'
|
||||
|
||||
@@ -2,11 +2,11 @@ import { FLOATING_TERMINAL_WORKTREE_ID } from '../../../../shared/constants'
|
||||
import { createUntitledMarkdownFileWithTemplateSelection } from '../../lib/editor/file-operations/create-untitled-markdown'
|
||||
import { getConnectionId } from '../../lib/workspace/ownership/connection-context'
|
||||
import { detectLanguage } from '../../../../shared/editor-language/editor-language-detect'
|
||||
import type { AppState } from '@/store/types'
|
||||
import { focusTerminalTabSurface } from '../terminal-pane/input/focus/focus-terminal-tab-surface'
|
||||
import { createNonSecureContextUuid as createBrowserUuid } from '../../../../shared/non-secure-context-uuid'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { assertClientCreationActionAvailable } from '../../lib/client-creation-action-policy'
|
||||
import { assertClientCreationActionAvailable } from '../../lib/workspace/creation/surface-policy/client-creation-action-policy'
|
||||
import type { AppState } from '@/store/types'
|
||||
|
||||
type FloatingWorkspaceTerminalStore = Pick<AppState, 'activeGroupIdByWorktree' | 'createTab'>
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import { toast } from 'sonner'
|
||||
import { resolveGroupTabFromVisibleId } from '@/components/tab-group/tab-group-visible-id'
|
||||
import { getConnectionId } from '@/lib/workspace/ownership/connection-context'
|
||||
import { createUntitledMarkdownFileWithTemplateSelection } from '@/lib/editor/file-operations/create-untitled-markdown'
|
||||
import { ensureClientCreationActionAllowed } from '@/lib/client-creation-action-error'
|
||||
import { ensureClientCreationActionAllowed } from '@/lib/workspace/creation/surface-policy/client-creation-action-error'
|
||||
import { openDocumentInFloatingWorkspace } from '@/components/floating-terminal/open-document-in-floating-workspace'
|
||||
import { extractIpcErrorMessage } from '@/runtime/errors/ipc-error'
|
||||
import { focusTerminalTabSurface } from '@/components/terminal-pane/input/focus/focus-terminal-tab-surface'
|
||||
|
||||
+6
-8
@@ -1,6 +1,7 @@
|
||||
import { useCallback, useEffect, useRef, type KeyboardEvent as ReactKeyboardEvent } from 'react'
|
||||
import { useCallback, useEffect, useRef } from 'react'
|
||||
import type { KeyboardEvent as ReactKeyboardEvent } from 'react'
|
||||
import { isTerminalPaneCloseChord } from '@/components/terminal-pane/input/keyboard/terminal-shortcut-policy'
|
||||
import { ensureClientCreationActionAllowed } from '@/lib/client-creation-action-error'
|
||||
import { ensureClientCreationActionAllowed } from '@/lib/workspace/creation/surface-policy/client-creation-action-error'
|
||||
import {
|
||||
matchFloatingWorkspacePanelOwnedAction,
|
||||
matchFloatingWorkspacePanelShortcut
|
||||
@@ -10,13 +11,10 @@ import { getShortcutPlatform } from '@/lib/keyboard/shortcut-platform'
|
||||
import { requestTerminalTabRename } from '@/components/tab-bar/terminal-tab-rename-request'
|
||||
import { resolveTerminalAgentTabShortcut } from '@/components/terminal-agent-tab-shortcut'
|
||||
import { launchFloatingWorkspaceAgentShortcut } from '@/components/agent-tab-shortcut-launch'
|
||||
import { useAppStore } from '@/store'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import { FLOATING_TERMINAL_WORKTREE_ID } from '../../../../shared/constants'
|
||||
import {
|
||||
keybindingMatchesAction,
|
||||
type KeybindingContext,
|
||||
type KeybindingMatchOptions
|
||||
} from '../../../../shared/keybindings'
|
||||
import { keybindingMatchesAction } from '../../../../shared/keybindings'
|
||||
import type { KeybindingContext, KeybindingMatchOptions } from '../../../../shared/keybindings'
|
||||
import type {
|
||||
FloatingPanelShortcutInput,
|
||||
FloatingPanelShortcutResolution,
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { getClientCreationActionPolicy } from '@/lib/client-creation-action-policy'
|
||||
import { useAppStore } from '@/store'
|
||||
import { getClientCreationActionPolicy } from '@/lib/workspace/creation/surface-policy/client-creation-action-policy'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import { FLOATING_TERMINAL_WORKTREE_ID } from '../../../../shared/constants'
|
||||
import { selectFloatingTerminalPanelInputs } from './floating-terminal-panel-inputs'
|
||||
|
||||
|
||||
+6
-6
@@ -1,12 +1,12 @@
|
||||
import { useState } from 'react'
|
||||
import { useMountedRef } from '@/hooks/useMountedRef'
|
||||
import { getLocalPreflightContext } from '@/lib/local-preflight-context'
|
||||
import { localPreflightContextKey } from '@/lib/local-preflight-context-key'
|
||||
import { getLocalPreflightContext } from '@/runtime/hosts/preflight/local-preflight-context'
|
||||
import { localPreflightContextKey } from '@/runtime/hosts/preflight/local-preflight-context-key'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import {
|
||||
getPreflightIntegrationStatuses,
|
||||
type PreflightIntegrationStatuses,
|
||||
type PreflightRefreshProvider
|
||||
import { getPreflightIntegrationStatuses } from './integrations-pane-status'
|
||||
import type {
|
||||
PreflightIntegrationStatuses,
|
||||
PreflightRefreshProvider
|
||||
} from './integrations-pane-status'
|
||||
|
||||
type CliStatus = {
|
||||
|
||||
@@ -4,32 +4,32 @@ import { Button } from '../ui/button'
|
||||
import { Checkbox } from '../ui/checkbox'
|
||||
import { Dialog, DialogContent, DialogFooter } from '../ui/dialog'
|
||||
import { useAppStore } from '../../store/index'
|
||||
import { useTranslate, type Translate } from '@/i18n/use-translate'
|
||||
import { activateAiVaultStructuredSession } from '@/lib/activate-ai-vault-structured-session'
|
||||
import { useTranslate } from '@/i18n/use-translate'
|
||||
import type { Translate } from '@/i18n/use-translate'
|
||||
import { activateAiVaultStructuredSession } from '@/lib/agent-session/open/activate-ai-vault-structured-session'
|
||||
import { ResumeOnRestartGroups } from './tree/NativeChatResumeOnRestartGroups'
|
||||
import { ResumeTreeRow } from './tree/NativeChatResumeTreeRow'
|
||||
import {
|
||||
resumeFailureGuidance,
|
||||
resumeFailureSelectable,
|
||||
type ResumeFailureAction
|
||||
resumeFailureSelectable
|
||||
} from './failures/native-chat-resume-failure-guidance'
|
||||
import type { ResumeFailureAction } from './failures/native-chat-resume-failure-guidance'
|
||||
import {
|
||||
resumeSelectionState,
|
||||
toggleResumeSelection,
|
||||
type ResumeCandidate,
|
||||
type ResumeFailure
|
||||
toggleResumeSelection
|
||||
} from './tree/native-chat-resume-on-restart-grouping'
|
||||
import type { ResumeCandidate, ResumeFailure } from './tree/native-chat-resume-on-restart-grouping'
|
||||
import {
|
||||
useNativeChatRestartOffer,
|
||||
useNativeChatRestartResuming,
|
||||
useNativeChatRestartRun
|
||||
} from './offers/native-chat-resume-on-restart-store'
|
||||
import type { NativeChatRestartStore } from './offers/native-chat-restart-runtime-store'
|
||||
import { useResumeRunPanel } from './runs/NativeChatResumeRunPanel'
|
||||
import { resumeRunFailures } from './runs/native-chat-resume-run-view'
|
||||
import { NativeChatResumeAutoNote } from './dialogs/NativeChatResumeAutoNote'
|
||||
import { NativeChatRemoteResumeActions } from './dialogs/NativeChatRemoteResumeActions'
|
||||
import { moveInTree } from './tree/native-chat-resume-tree-keys'
|
||||
import type { NativeChatRestartStore } from './offers/native-chat-restart-runtime-store'
|
||||
|
||||
/** Resume reattaches and sends a continuation, never the original user prompt; disclose this before sending. Automatic preference skips the prompt but uses the same host safety checks.
|
||||
* The store owns runs across dialog closes. Closing snoozes; Dismiss all deletes durable offers. Row Retry/Dismiss keep the dialog open, and settled runs cannot close a user-reopened dialog. Unretryable failures stay outside Resume. */
|
||||
|
||||
-150
@@ -1,150 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
import {
|
||||
createResumeModalFixture,
|
||||
offered,
|
||||
failure,
|
||||
type RestartRpc,
|
||||
type ResumeStatusStream
|
||||
} from './native-chat-resume-modal.test-support'
|
||||
import { act } from 'react'
|
||||
import { expect, it, vi, type Mock } from 'vitest'
|
||||
import { NativeChatResumeOnRestartModal } from '../NativeChatResumeRuntimeModal'
|
||||
|
||||
import { NativeChatResumeStatusSegment } from '../../status-bar/NativeChatResumeStatusSegment'
|
||||
import type { ResumeCandidate, ResumeFailure } from '../tree/native-chat-resume-on-restart-grouping'
|
||||
import type { AgentSessionStatusSummary } from '../../../../../shared/agent-session/agent-session-wire'
|
||||
|
||||
const rpc: Mock<RestartRpc> = vi.hoisted(() => vi.fn<RestartRpc>())
|
||||
const statusStream: ResumeStatusStream = vi.hoisted(() => ({
|
||||
emit: (_event: Parameters<ResumeStatusStream['emit']>[0]) => {},
|
||||
snapshot: new Map()
|
||||
}))
|
||||
vi.mock('../../../runtime/native-chat/requests/structured-agent-session-call', () => ({
|
||||
callStructuredAgentSession: rpc
|
||||
}))
|
||||
|
||||
vi.mock('../../../runtime/native-chat/requests/structured-agent-session-subscriptions', () => ({
|
||||
subscribeStructuredAgentSessionStatus: async (
|
||||
_target: unknown,
|
||||
emit: (event: Parameters<ResumeStatusStream['emit']>[0]) => void
|
||||
) => {
|
||||
statusStream.emit = emit
|
||||
emit({ type: 'snapshot', sessions: [...statusStream.snapshot.values()] })
|
||||
return { unsubscribe: () => {} }
|
||||
}
|
||||
}))
|
||||
vi.mock('@/lib/activate-ai-vault-structured-session', () => ({
|
||||
activateAiVaultStructuredSession: vi.fn(async () => true)
|
||||
}))
|
||||
vi.mock('sonner', async () =>
|
||||
(await import('./native-chat-resume-sonner-mock.test-support')).resumeSonnerMock()
|
||||
)
|
||||
|
||||
const { mount, button, offerIds, runStatus } = createResumeModalFixture(rpc, statusStream)
|
||||
|
||||
function emitPhase(
|
||||
sessionId: string,
|
||||
phase?: NonNullable<AgentSessionStatusSummary['restartResume']>['phase']
|
||||
): void {
|
||||
statusStream.emit({
|
||||
type: 'status',
|
||||
session: {
|
||||
sessionId,
|
||||
workspaceId: 'workspace',
|
||||
agent: 'codex',
|
||||
status: 'idle',
|
||||
latestPrompt: '',
|
||||
updatedAt: 1,
|
||||
...(phase ? { restartResume: { phase } } : {})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
it('keeps the run in flight after every feed verdict until the fallback list is published', async () => {
|
||||
const answer = Promise.withResolvers<{
|
||||
continued: { sessionId: string; outcome: 'continued' }[]
|
||||
}>()
|
||||
const listing = Promise.withResolvers<{ sessions: ResumeCandidate[]; failed: ResumeFailure[] }>()
|
||||
let reads = 0
|
||||
rpc.mockImplementation(async (_target, method) =>
|
||||
method === 'agentSession.restartContinue'
|
||||
? answer.promise
|
||||
: reads++ === 0
|
||||
? { sessions: offered, failed: [] }
|
||||
: listing.promise
|
||||
)
|
||||
await mount(
|
||||
<>
|
||||
<NativeChatResumeOnRestartModal />
|
||||
<NativeChatResumeStatusSegment iconOnly={false} />
|
||||
</>
|
||||
)
|
||||
await act(async () => button('Resume 2 chats').click())
|
||||
await act(async () => button('Resuming chats 0/2').click())
|
||||
await act(async () => {
|
||||
for (const { sessionId } of offered) {
|
||||
statusStream.emit({
|
||||
type: 'status',
|
||||
session: {
|
||||
sessionId,
|
||||
workspaceId: 'workspace',
|
||||
agent: 'codex',
|
||||
status: 'idle',
|
||||
latestPrompt: '',
|
||||
updatedAt: 1,
|
||||
restartResume: { phase: 'continued' }
|
||||
}
|
||||
})
|
||||
}
|
||||
answer.resolve({
|
||||
continued: offered.map(({ sessionId }) => ({ sessionId, outcome: 'continued' }))
|
||||
})
|
||||
})
|
||||
expect(button('Resuming chats 2/2')).toBeTruthy()
|
||||
await act(async () => offered.forEach(({ sessionId }) => emitPhase(sessionId)))
|
||||
expect(button('Resuming chats 2/2')).toBeTruthy()
|
||||
expect(runStatus('Prompt a')).toBe('Prompt a: Resumed')
|
||||
expect(button('Resuming…').disabled).toBe(true)
|
||||
expect(document.body.textContent).not.toContain('chats to resume')
|
||||
await act(async () => listing.resolve({ sessions: [], failed: [] }))
|
||||
expect(offerIds()).toEqual([])
|
||||
expect(button('Done').disabled).toBe(false)
|
||||
expect(document.body.textContent).not.toContain('Resuming chats')
|
||||
})
|
||||
|
||||
it('retains success and refusal frames through cleanup before a delayed bulk reply', async () => {
|
||||
const reply = Promise.withResolvers<unknown>()
|
||||
rpc.mockImplementation(async (_target, method) =>
|
||||
method === 'agentSession.restartResumable' ? { sessions: offered, failed: [] } : reply.promise
|
||||
)
|
||||
await mount(
|
||||
<>
|
||||
<NativeChatResumeOnRestartModal />
|
||||
<NativeChatResumeStatusSegment iconOnly={false} />
|
||||
</>
|
||||
)
|
||||
await act(async () => button('Resume 2 chats').click())
|
||||
// Verdicts and cleanup can arrive together before React gets a render.
|
||||
await act(async () => {
|
||||
emitPhase('a', 'continued')
|
||||
emitPhase('b', 'refused')
|
||||
emitPhase('a')
|
||||
emitPhase('b')
|
||||
})
|
||||
expect(button('Resuming chats 2/2')).toBeTruthy()
|
||||
await act(async () => button('Resuming chats 2/2').click())
|
||||
expect(runStatus('Prompt a')).toBe('Prompt a: Resumed')
|
||||
expect(runStatus('Prompt b')).toBe('Prompt b: Couldn’t resume')
|
||||
expect(document.querySelector('[role="dialog"]')?.textContent).toContain('Need you1')
|
||||
await act(async () =>
|
||||
reply.resolve({
|
||||
sessions: [],
|
||||
failed: [failure('b')],
|
||||
continued: [
|
||||
{ sessionId: 'a', outcome: 'continued' },
|
||||
{ sessionId: 'b', outcome: 'refused' }
|
||||
]
|
||||
})
|
||||
)
|
||||
expect(document.querySelector('[role="dialog"]')?.textContent).toContain('Resumed 1 of 2 chats')
|
||||
})
|
||||
@@ -0,0 +1,96 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { Terminal } from '@xterm/xterm'
|
||||
import { defineFixture } from '../../../component-fixtures/component-fixture'
|
||||
import { NativeChatPaneCover } from '../../terminal-pane/chat/NativeChatPaneCover'
|
||||
import {
|
||||
NATIVE_CHAT_APPEARANCE_ROOT_CLASS,
|
||||
nativeChatAppearanceStyle
|
||||
} from './native-chat-appearance-style'
|
||||
|
||||
function ChatCanvas({ sample }: { sample: string }): React.JSX.Element {
|
||||
return (
|
||||
<div
|
||||
data-native-chat-root="true"
|
||||
className={`${NATIVE_CHAT_APPEARANCE_ROOT_CLASS} relative h-full w-full`}
|
||||
style={nativeChatAppearanceStyle({ theme: 'dark' })}
|
||||
>
|
||||
<div data-paint-sample={sample} className="absolute left-4 top-4 size-8" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function TerminalPane({
|
||||
covered,
|
||||
sample
|
||||
}: {
|
||||
covered: boolean
|
||||
sample: string
|
||||
}): React.JSX.Element {
|
||||
const [container, setContainer] = useState<HTMLDivElement | null>(null)
|
||||
const [terminal] = useState(() => new Terminal())
|
||||
useEffect(() => () => terminal.dispose(), [terminal])
|
||||
return (
|
||||
<div ref={setContainer} className="pane relative h-32 w-40">
|
||||
<div className="xterm-container absolute inset-0">
|
||||
<div data-terminal-ink className="absolute inset-0" />
|
||||
</div>
|
||||
{!covered && <div data-paint-sample={sample} className="absolute left-4 top-4 size-8" />}
|
||||
{covered && container
|
||||
? createPortal(
|
||||
<NativeChatPaneCover pane={{ container, terminal }}>
|
||||
<ChatCanvas sample={sample} />
|
||||
</NativeChatPaneCover>,
|
||||
container
|
||||
)
|
||||
: null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Backdrops(): React.JSX.Element {
|
||||
const [covered, setCovered] = useState(false)
|
||||
useEffect(() => {
|
||||
const root = document.documentElement
|
||||
const previousMaterial = root.getAttribute('data-window-material')
|
||||
const previousOpacity = root.style.getPropertyValue('--orca-window-surface-opacity')
|
||||
root.dataset.windowMaterial = 'blur'
|
||||
root.style.setProperty('--orca-window-surface-opacity', '0.3')
|
||||
return () => {
|
||||
if (previousMaterial === null) {
|
||||
root.removeAttribute('data-window-material')
|
||||
} else {
|
||||
root.setAttribute('data-window-material', previousMaterial)
|
||||
}
|
||||
root.style.setProperty('--orca-window-surface-opacity', previousOpacity)
|
||||
}
|
||||
}, [])
|
||||
const terminalBackground = 'color-mix(in srgb, var(--background) 30%, transparent)'
|
||||
return (
|
||||
<>
|
||||
<button onClick={() => setCovered(!covered)}>Toggle split chat</button>
|
||||
<div data-test-backdrop className="flex gap-4">
|
||||
<div data-paint-sample="bare" className="size-8 shrink-0" />
|
||||
<div data-terminal-chat-pane="" style={{ background: terminalBackground }}>
|
||||
<TerminalPane covered sample="single" />
|
||||
</div>
|
||||
<div
|
||||
data-terminal-chat-pane={covered ? '' : undefined}
|
||||
className="has-multiple-panes flex"
|
||||
style={{ background: terminalBackground }}
|
||||
>
|
||||
<TerminalPane covered={covered} sample="split" />
|
||||
<TerminalPane covered={false} sample="neighbor" />
|
||||
</div>
|
||||
<div data-structured-agent-session-overlay-tab-id="fixture" className="h-32 w-40">
|
||||
<ChatCanvas sample="structured" />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export const material = defineFixture({
|
||||
width: 800,
|
||||
render: () => <Backdrops />
|
||||
})
|
||||
@@ -1,17 +1,18 @@
|
||||
import './native-chat-appearance.css'
|
||||
import { useMemo, type CSSProperties } from 'react'
|
||||
import { useMemo } from 'react'
|
||||
import type { CSSProperties } from 'react'
|
||||
import { useShallow } from 'zustand/react/shallow'
|
||||
import type { GlobalSettings } from '../../../../../shared/global-settings-types'
|
||||
import { resolveNativeChatAppearanceSettings } from '../../../../../shared/native-chat/native-chat-appearance-settings'
|
||||
import { resolveConfiguredTerminalColors } from '../../../../../shared/terminal-themes/terminal-theme-selection'
|
||||
import { MATCH_TERMINAL_APP_THEME } from '../../../../../shared/plugin-theme-settings'
|
||||
import { buildFontFamily } from '../../../../../shared/monospace-font-family'
|
||||
import { buildAppFontFamily } from '@/app-shell/appearance/app-font-family'
|
||||
import { resolveEditorFontStack } from '../../../../../shared/editor/editor-typography'
|
||||
import { getSystemPrefersDark } from '@/lib/terminal-theme'
|
||||
import { getSystemPrefersDark } from '@/lib/terminal/appearance/terminal-theme'
|
||||
import { isTerminalBackgroundLight } from '../../../../../shared/terminal-themes/terminal-title-contrast'
|
||||
import { useSystemPrefersDark } from '../../../hooks/theme/use-system-prefers-dark'
|
||||
import { terminalChatSelectionMix } from '@/app-shell/appearance/chat-selection-mix'
|
||||
import type { GlobalSettings } from '../../../../../shared/global-settings-types'
|
||||
|
||||
export const NATIVE_CHAT_APPEARANCE_ROOT_CLASS = 'native-chat-appearance bg-chat-canvas'
|
||||
// Bottom padding clears 20px control overhang; rail padding also covers its 34px overlay on macOS without scrollbar gutters.
|
||||
|
||||
@@ -39,35 +39,31 @@
|
||||
initial-value: 0px;
|
||||
}
|
||||
|
||||
/* Over a theme image (main.css) a chat that fills its pane paints the canvas once and the layers
|
||||
under it go clear. The canvas follows Background Opacity, floored at 0.8 so body text stays near
|
||||
4.5:1 even over white or black pixels. A chat split beside terminals stays opaque, since the pane
|
||||
manager paints the terminal color under every pane of the split. */
|
||||
:root[data-theme-background] [data-terminal-chat-view]:not(.has-multiple-panes) {
|
||||
/* Chat keeps a readable canvas over either backdrop. Mixed splits retain their shared terminal
|
||||
paint beneath it so neighboring terminals keep their background. */
|
||||
:root:is([data-theme-background], [data-window-material])
|
||||
[data-terminal-chat-pane]:not(.has-multiple-panes) {
|
||||
/* Beats the pane manager's inline split paint (pane-divider.ts applyRootBackground). */
|
||||
background: transparent !important;
|
||||
}
|
||||
|
||||
:root[data-theme-background]
|
||||
[data-terminal-chat-view]:not(.has-multiple-panes)
|
||||
:root:is([data-theme-background], [data-window-material])
|
||||
[data-terminal-chat-pane]
|
||||
.native-chat-pane-shell {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/* The opaque cover used to hide the terminal and its banners (layers below its z-10); overlays
|
||||
above it stay. Opacity, not visibility, so the covered terminal can still take focus handoffs. */
|
||||
:root[data-theme-background]
|
||||
[data-terminal-chat-view]:not(.has-multiple-panes)
|
||||
.pane
|
||||
:root:is([data-theme-background], [data-window-material])
|
||||
[data-terminal-chat-pane]
|
||||
.pane:has(> .native-chat-pane-shell)
|
||||
> :is(.xterm-container, .session-restored-banner, .pane-top-banner) {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
:root[data-theme-background]
|
||||
:is(
|
||||
[data-terminal-chat-view]:not(.has-multiple-panes),
|
||||
[data-structured-agent-session-overlay-tab-id]
|
||||
)
|
||||
:root:is([data-theme-background], [data-window-material])
|
||||
:is([data-terminal-chat-pane], [data-structured-agent-session-overlay-tab-id])
|
||||
[data-native-chat-root] {
|
||||
--chat-pane: transparent;
|
||||
/* Text-bearing surfaces keep an opaque base, as in the light scheme. */
|
||||
@@ -90,7 +86,14 @@
|
||||
);
|
||||
background-color: color-mix(
|
||||
in srgb,
|
||||
var(--chat-canvas) calc(max(var(--orca-theme-background-surface-opacity), 0.8) * 100%),
|
||||
var(--chat-canvas)
|
||||
calc(
|
||||
max(
|
||||
var(--orca-theme-background-surface-opacity, var(--orca-window-surface-opacity, 1)),
|
||||
0.8
|
||||
) *
|
||||
100%
|
||||
),
|
||||
transparent
|
||||
);
|
||||
}
|
||||
|
||||
+18
-13
@@ -1,13 +1,15 @@
|
||||
import { captureNativeChatEditDraftDestination } from '../../drafts/native-chat-composer-draft-memory'
|
||||
import { useCallback, useLayoutEffect, useRef } from 'react'
|
||||
import { useAppStore } from '@/store'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import { NATIVE_FILE_DROP_MAX_PATHS } from '../../../../../../shared/file-import/native-file-drop'
|
||||
import {
|
||||
isSameComposerWorkspace,
|
||||
nativeChatAttachmentOwnerUnchanged,
|
||||
type ComposerWorkspace,
|
||||
type NativeChatAttachmentFocusOptions,
|
||||
type NativeChatResolvedPathOptions
|
||||
nativeChatAttachmentOwnerUnchanged
|
||||
} from '../uploads/native-chat-resolved-path-ownership'
|
||||
import type {
|
||||
ComposerWorkspace,
|
||||
NativeChatAttachmentFocusOptions,
|
||||
NativeChatResolvedPathOptions
|
||||
} from '../uploads/native-chat-resolved-path-ownership'
|
||||
import {
|
||||
nativeChatAttachmentOwnerChangedNotice,
|
||||
@@ -18,21 +20,24 @@ import {
|
||||
import {
|
||||
resolveNativeChatAttachmentOwner,
|
||||
resolveNativeChatAttachmentOwnerForWorktree,
|
||||
resolveNativeChatRuntimeSessionAttachmentOwner,
|
||||
type NativeChatAttachmentOwner,
|
||||
type NativeChatStructuredAttachmentSession
|
||||
resolveNativeChatRuntimeSessionAttachmentOwner
|
||||
} from '../uploads/native-chat-attachment-owner'
|
||||
import type {
|
||||
NativeChatAttachmentOwner,
|
||||
NativeChatStructuredAttachmentSession
|
||||
} from '../uploads/native-chat-attachment-owner'
|
||||
|
||||
import {
|
||||
attachNativeChatSessionAttachmentPaths,
|
||||
reserveNativeChatAttachmentChips,
|
||||
type NativeChatPendingAttachmentChips,
|
||||
type NativeChatReservedAttachment
|
||||
reserveNativeChatAttachmentChips
|
||||
} from './native-chat-session-attachment-drop'
|
||||
import type {
|
||||
NativeChatPendingAttachmentChips,
|
||||
NativeChatReservedAttachment
|
||||
} from './native-chat-session-attachment-drop'
|
||||
import { releaseBrowserAttachmentFiles } from '@/lib/files/drop/browser-attachment-files'
|
||||
import { attachNativeChatLocalAttachmentPaths } from './native-chat-local-attachment-drop'
|
||||
import { useMountedRef } from '@/hooks/useMountedRef'
|
||||
import { chatWorkspaceByTabId as findTerminalTabWorktreeId } from '../../../../lib/structured-chat-tab-index'
|
||||
import { chatWorkspaceByTabId as findTerminalTabWorktreeId } from '../../../../lib/agent-session/tab-identity/structured-chat-tab-index'
|
||||
import type { CapturedNativeChatDrop } from './native-chat-pane-file-drop'
|
||||
|
||||
export type UseNativeChatExternalAttachmentsArgs = {
|
||||
|
||||
+6
-5
@@ -1,5 +1,6 @@
|
||||
import { useCallback, useLayoutEffect, useRef, type DragEventHandler } from 'react'
|
||||
import { useAppStore } from '@/store'
|
||||
import { useCallback, useLayoutEffect, useRef } from 'react'
|
||||
import type { DragEventHandler } from 'react'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import {
|
||||
getWorkspaceFileDragRejectionMessage,
|
||||
hasWorkspaceFileDragType,
|
||||
@@ -12,13 +13,13 @@ import {
|
||||
resolveNativeChatAttachmentHost
|
||||
} from '../uploads/native-chat-attachment-owner'
|
||||
import { nativeChatWorktreeNotReadyNotice } from './native-chat-attachment-notices'
|
||||
import { chatWorkspaceByTabId as findTerminalTabWorktreeId } from '../../../../lib/structured-chat-tab-index'
|
||||
import { chatWorkspaceByTabId as findTerminalTabWorktreeId } from '../../../../lib/agent-session/tab-identity/structured-chat-tab-index'
|
||||
import { parseExecutionHostId } from '../../../../../../shared/execution-host'
|
||||
import {
|
||||
nativeChatAttachmentOwnerUnchanged,
|
||||
nativeChatWorkspaceAttachmentMismatchNotice,
|
||||
type NativeChatResolvedPathOptions
|
||||
nativeChatWorkspaceAttachmentMismatchNotice
|
||||
} from '../uploads/native-chat-resolved-path-ownership'
|
||||
import type { NativeChatResolvedPathOptions } from '../uploads/native-chat-resolved-path-ownership'
|
||||
|
||||
export type NativeChatResolvedPathSink = (
|
||||
paths: string[],
|
||||
|
||||
+3
-4
@@ -1,18 +1,17 @@
|
||||
import type { AppState } from '../../../../store/types'
|
||||
import { chatWorkspaceByTabId as findTerminalTabWorktreeId } from '../../../../lib/structured-chat-tab-index'
|
||||
|
||||
import { chatWorkspaceByTabId as findTerminalTabWorktreeId } from '../../../../lib/agent-session/tab-identity/structured-chat-tab-index'
|
||||
import { FLOATING_TERMINAL_WORKTREE_ID } from '../../../../../../shared/constants'
|
||||
import { getKnownExecutionHostIdForWorktree } from '../../../../lib/workspace/ownership/worktree-runtime-owner'
|
||||
import { runtimeEnvironmentIdForWorkspaceOwner } from '../../../../lib/workspace/ownership/resolve-owner'
|
||||
import { getConnectionIdFromState } from '../../../../lib/workspace/ownership/connection-owner-resolution'
|
||||
import {
|
||||
type ExecutionHostId,
|
||||
toRuntimeExecutionHostId,
|
||||
getConnectionExecutionHostId,
|
||||
parseExecutionHostId
|
||||
} from '../../../../../../shared/execution-host'
|
||||
import type { ExecutionHostId } from '../../../../../../shared/execution-host'
|
||||
import { findKnownWorktreeById } from '../../../../store/slices/worktrees/listing/detected-worktree-meta'
|
||||
import { getRuntimeEnvironmentRevision } from '../../../../runtime/rpc/environment-revisions/runtime-environment-revision'
|
||||
import type { AppState } from '../../../../store/types'
|
||||
|
||||
/** The paired host validates every stored attachment path when admitting a structured send. */
|
||||
export type NativeChatRuntimeSessionAttachmentOwner = {
|
||||
|
||||
+6
-6
@@ -1,11 +1,9 @@
|
||||
import type { AppState } from '@/store/types'
|
||||
import { workspaceTabs } from '@/lib/structured-chat-tab-index'
|
||||
import { workspaceTabs } from '@/lib/agent-session/tab-identity/structured-chat-tab-index'
|
||||
import { selectExecutionHostDisplayLabel } from '@/runtime/hosts/display/execution-host-display-label'
|
||||
import { findIndexedRepoOwnerForHost } from '@/lib/workspace/ownership/repo-owner-index'
|
||||
import { getWslDistroFromPath } from '@/lib/local-preflight-context'
|
||||
import { getWslDistroFromPath } from '@/runtime/hosts/preflight/local-preflight-context'
|
||||
import { selectWslHostDistro } from '@/components/wsl-host-mark/WslHostMark'
|
||||
import { resolvePaneWslDistro } from '@/components/terminal-pane/host-state/terminal-pane-wsl-distro'
|
||||
import type { Repo } from '../../../../../../shared/repo-types'
|
||||
import { getHostSettingOverride } from '../../../../../../shared/host-setting-overrides'
|
||||
import { isFolderRepo } from '../../../../../../shared/repo-kind'
|
||||
import { parseWorkspaceKey } from '../../../../../../shared/workspace-scope'
|
||||
@@ -19,9 +17,9 @@ import {
|
||||
import {
|
||||
isUnresolvedOwnerHostId,
|
||||
parseExecutionHostId,
|
||||
toRuntimeExecutionHostId,
|
||||
type ExecutionHostId
|
||||
toRuntimeExecutionHostId
|
||||
} from '../../../../../../shared/execution-host'
|
||||
import type { ExecutionHostId } from '../../../../../../shared/execution-host'
|
||||
import {
|
||||
floatingWorkspaceToWorktree,
|
||||
isFloatingWorkspaceId
|
||||
@@ -29,6 +27,8 @@ import {
|
||||
import { createNativeChatTabOwnerSelector } from '../../pane/ownership/native-chat-tab-owner'
|
||||
import { FILE_LINK_CONTEXT_INPUT_KEYS } from '../../links/actions/native-chat-file-link-context'
|
||||
import { resolveNativeChatTabDirectory } from '../../pane/routing/native-chat-tab-directory'
|
||||
import type { AppState } from '@/store/types'
|
||||
import type { Repo } from '../../../../../../shared/repo-types'
|
||||
import type { NativeChatStructuredComposerTransport } from '../submit/native-chat-structured-composer-transport'
|
||||
|
||||
const OWNER_CONTEXT_INPUT_KEYS = FILE_LINK_CONTEXT_INPUT_KEYS.filter(
|
||||
|
||||
+6
-6
@@ -1,21 +1,21 @@
|
||||
import type { AppState } from '../../../../store/types'
|
||||
import type { SkillDiscoveryTarget } from '../../../../../../shared/skills'
|
||||
import { parseExecutionHostId } from '../../../../../../shared/execution-host'
|
||||
import type { RuntimeClientTarget } from '../../../../../../shared/runtime-client-target'
|
||||
import { getExecutionHostIdForWorktree } from '@/lib/workspace/ownership/worktree-runtime-owner'
|
||||
import { runtimeEnvironmentIdForWorkspaceOwner } from '@/lib/workspace/ownership/resolve-owner'
|
||||
import { getLocalProjectExecutionRuntimeContext } from '@/lib/local-preflight-context'
|
||||
import { getLocalProjectExecutionRuntimeContext } from '@/runtime/hosts/preflight/local-preflight-context'
|
||||
import { resolveWorkspaceDirectory } from '@/lib/workspace/paths/workspace-directory'
|
||||
import {
|
||||
resolveNativeChatTabDirectory,
|
||||
resolveNativeChatTabDirectoryResolution,
|
||||
type NativeChatTabDirectoryState
|
||||
resolveNativeChatTabDirectoryResolution
|
||||
} from '../../pane/routing/native-chat-tab-directory'
|
||||
import type { NativeChatTabDirectoryState } from '../../pane/routing/native-chat-tab-directory'
|
||||
import {
|
||||
selectDetectedWorktreesByRepo,
|
||||
selectFolderWorkspaces,
|
||||
selectWorktreesByRepo
|
||||
} from '@/store/workspaces/catalog/workspace-record-fields'
|
||||
import type { AppState } from '../../../../store/types'
|
||||
import type { SkillDiscoveryTarget } from '../../../../../../shared/skills'
|
||||
import type { RuntimeClientTarget } from '../../../../../../shared/runtime-client-target'
|
||||
|
||||
export type NativeChatSkillStateInputs = Pick<
|
||||
AppState,
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
import { useMemo } from 'react'
|
||||
import { useAppStore } from '@/store'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import { useRuntimeFileListForWorktree } from '@/components/quick-open-file-list'
|
||||
import { rankQuickOpenFilesWithHistory } from '@/components/quick-open-history-ranking'
|
||||
import { useQuickOpenHistory } from '@/lib/files/search/quick-open-file-history'
|
||||
import { chatWorkspaceByTabId as findTerminalTabWorktreeId } from '../../../../lib/structured-chat-tab-index'
|
||||
import { chatWorkspaceByTabId as findTerminalTabWorktreeId } from '../../../../lib/agent-session/tab-identity/structured-chat-tab-index'
|
||||
import { useFileListWorktree } from '@/store/workspaces/selection/use-selected-worktree'
|
||||
|
||||
const MENTION_FILE_LIMIT = 20
|
||||
|
||||
-416
@@ -1,416 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
// Queued sends wait after the opening turn’s live status until actual handover, including across Stop.
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
import { cleanup, screen } from '@testing-library/react'
|
||||
import { render } from '../../messages/actions/native-chat-tooltip-test-harness'
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
const unusedChatLeaves = vi.hoisted(() => ({
|
||||
inlineVisual: vi.fn(() => {
|
||||
throw new Error('Unexpected inline visual in transcript fixture')
|
||||
}),
|
||||
openSender: vi.fn(() => {
|
||||
throw new Error('Unexpected sender navigation in transcript fixture')
|
||||
})
|
||||
}))
|
||||
vi.mock('../../media/visuals/NativeChatInlineVisual', () => ({
|
||||
NativeChatInlineVisual: unusedChatLeaves.inlineVisual
|
||||
}))
|
||||
vi.mock('@/lib/open-agent-message-sender', () => ({
|
||||
openAgentMessageSender: unusedChatLeaves.openSender
|
||||
}))
|
||||
import { agentSessionFailureFact } from '../../../../../../shared/agent-session/failures/agent-session-failure'
|
||||
import { agentSessionFailureWords } from '../../../../../../shared/agent-session/failures/agent-session-failure-words'
|
||||
import { agentJournalSubmissionKey } from '../../../../../../shared/agent-session/journal/agent-session-journal-item-key'
|
||||
import type {
|
||||
AgentJournalItemBody,
|
||||
AgentJournalRenderItem,
|
||||
AgentJournalSubmission
|
||||
} from '../../../../../../shared/agent-session/journal/agent-session-journal-types'
|
||||
import type { AgentJournalTurnScope } from '../../../../../../shared/agent-session/journal/agent-session-journal-turn-scope'
|
||||
import {
|
||||
projectStructuredAgentSessionMessages,
|
||||
type StructuredAgentSessionOptimisticMessage
|
||||
} from '../../../../../../shared/agent-session/view/structured-agent-session-message-projection'
|
||||
import { selectStructuredAgentSettledTurns } from '../../../../../../shared/agent-session/view/structured-agent-session-turn-timing'
|
||||
import { NativeChatMessageList } from '../../NativeChatMessageList'
|
||||
import { installNativeChatMessageListTestViewport } from '../../viewport/virtualization/native-chat-message-list-test-viewport'
|
||||
import { DISPATCH_REJECTED_CANCELLED } from '../../../../../../shared/agent-session/requests/structured-agent-session-dispatch-rejection'
|
||||
|
||||
describe('a message sent while the turn ahead is still opening', () => {
|
||||
let restoreViewport = (): void => {}
|
||||
beforeAll(() => {
|
||||
restoreViewport = installNativeChatMessageListTestViewport()
|
||||
})
|
||||
afterAll(() => restoreViewport())
|
||||
afterEach(cleanup)
|
||||
|
||||
const THREAD: AgentJournalTurnScope = { kind: 'thread' }
|
||||
const NOW = 100_000
|
||||
|
||||
function item(
|
||||
itemId: string,
|
||||
sequence: number,
|
||||
body: AgentJournalItemBody
|
||||
): AgentJournalRenderItem {
|
||||
return { itemId, revision: 0, sequence, observedAt: sequence, body, turnScope: THREAD }
|
||||
}
|
||||
|
||||
const userMessage = (id: string, sequence: number, text: string) =>
|
||||
item(agentJournalSubmissionKey(id), sequence, {
|
||||
kind: 'message',
|
||||
role: 'user',
|
||||
blocks: [{ type: 'text', text }]
|
||||
})
|
||||
|
||||
function submission(
|
||||
clientMessageId: string,
|
||||
overrides: Partial<AgentJournalSubmission> = {}
|
||||
): AgentJournalSubmission {
|
||||
return {
|
||||
clientMessageId,
|
||||
fence: 1,
|
||||
payloadFingerprint: clientMessageId,
|
||||
dispatchState: 'pending',
|
||||
providerItemId: null,
|
||||
reason: null,
|
||||
submittedAt: NOW,
|
||||
resolvedAt: null,
|
||||
handoverRecorded: true,
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
|
||||
/** A finished warm-up, then "first" handed over (row 5) with no turn record yet: its turn opens. */
|
||||
function openingFirst(): {
|
||||
items: AgentJournalRenderItem[]
|
||||
submissions: AgentJournalSubmission[]
|
||||
} {
|
||||
return {
|
||||
items: [
|
||||
userMessage('warm', 1, 'warm up'),
|
||||
item('turn-warm', 2, {
|
||||
kind: 'turn',
|
||||
turnId: 'turn-warm',
|
||||
state: 'completed',
|
||||
outcome: 'success',
|
||||
userItemId: agentJournalSubmissionKey('warm'),
|
||||
startedAt: 1_000,
|
||||
completedAt: 2_000
|
||||
}),
|
||||
userMessage('first', 5, 'first')
|
||||
],
|
||||
submissions: [
|
||||
submission('warm', { dispatchState: 'accepted', resolvedAt: 2_000 }),
|
||||
submission('first', { acceptedSequence: 3, handedOverAt: NOW })
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
/** The first send's turn record, written as its turn opens; Codex names its own provider key. */
|
||||
const firstTurnOpened = (sequence: number) =>
|
||||
item('turn-first', sequence, {
|
||||
kind: 'turn',
|
||||
turnId: 'turn-first',
|
||||
state: 'running',
|
||||
userItemId: FIRST_TURN_PROVIDER_KEY,
|
||||
startedAt: NOW
|
||||
})
|
||||
const FIRST_TURN_PROVIDER_KEY = 'codex:thread:turn-first:0'
|
||||
const inFirstTurn: AgentJournalTurnScope = { kind: 'turn', turnItemId: 'turn-first' }
|
||||
|
||||
/** This client's own send the host has not recorded yet: its lane still runs the first handover. */
|
||||
const unrecorded = (
|
||||
clientMessageId: string,
|
||||
text: string
|
||||
): StructuredAgentSessionOptimisticMessage => ({
|
||||
clientMessageId,
|
||||
body: { kind: 'message', role: 'user', blocks: [{ type: 'text', text }] },
|
||||
queuedAt: NOW + 100
|
||||
})
|
||||
|
||||
function frame(
|
||||
items: AgentJournalRenderItem[],
|
||||
submissions: AgentJournalSubmission[],
|
||||
optimistic: StructuredAgentSessionOptimisticMessage[],
|
||||
stopping = false
|
||||
): React.JSX.Element {
|
||||
return (
|
||||
<NativeChatMessageList
|
||||
session={{
|
||||
messages: projectStructuredAgentSessionMessages(items, optimistic, submissions),
|
||||
status: 'ready',
|
||||
sessionId: 'session-1',
|
||||
agent: 'codex',
|
||||
hasMore: false,
|
||||
loadingEarlier: false,
|
||||
olderHistoryGeneration: 0,
|
||||
loadEarlier: vi.fn(),
|
||||
readPhase: 'ready'
|
||||
}}
|
||||
journalItems={items}
|
||||
journalSubmissions={submissions}
|
||||
settledTurns={selectStructuredAgentSettledTurns(items, submissions)}
|
||||
isWorking
|
||||
workingStartedAt={NOW}
|
||||
stopping={stopping}
|
||||
expandSignal={false}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function follows(later: HTMLElement, earlier: HTMLElement): boolean {
|
||||
return Boolean(earlier.compareDocumentPosition(later) & Node.DOCUMENT_POSITION_FOLLOWING)
|
||||
}
|
||||
|
||||
const liveStatus = () => screen.getByText(/^Working for/)
|
||||
const liveActivity = () => screen.getByText(/^(Working|Stopping)…$/)
|
||||
|
||||
/** `text` is drawn after the live turn: its status and its activity line. */
|
||||
function waitsAtTheTail(text: string): void {
|
||||
expect(follows(screen.getByText(text), liveStatus())).toBe(true)
|
||||
expect(follows(screen.getByText(text), liveActivity())).toBe(true)
|
||||
}
|
||||
|
||||
// Stop withdraws B from the queue; its settled row stays after the live turn’s status and above its activity.
|
||||
it('stays after the live turn when a Stop takes it back, with no frame above the live status', () => {
|
||||
const { items, submissions } = openingFirst()
|
||||
const view = render(frame(items, submissions, [unrecorded('b', 'B')]))
|
||||
waitsAtTheTail('B')
|
||||
|
||||
// Pressed: Stopping, with B now recorded and queued behind the first send.
|
||||
const queued = [...items, userMessage('b', 4, 'B')]
|
||||
view.rerender(
|
||||
frame(queued, [...submissions, submission('b', { acceptedSequence: 4 })], [], true)
|
||||
)
|
||||
waitsAtTheTail('B')
|
||||
|
||||
const withdrawn = submission('b', {
|
||||
acceptedSequence: 4,
|
||||
dispatchState: 'rejected',
|
||||
resolvedAt: NOW + 200,
|
||||
...agentSessionFailureWords(agentSessionFailureFact('cancelled'), { surface: 'rejection' })
|
||||
})
|
||||
view.rerender(frame(queued, [...submissions, withdrawn], [], true))
|
||||
const stopRow = screen.getByText('Stopped manually')
|
||||
expect(follows(screen.getByText('B'), liveStatus())).toBe(true)
|
||||
expect(follows(stopRow, screen.getByText('B'))).toBe(true)
|
||||
expect(follows(liveActivity(), stopRow)).toBe(true)
|
||||
})
|
||||
|
||||
/** Check each commit keeps second at its handover position and the live status under first. */
|
||||
function walkTurnOpening(
|
||||
steps: [
|
||||
AgentJournalRenderItem[],
|
||||
AgentJournalSubmission[],
|
||||
StructuredAgentSessionOptimisticMessage[]
|
||||
][]
|
||||
): void {
|
||||
const view = render(<div />)
|
||||
for (const step of steps) {
|
||||
view.rerender(frame(...step))
|
||||
expect(follows(liveStatus(), screen.getByText('first'))).toBe(true)
|
||||
expect(follows(screen.getByText('second'), liveStatus())).toBe(true)
|
||||
expect(follows(liveActivity(), screen.getByText('second'))).toBe(true)
|
||||
}
|
||||
}
|
||||
|
||||
function turnOpening() {
|
||||
const { items, submissions } = openingFirst()
|
||||
const [warm, first] = submissions
|
||||
if (!warm || !first) {
|
||||
throw new Error('expected the warm-up and the first send')
|
||||
}
|
||||
const opened = [...items, firstTurnOpened(6)]
|
||||
return {
|
||||
submissions,
|
||||
warm,
|
||||
first,
|
||||
opened,
|
||||
// Handed over as a steer once the turn opened (row 8).
|
||||
steered: [...opened, { ...userMessage('second', 8, 'second'), turnScope: inFirstTurn }],
|
||||
echoed: (sent: AgentJournalSubmission): AgentJournalSubmission => ({
|
||||
...sent,
|
||||
dispatchState: 'accepted',
|
||||
providerItemId: FIRST_TURN_PROVIDER_KEY,
|
||||
resolvedAt: NOW + 20
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
it('draws it where it lands at every step of the turn opening, even with the steer echoed first', () => {
|
||||
const { submissions, warm, first, opened, steered, echoed } = turnOpening()
|
||||
const handedOver = submission('second', { acceptedSequence: 7, handedOverAt: NOW + 10 })
|
||||
walkTurnOpening([
|
||||
// The turn record is in; the host has not recorded "second" yet.
|
||||
[opened, submissions, [unrecorded('second', 'second')]],
|
||||
// Recorded after the turn record, not yet handed over.
|
||||
[
|
||||
[...opened, userMessage('second', 7, 'second')],
|
||||
[...submissions, submission('second', { acceptedSequence: 7 })],
|
||||
[]
|
||||
],
|
||||
[steered, [...submissions, handedOver], []],
|
||||
// Codex echoes the steer before the send that opened the turn, then that send.
|
||||
[steered, [warm, first, echoed(handedOver)], []],
|
||||
[steered, [warm, echoed(first), echoed(handedOver)], []]
|
||||
])
|
||||
})
|
||||
|
||||
// Two messages queued behind /compact, or sent while Stopping: "second" is accepted above the
|
||||
// first send's handover, and the first send's turn record lands before "second" is handed over.
|
||||
it('draws it where it lands at every step when it was accepted above the first send', () => {
|
||||
const { submissions, warm, first, opened, steered, echoed } = turnOpening()
|
||||
const [warmUp, warmTurn, firstRow, turnRecord] = opened
|
||||
if (!warmUp || !warmTurn || !firstRow || !turnRecord) {
|
||||
throw new Error('expected the warm-up, the first send and its turn record')
|
||||
}
|
||||
const queuedAbove = [warmUp, warmTurn, userMessage('second', 4, 'second'), firstRow, turnRecord]
|
||||
const queued = submission('second', { acceptedSequence: 4 })
|
||||
const handedOver = { ...queued, handedOverAt: NOW + 10 }
|
||||
walkTurnOpening([
|
||||
[queuedAbove, [...submissions, queued], []],
|
||||
// The first send echoes while "second" is still queued.
|
||||
[queuedAbove, [warm, echoed(first), queued], []],
|
||||
[steered, [...submissions, handedOver], []],
|
||||
[steered, [warm, first, echoed(handedOver)], []],
|
||||
[steered, [warm, echoed(first), echoed(handedOver)], []]
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe('a send a Stop took back before the agent started it', () => {
|
||||
let restoreViewport = (): void => {}
|
||||
beforeAll(() => {
|
||||
restoreViewport = installNativeChatMessageListTestViewport()
|
||||
})
|
||||
afterAll(() => restoreViewport())
|
||||
afterEach(cleanup)
|
||||
|
||||
const STOP_ROW = 'Stopped manually'
|
||||
const THREAD: AgentJournalTurnScope = { kind: 'thread' }
|
||||
let sequence = 0
|
||||
|
||||
function item(
|
||||
itemId: string,
|
||||
body: AgentJournalItemBody,
|
||||
turnScope: AgentJournalTurnScope = THREAD
|
||||
): AgentJournalRenderItem {
|
||||
sequence += 1
|
||||
return { itemId, revision: 0, sequence, observedAt: sequence, body, turnScope }
|
||||
}
|
||||
|
||||
const sent = (id: string, text: string) =>
|
||||
item(agentJournalSubmissionKey(id), {
|
||||
kind: 'message',
|
||||
role: 'user',
|
||||
blocks: [{ type: 'text', text }]
|
||||
})
|
||||
|
||||
function turn(
|
||||
itemId: string,
|
||||
userId: string,
|
||||
seconds: number,
|
||||
end: { state: 'completed' | 'interrupted'; outcome: 'success' | 'cancellation' }
|
||||
) {
|
||||
return item(itemId, {
|
||||
kind: 'turn',
|
||||
turnId: itemId,
|
||||
...end,
|
||||
userItemId: agentJournalSubmissionKey(userId),
|
||||
startedAt: 1_000,
|
||||
completedAt: 1_000 + seconds * 1_000
|
||||
})
|
||||
}
|
||||
|
||||
function warmUp(): AgentJournalRenderItem[] {
|
||||
return [
|
||||
sent('warm-up', 'warm up'),
|
||||
turn('t1', 'warm-up', 3, { state: 'completed', outcome: 'success' }),
|
||||
item(
|
||||
't1-answer',
|
||||
{ kind: 'message', role: 'assistant', blocks: [{ type: 'text', text: 'Warmed up.' }] },
|
||||
{ kind: 'turn', turnItemId: 't1' }
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
function submission(
|
||||
clientMessageId: string,
|
||||
overrides: Partial<AgentJournalSubmission> = {}
|
||||
): AgentJournalSubmission {
|
||||
return {
|
||||
clientMessageId,
|
||||
fence: 1,
|
||||
payloadFingerprint: clientMessageId,
|
||||
dispatchState: 'accepted',
|
||||
providerItemId: null,
|
||||
reason: null,
|
||||
submittedAt: 1,
|
||||
resolvedAt: 2,
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
|
||||
const stopped = (id: string, overrides: Partial<AgentJournalSubmission> = {}) =>
|
||||
submission(id, { dispatchState: 'rejected', reason: DISPATCH_REJECTED_CANCELLED, ...overrides })
|
||||
|
||||
function journalList(
|
||||
items: AgentJournalRenderItem[],
|
||||
submissions: AgentJournalSubmission[],
|
||||
live: { isWorking: boolean; workingStartedAt: number | null } = {
|
||||
isWorking: false,
|
||||
workingStartedAt: null
|
||||
}
|
||||
): React.JSX.Element {
|
||||
return (
|
||||
<NativeChatMessageList
|
||||
session={{
|
||||
messages: projectStructuredAgentSessionMessages(items, [], submissions),
|
||||
status: 'ready',
|
||||
sessionId: 'session-1',
|
||||
agent: 'codex',
|
||||
hasMore: false,
|
||||
loadingEarlier: false,
|
||||
olderHistoryGeneration: 0,
|
||||
loadEarlier: vi.fn(),
|
||||
readPhase: 'ready'
|
||||
}}
|
||||
journalItems={items}
|
||||
journalSubmissions={submissions}
|
||||
settledTurns={selectStructuredAgentSettledTurns(items, submissions)}
|
||||
isWorking={live.isWorking}
|
||||
workingStartedAt={live.workingStartedAt}
|
||||
expandSignal={false}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function follows(later: HTMLElement, earlier: HTMLElement): boolean {
|
||||
return Boolean(earlier.compareDocumentPosition(later) & Node.DOCUMENT_POSITION_FOLLOWING)
|
||||
}
|
||||
|
||||
it('keeps no clock it showed while the send waited on its turn', () => {
|
||||
const items = [...warmUp(), sent('never-ran', 'look around')]
|
||||
const { rerender } = render(
|
||||
journalList(
|
||||
items,
|
||||
[submission('warm-up'), submission('never-ran', { dispatchState: 'pending' })],
|
||||
{
|
||||
isWorking: true,
|
||||
workingStartedAt: Date.now() - 5_000
|
||||
}
|
||||
)
|
||||
)
|
||||
expect(screen.getByText('Working for 5s')).toBeInTheDocument()
|
||||
|
||||
rerender(journalList(items, [submission('warm-up'), stopped('never-ran')]))
|
||||
|
||||
expect(screen.getAllByText(/^(Worked|Working) for/).map((node) => node.textContent)).toEqual([
|
||||
'Worked for 3s'
|
||||
])
|
||||
expect(follows(screen.getByText(STOP_ROW), screen.getByText('look around'))).toBe(true)
|
||||
})
|
||||
})
|
||||
-163
@@ -1,163 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { cleanup, screen } from '@testing-library/react'
|
||||
import { render } from '../../messages/actions/native-chat-tooltip-test-harness'
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
const unusedChatLeaves = vi.hoisted(() => ({
|
||||
inlineVisual: vi.fn(() => {
|
||||
throw new Error('Unexpected inline visual in transcript fixture')
|
||||
}),
|
||||
openSender: vi.fn(() => {
|
||||
throw new Error('Unexpected sender navigation in transcript fixture')
|
||||
})
|
||||
}))
|
||||
vi.mock('../../media/visuals/NativeChatInlineVisual', () => ({
|
||||
NativeChatInlineVisual: unusedChatLeaves.inlineVisual
|
||||
}))
|
||||
vi.mock('@/lib/open-agent-message-sender', () => ({
|
||||
openAgentMessageSender: unusedChatLeaves.openSender
|
||||
}))
|
||||
import type {
|
||||
AgentJournalItemBody,
|
||||
AgentJournalRenderItem
|
||||
} from '../../../../../../shared/agent-session/journal/agent-session-journal-types'
|
||||
import type { AgentJournalTurnScope } from '../../../../../../shared/agent-session/journal/agent-session-journal-turn-scope'
|
||||
import type { NativeChatMessage } from '../../../../../../shared/native-chat/native-chat-types'
|
||||
import type { NativeChatLiveSession } from '../../session/terminal/read/native-chat-live-session-contract'
|
||||
import { NativeChatMessageList } from '../../NativeChatMessageList'
|
||||
import { installNativeChatMessageListTestViewport } from '../../viewport/virtualization/native-chat-message-list-test-viewport'
|
||||
|
||||
let restoreViewport = (): void => {}
|
||||
beforeAll(() => {
|
||||
restoreViewport = installNativeChatMessageListTestViewport()
|
||||
})
|
||||
afterAll(() => restoreViewport())
|
||||
afterEach(cleanup)
|
||||
|
||||
const text = (
|
||||
id: string,
|
||||
role: NativeChatMessage['role'],
|
||||
body: string,
|
||||
timestamp: number
|
||||
): NativeChatMessage => ({
|
||||
id,
|
||||
role,
|
||||
blocks: [{ type: 'text', text: body }],
|
||||
timestamp,
|
||||
source: 'transcript'
|
||||
})
|
||||
const toolRun = (id: string, timestamp: number): NativeChatMessage => ({
|
||||
id,
|
||||
role: 'assistant',
|
||||
blocks: [{ type: 'tool-call', name: 'Bash', input: { command: 'sleep 5' }, state: 'completed' }],
|
||||
timestamp,
|
||||
source: 'transcript'
|
||||
})
|
||||
|
||||
// The journal records B mid-turn before A’s remaining output; B’s own turn opens after A ends.
|
||||
const messages = [
|
||||
text('user-a', 'user', 'Run the first job', 1),
|
||||
toolRun('a-tool-1', 2),
|
||||
text('user-b', 'user', 'Then run the second job', 3),
|
||||
toolRun('a-tool-2', 4),
|
||||
text('a-answer', 'assistant', 'FIRST DONE', 5),
|
||||
text('b-answer', 'assistant', 'SECOND DONE', 6)
|
||||
]
|
||||
|
||||
/** With `statesScope` false the rows carry no turn scope, as a host older than turn scopes writes. */
|
||||
function journal(bState: 'running' | 'completed', statesScope: boolean): AgentJournalRenderItem[] {
|
||||
const thread: AgentJournalTurnScope = { kind: 'thread' }
|
||||
const inTurn = (turnItemId: string): AgentJournalTurnScope => ({ kind: 'turn', turnItemId })
|
||||
const row = (
|
||||
itemId: string,
|
||||
body: AgentJournalItemBody,
|
||||
turnScope: AgentJournalTurnScope,
|
||||
sequence: number
|
||||
): AgentJournalRenderItem => ({
|
||||
itemId,
|
||||
revision: 0,
|
||||
sequence,
|
||||
observedAt: sequence,
|
||||
body,
|
||||
...(statesScope ? { turnScope } : {})
|
||||
})
|
||||
const said = (role: 'user' | 'assistant'): AgentJournalItemBody => ({
|
||||
kind: 'message',
|
||||
role,
|
||||
blocks: []
|
||||
})
|
||||
return [
|
||||
row('user-a', said('user'), thread, 1),
|
||||
row(
|
||||
'turn-a',
|
||||
{ kind: 'turn', turnId: 'turn-a', state: 'completed', userItemId: 'user-a' },
|
||||
thread,
|
||||
2
|
||||
),
|
||||
row('a-tool-1', said('assistant'), inTurn('turn-a'), 3),
|
||||
// Handed over while A runs, so the host scopes it to A's turn until its own opens.
|
||||
row('user-b', said('user'), inTurn('turn-a'), 4),
|
||||
row('a-tool-2', said('assistant'), inTurn('turn-a'), 5),
|
||||
row('a-answer', said('assistant'), inTurn('turn-a'), 6),
|
||||
row(
|
||||
'turn-b',
|
||||
{ kind: 'turn', turnId: 'turn-b', state: bState, userItemId: 'user-b' },
|
||||
thread,
|
||||
7
|
||||
),
|
||||
row('b-answer', said('assistant'), inTurn('turn-b'), 8)
|
||||
]
|
||||
}
|
||||
|
||||
const session = (status: NativeChatLiveSession['status']): NativeChatLiveSession => ({
|
||||
messages,
|
||||
status,
|
||||
sessionId: 'session-1',
|
||||
agent: 'claude',
|
||||
hasMore: false,
|
||||
loadingEarlier: false,
|
||||
olderHistoryGeneration: 0,
|
||||
loadEarlier: vi.fn(),
|
||||
readPhase: 'ready'
|
||||
})
|
||||
|
||||
function expectInOrder(...nodes: Element[]): void {
|
||||
for (const [index, node] of nodes.slice(1).entries()) {
|
||||
expect(nodes[index]!.compareDocumentPosition(node)).toBe(Node.DOCUMENT_POSITION_FOLLOWING)
|
||||
}
|
||||
}
|
||||
|
||||
const bar = (label: string | RegExp): Element =>
|
||||
screen.getByText(label).closest('[data-native-chat-turn-status]')!
|
||||
|
||||
describe.each([['states each row’s turn', true]])(
|
||||
'a message the provider answered after the running turn, on a host that %s',
|
||||
(_host, statesScope) => {
|
||||
it("draws A's remaining rows and answer under A's bar, then B's bubble and turn", () => {
|
||||
render(
|
||||
<NativeChatMessageList
|
||||
session={session('working')}
|
||||
journalItems={journal('running', statesScope)}
|
||||
journalSubmissions={[]}
|
||||
isWorking
|
||||
workingStartedAt={Date.now() - 1000}
|
||||
settledTurns={new Map([['user-a', { startedAt: 1, workedSeconds: 17 }]])}
|
||||
expandSignal={false}
|
||||
/>
|
||||
)
|
||||
|
||||
expectInOrder(
|
||||
screen.getByText('Run the first job'),
|
||||
bar('Worked for 17s'),
|
||||
screen.getByText('FIRST DONE'),
|
||||
screen.getByText('Then run the second job'),
|
||||
bar(/Working for/),
|
||||
screen.getByText('SECOND DONE')
|
||||
)
|
||||
})
|
||||
}
|
||||
)
|
||||
-538
@@ -1,538 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { cleanup, screen, fireEvent } from '@testing-library/react'
|
||||
import { render } from '../../messages/actions/native-chat-tooltip-test-harness'
|
||||
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
const unusedChatLeaves = vi.hoisted(() => ({
|
||||
inlineVisual: vi.fn(() => {
|
||||
throw new Error('Unexpected inline visual in transcript fixture')
|
||||
}),
|
||||
openSender: vi.fn(() => {
|
||||
throw new Error('Unexpected sender navigation in transcript fixture')
|
||||
})
|
||||
}))
|
||||
vi.mock('../../media/visuals/NativeChatInlineVisual', () => ({
|
||||
NativeChatInlineVisual: unusedChatLeaves.inlineVisual
|
||||
}))
|
||||
vi.mock('@/lib/open-agent-message-sender', () => ({
|
||||
openAgentMessageSender: unusedChatLeaves.openSender
|
||||
}))
|
||||
|
||||
import {
|
||||
agentJournalItemKey,
|
||||
agentJournalSubmissionKey
|
||||
} from '../../../../../../shared/agent-session/journal/agent-session-journal-item-key'
|
||||
|
||||
import type {
|
||||
AgentJournalItemBody,
|
||||
AgentJournalRenderItem,
|
||||
AgentJournalSubmission
|
||||
} from '../../../../../../shared/agent-session/journal/agent-session-journal-types'
|
||||
import type { AgentJournalTurnScope } from '../../../../../../shared/agent-session/journal/agent-session-journal-turn-scope'
|
||||
|
||||
import { projectStructuredAgentSessionMessages } from '../../../../../../shared/agent-session/view/structured-agent-session-message-projection'
|
||||
|
||||
import { selectStructuredAgentSettledTurns } from '../../../../../../shared/agent-session/view/structured-agent-session-turn-timing'
|
||||
|
||||
import { NativeChatMessageList } from '../../NativeChatMessageList'
|
||||
|
||||
import { installNativeChatMessageListTestViewport } from '../../viewport/virtualization/native-chat-message-list-test-viewport'
|
||||
|
||||
import type { NativeChatLiveSession } from '../../session/terminal/read/native-chat-live-session-contract'
|
||||
|
||||
import type { NativeChatMessage } from '../../../../../../shared/native-chat/native-chat-types'
|
||||
|
||||
{
|
||||
const THREAD: AgentJournalTurnScope = { kind: 'thread' }
|
||||
const inTurn = (turnItemId: string): AgentJournalTurnScope => ({ kind: 'turn', turnItemId })
|
||||
let sequence = 0
|
||||
|
||||
function item(
|
||||
itemId: string,
|
||||
body: AgentJournalItemBody,
|
||||
turnScope: AgentJournalTurnScope = THREAD
|
||||
): AgentJournalRenderItem {
|
||||
sequence += 1
|
||||
return { itemId, revision: 0, sequence, observedAt: sequence, body, turnScope }
|
||||
}
|
||||
const say = (
|
||||
itemId: string,
|
||||
role: 'user' | 'assistant',
|
||||
text: string,
|
||||
scope: AgentJournalTurnScope = THREAD
|
||||
) => item(itemId, { kind: 'message', role, blocks: [{ type: 'text', text }] }, scope)
|
||||
const work = (itemId: string, scope: AgentJournalTurnScope) =>
|
||||
item(
|
||||
itemId,
|
||||
{
|
||||
kind: 'message',
|
||||
role: 'assistant',
|
||||
blocks: [{ type: 'tool-call', name: 'shell', input: { command: 'ls' }, state: 'completed' }]
|
||||
},
|
||||
scope
|
||||
)
|
||||
const settledTurn = (itemId: string, userItemId: string, seconds: number, start: number) =>
|
||||
item(itemId, {
|
||||
kind: 'turn',
|
||||
turnId: itemId,
|
||||
state: 'completed',
|
||||
outcome: 'success',
|
||||
userItemId,
|
||||
startedAt: start,
|
||||
completedAt: start + seconds * 1000
|
||||
})
|
||||
|
||||
function fruitTurn(): AgentJournalRenderItem[] {
|
||||
return [
|
||||
say('u1', 'user', 'List three fruits'),
|
||||
settledTurn('t1', 'u1', 4, 1_000),
|
||||
say('t1-narration', 'assistant', 'Thinking about fruit.', inTurn('t1')),
|
||||
work('t1-work', inTurn('t1')),
|
||||
say('t1-answer', 'assistant', 'Apple, banana, cherry.', inTurn('t1'))
|
||||
]
|
||||
}
|
||||
|
||||
function journalList(
|
||||
items: AgentJournalRenderItem[],
|
||||
submissions: AgentJournalSubmission[] = [],
|
||||
{
|
||||
isWorking = false,
|
||||
workingStartedAt = null,
|
||||
hostTiming = true
|
||||
}: { isWorking?: boolean; workingStartedAt?: number | null; hostTiming?: boolean } = {}
|
||||
): React.JSX.Element {
|
||||
return (
|
||||
<NativeChatMessageList
|
||||
session={{
|
||||
messages: projectStructuredAgentSessionMessages(items, [], submissions),
|
||||
status: 'ready',
|
||||
sessionId: 'session-1',
|
||||
agent: 'codex',
|
||||
hasMore: false,
|
||||
loadingEarlier: false,
|
||||
olderHistoryGeneration: 0,
|
||||
loadEarlier: vi.fn(),
|
||||
readPhase: 'ready'
|
||||
}}
|
||||
journalItems={items}
|
||||
journalSubmissions={submissions}
|
||||
settledTurns={
|
||||
hostTiming ? selectStructuredAgentSettledTurns(items, submissions) : undefined
|
||||
}
|
||||
isWorking={isWorking}
|
||||
workingStartedAt={workingStartedAt}
|
||||
expandSignal={false}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function renderJournal(
|
||||
items: AgentJournalRenderItem[],
|
||||
submissions: AgentJournalSubmission[] = [],
|
||||
isWorking = false
|
||||
): void {
|
||||
render(journalList(items, submissions, { isWorking }))
|
||||
}
|
||||
|
||||
function follows(later: HTMLElement, earlier: HTMLElement): boolean {
|
||||
return Boolean(earlier.compareDocumentPosition(later) & Node.DOCUMENT_POSITION_FOLLOWING)
|
||||
}
|
||||
|
||||
describe('NativeChatMessageList turns from the turn record', () => {
|
||||
let restoreViewport = (): void => {}
|
||||
beforeAll(() => {
|
||||
restoreViewport = installNativeChatMessageListTestViewport()
|
||||
})
|
||||
afterAll(() => restoreViewport())
|
||||
afterEach(cleanup)
|
||||
|
||||
it('draws a message waiting behind /compact after the compaction, never above it', () => {
|
||||
const compactEntry = agentJournalSubmissionKey('cmd-1')
|
||||
const commandTurn = agentJournalItemKey({
|
||||
provider: 'orca',
|
||||
clientMessageId: 'command-turn:cmd-1'
|
||||
})
|
||||
const held = agentJournalSubmissionKey('held')
|
||||
const items = [
|
||||
...fruitTurn(),
|
||||
item(compactEntry, {
|
||||
kind: 'message',
|
||||
role: 'user',
|
||||
blocks: [{ type: 'text', text: '/compact' }],
|
||||
command: { name: 'compact' }
|
||||
}),
|
||||
settledTurn(commandTurn, compactEntry, 2, 10_000),
|
||||
// Accepted while the command ran, so written before the command's result.
|
||||
say(held, 'user', 'Say DONE'),
|
||||
item(
|
||||
'command-result',
|
||||
{ kind: 'status', text: 'Conversation compacted.', presentation: 'compaction' },
|
||||
inTurn(commandTurn)
|
||||
)
|
||||
]
|
||||
const submission = (
|
||||
clientMessageId: string,
|
||||
handedOverAt?: number
|
||||
): AgentJournalSubmission => ({
|
||||
clientMessageId,
|
||||
fence: 1,
|
||||
payloadFingerprint: clientMessageId,
|
||||
dispatchState:
|
||||
handedOverAt === undefined && clientMessageId === 'held' ? 'pending' : 'accepted',
|
||||
providerItemId: null,
|
||||
reason: null,
|
||||
submittedAt: 9_000,
|
||||
resolvedAt: null,
|
||||
handoverRecorded: true,
|
||||
...(handedOverAt !== undefined ? { handedOverAt } : {})
|
||||
})
|
||||
// The command settled; the loop has not yet handed the held message over.
|
||||
renderJournal(items, [submission('cmd-1', 9_500), submission('held')])
|
||||
|
||||
expect(
|
||||
follows(
|
||||
screen.getByText('Say DONE'),
|
||||
screen.getByRole('separator', { name: 'Context compacted' })
|
||||
)
|
||||
).toBe(true)
|
||||
})
|
||||
|
||||
it('folds a turn the provider resumed on its own under its own status', () => {
|
||||
const wake = agentJournalItemKey({
|
||||
provider: 'legacy',
|
||||
agent: 'claude',
|
||||
sessionId: 'session-1',
|
||||
recordId: 'turn-lifecycle:wake'
|
||||
})
|
||||
const items = [
|
||||
...fruitTurn(),
|
||||
// Claude keys a resumed turn's record on itself: no message opened it.
|
||||
settledTurn(wake, wake, 9, 20_000),
|
||||
say('wake-narration', 'assistant', 'The background build finished.', inTurn(wake)),
|
||||
work('wake-work', inTurn(wake)),
|
||||
say('wake-answer', 'assistant', 'All tests pass now.', inTurn(wake))
|
||||
]
|
||||
renderJournal(items)
|
||||
|
||||
const previousStatus = screen.getByText('Worked for 4s')
|
||||
const ownStatus = screen.getByText('Worked for 9s')
|
||||
expect(follows(ownStatus, screen.getByText('Apple, banana, cherry.'))).toBe(true)
|
||||
expect(follows(ownStatus, previousStatus)).toBe(true)
|
||||
expect(screen.queryByText('The background build finished.')).toBeNull()
|
||||
expect(screen.getByText('All tests pass now.')).toBeInTheDocument()
|
||||
expect(screen.getAllByRole('button', { name: 'Toggle turn details' })).toHaveLength(2)
|
||||
})
|
||||
|
||||
it('clocks a turn the provider opened under its own key, not the user turn before it', () => {
|
||||
const wake = 'wake'
|
||||
const ask = say('u1', 'user', 'List three fruits')
|
||||
const answer = (state: 'running' | 'completed') => [
|
||||
ask,
|
||||
item('t1', { kind: 'turn', turnId: 't1', state, userItemId: 'u1' }),
|
||||
say('t1-answer', 'assistant', 'Apple, banana, cherry.', inTurn('t1'))
|
||||
]
|
||||
const local = { hostTiming: false }
|
||||
const { rerender } = render(
|
||||
journalList(answer('running'), [], {
|
||||
...local,
|
||||
isWorking: true,
|
||||
workingStartedAt: Date.now() - 7_000
|
||||
})
|
||||
)
|
||||
rerender(journalList(answer('completed'), [], local))
|
||||
expect(screen.getByText('Worked for 7s')).toBeInTheDocument()
|
||||
|
||||
const woken = [
|
||||
...answer('completed'),
|
||||
item(wake, { kind: 'turn', turnId: wake, state: 'running', userItemId: 'claude:wake' }),
|
||||
say('wake-answer', 'assistant', 'Checking the background build.', inTurn(wake))
|
||||
]
|
||||
rerender(journalList(woken, [], { ...local, isWorking: true, workingStartedAt: Date.now() }))
|
||||
expect(screen.getByText('Worked for 7s')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('draws a message waiting behind a running /compact after its live activity', () => {
|
||||
const compactEntry = agentJournalSubmissionKey('cmd-1')
|
||||
const commandTurn = agentJournalItemKey({
|
||||
provider: 'orca',
|
||||
clientMessageId: 'command-turn:cmd-1'
|
||||
})
|
||||
const held = agentJournalSubmissionKey('held')
|
||||
const items = [
|
||||
...fruitTurn(),
|
||||
item(compactEntry, {
|
||||
kind: 'message',
|
||||
role: 'user',
|
||||
blocks: [{ type: 'text', text: '/compact' }],
|
||||
command: { name: 'compact' }
|
||||
}),
|
||||
item(commandTurn, {
|
||||
kind: 'turn',
|
||||
turnId: 'compact:cmd-1',
|
||||
state: 'running',
|
||||
userItemId: compactEntry,
|
||||
startedAt: 10_000
|
||||
}),
|
||||
say(held, 'user', 'Say DONE')
|
||||
]
|
||||
const submission = (
|
||||
clientMessageId: string,
|
||||
handedOverAt?: number
|
||||
): AgentJournalSubmission => ({
|
||||
clientMessageId,
|
||||
fence: 1,
|
||||
payloadFingerprint: clientMessageId,
|
||||
dispatchState: handedOverAt === undefined ? 'pending' : 'accepted',
|
||||
providerItemId: null,
|
||||
reason: null,
|
||||
submittedAt: 9_000,
|
||||
resolvedAt: null,
|
||||
handoverRecorded: true,
|
||||
...(handedOverAt !== undefined ? { handedOverAt } : {})
|
||||
})
|
||||
const { container } = render(
|
||||
journalList(items, [submission('cmd-1', 9_500), submission('held')], {
|
||||
isWorking: true,
|
||||
workingStartedAt: 10_000
|
||||
})
|
||||
)
|
||||
|
||||
const activity = container.querySelector<HTMLElement>('[data-native-chat-turn-activity]')
|
||||
expect(activity).not.toBeNull()
|
||||
expect(follows(activity!, screen.getByText('/compact'))).toBe(true)
|
||||
expect(follows(screen.getByText('Say DONE'), activity!)).toBe(true)
|
||||
})
|
||||
|
||||
it("keeps a steer on its way into an ordinary running turn above that turn's activity", () => {
|
||||
const steer = agentJournalSubmissionKey('steer')
|
||||
const items = [
|
||||
say('u1', 'user', 'List three fruits'),
|
||||
item('t1', {
|
||||
kind: 'turn',
|
||||
turnId: 't1',
|
||||
state: 'running',
|
||||
userItemId: 'u1',
|
||||
startedAt: 10_000
|
||||
}),
|
||||
say('t1-narration', 'assistant', 'Thinking about fruit.', inTurn('t1')),
|
||||
say(steer, 'user', 'Make it four')
|
||||
]
|
||||
const { container } = render(
|
||||
journalList(
|
||||
items,
|
||||
[
|
||||
{
|
||||
clientMessageId: 'steer',
|
||||
fence: 1,
|
||||
payloadFingerprint: 'steer',
|
||||
dispatchState: 'pending',
|
||||
providerItemId: null,
|
||||
reason: null,
|
||||
submittedAt: 10_500,
|
||||
resolvedAt: null,
|
||||
handoverRecorded: true
|
||||
}
|
||||
],
|
||||
{ isWorking: true, workingStartedAt: 10_000 }
|
||||
)
|
||||
)
|
||||
|
||||
const activity = container.querySelector<HTMLElement>('[data-native-chat-turn-activity]')
|
||||
expect(activity).not.toBeNull()
|
||||
expect(follows(activity!, screen.getByText('Make it four'))).toBe(true)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
describe('NativeChatMessageList host-settled turn timing', () => {
|
||||
afterEach(cleanup)
|
||||
|
||||
let restoreViewport = (): void => {}
|
||||
|
||||
beforeAll(() => {
|
||||
restoreViewport = installNativeChatMessageListTestViewport()
|
||||
})
|
||||
|
||||
afterAll(() => restoreViewport())
|
||||
|
||||
const session: NativeChatLiveSession = {
|
||||
messages: [
|
||||
{
|
||||
id: 'user-settled',
|
||||
role: 'user',
|
||||
blocks: [{ type: 'text', text: 'Settled on the host' }],
|
||||
timestamp: 1,
|
||||
source: 'transcript'
|
||||
},
|
||||
{
|
||||
id: 'assistant-settled',
|
||||
role: 'assistant',
|
||||
blocks: [{ type: 'text', text: 'Done.' }],
|
||||
timestamp: 2,
|
||||
source: 'transcript'
|
||||
}
|
||||
],
|
||||
status: 'ready',
|
||||
sessionId: 'session-1',
|
||||
agent: 'codex',
|
||||
hasMore: false,
|
||||
loadingEarlier: false,
|
||||
olderHistoryGeneration: 0,
|
||||
loadEarlier: vi.fn(),
|
||||
readPhase: 'ready'
|
||||
}
|
||||
|
||||
it('does not render a local completed duration when the host cannot verify the end', () => {
|
||||
const now = vi.spyOn(Date, 'now').mockReturnValue(1_000)
|
||||
const unknownTurns = new Map([['user-settled', null]])
|
||||
try {
|
||||
const { rerender } = render(
|
||||
<NativeChatMessageList
|
||||
session={session}
|
||||
isWorking
|
||||
workingStartedAt={1_000}
|
||||
settledTurns={unknownTurns}
|
||||
expandSignal={false}
|
||||
/>
|
||||
)
|
||||
now.mockReturnValue(60_000)
|
||||
rerender(
|
||||
<NativeChatMessageList
|
||||
session={session}
|
||||
isWorking={false}
|
||||
workingStartedAt={null}
|
||||
settledTurns={unknownTurns}
|
||||
expandSignal={false}
|
||||
/>
|
||||
)
|
||||
expect(screen.queryByText(/Worked for/)).not.toBeInTheDocument()
|
||||
} finally {
|
||||
now.mockRestore()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('a thought joining a work run', () => {
|
||||
let restoreViewport = (): void => {}
|
||||
beforeAll(() => {
|
||||
restoreViewport = installNativeChatMessageListTestViewport()
|
||||
})
|
||||
afterAll(() => restoreViewport())
|
||||
afterEach(cleanup)
|
||||
|
||||
const STARTED = 1_000
|
||||
|
||||
const prompt: NativeChatMessage = {
|
||||
id: 'user-1',
|
||||
role: 'user',
|
||||
blocks: [{ type: 'text', text: 'Start the task' }],
|
||||
timestamp: STARTED - 500,
|
||||
source: 'transcript'
|
||||
}
|
||||
|
||||
const command: NativeChatMessage = {
|
||||
id: 'tool-1',
|
||||
role: 'assistant',
|
||||
blocks: [
|
||||
{ type: 'tool-call', name: 'Bash', input: { command: 'ls logs' }, state: 'completed' }
|
||||
],
|
||||
timestamp: STARTED,
|
||||
source: 'transcript'
|
||||
}
|
||||
|
||||
function reasoning(state: 'running' | 'completed'): NativeChatMessage {
|
||||
return {
|
||||
id: 'r-1',
|
||||
role: 'reasoning',
|
||||
blocks: [{ type: 'text', text: 'Weighing two approaches' }],
|
||||
timestamp: STARTED + 50,
|
||||
source: 'transcript',
|
||||
state,
|
||||
...(state === 'completed' ? { completedAt: STARTED + 12_000 } : {})
|
||||
}
|
||||
}
|
||||
|
||||
function journal(rows: readonly NativeChatMessage[]): AgentJournalRenderItem[] {
|
||||
return [
|
||||
{
|
||||
itemId: prompt.id,
|
||||
revision: 1,
|
||||
sequence: 1,
|
||||
observedAt: 1,
|
||||
body: { kind: 'message', role: 'user', blocks: prompt.blocks }
|
||||
},
|
||||
{
|
||||
itemId: 'turn-1',
|
||||
revision: 1,
|
||||
sequence: 2,
|
||||
observedAt: 2,
|
||||
body: { kind: 'turn', turnId: 'turn-1', state: 'running', userItemId: prompt.id }
|
||||
},
|
||||
...rows.map((row, index) => ({
|
||||
itemId: row.id,
|
||||
revision: 1,
|
||||
sequence: index + 3,
|
||||
observedAt: index + 3,
|
||||
body: {
|
||||
kind: 'message' as const,
|
||||
role: row.role,
|
||||
blocks: row.blocks,
|
||||
...(row.state ? { state: row.state } : {})
|
||||
}
|
||||
}))
|
||||
]
|
||||
}
|
||||
|
||||
function list(
|
||||
rows: readonly NativeChatMessage[],
|
||||
props: Partial<React.ComponentProps<typeof NativeChatMessageList>> = {}
|
||||
): React.JSX.Element {
|
||||
const session: NativeChatLiveSession = {
|
||||
messages: [prompt, ...rows],
|
||||
status: 'working',
|
||||
sessionId: 'session-1',
|
||||
agent: 'claude',
|
||||
hasMore: false,
|
||||
loadingEarlier: false,
|
||||
olderHistoryGeneration: 0,
|
||||
loadEarlier: vi.fn(),
|
||||
readPhase: 'ready'
|
||||
}
|
||||
return (
|
||||
<NativeChatMessageList
|
||||
session={session}
|
||||
journalItems={journal(rows)}
|
||||
isWorking
|
||||
expandSignal={false}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const runHeader = (): HTMLElement =>
|
||||
document.querySelector<HTMLElement>('[data-native-chat-tool-run-state]')!
|
||||
|
||||
it('keeps a thought the reader opened live open inside its collapsed run', () => {
|
||||
const { rerender } = render(list([command, reasoning('running')]))
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Thinking' }))
|
||||
expect(screen.getByText('Weighing two approaches')).toBeInTheDocument()
|
||||
|
||||
rerender(list([command, reasoning('completed')]))
|
||||
expect(runHeader()).toHaveAttribute('aria-expanded', 'false')
|
||||
expect(screen.queryByText('Weighing two approaches')).toBeNull()
|
||||
|
||||
fireEvent.click(runHeader())
|
||||
expect(screen.getByRole('button', { name: /Thought for/ })).toHaveAttribute(
|
||||
'aria-expanded',
|
||||
'true'
|
||||
)
|
||||
expect(screen.getByText('Weighing two approaches')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
}
|
||||
-259
@@ -1,259 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
|
||||
import { cleanup, screen } from '@testing-library/react'
|
||||
import { render } from '../../messages/actions/native-chat-tooltip-test-harness'
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
const unusedChatLeaves = vi.hoisted(() => ({
|
||||
inlineVisual: vi.fn(() => {
|
||||
throw new Error('Unexpected inline visual in transcript fixture')
|
||||
}),
|
||||
openSender: vi.fn(() => {
|
||||
throw new Error('Unexpected sender navigation in transcript fixture')
|
||||
})
|
||||
}))
|
||||
vi.mock('../../media/visuals/NativeChatInlineVisual', () => ({
|
||||
NativeChatInlineVisual: unusedChatLeaves.inlineVisual
|
||||
}))
|
||||
vi.mock('@/lib/open-agent-message-sender', () => ({
|
||||
openAgentMessageSender: unusedChatLeaves.openSender
|
||||
}))
|
||||
import type { NativeChatLiveSession } from '../../session/terminal/read/native-chat-live-session-contract'
|
||||
import { NativeChatMessageList } from '../../NativeChatMessageList'
|
||||
import { installNativeChatMessageListTestViewport } from '../../viewport/virtualization/native-chat-message-list-test-viewport'
|
||||
import type {
|
||||
AgentJournalItemBody,
|
||||
AgentJournalRenderItem
|
||||
} from '../../../../../../shared/agent-session/journal/agent-session-journal-types'
|
||||
import type { AgentJournalTurnScope } from '../../../../../../shared/agent-session/journal/agent-session-journal-turn-scope'
|
||||
|
||||
let restoreViewport = (): void => {}
|
||||
beforeAll(() => {
|
||||
restoreViewport = installNativeChatMessageListTestViewport()
|
||||
})
|
||||
afterAll(() => restoreViewport())
|
||||
afterEach(cleanup)
|
||||
|
||||
const session: NativeChatLiveSession = {
|
||||
messages: [
|
||||
{
|
||||
id: 'assistant-1',
|
||||
role: 'assistant',
|
||||
blocks: [{ type: 'text', text: 'Selectable agent response.' }],
|
||||
timestamp: 1,
|
||||
source: 'transcript'
|
||||
}
|
||||
],
|
||||
status: 'ready',
|
||||
sessionId: 'session-1',
|
||||
agent: 'codex',
|
||||
hasMore: false,
|
||||
loadingEarlier: false,
|
||||
olderHistoryGeneration: 0,
|
||||
loadEarlier: vi.fn(),
|
||||
readPhase: 'ready'
|
||||
}
|
||||
|
||||
// Live turns show a prompt clock and tail activity; settled turns retain the clock bar.
|
||||
describe('NativeChatMessageList turn indicator', () => {
|
||||
it('replaces a bridge ask row and settles it from the FIFO tool result', () => {
|
||||
const user = {
|
||||
id: 'bridge-user',
|
||||
role: 'user' as const,
|
||||
blocks: [{ type: 'text' as const, text: 'Help me choose' }],
|
||||
timestamp: 1,
|
||||
source: 'transcript' as const
|
||||
}
|
||||
const call = {
|
||||
id: 'bridge-ask',
|
||||
role: 'assistant' as const,
|
||||
blocks: [
|
||||
{
|
||||
type: 'tool-call' as const,
|
||||
name: 'AskUserQuestion',
|
||||
input: { questions: [{ question: 'Which branch?' }] }
|
||||
}
|
||||
],
|
||||
timestamp: 2,
|
||||
source: 'transcript' as const
|
||||
}
|
||||
const bridgeSession: NativeChatLiveSession = {
|
||||
...session,
|
||||
agent: 'claude',
|
||||
messages: [user, call],
|
||||
transcriptLifecycle: { state: 'working', turnId: user.id, timestamp: 1 }
|
||||
}
|
||||
const rendered = render(
|
||||
<NativeChatMessageList session={bridgeSession} isWorking={false} expandSignal={false} />
|
||||
)
|
||||
|
||||
expect(screen.getByText('Awaiting user input:')).toBeInTheDocument()
|
||||
expect(screen.getByText('Which branch?')).toBeInTheDocument()
|
||||
expect(screen.queryByText(/AskUserQuestion/)).toBeNull()
|
||||
|
||||
rendered.rerender(
|
||||
<NativeChatMessageList
|
||||
session={{
|
||||
...bridgeSession,
|
||||
messages: [
|
||||
user,
|
||||
call,
|
||||
{
|
||||
id: 'bridge-answer',
|
||||
role: 'tool',
|
||||
blocks: [{ type: 'tool-result', output: 'main' }],
|
||||
timestamp: 3,
|
||||
source: 'transcript'
|
||||
}
|
||||
]
|
||||
}}
|
||||
isWorking={false}
|
||||
expandSignal={false}
|
||||
/>
|
||||
)
|
||||
|
||||
expect(screen.queryByText('Awaiting user input:')).toBeNull()
|
||||
expect(screen.getByText('Asked:')).toBeInTheDocument()
|
||||
expect(screen.queryByText(/AskUserQuestion/)).toBeNull()
|
||||
})
|
||||
|
||||
it.each([
|
||||
["a host that states each row's turn", true],
|
||||
['a host that states none', false]
|
||||
])(
|
||||
'keeps the live bar under the prompt that opened the running turn, not a message sent mid-turn, on %s',
|
||||
(_, scoped) => {
|
||||
const prompt = (id: string, text: string): NativeChatLiveSession['messages'][number] => ({
|
||||
id,
|
||||
role: 'user',
|
||||
blocks: [{ type: 'text', text }],
|
||||
timestamp: 1,
|
||||
source: 'transcript'
|
||||
})
|
||||
const messages = [
|
||||
prompt('user-a', 'Run four sleeps'),
|
||||
{
|
||||
id: 'tool-a',
|
||||
role: 'assistant' as const,
|
||||
blocks: [
|
||||
{
|
||||
type: 'tool-call' as const,
|
||||
name: 'Bash',
|
||||
input: { command: 'sleep 15' },
|
||||
state: 'running' as const
|
||||
}
|
||||
],
|
||||
timestamp: 2,
|
||||
source: 'transcript' as const
|
||||
},
|
||||
prompt('user-b', 'Also say banana')
|
||||
]
|
||||
// B was handed over while A's turn runs, so a host that states scopes puts it in that turn.
|
||||
const t1: AgentJournalTurnScope = { kind: 'turn', turnItemId: 't1' }
|
||||
const thread: AgentJournalTurnScope = { kind: 'thread' }
|
||||
const row = (
|
||||
itemId: string,
|
||||
sequence: number,
|
||||
body: AgentJournalItemBody,
|
||||
turnScope: AgentJournalTurnScope
|
||||
): AgentJournalRenderItem => ({
|
||||
itemId,
|
||||
revision: 1,
|
||||
sequence,
|
||||
observedAt: sequence,
|
||||
body,
|
||||
...(scoped ? { turnScope } : {})
|
||||
})
|
||||
const journal = (t1State: 'running' | 'completed', t2State?: 'running' | 'completed') => [
|
||||
row('user-a', 1, { kind: 'message', role: 'user', blocks: [] }, thread),
|
||||
row('t1', 2, { kind: 'turn', turnId: 't1', state: t1State, userItemId: 'user-a' }, thread),
|
||||
row('tool-a', 3, { kind: 'message', role: 'assistant', blocks: [] }, t1),
|
||||
row('user-b', 4, { kind: 'message', role: 'user', blocks: [] }, t1),
|
||||
...(t2State
|
||||
? [
|
||||
row(
|
||||
't2',
|
||||
5,
|
||||
{ kind: 'turn', turnId: 't2', state: t2State, userItemId: 'user-b' },
|
||||
thread
|
||||
)
|
||||
]
|
||||
: [])
|
||||
]
|
||||
const list = (props: Partial<React.ComponentProps<typeof NativeChatMessageList>>) => (
|
||||
<NativeChatMessageList
|
||||
session={{ ...session, status: 'working', messages }}
|
||||
isWorking
|
||||
expandSignal={false}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
// B was sent while A's turn runs: the host's record still names A as the running turn's opener.
|
||||
const { rerender } = render(
|
||||
list({
|
||||
workingStartedAt: Date.now() - 5000,
|
||||
settledTurns: new Map(),
|
||||
journalItems: journal('running')
|
||||
})
|
||||
)
|
||||
const barA = screen.getByText('Working for 5s').closest('[data-native-chat-turn-status]')
|
||||
expect(screen.getAllByText(/Working for/)).toHaveLength(1)
|
||||
expect(screen.getByText('Run four sleeps').compareDocumentPosition(barA!)).toBe(
|
||||
Node.DOCUMENT_POSITION_FOLLOWING
|
||||
)
|
||||
expect(barA!.compareDocumentPosition(screen.getByText('Also say banana'))).toBe(
|
||||
Node.DOCUMENT_POSITION_FOLLOWING
|
||||
)
|
||||
|
||||
// A’s bar settles under A; tool scope or journal order keeps A’s work inside its fold.
|
||||
const expectSettledUnderA = () => {
|
||||
const settledA = screen
|
||||
.getByText('Worked for 17s')
|
||||
.closest('[data-native-chat-turn-status]')
|
||||
expect(screen.getByText('Run four sleeps').compareDocumentPosition(settledA!)).toBe(
|
||||
Node.DOCUMENT_POSITION_FOLLOWING
|
||||
)
|
||||
expect(settledA!.compareDocumentPosition(screen.getByText('Also say banana'))).toBe(
|
||||
Node.DOCUMENT_POSITION_FOLLOWING
|
||||
)
|
||||
}
|
||||
|
||||
// B's own turn opens: A settles in place and B counts from A's end.
|
||||
rerender(
|
||||
list({
|
||||
workingStartedAt: Date.now() - 1000,
|
||||
settledTurns: new Map([['user-a', { startedAt: 1, workedSeconds: 17 }]]),
|
||||
journalItems: journal('completed', 'running')
|
||||
})
|
||||
)
|
||||
expectSettledUnderA()
|
||||
const barB = screen.getByText('Working for 1s').closest('[data-native-chat-turn-status]')
|
||||
expect(screen.getByText('Also say banana').compareDocumentPosition(barB!)).toBe(
|
||||
Node.DOCUMENT_POSITION_FOLLOWING
|
||||
)
|
||||
|
||||
rerender(
|
||||
list({
|
||||
isWorking: false,
|
||||
session: { ...session, status: 'ready', messages },
|
||||
workingStartedAt: null,
|
||||
settledTurns: new Map([
|
||||
['user-a', { startedAt: 1, workedSeconds: 17 }],
|
||||
['user-b', { startedAt: 2, workedSeconds: 51 }]
|
||||
]),
|
||||
journalItems: journal('completed', 'completed')
|
||||
})
|
||||
)
|
||||
expectSettledUnderA()
|
||||
expect(
|
||||
screen
|
||||
.getByText('Also say banana')
|
||||
.compareDocumentPosition(screen.getByText('Worked for 51s'))
|
||||
).toBe(Node.DOCUMENT_POSITION_FOLLOWING)
|
||||
expect(screen.queryByText(/Working for/)).toBeNull()
|
||||
}
|
||||
)
|
||||
})
|
||||
+5
-5
@@ -1,14 +1,14 @@
|
||||
// Keep persistence thin; the draft store owns merge and lifecycle policy.
|
||||
|
||||
import type {
|
||||
NativeChatComposerDraftStorage,
|
||||
StoredNativeChatComposerDraft
|
||||
} from './native-chat-composer-draft-storage'
|
||||
import {
|
||||
committedTransaction,
|
||||
indexedDbConnection,
|
||||
settledRequest
|
||||
} from '@/lib/indexeddb-connection'
|
||||
} from '@/app-shell/storage/indexeddb-connection'
|
||||
import type {
|
||||
NativeChatComposerDraftStorage,
|
||||
StoredNativeChatComposerDraft
|
||||
} from './native-chat-composer-draft-storage'
|
||||
|
||||
const DATABASE_NAME = 'orca-native-chat-composer-drafts'
|
||||
const DATABASE_VERSION = 1
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import type { AppState } from '../../../store/types'
|
||||
import type { NativeChatComposerDraftOwner } from '@/components/native-chat/drafts/native-chat-composer-draft-storage'
|
||||
import {
|
||||
nativeChatDraftScopeTabId,
|
||||
structuredAgentSessionIdOfDraftScope
|
||||
@@ -7,8 +5,10 @@ import {
|
||||
import {
|
||||
chatWorkspaceByTabId,
|
||||
structuredChatWorkspacesBySessionId
|
||||
} from '../../../lib/structured-chat-tab-index'
|
||||
} from '../../../lib/agent-session/tab-identity/structured-chat-tab-index'
|
||||
import { resolveWorktreeOperationRoute } from '../../../lib/workspace/ownership/worktree-operation-route'
|
||||
import type { AppState } from '../../../store/types'
|
||||
import type { NativeChatComposerDraftOwner } from '@/components/native-chat/drafts/native-chat-composer-draft-storage'
|
||||
|
||||
function workspaceOfDraftScope(
|
||||
state: Pick<AppState, 'tabsByWorktree' | 'unifiedTabsByWorktree'>,
|
||||
|
||||
+8
-10
@@ -1,17 +1,12 @@
|
||||
import { useAppStore } from '@/store'
|
||||
import type { AppState } from '@/store/types'
|
||||
import type { RuntimeFileOperationArgs } from '@/runtime/files/runtime-file-client-types'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import { runtimeTargetForOwnerEnvironment } from '@/runtime/rpc/targets/runtime-client-target'
|
||||
import type { RuntimeClientTarget } from '../../../../../../shared/runtime-client-target'
|
||||
import {
|
||||
resolveWorktreeOperationRouteResult,
|
||||
type WorktreeOperationRouteResolution
|
||||
} from '@/lib/workspace/ownership/worktree-operation-route'
|
||||
import { resolveWorktreeOperationRouteResult } from '@/lib/workspace/ownership/worktree-operation-route'
|
||||
import type { WorktreeOperationRouteResolution } from '@/lib/workspace/ownership/worktree-operation-route'
|
||||
import {
|
||||
createNativeChatTabOwnerSelector,
|
||||
findNativeChatTabOwnerWorktreeId
|
||||
} from '../../pane/ownership/native-chat-tab-owner'
|
||||
import { captureDirectSshMutationExpectation } from '@/lib/ssh-mutation-expectation'
|
||||
import { captureDirectSshMutationExpectation } from '@/runtime/hosts/ssh/ssh-mutation-expectation'
|
||||
import {
|
||||
parseExecutionHostId,
|
||||
toRuntimeExecutionHostId
|
||||
@@ -21,12 +16,15 @@ import { resolveNativeChatTabDirectory } from '../../pane/routing/native-chat-ta
|
||||
import { resolveOwner } from '@/lib/workspace/ownership/resolve-owner'
|
||||
import { useMemo } from 'react'
|
||||
import { shallow } from 'zustand/shallow'
|
||||
import { firstRegisteredStructuredChatTab } from '@/lib/structured-chat-tab-index'
|
||||
import { firstRegisteredStructuredChatTab } from '@/lib/agent-session/tab-identity/structured-chat-tab-index'
|
||||
import {
|
||||
selectDetectedWorktreesByRepo,
|
||||
selectFolderWorkspaces,
|
||||
selectWorktreesByRepo
|
||||
} from '@/store/workspaces/catalog/workspace-record-fields'
|
||||
import type { AppState } from '@/store/types'
|
||||
import type { RuntimeFileOperationArgs } from '@/runtime/files/runtime-file-client-types'
|
||||
import type { RuntimeClientTarget } from '../../../../../../shared/runtime-client-target'
|
||||
|
||||
/** The transcript must not read until ownership and its path are both known. */
|
||||
export type NativeChatImageRuntimeContext = RuntimeFileOperationArgs | null
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { useAppStore } from '@/store'
|
||||
import { captureLinkOpenIntent } from '@/lib/link-open-intent'
|
||||
import { beginLinkOpenRequest } from '@/lib/link-open-request'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import { captureLinkOpenIntent } from '@/lib/links/placement/link-open-intent'
|
||||
import { beginLinkOpenRequest } from '@/lib/links/link-open-request'
|
||||
import { useContext, useEffect, useRef, useState } from 'react'
|
||||
import { SquareArrowOutUpRight } from 'lucide-react'
|
||||
import { toast } from 'sonner'
|
||||
import type { ArtifactWriteRequest } from '../../../../../../shared/artifacts/artifacts'
|
||||
import { ArtifactPublishButton } from '@/components/artifacts/ArtifactPublishButton'
|
||||
import { ArtifactPublishPreparationError } from '@/components/artifacts/artifact-publish-flow'
|
||||
import { Button } from '@/components/ui/button'
|
||||
@@ -20,9 +19,10 @@ import {
|
||||
import { NATIVE_CHAT_VISUAL_RESERVED_HEIGHT, NativeChatVisualFrame } from './NativeChatVisualFrame'
|
||||
import { observeTranscriptVisibility } from '../images/native-chat-image-visibility'
|
||||
import { NativeChatForwardedGestureContext } from '../../viewport/scroll/native-chat-reader-scroll-input'
|
||||
import type { NativeChatVisualOwner } from './native-chat-visual-owner'
|
||||
import { readNativeChatVisual } from './native-chat-visual-read-client'
|
||||
import { useNativeChatVisualDocument } from './use-native-chat-visual-document'
|
||||
import type { ArtifactWriteRequest } from '../../../../../../shared/artifacts/artifacts'
|
||||
import type { NativeChatVisualOwner } from './native-chat-visual-owner'
|
||||
|
||||
export function NativeChatVisualUnavailable(): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
|
||||
+3
-3
@@ -1,6 +1,5 @@
|
||||
import { useMemo } from 'react'
|
||||
import { openDesktopStructuredSession } from '@/lib/activate-ai-vault-structured-session'
|
||||
import type { NativeChatStructuredViewProps } from '@/components/native-chat/native-chat-view-types'
|
||||
import { openDesktopStructuredSession } from '@/lib/agent-session/open/activate-ai-vault-structured-session'
|
||||
import {
|
||||
NativeChatForkContext,
|
||||
NativeChatForkedFromContext,
|
||||
@@ -8,9 +7,10 @@ import {
|
||||
NativeChatSideChatForkPointContext
|
||||
} from '@/components/native-chat/messages/actions/native-chat-fork-context'
|
||||
import { NativeChatRewindContext } from '@/components/native-chat/messages/actions/native-chat-rewind-context'
|
||||
import { useNativeChatTabOwnerWorktreeId } from '@/components/native-chat/pane/ownership/use-native-chat-tab-owner'
|
||||
import type { NativeChatStructuredViewProps } from '@/components/native-chat/native-chat-view-types'
|
||||
import type { NativeChatRewindSurface } from '@/components/native-chat/messages/actions/use-native-chat-rewind-host'
|
||||
import type { NativeChatPaneForks } from '@/components/native-chat/messages/actions/use-native-chat-fork'
|
||||
import { useNativeChatTabOwnerWorktreeId } from '@/components/native-chat/pane/ownership/use-native-chat-tab-owner'
|
||||
|
||||
/** What the pane's transcript rows offer: rewind on prompts, fork on responses, and the chat a
|
||||
* "Forked from" divider opens. */
|
||||
|
||||
+6
-6
@@ -2,19 +2,19 @@ import { Fragment } from 'react'
|
||||
import { ArrowUpRight } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { useTranslate } from '@/i18n/use-translate'
|
||||
import { openAgentMessageSender } from '@/lib/open-agent-message-sender'
|
||||
import type { RuntimeClientTarget } from '../../../../../../shared/runtime-client-target'
|
||||
import { openAgentMessageSender } from '@/lib/agent-session/open/open-agent-message-sender'
|
||||
import { useNativeChatVisualOwner } from '../../media/visuals/native-chat-visual-owner'
|
||||
import {
|
||||
agentMessageSendersShown,
|
||||
type AgentMessageSender,
|
||||
type AgentMessageSource
|
||||
import { agentMessageSendersShown } from '../../../../../../shared/agent-session/agent-session-message-source'
|
||||
import type {
|
||||
AgentMessageSender,
|
||||
AgentMessageSource
|
||||
} from '../../../../../../shared/agent-session/agent-session-message-source'
|
||||
import {
|
||||
unnamedSenderLabel,
|
||||
useAgentMessageSenderLabel
|
||||
} from './native-chat-agent-message-sender-label'
|
||||
import { useAgentMessageSenderOpens } from './native-chat-agent-message-sender-view'
|
||||
import type { RuntimeClientTarget } from '../../../../../../shared/runtime-client-target'
|
||||
|
||||
/** Link a sender only where its one resolution can open something; otherwise a plain name. */
|
||||
export function NativeChatAgentMessageSenders({
|
||||
|
||||
+9
-94
@@ -4,22 +4,19 @@ import {
|
||||
structuredAgentSessionTabId
|
||||
} from '../../../../../../shared/agent-session/view/structured-agent-session-projection'
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { cleanup, render, screen } from '@testing-library/react'
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
||||
import { useAppStore } from '@/store'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import { foldAgentSessionConversationNames } from '../../../../../../shared/agent-session/agent-session-conversation-names'
|
||||
import type { AgentSessionConversationNames } from '../../../../../../shared/agent-session/agent-session-conversation-names'
|
||||
import { testOrcaSessionId } from '../../../../../../shared/orca-session-address-test-fixture'
|
||||
import { NativeChatAgentMessageSenders } from './NativeChatAgentMessageSenders'
|
||||
import type {
|
||||
AgentSessionConversationName,
|
||||
AgentSessionStatusSummary
|
||||
} from '../../../../../../shared/agent-session/agent-session-wire'
|
||||
import {
|
||||
foldAgentSessionConversationNames,
|
||||
type AgentSessionConversationNames
|
||||
} from '../../../../../../shared/agent-session/agent-session-conversation-names'
|
||||
import type { AgentMessageSource } from '../../../../../../shared/agent-session/agent-session-message-source'
|
||||
import type { AgentStatusEntry } from '../../../../../../shared/agent-status/contracts/agent-status-types'
|
||||
import { testOrcaSessionId } from '../../../../../../shared/orca-session-address-test-fixture'
|
||||
import type { Tab } from '../../../../../../shared/tab-types'
|
||||
import { NativeChatAgentMessageSenders } from './NativeChatAgentMessageSenders'
|
||||
|
||||
const feeds = vi.hoisted(
|
||||
() =>
|
||||
@@ -63,14 +60,14 @@ vi.mock('@/runtime/native-chat/status/structured-agent-session-status-feed', ()
|
||||
}
|
||||
}))
|
||||
const openAgentMessageSender = vi.hoisted(() => vi.fn())
|
||||
vi.mock('@/lib/open-agent-message-sender', () => ({ openAgentMessageSender }))
|
||||
vi.mock('@/lib/agent-session/open/open-agent-message-sender', () => ({ openAgentMessageSender }))
|
||||
|
||||
const ROOT = testOrcaSessionId('root-chat')
|
||||
const RECIPIENT = 'recipient'
|
||||
const SENDER = 'sender'
|
||||
const PANE = 'terminal:11111111-1111-4111-8111-111111111111'
|
||||
void 'terminal:11111111-1111-4111-8111-111111111111'
|
||||
const initial = useAppStore.getInitialState()
|
||||
const providerA = { key: 'session_id' as const, id: 'provider-a' }
|
||||
void { key: 'session_id' as const, id: 'provider-a' }
|
||||
|
||||
function summary(sessionId: string): AgentSessionStatusSummary {
|
||||
return {
|
||||
@@ -131,21 +128,6 @@ function publish(
|
||||
listener()
|
||||
}
|
||||
}
|
||||
function row(provider = providerA, agentType = 'claude'): AgentStatusEntry {
|
||||
return {
|
||||
paneKey: PANE,
|
||||
terminalHandle: 'term-a',
|
||||
worktreeId: SENDER,
|
||||
state: 'working',
|
||||
prompt: '',
|
||||
updatedAt: 1,
|
||||
stateStartedAt: 1,
|
||||
stateHistory: [],
|
||||
agentType,
|
||||
providerSession: provider,
|
||||
connectionId: null
|
||||
}
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
openAgentMessageSender.mockClear()
|
||||
@@ -167,73 +149,6 @@ afterEach(() => {
|
||||
feeds.clear()
|
||||
})
|
||||
|
||||
it('shows a chat sender by its current rename', () => {
|
||||
const renamed = 'Production Release Scan & Compatibility Review'
|
||||
useAppStore.setState({ unifiedTabsByWorktree: { [SENDER]: [tab(ROOT, '')] } })
|
||||
const feed = feeds.get('local')!
|
||||
const status = feed.snapshot
|
||||
expect(feed.names.has(ROOT)).toBe(false)
|
||||
render(<NativeChatAgentMessageSenders from={source()} chatWorktreeId={RECIPIENT} />)
|
||||
expect(screen.getByText('Original sender')).toBeInTheDocument()
|
||||
act(() => publish('local', undefined, [{ sessionId: ROOT, conversationName: null }]))
|
||||
expect(screen.getByText('Original sender')).toBeInTheDocument()
|
||||
act(() => publish('local', undefined, [{ sessionId: ROOT, conversationName: renamed }]))
|
||||
const name = screen.getByText(renamed)
|
||||
expect(name).toBeInTheDocument()
|
||||
fireEvent.click(name)
|
||||
expect(openAgentMessageSender).toHaveBeenCalledWith(
|
||||
source(),
|
||||
source().senders[0],
|
||||
RECIPIENT,
|
||||
undefined,
|
||||
undefined,
|
||||
renamed
|
||||
)
|
||||
expect(feed.snapshot).toBe(status)
|
||||
expect(status.get(ROOT)?.conversationName).toBeUndefined()
|
||||
})
|
||||
|
||||
it.each([false, true])(
|
||||
'keeps CLI A saved name after provider B and a terminal rename reuse the shell (%s queued)',
|
||||
(queued) => {
|
||||
const terminal = {
|
||||
id: 'terminal',
|
||||
ptyId: 'pty',
|
||||
worktreeId: SENDER,
|
||||
title: 'Claude Code',
|
||||
customTitle: 'Resumed A',
|
||||
color: null,
|
||||
sortOrder: 0,
|
||||
createdAt: 0
|
||||
}
|
||||
useAppStore.setState({
|
||||
agentStatusByPaneKey: { [PANE]: row() },
|
||||
tabsByWorktree: { [SENDER]: [terminal] }
|
||||
})
|
||||
const from = source(true)
|
||||
render(<NativeChatAgentMessageSenders from={from} chatWorktreeId={RECIPIENT} queued={queued} />)
|
||||
expect(screen.getByText('Original sender')).toBeInTheDocument()
|
||||
act(() => {
|
||||
useAppStore.setState({
|
||||
agentStatusByPaneKey: { [PANE]: row({ key: 'session_id', id: 'provider-b' }) },
|
||||
tabsByWorktree: { [SENDER]: [{ ...terminal, customTitle: 'Renamed B' }] }
|
||||
})
|
||||
})
|
||||
const link = screen.getByText('Original sender')
|
||||
expect(link).toBeInTheDocument()
|
||||
fireEvent.click(link)
|
||||
expect(openAgentMessageSender).toHaveBeenCalledWith(
|
||||
from,
|
||||
from.senders[0],
|
||||
RECIPIENT,
|
||||
undefined,
|
||||
undefined,
|
||||
'Original sender'
|
||||
)
|
||||
expect(feeds.get('local')!.activations).toBe(0)
|
||||
}
|
||||
)
|
||||
|
||||
it('uses the same published /clear successor for the live sender label', () => {
|
||||
const live = testOrcaSessionId('22222222-2222-4222-8222-222222222222')
|
||||
publish('local', [summary(live)], [{ sessionId: live, conversationName: 'Continued sender' }])
|
||||
|
||||
+5
-4
@@ -4,13 +4,13 @@ import {
|
||||
} from '@/runtime/native-chat/agent-senders/agent-sender-associations'
|
||||
import { agentMessageSenderLabel } from '../../../../../../shared/agent-session/agent-message-presentation'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { useTranslate, type Translate } from '@/i18n/use-translate'
|
||||
import { useTranslate } from '@/i18n/use-translate'
|
||||
import type { Translate } from '@/i18n/use-translate'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import type { AppState } from '@/store/types'
|
||||
import {
|
||||
structuredChatTabBySessionId,
|
||||
structuredChatWorkspacesBySessionId
|
||||
} from '@/lib/structured-chat-tab-index'
|
||||
} from '@/lib/agent-session/tab-identity/structured-chat-tab-index'
|
||||
import { useStructuredConversationName } from '@/runtime/native-chat/naming/structured-conversation-name'
|
||||
import {
|
||||
structuredAgentSessionOwnerForTab,
|
||||
@@ -18,10 +18,11 @@ import {
|
||||
resolveStructuredAgentSessionOwner,
|
||||
executionHostIdForStructuredTarget
|
||||
} from '@/runtime/native-chat/session-ownership/structured-agent-session-owner'
|
||||
import { getKnownExecutionHostIdForWorktree } from '@/lib/workspace/ownership/worktree-runtime-owner'
|
||||
import type { AppState } from '@/store/types'
|
||||
import type { RuntimeClientTarget } from '../../../../../../shared/runtime-client-target'
|
||||
import type { AgentMessageSender } from '../../../../../../shared/agent-session/agent-session-message-source'
|
||||
import type { Tab } from '../../../../../../shared/tab-types'
|
||||
import { getKnownExecutionHostIdForWorktree } from '@/lib/workspace/ownership/worktree-runtime-owner'
|
||||
|
||||
export function unnamedSenderLabel(t: Translate = translate): string {
|
||||
return t('components.native-chat.agentMessage.unnamedSender', 'an agent')
|
||||
|
||||
-163
@@ -1,163 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { act, cleanup } from '@testing-library/react'
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
callRuntimeRpc: vi.fn(),
|
||||
activatePane: vi.fn(),
|
||||
activateChat: vi.fn(async () => true),
|
||||
paneUnavailable: vi.fn(),
|
||||
toastInfo: vi.fn(),
|
||||
focusRenderer: vi.fn(() => true),
|
||||
focusRuntime: vi.fn(async () => undefined)
|
||||
}))
|
||||
vi.mock('@/components/terminal-pane/links/handles/terminal-handle-links', () => ({
|
||||
focusRendererTerminalHandle: mocks.focusRenderer,
|
||||
focusRuntimeTerminalHandle: mocks.focusRuntime
|
||||
}))
|
||||
vi.mock('sonner', async (original) => ({
|
||||
...(await original<Record<string, unknown>>()),
|
||||
toast: { info: mocks.toastInfo, error: vi.fn() }
|
||||
}))
|
||||
vi.mock('@/runtime/rpc/calls/runtime-rpc-call', async (original) => ({
|
||||
...(await original<Record<string, unknown>>()),
|
||||
callRuntimeRpc: mocks.callRuntimeRpc
|
||||
}))
|
||||
vi.mock('@/components/sidebar/workspace-card/activity/use-worktree-agent-activation', () => ({
|
||||
activateWorktreeAgentPane: mocks.activatePane
|
||||
}))
|
||||
vi.mock('@/components/terminal-pane/agent-status/stale-agent-row', async (original) => ({
|
||||
...(await original<Record<string, unknown>>()),
|
||||
showAgentPaneUnavailable: mocks.paneUnavailable
|
||||
}))
|
||||
vi.mock('@/lib/activate-ai-vault-structured-session', async (original) => ({
|
||||
...(await original<Record<string, unknown>>()),
|
||||
activateAiVaultStructuredSession: mocks.activateChat
|
||||
}))
|
||||
vi.mock('@/lib/agent-session/structured-agent-session-tab-activation', async (original) => ({
|
||||
...(await original<Record<string, unknown>>()),
|
||||
activateStructuredAgentSessionById: mocks.activateChat
|
||||
}))
|
||||
|
||||
import { useAppStore } from '@/store'
|
||||
|
||||
import { openAgentMessageSender } from '@/lib/open-agent-message-sender'
|
||||
|
||||
import {
|
||||
agentMessageSenderOpens,
|
||||
resolveAgentMessageSenderTarget
|
||||
} from './native-chat-agent-message-sender-target'
|
||||
|
||||
import { initialStore, resetSenderStore, status } from './native-chat-agent-sender.test-fixture'
|
||||
import type { AgentSenderPublication } from '../../../../../../shared/agent-sender-associations'
|
||||
import type {
|
||||
AgentMessageSender,
|
||||
AgentMessageSource
|
||||
} from '../../../../../../shared/agent-session/agent-session-message-source'
|
||||
|
||||
import { FLOATING_TERMINAL_WORKTREE_ID } from '../../../../../../shared/constants'
|
||||
import { handleGlobalSessionEvent } from '@/runtime/web-session-tabs-sync/global-session-events'
|
||||
import { receivedAgentSenderPublications } from '@/runtime/web-session-tabs-sync/received-agent-sender-publications'
|
||||
import { VisibilityResumeCoordinator } from '@/runtime/web-session-tabs-sync/visibility-resume-coordinator'
|
||||
import { resetWebSessionTabsSnapshotFreshnessForTests } from '@/runtime/web-session-tabs-sync/tracking-lifecycle'
|
||||
|
||||
let revision = 0
|
||||
/** Each delivery is the host's next revision, as a publishing host stamps it. */
|
||||
const publication = (
|
||||
associations: AgentSenderPublication['associations'] = []
|
||||
): AgentSenderPublication => ({
|
||||
associations,
|
||||
principals: [],
|
||||
attachments: [],
|
||||
revision: { epoch: 'host', revision: ++revision }
|
||||
})
|
||||
const terminal = (handle = 'term_0', agent: AgentMessageSender['agent'] = 'claude') => ({
|
||||
party: { address: handle, terminalHandle: handle, orcaSessionId: null },
|
||||
name: 'Worker',
|
||||
agent
|
||||
})
|
||||
const sourceOf = (sender: AgentMessageSender): AgentMessageSource => ({
|
||||
kind: 'agent',
|
||||
senders: [sender],
|
||||
orchestration: null
|
||||
})
|
||||
|
||||
/** What the card draws for this sender: its avatar, and whether its name is a link. */
|
||||
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers({ toFake: ['Date'] })
|
||||
vi.setSystemTime(2_000_000)
|
||||
resetSenderStore()
|
||||
for (const mock of Object.values(mocks)) {
|
||||
mock.mockClear()
|
||||
}
|
||||
})
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
useAppStore.setState(initialStore, true)
|
||||
vi.useRealTimers()
|
||||
})
|
||||
|
||||
it("asks a paired host for its floating terminal's sender, which this window never mirrors", async () => {
|
||||
resetWebSessionTabsSnapshotFreshnessForTests()
|
||||
const paired = { kind: 'environment', environmentId: 'paired' } as const
|
||||
const frame = (worktree: string, revision: number, identity: string) => {
|
||||
const scope = publication([{ identity, paneKey: status(0).paneKey, worktreeId: worktree }])
|
||||
return {
|
||||
type: 'updated',
|
||||
worktree,
|
||||
publicationEpoch: 'host',
|
||||
snapshotVersion: revision,
|
||||
activeGroupId: null,
|
||||
activeTabId: null,
|
||||
activeTabType: null,
|
||||
tabs: [],
|
||||
agentSenderAssociations: { ...scope, revision: { epoch: 'paired-host', revision } }
|
||||
}
|
||||
}
|
||||
// The window's real stream receipt, as for any paired frame.
|
||||
const receive = (event: ReturnType<typeof frame>) =>
|
||||
act(() =>
|
||||
handleGlobalSessionEvent({
|
||||
environmentId: 'paired',
|
||||
expectedEnvironmentConnectionGeneration: 0,
|
||||
expectedTrackingGeneration: 0,
|
||||
visibilityGeneration: 0,
|
||||
isCurrent: () => true,
|
||||
event,
|
||||
response: { id: 'stream', ok: true, result: event, _meta: { runtimeId: 'rt-1' } },
|
||||
awaitingVisibilityResumeInventory: { value: false },
|
||||
coordinator: new VisibilityResumeCoordinator({
|
||||
environments: [],
|
||||
environmentIdBySubscriptionSpec: [],
|
||||
omissions: new Map(),
|
||||
activeRuntimeWorktreeKey: () => null
|
||||
})
|
||||
})
|
||||
)
|
||||
const floatingTabs = useAppStore.getState().tabsByWorktree[FLOATING_TERMINAL_WORKTREE_ID]
|
||||
receive(frame(FLOATING_TERMINAL_WORKTREE_ID, 1, 'term_float'))
|
||||
receive(frame('workspace', 2, 'term_0'))
|
||||
const state = useAppStore.getState()
|
||||
expect(Object.keys(state.agentSenderPublicationsByHost['runtime:paired'])).toEqual(['workspace'])
|
||||
expect(state.tabsByWorktree[FLOATING_TERMINAL_WORKTREE_ID]).toBe(floatingTabs)
|
||||
const floating = terminal('term_float')
|
||||
const resolved = resolveAgentMessageSenderTarget(state, floating, 'workspace', paired, undefined)
|
||||
expect(resolved).toEqual({ kind: 'gone', sender: 'terminal' })
|
||||
expect(agentMessageSenderOpens(resolved, floating)).toBe(true)
|
||||
await openAgentMessageSender(
|
||||
sourceOf(floating),
|
||||
floating,
|
||||
'workspace',
|
||||
paired,
|
||||
undefined,
|
||||
'Worker'
|
||||
)
|
||||
expect(mocks.callRuntimeRpc).toHaveBeenCalled()
|
||||
expect(mocks.activatePane).not.toHaveBeenCalled()
|
||||
// This machine's own floating terminal still publishes its senders.
|
||||
const local = receivedAgentSenderPublications({}, 'local', [
|
||||
frame(FLOATING_TERMINAL_WORKTREE_ID, 3, 'term_local')
|
||||
])
|
||||
expect(Object.keys(local.local)).toEqual([FLOATING_TERMINAL_WORKTREE_ID])
|
||||
})
|
||||
@@ -1,201 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { NativeChatHostSetupContext } from '../../host-access/native-chat-host-setup'
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
import { cleanup, fireEvent, screen, waitFor } from '@testing-library/react'
|
||||
import { render } from '../actions/native-chat-tooltip-test-harness'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
// Why: these fixtures have neither inline visual owners nor sender navigation.
|
||||
const unusedChatLeaves = vi.hoisted(() => ({
|
||||
inlineVisual: vi.fn(() => {
|
||||
throw new Error('Unexpected inline visual in transcript fixture')
|
||||
}),
|
||||
openSender: vi.fn(() => {
|
||||
throw new Error('Unexpected sender navigation in transcript fixture')
|
||||
})
|
||||
}))
|
||||
vi.mock('../../media/visuals/NativeChatInlineVisual', () => ({
|
||||
NativeChatInlineVisual: unusedChatLeaves.inlineVisual
|
||||
}))
|
||||
vi.mock('@/lib/open-agent-message-sender', () => ({
|
||||
openAgentMessageSender: unusedChatLeaves.openSender
|
||||
}))
|
||||
afterEach(() => {
|
||||
expect(unusedChatLeaves.inlineVisual).not.toHaveBeenCalled()
|
||||
expect(unusedChatLeaves.openSender).not.toHaveBeenCalled()
|
||||
})
|
||||
import type { NativeChatMessage } from '../../../../../../shared/native-chat/native-chat-types'
|
||||
import { MessageRow } from './NativeChatMessageRow'
|
||||
import type { NativeChatRewindSurface } from '../actions/use-native-chat-rewind-host'
|
||||
import { readNativeChatQuotableSelection } from '../../selection-quotes/native-chat-quote-selection'
|
||||
import type { AgentJournalSubmission } from '../../../../../../shared/agent-session/journal/agent-session-journal-types'
|
||||
import { agentJournalSubmissionKey } from '../../../../../../shared/agent-session/journal/agent-session-journal-item-key'
|
||||
import { useStructuredAgentSessionDeliveryNotices } from '../../session/structured/delivery/use-structured-agent-session-delivery-notices'
|
||||
|
||||
const confirm = vi.hoisted(() => vi.fn())
|
||||
vi.mock('@/lib/syntax-highlighting/oniguruma', async () => ({
|
||||
loadOniguruma: (await import('@/lib/syntax-highlighting/oniguruma-test-harness'))
|
||||
.loadNodeOniguruma
|
||||
}))
|
||||
vi.mock('@/components/confirmation-dialog-context', () => ({
|
||||
useConfirmationDialog: () => confirm
|
||||
}))
|
||||
|
||||
afterEach(cleanup)
|
||||
const signInView = { signingIn: false, signIn: vi.fn() }
|
||||
const setupView = { signIn: signInView, install: null }
|
||||
|
||||
function renderMessage(
|
||||
role: NativeChatMessage['role'],
|
||||
timestamp: number | null = 0,
|
||||
rewind?: NativeChatRewindSurface
|
||||
) {
|
||||
return render(
|
||||
<MessageRow
|
||||
message={{
|
||||
id: 'message',
|
||||
role,
|
||||
timestamp,
|
||||
source: 'transcript',
|
||||
blocks: [{ type: 'text', text: 'Message text' }]
|
||||
}}
|
||||
expandSignal={false}
|
||||
onScrollMessageToTop={vi.fn()}
|
||||
rewind={rewind}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
describe('MessageRow control visibility', () => {
|
||||
it('copies an assistant reply without its visual lines, which mean nothing outside Orca', async () => {
|
||||
const writeClipboardText = vi.fn().mockResolvedValue(undefined)
|
||||
Object.assign(window, { api: { ui: { writeClipboardText } } })
|
||||
|
||||
render(
|
||||
<MessageRow
|
||||
message={{
|
||||
id: 'message',
|
||||
role: 'assistant',
|
||||
timestamp: 0,
|
||||
source: 'transcript',
|
||||
blocks: [
|
||||
{
|
||||
type: 'text',
|
||||
text: 'Here it is.\n\n::orca-visual{file="usage.html" title="Usage"}\n\nDone.'
|
||||
}
|
||||
]
|
||||
}}
|
||||
expandSignal={false}
|
||||
onScrollMessageToTop={vi.fn()}
|
||||
/>
|
||||
)
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Copy message' }))
|
||||
|
||||
await waitFor(() => {
|
||||
expect(writeClipboardText).toHaveBeenCalledWith('Here it is.\n\nDone.')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('which messages can be quoted', () => {
|
||||
it.each([
|
||||
['assistant', 'Message text'],
|
||||
['user', undefined],
|
||||
['system', undefined]
|
||||
] as const)('a selection in a %s message', (role, quoted) => {
|
||||
const { container } = renderMessage(role)
|
||||
window.getSelection()!.selectAllChildren(screen.getByText('Message text'))
|
||||
|
||||
expect(readNativeChatQuotableSelection(container)?.text).toBe(quoted)
|
||||
})
|
||||
})
|
||||
|
||||
describe('what a user message says about its delivery', () => {
|
||||
function RecordedMessage({ submission }: { submission: AgentJournalSubmission }) {
|
||||
const notices = useStructuredAgentSessionDeliveryNotices({
|
||||
pending: [],
|
||||
submissions: [submission],
|
||||
journalItems: [],
|
||||
agentName: 'Codex',
|
||||
startFailures: []
|
||||
})
|
||||
const id = agentJournalSubmissionKey(submission.clientMessageId)
|
||||
return (
|
||||
<MessageRow
|
||||
message={{
|
||||
id,
|
||||
role: 'user',
|
||||
timestamp: 0,
|
||||
source: 'transcript',
|
||||
blocks: [{ type: 'text', text: 'Ignore failures outside this branch.' }]
|
||||
}}
|
||||
expandSignal={false}
|
||||
onScrollMessageToTop={vi.fn()}
|
||||
deliveryNotice={notices.get(id)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
it('lets a user sign in from the refused message when no composer notice is shown', () => {
|
||||
const { signIn } = signInView
|
||||
render(
|
||||
<NativeChatHostSetupContext.Provider value={setupView}>
|
||||
<RecordedMessage
|
||||
submission={{
|
||||
clientMessageId: 'signed-out',
|
||||
fence: 1,
|
||||
payloadFingerprint: 'signed-out',
|
||||
dispatchState: 'rejected',
|
||||
rejection: { kind: 'notSignedIn' },
|
||||
providerItemId: null,
|
||||
reason: 'Sign in to Pi.',
|
||||
submittedAt: 1,
|
||||
resolvedAt: 2
|
||||
}}
|
||||
/>
|
||||
</NativeChatHostSetupContext.Provider>
|
||||
)
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Sign in' }))
|
||||
expect(signIn).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it.each(['accepted', 'rejected', 'unknown'] as const)(
|
||||
'keeps a recorded steer Sending through handoff until it becomes %s',
|
||||
(dispatchState) => {
|
||||
const held: AgentJournalSubmission = {
|
||||
clientMessageId: 'steer',
|
||||
fence: 1,
|
||||
payloadFingerprint: 'steer',
|
||||
dispatchState: 'pending',
|
||||
providerItemId: null,
|
||||
reason: null,
|
||||
submittedAt: 1,
|
||||
resolvedAt: null,
|
||||
handoverRecorded: true
|
||||
}
|
||||
const { rerender } = render(<RecordedMessage submission={held} />)
|
||||
expect(screen.getByText('Sending…')).toBeInTheDocument()
|
||||
expect(screen.queryByRole('time')).toBeNull()
|
||||
|
||||
const handedOver = { ...held, handedOverAt: 2 }
|
||||
rerender(<RecordedMessage submission={handedOver} />)
|
||||
expect(screen.getByText('Sending…')).toBeInTheDocument()
|
||||
|
||||
rerender(
|
||||
<RecordedMessage
|
||||
submission={{
|
||||
...handedOver,
|
||||
dispatchState,
|
||||
resolvedAt: 3,
|
||||
reason: dispatchState === 'rejected' ? 'Codex refused the message.' : null
|
||||
}}
|
||||
/>
|
||||
)
|
||||
expect(screen.queryByText('Sending…')).toBeNull()
|
||||
expect(screen.getByRole('time')).toBeInTheDocument()
|
||||
if (dispatchState === 'rejected') {
|
||||
expect(screen.getByText('Codex refused the message.')).toBeInTheDocument()
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
-136
@@ -1,136 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { act, cleanup, fireEvent, render, within } from '@testing-library/react'
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
||||
import { TooltipProvider } from '@/components/ui/tooltip'
|
||||
import { useAppStore } from '@/store'
|
||||
|
||||
import type { Tab } from '../../../../../../shared/tab-types'
|
||||
import { createTabsSliceMockApi } from '@/store/slices/tabs/tabs-slice-test-harness'
|
||||
import { makeTabGroup } from '@/store/slices/tabs/tab-group.test-fixture'
|
||||
import {
|
||||
makeFolderWorkspace,
|
||||
makeUnifiedTab
|
||||
} from '../../../worktree-jump/worktree-jump-palette-test-fixtures'
|
||||
|
||||
import * as history from '../../../right-sidebar/ai-vault/scanning/ai-vault-panel-session-list-request'
|
||||
import type { NativeChatCliForkPreparation } from '@/lib/agent-session/resume/cli-fork/native-chat-cli-fork-preparation'
|
||||
import type { NativeChatStructuredViewProps } from '../../native-chat-view-types'
|
||||
|
||||
const mocks = vi.hoisted(() => ({ prepare: vi.fn(), launch: vi.fn(), close: vi.fn() }))
|
||||
vi.mock('@/store', async () => {
|
||||
const { createTestStore } = await import('@/store/testing/app-store-test-fixture')
|
||||
return { useAppStore: createTestStore() }
|
||||
})
|
||||
vi.mock('../../NativeChatView', async () => {
|
||||
const { nativeChatPaneHeader } = await import('./NativeChatPaneHeader')
|
||||
return {
|
||||
default: (props: NativeChatStructuredViewProps) => (
|
||||
<div className="native-chat-appearance" data-chat={props.tabId}>
|
||||
{nativeChatPaneHeader(props, 'folder:workspace', 'dark')}
|
||||
<output data-transcript={props.tabId}>{props.sessionId}</output>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
})
|
||||
vi.mock('@/lib/workspace/tabs/workspace-tab-commands', () => ({
|
||||
dispatchWorkspaceTabCommand: mocks.close
|
||||
}))
|
||||
vi.mock('@/lib/agent-session/resume/cli-fork/native-chat-cli-fork-preparation', () => ({
|
||||
prepareNativeChatCliFork: mocks.prepare
|
||||
}))
|
||||
vi.mock('@/lib/launch-ai-vault-session-and-reveal', () => ({
|
||||
launchAiVaultSessionAndReveal: mocks.launch
|
||||
}))
|
||||
vi.mock('@/lib/agent-session/resume/history/ai-vault-session-fork-startup', () => ({
|
||||
assertAiVaultCopiedSessionLaunchAllowed: () => {},
|
||||
buildAiVaultForkStartupForWorktree: () => ({ command: 'fixture-fork' })
|
||||
}))
|
||||
|
||||
import StructuredAgentSessionPaneOverlayLayer from '../routing/StructuredAgentSessionPaneOverlayLayer'
|
||||
|
||||
const workspace = 'folder:workspace'
|
||||
const initial = useAppStore.getInitialState()
|
||||
const fullRequest = vi.spyOn(history, 'resolveAiVaultPanelSessionListRequest')
|
||||
|
||||
const testWindow = window
|
||||
const originalApi = window.api
|
||||
const api = createTabsSliceMockApi()
|
||||
vi.stubGlobal('window', testWindow)
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
Object.assign(window, { api })
|
||||
useAppStore.setState(initial, true)
|
||||
useAppStore.setState({
|
||||
folderWorkspaces: [makeFolderWorkspace({ id: 'workspace', folderPath: '/repo' })]
|
||||
})
|
||||
})
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
useAppStore.setState(initial, true)
|
||||
Object.assign(window, { api: originalApi })
|
||||
})
|
||||
function seedChats(size: number) {
|
||||
const tabs: Tab[] = Array.from({ length: size }, (_, index) => ({
|
||||
...makeUnifiedTab(`chat-${index}`, workspace, `session-${index}`, `Chat ${index}`),
|
||||
contentType: 'agent-session',
|
||||
agentSessionAgent: 'codex',
|
||||
executionHostId: 'local',
|
||||
groupId: index === size - 1 ? 'second' : 'first'
|
||||
}))
|
||||
const groups = ['first', 'second'].map((id) =>
|
||||
makeTabGroup({
|
||||
id,
|
||||
worktreeId: workspace,
|
||||
tabOrder: tabs.filter((tab) => tab.groupId === id).map((tab) => tab.id),
|
||||
activeTabId: id === 'first' ? 'chat-0' : `chat-${size - 1}`
|
||||
})
|
||||
)
|
||||
useAppStore.setState({
|
||||
unifiedTabsByWorktree: { [workspace]: tabs },
|
||||
groupsByWorktree: { [workspace]: groups },
|
||||
activeGroupIdByWorktree: { [workspace]: 'first' }
|
||||
})
|
||||
}
|
||||
function overlay(active: boolean) {
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<StructuredAgentSessionPaneOverlayLayer worktreeId={workspace} isWorktreeActive={active} />
|
||||
</TooltipProvider>
|
||||
)
|
||||
}
|
||||
function chat(container: HTMLElement, id: string) {
|
||||
return within(container).getByText(`session-${id.slice(5)}`).parentElement!
|
||||
}
|
||||
|
||||
it('keeps the real Continue pending operation disabled across header hide/reveal and launches once', async () => {
|
||||
seedChats(10)
|
||||
const preparation = Promise.withResolvers<NativeChatCliForkPreparation>()
|
||||
mocks.prepare.mockReturnValue(preparation.promise)
|
||||
mocks.launch.mockResolvedValue(undefined)
|
||||
const view = render(overlay(true))
|
||||
const source = chat(view.container, 'chat-0')
|
||||
const button = () => within(source).getByRole('button', { name: 'Continue with Terminal Agent' })
|
||||
expect(fullRequest).not.toHaveBeenCalled()
|
||||
fireEvent.click(button())
|
||||
expect(button().hasAttribute('disabled')).toBe(true)
|
||||
expect(button().getAttribute('aria-busy')).toBe('true')
|
||||
view.rerender(overlay(false))
|
||||
expect(within(source).queryByRole('button')).toBeNull()
|
||||
expect(useAppStore.getState().getTab('chat-0')).not.toBeNull()
|
||||
view.rerender(overlay(true))
|
||||
expect(button().hasAttribute('disabled')).toBe(true)
|
||||
expect(button().getAttribute('aria-busy')).toBe('true')
|
||||
fireEvent.click(button())
|
||||
expect(mocks.prepare).toHaveBeenCalledTimes(1)
|
||||
await act(async () =>
|
||||
preparation.resolve({
|
||||
copied: false,
|
||||
session: { agent: 'codex', sessionId: 'fork', cwd: '/repo', codexHome: null }
|
||||
})
|
||||
)
|
||||
expect(mocks.launch).toHaveBeenCalledTimes(1)
|
||||
expect(button().hasAttribute('disabled')).toBe(false)
|
||||
expect(button().hasAttribute('aria-busy')).toBe(false)
|
||||
expect(fullRequest).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
@@ -1,24 +1,23 @@
|
||||
import { toast } from 'sonner'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { withTimeout } from '../../../../../../shared/promise-timeout-fallback'
|
||||
import { useCallback, useLayoutEffect, useRef, useState, type ReactNode } from 'react'
|
||||
import { useAppStore } from '@/store'
|
||||
import { structuredChatTabById } from '@/lib/structured-chat-tab-index'
|
||||
import { useCallback, useLayoutEffect, useRef, useState } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { useAppStore } from '@/store/index'
|
||||
import { structuredChatTabById } from '@/lib/agent-session/tab-identity/structured-chat-tab-index'
|
||||
import { useStructuredChatTabConversationName } from '@/runtime/native-chat/naming/structured-conversation-name'
|
||||
import { AgentSessionContinuationDialog } from '@/components/agent-session-continuation/AgentSessionContinuationDialog'
|
||||
import {
|
||||
buildAgentSessionContinuationPrompt,
|
||||
type AgentSessionContinuationRequest
|
||||
} from '@/lib/agent-session/context/agent-session-continuation'
|
||||
import { buildAgentSessionContinuationPrompt } from '@/lib/agent-session/context/agent-session-continuation'
|
||||
import type { AgentSessionContinuationRequest } from '@/lib/agent-session/context/agent-session-continuation'
|
||||
import { isTuiAgent } from '../../../../../../shared/agent-launch/catalog/tui-agent-config'
|
||||
import { callStructuredAgentSession } from '@/runtime/native-chat/requests/structured-agent-session-call'
|
||||
import { supportsStructuredAgentSessionContinuationContext } from '@/runtime/native-chat/host-capabilities/structured-agent-session-host-support'
|
||||
import type { AgentSessionContinuationContext } from '../../../../../../shared/agent-session/agent-session-wire'
|
||||
import { executionHostIdForStructuredTarget } from '@/runtime/native-chat/session-ownership/structured-agent-session-owner'
|
||||
import { buildAgentSessionHandoffContext } from '../../../../../../shared/agent-session-handoff-context'
|
||||
import type { AgentSessionContinuationContext } from '../../../../../../shared/agent-session/agent-session-wire'
|
||||
import type { NativeChatMessage } from '../../../../../../shared/native-chat/native-chat-types'
|
||||
import type { NativeChatStructuredViewProps } from '../../native-chat-view-types'
|
||||
import type { NativeChatFileLinkContext } from '../../links/actions/native-chat-file-link-context'
|
||||
import { buildAgentSessionHandoffContext } from '../../../../../../shared/agent-session-handoff-context'
|
||||
|
||||
export type NativeChatHandOff = {
|
||||
/** This chat can seed another agent from its owning workspace. */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { runtimeEnvironmentIdOrLocalUnlessTwin } from '@/lib/workspace/ownership/worktree-runtime-owner'
|
||||
import { createNativeChatTabOwnerSelector } from './native-chat-tab-owner'
|
||||
import { chatWorkspaceByTabId as findTerminalTabWorktreeId } from '../../../../lib/agent-session/tab-identity/structured-chat-tab-index'
|
||||
import type { WorktreeRuntimeOwnerState } from '@/lib/workspace/ownership/worktree-runtime-owner-state'
|
||||
import type { AppState } from '@/store/types'
|
||||
import { createNativeChatTabOwnerSelector } from './native-chat-tab-owner'
|
||||
import { chatWorkspaceByTabId as findTerminalTabWorktreeId } from '../../../../lib/structured-chat-tab-index'
|
||||
|
||||
export type NativeChatRuntimeOwnerState = Pick<AppState, 'tabsByWorktree'> &
|
||||
WorktreeRuntimeOwnerState
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user