fix(publishing): abandon publications when challenges close - #829
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughChangesThe PR adds callback-aware challenge queue entries, connects challenge cancellation to publish-abandon actions, removes challenge registration from publish stores, and updates modal cancellation behavior to abandon only the current challenge while advancing the queue. Challenge abandonment flow
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant SubmitPage
participant usePublishComment
participant useChallengesStore
participant ChallengeModal
SubmitPage->>usePublishComment: register onChallenge and capture abandonPublish
usePublishComment->>SubmitPage: emit challenge
SubmitPage->>useChallengesStore: addChallenge with abandon callback
ChallengeModal->>useChallengesStore: abandonCurrentChallenge
useChallengesStore->>usePublishComment: invoke abandonPublish
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2a790f8. Configure here.
| ...publishCommentOptions, | ||
| onChallenge: async (...args: any[]) => { | ||
| addChallenge(args, abandonCurrentPublish); | ||
| }, |
There was a problem hiding this comment.
Stale abandon on queued challenges
Medium Severity
Each queued challenge stores the same abandonCurrentPublish callback, which reads abandonPublishRef when cancel runs—not when the challenge was enqueued. If two publishes from the same hook are queued, canceling the first modal can invoke the latest abandonPublish and miss the publication that actually owns that challenge.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 2a790f8. Configure here.
There was a problem hiding this comment.
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 `@src/hooks/use-publish-reply.ts`:
- Line 1: The challenge-abandon wiring is duplicated between usePublishReply and
the submit-page flow. Extract the addChallenge selector, abandon ref/callback,
publish-options memoization, usePublishComment call, and ref-sync effect into a
shared hook such as useChallengeAbandonPublish under src/hooks/, then replace
both inline implementations with that hook while preserving the existing
returned publish result contract.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f90c6c51-fd1b-409f-b7e3-8c8e689ee8a5
📒 Files selected for processing (12)
src/components/challenge-modal/challenge-modal.test.tsxsrc/components/challenge-modal/challenge-modal.tsxsrc/hooks/use-publish-reply.test.tsxsrc/hooks/use-publish-reply.tssrc/stores/use-challenges-store.test.tssrc/stores/use-challenges-store.tssrc/stores/use-publish-post-store.test.tssrc/stores/use-publish-post-store.tssrc/stores/use-publish-reply-store.test.tssrc/stores/use-publish-reply-store.tssrc/views/submit-page/submit-page.test.tsxsrc/views/submit-page/submit-page.tsx
💤 Files with no reviewable changes (3)
- src/stores/use-publish-reply-store.test.ts
- src/stores/use-publish-post-store.ts
- src/stores/use-publish-reply-store.ts
|
Addressed CodeRabbit’s valid duplication finding in 552c454 by extracting the shared publish/challenge-abandon hook. Declined Bugbot’s stale-callback suggestion because all returned |


Summary
Verification
yarn buildyarn lintyarn type-checkyarn test --run(177 tests)yarn doctor --verbose --scope changedCloses #828
Note
Medium Risk
Touches core publish/challenge cancellation paths for posts and replies; behavior change if abandon is not wired everywhere (e.g. edit flows still use legacy
addChallenge).Overview
Cancelling or dismissing a challenge now abandons the in-flight publication instead of only dequeuing the modal. Successful submit still uses
removeChallenge/closeModalonly.The challenges store now queues
ChallengeEntryitems (stableid, optionalonAbandon).abandonCurrentChallengepops the head first, then runsonAbandonor falls back to the publisher’sstop(). Post and reply publishing moveonChallengewiring intousePublishCommentWithChallengeAbandon, which registers each challenge withabandonPublishfromusePublishComment.ChallengeModalroutes Cancel, invalid iframe URL, and floating-ui dismiss (including Escape viaonOpenChange) throughabandonModal; it keys content by entryidso the next queued challenge remounts cleanly. Regression tests cover the modal queue, store abandonment, submit page, and reply hook.Reviewed by Cursor Bugbot for commit 552c454. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
New Features
Bug Fixes
Tests