Repository navigation
Conversation
A change made while a save was in flight could be marked saved without ever reaching the server. Picking Reels right after typing a caption did exactly that: the editor blur flushed the caption, the click landed before the flush's request started, 'saveStarted' overwrote the click's dirty flag, and the save's success marked everything saved. The composer kept showing Reels while the post stayed a feed post. A finished save now carries the snapshot it sent, and the composer stays dirty when anything it persists changed since that snapshot. A debounced save that fires while another is running now queues behind it instead of being skipped, since nothing re-armed the debounce once the running save landed.
…text The counter turned red whenever the active account was blocked, so an Instagram Reel without a video showed "85 / 2200" in red as if the caption were too long. Stories without media did the same. The counter now goes red only for an empty post, a section over the limit or too many sections. Any other block still marks the account's tab, and the reason is still listed where it was.
The first save of a new draft sent no per-account choices, and the store request had no rules for them, so a format picked before the draft existed was dropped. Picking Reels for an Instagram account and then typing the caption was enough: the create made a feed post, marked the composer saved, and no later save sent the format. The first save now sends each account's format, and the store request validates it with the same rule as an update.
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
Three composer fixes, one commit each. The first and third both change
createPostinuse-autosave.ts, so they're in one PR rather than two that conflict.1. Keep edits made while an autosave is running
To reproduce on
main: pick an Instagram account, type a caption, then click Reels right away.saveStartedoverwrites the click's dirty flag.The composer keeps showing Reels, the post stays a feed post, and nothing triggers another save. Reloading the draft shows Feed.
There was a second gap: a debounced save that fired while another save was running was skipped, and nothing re-armed the debounce once the running save landed.
saveSucceededcarries the snapshot the save sent. The reducer keeps the composer dirty when any persisted field changed since that snapshot (hasEditsSince, over the fieldsbuildPutBodysends), so the next debounce saves the change.2. Only color the character counter for problems with the text
The counter turned red whenever the active account was blocked for any reason. An Instagram Reel without a video showed its caption count in red, and a Story without media did the same.
The counter now goes red only for problems with the text: an empty post, a section over the limit, or too many sections. Any other block still marks the account's tab, and its reason is still listed where it was.
isTextBlockReasoninprecheck.tsnames the text reasons (empty,section_too_long,too_many_sections).severityForincomposer.tsxtakes a scope. The counter asks for'text'; the account tabs keep using every reason.3. Keep a format picked before the draft's first save
To reproduce on
main: pick an Instagram account, choose Reels, then type the caption. The first save creates the post, butcreatePostsends no per-account choices andStorePostRequesthas no rules for them. The post is created as a feed post, the composer marks itself saved, and no later save sends the format. The composer keeps showing Reels until the draft is reloaded.createPostsendstargetson the first save, built bybuildCreateTargets: each selected account's id and format. It sends the same snapshot the first fix tracks.StorePostRequestvalidates them with the same format rule as an update (Rule::enum(PostFormat::class)).DraftData::fromArrayalready readtargets; the request just didn't pass them through.Screenshots
Only the counter fix changes anything visible. An Instagram account with Reels picked, an 83-character caption and no video. The before is upstream
mainrun locally; the after is this branch. Same viewport, data and steps for both.The count "83" goes from red to the normal text color in both themes. The Instagram tab is still underlined in red, because the missing video still blocks it.
Testing
hasEditsSinceandsaveSucceeded, and hook tests for an edit made during a save and for the queued save. Four of them fail onmain.precheck.test.tscovers which reasons count as text problems.ComposeApiTest: a format sent onPOST /postsis stored (onmainit comes back asfeed), and an unknown format is rejected (onmainit is accepted with a 201).buildCreateTargetsunit tests, and an autosave test for the first save sending the format (fails onmain).