mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-30 05:29:47 +00:00
refactor(core): simplify instruction preview blobs (#45702)
This commit is contained in:
parent
0b82fe60ea
commit
afe9e579d6
2 changed files with 30 additions and 1 deletions
|
|
@ -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),
|
||||
),
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue