Skip to content

Fix issue #20 - #59

Merged
Wishmaster117 merged 3 commits into
mainfrom
Fix-issue-#20
Aug 12, 2026
Merged

Fix issue #20#59
Wishmaster117 merged 3 commits into
mainfrom
Fix-issue-#20

Conversation

@Wishmaster117

@Wishmaster117 Wishmaster117 commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes
    • Improved connection startup by waiting for capabilities to be resolved before returning bridge state.
    • Added fallback and retry handling to retrieve initial state when startup events are delayed or interrupted.
    • Prevented duplicate state requests during connection and world-entry transitions.
    • Improved handling of timeouts, disconnects, and failed requests to reduce stale or missing data.
    • Ensured queued state updates are processed once connection readiness is confirmed.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 32 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 66c7bcd4-0c77-496e-805b-535fbe9b3d66

📥 Commits

Reviewing files that changed from the base of the PR and between fc03e32 and a0fdefe.

📒 Files selected for processing (1)
  • Core/MultiBotComm.lua
📝 Walkthrough

Walkthrough

The bridge now gates state requests on capability resolution, coalesces pending refreshes, retries failed bootstrap requests, and tracks connection generations. HELLO, timers, disconnects, and world entry use generation-aware bootstrap handling.

Changes

Bootstrap state flow

Layer / File(s) Summary
Request gating and bootstrap guard
Core/MultiBotComm.lua
State requests queue until capabilities resolve. Global and per-bot refreshes coalesce. Guarded bootstrap retrieval preserves request associations.
Bootstrap failure and retry handling
Core/MultiBotComm.lua
Timeout, abort, and state errors invoke bootstrap recovery. Failed requests use bounded retry scheduling.
Capability and bootstrap event wiring
Core/MultiBotComm.lua
HELLO handling, capability processing, initial dispatch, recurring dispatch, disconnect, and world entry use connection generations and reset related state.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant StateRequest
  participant CapabilityResolution
  participant BootstrapRetrieval
  participant ConnectionLifecycle

  StateRequest->>CapabilityResolution: queue refresh
  CapabilityResolution->>BootstrapRetrieval: flush queued refreshes
  BootstrapRetrieval->>BootstrapRetrieval: guard request by generation
  BootstrapRetrieval-->>StateRequest: return bootstrap state or failure
  BootstrapRetrieval->>BootstrapRetrieval: schedule bounded retry
  ConnectionLifecycle->>ConnectionLifecycle: increment generation and clear state
  BootstrapRetrieval->>BootstrapRetrieval: reject stale dispatch
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title identifies an issue but does not describe the capability resolution, bootstrap retry, or queued state request changes. Replace the title with a concise description of the primary change, such as "Add capability resolution and bootstrap request retries".
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch Fix-issue-#20

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.

@Wishmaster117

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 95912603a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Core/MultiBotComm.lua Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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 `@Core/MultiBotComm.lua`:
- Around line 468-471: Update Comm.RequestState and Comm.RequestStates so
refresh requests made before state.capabilitiesResolved are queued or retried
after capability negotiation instead of returning false and dropping them.
Ensure the pending requests are replayed once capabilities resolve, and preserve
normal immediate request behavior after resolution.
- Around line 522-540: Update the bootstrap request lifecycle around
requestBootstrapStates so state.bootstrapStateRequested is cleared when the
Comm.RequestStates operation ends with ERR, STATE_ABORT, or timeout, allowing
subsequent bootstrap attempts to retry state retrieval while preserving the
existing in-flight guard.
- Around line 1614-1615: Make capability fallback in Comm.OnPlayerEnteringWorld
generation-scoped and retryable: track the active world-entry/connection
generation, ignore delayed callbacks from older generations, and allow fallback
retries until the current peer’s CAPS or HELLO_ACK is received. Preserve a
TimerAfter-based path when available and add an equivalent retry mechanism when
MultiBot.TimerAfter is unavailable, ensuring RequestState and RequestStates are
not permanently blocked.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 21ac8331-8ab1-4301-ad68-d1ed32d83453

📥 Commits

Reviewing files that changed from the base of the PR and between edc77cf and 9591260.

📒 Files selected for processing (1)
  • Core/MultiBotComm.lua

Comment thread Core/MultiBotComm.lua
Comment thread Core/MultiBotComm.lua Outdated
Comment thread Core/MultiBotComm.lua
@Wishmaster117

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: fc03e328a9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Wishmaster117

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
Core/MultiBotComm.lua (2)

