mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-21 00:02:30 +00:00
fix: ignore an ask older than the one that already holds, its value included
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015vn1jCHUcAdaG9C4NsUehF
This commit is contained in:
co-authored by
Claude Opus 5
parent
6e98542839
commit
2bedaf1afe
@@ -359,6 +359,8 @@ class Entry<V> {
|
||||
/** An outside write (the AI chat, another editor): a real divergence, never settling. */
|
||||
/** `askedAt`: when the write was made, for one parked while a move was heading here. */
|
||||
applyExternal(value: V, askedAt = nextAsk++): number {
|
||||
// An ask older than the one that holds changes nothing, value included.
|
||||
if (askedAt < (this.lastAsk?.at ?? 0)) return this.revision
|
||||
// Before the unchanged-value return: re-writing the same draft is still an ask, and which
|
||||
// ask came last is what outranks a discard still waiting for its turn.
|
||||
this.recordAsk('write', askedAt)
|
||||
|
||||
@@ -710,6 +710,17 @@ describe('item store: one entry per key', () => {
|
||||
expect(parkedAfterDiscard.moving.value).toEqual(again)
|
||||
expect(parkedAfterDiscard.rows.writes.at(-1)).toEqual({ path: 'u/me/b', value: again })
|
||||
|
||||
// A draft parked for the move, then a newer one written to the editor that opened over it:
|
||||
// the newer one holds, and the parked one does not come back with the item.
|
||||
const newerThanParked = { ...b, description: 'written after the parked one' }
|
||||
const parkedThenWritten = await moveOnto(false, (store, open) => {
|
||||
store.bridge.seed('w', 'resource', 'u/me/b', { ...b, description: 'parked draft' })
|
||||
open()
|
||||
store.bridge.seed('w', 'resource', 'u/me/b', newerThanParked)
|
||||
})
|
||||
expect(parkedThenWritten.moving.value).toEqual(newerThanParked)
|
||||
expect(parkedThenWritten.rows.writes.at(-1)).toEqual({ path: 'u/me/b', value: newerThanParked })
|
||||
|
||||
// Deleted last: the delete is what holds, however many drafts preceded it.
|
||||
const deleted = await moveOnto(true, (store) => {
|
||||
store.bridge.seed('w', 'resource', 'u/me/b', { ...b, description: 'first draft' })
|
||||
|
||||
Reference in New Issue
Block a user