Fix race condition in stale review flag self-healing
Reload fresh state before saving to avoid overwriting concurrent changes from other processes between the initial load and the heal write. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
2f524da292
commit
ad90c9dcc1
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user