Skip to content

add beforeReload hook#582

Merged
sunnylqm merged 1 commit into
masterfrom
codex/before-reload-hook
Jun 16, 2026
Merged

add beforeReload hook#582
sunnylqm merged 1 commit into
masterfrom
codex/before-reload-hook

Conversation

@sunnylqm

@sunnylqm sunnylqm commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added a beforeReload callback option that runs before app reloads or restarts, providing context about the operation type and allowing you to prevent the action by returning false.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 630df2c4-21ca-4c33-9478-87b3ed95bb6b

📥 Commits

Reviewing files that changed from the base of the PR and between a939db7 and 714e108.

📒 Files selected for processing (3)
  • src/__tests__/client.test.ts
  • src/client.ts
  • src/type.ts

📝 Walkthrough

Walkthrough

Adds a BeforeReloadContext interface and an optional beforeReload callback to ClientOptions. Implements a runBeforeReload helper on Pushy that invokes the callback and returns a boolean; switchVersion and restartApp now call this helper and skip the native reload when it returns false. Three new tests verify the sequencing and skip behavior.

beforeReload Hook

Layer / File(s) Summary
BeforeReloadContext contract and runBeforeReload implementation
src/type.ts, src/client.ts
BeforeReloadContext (type: 'switchVersion' | 'restartApp', optional hash) and beforeReload are added to ClientOptions. runBeforeReload is added to Pushy, gating PushyModule.reloadUpdate in switchVersion (with applyingUpdate cleanup on skip or throw) and PushyModule.restartApp in restartApp.
Test mock wiring and beforeReload test cases
src/__tests__/client.test.ts
setupClientMocks gains overridable reloadUpdate, setNeedUpdate, and restartApp options wired into the PushyModule mock. Three new tests assert: beforeReload runs before switchVersion with correct context; switching is skipped and applyingUpdate stays false when beforeReload returns false; beforeReload receives { type: 'restartApp' } before restartApp.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A hook before the leap, a chance to say "not yet!"
The rabbit checks the context, type and hash both set.
If false comes back, we pause — no reload in the night,
applyingUpdate cleared, everything feels right.
Three new tests stand guard, the burrow safe and sound. 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'add beforeReload hook' directly and clearly describes the main change introduced across all modified files: adding a new beforeReload callback hook to the ClientOptions.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/before-reload-hook

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.

@sunnylqm sunnylqm merged commit 311cefd into master Jun 16, 2026
6 of 10 checks passed
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