mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
fix(parts-batcher): defer operations when target message is missing from cache (#262)
* fix(parts-batcher): defer operations when target message is missing from cache * fix(parts-batcher): add TTL for deferred operations to prevent repeated invalidations
This commit is contained in:
1 parent
5dc95dc3f4
commit
d6bc1d7b69
3 files changed
+196
-53
No files matched your search
@@ -4,7 +4,8 @@ import type { ReactNode } from 'react'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { useSSE } from './useSSE'
|
||||
import { useSessionStatus } from '../stores/sessionStatusStore'
|
||||
import type { Part, MessageWithParts } from '@/api/types'
|
||||
import type { MessageWithParts } from '@/api/types'
|
||||
import { createTextPart } from '@/lib/partsBatcher'
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
getSessionStatuses: vi.fn(),
|
||||
@@ -293,14 +294,14 @@ describe('useSSE', () => {
|
||||
['opencode', 'messages', 'http://localhost:5551', 'session-1', '/repo-a'],
|
||||
[{
|
||||
...assistantMessage('session-1', 'message-1'),
|
||||
parts: [textPart('session-1', 'message-1', 'part-1', 'A')],
|
||||
parts: [createTextPart('session-1', 'message-1', 'part-1', 'A')],
|
||||
}],
|
||||
)
|
||||
queryClient.setQueryData(
|
||||
['opencode', 'messages', 'http://localhost:5551', 'session-1', '/repo-b'],
|
||||
[{
|
||||
...assistantMessage('session-1', 'message-1'),
|
||||
parts: [textPart('session-1', 'message-1', 'part-1', 'B')],
|
||||
parts: [createTextPart('session-1', 'message-1', 'part-1', 'B')],
|
||||
}],
|
||||
)
|
||||
|
||||
@@ -377,7 +378,7 @@ describe('useSSE', () => {
|
||||
['opencode', 'messages', 'http://localhost:5551', 'session-1', '/repo'],
|
||||
[{
|
||||
...assistantMessage('session-1', 'message-1'),
|
||||
parts: [textPart('session-1', 'message-1', 'part-1', '')],
|
||||
parts: [createTextPart('session-1', 'message-1', 'part-1', '')],
|
||||
}],
|
||||
)
|
||||
|
||||
@@ -450,6 +451,3 @@ function assistantMessage(sessionID: string, messageID: string): MessageWithPart
|
||||
}
|
||||
}
|
||||
|
||||
function textPart(sessionID: string, messageID: string, partID: string, text: string): Part {
|
||||
return { id: partID, sessionID, messageID, type: 'text', text } as Part
|
||||
}
|
||||
Reference in new issue
Block a user