Skip to content

Commit 99fef80

Browse files
committed
fix(tui): keep server-scoped pins out of the local scope check
The server scopes the fetched page by project and subpath, so a pin from another worktree of the same project was dropped from Pinned by the directory check that only the store fallback needs.
1 parent d1ac40f commit 99fef80

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎packages/tui/src/component/dialog-session-list.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ export function DialogSessionList() {
149149
const query = filter().trim()
150150
const current = data.location.info(pickerLocation())
151151
const pinned = local.session.pinned().flatMap((sessionID) => {
152-
const session = sessionMap.get(sessionID) ?? (query ? undefined : data.session.get(sessionID))
152+
const fetched = sessionMap.get(sessionID)
153+
if (fetched) return [fetched]
154+
if (query) return []
155+
const session = data.session.get(sessionID)
153156
if (!session || session.parentID) return []
154157
if (
155158
!allProjects() &&

‎packages/tui/test/cli/tui/dialog-session-list.test.tsx‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ test("scopes sessions to the active session location", async () => {
132132

133133
test("shows pinned sessions outside the fetched page when tabs are enabled", async () => {
134134
const events = createEventStream()
135-
const session = (id: string, title: string, updated: number) => ({
135+
const session = (id: string, title: string, updated: number, directory = process.cwd()) => ({
136136
id,
137137
projectID: "proj_test",
138138
cost: 0,
139139
tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
140140
time: { created: 1, updated },
141141
title,
142-
location: { directory: process.cwd() },
142+
location: { directory },
143143
})
144144
const calls = createFetch((url) => {
145145
if (url.pathname === "/api/location") {
@@ -150,10 +150,13 @@ test("shows pinned sessions outside the fetched page when tabs are enabled", asy
150150
if (url.pathname !== "/api/session") return undefined
151151
const parentID = url.searchParams.get("parentID")
152152
if (parentID && parentID !== "null") return json({ data: [], cursor: {} })
153-
return json({ data: [session("ses_recent", "Recent session", 2)], cursor: {} })
153+
return json({
154+
data: [session("ses_recent", "Recent session", 2, "/tmp/opencode/worktree-b")],
155+
cursor: {},
156+
})
154157
}, events)
155158
const temporary = await tmpdir()
156-
await Bun.write(path.join(temporary.path, "session.json"), JSON.stringify({ pinned: ["ses_old"] }))
159+
await Bun.write(path.join(temporary.path, "session.json"), JSON.stringify({ pinned: ["ses_old", "ses_recent"] }))
157160
let storage!: ReturnType<typeof useStorage>
158161

159162
function Probe() {
@@ -208,6 +211,7 @@ test("shows pinned sessions outside the fetched page when tabs are enabled", asy
208211
(value) => value.includes("Old pinned session") && value.includes("Recent session"),
209212
)
210213
expect(frame).toContain("Pinned")
214+
expect(frame).not.toContain("1970")
211215
} finally {
212216
app.renderer.destroy()
213217
await storage.flush()

0 commit comments

Comments
 (0)