Skip to content

Commit c7de57e

Browse files
authored
fix(drive): serialize unfocused UI state (#42360)
1 parent 642772e commit c7de57e

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎packages/simulation/src/frontend/actions.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,10 @@ export function elements(renderer: CliRenderer): Element[] {
115115
}
116116

117117
export function state(harness: Harness) {
118+
const renderable = harness.renderer.currentFocusedRenderable?.num
118119
return {
119120
focused: {
120-
renderable: harness.renderer.currentFocusedRenderable?.num,
121+
...(renderable === undefined ? {} : { renderable }),
121122
editor: Boolean(harness.renderer.currentFocusedEditor),
122123
},
123124
elements: elements(harness.renderer),

‎packages/simulation/test/actions.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ test("matches literal screen text", () => {
1414
expect(matches(harness, "opencode")).toBe(false)
1515
})
1616

17+
test("omits an absent focused renderable from state", () => {
18+
const harness = {
19+
renderer: {
20+
root: { getChildren: () => [] },
21+
currentFocusedRenderable: undefined,
22+
currentFocusedEditor: undefined,
23+
},
24+
} as unknown as Harness
25+
26+
expect(state(harness)).toEqual({ focused: { editor: false }, elements: [] })
27+
})
28+
1729
test("normalizes named keys for OpenTUI", async () => {
1830
const pressed: Array<readonly [string, object | undefined]> = []
1931
const harness = {

0 commit comments

Comments
 (0)