mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
Merge pull request #13459 from Kilo-Org/fix-worktree-session-metadata
fix(agent-manager): restore promoted session metadata
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"kilo-code": patch
|
||||
---
|
||||
|
||||
Restore the session title and branch subtitle immediately when opening an existing session in a worktree.
|
||||
@@ -0,0 +1,37 @@
|
||||
import { describe, expect, it } from "bun:test"
|
||||
import { createRoot, createSignal } from "solid-js"
|
||||
import { createProjectSessionsLive } from "../../webview-ui/agent-manager/project/sessions-live"
|
||||
import type { ProjectSessionInfo, SessionInfo } from "../../webview-ui/src/types/messages"
|
||||
|
||||
const session = (worktreeId: string | null): ProjectSessionInfo => ({
|
||||
id: "session-1",
|
||||
parentID: null,
|
||||
title: "Restore worktree metadata",
|
||||
createdAt: "2026-08-26T10:00:00.000Z",
|
||||
updatedAt: "2026-08-26T10:00:00.000Z",
|
||||
worktreeId,
|
||||
})
|
||||
|
||||
describe("project session live state", () => {
|
||||
it("uses managed placement while the project session cache is stale", () => {
|
||||
createRoot((dispose) => {
|
||||
const [base] = createSignal<Record<string, ProjectSessionInfo[]>>({ project: [session(null)] })
|
||||
const [store] = createSignal<SessionInfo[]>([session(null)])
|
||||
const live = createProjectSessionsLive({
|
||||
base,
|
||||
pid: () => "project",
|
||||
enabled: () => true,
|
||||
store,
|
||||
managed: () => [{ id: "session-1", worktreeId: "worktree-1", createdAt: "2026-08-26T10:00:00.000Z" }],
|
||||
locals: () => new Set(),
|
||||
})
|
||||
|
||||
expect(live().project?.[0]).toMatchObject({
|
||||
id: "session-1",
|
||||
title: "Restore worktree metadata",
|
||||
worktreeId: "worktree-1",
|
||||
})
|
||||
dispose()
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -30,7 +30,8 @@ export function createProjectSessionsLive(opts: {
|
||||
const live = new Map(store.filter(isKnownRootSession).map((item) => [item.id, item]))
|
||||
const merged = pushed.map((item) => {
|
||||
const fresh = live.get(item.id)
|
||||
return fresh ? { ...fresh, worktreeId: item.worktreeId } : item
|
||||
const worktreeId = managed.has(item.id) ? managed.get(item.id)! : item.worktreeId
|
||||
return fresh ? { ...fresh, worktreeId } : worktreeId === item.worktreeId ? item : { ...item, worktreeId }
|
||||
})
|
||||
const known = new Set(pushed.map((item) => item.id))
|
||||
const owned = (id: string) => managed.has(id) || opts.locals().has(id)
|
||||
|
||||
Reference in New Issue
Block a user