fix(sync): drop orphan session parts (#1183)
* fix(sync): drop orphan session parts * fix(sync): guard missing part cache --------- Co-authored-by: Isaac Sanchez <isanchez-hawkins@arize.com>
This commit is contained in:
committed by
GitHub
co-authored by
Isaac Sanchez
parent
b944bd812c
commit
e50a484633
@@ -1,11 +1,11 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import type { Message, PermissionRequest, QuestionRequest } from "@opencode-ai/sdk/v2/client"
|
||||
import type { Message, Part, PermissionRequest, QuestionRequest } from "@opencode-ai/sdk/v2/client"
|
||||
import {
|
||||
canDisposeDirectory,
|
||||
hasPendingBlockingRequests,
|
||||
pickDirectoriesToEvict,
|
||||
} from "../eviction"
|
||||
import { getProtectedSessionCacheIds, pickSessionCacheEvictions } from "../session-cache"
|
||||
import { dropSessionCaches, getProtectedSessionCacheIds, pickSessionCacheEvictions } from "../session-cache"
|
||||
import { INITIAL_STATE, type DirState, type State } from "../types"
|
||||
|
||||
const DAY_MS = 24 * 60 * 60 * 1000
|
||||
@@ -172,4 +172,20 @@ describe("session cache eviction", () => {
|
||||
expect(seen.has("ses_question")).toBe(true)
|
||||
expect(seen.has("ses_streaming")).toBe(true)
|
||||
})
|
||||
|
||||
test("drops parts for evicted messages without part session ids", () => {
|
||||
const store = buildState({
|
||||
message: {
|
||||
ses_old: [{ id: "msg_1", role: "user", time: { created: 1 } } as Message],
|
||||
},
|
||||
part: {
|
||||
msg_1: [{ id: "prt_1", messageID: "msg_1" } as Part],
|
||||
},
|
||||
})
|
||||
|
||||
dropSessionCaches(store, ["ses_old"])
|
||||
|
||||
expect(store.message.ses_old).toBe(undefined)
|
||||
expect(store.part.msg_1).toBe(undefined)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user