fix(compaction): isolate preservation hook failures
This commit is contained in:
@@ -5,32 +5,34 @@ describe("experimental.session.compacting", () => {
|
||||
test("does not hardcode a model and uses output.context", () => {
|
||||
//#given
|
||||
const indexUrl = new URL("./index.ts", import.meta.url)
|
||||
const compactionUrl = new URL("./plugin/session-compacting.ts", import.meta.url)
|
||||
const content = readFileSync(indexUrl, "utf-8")
|
||||
const hookIndex = content.indexOf('"experimental.session.compacting"')
|
||||
const compactionContent = readFileSync(compactionUrl, "utf-8")
|
||||
|
||||
//#when
|
||||
const hookSlice = hookIndex >= 0 ? content.slice(hookIndex, hookIndex + 1200) : ""
|
||||
const hookIndex = content.indexOf("createSessionCompactingHandler")
|
||||
|
||||
//#then
|
||||
expect(hookIndex).toBeGreaterThanOrEqual(0)
|
||||
expect(content.includes('modelID: "claude-opus-4-7"')).toBe(false)
|
||||
expect(hookSlice.includes("output.context.push")).toBe(true)
|
||||
expect(hookSlice.includes("providerID:")).toBe(false)
|
||||
expect(hookSlice.includes("modelID:")).toBe(false)
|
||||
expect(`${content}\n${compactionContent}`.includes('modelID: "claude-opus-4-7"')).toBe(false)
|
||||
expect(compactionContent.includes("output.context.push")).toBe(true)
|
||||
expect(compactionContent.includes("providerID:")).toBe(false)
|
||||
expect(compactionContent.includes("modelID:")).toBe(false)
|
||||
})
|
||||
|
||||
test("registers autocontinue restores before OpenCode synthetic continue", () => {
|
||||
//#given
|
||||
const indexUrl = new URL("./index.ts", import.meta.url)
|
||||
const compactionUrl = new URL("./plugin/session-compacting.ts", import.meta.url)
|
||||
const content = readFileSync(indexUrl, "utf-8")
|
||||
const hookIndex = content.lastIndexOf('"experimental.compaction.autocontinue"')
|
||||
const compactionContent = readFileSync(compactionUrl, "utf-8")
|
||||
|
||||
//#when
|
||||
const hookSlice = hookIndex >= 0 ? content.slice(hookIndex, hookIndex + 500) : ""
|
||||
const hookIndex = content.indexOf("createCompactionAutocontinueHandler")
|
||||
|
||||
//#then
|
||||
expect(hookIndex).toBeGreaterThanOrEqual(0)
|
||||
expect(hookSlice.includes("compactionContextInjector?.restore")).toBe(true)
|
||||
expect(hookSlice.includes("compactionTodoPreserver?.restore")).toBe(true)
|
||||
expect(compactionContent.includes("compactionContextInjector?.restore")).toBe(true)
|
||||
expect(compactionContent.includes("compactionTodoPreserver?.restore")).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user