fix(publish): deliver overflowing waves and deck threads to the composer#1237
Conversation
A wave or deck thread past its character limit wrote its content into the
submit page's local draft key and opened /publish. Nothing on /publish reads
that key, so the content was silently dropped.
The write was also partial ({ ...localDraft, body } over a localDraft that
defaults to {}), so it left that key holding a draft with neither title nor
tags. The submit page fed those straight into applyTitle, crashing every
later visit to /submit (ECENCY-NEXT-1GJC).
Both surfaces now stage content on a dedicated one-shot key that the publish
composer consumes on mount, so the handoff arrives and the submit draft is
left to the submit page.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughOversized deck-thread and wave content now uses a one-shot local-storage handoff to populate the publish composer. The publish page consumes the handoff into both editor states, replacing the prior local-draft flow. ChangesPublish handoff
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant DeckThreadsForm
participant useWaveSubmit
participant PublishHandoffStorage
participant PublishPage
DeckThreadsForm->>PublishHandoffStorage: Stage oversized thread content
useWaveSubmit->>PublishHandoffStorage: Stage oversized wave content
PublishPage->>PublishHandoffStorage: Read and remove staged body
PublishHandoffStorage-->>PublishPage: Deliver body
PublishPage->>PublishPage: Set content and editor content
Suggested labels: Poem
🚥 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.
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/app/publish/_hooks/use-publish-handoff.ts`:
- Around line 39-49: Update the useMount logic in use-publish-handoff.ts to
remove the staged handoff immediately when processing begins, before checking
whether handoff?.body is deliverable; add a ref-based guard so the same staged
entry is consumed only once across later mounts, while preserving onReceive for
non-empty bodies. In apps/web/src/specs/app/publish/publish-handoff.spec.ts
lines 64-70, add coverage asserting entries with an empty body are removed and
not delivered.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b7d220d9-f0a1-457b-9326-ac15ceaea2e1
📒 Files selected for processing (6)
apps/web/src/app/decks/_components/deck-threads-form/index.tsxapps/web/src/app/publish/_hooks/index.tsapps/web/src/app/publish/_hooks/use-publish-handoff.tsapps/web/src/app/publish/_page.tsxapps/web/src/features/waves/hooks/use-wave-submit.tsapps/web/src/specs/app/publish/publish-handoff.spec.ts
Greptile SummaryThis PR introduces a dedicated one-shot handoff channel (
Confidence Score: 5/5Safe to merge — the fix is narrowly scoped to the handoff path, does not touch the submit page's own draft key, and every edge case (empty body, missing entry, re-visit after delivery) is covered by the new tests. The handoff key is isolated from the submit draft, the consumer removes the entry unconditionally before inspecting its contents (preventing stale-key accumulation), and the dual seed in the publish page correctly handles the lazy-load timing of the editor. The six new tests exercise all the cases called out in the PR description and the previous review thread, including the empty-body cleanup path that was the subject of those earlier comments. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant WaveForm as Wave / DeckThreadsForm
participant LS as localStorage
participant PublishPage as /publish (_page.tsx)
participant Editor as PublishEditor (lazy)
User->>WaveForm: "Submit content > char limit"
WaveForm->>LS: "setHandoff({ body }) → ecency_pub_handoff"
WaveForm->>PublishPage: window.open("/publish", "_blank")
PublishPage->>PublishPage: mount → usePublishHandoff fires (useMount)
PublishPage->>LS: read ecency_pub_handoff
PublishPage->>LS: removeHandoff() — cleared before use
alt body present
PublishPage->>PublishPage: setContent(body)
PublishPage->>PublishPage: setEditorContent(body)
end
PublishPage->>Editor: lazy load completes
Editor->>PublishPage: reads publish state (content already seeded)
Editor-->>User: composer pre-filled with overflowing content
Reviews (2): Last reviewed commit: "fix(publish): drop a staged handoff befo..." | Re-trigger Greptile |
An entry whose body was empty or unreadable hit the early return before removeHandoff ran, so it stayed in local storage and was re-examined on every later visit to the composer without ever being consumed. No caller writes such an entry today, since the overflow guard requires content, but the hook promised one-shot consumption and did not deliver it.
When a wave or a deck thread goes past its character limit, the form builds the content with its attachments, stashes it, and opens
/publishso it can become a post instead.It stashed it under the submit page's local draft key (
ecency_local_draft). Nothing on/publishreads that key, so the content was silently dropped and the composer opened empty.The write was also partial:
setLocalDraft({ ...localDraft, body: content })over alocalDraftthat defaults to{}. That left the key holding a draft with neithertitlenortags, which the submit page passed straight intoapplyTitle->value.slice(...), crashing every later visit to/submit(ECENCY-NEXT-1GJC).Change
usePublishHandoffWriter/usePublishHandoffpair on a dedicated one-shot key (ecency_pub_handoff), consumed and cleared on composer mount.use-wave-submitand the deck threads form stage content through the writer instead of writing into the submit draft.ecency_local_draftis now written only by the submit page, which always writes a completePostBase.Notes
pnpm --filter @ecency/web test240 files / 2332 tests pass, typecheck clean, lint shows no new warnings.Summary by CodeRabbit
New Features
Bug Fixes
Tests