Repository navigation
[No QA] [Performance] Add write-readiness barrier primitives and pending-write modules - #98979
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
…sition barriers and lifecycle hooks
|
@MelvinBot review this PR |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1385758e4e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
|
🤖 Review: LGTM. This is a clean, purely-additive primitives PR — no existing call site changes and nothing in product code imports it yet, so the blast radius is limited to whatever the follow-up cutover wires up. The back-compat handling (numeric fifth param still accepted), the error isolation around One edge case worth a note, plus a couple of minor observations below. Edge case —
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1385758e4e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1385758e4e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
1385758 to
ba0d3aa
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 730678d054
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 730678d054
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca251cb14b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca251cb14b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
| import {SAFETY_TIMEOUT_MS} from './API/writeWhenReady'; | ||
|
|
||
| /** | ||
| * Search's own write-readiness signal. |
There was a problem hiding this comment.
Just to confirm, we'll replace the existing deferredLayoutWrite in the follow up PR?
There was a problem hiding this comment.
yep, that's the plan for the follow up PR - you can see the prototype here: software-mansion-labs#368
| if (pending) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Should the return happen AFTER watchKey = undefined;?
There was a problem hiding this comment.
Any maybe more of the logic here
There was a problem hiding this comment.
ah no, order's right - early return has to come before the reset, or a second write from the same expense split would wipe the watch key the first one set
There was a problem hiding this comment.
Cool, thanks for checking
| ): Promise<void | Response<TKey>> { | ||
| Log.info('[API] Called API writeWhenReady', false, buildLogParams(command, apiCommandParameters ?? {})); | ||
|
|
||
| // Back-compat: the fifth parameter used to be a bare safetyTimeoutMs number. |
There was a problem hiding this comment.
Lets not comment about prior functionality.
| * Those two live in unrelated module/component trees with no props path between them, so the signal | ||
| * needs somewhere to live. It is deliberately not the write-scheduling registry it replaces: this only | ||
| * answers a question, it never decides where a write goes, so stale state here cannot send a | ||
| * submission down the wrong path the way a stale channel reservation could. |
There was a problem hiding this comment.
It is deliberately not the write-scheduling registry it replaces
Lets remove notes about prior implementation
| // Given a write queued with a bare number as the fifth parameter, the old signature | ||
| // before it widened to accept a WriteWhenReadyOptions object |
There was a problem hiding this comment.
the old signature before it widened
Not relevant
| * Re-declared here for the same reason as `write` above: a re-exported binding is a non-configurable getter, | ||
| * so `jest.spyOn(API, 'writeWhenReady')` cannot replace it. Tests need to observe this one now that submit | ||
| * writes go out through it rather than through `write`. |
There was a problem hiding this comment.
now that submit writes go out through it rather than through
write.
Not relevant
Julesssss
left a comment
There was a problem hiding this comment.
Looking good, it would be good to do a pass on the comments to remove refs to prior functionality, also added some comments about potential issues
roryabraham
left a comment
There was a problem hiding this comment.
Please try to audit your comments by hand before submitting for review next time. I felt overwhelmed by AI comment slop during this review.
| /** | ||
| * Attach a transition barrier now, use it later. | ||
| * | ||
| * The default barrier only takes its fast path when `TransitionTracker` already knows a transition is |
There was a problem hiding this comment.
I'm not sure I have a better suggestion, but something feels off here. If the default behavior is "perform the write after the transition", why would a caller need to issue the write from a navigation's completion callback? Why can't it just use the default barrier?
There was a problem hiding this comment.
docstring above armTransitionBarrier answers this now - let me know if it's still not clear:
/**
* Use when a caller navigates first and only builds the write afterward, once the navigation has
* already finished: attaching the default barrier that late would miss the transition and fall
* through to the safety timeout. Arm this instead when navigation triggers, then pass the resulting
* barrier to `writeWhenReady` once the write is built; one armed barrier can gate several writes from
* the same interaction (e.g. one per receipt in a split), releasing them together.
*/| */ | ||
| function armTransitionBarrier(waitFor: true | 'navigation' = true): ArmedTransitionBarrier { | ||
| const armController = new AbortController(); | ||
| const armed = createTransitionBarrier(waitFor)(armController.signal); |
There was a problem hiding this comment.
| const armed = createTransitionBarrier(waitFor)(armController.signal); | |
| const isArmed = createTransitionBarrier(waitFor)(armController.signal); |
There was a problem hiding this comment.
armed holds a Promise, not a bool, so isArmed felt like the wrong name. Kept armed, open to armedPromise if you still think it's better
yeah, valid, as I said on Slack - sorry for that. Should be good now (I corrected & verified all the comments and they make sense to me), if something is still unclear lmk |
Julesssss
left a comment
There was a problem hiding this comment.
Thanks for addressing the reviews
|
🚧 Julesssss has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/Julesssss in version: 9.4.62-1 🚀
|
|
🤖 No help site changes required — no docs PR created. This PR adds internal write-readiness barrier primitives and pending-write modules ( Per the PR description, it is purely additive — no existing call site is changed, nothing in product code imports any of it yet, and QA is explicitly N/A because the API surface is unused until the follow-up cutover PR wires a consumer to it. Since there is no user-facing change — no UI, feature, tab, setting, button, or workflow — nothing in |
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 9.4.62-4 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
Extends the existing
API.writeWhenReadyprimitive (already onmain, currently with no call sites) with the pieces the submit-expense cutover needs:API.armTransitionBarrier(waitFor?)- attaches a transition barrier before the write exists, returning{barrier, cancel}. The default barrier only takes its fast path whenTransitionTrackeralready knows a transition is active or imminent at the moment the barrier is attached. A caller that navigates first and issues the write from the navigation's own completion callback would attach after that transition ended, so it would wait on an unrelated future transition and fall through to the safety timeout. Arming splits those two moments: register when the navigation is triggered, hand the barrier towriteWhenReadywhen the write is actually built. One armed barrier can gate several writes from a single interaction (e.g. one per receipt in a split) so they release together rather than racing separate barriers.cancel()covers the abandoned path.WriteWhenReadyOptionswithonRelease(reason)andonWriteStarted()lifecycle hooks. The fifth parameter widens from a baresafetyTimeoutMs: numbertonumber | WriteWhenReadyOptions, and the numeric form is still accepted, so nothing existing has to change.writeWhenReadyre-declared as a thin wrapper insrc/libs/API/index.tsinstead of being re-exported. A re-exported binding is a non-configurable getter, sojest.spyOn(API, 'writeWhenReady')cannot replace it; tests need to observe this once submit writes go out through it rather than throughwrite.Also lands the leaf modules the cutover wires up, none of them referenced by product code yet:
src/libs/pendingSearchWrite.ts- Search's own write-readiness barrier plus a "a Search write is pending" signal (markPendingSearchWrite,hasPendingSearchWrite,acquireSearchWriteBarrier,flushPendingSearchWrite,set/getSearchWriteWatchKey). Generation-counted, so a stale release cannot clear a newer pending write.src/libs/pendingSubmitWrite.ts- the per-report equivalent (markPendingSubmitWriteForReport, which returns its own clear callback, andhasPendingSubmitWriteForReport), for the loading-skeleton and empty-state-animation checks.src/libs/actions/IOU/resolveWriteBarrier.ts- decides what a submit write waits on: an explicitwriteBarrierif the caller threaded one down, else Search's barrier when a Search write is pending and this is not a retry, elseIMMEDIATE. Retries deliberately skip Search, because the layout that would have released them already happened and the write would otherwise sit until its safety timeout. Returns a barrier rather than performing the write, so timing stays visible at the call site instead of in a shared registry.src/libs/Navigation/helpers/markPendingSearchWriteIfGlobalCreate.ts- raises the Search signal when a submission started from global create rather than from inside a report.Purely additive: no existing call site is changed, and nothing in product code imports any of this yet. The consumers land in the follow-up cutover PR, which is then purely rewiring.
Fixed Issues
$ #96010
PROPOSAL: N/A
Tests
N/A
Offline tests
N/A - no call sites yet, so no network/Onyx behavior is reachable through the UI.
QA Steps
No QA - purely additive API surface, unused until the follow-up PR wires a consumer to it.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari