Skip to content

Conversation

@VectorSophie
Copy link
Contributor

Description:

Describe the PR.

Modified FluentSlider(my code) to split number input handle to visual update(NumberInput) and dispatch value(NumberComplete)

updated the event flow to match them, will fix rapid-fire updates that seemed to glitch bots out.

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

Please put your Discord username so you can be contacted if a bug or regression is found:

jackochess

@VectorSophie VectorSophie requested a review from a team as a code owner January 3, 2026 12:36
@VectorSophie VectorSophie changed the title better update handling Fluentslider rapid-fire fix Jan 3, 2026
@VectorSophie VectorSophie changed the title Fluentslider rapid-fire fix Fluentslider rapid-fire bug fix Jan 3, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 3, 2026

Walkthrough

Two defensive improvements: LocalServer adds a guard check before assigning a hash to ensure the turn object exists, preventing runtime errors. FluentSlider refactors input handlers to dispatch value changes only on completion (blur or Enter key) rather than on every keystroke, with renamed handler methods and updated event bindings.

Changes

Cohort / File(s) Summary
Bug Fix: Turn Object Guard
src/client/LocalServer.ts
Added null/undefined check before accessing this.turns[clientMsg.turnNumber].hash in non-replay mode. Prevents runtime error when turn entry is missing.
Handler Refactoring: Input Dispatch Timing
src/client/components/FluentSlider.ts
Renamed handleNumberChange to handleNumberInput, added handleNumberComplete method. Value-change dispatch now occurs only on blur or Enter key press instead of every keystroke. Updated event bindings accordingly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • evanpelle

Poem

🛡️ Guards protect what might go missing,
Numbers wait 'til blur is kissing,
Enter completes the input dance,
Safer code, a cleaner glance! 📝

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fluentslider rapid-fire bug fix' directly and concisely describes the main change—fixing rapid-fire update issues in the FluentSlider component, which matches the core objective of the pull request.
Description check ✅ Passed The description clearly explains the changeset: splitting the number input handler into visual update (NumberInput) and value dispatch (NumberComplete) to fix rapid-fire glitches, which aligns with the code modifications made.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/client/LocalServer.ts (1)

135-138: Consider logging when turn is missing.

The guard check prevents a runtime error when the turn doesn't exist, which is good defensive programming. However, silently ignoring this case might hide bugs. If a hash arrives for a non-existent turn, it could indicate an issue with turn synchronization or message ordering that should be investigated.

🔎 Proposed addition of warning log
           const turn = this.turns[clientMsg.turnNumber];
           if (turn) {
             turn.hash = clientMsg.hash;
+          } else {
+            console.warn(
+              `Cannot assign hash for turn ${clientMsg.turnNumber}: turn does not exist yet`,
+            );
           }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab5b044 and 584ce23.

📒 Files selected for processing (2)
  • src/client/LocalServer.ts
  • src/client/components/FluentSlider.ts
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: andrewNiziolek
Repo: openfrontio/OpenFrontIO PR: 1007
File: resources/lang/de.json:115-115
Timestamp: 2025-06-02T14:27:37.609Z
Learning: For OpenFrontIO project: When localization keys are renamed in language JSON files, the maintainers separate technical changes from translation content updates. They wait for community translators to update the actual translation values rather than attempting to translate in the same PR. This allows technical changes to proceed while ensuring accurate translations from native speakers.
📚 Learning: 2025-12-13T14:58:29.645Z
Learnt from: scamiv
Repo: openfrontio/OpenFrontIO PR: 2607
File: src/core/execution/PlayerExecution.ts:271-295
Timestamp: 2025-12-13T14:58:29.645Z
Learning: In src/core/execution/PlayerExecution.ts surroundedBySamePlayer(), the `as Player` cast on `mg.playerBySmallID(scan.enemyId)` is intentional. Since scan.enemyId comes from ownerID() on an owned tile and playerBySmallID() only returns Player or undefined, the cast expresses a known invariant. The maintainers prefer loud failures (runtime errors) over silent masking (early returns with guards) for corrupted game state scenarios at trusted call sites.

Applied to files:

  • src/client/LocalServer.ts
🔇 Additional comments (4)
src/client/components/FluentSlider.ts (4)

87-97: LGTM! Clean separation of visual updates from value dispatch.

The renamed method now only updates the visual state without dispatching events. The immediate clamping provides instant feedback to the user, and deferring the dispatch to completion (blur/Enter) prevents rapid-fire updates as intended.


99-102: LGTM! Clear centralization of completion dispatch.

The new method provides a single point for dispatching value changes on completion, making the completion behavior explicit and easy to maintain.


104-109: LGTM! Enter key correctly completes editing.

The Enter key now properly ends the editing session and dispatches the final value, consistent with standard form input behavior.


136-140: LGTM! Event bindings correctly implement the split behavior.

The input event updates visuals via handleNumberInput, and the blur event properly completes editing and dispatches the final value via handleNumberComplete. The refactor is complete and consistent.

@iiamlewis iiamlewis added the Bugfix Fixes a bug label Jan 3, 2026
@iiamlewis iiamlewis added the Backend Server-side features and systems - lobbies, matchmaking, accounts, APIs, etc. label Jan 3, 2026
@iiamlewis iiamlewis added this to the v29 milestone Jan 3, 2026
@iiamlewis iiamlewis moved this from Triage to Final Review in OpenFront Release Management Jan 3, 2026
@evanpelle evanpelle merged commit 70767d2 into openfrontio:main Jan 4, 2026
11 of 14 checks passed
@github-project-automation github-project-automation bot moved this from Final Review to Complete in OpenFront Release Management Jan 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend Server-side features and systems - lobbies, matchmaking, accounts, APIs, etc. Bugfix Fixes a bug

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

3 participants