refactor(compose): split the 1579-line compose modal into hooks and a publish helper - #385
Merged
Merged
Conversation
… publish helper compose-modal.tsx owned the image attachment (pick, paste, upload, preview URL), the private-feed enable flow, the inherited-encryption check for replies, the poll attachment, and a 570-line post handler that created the thread one document at a time. It is 598 lines now and composes hooks/use-compose-image.ts, use-compose-private-feed.ts, use-inherited-encryption.ts and use-compose-poll.ts, with the per-document loop in lib/compose/publish-thread.ts returning an outcome the modal turns into toasts and store updates. Behaviour kept: the same guards on canPost and canAddThread, the poll-first ordering and the unconfirmed-poll retry gate, the SYNC_REQUIRED abort, timeout-as-retry, partial-thread reporting, hashtag/mention indexing rules for private and inherited posts, and the created events. The file-select and paste paths now share one attach routine.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
Deploying yappr with
|
| Latest commit: |
fa536ae
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://aa6c6278.yappr.pages.dev |
| Branch Preview URL: | https://refactor-compose-split.yappr.pages.dev |
CHARACTER_LIMIT moves to lib/compose/limits.ts so lib no longer imports a component; publish-thread drops its pass-through re-exports and its nested ternaries; planPosts gets a spec. In the modal the five stopPosting calls shadowed by the finally block go, the dead Complete! progress goes, the upload progress only shows when an upload is pending, the dark-mode teaser placeholder colour is restored, and the encrypted-thread guard drops a redundant conjunct. remove() in the image hook leaves revocation to the effect that owns it.
Merged
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
components/compose/compose-modal.tsx(1579 lines) is now 598 lines of composition. What moved out:hooks/use-compose-image.ts: pick / paste / upload / preview-URL lifecycle and the storage-provider gate. File-select and paste shared 30 duplicated lines; they now share oneattach.hooks/use-compose-private-feed.ts: private-feed status on open, plus the enable flow (add key to identity → enter key → enable → apply the requested visibility).hooks/use-inherited-encryption.ts: the reply-to-private-post source lookup with cancellation and retry (the old file had this logic twice: once in an effect, once in a retry callback).hooks/use-compose-poll.ts: draft / created-id / unconfirmed state and the detach-with-toast rule.lib/compose/publish-thread.ts:planPostsandpublishThread, the per-document creation loop (encryption options, reply linkage, unconfirmed-reference gate, retry, SYNC_REQUIRED, timeout, index registration, events). It returns an outcome; the modal turns that into toasts,markThreadPostAsPostedand the active-post cursor.Behaviour preserved: every
canPost/canAddThread/canAttachPollguard, poll-first ordering and the unconfirmed-poll retry gate, the encrypted-thread trim, character accounting for the image URL, partial-success reporting and the thread events, hashtag/mention indexing rules (teaser only for private, nothing for inherited),Ctrl/⌘+Enter.Not touched:
compose-sub-components.tsx,thread-post-editor.tsx,poll-editor.tsx,visibility-selector.tsx.Part of the anti-slop cleanup series (after #370–#384).
Test plan
npm run lint(zero warnings),tsc --noEmit,npm run test,npx knip,npm run buildall green locally🤖 Generated with Claude Code