Skip to content

Commit 1963373

Browse files
refactor(tui): clarify subscribeInput locals and drop test bangs
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 364c7a5 commit 1963373

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

packages/tui/src/context/event-interest.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ export function interestEqual(left?: EventInterest, right?: EventInterest) {
2121
/** Map TUI interest into the generated `event.subscribe` query shape. */
2222
export function subscribeInput(interest?: EventInterest) {
2323
if (!interest) return undefined
24+
const location = interest.location
25+
const session = interest.sessions && interest.sessions.length > 0 ? [...interest.sessions] : undefined
2426
return {
25-
...(interest.location ? { location: interest.location } : {}),
26-
...(interest.sessions && interest.sessions.length > 0 ? { session: [...interest.sessions] } : {}),
27+
...(location ? { location } : {}),
28+
...(session ? { session } : {}),
2729
}
2830
}

packages/tui/test/cli/tui/client-scope.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ describe("ClientProvider event.scope", () => {
5151
const { app, client, eventUrls } = await mount({ location: { directory } })
5252
try {
5353
await wait(() => client.connection.status() === "connected" && eventUrls.length >= 1)
54-
expect(eventUrls[0]!.searchParams.get("location[directory]")).toBe(directory)
55-
expect(eventUrls[0]!.searchParams.getAll("session")).toEqual([])
54+
expect(eventUrls[0]?.searchParams.get("location[directory]")).toBe(directory)
55+
expect(eventUrls[0]?.searchParams.getAll("session")).toEqual([])
5656
} finally {
5757
app.renderer.destroy()
5858
}
@@ -65,8 +65,8 @@ describe("ClientProvider event.scope", () => {
6565

6666
client.event.scope({ location: { directory }, sessions: ["ses_a"] })
6767
await wait(() => eventUrls.length >= 2)
68-
expect(eventUrls[1]!.searchParams.get("location[directory]")).toBe(directory)
69-
expect(eventUrls[1]!.searchParams.getAll("session")).toEqual(["ses_a"])
68+
expect(eventUrls[1]?.searchParams.get("location[directory]")).toBe(directory)
69+
expect(eventUrls[1]?.searchParams.getAll("session")).toEqual(["ses_a"])
7070
} finally {
7171
app.renderer.destroy()
7272
}

0 commit comments

Comments
 (0)