feat(simulation): expose semantic UI snapshots (#37802)

This commit is contained in:
Kit Langton 2026-07-19 16:04:27 -04:00 committed by GitHub
commit edc93ceff1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 477 additions and 43 deletions

View file

@ -0,0 +1,23 @@
import { expect, test } from "bun:test"
import { BoxRenderable } from "@opentui/core"
import { Effect } from "effect"
import { SimulationSemantics as Reader } from "@opencode-ai/simulation/frontend/semantics"
import { SimulationRenderer } from "@opencode-ai/simulation/frontend/renderer"
import { SimulationSemantics } from "../../src/simulation/semantics"
test("shares lazy semantic annotations with the simulation renderer", async () => {
await Effect.runPromise(
Effect.scoped(
Effect.gen(function* () {
const renderer = yield* SimulationRenderer.create({})
const renderable = new BoxRenderable(renderer, { id: "permission" })
let selected = false
SimulationSemantics.bind(() => ({ role: "option", selected }))(renderable)
expect(Reader.read(renderable)?.()).toEqual({ role: "option", selected: false })
selected = true
expect(Reader.read(renderable)?.()).toEqual({ role: "option", selected: true })
}),
),
)
})