Repository navigation
RDC - Keep full-mode AI loops alive across aborts and New Game - #19
Merged
Merged
Conversation
An aborted model returned before calling onComplete, so an external abort (New Game, mode switch) left runModelsInParallel pending forever and the AI loop never released isProcessing. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N9d8nojPb1FPFCGZ8vcRSB
A superseded loop resetting the shared flag let a second loop start on the same engine. New Game now clears the flag itself, and the engine is synced to signals in finally so the board never shows a stale prompt. Auto phase advance is skipped when the human seat is AI-controlled. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N9d8nojPb1FPFCGZ8vcRSB
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N9d8nojPb1FPFCGZ8vcRSB
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in
30E1
a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One thing
In full mode the AI must never stop and wait for a human. This PR closes the ways an AI loop could stall so the board sits on a human-style prompt ("Discard down to 3", "SKIP TO BUY") with nothing voting.
Root causes
handleModelResultreturned early when the consensus controller was aborted and never calledonComplete. Any external abort (abortOngoingConsensusfrom New Game, mode switch, unmount) leftrunModelsInParallelpending forever, sorunAITurn/resolveAIPendingDecisionnever settled andisProcessingwas never released. Every automation effect returns early whileisProcessingis true, so the game was dead until reload.startGameaborted the consensus but did not resetisProcessing, so the new game inherited the stuck flag.isProcessingflag infinallyeven after being superseded, which let a second loop start on the same engine. Now only the loop whose abort signal is still live releases the flag, and it syncs the engine to signals in the same place so the UI never shows a stale pending choice.useAutoPhaseAdvancealways acted for the"human"seat, including in full mode where that seat is AI-controlled after a hybrid game switches to full.Evidence
Reproduced in Chrome against the dev server with a seeded full-mode game (opponent has a live Militia discard):
Also verified on master that the plain Militia path (restored state, live play, and hybrid-to-full switch mid-decision) already resolves through consensus, so the reported pause is this stall class rather than a missing decision handler.
Unit test:
handleModelResultnow has a test that fails on master (aborted result must still report completion).bun test: 2185 pass, 0 fail.bun run typeandbun run lintclean.Dead code
Removed
convertToFullModePlayersand its tests: it had no production caller. 1 removal.Not in this PR
The app blocks its main thread for a long time after load and during consensus (65 s between "Restoring saved mode" and "Restored game" on production with 642 events, and a 1e6-iteration loop took 949 ms on an idle page). Separate investigation.
🤖 Generated with Claude Code
https://claude.ai/code/session_01N9d8nojPb1FPFCGZ8vcRSB