Skip to content

fix(publishing): abandon publications when challenges close - #829

Merged
tomcasaburi merged 2 commits into
masterfrom
codex/fix/abandon-publishing
Jul 23, 2026
Merged

fix(publishing): abandon publications when challenges close#829
tomcasaburi merged 2 commits into
masterfrom
codex/fix/abandon-publishing

Conversation

@tomcasaburi

@tomcasaburi tomcasaburi commented Jul 23, 2026

Copy link
Copy Markdown
Member

Summary

  • abandon the active publication when its challenge is cancelled or dismissed
  • keep successful challenge completion separate and reset state between queued challenges
  • add regression coverage for the challenge modal, queue, post publishing, and reply publishing

Verification

  • yarn build
  • yarn lint
  • yarn type-check
  • yarn test --run (177 tests)
  • yarn doctor --verbose --scope changed
  • Chrome, Firefox, and WebKit desktop/mobile synthetic challenge checks

Closes #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 / closeModal only.

The challenges store now queues ChallengeEntry items (stable id, optional onAbandon). abandonCurrentChallenge pops the head first, then runs onAbandon or falls back to the publisher’s stop(). Post and reply publishing move onChallenge wiring into usePublishCommentWithChallengeAbandon, which registers each challenge with abandonPublish from usePublishComment.

ChallengeModal routes Cancel, invalid iframe URL, and floating-ui dismiss (including Escape via onOpenChange) through abandonModal; it keys content by entry id so 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

    • Added challenge cancellation handling during post and reply publishing.
    • Canceling or closing a challenge now abandons the active challenge and resumes the correct publishing flow.
    • Added support for canceling challenges via the Escape key.
    • Challenge prompts now advance correctly after cancellation or answer submission.
  • Bug Fixes

    • Prevented abandoned challenges from incorrectly affecting subsequent queued challenges.
  • Tests

    • Added coverage for challenge queuing, cancellation, publishing, and modal interactions.

@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
seedit Ready Ready Preview, Comment Jul 23, 2026 11:43am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

The 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

Layer / File(s) Summary
Challenge queue and abandonment
src/stores/use-challenges-store.ts, src/stores/use-challenges-store.test.ts
Challenge entries now carry IDs and optional abandonment callbacks; the queue removes its head before invoking cleanup, supports publisher-stop fallback, and logs failures.
Publishing challenge callbacks
src/hooks/use-publish-reply.*, src/views/submit-page/*, src/stores/use-publish-*-store.*
Submit and reply publishing register challenge callbacks and retain publisher abandonment functions, while publish stores keep verification and error handlers only.
Modal cancellation and queue progression
src/components/challenge-modal/*
Cancel, close, Escape, and iframe failure paths abandon the current challenge, while rendering uses the current identified queue entry and advances to the next prompt. `

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
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR addresses #828 by abandoning the active publish on challenge close and preventing queued challenge leakage and stale answer state.
Out of Scope Changes check ✅ Passed The added tests and store wiring are directly related to challenge abandonment and publishing flow behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: closing a challenge now abandons the underlying publication.
✨ 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/fix/abandon-publishing

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.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread src/hooks/use-publish-reply.ts Outdated
...publishCommentOptions,
onChallenge: async (...args: any[]) => {
addChallenge(args, abandonCurrentPublish);
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2a790f8. Configure here.

@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 `@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

📥 Commits

Reviewing files that changed from the base of the PR and between 8cf73d7 and 2a790f8.

📒 Files selected for processing (12)
  • src/components/challenge-modal/challenge-modal.test.tsx
  • src/components/challenge-modal/challenge-modal.tsx
  • src/hooks/use-publish-reply.test.tsx
  • src/hooks/use-publish-reply.ts
  • src/stores/use-challenges-store.test.ts
  • src/stores/use-challenges-store.ts
  • src/stores/use-publish-post-store.test.ts
  • src/stores/use-publish-post-store.ts
  • src/stores/use-publish-reply-store.test.ts
  • src/stores/use-publish-reply-store.ts
  • src/views/submit-page/submit-page.test.tsx
  • src/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

Comment thread src/hooks/use-publish-reply.ts Outdated
@tomcasaburi

Copy link
Copy Markdown
Member Author

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 abandonPublish functions from one usePublishComment instance close over the same hook-owned refs, so capturing an older function would not bind an earlier publication. Reverified build, lint, type-check, all 177 tests, and changed-scope React Doctor under Node 22.12.0.

@tomcasaburi
tomcasaburi merged commit 4e0bfc4 into master Jul 23, 2026
8 checks passed
@tomcasaburi
tomcasaburi deleted the codex/fix/abandon-publishing branch July 23, 2026 11:49
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.

Closing publishing challenges leaves publications active

1 participant