mirror of
https://github.com/stablyai/orca.git
synced 2026-10-09 08:02:35 +00:00
Route mirrored editor closes through their captured runtime owner
This commit is contained in:
@@ -99,6 +99,39 @@ describe('notifyHostOfMirroredEditorClose', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('routes to the captured file owner when the workspace catalog disagrees', async () => {
|
||||
const state = buildState()
|
||||
state.openFiles = state.openFiles.map((file) => ({ ...file, runtimeEnvironmentId: 'env-2' }))
|
||||
|
||||
expect(notifyHostOfMirroredEditorClose(state, 'wt-1', 'file-1')).toBe(true)
|
||||
expect(
|
||||
isWebSessionCloseIntentPending(
|
||||
{ environmentId: 'env-2' },
|
||||
'wt-1',
|
||||
toHostSessionTabId('host-tab-1'),
|
||||
Date.now()
|
||||
)
|
||||
).toBe(true)
|
||||
await vi.waitFor(() =>
|
||||
expect(closeWebRuntimeSessionTabMock).toHaveBeenCalledWith({
|
||||
worktreeId: 'wt-1',
|
||||
tabId: 'host-tab-1',
|
||||
environmentId: 'env-2',
|
||||
reason: 'user'
|
||||
})
|
||||
)
|
||||
expect(getRuntimeEnvironmentIdForWorktreeMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not infer a remote owner for an explicitly local file', () => {
|
||||
const state = buildState()
|
||||
state.openFiles = state.openFiles.map((file) => ({ ...file, runtimeEnvironmentId: null }))
|
||||
|
||||
expect(notifyHostOfMirroredEditorClose(state, 'wt-1', 'file-1')).toBe(false)
|
||||
expect(getRuntimeEnvironmentIdForWorktreeMock).not.toHaveBeenCalled()
|
||||
expect(closeWebRuntimeSessionTabMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not route locally-opened (non-mirrored) files to the host', () => {
|
||||
const state = buildState({
|
||||
openFiles: [
|
||||
|
||||
@@ -27,7 +27,11 @@ export function notifyHostOfMirroredEditorClose(
|
||||
if (!file?.mirroredFromRuntimeSession) {
|
||||
return false
|
||||
}
|
||||
const runtimeEnvironmentId = getRuntimeEnvironmentIdForWorktree(state, worktreeId)
|
||||
// Only legacy records need catalog inference; snapshots capture their authoritative runtime owner.
|
||||
const runtimeEnvironmentId =
|
||||
file.runtimeEnvironmentId === undefined
|
||||
? getRuntimeEnvironmentIdForWorktree(state, worktreeId)
|
||||
: file.runtimeEnvironmentId
|
||||
if (!runtimeEnvironmentId?.trim()) {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user