Skip to content

feat(#585): retry a failed resync instead of masking it as offline - #642

Merged
zgeoff merged 4 commits into
mainfrom
585-resync-failure-status
Jul 18, 2026
Merged

feat(#585): retry a failed resync instead of masking it as offline#642
zgeoff merged 4 commits into
mainfrom
585-resync-failure-status

Conversation

@zgeoff

@zgeoff zgeoff commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Description

Closes #585

A resync that fails outright now surfaces as its own status instead of masquerading as a connection drop, so the welcome-back modal can offer a retry rather than leaving the tab looking merely offline.

  • ResyncStatus gains a failed arm carrying the avatar ID it failed for
  • the worker's resync orchestrator broadcasts that failed status on outright failure instead of a connection-status-offline signal, and drops the now-unused connection-status import/helper
  • the welcome-back modal renders failure copy with a Try again button that re-sends RequestResync over the existing worker handle and clears the status, relying on the worker's single-flight guard instead of client-side debouncing

Testing

  • bun run typecheck passes
  • bun run test passes
  • bun run lint passes
  • New tests added for new functionality

Context

zgeoff added 3 commits July 18, 2026 17:09
The catch-up status union had no way to represent a resync that fails
mid-catch-up, so tabs had no dedicated signal for that outcome. Add a
`failed` arm carrying the avatar it failed for, and cover the message
creator's generic handling of it.
A resync that failed mid-catch-up only ever broadcast connection-status
offline, so the welcome-back modal stuck at "Catching up..." forever
with nothing to recover it. Broadcast the new failed ResyncStatus for
the avatar instead — connectivity stays the connection layer's own
signal, not a resync outcome.
The welcome-back modal had no rendering for the failed catch-up state,
so a resync failure left it stuck on the fast-forwarding copy forever
with no way out. Render plain copy plus a "Try again" button that
re-requests the resync and clears the status, relying on the worker's
existing single-flight guard against a redundant retry.
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d9b534b6-a2c4-4cad-83f4-4c53dc9e6095

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The resync worker now reports failed catch-up through a dedicated status. The welcome-back modal displays failure details, offers retry, sends a new resync request, and dismisses after retry.

Changes

Resync failure retry

Layer / File(s) Summary
Resync failure protocol and worker handling
libs/game/idle-client/src/types.ts, libs/game/idle-client/src/worker/*
Adds a failed ResyncStatus variant and changes request-resync failure handling and tests to emit and validate that status instead of an offline connection status.
Welcome-back failure and retry UI
apps/web/src/routes/-game/welcome-back-modal.tsx, apps/web/src/routes/-game/welcome-back-modal.test.tsx
Renders failure copy with a “Try again” action, posts a resync request containing the avatar ID, clears the status, and validates the flow in component tests.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: retrying failed resyncs instead of treating them as offline.
Description check ✅ Passed The description is directly related to the resync failure and retry changes in this PR.
Linked Issues check ✅ Passed The changes implement #585's dedicated failure status, modal retry action, and resend path through the worker.
Out of Scope Changes check ✅ Passed The diff only adds related protocol, UI, and test updates for failed resync handling.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 585-resync-failure-status

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

@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

🤖 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 `@apps/web/src/routes/-game/welcome-back-modal.test.tsx`:
- Around line 77-88: Update the cleanup registered by onTestFinished in this
test to also restore the default or previous idle worker handle after
setIdleWorkerHandle mutates shared state. Keep the existing
setResyncStatus(null) cleanup, ensuring later tests cannot inherit the worker.
🪄 Autofix (Beta)

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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2501587c-352d-46f3-959d-8cb37167d849

📥 Commits

Reviewing files that changed from the base of the PR and between 754968e and f91259f.

📒 Files selected for processing (6)
  • apps/web/src/routes/-game/welcome-back-modal.test.tsx
  • apps/web/src/routes/-game/welcome-back-modal.tsx
  • libs/game/idle-client/src/types.ts
  • libs/game/idle-client/src/worker/create-resync-status-message.test.ts
  • libs/game/idle-client/src/worker/handle-request-resync-message.test.ts
  • libs/game/idle-client/src/worker/handle-request-resync-message.ts

Comment thread apps/web/src/routes/-game/welcome-back-modal.test.tsx Outdated
The app-web preload registers the zustand create wrapper, so the idle
store resets between tests on its own; per AGENTS.md, restoring
preload-owned state per test is noise. Removes the pattern from the
whole file, pre-existing sites included.
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.

resync failure status in the worker protocol

1 participant