344-366: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Consider safeDelay so the retry also runs without MultiBot.TimerAfter.

If MultiBot.TimerAfter is absent, scheduleBootstrapStateRetry returns without scheduling, so bootstrapStatePending stays set until the next disconnect or world entry. safeDelay already provides an immediate-invocation fallback, and the callback guards plus STATE_BOOTSTRAP_MAX_AUTO_ATTEMPTS keep the retry bounded.

♻️ Proposed change
-  if not (MultiBot and type(MultiBot.TimerAfter) == "function") then
-    return
-  end
-
-  MultiBot.TimerAfter(STATE_BOOTSTRAP_RETRY_SECONDS, function()
+  safeDelay(STATE_BOOTSTRAP_RETRY_SECONDS, function()
     local bridge = ensureBridgeState()
     if bridge.connectionGeneration ~= generation
         or not bridge.connected
         or not bridge.capabilitiesResolved
         or bridge.bootstrapStateRequested
         or not bridge.bootstrapStatePending then
       return
     end
 
     requestBootstrapStates()
   end)
🤖 Prompt for 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.

In `@Core/MultiBotComm.lua` around lines 344 - 366, Update
scheduleBootstrapStateRetry to use the existing safeDelay helper instead of
returning when MultiBot.TimerAfter is unavailable, passing the retry delay and
current callback. Preserve the callback’s connection, capability, request, and
pending-state guards so retries remain bounded by
STATE_BOOTSTRAP_MAX_AUTO_ATTEMPTS.

642-682: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Return after a failed bootstrap request and schedule a retry.

If requestBootstrapStates() fails at line 649, control falls through to line 660 and calls Comm.RequestStates() again in the same tick. requestBootstrapStates already attempted that send. The re-queued global refresh at line 664 also has no retry, so it waits for the next periodic refresh in Core/MultiBotHandler.lua.

♻️ Proposed change
   if state.bootstrapStatePending and not state.bootstrapStateRequested then
     if requestBootstrapStates() then
       state.pendingStateRefreshAll = false
       state.pendingStateRefreshByBot = {}
       return true
     end
+    scheduleBootstrapStateRetry(state.connectionGeneration)
+    return false
   elseif state.bootstrapStateRequested then
🤖 Prompt for 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.

In `@Core/MultiBotComm.lua` around lines 642 - 682, Update
flushPendingStateRefreshes so a failed requestBootstrapStates call immediately
re-queues the global state refresh and returns false, rather than falling
through to Comm.RequestStates in the same tick. Preserve the existing successful
bootstrap handling and ensure the queued refresh is retried by the normal
subsequent flush cycle.
🤖 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 `@Core/MultiBotComm.lua`:
- Around line 556-560: Ensure capability fallback is armed before resolution is
attempted when HELLO_ACK is missed. In Core/MultiBotComm.lua lines 556-560,
update Comm.RequestState to call
armCapabilityFallback(state.connectionGeneration) before
maybeResolveCapabilityFallback; make the same change in Comm.RequestStates at
lines 591-595, and add the required forward declaration for
armCapabilityFallback alongside the existing declarations near lines 35-37.

---

Nitpick comments:
In `@Core/MultiBotComm.lua`:
- Around line 344-366: Update scheduleBootstrapStateRetry to use the existing
safeDelay helper instead of returning when MultiBot.TimerAfter is unavailable,
passing the retry delay and current callback. Preserve the callback’s
connection, capability, request, and pending-state guards so retries remain
bounded by STATE_BOOTSTRAP_MAX_AUTO_ATTEMPTS.
- Around line 642-682: Update flushPendingStateRefreshes so a failed
requestBootstrapStates call immediately re-queues the global state refresh and
returns false, rather than falling through to Comm.RequestStates in the same
tick. Preserve the existing successful bootstrap handling and ensure the queued
refresh is retried by the normal subsequent flush cycle.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 16ad2c27-e59c-4cb7-bc0b-ccc0951fc01d

📥 Commits

Reviewing files that changed from the base of the PR and between 9591260 and fc03e32.

📒 Files selected for processing (1)
  • Core/MultiBotComm.lua

Comment thread Core/MultiBotComm.lua
@Wishmaster117

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: a0fdefe046

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Wishmaster117
Wishmaster117 merged commit cd11770 into main Aug 12, 2026
5 checks passed
@Wishmaster117
Wishmaster117 deleted the Fix-issue-#20 branch August 12, 2026 16:32
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.

1 participant