Skip to content

Commit 488445a

Browse files
committed
fix(tui): correct project-aware session lists
1 parent 97786af commit 488445a

38 files changed

Lines changed: 506 additions & 220 deletions

packages/app/src/context/global-sync/bootstrap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ export const loadProjectsQuery = (scope: ServerScope, api: ProjectApi) =>
129129
api.list().then((projects) => {
130130
return projects
131131
.filter((p) => !!p?.id)
132-
.filter((p) => !!p.worktree && !p.worktree.includes("opencode-test"))
133132
.map(normalizeProjectInfo)
133+
.filter((p) => !!p.worktree && !p.worktree.includes("opencode-test"))
134134
.slice()
135135
.sort((a, b) => cmp(a.id, b.id))
136136
}),

packages/app/src/context/global-sync/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ export function sanitizeProject(project: Project) {
168168
export function normalizeProjectInfo(project: Project | CurrentProject): Project {
169169
return {
170170
...project,
171+
worktree: "canonical" in project ? project.canonical : project.worktree,
171172
vcs: project.vcs === "git" ? "git" : undefined,
172173
}
173174
}

packages/app/src/utils/server-compat.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function createV1Api(input: CompatibleInput): CompatibleApi {
128128
const located = <T>(data: T, value?: { directory?: string }) => ({
129129
location: {
130130
directory: directory(value) ?? "",
131-
project: { id: "", directory: directory(value) ?? "" },
131+
project: { id: "", directory: directory(value) ?? "", canonical: directory(value) ?? "" },
132132
},
133133
data,
134134
})
@@ -298,12 +298,19 @@ function createV1Api(input: CompatibleInput): CompatibleApi {
298298
project: {
299299
...input.current.project,
300300
async list() {
301-
return ((await legacy().project.list()).data ?? []) as Project[]
301+
return ((await legacy().project.list()).data ?? []).map((project) => ({
302+
...project,
303+
canonical: project.worktree,
304+
}))
302305
},
303306
async current(value?: Parameters<ServerApi["project"]["current"]>[0]) {
304307
const result = await legacy(value?.location).project.current()
305308
if (!result.data) throw new Error("Project not found")
306-
return { id: result.data.id, directory: result.data.worktree } satisfies ProjectCurrent
309+
return {
310+
id: result.data.id,
311+
directory: result.data.worktree,
312+
canonical: result.data.worktree,
313+
} satisfies ProjectCurrent
307314
},
308315
// async update(value: Parameters<ServerApi["project"]["update"]>[0]) {
309316
// const project = (await legacy().project.list()).data?.find((item) => item.id === value.projectID)

packages/cli/test/session-target.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { OpenCode, type LocationGetOutput, type ModelRef, type SessionInfo } fro
33
import { resolveSessionTarget, SessionTargetMutationError } from "../src/session-target"
44

55
function location(directory: string, workspaceID?: string): LocationGetOutput {
6-
return { directory, workspaceID, project: { id: "project", directory } }
6+
return { directory, workspaceID, project: { id: "project", directory, canonical: directory } }
77
}
88

99
function session(id: string, directory: string, workspaceID?: string, model?: ModelRef): SessionInfo {

0 commit comments

Comments
 (0)