Skip to content

Vps 61 infinite toast fix - #469

Open
FridgeProtector1 wants to merge 9 commits into
masterfrom
vps-61-infinite-toast-fix
Open

Vps 61 infinite toast fix#469
FridgeProtector1 wants to merge 9 commits into
masterfrom
vps-61-infinite-toast-fix

Conversation

@FridgeProtector1

@FridgeProtector1 FridgeProtector1 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Issue

The infinite toast bug occurs because of a recursive loop in the 409 error handling

Solution

ref-based guard to prevent recursive 409 error handling

Risk

Idk, should be fine

Checklist

  • Acceptance criteria met
  • Wiki documentation is written and up to date
  • Unit tests written and passing
  • Integration tests written and passing
  • Continuous integration build passing

Summary by CodeRabbit

  • Bug Fixes
    • Improved multiplayer and single-player navigation after conflicts by refreshing scene and game state data.
    • Prevented duplicate conflict-resolution requests and success notifications during rapid navigation.
    • Ensured the correct scene is selected when navigation requests conflict.
    • Prevented automatic scene changes when manual conflict resolution is required.
    • Added fallback routing to the error page if synchronization fails.

@linear

linear Bot commented Aug 5, 2026

Copy link
Copy Markdown

VPS-61

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@FridgeProtector1, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 8 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e5edafe6-6a1c-4c2b-9e00-8522856377b8

📥 Commits

Reviewing files that changed from the base of the PR and between a04f3ba and 884c35c.

📒 Files selected for processing (1)
  • frontend/src/features/playScenario/PlayScenarioPage.jsx
📝 Walkthrough

Walkthrough

PlayScenarioPage now refreshes scene and state data after navigation conflicts. It prevents concurrent conflict recovery, updates local data after a successful refresh, and routes to the error page when refresh fails. Scene navigation accepts an optional scene override.

Changes

Play scenario handling

Layer / File(s) Summary
Conflict recovery refresh
frontend/src/features/playScenario/PlayScenarioPage.jsx
refreshFromServer requests current navigation data without a scene transition. Conflict handling guards concurrent refreshes, updates local scene and state data, shows a success toast, and routes to the error page if refresh fails.
Scene navigation override
frontend/src/features/playScenario/PlayScenarioPage.jsx
onSceneChange accepts an optional current-scene override, clears the initial startScene, and passes the selected scene to multiplayer and singleplayer requests.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PlayScenarioPage
  participant NavigationAPI
  participant SceneCache
  participant ErrorPage
  PlayScenarioPage->>NavigationAPI: request current navigation state
  NavigationAPI-->>PlayScenarioPage: return active scene and state data
  PlayScenarioPage->>SceneCache: cache scenes and update local state
  NavigationAPI-->>PlayScenarioPage: return refresh failure
  PlayScenarioPage->>ErrorPage: route after refresh failure
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: fixing the infinite toast issue for VPS-61.
Description check ✅ Passed The description includes all required sections and explains the recursive 409 error and ref-based guard, but the risk is vague and checklist items are unchecked.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/src/features/playScenario/PlayScenarioPage.jsx`:
- Around line 136-144: Restore the conflict-recovery path in PlayScenarioPage so
the 409 handler does more than show a toast: in the branch around
handlingConflictRef.current, resynchronize the client by making a separate
non-recursive request with currentScene set to null and no component, then
replace the local scene and state from that authoritative response. Keep
buttonPressed and onSceneChange from leaving the UI on the rejected optimistic
scene, and only use the toast as feedback after the local state has been
corrected.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 473c6b78-e2de-42f9-82ce-a8a0e65fbe38

📥 Commits

Reviewing files that changed from the base of the PR and between d567f9e and 18f90f0.

📒 Files selected for processing (1)
  • frontend/src/features/playScenario/PlayScenarioPage.jsx

Comment thread frontend/src/features/playScenario/PlayScenarioPage.jsx

@harbassan harbassan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah u need to actually make the request to get the new state, which is what it was doing before. The way youve done it it just doesn't make a refresh request, so nothing happens.

Basically: on 409, get the actual current state, then toast after switch.

You have: on 409, toast.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/src/features/playScenario/PlayScenarioPage.jsx`:
- Around line 171-179: Update the navigation and conflict-recovery flow in
PlayScenarioPage so every request, including refreshFromServer calls, receives a
shared monotonically increasing request ID. Before applying a response via
setSceneId, setStateVariables, or setStateVersion, verify its ID is still
current; also begin conflict recovery only when its assigned ID remains current,
preventing stale recovery responses from overriding newer navigation state.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f274a8f0-7bb6-45b9-bd9e-21c3a07a2eb8

📥 Commits

Reviewing files that changed from the base of the PR and between 18f90f0 and a04f3ba.

📒 Files selected for processing (1)
  • frontend/src/features/playScenario/PlayScenarioPage.jsx

Comment thread frontend/src/features/playScenario/PlayScenarioPage.jsx Outdated
Comment on lines +87 to +130
const refreshFromServer = async (user, scenarioId, groupId, isMultiplayer) => {
const token = await user.getIdToken();
const config = isMultiplayer
? {
method: "post",
url: `/api/navigate/group/${groupId}`,
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
data: {
currentScene: null,
addFlags: [],
removeFlags: [],
componentId: null,
nextScene: null,
},
}
: {
method: "post",
url: `/api/navigate/user/${scenarioId}`,
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
data: {
currentScene: null,
addFlags: [],
removeFlags: [],
componentId: null,
nextScene: null,
startScene: null,
},
};
const res = await axios.request(config);
if (res.data.scenes) {
res.data.scenes.forEach((scene) => sceneCache.set(scene._id, scene));
}
return {
newSceneId: res.data.active,
stateVariables: res.data.stateVariables,
newStateVersion: res.data.stateVersion,
};
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i may be missing something, whats the point of this function compared to onSceneChange? Looks like it does the same thing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onSceneChange sends active move data like componentId and flags to progress the player forward. refreshFromServer is just for 409 error recovery it sends null for the scene so we can fetch the server's true state without accidentally making a new move or applying state changes. But like onScene change could be refactored to handle both if u want.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cause the infinite toast was caused by onSceneChange being called with the same parameters recursively.

@harbassan harbassan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rgin216
rgin216 requested a review from harbassan August 26, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants