Merge origin/main into delete-agent-retention

This commit is contained in:
Brennan Benson
2026-11-10 03:50:24 -08:00
1241 changed files with 16519 additions and 18001 deletions
-2
View File
@@ -257,7 +257,6 @@
1 test-no-real-time-wait:src/main/windows/windows-process-tree-command-line-patch.test.ts
2 test-no-real-time-wait:src/main/windows/windows-pty-job.win32.test.ts
1 test-no-real-time-wait:src/main/worker-thread-child-process/worker-thread-child-process.test.ts
1 test-no-real-time-wait:src/main/workspaces/creation/preparation/worktree-create-preparation-cancellation.test.ts
1 test-no-real-time-wait:src/main/workspaces/removal/local-worktree-removal-recovery-live.test.ts
2 test-no-real-time-wait:src/main/wsl/execution/wsl-command-loop.test.ts
2 test-no-real-time-wait:src/main/wsl/orcad/wsl-orcad-real-distro-lane.test.ts
@@ -273,7 +272,6 @@
1 test-no-real-time-wait:src/renderer/src/components/terminal-pane/viewport/terminal-fit-restore.test.ts
1 test-no-real-time-wait:src/renderer/src/hooks/runtime-project-refresh-scheduler.test.ts
1 test-no-real-time-wait:src/renderer/src/lib/agent-session/resume/cli-fork/native-chat-cli-fork-preparation.test.ts
1 test-no-real-time-wait:src/renderer/src/lib/orca-yaml-trust-prompt-slot-eviction.test.ts
2 test-no-real-time-wait:src/renderer/src/store/slices/workspace-cleanup/workspace-cleanup-removal-preflight.test.ts
2 test-no-real-time-wait:src/shared/__tests__/process-host/windows-tree-kill-late-taskkill.win32.test.ts
1 test-no-real-time-wait:src/shared/darwin-process-table-capture.test.ts
+3 -3
View File
@@ -231,10 +231,10 @@
1 src/renderer/src/lib/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/terminal-close-route.ts
4 src/renderer/src/lib/terminal-worktree-route.ts # resolveTerminalPtyOwner: teardown, close and PTY identity read spawn's attribution (round 3 F8), which retired the deprecated resolver's readers
1 src/renderer/src/lib/workspace/ownership/terminal-close-route.ts
4 src/renderer/src/lib/workspace/ownership/terminal-worktree-route.ts # resolveTerminalPtyOwner: teardown, close and PTY identity read spawn's attribution (round 3 F8), which retired the deprecated resolver's readers
3 src/renderer/src/lib/unread-badge-count-selector.ts
1 src/renderer/src/lib/web-runtime-worktree-terminal-after-wake.ts
1 src/renderer/src/runtime/hosted-terminals/restoration/web-runtime-worktree-terminal-after-wake.ts
1 src/renderer/src/lib/work-items/linear/linear-issue-url-lookup.ts
1 src/renderer/src/lib/work-items/linear/linear-issue-write.ts
1 src/renderer/src/lib/workspace/activation/worktree-activation.ts
@@ -560,21 +560,21 @@
"count": 1
},
{
"filePath": "mobile/src/transport/hosts/mobile-relay-host-overlay.ts",
"filePath": "mobile/src/host-catalog/mobile-relay-host-overlay.ts",
"kind": "object-property:message",
"text": "Expected exactly one endpoint for configured relay metadata",
"dynamic": false,
"count": 1
},
{
"filePath": "mobile/src/transport/hosts/mobile-relay-host-overlay.ts",
"filePath": "mobile/src/host-catalog/mobile-relay-host-overlay.ts",
"kind": "object-property:message",
"text": "Relay host identity mismatch",
"dynamic": false,
"count": 1
},
{
"filePath": "mobile/src/transport/hosts/mobile-relay-host-overlay.ts",
"filePath": "mobile/src/host-catalog/mobile-relay-host-overlay.ts",
"kind": "object-property:message",
"text": "Relay identity and endpoint must coexist",
"dynamic": false,
+2 -2
View File
@@ -651,7 +651,7 @@
2 src/renderer/src/components/terminal-pane/mobile-driver/MobileDriverOverlay.tsx
1 src/renderer/src/components/terminal-pane/mobile-driver/TerminalPaneMobileDriverPortals.tsx
1 src/renderer/src/components/terminal-pane/mounting/use-terminal-pane-mount-lifecycle.ts
2 src/renderer/src/components/terminal-pane/parking/lifecycle/use-terminal-tab-cold-parking.ts
1 src/renderer/src/components/terminal-pane/parking/lifecycle/use-terminal-tab-cold-parking.ts
1 src/renderer/src/components/terminal-pane/parking/retention/terminal-pending-startup-park-presence.ts
1 src/renderer/src/components/terminal-pane/pty-transport/remote-runtime/recovery/TerminalPaneRecoveryPortals.tsx
2 src/renderer/src/components/terminal-pane/session-fork/TerminalAgentSessionForkDialog.tsx
@@ -705,7 +705,7 @@
4 src/renderer/src/hooks/skills/freshness/useSkillFreshness.ts
1 src/renderer/src/hooks/useTaskPageGitHubWorkItemMutation.ts
6 src/renderer/src/hooks/useVirtualizedScrollAnchor.ts
1 src/renderer/src/lib/host-chat-program-acquisition.ts
1 src/renderer/src/lib/agent-session/launch/inventory/host-chat-program-acquisition.ts
1 src/renderer/src/lib/quick-open-file-history.ts
2 src/renderer/src/lib/worker-auto-close.ts
1 src/renderer/src/runtime/native-chat/naming/structured-chat-name-observation.ts
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -17,7 +17,7 @@
4 src/renderer/src/components/terminal-pane/render-health/recovery/terminal-recovery-ledger-test-store.ts
3 src/renderer/src/components/worktree-jump/worktree-jump-palette-status-inputs.ts
1 src/renderer/src/lib/agent-session/hibernation/agent-hibernation-coordinator.ts
4 src/renderer/src/lib/floating-workspace-terminal-actions.ts
4 src/renderer/src/components/floating-terminal/floating-workspace-terminal-actions.ts
1 src/renderer/src/lib/pane-manager/client-hosted-browser-row-state.ts
4 src/renderer/src/lib/workspace/persistence/session-write-subscriber.ts
1 src/renderer/src/lib/workspace/persistence/workspace-session-browser-tabs.ts
@@ -5318,8 +5318,6 @@
"src/renderer/src/components/new-workspace/DirectWorkItemSetupDialog.test.tsx": 5296,
"src/renderer/src/components/new-workspace/NewWorkspaceComposerNameSection.test.tsx": 2493,
"src/renderer/src/components/new-workspace/ProjectCombobox.dialog-handoff.test.tsx": 1043,
"src/renderer/src/components/new-workspace/ProjectCombobox.test.tsx": 848,
"src/renderer/src/components/new-workspace/ProjectComboboxRow.test.tsx": 415,
"src/renderer/src/components/new-workspace/RunTargetCombobox.host-identity.test.tsx": 856,
"src/renderer/src/components/new-workspace/SetProjectLocationDialog.host-identity.test.tsx": 1094,
"src/renderer/src/components/new-workspace/SetProjectLocationDialog.test.tsx": 1387,
@@ -5482,7 +5480,6 @@
"src/renderer/src/components/settings/browser/BrowserUserAgentSetting.test.tsx": 2325,
"src/renderer/src/components/settings/chat/ChatNamingSetting.test.tsx": 2454,
"src/renderer/src/components/settings/chat/ChatPermissionSetting.test.tsx": 834,
"src/renderer/src/components/settings/chat/ChatSettingsSection.navigation.test.tsx": 2540,
"src/renderer/src/components/settings/chat/ChatSettingsSection.test.tsx": 2718,
"src/renderer/src/lib/skills/runtime/skill-runtime-command.test.ts": 1670,
"src/renderer/src/components/settings/virtual-machines/recipes/EphemeralVmsPane.test.tsx": 1025,
@@ -5511,7 +5508,6 @@
"src/renderer/src/components/settings/terminal/appearance/TerminalContrastSetting.test.tsx": 798,
"src/renderer/src/components/settings/terminal/session-management/TerminalLimitSetting.test.tsx": 1015,
"src/renderer/src/components/settings/terminal/TerminalPane.section-lifetime.test.tsx": 1237,
"src/renderer/src/components/settings/terminal/appearance/TerminalSettingsPreview.lifecycle.test.tsx": 595,
"src/renderer/src/components/settings/developer-permissions/TerminalTccAttributionNotice.test.tsx": 401,
"src/renderer/src/components/settings/voice/VoiceMicrophoneSetting.test.tsx": 957,
"src/renderer/src/components/settings/voice/VoicePane.test.tsx": 1042,
@@ -5524,7 +5520,6 @@
"src/renderer/src/components/settings/developer-permissions/developer-permissions-search.test.ts": 308,
"src/renderer/src/components/settings/shortcuts/keybinding-diagnostic-text.test.ts": 522,
"src/renderer/src/components/settings/shortcuts/keybinding-title-copy.test.ts": 227,
"src/renderer/src/lib/agent-session/launch/native-chat-provider-choice.test.tsx": 3738,
"src/renderer/src/components/settings/notifications/notification-host-pending-save.test.tsx": 2029,
"src/renderer/src/components/settings/repository/RepositoryJiraProjectSection.test.tsx": 463,
"src/renderer/src/components/settings/repository/RepositoryPaneDraftInput.test.tsx": 314,
@@ -5669,8 +5664,6 @@
"src/renderer/src/components/skills/sharing/SkillSharedLinkRow.test.tsx": 817,
"src/renderer/src/components/skills/SkillsPage.test.tsx": 3822,
"src/renderer/src/components/skills/catalog/skill-agent-filter.test.ts": 274,
"src/shared/skill-share-link.test.ts": 55,
"src/renderer/src/components/skills/sharing/skill-share-package-selection.test.ts": 49,
"src/renderer/src/components/sparse/sparse-directory-entry-input.test.ts": 207,
"src/renderer/src/components/stats/usage-daily-chart.test.tsx": 333,
@@ -5959,7 +5952,6 @@
"src/renderer/src/components/terminal-pane/emulation/terminal-capability-replies.test.ts": 131,
"src/renderer/src/components/terminal-pane/clipboard/terminal-clipboard-paste.test.ts": 76,
"src/renderer/src/components/terminal-pane/parking/retention/terminal-cold-park-timer-rearm.test.tsx": 701,
"src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-handler.test.ts": 638,
"src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-image-path.test.ts": 61,
"src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-internal-handler.test.ts": 800,
"src/renderer/src/components/terminal-pane/input/file-drop/terminal-drop-path-writer.test.ts": 245,
@@ -6344,7 +6336,7 @@
"src/renderer/src/lib/browser/documents/doc-preview-grants.test.ts": 2094,
"src/renderer/src/lib/editor/file-operations/editor-file-operation-owner.test.ts": 2848,
"src/renderer/src/lib/emulator-error-copy.test.ts": 415,
"src/renderer/src/lib/ensure-hooks-confirmed.test.ts": 799,
"src/renderer/src/runtime/repo-hooks/ensure-hooks-confirmed.test.ts": 799,
"src/renderer/src/lib/simulator/tabs/ensure-simulator-tab-behavior.test.ts": 3601,
"src/renderer/src/runtime/hosts/platform/execution-host-facts.test.ts": 1796,
"src/renderer/src/lib/feature-education-telemetry.test.ts": 52,
@@ -6352,13 +6344,8 @@
"src/renderer/src/lib/file-search-selection.test.ts": 51,
"src/renderer/src/lib/find-query-bounds.test.ts": 45,
"src/renderer/src/lib/finished-agent-resume-resurrection.test.ts": 1872,
"src/renderer/src/lib/focus-terminal-tab-surface.split-focus.test.ts": 331,
"src/renderer/src/lib/foreground-terminal-tabs.test.ts": 55,
"src/shared/new-workspace/github-links.test.ts": 76,
"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/shared/new-workspace/gitlab-links.test.ts": 56,
"src/renderer/src/lib/hook-command-delayed-delivery.test.ts": 1904,
"src/renderer/src/lib/host-chat-program.test.ts": 2419,
"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,
@@ -6403,12 +6390,8 @@
"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/new-workspace.test.ts": 4534,
"src/renderer/src/lib/non-secure-context-crypto.repro.test.ts": 1691,
"src/renderer/src/lib/onboarding-folder-cancellation.test.ts": 2486,
"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/orca-yaml-trust-prompt-slot-eviction.test.ts": 884,
"src/renderer/src/lib/order-empty-query-worktrees.test.ts": 62,
"src/renderer/src/lib/os-file-drop-cancellation-guard.test.ts": 204,
"src/renderer/src/lib/os-file-drop-preload-integration.test.tsx": 353,
@@ -6424,7 +6407,6 @@
"src/renderer/src/lib/pane-manager/pane-layout-geometry-apply.test.ts": 897,
"src/renderer/src/lib/pane-manager/pane-manager-registry.test.ts": 69,
"src/renderer/src/lib/pane-manager/pane-manager-spawn-placement.test.ts": 766,
"src/renderer/src/lib/pane-manager/pane-overlay-focus.test.ts": 622,
"src/renderer/src/lib/pane-manager/pane-scroll.test.ts": 153,
"src/renderer/src/lib/pane-manager/pane-terminal-foreground-render-settle.test.ts": 43,
"src/renderer/src/lib/pane-manager/pane-terminal-mouse-wheel.test.ts": 88,
@@ -6469,20 +6451,20 @@
"src/renderer/src/lib/pane-manager/xterm-parse-barrier.test.ts": 154,
"src/renderer/src/lib/pane-manager/xterm-user-scrolling-contract.test.ts": 1266,
"src/renderer/src/lib/pane-manager/xterm-write-callback-guard.test.ts": 53,
"src/renderer/src/lib/pane-spawn-deferral-drain.test.ts": 61,
"src/renderer/src/lib/parked-terminal-host-hydration.test.ts": 274,
"src/renderer/src/components/terminal-pane/session-restore/spawn-deferral/pane-spawn-deferral-drain.test.ts": 61,
"src/renderer/src/components/terminal-pane/mounting/parked-terminal-host-hydration.test.ts": 274,
"src/renderer/src/lib/text-input/paste/paste-payload-metadata.test.ts": 53,
"src/renderer/src/lib/path-head-elision.test.ts": 53,
"src/renderer/src/lib/path.test.ts": 55,
"src/renderer/src/lib/plugin-command-keybindings.test.ts": 1909,
"src/renderer/src/lib/plugin-command-replacements.test.ts": 95,
"src/renderer/src/lib/plugin-icons/plugin-icon-svg.test.ts": 231,
"src/renderer/src/lib/plugin-monaco-token-rules.test.ts": 51,
"src/renderer/src/lib/editor/appearance/plugin-monaco-token-rules.test.ts": 51,
"src/renderer/src/lib/source-control/review/pr-bot-author-overrides.test.ts": 349,
"src/renderer/src/lib/source-control/review/comments/pr-comment-thread-resolution.test.ts": 48,
"src/renderer/src/lib/project-clone-url-prefill.test.ts": 61,
"src/renderer/src/lib/project-host-workspace-target.jira-mapping.test.ts": 76,
"src/renderer/src/lib/project-host-workspace-target.test.ts": 92,
"src/renderer/src/lib/workspace/creation/project-clone-url-prefill.test.ts": 61,
"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/react-commit-cascade-observer.react185.test.tsx": 285,
"src/renderer/src/lib/react-commit-cascade-observer.test.ts": 189,
"src/renderer/src/lib/react-commit-cascade-telemetry.test.ts": 159,
@@ -6523,7 +6505,6 @@
"src/renderer/src/lib/simulator/tabs/simulator-pane-shutdown-scheduler.test.ts": 1679,
"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/sleeping-agent-session-launch-windows-quoting.test.ts": 547,
"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/lib/state-collection-byte-estimate.test.ts": 86,
@@ -6538,7 +6519,7 @@
"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/lib/terminal-app-theme.test.ts": 301,
"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,
@@ -6554,9 +6535,7 @@
"src/renderer/src/lib/wake-sleeping-agents-live-unmounted-pane.test.ts": 2432,
"src/renderer/src/lib/window-visibility-interval.test.ts": 48,
"src/renderer/src/lib/window-visibility-timeout-poller.test.ts": 207,
"src/renderer/src/lib/windows-terminal-capabilities-race.test.ts": 450,
"src/renderer/src/lib/windows-terminal-capabilities.test.ts": 585,
"src/renderer/src/lib/windows-terminal-capability-reprobe.test.ts": 198,
"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,
"src/renderer/src/lib/workspace-doc-address-input.test.ts": 470,
@@ -8048,8 +8027,6 @@
"tests/e2e/structured-session-tab-close-regressions.unit.test.ts": 32432,
"tests/e2e/sustained-agent-typing-load-scripts.unit.test.ts": 2169,
"tests/e2e/task-page-linear-refresh-authority.unit.test.ts": 5548,
"tests/e2e/task-page-linear-refresh-transport.unit.test.ts": 2019,
"tests/e2e/terminal-agent-fork-draft-ownership.unit.test.ts": 30195,
"tests/e2e/terminal-binding-crash-hydration.unit.test.ts": 1769,
"tests/e2e/terminal-foreground-confirmation.unit.test.ts": 644,
"tests/e2e/terminal-perf-presentation.unit.test.ts": 60,
@@ -48,6 +48,7 @@ const RATCHET_INPUTS = {
'check-repo-host-read-ratchet.mjs': ['src/cli/', 'src/main/', 'src/shared/'],
'check-runtime-electron-ratchet.mjs': ['src/main/', 'src/cli/', 'src/shared/'],
'check-tab-map-seam-ratchet.mjs': ['src/renderer/src/'],
'check-terminal-parking-ownership-ratchet.mjs': ['src/renderer/src/'],
'check-unproven-pty-retirement-ratchet.mjs': ['src/main/'],
'check-workspace-record-read-ratchet.mjs': ['src/renderer/src/'],
'check-worktree-id-composer-ratchet.mjs': ['src/', 'mobile/src/']
@@ -41,6 +41,7 @@ export const LINT_STEPS = [
'check:ts-nocheck-ratchet',
'check:workspace-record-read-ratchet',
'check:tab-map-seam-ratchet',
'check:terminal-parking-ownership-ratchet',
'check:unproven-pty-retirement-ratchet',
'check:daemon-blocking-call-ratchet',
'check:main-sync-fs-ratchet',
@@ -1,87 +0,0 @@
import { describe, expect, it } from 'vitest'
import { CONSUMERS, consumerViolations, writerViolations } from './check-tab-map-seam-ratchet.mjs'
const BRIDGE =
'src/renderer/src/components/native-chat/session/status/StructuredAgentSessionStatusBridge.tsx'
const rules = CONSUMERS.get(BRIDGE)
describe('tab-map seam guard', () => {
it('rejects an ordinary handler reaching the cold path or walking a map', () => {
const text = [
'const reconcileFromSnapshot = () => getStructuredAgentSessionTabs(source)',
'const reconcile = () => reconcileFromSnapshot()',
'const ordinary = () => { reconcileFromSnapshot(); Object.keys(source) }'
].join('\n')
expect(consumerViolations('bridge.tsx', text, rules)).toEqual([
'bridge.tsx:3 reconcileFromSnapshot() outside a named cold path',
'bridge.tsx:3 Object.keys outside a named cold path'
])
})
it('rejects an unreviewed value import, not type imports', () => {
const text = [
"import { wholeMap } from './new-walk'",
"import type { Walk } from './new-walk'"
].join('\n')
expect(consumerViolations('bridge.tsx', text, rules)).toEqual([
'bridge.tsx:1 imports wholeMap; repaired consumers import only reviewed helpers'
])
})
it('follows a raw record through a local binding unless it is marked full resync', () => {
const text = [
'function raw(state) {',
' const next = { ...state.unifiedTabsByWorktree, [id]: tabs }',
' set({ unifiedTabsByWorktree: next })',
'}',
'function annotated(state) {',
' const next = { ...state.unifiedTabsByWorktree, [id]: tabs }',
' markFullResync(next, "hydration")',
' set({ unifiedTabsByWorktree: next })',
'}'
].join('\n')
expect(writerViolations('writer.ts', text)).toEqual([
'writer.ts:3 raw unifiedTabsByWorktree record; build it with a replace helper or draft, or mark it full resync'
])
})
it('follows aliases of cold helpers and enumerators', () => {
const text = [
'const reconcileFromSnapshot = () => getStructuredAgentSessionTabs(source)',
'const reconcile = () => reconcileFromSnapshot()',
'const resync = reconcileFromSnapshot',
'const keys = Object.keys'
].join('\n')
expect(consumerViolations('bridge.tsx', text, rules)).toEqual([
'bridge.tsx:3 reconcileFromSnapshot() outside a named cold path',
'bridge.tsx:4 Object.keys outside a named cold path'
])
})
it('follows aliased raw records and requires annotation before publication', () => {
const raw =
'raw unifiedTabsByWorktree record; build it with a replace helper or draft, or mark it full resync'
const text = [
'function aliased(state) {',
' const next = { ...state.unifiedTabsByWorktree, [id]: tabs }',
' const unifiedTabsByWorktree = next',
' set({ unifiedTabsByWorktree })',
'}',
'function late(state) {',
' const next = { ...state.unifiedTabsByWorktree, [id]: tabs }',
' set({ unifiedTabsByWorktree: next })',
' markFullResync(next, "hydration")',
'}',
'function early(state) {',
' const next = { ...state.unifiedTabsByWorktree, [id]: tabs }',
' const alias = next',
' markFullResync(alias, "hydration")',
' set({ unifiedTabsByWorktree: alias })',
'}'
].join('\n')
expect(writerViolations('writer.ts', text)).toEqual([
`writer.ts:4 ${raw}`,
`writer.ts:8 ${raw}`
])
})
})
@@ -0,0 +1,478 @@
import fs from 'node:fs'
import path from 'node:path'
import process from 'node:process'
import { pathToFileURL } from 'node:url'
import ts from 'typescript-api'
const RENDERER = 'src/renderer/src/'
const WATCHERS = `${RENDERER}components/terminal-pane/parking/output-watchers/`
const ROOTS = new Map([
[
`${RENDERER}components/terminal/terminal-provider-snapshot-bound-pty-ids.ts`,
['createTerminalProviderSnapshotBoundPtyIdsSelector']
],
[`${RENDERER}components/use-terminal-watcher-effects.ts`, ['useTerminalWatcherEffects']],
[`${RENDERER}components/use-terminal-parking-pass.ts`, ['useTerminalParkingPass']],
[
`${RENDERER}components/terminal-parking-pass-candidates.ts`,
['collectTerminalParkingPassCandidates']
],
[`${RENDERER}components/terminal/split-group-mount.ts`, ['anyMountedWorktreeHasLayout']],
[
`${RENDERER}components/terminal-pane/parking/lifecycle/use-parked-terminal-watcher-synchronization.ts`,
['useParkedTerminalWatcherSynchronization']
],
[
`${RENDERER}components/terminal-pane/parking/lifecycle/use-terminal-tab-cold-parking.ts`,
['useTerminalTabColdParking']
],
[
`${WATCHERS}terminal-parked-tab-watchers.ts`,
['syncParkedTerminalTabWatchers', 'canWatcherCoverParkedTerminalTab']
],
[`${WATCHERS}parked-terminal-tab-coverage.ts`, ['canWatcherCoverParkedTerminalTab']],
[
`${RENDERER}lib/agent-session/resume/resume-sleeping-agent-session.ts`,
['resumeSleepingAgentSessionsForWorktree']
]
])
const HOT_MAPS = new Set([
'tabsByWorktree',
'unifiedTabsByWorktree',
'terminalLayoutsByTabId',
'sleepingAgentSessionsByPaneKey'
])
const OWNER_ROOTS = [
{
rel: 'store/terminals/terminal-parking-input-owner.ts',
name: 'acceptTerminalParkingInputs',
inputs: []
},
{
rel: 'store/terminals/terminal-parking-input-owner.ts',
name: 'publishAcceptedTerminalParkingInputs',
inputs: []
},
{
rel: 'store/terminals/terminal-parking-input-owner.ts',
name: 'invalidateTerminalParkingPtyInputs',
inputs: []
},
{
rel: 'store/terminals/terminal-tab-owner-index.ts',
name: 'update',
inputs: ['tabsByWorktree']
},
{ rel: 'store/terminals/sleeping-agent-record-index.ts', name: 'update', inputs: ['records'] },
{
rel: 'store/terminals/sleeping-agent-record-index.ts',
name: 'acceptTransition',
inputs: ['previous', 'next']
},
{
rel: 'lib/workspace/tabs/worktree-tab-bucket-projection.ts',
name: 'project',
inputs: ['source']
}
]
const KEY_DIFFS = new Set([
`${RENDERER}store/terminals/terminal-parking-input-owner.ts#diffUnknownParkingRecordKeys`,
`${RENDERER}store/terminals/terminal-tab-owner-index.ts#diffUnknownTabOwnerKeys`,
`${RENDERER}store/terminals/sleeping-agent-record-index.ts#diffUnknownSleepingRecordKeys`,
`${RENDERER}lib/workspace/tabs/worktree-tab-bucket-projection.ts#diffUnknownProjectionKeys`
])
const COLD_RESYNCS = new Set([
`${RENDERER}store/terminals/terminal-parking-input-owner.ts#resyncTerminalParkingWorkspaceIds`,
`${RENDERER}store/terminals/sleeping-agent-record-index.ts#resyncSleepingAgentRecordKeys`
])
function isColdResyncCall(node, source) {
for (let ancestor = node.parent; ancestor; ancestor = ancestor.parent) {
if (
ts.isConditionalExpression(ancestor) &&
ancestor.condition.getText(source) === 'previous' &&
node.pos >= ancestor.whenFalse.pos
) {
return true
}
if (
ts.isBinaryExpression(ancestor) &&
ancestor.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken &&
ancestor.left.getText(source) === 'keys'
) {
return true
}
if (
ts.isIfStatement(ancestor) &&
node.pos >= ancestor.thenStatement.pos &&
node.end <= ancestor.thenStatement.end
) {
const condition = ancestor.expression.getText(source).replace(/\s+/g, ' ')
if (
condition === 'ptyIds === undefined' ||
condition.includes(
'previous.settings?.terminalSshViewParking !== state.settings?.terminalSshViewParking'
)
) {
return true
}
}
}
return false
}
const STORE_BOUNDARIES = new Set([`${RENDERER}store/index.ts`, `${RENDERER}store.ts`])
// Resource delivery and startup recovery are separate entry points, not parking input discovery.
const EFFECT_BOUNDARIES = new Set([
`${RENDERER}components/terminal/terminal-provider-snapshot-bound-pty-ids.ts#resyncUnknownSnapshot`,
`${RENDERER}components/terminal/use-terminal-startup-activation.ts#useTerminalStartupActivation`,
`${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}runtime/web-session-tabs-sync/hydration/host-session-mirror-hydration.ts#parkUntilHostSessionMirrorHydrates`
])
const ENUMERATORS = new Set(['entries', 'values', 'keys', 'assign'])
const ADDRESSED_FIELDS = new Set([
'terminalLayoutsByTabId',
'ptyIdsByTabId',
'lastKnownRelayPtyIdByTabId',
'runtimePaneTitlesByTabId',
'pendingStartupByTabId',
'sleepingAgentSessionsByPaneKey'
])
const ORDINARY_WRITERS = [
'store/terminals/terminal-layout-state.ts',
'store/terminals/terminal-pane-hibernation.ts',
'store/terminals/terminal-pty-bindings.ts',
'store/terminals/terminal-pty-release.ts',
'store/terminals/terminal-orphan-cleanup.ts',
'store/terminals/terminal-startup-queues.ts',
'store/terminals/terminal-tab-presentation.ts',
'store/terminals/terminal-shutdown-state.ts',
'store/terminals/window-tab-start-in-main.ts',
'store/slices/agent-status/agent-status-live-reducer.ts',
'store/slices/agent-status/agent-status-launch-actions.ts',
'store/slices/agent-status/agent-status-provider-session-actions.ts',
'store/slices/agent-status/agent-status-recovery-actions.ts',
'store/slices/agent-status/agent-status-authority-actions.ts'
].map((rel) => RENDERER + rel)
const RECORD_TRANSITIONS = new Set([
'replaceRecordEntries',
'removePaneKeys',
'removePaneKeysByTabPrefix'
])
function collectUnaddressedWrites(root) {
const violations = []
for (const rel of ORDINARY_WRITERS) {
const { source, aliases, assignments } = readModule(root, rel)
function addressed(value, field, seen = new Set()) {
if (ts.isCallExpression(value) && ts.isIdentifier(value.expression)) {
return RECORD_TRANSITIONS.has(value.expression.text)
}
if (ts.isPropertyAccessExpression(value)) {
return value.name.text === field
}
if (ts.isConditionalExpression(value)) {
return addressed(value.whenTrue, field, seen) && addressed(value.whenFalse, field, seen)
}
if (ts.isIdentifier(value)) {
if (seen.has(value.text)) {
return false
}
seen.add(value.text)
const alias = aliases.get(value.text)
return (
alias !== undefined &&
[alias, ...(assignments.get(value.text) ?? [])].every((replacement) =>
addressed(replacement, field, new Set(seen))
)
)
}
return false
}
function visit(node) {
if (ts.isPropertyAssignment(node) || ts.isShorthandPropertyAssignment(node)) {
const field =
ts.isIdentifier(node.name) || ts.isStringLiteral(node.name) ? node.name.text : null
const value = ts.isPropertyAssignment(node) ? node.initializer : node.name
if (ADDRESSED_FIELDS.has(field) && !addressed(value, field)) {
const line = source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1
violations.push(`${rel}:${line}: ${field} write needs complete record-key provenance.`)
}
}
ts.forEachChild(node, visit)
}
visit(source)
}
return violations
}
function resolveImport(root, from, specifier) {
const base = specifier.startsWith('@/')
? RENDERER + specifier.slice(2)
: specifier.startsWith('.')
? path.posix.join(path.posix.dirname(from), specifier)
: null
if (!base) {
return null
}
return (
[base, `${base}.ts`, `${base}.tsx`, `${base}/index.ts`].find(
(candidate) =>
fs.existsSync(path.join(root, candidate)) &&
fs.statSync(path.join(root, candidate)).isFile()
) ?? null
)
}
function readModule(root, rel) {
const source = ts.createSourceFile(
rel,
fs.readFileSync(path.join(root, rel), 'utf8'),
ts.ScriptTarget.Latest,
true
)
const imports = new Map()
const functions = new Map()
const aliases = new Map()
const assignments = new Map()
function visit(node) {
if (
ts.isBinaryExpression(node) &&
ts.isIdentifier(node.left) &&
node.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&
node.operatorToken.kind <= ts.SyntaxKind.LastAssignment
) {
const values = assignments.get(node.left.text) ?? []
values.push(node.right)
assignments.set(node.left.text, values)
}
if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {
const target = resolveImport(root, rel, node.moduleSpecifier.text)
const bindings = node.importClause?.namedBindings
if (target && bindings && ts.isNamedImports(bindings)) {
for (const binding of bindings.elements) {
imports.set(binding.name.text, {
rel: target,
name: binding.propertyName?.text ?? binding.name.text
})
}
}
}
if (
(ts.isFunctionDeclaration(node) || ts.isMethodDeclaration(node)) &&
node.name &&
node.body
) {
functions.set(node.name.text, node)
}
if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer) {
aliases.set(node.name.text, node.initializer)
if (ts.isArrowFunction(node.initializer) || ts.isFunctionExpression(node.initializer)) {
functions.set(node.name.text, node.initializer)
}
}
ts.forEachChild(node, visit)
}
visit(source)
return { source, imports, functions, aliases, assignments }
}
export function collectParkingOwnershipViolations(root = process.cwd()) {
const modules = new Map()
const pending = [...ROOTS].flatMap(([rel, names]) =>
names.map((name) => ({ rel, name, tainted: new Set() }))
)
for (const { rel, name, inputs } of OWNER_ROOTS) {
pending.push({ rel: RENDERER + rel, name, tainted: new Set(inputs) })
}
const visited = new Set()
const violations = new Set()
while (pending.length) {
const { rel, name, tainted } = pending.pop()
if (STORE_BOUNDARIES.has(rel) || EFFECT_BOUNDARIES.has(`${rel}#${name}`)) {
continue
}
const identity = `${rel}#${name}#${[...tainted].sort().join(',')}`
if (visited.has(identity)) {
continue
}
visited.add(identity)
let mod = modules.get(rel)
if (!mod) {
modules.set(rel, (mod = readModule(root, rel)))
}
const fn = mod.functions.get(name)
if (!fn) {
continue
}
function hotMap(node, seen = new Set()) {
if (ts.isPropertyAccessExpression(node)) {
if (HOT_MAPS.has(node.name.text)) {
return true
}
if (ts.isIdentifier(node.expression)) {
const value = mod.aliases.get(node.expression.text)
if (value && ts.isObjectLiteralExpression(value)) {
const property = value.properties.find(
(candidate) =>
ts.isPropertyAssignment(candidate) &&
candidate.name.getText(mod.source) === node.name.text
)
if (property && ts.isPropertyAssignment(property)) {
return hotMap(property.initializer, seen)
}
}
}
return false
}
if (ts.isElementAccessExpression(node)) {
return (
ts.isStringLiteral(node.argumentExpression) && HOT_MAPS.has(node.argumentExpression.text)
)
}
if (ts.isIdentifier(node)) {
if (HOT_MAPS.has(node.text) || tainted.has(node.text)) {
return true
}
if (seen.has(node.text)) {
return false
}
seen.add(node.text)
const alias = mod.aliases.get(node.text)
return alias ? hotMap(alias, seen) : false
}
if (
ts.isParenthesizedExpression(node) ||
ts.isAsExpression(node) ||
ts.isNonNullExpression(node)
) {
return hotMap(node.expression, seen)
}
if (
ts.isBinaryExpression(node) &&
node.operatorToken.kind === ts.SyntaxKind.QuestionQuestionToken
) {
return hotMap(node.left, seen)
}
return false
}
function report(node) {
const line = mod.source.getLineAndCharacterOfPosition(node.getStart(mod.source)).line + 1
violations.add(
`${rel}:${line}: ${name} enumerates a whole parking input; use the addressed owner or a named source resync.`
)
}
function visit(node) {
if (
ts.isFunctionDeclaration(node) &&
node.name &&
EFFECT_BOUNDARIES.has(`${rel}#${node.name.text}`)
) {
return
}
if (ts.isForInStatement(node) && hotMap(node.expression)) {
report(node)
}
if (ts.isCallExpression(node)) {
const callee = node.expression
if (
ts.isPropertyAccessExpression(callee) &&
ts.isIdentifier(callee.expression) &&
callee.expression.text === 'Object' &&
ENUMERATORS.has(callee.name.text) &&
node.arguments.some((arg) => hotMap(arg)) &&
!(callee.name.text === 'keys' && KEY_DIFFS.has(`${rel}#${name}`)) &&
!COLD_RESYNCS.has(`${rel}#${name}`)
) {
report(node)
}
if (ts.isIdentifier(callee)) {
const target = mod.imports.get(callee.text) ?? { rel, name: callee.text }
if (
COLD_RESYNCS.has(`${target.rel}#${target.name}`) &&
!isColdResyncCall(node, mod.source)
) {
report(node)
}
if (!STORE_BOUNDARIES.has(target.rel)) {
let targetModule = modules.get(target.rel)
if (!targetModule) {
modules.set(target.rel, (targetModule = readModule(root, target.rel)))
}
const called = targetModule.functions.get(target.name)
const parameters = new Set()
called?.parameters.forEach((parameter, index) => {
if (
ts.isIdentifier(parameter.name) &&
node.arguments[index] &&
hotMap(node.arguments[index])
) {
parameters.add(parameter.name.text)
}
})
if (called) {
pending.push({ ...target, tainted: parameters })
}
}
}
}
ts.forEachChild(node, visit)
}
visit(fn.body)
}
return [...violations].sort()
}
function collectPublicCoverageViolations(root) {
const rel = `${WATCHERS}parked-terminal-tab-coverage.ts`
const { source } = readModule(root, rel)
const privateNames = new Set([
'fallbackParkedPaneCandidates',
'resolveParkedTerminalPaneCandidates',
'capturedCoversFallback'
])
const violations = []
for (const statement of source.statements) {
const exported =
ts.canHaveModifiers(statement) &&
ts.getModifiers(statement)?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword)
const leaksDeclaration =
exported && ts.isFunctionDeclaration(statement) && privateNames.has(statement.name?.text)
const leaksNamedExport =
ts.isExportDeclaration(statement) &&
statement.exportClause &&
ts.isNamedExports(statement.exportClause) &&
statement.exportClause.elements.some((element) =>
privateNames.has(element.propertyName?.text ?? element.name.text)
)
if (leaksDeclaration || leaksNamedExport) {
violations.push(`${rel}: raw coverage derivation must stay private to its owner.`)
}
}
return violations
}
export function main(root = process.cwd()) {
const violations = [
...collectParkingOwnershipViolations(root),
...collectUnaddressedWrites(root),
...collectPublicCoverageViolations(root)
]
for (const violation of violations) {
console.error(violation)
}
if (violations.length) {
return 1
}
console.log(
'terminal-parking-ownership: addressed consumer paths contain no whole input enumeration'
)
return 0
}
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
process.exitCode = main()
}
@@ -0,0 +1,16 @@
import { TestRunner } from 'vitest'
export default class SharedWorkerSetupRunner extends TestRunner {
importFile(filepath, source) {
if (source === 'setup') {
// Warm transforms can key setup roots by a different URL than Vitest invalidates.
const modules = this.moduleRunner.evaluatedModules
for (const node of modules.getModulesByFile(filepath) ?? []) {
if (node.evaluated) {
modules.invalidateModule(node)
}
}
}
return super.importFile(filepath, source)
}
}
@@ -170,7 +170,9 @@ const NODE_RUNTIME_INCLUDE = [
'config/scripts/orcad-distribution/server-bundle/profile-state-worker-smoke.test.mjs',
'config/scripts/desktop-distribution/runtime-verification/process-host-dev-rebuild.test.ts',
'config/scripts/test-runtime/node-worker/vitest-node-runtime-pool.test.ts',
// Reopen the WAL-backed dismissal cache read-only through the row cache, which Bun on macOS cannot.
// Reopen WAL-backed row caches read-only, which Bun on macOS cannot.
'src/main/agent-hooks/server/testing/identity/server-hook-session-binding.test.ts',
'tests/e2e/helpers/persisted-profile-state.unit.test.ts',
'src/main/runtime/push/notifications/mobile-notification-dismissal-store.test.ts',
'src/main/runtime/push/notifications/mobile-notification-dismissal-read-failure.test.ts',
'src/main/ipc/notifications-subject-retirement.test.ts',
+1 -1
View File
@@ -23,7 +23,7 @@
"../src/cli/runtime/runtime-access-denied.ts",
"../src/cli/runtime/runtime-pid-liveness.ts",
"../src/renderer/src/store/slices/worktrees/create/worktree-create-payload.ts",
"../src/renderer/src/lib/orca-hook-trust.ts",
"../src/renderer/src/runtime/repo-hooks/orca-hook-trust.ts",
"../src/renderer/src/lib/sha256.ts",
"../src/renderer/src/components/native-chat/native-chat-resolution-receipt.ts",
"../src/renderer/src/components/native-chat/structured-agent-question-projection.ts",
+3
View File
@@ -153,6 +153,9 @@ const sharedProjects =
name: `${runtimeProject.test.name}-shared`,
include: sharedWorkerFiles,
isolate: false,
runner: resolve(
'config/scripts/test-runtime/execution-policy/vitest-shared-worker-setup-runner.mjs'
),
setupFiles: [
...runtimeProject.test.setupFiles,
resolve('config/scripts/test-runtime/environment/vitest-shared-worker-file-reset.mjs')
+1 -1
View File
@@ -35,7 +35,7 @@
1 src/renderer/src/runtime/hosts/wsl/local-project-runtime-workspace.ts # P5b-2 must clear: optional state field defaults to empty
1 src/renderer/src/lib/resolved-worktree-execution-host.ts # P5b-2 must clear: loosely typed state param
2 src/renderer/src/lib/workspace/ownership/runtime-session-mirror-owners.ts # P5b-2 must clear: optional state fields default to empty
2 src/renderer/src/lib/terminal-worktree-route.ts # P5b-2 must clear: the unattributed-twin check reads both catalogs directly
2 src/renderer/src/lib/workspace/ownership/terminal-worktree-route.ts # P5b-2 must clear: the unattributed-twin check reads both catalogs directly
3 src/renderer/src/lib/typing-latency/diagnostic-summary.ts # P5b-2 must clear: optional state field
2 src/renderer/src/lib/unread-badge-count.ts # reads a passed-in copy
1 src/renderer/src/lib/workspace-directory.ts # P5b-2 must clear: optional state field defaults to empty
+1 -1
View File
@@ -27,7 +27,7 @@ import {
} from '../src/notifications/push-receive'
import { startPushTokenSync } from '../src/notifications/push-registration'
import { ensureDesktopNotificationChannel } from '../src/notifications/desktop-notification-channel'
import { loadHostCatalog } from '../src/transport/hosts/host-store'
import { loadHostCatalog } from '../src/host-catalog/host-store'
import { usePairingLinks } from '../src/navigation/use-pairing-links'
import { consumeInitialLaunchIntent } from '../src/navigation/initial-launch-intent'
import { recoverMobileRelayPairing } from '../src/pairing/mobile-relay-pairing-recovery'
+2 -2
View File
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useMemo, useState, useSyncExternalStore } from
import { View, Text, Pressable } from 'react-native'
import { useLocalSearchParams, useRouter } from 'expo-router'
import * as Clipboard from 'expo-clipboard'
import { loadHosts } from '../src/transport/hosts/host-store'
import { loadHosts } from '../src/host-catalog/host-store'
import { connectionLogStore } from '../src/diagnostics/connection/persisted-connection-log-store'
import { useRpcClientContext } from '../src/transport/connection/client-context'
import { useHostClient } from '../src/transport/connection/host-client-hooks'
@@ -22,7 +22,7 @@ import { connectionDiagnosticsScreenStyles as styles } from '../src/diagnostics/
import { useMobileColorScheme } from '../src/theme/use-mobile-color-scheme'
import { NATIVE_APP_LOG_ID } from '../src/diagnostics/native-render-log'
import type { ConnectionLogEntry } from '../src/diagnostics/connection/connection-log-types'
import type { HostProfile } from '../src/transport/hosts/host-profile'
import type { HostProfile } from '../src/host-catalog/host-profile'
import { pressedStyle } from '../src/theme/mobile-theme'
// Keep empty snapshot identity stable or useSyncExternalStore rerenders forever.
+4 -4
View File
@@ -18,7 +18,7 @@ import { NavBar } from '../../../src/components/nav-bar/NavBar'
import { NavBarButton } from '../../../src/components/nav-bar/NavBarButton'
import { themedStyleSheet } from '../../../src/theme/themed-styles'
import { useMobileColorScheme } from '../../../src/theme/use-mobile-color-scheme'
import { loadHosts, updateHostNameAndEndpoint } from '../../../src/transport/hosts/host-store'
import { loadHosts, updateHostNameAndEndpoint } from '../../../src/host-catalog/host-store'
import { displayHostEndpoint } from '../../../src/transport/hosts/host-endpoint'
import { resolveHostEndpointEdit } from '../../../src/transport/hosts/host-endpoint-edit'
import {
@@ -26,12 +26,12 @@ import {
usePrimeHosts,
useRefreshHostClient
} from '../../../src/transport/connection/host-client-hooks'
import { removeHostAndCloseClient } from '../../../src/transport/hosts/host-removal-lifecycle'
import { useHostDisplay } from '../../../src/transport/hosts/use-host-display'
import { removeHostAndCloseClient } from '../../../src/host-catalog/host-removal-lifecycle'
import { useHostDisplay } from '../../../src/host-descriptors/use-host-display'
import { leaveHostRoute } from '../../../src/host-route-exit'
import { ConfirmModal } from '../../../src/components/ConfirmModal'
import { ListGroup, ListRow } from '../../../src/components/list/ListGroup'
import type { HostProfile } from '../../../src/transport/hosts/host-profile'
import type { HostProfile } from '../../../src/host-catalog/host-profile'
import { hostOs } from '../../../src/platform/host-os'
import { translate } from '../../../src/i18n/mobile-i18n'
import { useMobileTranslation } from '../../../src/i18n/use-mobile-translation'
+2 -2
View File
@@ -12,8 +12,8 @@ import { colors, spacing } from '../src/theme/mobile-theme'
import { useMobileColorScheme } from '../src/theme/use-mobile-color-scheme'
import type { Translate } from '../src/i18n/mobile-i18n'
import { useMobileTranslation } from '../src/i18n/use-mobile-translation'
import { loadHosts, peekHosts } from '../src/transport/hosts/host-store'
import type { HostProfile } from '../src/transport/hosts/host-profile'
import { loadHosts, peekHosts } from '../src/host-catalog/host-store'
import type { HostProfile } from '../src/host-catalog/host-profile'
import { useFocusedSettingsHostClients } from '../src/settings/settings-host-client-connections'
import type { RpcClient } from '../src/transport/rpc/rpc-client-contract'
import { LIST_LEADING_INSET, ListRow } from '../src/components/list/ListGroup'
+2 -2
View File
@@ -1,7 +1,7 @@
import { useEffect, useMemo, useState } from 'react'
import { useRouter } from 'expo-router'
import { loadHosts, peekHosts } from '../src/transport/hosts/host-store'
import type { HostProfile } from '../src/transport/hosts/host-profile'
import { loadHosts, peekHosts } from '../src/host-catalog/host-store'
import type { HostProfile } from '../src/host-catalog/host-profile'
import { useFocusedSettingsHostClients } from '../src/settings/settings-host-client-connections'
import VoiceSettingsScreen from '../src/settings/voice-settings-screen'
import { nativeVoiceSettingsOperations } from '../src/settings/native-voice-settings-operations'
+2 -2
View File
@@ -16601,7 +16601,7 @@
"id": "notifications-push-registered",
"operation": "notifications.push-registration",
"family": "notifications.push-registration",
"sites": ["mobile/src/notifications/push-registration.ts"],
"sites": ["mobile/src/notifications/mobile-push-registration-operations.ts"],
"schedules": [],
"steps": [
{
@@ -16650,7 +16650,7 @@
"id": "notifications-push-gateway-rejected",
"operation": "notifications.push-registration",
"family": "notifications.push-registration",
"sites": ["mobile/src/notifications/push-registration.ts"],
"sites": ["mobile/src/notifications/mobile-push-registration-operations.ts"],
"schedules": [],
"steps": [
{
+1 -1
View File
@@ -3,7 +3,7 @@ import { View, Text, ScrollView, ActivityIndicator } from 'react-native'
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
import { useFocusEffect, useLocalSearchParams } from 'expo-router'
import { ChevronLeft, RefreshCw, User } from 'lucide-react-native'
import { loadHosts, peekHosts } from '../transport/hosts/host-store'
import { loadHosts, peekHosts } from '../host-catalog/host-store'
import { useForceReconnect, useHostClient } from '../transport/connection/host-client-hooks'
import { useHostConnectionInputs } from '../transport/connection/client-context-connection-metrics'
import { classifyConnection, isConnectionOutage } from '../transport/connection/connection-health'
@@ -16,7 +16,7 @@ import type { TuiAgent } from '../../../src/shared/agent-launch/catalog/tui-agen
import { parseWslUncPath } from '../../../src/shared/wsl-paths'
import { resolveWindowsShellStartupFamily } from '../../../src/shared/windows-terminal-shell'
import { RESUME_RPC_TIMEOUT_MS } from './ai-vault-resume-preparation'
import type { RpcOperationSender } from '../transport/rpc/rpc-operation-sender'
import type { UnvalidatedRpcRequestPort } from '../transport/rpc/unvalidated-rpc-request-port'
import { interpretOrThrowRefusalMessage } from '../transport/rpc/rpc-refusal-message'
import {
reviewTerminalCreateRun,
@@ -78,7 +78,7 @@ export function buildMobileAiVaultResumeLaunch(args: {
}
export async function resumeAiVaultSessionInTerminal(
client: RpcOperationSender,
client: UnvalidatedRpcRequestPort,
worktreeId: string,
launch: MobileAiVaultResumeLaunch & {
clientMutationId?: string
@@ -6,7 +6,7 @@ import {
} from '../../../src/shared/ai-vault/resume/ai-vault-resume-preparation'
import { LOCAL_EXECUTION_HOST_ID } from '../../../src/shared/execution-host'
import { aiVaultResumePreparationRun } from './mobile-ai-vault-resume-operations'
import type { RpcOperationSender } from '../transport/rpc/rpc-operation-sender'
import type { UnvalidatedRpcRequestPort } from '../transport/rpc/unvalidated-rpc-request-port'
import { translate } from '../i18n/mobile-i18n'
// Why: without an explicit timeout, a socket drop mid-resume parks the request
@@ -14,7 +14,7 @@ import { translate } from '../i18n/mobile-i18n'
export const RESUME_RPC_TIMEOUT_MS = 30_000
export async function prepareMobileAiVaultSessionResume(
client: RpcOperationSender,
client: UnvalidatedRpcRequestPort,
session: AiVaultSession
): Promise<AiVaultSession> {
// Why: per-account repinning runs on the serving host, whose account
@@ -4,7 +4,6 @@ import '../files/mobile-file-preview-operations'
import { aiVaultResumePreparationSchema } from './mobile-ai-vault-resume-reply-schema'
import '../browser/mobile-session-browser-reply-schema'
import '../files/session-documents/mobile-file-tap-reply-schema'
import '../transport/rpc/rpc-uninterpreted-reply-schemas'
// Legacy resume reads unsupported-method refusals raw to fall back to shared home.
export const aiVaultResumePreparationRun = bindDeferredRpcOperation(
+2 -2
View File
@@ -12,8 +12,8 @@ import { triggerMediumImpact } from '../platform/haptics'
import { colors, spacing } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import type { HostProfile } from '../transport/hosts/host-profile'
import { useHostDisplay } from '../transport/hosts/use-host-display'
import type { HostProfile } from '../host-catalog/host-profile'
import { useHostDisplay } from '../host-descriptors/use-host-display'
import { agentStateLabel, formatTimeAgo, type AgentDotState } from '../worktree/agent-row-display'
import { isDisclosureOpen, toggleDisclosure } from '../worktree/agent-child-disclosure'
import { areStructurallyEqual } from '../worktree/structural-equality'
@@ -6,7 +6,7 @@ import { TransientToast, useTransientToast } from '../components/TransientToast'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { useClipboardWriter } from '../platform/clipboard'
import { useOpenMobileSession } from '../session/use-open-mobile-session'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import type { AgentActivityChange, AgentListRow } from './agent-list-rows'
import type { AgentListRowHandlers } from './MobileAgentListRows'
import type { AgentActivityFailure } from './use-agent-activity-writes'
@@ -9,8 +9,8 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { firstParam } from '../navigation/route-param-reader'
import { useRouteHandoff } from '../navigation/route-handoff'
import { useHostClient } from '../transport/connection/host-client-hooks'
import { useHostDisplay } from '../transport/hosts/use-host-display'
import { useHostProfile } from '../transport/hosts/use-host-profile'
import { useHostDisplay } from '../host-descriptors/use-host-display'
import { useHostProfile } from '../host-catalog/use-host-profile'
import { useHostProtocolGates } from '../components/host-protocol-gates-context'
import { NavBar, NavBarTitleButton } from '../components/nav-bar/NavBar'
import { NavBarButton } from '../components/nav-bar/NavBarButton'
@@ -4,7 +4,6 @@ import '../files/mobile-file-preview-operations'
import { browserTabCreatedSchema } from './mobile-session-browser-reply-schema'
import '../agent-history/mobile-ai-vault-resume-reply-schema'
import '../files/session-documents/mobile-file-tap-reply-schema'
import '../transport/rpc/rpc-uninterpreted-reply-schemas'
export const sessionBrowserTabCreate = bindDeferredRpcOperation(
defineRpcOperation({
+2 -80
View File
@@ -1,13 +1,6 @@
import { probe, publishLayout, mounted, positions } from './drag-reorder-test-harness.test-fixture'
import { createElement } from 'react'
import { act, create } from 'react-test-renderer'
import Animated, { useAnimatedRef, useSharedValue } from 'react-native-reanimated'
import { probe, mounted, positions } from './drag-reorder-test-harness.test-fixture'
import { act } from 'react-test-renderer'
import { describe, expect, it, vi } from 'vitest'
import { DragReorderList } from './DragReorderList'
import { GripVertical } from 'lucide-react-native'
import { queuedMessageStyles } from '../session/native-chat/input/mobile-native-chat-queued-message-styles'
import { spacing } from '../theme/mobile-theme'
describe('drag completion and cancellation', () => {
it('restores original positions and writes nothing when an active drag is cancelled', async () => {
@@ -204,74 +197,3 @@ describe('late gesture callbacks', () => {
expect(fixture.onReorder).not.toHaveBeenCalled()
})
})
it('stops scrolling at the viewport edge when rows are replaced', async () => {
const fixture = await mounted()
probe.viewport = { pageY: 0, height: 100 }
await act(async () => {
fixture.gesture.start!({ absoluteY: 90, translationY: 0 }, true)
probe.frame!({ timeSincePreviousFrame: 16 })
})
expect(probe.scroll).toHaveBeenCalledTimes(1)
await fixture.updateItems(['b', 'c'])
await act(async () => probe.frame!({ timeSincePreviousFrame: 16 }))
expect(probe.scroll).toHaveBeenCalledTimes(1)
expect(probe.frameActive).toHaveBeenLastCalledWith(false)
await act(async () => fixture.root.unmount())
})
it('keeps measured rows still on hold, restores cancellation, and drops by moved ID plus neighbor', async () => {
const move = vi.fn()
function Harness() {
return createElement(DragReorderList<string>, {
items: ['a', 'b', 'c'],
itemKey: (item) => item,
rowPresentation: 'plain',
renderRow: (item, handle) => createElement('Text', null, item, handle),
onMove: move,
scrollRef: useAnimatedRef<Animated.ScrollView>(),
scrollOffsetY: useSharedValue(0),
scrollContentHeight: useSharedValue(140)
})
}
let root: ReturnType<typeof create>
await act(async () => {
root = create(createElement(Harness))
})
const handle = root!.root.findAllByType(Animated.View).find((node) => node.props.hitSlop)!
const handleStyle = Object.assign({}, ...handle.props.style)
const gripWidth = handle.findByType(GripVertical).props.size
const width = gripWidth + 2 * handleStyle.paddingHorizontal
const left = queuedMessageStyles.row.paddingLeft - handle.props.hitSlop.left
const right = queuedMessageStyles.row.paddingLeft + width + handle.props.hitSlop.right
expect(handleStyle.paddingHorizontal).toBe(spacing.xs)
expect([left, right]).toEqual([4, 62])
expect(right - Math.max(0, left)).toBe(58)
const rows = root!.root.findAll(
(node) => node.type === Animated.View && typeof node.props.onLayout === 'function'
)
await act(async () =>
rows.forEach((row, index) =>
row.props.onLayout({ nativeEvent: { layout: { height: index === 0 ? 100 : 20 } } })
)
)
await publishLayout()
const gesture = probe.gestures.at(-3)!
const at = (translationY: number) => ({ absoluteY: 100 + translationY, translationY })
await act(async () => {
gesture.start!(at(0), true)
gesture.update!(at(0), true)
gesture.finalize!(at(0), true)
gesture.start!(at(0), true)
gesture.update!(at(35), true)
gesture.finalize!(at(35), false)
})
expect(move).not.toHaveBeenCalled()
await act(async () => {
gesture.start!(at(0), true)
gesture.update!(at(35), true)
gesture.finalize!(at(35), true)
})
expect(move).toHaveBeenCalledExactlyOnceWith({ movedId: 'a', afterId: 'c' })
await act(async () => root!.unmount())
})
@@ -62,9 +62,9 @@ vi.mock('../host-screen/host-list-queries', () => ({
(hostId && cachedRepos.get(hostId)) || null
}))
import '../transport/hosts/host-descriptor-store'
import '../host-descriptors/host-descriptor-store'
import { FakeSession } from '../transport/connection/mobile-endpoint-supervisor-test-fakes'
import { markRpcDeliveryUnknown } from '../transport/rpc/rpc-delivery-ambiguity'
import '../../../src/shared/execution-host'
import type { ExecutionHostId } from '../../../src/shared/execution-host'
@@ -231,72 +231,6 @@ describe('NewWorktreeModal project targets', () => {
expect(runTargetPicker(renderer).props.selectedId).toBe('runtime:env-1')
})
async function submitFromFolder(createReply: () => Promise<RpcResponse>) {
const serverRepo = { ...repos[0]!, path: '/srv/orca' }
const server = requestsOnly(
vi.fn((method: string) =>
method === 'repo.list'
? replied({ repos: [serverRepo] })
: method === 'worktree.create'
? createReply()
: Promise.reject(new Error(`unexpected ${method}`))
)
)
const settle = vi.fn()
await act(async () => {
renderer = create(
createElement(NewWorktreeModal, {
visible: true,
client: requestsOnly(() => new Promise<never>(() => {})),
serverClients: new Map<ExecutionHostId, RpcClient>([['runtime:env-1', server]]),
hostId: 'host-1',
onCreated: () => {},
onClose: () => {},
openExternalUrl: () => {},
folderLaunch: {
repoId: 'repo-1',
executionHostId: 'runtime:env-1',
name: 'payments',
parentWorkspace: 'folder:f-1',
submit: { begin: () => ({ settle }), presenting: () => true }
}
})
)
})
await flushUpdates()
const form = renderer.root.find((node) => typeof node.props.onCreate === 'function')
await act(async () => form.props.onCreate())
await flushUpdates()
const creates = vi
.mocked(server.sendRequest)
.mock.calls.filter(([method]) => method === 'worktree.create')
return { creates: creates.map(([, params]) => params), settle }
}
it('creates from a folder attached to that folder, on its host', async () => {
const { creates, settle } = await submitFromFolder(() =>
replied({ worktree: { id: 'repo-1::/srv/w/payments', displayName: 'payments' } })
)
expect(creates).toEqual([
expect.objectContaining({
repo: 'id:repo-1',
parentWorkspace: 'folder:f-1',
parentWorkspaceOrigin: 'manual'
})
])
expect(settle).toHaveBeenCalledWith('created')
})
it("doesn't try another name when a folder create's reply is lost", async () => {
const { creates, settle } = await submitFromFolder(() =>
Promise.reject(markRpcDeliveryUnknown(new Error('connection lost')))
)
expect(creates).toHaveLength(1)
expect(settle).toHaveBeenCalledWith('uncertain')
})
it('ignores a stale repo list after the client changes', async () => {
let resolveOldList: ((value: unknown) => void) | undefined
const oldList = new Promise((resolve) => {
+1 -1
View File
@@ -10,7 +10,7 @@ import { deriveRepoSlug, type PasteRepoCandidate } from '../tasks/smart-source-p
import { useMobileComposerSource } from '../tasks/use-mobile-composer-source'
import { useNewWorktreeRuntimeCapabilities } from '../tasks/worktree-create-capability'
import { useWorktreeCreateBasePrefetch } from '../tasks/use-worktree-create-base-prefetch'
import { useHostDescriptor } from '../transport/hosts/host-descriptor-store'
import { useHostDescriptor } from '../host-descriptors/host-descriptor-store'
import { isSameMobileWorkspaceRepo } from '../worktree/new-workspace-dialog-repo-selection'
import {
buildRetiredWorktreeNamesRefreshKey,
@@ -1,7 +1,7 @@
import { createElement } from 'react'
import { act, create, type ReactTestRenderer } from 'react-test-renderer'
import { afterEach, describe, expect, it, vi } from 'vitest'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import { useConnectedHostPicker } from './use-connected-host-picker'
function host(id: string, name: string, endpoint: string): HostProfile {
@@ -1,6 +1,6 @@
import { useRef, useState } from 'react'
import { hostEndpointLabel } from '../transport/hosts/host-endpoint-label'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
/** Picker rows for desktops, telling apart two that share a name and endpoint. */
export function hostPickerOptions(hosts: HostProfile[]) {
@@ -44,31 +44,25 @@ afterEach(async () => {
})
describe('useNewWorkspaceRepositories initial repo', () => {
it.each([
{ order: 'desktop first', desktopFirst: true },
{ order: 'server first', desktopFirst: false }
])(
'picks the named host’s copy of a repo id two hosts share ($order)',
async ({ desktopFirst }) => {
const client = desktopListing(desktopFirst ? [repo()] : [])
let picked: MobileWorkspaceRepo | null = null
mounted = hookMount(() => {
picked = useNewWorkspaceRepositories({
client,
hostId: 'host-1',
visible: true,
initialRepo: { id: 'api', executionHostId: SERVER }
}).selectedRepo
})
mounted.mount()
await settleQueryNotifications()
// The desktop's same-id repo must not stand in while the server's listing is on its way.
expect(picked).toBeNull()
it('picks the named host’s copy of a repo id two hosts share', async () => {
const client = desktopListing([repo()])
let picked: MobileWorkspaceRepo | null = null
mounted = hookMount(() => {
picked = useNewWorkspaceRepositories({
client,
hostId: 'host-1',
visible: true,
initialRepo: { id: 'api', executionHostId: SERVER }
}).selectedRepo
})
mounted.mount()
await settleQueryNotifications()
// The desktop's same-id repo must not stand in while the server's listing is on its way.
expect(picked).toBeNull()
servers.repos = new Map([[SERVER, [repo(SERVER)]]])
act(() => mounted?.update())
await settleQueryNotifications()
expect(picked).toMatchObject({ id: 'api', executionHostId: SERVER })
}
)
servers.repos = new Map([[SERVER, [repo(SERVER)]]])
act(() => mounted?.update())
await settleQueryNotifications()
expect(picked).toMatchObject({ id: 'api', executionHostId: SERVER })
})
})
+2 -2
View File
@@ -7,11 +7,11 @@ import type { AESEncryptionKey } from 'expo-crypto'
import { Directory, Paths } from 'expo-file-system'
import { AppState } from 'react-native'
import { createExpoGenerationFileSystem } from '../mobile-web-shell/generation-store-file-system'
import { loadStoredHostProfiles } from '../transport/hosts/host-metadata-store'
import { loadStoredHostProfiles } from '../host-catalog/host-metadata-store'
import {
readPairingKeychainItem,
writePairingKeychainItem
} from '../transport/hosts/pairing-keychain'
} from '../host-credentials/pairing-keychain'
import {
createRootIndex,
DEVICE_STORE_CAPS,
@@ -5,7 +5,7 @@ import type {
MobileConnectionDiagnosticPath
} from './connection/connection-log-types'
import type { ConnectionState } from '../transport/connection/connection-state'
import { normalizeHostAppVersion } from '../transport/hosts/host-app-version'
import { normalizeHostAppVersion } from '../host-descriptors/host-app-version'
import { formatEndpoint } from './host-reachability'
import { diagnoseConnection } from './connection-diagnostics-analysis'
import { redactConnectionLogEntry, redactConnectionLogText } from './connection-log-redaction'
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'
import { resolveDiagnosticsHostId } from './connection-diagnostics-screen-data'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
const host = (id: string): HostProfile => ({
id,
@@ -1,6 +1,6 @@
import type { ConnectionLogStore } from './connection/connection-log-buffer'
import type { ConnectionLogEntry } from './connection/connection-log-types'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import type { RpcClientContextValue } from '../transport/connection/rpc-client-context-contract'
/** Route identity token: compared by reference to detect navigating away and back, never read. */
@@ -1,7 +1,7 @@
import { useEffect, useState } from 'react'
import { View, Text, Pressable, ActivityIndicator } from 'react-native'
import { Package } from 'lucide-react-native'
import { loadHosts } from '../transport/hosts/host-store'
import { loadHosts } from '../host-catalog/host-store'
import { colors } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { troubleshootScreenStyles as styles } from './troubleshoot-screen-styles'
@@ -9,7 +9,7 @@ import {
useMobileWebBundleProbe,
type MobileWebBundleProbeState
} from './use-mobile-web-bundle-probe'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import type { Translate } from '../i18n/mobile-i18n'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { ListGroup, ListRow } from '../components/list/ListGroup'
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'
import { Text, View } from 'react-native'
import type { MobileWebShellUpdateFailure } from '../mobile-web-shell/mobile-web-shell-update-failure'
import { processGenerationStore } from '../mobile-web-shell/process-generation-store'
import { loadHosts } from '../transport/hosts/host-store'
import { loadHosts } from '../host-catalog/host-store'
import { formatUpdateFailure } from './mobile-web-shell-update-failure-copy'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { troubleshootScreenStyles as styles } from './troubleshoot-screen-styles'
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { ConnectionState } from '../transport/connection/connection-state'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import { createNativeDiagnosticsOperations } from './native-diagnostics-operations'
const logStore = vi.hoisted(() => ({
@@ -1,6 +1,6 @@
import { Platform } from 'react-native'
import Constants from 'expo-constants'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import type { RpcClientContextValue } from '../transport/connection/rpc-client-context-contract'
import { connectionLogStore } from './connection/persisted-connection-log-store'
import {
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'
import type { View } from 'react-native'
import { Platform } from 'react-native'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { loadHostCatalog, loadHosts } from '../transport/hosts/host-store'
import { loadHostCatalog, loadHosts } from '../host-catalog/host-store'
import {
startDiagnosticFetchTimeout,
type DiagnosticFetchTimeout
@@ -3,7 +3,7 @@ import {
hostDictationErrorMessage
} from '../../../src/shared/host-dictation-error-messages'
import { translate } from '../i18n/mobile-i18n'
import type { RpcOperationSender } from '../transport/rpc/rpc-operation-sender'
import type { UnvalidatedRpcRequestPort } from '../transport/rpc/unvalidated-rpc-request-port'
import type { RpcResponse } from '../transport/rpc/rpc-wire-types'
import { interpretOrThrowRefusalMessage } from '../transport/rpc/rpc-refusal-message'
import '../transport/connection/stable-logical-rpc-client'
@@ -128,7 +128,7 @@ export function isDictationSetupRequiredError(message: string): boolean {
/** `worktreeId` asks for that repo's dictionary terms too. */
export async function fetchDictationSetup(
client: RpcOperationSender,
client: UnvalidatedRpcRequestPort,
worktreeId?: string
): Promise<MobileSpeechSetup> {
const reply = await requestDictationSetupReply(client, worktreeId ? { worktreeId } : null)
@@ -150,7 +150,7 @@ export async function fetchDictationSetup(
}
async function requestDictationSetupReply(
client: RpcOperationSender,
client: UnvalidatedRpcRequestPort,
params: { worktreeId: string } | null
): Promise<RpcResponse> {
try {
@@ -165,7 +165,7 @@ async function requestDictationSetupReply(
}
export async function downloadDictationModel(
client: RpcOperationSender,
client: UnvalidatedRpcRequestPort,
modelId: string
): Promise<void> {
const reply = await dictationModelDownload.request(client, { modelId })
@@ -176,7 +176,7 @@ export async function downloadDictationModel(
}
export async function deleteDictationModel(
client: RpcOperationSender,
client: UnvalidatedRpcRequestPort,
modelId: string
): Promise<MobileSpeechSetup> {
const reply = await dictationModelDelete.request(client, { modelId })
@@ -187,7 +187,7 @@ export async function deleteDictationModel(
}
export async function setDictationConfig(
client: RpcOperationSender,
client: UnvalidatedRpcRequestPort,
params: {
enabled?: boolean
modelId?: string
@@ -1,8 +1,8 @@
import { useCallback, useLayoutEffect, useMemo, useRef } from 'react'
import type { UseMobileDictationResult } from '../hooks/mobile-dictation-session-state'
import { useWorkspaceExecutionHost } from '../navigation/workspace-execution-host'
import { useHostDisplay } from '../transport/hosts/use-host-display'
import { useHostProfile } from '../transport/hosts/use-host-profile'
import { useHostDisplay } from '../host-descriptors/use-host-display'
import { useHostProfile } from '../host-catalog/use-host-profile'
import type { MobileDictationLive } from './mobile-dictation-live-context'
import { dictationFailureReason } from './mobile-dictation-controls-copy'
@@ -8,7 +8,7 @@ import {
type AttachmentTextRead
} from '../../../src/shared/attachment-text/attachment-text-source'
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
import type { RpcOperationSender } from '../transport/rpc/rpc-operation-sender'
import type { UnvalidatedRpcRequestPort } from '../transport/rpc/unvalidated-rpc-request-port'
// Match the shared wire identifier without importing the host capability aggregate into this route.
const AGENT_SESSION_TEXT_ATTACHMENT_READ_CAPABILITY = 'native-chat.text-attachment-read.v1'
@@ -23,7 +23,7 @@ const textRead = bindDeferredRpcOperation(
})
)
type AttachmentReaderClient = RpcOperationSender &
type AttachmentReaderClient = UnvalidatedRpcRequestPort &
Pick<RpcClient, 'getState' | 'getLastConnectedAt' | 'getGeneration'>
export function createMobileChatAttachmentReader(
@@ -2,13 +2,6 @@ import { bindDeferredRpcOperation, defineRpcOperation } from '../transport/rpc/r
import { rpcResultVariant } from '../transport/rpc/rpc-operation-result-reader'
import '../terminal/terminal-reply-schema'
import { workspaceFilePathsSchema } from './workspace-file-paths-reply-schema'
import '../session/agent-launch/mobile-agent-detection-reply-schema'
import './session-documents/mobile-markdown-tab-reply-schema'
import '../transport/rpc/rpc-uninterpreted-reply-schemas'
import '../terminal/session/mobile-session-terminal-reply-schema'
import '../worktree/session-worktree-record-reply-schema'
import '../session/native-chat/composer/mobile-native-chat-skill-reply-schema'
import '../terminal/quick-commands/mobile-quick-command-reply-schema'
// Skip refusals to retain suggestions; inspect method_not_found first to fall back from search to inventory.
export const nativeChatFileSearchRead = bindDeferredRpcOperation(
@@ -12,7 +12,7 @@ import {
type OpenedMobileSessionTabActivationState
} from '../../session/tabs/opened-mobile-session-tab'
import { isRendererUnavailableReply } from '../../transport/rpc/renderer-unavailable-reply'
import type { RpcOperationSender } from '../../transport/rpc/rpc-operation-sender'
import type { UnvalidatedRpcRequestPort } from '../../transport/rpc/unvalidated-rpc-request-port'
import type { RpcResponse } from '../../transport/rpc/rpc-wire-types'
// Hard-wrap guesses can number in the hundreds; stay far below the page bridge's 64 pending requests.
@@ -30,7 +30,7 @@ export type MobileFileTapFailure = {
}
export type OpenMobileFileTapOptions<T extends FileTapSessionTab> = {
client: RpcOperationSender
client: UnvalidatedRpcRequestPort
hostId: string
worktreeId: string
worktreeName?: string
@@ -4,7 +4,6 @@ import '../mobile-file-preview-operations'
import { fileTapOpenedSchema } from './mobile-file-tap-reply-schema'
import '../../agent-history/mobile-ai-vault-resume-reply-schema'
import '../../browser/mobile-session-browser-reply-schema'
import '../../transport/rpc/rpc-uninterpreted-reply-schemas'
// Best-effort taps skip refused opens; explicit Changes-screen opens instead show the host error.
export const fileTapOpenRun = bindDeferredRpcOperation(
@@ -19,13 +19,6 @@ export const sessionMarkdownNoteCreate = bindDeferredRpcOperation(
import '../../terminal/terminal-reply-schema'
import { markdownTabDocumentSchema } from './mobile-markdown-tab-reply-schema'
import '../../session/agent-launch/mobile-agent-detection-reply-schema'
import '../../terminal/session/mobile-session-terminal-reply-schema'
import '../../worktree/session-worktree-record-reply-schema'
import '../../session/native-chat/composer/mobile-native-chat-skill-reply-schema'
import '../../terminal/quick-commands/mobile-quick-command-reply-schema'
import '../workspace-file-paths-reply-schema'
// Inspect renderer_unavailable before interpretation so headless hosts can fall back to disk.
export const markdownTabRead = bindDeferredRpcOperation(
@@ -38,8 +31,6 @@ export const markdownTabRead = bindDeferredRpcOperation(
})
)
import '../../session/tabs/mobile-session-tab-write-reply-schema'
import '../../terminal/quick-commands/mobile-quick-command-operations'
export const markdownTabSave = bindDeferredRpcOperation(
@@ -6,10 +6,10 @@ import { useWorkspaceRouteHandoff } from '../../navigation/workspace-route-hando
import { triggerSelection } from '../../platform/haptics'
import { openMobileFileTap, type FileTapSessionTab } from './mobile-file-tap-open'
import { openMobileNativeChatFileTap } from '../../session/native-chat/visual/mobile-native-chat-open-file'
import type { RpcOperationSender } from '../../transport/rpc/rpc-operation-sender'
import type { UnvalidatedRpcRequestPort } from '../../transport/rpc/unvalidated-rpc-request-port'
type MobileFileTapHandlerOptions<T extends FileTapSessionTab> = {
client: RpcOperationSender | null
client: UnvalidatedRpcRequestPort | null
hostId: string
worktreeId: string
worktreeName?: string
+1 -1
View File
@@ -2,7 +2,7 @@ import { memo } from 'react'
import type { AgentListRow } from '../agents/agent-list-rows'
import { MobileAgentListRows, type AgentListRowHandlers } from '../agents/MobileAgentListRows'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import { areStructurallyEqual } from '../worktree/structural-equality'
import { MobileHomeSectionHeading } from './MobileHomeSectionHeading'
+2 -2
View File
@@ -6,10 +6,10 @@ import { statusDotColor } from '../components/StatusDot'
import type { ConnectionVerdict } from '../transport/connection/connection-health'
import { verdictDisplayLabel } from '../transport/connection/connection-health'
import { mobileConnectionPathAccessibilityLabel } from '../transport/connection/mobile-connection-path-label'
import { useHostDisplay } from '../transport/hosts/use-host-display'
import { useHostDisplay } from '../host-descriptors/use-host-display'
import type { MobileConnectionPath } from '../transport/connection/stable-logical-rpc-client'
import type { ConnectionState } from '../transport/connection/connection-state'
import type { HostCatalogEntry, HostProfile } from '../transport/hosts/host-profile'
import type { HostCatalogEntry, HostProfile } from '../host-catalog/host-profile'
import { colors } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { homeHostWorktreeSummary, type HostWorktreeInfo } from '../worktree/home-worktree-info'
+1 -1
View File
@@ -7,7 +7,7 @@ import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { classifyConnection } from '../transport/connection/connection-health'
import { resolveHomeHostConnectionState } from '../transport/hosts/home-host-auto-connect'
import type { ConnectionState } from '../transport/connection/connection-state'
import type { HostCatalogEntry } from '../transport/hosts/host-profile'
import type { HostCatalogEntry } from '../host-catalog/host-profile'
import type { HostWorktreeInfo } from '../worktree/home-worktree-info'
import type { HomeHostConnections } from './home-host-connection-projection'
import { homeListStyles } from './home-list-styles'
+3 -3
View File
@@ -23,9 +23,9 @@ import {
} from '../transport/connection/host-client-hooks'
import { hostEndpointLabel } from '../transport/hosts/host-endpoint-label'
import { resolveHomeHostConnectionState } from '../transport/hosts/home-host-auto-connect'
import { removeHostAndCloseClient } from '../transport/hosts/host-removal-lifecycle'
import { loadHostCatalog } from '../transport/hosts/host-store'
import type { HostCatalogEntry, HostProfile } from '../transport/hosts/host-profile'
import { removeHostAndCloseClient } from '../host-catalog/host-removal-lifecycle'
import { loadHostCatalog } from '../host-catalog/host-store'
import type { HostCatalogEntry, HostProfile } from '../host-catalog/host-profile'
import { useOpenMobileHostEdit } from '../host-screen/use-open-mobile-host-edit'
import { mobileConnectionPathLabel } from '../transport/connection/mobile-connection-path-label'
import { newWorkspaceOverlayHref } from '../new-workspace/new-workspace-overlay-route'
+1 -1
View File
@@ -6,7 +6,7 @@ import { PickerModal } from '../components/PickerModal'
import { useConnectedHostPicker } from '../components/use-connected-host-picker'
import { colors } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import type { HostProfile } from '../transport/hosts/host-profile'
import type { HostProfile } from '../host-catalog/host-profile'
import { homeListStyles as styles } from './home-list-styles'
type HomeHostSectionProps = {
@@ -1,6 +1,6 @@
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
import type { ConnectionState } from '../transport/connection/connection-state'
import type { HostCatalogEntry } from '../transport/hosts/host-profile'
import type { HostCatalogEntry } from '../host-catalog/host-profile'
export type MobileHomeClientEntry = {
hostId: string
@@ -7,8 +7,8 @@ import type { Translate } from '../../i18n/mobile-i18n'
import { useMobileTranslation } from '../../i18n/use-mobile-translation'
import { colors } from '../../theme/mobile-theme'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import type { HostProfile } from '../../transport/hosts/host-profile'
import { useHostDisplay } from '../../transport/hosts/use-host-display'
import type { HostProfile } from '../../host-catalog/host-profile'
import { useHostDisplay } from '../../host-descriptors/use-host-display'
import { MobileHomePill } from './MobileHomeHostPill'
const ALL_DESKTOPS = '__all__'
+2 -2
View File
@@ -29,8 +29,8 @@ import { useSerializedStoredState } from '../../storage/use-serialized-stored-st
import { colors, spacing } from '../../theme/mobile-theme'
import { themedStyleSheet } from '../../theme/themed-styles'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import type { HostProfile } from '../../transport/hosts/host-profile'
import { useHostDisplay } from '../../transport/hosts/use-host-display'
import type { HostProfile } from '../../host-catalog/host-profile'
import { useHostDisplay } from '../../host-descriptors/use-host-display'
import { formatTimeAgo } from '../../worktree/agent-row-display'
import { homeListStyles } from '../home-list-styles'
import { MobileHomeSectionHeading } from '../MobileHomeSectionHeading'
@@ -20,8 +20,8 @@ import { themedStyleSheet } from '../../theme/themed-styles'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import { useHostClient } from '../../transport/connection/host-client-hooks'
import type { ConnectionState } from '../../transport/connection/connection-state'
import type { HostProfile } from '../../transport/hosts/host-profile'
import { useHostDisplay } from '../../transport/hosts/use-host-display'
import type { HostProfile } from '../../host-catalog/host-profile'
import { useHostDisplay } from '../../host-descriptors/use-host-display'
import { homeListStyles as list } from '../home-list-styles'
import { MobileHomeSectionHeading } from '../MobileHomeSectionHeading'
import { MobileHomeAutomationRow, MobileHomeAutomationRunRow } from './MobileHomeAutomationRows'
+1 -1
View File
@@ -4,7 +4,7 @@ import { useResponsiveLayout } from '../../layout/responsive-layout'
import { spacing } from '../../theme/mobile-theme'
import { themedStyleSheet } from '../../theme/themed-styles'
import type { AgentListRowHandlers } from '../../agents/MobileAgentListRows'
import type { HostCatalogEntry } from '../../transport/hosts/host-profile'
import type { HostCatalogEntry } from '../../host-catalog/host-profile'
import { MobileHomeAppUpdateCard } from '../MobileHomeAppUpdateCard'
import { MobileHomeEmptyState } from '../MobileHomeEmptyState'
import { MobileHomeHostList } from '../MobileHomeHostList'
+2 -2
View File
@@ -10,8 +10,8 @@ import { colors, radii, spacing } from '../../theme/mobile-theme'
import { themedStyleSheet } from '../../theme/themed-styles'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import type { ConnectionState } from '../../transport/connection/connection-state'
import type { HostProfile } from '../../transport/hosts/host-profile'
import { useHostDisplay } from '../../transport/hosts/use-host-display'
import type { HostProfile } from '../../host-catalog/host-profile'
import { useHostDisplay } from '../../host-descriptors/use-host-display'
/** The desktop a per-desktop tab shows; it stays put until the user picks another or it is unpaired. */
export function useHomeTabHost(hosts: readonly HostProfile[], preferred: readonly HostProfile[]) {
+2 -2
View File
@@ -25,8 +25,8 @@ import '../../theme/themed-styles'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import { useHostClient } from '../../transport/connection/host-client-hooks'
import type { ConnectionState } from '../../transport/connection/connection-state'
import type { HostProfile } from '../../transport/hosts/host-profile'
import { useHostDisplay } from '../../transport/hosts/use-host-display'
import type { HostProfile } from '../../host-catalog/host-profile'
import { useHostDisplay } from '../../host-descriptors/use-host-display'
import { formatTimeAgo } from '../../worktree/agent-row-display'
import { homeListStyles } from '../home-list-styles'
import { MobileHomeSectionHeading } from '../MobileHomeSectionHeading'
+3 -3
View File
@@ -30,9 +30,9 @@ import {
import {
selectConnectableHostProfiles,
sortHostsByLastConnected
} from '../transport/hosts/host-catalog-selection'
import { loadHostCatalog } from '../transport/hosts/host-store'
import type { HostCatalogEntry } from '../transport/hosts/host-profile'
} from '../host-catalog/host-catalog-selection'
import { loadHostCatalog } from '../host-catalog/host-store'
import type { HostCatalogEntry } from '../host-catalog/host-profile'
import { hostObserverOptions, type HostQuery } from '../query/host-query'
import { isHostNotConnectedError } from '../query/host-query-errors'
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
@@ -12,7 +12,7 @@ import { usePrimeHosts } from '../transport/connection/host-client-hooks'
import { selectHomeAutoConnectHostIds } from '../transport/hosts/home-host-auto-connect'
import type { RpcClient } from '../transport/rpc/rpc-client-contract'
import type { ConnectionState } from '../transport/connection/connection-state'
import type { HostCatalogEntry, HostProfile } from '../transport/hosts/host-profile'
import type { HostCatalogEntry, HostProfile } from '../host-catalog/host-profile'
import { useAllHostClients } from '../transport/connection/use-all-host-clients'
import {
readMobileHomeLastConnected,
@@ -1,4 +1,4 @@
import type { MobileRelayEndpoint } from '../../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import type { MobileRelayEndpoint } from '../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import type { HostListSnapshot } from './host-list-load-sharing'
import type { HostCatalogEntry, StoredHostProfile } from './host-profile'
@@ -0,0 +1,17 @@
import { mutateStoredHosts } from './host-list-mutation-queue'
export async function updateLastConnected(hostId: string): Promise<void> {
try {
await mutateStoredHosts((hosts) => {
const index = hosts.findIndex((h) => h.id === hostId)
if (index === -1) {
return hosts
}
const next = hosts.slice()
next[index] = { ...next[index]!, lastConnected: Date.now() }
return next
})
} catch {
// Swallow bookkeeping failures because void callers cannot catch them.
}
}
@@ -0,0 +1,2 @@
// Recency belongs to the native host list, which this page does not show.
export const updateLastConnected = (_hostId: string): Promise<void> => Promise.resolve()
@@ -25,7 +25,7 @@ vi.mock('react-native', () => ({
Platform: { OS: 'ios' }
}))
vi.mock('./host-credential-cleanup', () => ({
vi.mock('../host-credentials/host-credential-cleanup', () => ({
cancelPendingHostCredentialCleanup: vi.fn().mockResolvedValue(undefined),
recordHostCredentialCleanupIntent: vi.fn().mockResolvedValue(undefined),
scheduleHostCredentialCleanup: vi.fn().mockResolvedValue(undefined),
@@ -38,7 +38,7 @@ import {
savePairedHost,
updateHostNameAndEndpoint
} from './host-store'
import { updateHostDescriptor } from './host-descriptor-persistence'
import { updateHostDescriptor } from '../host-descriptors/host-descriptor-persistence'
import { resetMobileRelayHostOverlayStoreForTests } from './mobile-relay-host-overlay-store'
import { StoredHostProfileSchema, type StoredHostProfile } from './host-profile'
@@ -1,6 +1,6 @@
import { GENERATED_HOST_NAME_PATTERN, getNextHostNameFromHosts } from './host-names'
import type { StoredHostProfile } from './host-profile'
import { sameHostMachine, type HostMachine } from '../../../../src/shared/host-machine-line'
import { sameHostMachine, type HostMachine } from '../../../src/shared/host-machine-line'
// Resolve name identity inside host-store’s serialized mutation so display name and sources commit together; see withReportedDescriptor’s omission exception.
@@ -1,13 +1,13 @@
import { z } from 'zod'
import '../../../../src/shared/remote-runtime/pairing/mobile-relay-pairing-offer'
import '../../../src/shared/remote-runtime/pairing/mobile-relay-pairing-offer'
import {
MobileRelayEndpointSchema,
type MobileRelayEndpoint
} from '../../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import { NODE_PLATFORM_NAMES } from '../connection/mobile-runtime-host-platform'
import { salvagedOptional } from '../../../../src/shared/zod-salvage'
import type { HostMachine } from '../../../../src/shared/host-machine-line'
import { HostMachineSchema } from './host-status-reply-schema'
} from '../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import { NODE_PLATFORM_NAMES } from '../transport/connection/mobile-runtime-host-platform'
import { salvagedOptional } from '../../../src/shared/zod-salvage'
import type { HostMachine } from '../../../src/shared/host-machine-line'
import { HostMachineSchema } from '../transport/hosts/host-status-reply-schema'
export type HostProfile = {
id: string
@@ -1,12 +1,12 @@
import type { QueryClient } from '@tanstack/react-query'
import { wipeHostStore } from '../../device-store/device-store'
import { wipeHostStore } from '../device-store/device-store'
import {
deleteHostPageCache,
forgetHostUpdateFailures
} from '../../mobile-web-shell/removed-host-shell-cache'
import { unregisterPushForRemovedHost } from '../../notifications/push-registration'
import { forgetNativeHostQueries } from '../../query/native-query-persistence'
import { forgetHostDescriptor } from './host-descriptor-store'
} from '../mobile-web-shell/removed-host-shell-cache'
import { unregisterPushForRemovedHost } from '../notifications/push-registration'
import { forgetNativeHostQueries } from '../query/native-query-persistence'
import { forgetHostDescriptor } from '../host-descriptors/host-descriptor-store'
import { removeHost } from './host-store'
export async function removeHostAndCloseClient(
@@ -31,24 +31,14 @@ vi.mock('react-native', () => ({
Platform: platformMock
}))
vi.mock('./host-credential-cleanup', () => ({
vi.mock('../host-credentials/host-credential-cleanup', () => ({
cancelPendingHostCredentialCleanup: (...args: unknown[]) => cancelCleanupMock(...args),
recordHostCredentialCleanupIntent: (...args: unknown[]) => recordCleanupIntentMock(...args),
scheduleHostCredentialCleanup: (...args: unknown[]) => scheduleCleanupMock(...args),
retryPendingHostCredentialCleanups: vi.fn()
}))
import {
loadHostCatalog,
loadHosts,
RelayRoutingHostRemovedError,
removeHost,
resolvePairingHostIdentity,
resetHostStoreForTests,
savePairedHost,
setRelayRouting,
updateHostNameAndEndpoint
} from './host-store'
import { loadHostCatalog, loadHosts, resetHostStoreForTests, savePairedHost } from './host-store'
import { resetMobileRelayHostOverlayStoreForTests } from './mobile-relay-host-overlay-store'
const HOSTS_STORAGE_KEY = 'orca:hosts'
@@ -67,14 +57,6 @@ const HOST_TWO = {
publicKeyB64: 'key-2',
lastConnected: 0
}
const HOST_ONE_RELAY = {
v: 1 as const,
directorUrl: 'https://relay.onorca.dev',
cellUrl: 'https://relay-c1.onorca.dev',
assignmentEpoch: 7,
relayHostId: 'AbCdEf0123_-xyZ9',
e2eeFraming: 2 as const
}
describe('host-store list mutations', () => {
let storedHostsRaw: string
@@ -134,13 +116,6 @@ describe('host-store list mutations', () => {
expect(profiles.map(({ id }) => id)).toEqual([HOST_TWO.id])
})
it('fails closed when durable host identity storage is unreadable', async () => {
asyncStorageMock.getItem.mockRejectedValueOnce(new Error('storage unavailable'))
await expect(resolvePairingHostIdentity('key-new', 'host-new')).rejects.toThrow(/unreadable/)
expect(asyncStorageMock.setItem).not.toHaveBeenCalled()
})
it('serves a committed replacement token when same-key metadata persistence fails', async () => {
const duplicate = {
...HOST_TWO,
@@ -164,148 +139,6 @@ describe('host-store list mutations', () => {
loadHosts().then((hosts) => hosts.find(({ id }) => id === HOST_ONE.id)?.deviceToken)
).resolves.toBe('replacement-token')
})
it('refuses an early same-key token write without durable cleanup intent', async () => {
const replacement = {
...HOST_TWO,
id: 'host-replacement',
publicKeyB64: HOST_ONE.publicKeyB64,
deviceToken: 'replacement-token'
}
recordCleanupIntentMock.mockRejectedValueOnce(new Error('intent storage unavailable'))
await expect(savePairedHost(replacement)).rejects.toThrow('intent storage unavailable')
expect(JSON.parse(storedHostsRaw)).toEqual([HOST_ONE, HOST_TWO])
expect(secureStoreMock.setItemAsync).not.toHaveBeenCalled()
})
it('refuses to resurrect a removed host during relay upgrade publication', async () => {
storedHostsRaw = JSON.stringify([HOST_TWO])
await expect(setRelayRouting(HOST_ONE.id, HOST_ONE_RELAY)).rejects.toBeInstanceOf(
RelayRoutingHostRemovedError
)
expect(JSON.parse(storedHostsRaw)).toEqual([HOST_TWO])
expect(storedOverlayRaw).toBeNull()
expect(secureStoreMock.setItemAsync).not.toHaveBeenCalled()
})
it('applies concurrent rename and remove without clobbering either', async () => {
let releaseReads: (() => void) | undefined
const readsReleased = new Promise<void>((resolve) => {
releaseReads = resolve
})
let pendingReads = 0
asyncStorageMock.getItem.mockImplementation(async (key: string) => {
if (key !== HOSTS_STORAGE_KEY) {
return null
}
pendingReads += 1
if (pendingReads <= 2) {
await readsReleased
}
return storedHostsRaw
})
const rename = updateHostNameAndEndpoint(HOST_ONE.id, { personalName: 'Renamed Host' })
const remove = removeHost(HOST_TWO.id)
// Overlap writers behind one read gate to expose lost updates without serialization.
await vi.waitFor(() => {
expect(pendingReads).toBeGreaterThanOrEqual(1)
})
releaseReads?.()
await Promise.all([rename, remove])
expect(JSON.parse(storedHostsRaw)).toEqual([
{ ...HOST_ONE, name: 'Renamed Host', personalName: 'Renamed Host' }
])
})
it('does not wipe the host list when storage is unreadable during mutation', async () => {
storedHostsRaw = '{'
await expect(updateHostNameAndEndpoint(HOST_ONE.id, { personalName: 'Nope' })).rejects.toThrow(
/unreadable/
)
expect(asyncStorageMock.setItem).not.toHaveBeenCalled()
expect(storedHostsRaw).toBe('{')
})
// Park the slow keychain pass while a durable write invalidates it.
function gateKeychainReads(): () => void {
let release: () => void = () => {}
const gate = new Promise<void>((resolve) => {
release = resolve
})
secureStoreMock.getItemAsync.mockImplementation(async (key: string) => {
await gate
return key.endsWith(HOST_ONE.id) || key.endsWith(HOST_TWO.id) ? `token-${key.at(-1)}` : null
})
return release
}
it('does not serve a pre-removal snapshot to a load issued after the removal (#8791)', async () => {
const releaseKeychain = gateKeychainReads()
const parkedLoad = loadHosts()
await vi.waitFor(() => {
expect(secureStoreMock.getItemAsync).toHaveBeenCalled()
})
await removeHost(HOST_ONE.id)
const afterRemoval = loadHosts()
releaseKeychain()
await parkedLoad
await expect(afterRemoval.then((hosts) => hosts.map((host) => host.id))).resolves.toEqual([
HOST_TWO.id
])
})
it('does not serve a pre-rename snapshot to a load issued after the rename (#8791)', async () => {
const releaseKeychain = gateKeychainReads()
const parkedLoad = loadHosts()
await vi.waitFor(() => {
expect(secureStoreMock.getItemAsync).toHaveBeenCalled()
})
await updateHostNameAndEndpoint(HOST_ONE.id, { personalName: 'Living Room Mac' })
const afterRename = loadHosts()
releaseKeychain()
await parkedLoad
const hosts = await afterRename
expect(hosts.find((host) => host.id === HOST_ONE.id)?.name).toBe('Living Room Mac')
})
it('does not let a late pre-write token read poison the token cache', async () => {
const newHost = {
id: 'host-new',
name: 'New Host',
endpoint: 'ws://127.0.0.1:3',
publicKeyB64: 'key-new',
deviceToken: 'token-new',
lastConnected: 0
}
storedHostsRaw = JSON.stringify([{ ...newHost, deviceToken: undefined }])
let resolvePrewriteTokenRead: (token: string) => void = () => {}
secureStoreMock.getItemAsync.mockReturnValue(
new Promise<string>((resolve) => {
resolvePrewriteTokenRead = resolve
})
)
const parkedLoad = loadHosts()
await vi.waitFor(() => {
expect(secureStoreMock.getItemAsync).toHaveBeenCalled()
})
await savePairedHost(newHost)
resolvePrewriteTokenRead('token-old')
await parkedLoad
const hosts = await loadHosts()
expect(hosts.find((host) => host.id === newHost.id)?.deviceToken).toBe(newHost.deviceToken)
})
})
describe('host-store pairing save after an Android encryption rejection', () => {
@@ -1,4 +1,4 @@
import type { MobileRelayEndpoint } from '../../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import type { MobileRelayEndpoint } from '../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import { HostProfileSchema } from './host-profile'
import type { HostCatalogEntry, HostProfile, StoredHostProfile } from './host-profile'
@@ -6,27 +6,30 @@ import { getNextHostNameFromHosts } from './host-names'
import { mergeHostNameIdentity, withPersonalName } from './host-name-identity'
import * as hostListLoads from './host-list-load-sharing'
import { joinHostCatalogCredentials } from './host-catalog-credential-join'
import { resetPairingKeychainForTests } from './pairing-keychain'
import { readHostDeviceToken, writeHostDeviceToken } from './host-device-token-store'
import { resetPairingKeychainForTests } from '../host-credentials/pairing-keychain'
import {
readHostDeviceToken,
writeHostDeviceToken
} from '../host-credentials/host-device-token-store'
import {
cancelPendingHostCredentialCleanup,
recordHostCredentialCleanupIntent,
retryPendingHostCredentialCleanups,
scheduleHostCredentialCleanup
} from './host-credential-cleanup'
} from '../host-credentials/host-credential-cleanup'
import {
loadMobileRelayHostRoutingState,
removeMobileRelayHostRouting,
removeMobileRelayHostRoutings,
saveMobileRelayHostRouting
} from './mobile-relay-host-overlay-store'
import { scheduleOrphanedMobileRelayCleanup } from '../relay/mobile-relay-orphan-cleanup'
import { scheduleOrphanedMobileRelayCleanup } from '../transport/relay/mobile-relay-orphan-cleanup'
import {
getHostCredentialWriteRevision,
markHostCredentialWrite,
resetHostCredentialWriteRevisionsForTests
} from './host-credential-write-revision'
import { createUnpairedHostCredentialDeletion } from '../../pairing/unpaired-host-credential-deletion'
} from '../host-credentials/host-credential-write-revision'
import { createUnpairedHostCredentialDeletion } from '../pairing/unpaired-host-credential-deletion'
import {
loadStoredHostProfiles,
readStoredHostProfilesForMutation,
@@ -148,7 +151,7 @@ function removeOrphanOverlayIfUnpaired(hostId: string): Promise<void> {
})
}
import './host-descriptor-persistence'
import '../host-descriptors/host-descriptor-persistence'
export class RelayRoutingHostRemovedError extends Error {}
@@ -315,22 +318,6 @@ export async function updateHostNameAndEndpoint(
})
}
export async function updateLastConnected(hostId: string): Promise<void> {
try {
await mutateStoredHosts((hosts) => {
const index = hosts.findIndex((h) => h.id === hostId)
if (index === -1) {
return hosts
}
const next = hosts.slice()
next[index] = { ...next[index]!, lastConnected: Date.now() }
return next
})
} catch {
// Swallow bookkeeping failures because void callers cannot catch them.
}
}
export function resetHostStoreForTests(): void {
resetHostListMutationQueueForTests()
tokenCache.clear()
@@ -1,5 +1,5 @@
import { readPageHostProfile } from '../../mobile-web-shell/bridge/page-host-profile'
import type { MobileRelayEndpoint } from '../../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import { readPageHostProfile } from '../mobile-web-shell/bridge/page-host-profile'
import type { MobileRelayEndpoint } from '../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import type { HostCatalogEntry, HostProfile } from './host-profile'
// The page gets no device credential or public key; RPC uses the shell’s paired client.
@@ -26,9 +26,6 @@ export const setRelayRouting = (_hostId: string, _relay: MobileRelayEndpoint): P
export const removeHost = (_hostId: string): Promise<void> => Promise.resolve()
// Recency belongs to the native host list, which this page does not show.
export const updateLastConnected = (_hostId: string): Promise<void> => Promise.resolve()
export function updateHostNameAndEndpoint(
_hostId: string,
_updates: { personalName?: string | null; endpoint?: string }
@@ -74,22 +74,4 @@ describe('mobile relay host overlay store', () => {
await expect(saveMobileRelayHostRouting('host-1', RELAY)).resolves.toBe(true)
expect(JSON.parse(stored!)).toEqual([RELAY_ONLY_OVERLAY])
})
it('never overlays or resurrects a host whose legacy base was removed', async () => {
stored = JSON.stringify([LEGACY_OVERLAY])
await expect(loadMobileRelayHostRoutingState(new Set())).resolves.toEqual({
relays: new Map(),
orphanHostIds: ['host-1']
})
expect(asyncStorage.setItem).not.toHaveBeenCalled()
expect(JSON.parse(stored)).toEqual([LEGACY_OVERLAY])
})
it('refuses to overwrite unreadable overlay storage', async () => {
stored = '{'
await expect(saveMobileRelayHostRouting('host-1', RELAY)).rejects.toThrow(/unreadable/)
expect(asyncStorage.setItem).not.toHaveBeenCalled()
})
})
@@ -1,5 +1,5 @@
import AsyncStorage from '@react-native-async-storage/async-storage'
import type { MobileRelayEndpoint } from '../../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import type { MobileRelayEndpoint } from '../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import {
MobileRelayHostOverlaySchema,
toStoredMobileRelayHostOverlay,
@@ -2,8 +2,8 @@ import { z } from 'zod'
import {
MobileRelayEndpointSchema,
type MobileRelayEndpoint
} from '../../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import { relayConnectWebSocketUrl } from '../relay/mobile-relay-connect-url'
} from '../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import { relayConnectWebSocketUrl } from '../transport/relay/mobile-relay-connect-url'
const MobileAccessEndpointSchema = z
.object({
@@ -19,7 +19,7 @@ vi.mock('expo-secure-store', () => ({
vi.mock('react-native', () => ({ Platform: platform }))
import { promotePairingJournalCredential } from './mobile-relay-credential-bundle'
import type { MobileRelayPairingJournal } from '../../pairing/mobile-relay-pairing-journal'
import type { MobileRelayPairingJournal } from '../pairing/mobile-relay-pairing-journal'
import { resetPairingKeychainForTests } from './pairing-keychain'
const journal = {
@@ -1,7 +1,7 @@
import { Platform } from 'react-native'
import { z } from 'zod'
import type { DeviceCredentialInstalled } from '../../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import type { MobileRelayPairingJournal } from '../../pairing/mobile-relay-pairing-journal'
import type { DeviceCredentialInstalled } from '../../../src/shared/remote-runtime/relay/mobile-relay-credential-contract'
import type { MobileRelayPairingJournal } from '../pairing/mobile-relay-pairing-journal'
import {
deletePairingKeychainItem,
readPairingKeychainItem,
@@ -1,5 +1,8 @@
import { mutateStoredHosts } from './host-list-mutation-queue'
import { withReportedDescriptor, type ReportedHostDescriptor } from './host-name-identity'
import { mutateStoredHosts } from '../host-catalog/host-list-mutation-queue'
import {
withReportedDescriptor,
type ReportedHostDescriptor
} from '../host-catalog/host-name-identity'
// Keep authenticated descriptor upkeep best-effort; older hosts omitting both fields must not churn stored rows.
export async function updateHostDescriptor(

Some files were not shown because too many files have changed in this diff Show More