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
parent 86a468c4d8
commit edc93ceff1
12 changed files with 477 additions and 43 deletions
@@ -0,0 +1,7 @@
import { expect, test } from "bun:test"
import { permissionSemanticLabel } from "../../../src/routes/session/permission"
test("uses the permission action when a surface has no display title", () => {
expect(permissionSemanticLabel("shell")).toBe("Permission required: shell")
expect(permissionSemanticLabel("edit", "Edit fixture.txt")).toBe("Permission required: Edit fixture.txt")
})
@@ -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 })
}),
),
)
})