fix(runtime): keep one worktree spelling for an early alias session-tabs stream (#29592)

This commit is contained in:
Neil
2026-10-16 02:49:52 -07:00
committed by GitHub
parent b95ea32797
commit 2346970e97
2 changed files with 38 additions and 2 deletions
@@ -299,7 +299,7 @@ describe('session tab workspace path aliases', () => {
expect.objectContaining({
result: expect.objectContaining({
type: 'updated',
worktree: WORKTREE,
worktree: ALIAS,
tabs: expect.arrayContaining([expect.objectContaining({ id: TAB })])
})
})
@@ -313,6 +313,37 @@ describe('session tab workspace path aliases', () => {
runtime.cleanupSubscriptionsForConnection('alias-connection')
})
// Why: clients file frames by their `worktree`, so one stream switching spellings splits a
// workspace's tabs across two keys.
it('names an early alias subscriber stream by one spelling for its whole life', async () => {
const runtime = new OrcaRuntimeService()
runtime.attachWindow(1)
const dispatcher = new RpcDispatcher({ runtime, methods: SESSION_TAB_METHODS })
const frames: { type?: string; worktree?: string; tabs?: unknown[] }[] = []
await dispatcher.dispatchStreaming(
{
id: 'sub-early',
authToken: 'token',
method: 'session.tabs.subscribe',
params: { worktree: `id:${ALIAS}` }
},
(message) => {
const result = JSON.parse(message).result
if (result?.type === 'snapshot' || result?.type === 'updated') {
frames.push(result)
}
},
{ connectionId: 'alias-connection' }
)
publishGraph(runtime)
await vi.waitFor(() => expect(frames.some((frame) => frame.type === 'updated')).toBe(true))
expect(frames.map((frame) => frame.worktree)).toEqual(frames.map(() => ALIAS))
expect(frames.at(-1)?.tabs).toContainEqual(expect.objectContaining({ id: TAB }))
runtime.cleanupSubscriptionsForConnection('alias-connection')
})
it.each([
[WORKTREE, ALIAS],
[ALIAS, WORKTREE],
+6 -1
View File
@@ -193,11 +193,16 @@ export const SESSION_TAB_METHODS = [
}
}
if (snapshot.worktree === subscribedWorktree) {
// Why: clients file frames by `worktree`; a spelling switch mid-stream splits the tabs.
const streamSnapshot =
snapshot.worktree === initial.worktree
? snapshot
: { ...snapshot, worktree: initial.worktree }
emit({
type: 'updated',
...tabDelta.update(
withProofDelta(
projectSessionTabsForClient(snapshot, clientKind, clientCapabilities)
projectSessionTabsForClient(streamSnapshot, clientKind, clientCapabilities)
)
)
})