mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
fix(cli): resolve worktree folder name for session list labels
Instead of path.basename(session.directory) which shows the working directory name (e.g. 'opencode' for sessions in packages/opencode/), resolve the actual worktree root by matching against WorktreeFamily.list() directories. This shows the correct worktree folder name (e.g. 'kilocode', 'cross-session-conflict') matching git worktree list output.
This commit is contained in:
@@ -71,7 +71,7 @@ export function DialogSessionList() {
|
||||
const isWorking = status?.type === "busy"
|
||||
return {
|
||||
title: isDeleting ? `Press ${keybind.print("session_delete")} again to confirm` : x.title,
|
||||
description: all ? `(${path.basename(x.directory)})` : undefined, // kilocode_change - worktree label
|
||||
description: all && x.worktreeName ? `(${x.worktreeName})` : undefined, // kilocode_change - worktree label
|
||||
bg: isDeleting ? theme.error : undefined,
|
||||
value: x.id,
|
||||
category,
|
||||
|
||||
@@ -16,6 +16,8 @@ import { WorktreeDiff } from "../../kilocode/review/worktree-diff" // kilocode_c
|
||||
import { WorktreeFamily } from "../../kilocode/worktree-family" // kilocode_change
|
||||
import { Log } from "../../util/log" // kilocode_change
|
||||
import { WorkspaceRoutes } from "./workspace"
|
||||
import { Filesystem } from "../../util/filesystem" // kilocode_change
|
||||
import path from "path" // kilocode_change
|
||||
|
||||
export const ExperimentalRoutes = lazy(() =>
|
||||
new Hono()
|
||||
@@ -356,6 +358,9 @@ export const ExperimentalRoutes = lazy(() =>
|
||||
? Instance.project.id // kilocode_change
|
||||
: query.projectID
|
||||
const directories = query.worktrees ? await WorktreeFamily.list() : undefined // kilocode_change
|
||||
// kilocode_change start - sort longest-first so most specific worktree matches first
|
||||
const sorted = directories ? [...directories].sort((a, b) => b.length - a.length) : undefined
|
||||
// kilocode_change end
|
||||
const sessions: Session.GlobalInfo[] = []
|
||||
for await (const session of Session.listGlobal({
|
||||
projectID, // kilocode_change
|
||||
@@ -368,6 +373,13 @@ export const ExperimentalRoutes = lazy(() =>
|
||||
limit: limit + 1,
|
||||
archived: query.archived,
|
||||
})) {
|
||||
// kilocode_change start - resolve worktree folder name for each session
|
||||
if (sorted) {
|
||||
const root = sorted.find((d) => Filesystem.contains(d, session.directory))
|
||||
sessions.push({ ...session, worktreeName: path.basename(root ?? session.directory) })
|
||||
continue
|
||||
}
|
||||
// kilocode_change end
|
||||
sessions.push(session)
|
||||
}
|
||||
const hasMore = sessions.length > limit
|
||||
|
||||
@@ -204,6 +204,7 @@ export namespace Session {
|
||||
|
||||
export const GlobalInfo = Info.extend({
|
||||
project: ProjectInfo.nullable(),
|
||||
worktreeName: z.string().optional(), // kilocode_change - basename of the specific worktree directory
|
||||
}).meta({
|
||||
ref: "GlobalSession",
|
||||
})
|
||||
|
||||
@@ -1780,6 +1780,7 @@ export type GlobalSession = {
|
||||
diff?: string
|
||||
}
|
||||
project: ProjectSummary | null
|
||||
worktreeName?: string
|
||||
}
|
||||
|
||||
export type McpResource = {
|
||||
|
||||
@@ -5818,6 +5818,9 @@
|
||||
"projectID": {
|
||||
"type": "string"
|
||||
},
|
||||
"force": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"workspaceID": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -14210,6 +14213,9 @@
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"worktreeName": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["id", "slug", "projectID", "directory", "title", "version", "time", "project"]
|
||||
|
||||
Reference in New Issue
Block a user