fix(hololake): avoid no-op agent workspace writes
This commit is contained in:
parent
392d205341
commit
dc1a32a52b
6 changed files with 72 additions and 5 deletions
|
|
@ -178,4 +178,28 @@ describe('aiWorkspaceSessionStore', () => {
|
|||
expect(store.aiWorkspaceSessionSnapshot('native-chat').messages).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
it('does not rewrite native history when hydration only reads it', async () => {
|
||||
isTauriState.value = true
|
||||
invokeMock.mockImplementation(async (command: string) => {
|
||||
if (command === 'get_ai_workspace_sessions') {
|
||||
return {
|
||||
'native-chat': {
|
||||
messages: [{ userMessage: 'Native', actions: [], response: 'History', id: 'native-message' }],
|
||||
status: 'done',
|
||||
},
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
})
|
||||
|
||||
const store = await import('./aiWorkspaceSessionStore')
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(store.aiWorkspaceSessionSnapshot('native-chat').messages).toHaveLength(1)
|
||||
})
|
||||
await new Promise(resolve => setTimeout(resolve, 300))
|
||||
|
||||
expect(invokeMock).not.toHaveBeenCalledWith('save_ai_workspace_sessions', expect.anything())
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -160,7 +160,6 @@ async function syncFromNativeStorage(): Promise<void> {
|
|||
const mergedSessions = mergeStoredSessions(sessionStore.getSnapshot(), nativeSessions)
|
||||
sessionStore.replaceSnapshot(mergedSessions)
|
||||
sessionStore.writeStoredSnapshot(mergedSessions)
|
||||
if (Object.keys(mergedSessions).length > 0) scheduleNativeSessionsWrite(mergedSessions)
|
||||
}
|
||||
|
||||
function ensureSessionStoreSync(): void {
|
||||
|
|
|
|||
Loading…
Reference in a new issue