mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 11:24:37 +00:00
Preserve uncertainty across skipped tab reinsertion
This commit is contained in:
@@ -39,6 +39,15 @@ describe('addressed tab row references', () => {
|
||||
expect(readTabRowChanges(start, start)).toBeNull()
|
||||
})
|
||||
|
||||
it('requires resync when a removed row is reinserted across skipped writes', () => {
|
||||
const a = { id: 'a', contentType: 'terminal', entityId: 't0', groupId: 'g' }
|
||||
const b = { id: 'b', contentType: 'terminal', entityId: 't0', groupId: 'h' }
|
||||
const start = { workspace: [a, b] }
|
||||
const removed = replaceTabBuckets(start, [['workspace', [b]]])
|
||||
const reinserted = replaceTabBuckets(removed, [['workspace', [b, a]]])
|
||||
expect(readTabRowChanges(reinserted, start)).toBe('unknown')
|
||||
})
|
||||
|
||||
it('requires resync for unavailable or reordered histories', () => {
|
||||
const first = { id: 'first' }
|
||||
const second = { id: 'second' }
|
||||
|
||||
@@ -46,6 +46,10 @@ export function readTabRowChanges<T extends Row>(
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the net endpoints belong to the supplied T snapshots.
|
||||
const change = untypedChange as TabRowChange<T>
|
||||
const earlier = bucket.get(tabId)
|
||||
// Reinsertion may change which duplicate entity owns the assignment.
|
||||
if (earlier && earlier.after === undefined && change.after !== undefined) {
|
||||
return 'unknown'
|
||||
}
|
||||
bucket.set(tabId, { before: earlier ? earlier.before : change.before, after: change.after })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user