Repository navigation
fix(studio): a drain settles inline edits opened while it waits - #8676
Draft
terencecho wants to merge 6 commits into
Draft
terencecho wants to merge 6 commits into
terencecho wants to merge 6 commits into
Conversation
flushStudioPendingEdits read the open inline edits once, at its start. An edit opened while it waited on a slow write was never settled, yet the drain reported clean, so a caller that closes on clean closed with that edit still open. The drain now looks again after each wait and settles each newly opened edit once. If edits keep opening after five rounds it reports a failure, never clean. A drain of only the current edits is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A flush listener (a nudge, a colour grade) that queued an edit while the drain waited on another write was asked only once, at the drain's start, so its edit stayed queued while the drain reported clean. After each wait on a write other than the listeners' own saves, the drain asks the listeners again and waits for what they commit. A listener that answers every ask with a save is not asked again for it, so it cannot keep the drain from ending. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Splitting out the blur step made the drain wait a turn even with no field focused. A tracked write that had just failed could drop out of the pending set in that turn, and the drain reported clean. With no field focused the drain again reads the writes in flight in the same turn. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Edit accuracy: accurate 273 (base branch 271), smooth 57 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) Unstable (1)
|
The comment gate lets a file's comment share only go down. The drain's added comments move into names and the PR description. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jrusso1020
reviewed
Nov 24, 2026
jrusso1020
left a comment
Collaborator
There was a problem hiding this comment.
Review at 04562f3948 (draft, findings only).
What holds
- Red-first, run one test at a time with main's
studioPendingEdits.tsput back: "is settled before the drain reports clean" fails (secondcalled 0 times), "reports a failure, never clean, when edits keep opening" fails (clean), and "commits what a flush listener queued meanwhile" fails ([]). All 39 tests pass at head. - The two "write that just failed, with no field focused" cases and "leaves a drain of only the current edits" also pass on main. That fits the body: they guard this branch's own earlier commit, and they don't fix anything on main. Main already read
pendingEditssynchronously when nothing was focused. - The re-ask loop ends. I wrote a scratch probe with a listener that answers every ask with a save, plus one held write. It ended
cleanafter 2 asks, because the listener's own save is excluded by promise identity. A write that never settles still keeps the drain waiting forever, the same as on main. The five-round cap doesn't change that. - The failure state doesn't stick.
firstFailureis local to each drain. In a probe, a save that failed and then a successful save drainedclean, and a failed drain followed by a second drain gavefailedthenclean. - Callers: none of the full-drain callers sets a timeout (export/render, share, clipboard, colour-grade scope, outside file changes,
drawFileAgain). TheonlyCurrentpath (settlePendingEdits) behaves the same as before. A longer drain only waits longer, and there's a bound unless a write never settles.
Should-fix (small)
- A listener is exempt from re-asking only if the write the drain waits on is the very promise the listener returned. A listener can also track a separate inner write, as the nudge does with its
beginStudioPendingEditpromise. If that listener queues again on every ask, each round counts as "waited on other writes". My probe shows this: the listener's save tracks an innertrackStudioPendingEditpromise and returnsinner.then(...). The drain re-asked 6 times and returnedfailedwith "Edits kept opening while the pending edits were saved." No save failed. In the app this needs input that keeps arriving through the rounds, such as a held arrow key or a colour-grade drag during an export or an outside file change. Callers then show it as a save failure. On main the same case waited and then reportedclean. Two options: report the cap as a distinct status, or count only rounds that settled a newly opened edit. Or, if this is intended, name it in the Known limit section.
Nits
- In "is settled before the drain reports clean",
stopSecond()and the second save's release sit outsidefinally. On main the first failure leaves that edit open and its write pending. Every later test in the file then times out at 5 s (6 failures in a whole-file run instead of 3), which hides which tests really fail. - The Known limit is real and narrower than before. A listener's queued edit is now picked up after any wait on a non-listener write, and it's missed only when the drain waits only on listener saves. Before, it was missed after any wait.
A listener fed input on every ask, such as a held arrow key during an export, commits a nudge whose write is tracked apart from the listener's answer. Each round then counted toward the five-round cap, and the drain reported failed with no save failed, where it used to report clean. Only rounds that settle a newly opened edit count toward the cap that fails the drain. Listeners are asked again at most five times; after that the drain reports what its writes did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jrusso1020
reviewed
Nov 24, 2026
jrusso1020
left a comment
Collaborator
There was a problem hiding this comment.
Delta re-review at 8434dd32 (draft, findings only). The should-fix and the nit from my last review are resolved, and I have nothing new.
- The cap now counts only rounds that settled a newly opened edit (
opened && editsKeptOpening()). Listener re-asks have their own limit of 5, and reaching it never fails the drain. The loop still ends: a round with neither an opened edit nor a queued listener edit breaks, opened rounds fail at 5, and queued-only rounds stop after 5 re-asks. A re-ask always comes after a wait, and once the limit is hit the drain doesn't ask again, so it never leaves a freshly queued edit unwaited. - Red-first: with
studioPendingEdits.tsfrom04562f39put back, the new test "reports clean, not failed, while a listener is fed input on every ask" fails (1 failed, 39 passed). At head the file passes 40/40, and that includes "reports a failure, never clean, when edits keep opening". - The cleanup in "is settled before the drain reports clean" is now in
finally.
This branch has not been deployed
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.
What
flushStudioPendingEditsnow also saves edits that start while it is waiting on a slow write. That covers inline text edits that open, and debounced edits a flush listener queues (a nudge, a colour grade). Before, it looked for both once, at its start, so an edit started during the wait was never saved, yet the drain still reportedclean.Why
A caller that acts on
clean(closing the view, switching away) assumes every open edit has been saved. An inline edit opened during the drain's wait broke that. It was left to save itself on unmount, after the caller had already acted, so a failure of that save could no longer be handled.To reproduce:
settleOnDrain), then release the first save.The drain reports
clean, and the second edit's settle has run zero times.Related work
None. Self-contained.
How
failed("Edits kept opening while the pending edits were saved.") rather thanclean, so a caller that only proceeds oncleanstays put. The result type is unchanged.cleanif none failed, as before this change.onlyCurrent: true) never takes on newer ones, as before.Known limit
An edit a listener queues while the drain waits only on listeners' own saves is not asked for again, so the drain can report
cleanwith it still queued. Re-asking there would never end for a listener that answers every ask with a save. Running the drain again can meet the same sequence, so it does not close this.Likewise, input still arriving after the fifth re-ask (the key still held) can stay queued when the drain reports
clean, as it did before this change.No visible change
The diff changes only
studioPendingEdits.tsand its test: when a drain reportsclean, and which edits it saves first. Nothing renders differently.Test plan
src/utils/studioPendingEdits.test.ts, "an edit opened while a drain waits on a write":failed), passes now.onlyCurrent: the drain reads the writes in flight before any wait. These pass on main too; they guard this branch's earlier blur split.studioPendingEdits.tsthe first two fail, and the listener test fails on the first commit alone. 40/40 pass with the change.— tai (drafted on Terence's behalf)
🤖 Generated with Claude Code