diff --git a/src/commands/list.ts b/src/commands/list.ts index f2743d1..a08eb9b 100644 --- a/src/commands/list.ts +++ b/src/commands/list.ts @@ -59,10 +59,16 @@ export async function action(opts: { json?: boolean }) { ) const statuses = Object.fromEntries(statusEntries) - // Batch self-heal stale in_review flags with a single state write + // Batch self-heal stale in_review flags — reload fresh state to avoid overwriting concurrent changes if (staleReviewSessions.length > 0) { for (const s of staleReviewSessions) s.in_review = false - await state.save(root, st).catch(() => {}) + const fresh = await state.load(root).catch(() => null) + if (fresh) { + for (const s of staleReviewSessions) { + if (fresh.sessions[s.branch]) fresh.sessions[s.branch].in_review = false + } + await state.save(root, fresh).catch(() => {}) + } } if (opts.json) {