fix: don't mint worktreeMeta from a sidebar sort-order snapshot (#9342)
`worktrees:persistSortOrder` (ipc/worktrees.ts) and `persistManagedWorktreeSortOrder`
(orca-runtime.ts) call `store.setWorktreeMeta(id, { sortOrder })` for every id the
renderer sends. `setWorktreeMeta` has no repo-existence check, so a stale id the
client still lists — e.g. a removed repo's `${repoId}::${path}` that lingers in the
renderer's order — gets a brand-new `worktreeMeta` entry minted on every sidebar
snapshot, resurrecting an orphan/duplicate workspace on the next launch.
A sort-order snapshot must only reorder worktrees that already exist, never create
one. Guard both call sites with `getWorktreeMeta` so absent ids are skipped.
Co-authored-by: fanyunqian.1 <fanyunqian.1@bytedance.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
fanyunqian.1
Claude Opus 4.8
parent
dd642cb3e3
commit
d8499fae16
@@ -19973,6 +19973,12 @@ export class OrcaRuntimeService {
|
||||
const now = Date.now()
|
||||
let updated = 0
|
||||
for (let i = 0; i < orderedIds.length; i++) {
|
||||
// Why: a sort-order snapshot must only reorder existing worktrees, never
|
||||
// mint new meta — a stale id would otherwise resurrect an orphan workspace
|
||||
// (setWorktreeMeta has no repo-existence check).
|
||||
if (!this.store.getWorktreeMeta(orderedIds[i])) {
|
||||
continue
|
||||
}
|
||||
this.store.setWorktreeMeta(orderedIds[i], { sortOrder: now - i * 1000 })
|
||||
updated++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user