feat: persist context snapshots and defer permission changes to next messages
This commit is contained in:
1 parent
607afd2f39
commit
1a913cdb67
19 files changed
+510
-66
No files matched your search
@@ -695,6 +695,7 @@ async function testEarlyOrderedEventsAndDuplicateGuard(): Promise<void> {
|
||||
const result = sendResult('run-order')
|
||||
const response = deferred<SendResult>()
|
||||
let sendCalls = 0
|
||||
const enteredSend = deferred<void>()
|
||||
const events: ChatEvent[] = [
|
||||
{ runId: 'other-run', type: 'text', delta: 'must be ignored' },
|
||||
{ runId: result.runId, type: 'text', delta: 'before' },
|
||||
@@ -715,6 +716,7 @@ async function testEarlyOrderedEventsAndDuplicateGuard(): Promise<void> {
|
||||
|
||||
installFakeWindow(async () => {
|
||||
sendCalls++
|
||||
enteredSend.resolve()
|
||||
for (const event of events) useChatStore.getState().applyEvent(event)
|
||||
return response.promise
|
||||
})
|
||||
@@ -723,10 +725,19 @@ async function testEarlyOrderedEventsAndDuplicateGuard(): Promise<void> {
|
||||
assert.equal(useChatStore.getState().sending, true, 'sending should cover the pending IPC request')
|
||||
assert.equal(useChatStore.getState().messages.length, 0, 'early events wait for the send result placeholder')
|
||||
await assert.rejects(useChatStore.getState().send('duplicate'), /提交/)
|
||||
// The duplicate rejects synchronously; preference persistence/capture may still
|
||||
// be settling. Observe the actual IPC boundary rather than count microtasks.
|
||||
let deadline: ReturnType<typeof setTimeout> | undefined
|
||||
try {
|
||||
await Promise.race([enteredSend.promise, new Promise<never>((_, reject) => {
|
||||
deadline = setTimeout(() => reject(new Error('first send did not reach IPC')), 2000)
|
||||
})])
|
||||
} finally { clearTimeout(deadline) }
|
||||
assert.equal(sendCalls, 1, 'a second send must be ignored while the first send is pending')
|
||||
|
||||
response.resolve(result)
|
||||
await firstSend
|
||||
assert.equal(sendCalls, 1, 'duplicate must never reach IPC after the first submission completes')
|
||||
|
||||
const message = assistantMessage()
|
||||
assert.equal(message.turnStartedAt, undefined, 'terminal events clear the live timer timestamp')
|
||||
|
||||
Reference in new issue
Block a user