refactor(core): simplify instruction preview blobs (#45702)

This commit is contained in:
Kit Langton 2026-08-27 23:12:28 -04:00 committed by GitHub
parent 0b82fe60ea
commit afe9e579d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 1 deletions

View file

@ -202,7 +202,7 @@ export const preview = Effect.fn("InstructionState.preview")(function* (
update: Instructions.renderUpdate(
instructions,
dereference(state.current_values, stored),
dereferenceDelta(result.delta, new Map([...stored, ...observedBlobs])),
dereferenceDelta(result.delta, observedBlobs),
),
}
})

View file

@ -322,6 +322,35 @@ describe("InstructionState", () => {
}),
)
it.effect("previews changed and removed instructions from observed blobs", () =>
Effect.gen(function* () {
const sessionID = SessionSchema.ID.make("ses_instruction_generate_delta")
const { db, events } = yield* setup(sessionID)
let current = "Initial context"
let retired: string | Instructions.Removed = "Retired context"
const instructions = Instructions.combine([
source(
"test/current",
Effect.sync(() => current),
),
source(
"test/retired",
Effect.sync(() => retired),
),
])
yield* InstructionState.prepare(db, events, instructions, sessionID)
current = "Changed context"
retired = Instructions.removed
const assembled = yield* preview(db, sessionID, instructions)
expect(assembled.initial).toContain("Initial context")
expect(assembled.initial).toContain("Retired context")
expect(assembled.update).toContain("Changed context")
expect(assembled.update).toContain("Removed Retired context")
}),
)
it.effect("persists chronological updates as system messages", () =>
Effect.gen(function* () {
const sessionID = SessionSchema.ID.make("ses_instruction_messages")