Wait for the agent's turn instead of dropping a held merge

This commit is contained in:
Ian Gulliver
2026-10-21 11:03:25 -07:00
parent 39fe50eff2
commit 4ba742aee0
4 changed files with 129 additions and 120 deletions
+1 -1
View File
@@ -184,7 +184,7 @@ func (s *Store) EndTurn(ctx context.Context, sessionID, actor string, payload ma
case mergeAfterTurn && (othersRunning || continues):
end.MergeWaiting = true
case mergeAfterTurn:
err = tx.QueryRowContext(ctx, `UPDATE tasks SET merge_after_turn = 0 WHERE id = ? RETURNING merging_by`, taskID).Scan(&end.MergeBy)
err = tx.QueryRowContext(ctx, `SELECT merging_by FROM tasks WHERE id = ?`, taskID).Scan(&end.MergeBy)
case state == DiscardNone && finalizeMerge && lead:
err = tx.QueryRowContext(ctx, `UPDATE tasks SET finalizing = merging_by, merging_by = '' WHERE id = ? AND merging_by != '' RETURNING finalizing`, taskID).Scan(&end.FinalizeBy)
if errors.Is(err, sql.ErrNoRows) {