mirror of
https://github.com/stablyai/orca.git
synced 2026-10-19 16:03:26 +00:00
fix(remote): refresh mirrored resume attribution
This commit is contained in:
@@ -1954,6 +1954,35 @@ describe('applyWebSessionTabsSnapshot', () => {
|
||||
expect(attributionPatch.agentStatusEpoch).toBe(8)
|
||||
expect(attributionPatch.sortEpoch).toBe(12)
|
||||
|
||||
const fresherAttributionPatch = applyWebSessionTabsSnapshot(
|
||||
makeState({
|
||||
...initial,
|
||||
agentStatusByPaneKey: {
|
||||
[mirroredPaneKey]: {
|
||||
...existing,
|
||||
updatedAt: NOW,
|
||||
worktreeId: 'stale-worktree',
|
||||
tabId: 'stale-tab',
|
||||
providerSession: undefined
|
||||
}
|
||||
},
|
||||
agentStatusEpoch: 7,
|
||||
sortEpoch: 11
|
||||
}),
|
||||
{ ...snapshot, snapshotVersion: 3 },
|
||||
ENV,
|
||||
NOW
|
||||
) as Partial<WebSessionTabsSyncState>
|
||||
|
||||
expect(fresherAttributionPatch.agentStatusByPaneKey?.[mirroredPaneKey]).toMatchObject({
|
||||
worktreeId: existing.worktreeId,
|
||||
tabId: existing.tabId,
|
||||
updatedAt: NOW,
|
||||
providerSession: { key: 'session_id', id: 'session-1' }
|
||||
})
|
||||
expect(fresherAttributionPatch.agentStatusEpoch).toBe(8)
|
||||
expect(fresherAttributionPatch.sortEpoch).toBe(12)
|
||||
|
||||
const identityPatch = applyWebSessionTabsSnapshot(
|
||||
makeState({
|
||||
...initial,
|
||||
@@ -1966,7 +1995,7 @@ describe('applyWebSessionTabsSnapshot', () => {
|
||||
}
|
||||
}
|
||||
}),
|
||||
{ ...snapshot, snapshotVersion: 3 },
|
||||
{ ...snapshot, snapshotVersion: 4 },
|
||||
ENV,
|
||||
NOW
|
||||
) as Partial<WebSessionTabsSyncState>
|
||||
|
||||
@@ -713,11 +713,14 @@ function buildMirroredAgentStatusPatch(
|
||||
continue
|
||||
}
|
||||
const existing = state.agentStatusByPaneKey[entry.paneKey]
|
||||
// Why: an active web stream can report a fresher OSC 9999 status before the next host snapshot, so don't rewind it with an older host publication.
|
||||
// Why: keep fresher OSC state while taking remapped ownership metadata from the authoritative host snapshot.
|
||||
const nextEntry =
|
||||
existing && existing.updatedAt > entry.updatedAt
|
||||
? {
|
||||
...normalizeCompatibleAgentStatusEntryForOwner(existing, entry.agentType),
|
||||
paneKey: entry.paneKey,
|
||||
worktreeId: entry.worktreeId ?? existing.worktreeId,
|
||||
tabId: entry.tabId,
|
||||
providerSession: existing.providerSession ?? entry.providerSession
|
||||
}
|
||||
: entry
|
||||
|
||||
Reference in New Issue
Block a user