Repository navigation
fix(assets): give history cursor recovery epoch ownership - #13780
mattmillerai wants to merge 3 commits into
Conversation
Cursor recovery cleared the history walk state without bumping historyFetchEpoch, so a concurrent reader that captured the same epoch (notably an in-flight head refresh fetching offset:0) could pass its stale-guard and act on the just-cleared list. Recovery now bumps the epoch and threads the new value through a mutable walk holder so its caller and loadMoreHistory re-sync to the self-recovery epoch instead of misreading their own reset as external supersession. The reset still runs before the fallback fetch, so a failed offset-0 retry leaves the walk resumable and surfaces the error.
|
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: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
🎨 Storybook: ✅ Built — View Storybook🎭 Playwright: ✅ 1717 passed, 0 failed · 1 flaky📊 Browser Reports
📦 Bundle Size
⚡ Performance Report
Absolute values
Raw data{
"timestamp": "2026-07-23T01:35:31.807Z",
"gitSha": "bacd679b710ab9d14d1589d3bdcbd591e31cd7f6",
"branch": "matt/be-3420-history-fetch-epoch-ownership",
"measurements": [
{
"name": "canvas-idle",
"durationMs": 2090.7299999999796,
"styleRecalcs": 7,
"styleRecalcDurationMs": 6.310000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 551.049,
"heapDeltaBytes": 3863712,
"heapUsedBytes": 73057832,
"domNodes": 14,
"jsHeapTotalBytes": 19546112,
"scriptDurationMs": 27.473999999999997,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-idle",
"durationMs": 2021.9740000000002,
"styleRecalcs": 10,
"styleRecalcDurationMs": 8.958,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 372.369,
"heapDeltaBytes": 3846132,
"heapUsedBytes": 73177116,
"domNodes": 20,
"jsHeapTotalBytes": 19021824,
"scriptDurationMs": 18.542999999999996,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1873.3839999999873,
"styleRecalcs": 72,
"styleRecalcDurationMs": 38.951,
"layouts": 12,
"layoutDurationMs": 3.987,
"taskDurationMs": 891.692,
"heapDeltaBytes": -16630520,
"heapUsedBytes": 52525800,
"domNodes": -267,
"jsHeapTotalBytes": 19410944,
"scriptDurationMs": 126.771,
"eventListeners": -133,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.670000000000012,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "canvas-mouse-sweep",
"durationMs": 1891.808000000026,
"styleRecalcs": 76,
"styleRecalcDurationMs": 51.235,
"layouts": 12,
"layoutDurationMs": 3.833,
"taskDurationMs": 853.56,
"heapDeltaBytes": -16824840,
"heapUsedBytes": 52519600,
"domNodes": -266,
"jsHeapTotalBytes": 20197376,
"scriptDurationMs": 124.78999999999998,
"eventListeners": -133,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1755.788999999993,
"styleRecalcs": 31,
"styleRecalcDurationMs": 19.223999999999997,
"layouts": 6,
"layoutDurationMs": 0.8309999999999997,
"taskDurationMs": 335.209,
"heapDeltaBytes": 6910792,
"heapUsedBytes": 75989824,
"domNodes": 78,
"jsHeapTotalBytes": 19808256,
"scriptDurationMs": 22.199000000000005,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "canvas-zoom-sweep",
"durationMs": 1679.8699999999371,
"styleRecalcs": 32,
"styleRecalcDurationMs": 17.628999999999998,
"layouts": 6,
"layoutDurationMs": 0.599,
"taskDurationMs": 316.732,
"heapDeltaBytes": 7184792,
"heapUsedBytes": 76477440,
"domNodes": 79,
"jsHeapTotalBytes": 19021824,
"scriptDurationMs": 19.903999999999996,
"eventListeners": 19,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "dom-widget-clipping",
"durationMs": 562.4130000000491,
"styleRecalcs": 11,
"styleRecalcDurationMs": 8.047,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 374.551,
"heapDeltaBytes": -11784024,
"heapUsedBytes": 57319552,
"domNodes": 18,
"jsHeapTotalBytes": 19283968,
"scriptDurationMs": 58.32,
"eventListeners": 2,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "dom-widget-clipping",
"durationMs": 567.9149999999709,
"styleRecalcs": 14,
"styleRecalcDurationMs": 9.751000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 347.11800000000005,
"heapDeltaBytes": -11757316,
"heapUsedBytes": 57375552,
"domNodes": 24,
"jsHeapTotalBytes": 20332544,
"scriptDurationMs": 55.62400000000001,
"eventListeners": 0,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.670000000000012,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "large-graph-idle",
"durationMs": 2035.1290000000404,
"styleRecalcs": 8,
"styleRecalcDurationMs": 7.481999999999999,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 583.699,
"heapDeltaBytes": 5373300,
"heapUsedBytes": 64784060,
"domNodes": -268,
"jsHeapTotalBytes": 4538368,
"scriptDurationMs": 95.716,
"eventListeners": -127,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-idle",
"durationMs": 2012.1339999999464,
"styleRecalcs": 8,
"styleRecalcDurationMs": 7.924,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 576.747,
"heapDeltaBytes": 4805524,
"heapUsedBytes": 64372804,
"domNodes": -269,
"jsHeapTotalBytes": 4276224,
"scriptDurationMs": 91.818,
"eventListeners": -129,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "large-graph-pan",
"durationMs": 2136.4209999999844,
"styleRecalcs": 68,
"styleRecalcDurationMs": 15.885,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1150.587,
"heapDeltaBytes": 1480268,
"heapUsedBytes": 62626504,
"domNodes": -269,
"jsHeapTotalBytes": 5005312,
"scriptDurationMs": 414.085,
"eventListeners": -127,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "large-graph-pan",
"durationMs": 2181.018999999992,
"styleRecalcs": 69,
"styleRecalcDurationMs": 15.285,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 1175.425,
"heapDeltaBytes": -4078520,
"heapUsedBytes": 56487312,
"domNodes": -269,
"jsHeapTotalBytes": 5324800,
"scriptDurationMs": 403.376,
"eventListeners": -131,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "large-graph-zoom",
"durationMs": 3182.374999999979,
"styleRecalcs": 65,
"styleRecalcDurationMs": 16.566,
"layouts": 60,
"layoutDurationMs": 8.538,
"taskDurationMs": 1397.95,
"heapDeltaBytes": -3862060,
"heapUsedBytes": 58099204,
"domNodes": -272,
"jsHeapTotalBytes": 7684096,
"scriptDurationMs": 492.32699999999994,
"eventListeners": -133,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "large-graph-zoom",
"durationMs": 3184.82999999992,
"styleRecalcs": 65,
"styleRecalcDurationMs": 19.559000000000005,
"layouts": 60,
"layoutDurationMs": 8.373000000000001,
"taskDurationMs": 1402.284,
"heapDeltaBytes": -4002224,
"heapUsedBytes": 58122132,
"domNodes": -273,
"jsHeapTotalBytes": 8208384,
"scriptDurationMs": 494.126,
"eventListeners": -133,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "minimap-idle",
"durationMs": 2057.267999999965,
"styleRecalcs": 10,
"styleRecalcDurationMs": 8.77,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 565.677,
"heapDeltaBytes": 6093972,
"heapUsedBytes": 68648948,
"domNodes": -266,
"jsHeapTotalBytes": 4800512,
"scriptDurationMs": 94.248,
"eventListeners": -129,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "minimap-idle",
"durationMs": 2027.1139999999832,
"styleRecalcs": 6,
"styleRecalcDurationMs": 6.115000000000002,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 591.794,
"heapDeltaBytes": 5049768,
"heapUsedBytes": 66505324,
"domNodes": -269,
"jsHeapTotalBytes": 3751936,
"scriptDurationMs": 99.82400000000001,
"eventListeners": -127,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 590.8430000000067,
"styleRecalcs": 46,
"styleRecalcDurationMs": 9.902,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 384.108,
"heapDeltaBytes": -11157524,
"heapUsedBytes": 58098764,
"domNodes": 18,
"jsHeapTotalBytes": 20594688,
"scriptDurationMs": 127.84299999999999,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "subgraph-dom-widget-clipping",
"durationMs": 550.7270000000517,
"styleRecalcs": 45,
"styleRecalcDurationMs": 8.689999999999998,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 362.385,
"heapDeltaBytes": -11445800,
"heapUsedBytes": 57847356,
"domNodes": 16,
"jsHeapTotalBytes": 20070400,
"scriptDurationMs": 122.49700000000001,
"eventListeners": 6,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-idle",
"durationMs": 2016.4849999999888,
"styleRecalcs": 12,
"styleRecalcDurationMs": 10.293000000000001,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 413.72900000000004,
"heapDeltaBytes": 3603340,
"heapUsedBytes": 73030200,
"domNodes": 24,
"jsHeapTotalBytes": 19283968,
"scriptDurationMs": 20.245,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.800000000000182
},
{
"name": "subgraph-idle",
"durationMs": 2004.1329999999675,
"styleRecalcs": 8,
"styleRecalcDurationMs": 7.332,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 361.85100000000006,
"heapDeltaBytes": 3559140,
"heapUsedBytes": 72894312,
"domNodes": 16,
"jsHeapTotalBytes": 19546112,
"scriptDurationMs": 15.124,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1779.798000000028,
"styleRecalcs": 77,
"styleRecalcDurationMs": 41.369,
"layouts": 16,
"layoutDurationMs": 4.585999999999999,
"taskDurationMs": 794.726,
"heapDeltaBytes": -19856052,
"heapUsedBytes": 49471192,
"domNodes": -263,
"jsHeapTotalBytes": 19148800,
"scriptDurationMs": 99.22699999999999,
"eventListeners": -133,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-mouse-sweep",
"durationMs": 1690.266999999949,
"styleRecalcs": 76,
"styleRecalcDurationMs": 36.821000000000005,
"layouts": 16,
"layoutDurationMs": 4.509,
"taskDurationMs": 716.981,
"heapDeltaBytes": -5528572,
"heapUsedBytes": 64040356,
"domNodes": 65,
"jsHeapTotalBytes": 19546112,
"scriptDurationMs": 95.512,
"eventListeners": 4,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.66333333333335,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "subgraph-transition-enter",
"durationMs": 965.0720000000206,
"styleRecalcs": 18,
"styleRecalcDurationMs": 28.915999999999997,
"layouts": 14,
"layoutDurationMs": 11.562,
"taskDurationMs": 765.8210000000001,
"heapDeltaBytes": 30951920,
"heapUsedBytes": 97528740,
"domNodes": 13673,
"jsHeapTotalBytes": 14680064,
"scriptDurationMs": 28.645000000000003,
"eventListeners": 2369,
"totalBlockingTimeMs": 115,
"frameDurationMs": 16.66333333333332,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "viewport-pan-sweep",
"durationMs": 8209.216999999968,
"styleRecalcs": 249,
"styleRecalcDurationMs": 43.034000000000006,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 3862.262,
"heapDeltaBytes": 15783868,
"heapUsedBytes": 74974232,
"domNodes": -268,
"jsHeapTotalBytes": 7102464,
"scriptDurationMs": 1196.9560000000001,
"eventListeners": -113,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "viewport-pan-sweep",
"durationMs": 8139.683999999988,
"styleRecalcs": 250,
"styleRecalcDurationMs": 42.958999999999996,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 3744.0870000000004,
"heapDeltaBytes": 15268220,
"heapUsedBytes": 74845108,
"domNodes": -266,
"jsHeapTotalBytes": 6578176,
"scriptDurationMs": 1165.615,
"eventListeners": -113,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.80000000000109
},
{
"name": "vue-large-graph-idle",
"durationMs": 13516.824999999983,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 13494.735999999999,
"heapDeltaBytes": -31472840,
"heapUsedBytes": 171387860,
"domNodes": -8311,
"jsHeapTotalBytes": -10948608,
"scriptDurationMs": 532.716,
"eventListeners": -16384,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.223333333333358,
"p95FrameDurationMs": 16.799999999999272
},
{
"name": "vue-large-graph-idle",
"durationMs": 13683.36499999998,
"styleRecalcs": 0,
"styleRecalcDurationMs": 0,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 13665.646000000002,
"heapDeltaBytes": -60991208,
"heapUsedBytes": 166154972,
"domNodes": -8311,
"jsHeapTotalBytes": -11730944,
"scriptDurationMs": 536.014,
"eventListeners": -16384,
"totalBlockingTimeMs": 0,
"frameDurationMs": 17.223333333333358,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "vue-large-graph-pan",
"durationMs": 16736.829,
"styleRecalcs": 103,
"styleRecalcDurationMs": 16.761000000000024,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 16710.698,
"heapDeltaBytes": -55222152,
"heapUsedBytes": 169329240,
"domNodes": -8311,
"jsHeapTotalBytes": -10420224,
"scriptDurationMs": 831.9219999999999,
"eventListeners": -16382,
"totalBlockingTimeMs": 41,
"frameDurationMs": 17.776666666666763,
"p95FrameDurationMs": 16.80000000000291
},
{
"name": "vue-large-graph-pan",
"durationMs": 16545.394999999986,
"styleRecalcs": 102,
"styleRecalcDurationMs": 15.958000000000027,
"layouts": 0,
"layoutDurationMs": 0,
"taskDurationMs": 16516.942,
"heapDeltaBytes": -63445448,
"heapUsedBytes": 154108720,
"domNodes": -8311,
"jsHeapTotalBytes": -16453632,
"scriptDurationMs": 854.235,
"eventListeners": -16384,
"totalBlockingTimeMs": 52,
"frameDurationMs": 17.219999999999953,
"p95FrameDurationMs": 16.700000000000728
},
{
"name": "workflow-execution",
"durationMs": 456.50799999998526,
"styleRecalcs": 13,
"styleRecalcDurationMs": 18.793999999999997,
"layouts": 3,
"layoutDurationMs": 0.717,
"taskDurationMs": 115.134,
"heapDeltaBytes": -16509652,
"heapUsedBytes": 51902332,
"domNodes": 128,
"jsHeapTotalBytes": 6701056,
"scriptDurationMs": 9.856,
"eventListeners": 67,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.699999999999818
},
{
"name": "workflow-execution",
"durationMs": 459.51400000001286,
"styleRecalcs": 15,
"styleRecalcDurationMs": 21.075999999999997,
"layouts": 3,
"layoutDurationMs": 0.761,
"taskDurationMs": 121.452,
"heapDeltaBytes": -16613920,
"heapUsedBytes": 51806712,
"domNodes": 121,
"jsHeapTotalBytes": 7487488,
"scriptDurationMs": 13.650999999999998,
"eventListeners": 65,
"totalBlockingTimeMs": 0,
"frameDurationMs": 16.666666666666668,
"p95FrameDurationMs": 16.700000000000728
}
]
} |
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @mattmillerai.
✅ No high-signal findings.
Panel: 6/8 reviewers contributed findings.
Reviewers that did not contribute: kimi-k2.5:adversarial (empty), kimi-k2.5:edge-case (empty)
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## matt/fe-962-fe-adopt-cursor-pagination-in-the-generated-tab-jobs-sourced #13780 +/- ##
============================================================================================================
- Coverage 76.27% 76.20% -0.08%
============================================================================================================
Files 1696 1693 -3
Lines 118176 117745 -431
Branches 39060 38865 -195
============================================================================================================
- Hits 90143 89725 -418
+ Misses 27279 27266 -13
Partials 754 754
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 48 files with indirect coverage changes 🚀 New features to boost your workflow:
|
…ated-tab-jobs-sourced into matt/be-3420-history-fetch-epoch-ownership # Conflicts: # src/stores/assetsStore.ts
Reconcile the base branch's JobsApiError(message, status) signature and deferred cursor-recovery reset with this PR's epoch-ownership walk during the merge: two tests still constructed JobsApiError with the pre-rename arg order, and one asserted the pre-deferred-reset list length.
DrJKL
left a comment
There was a problem hiding this comment.
The cursor-recovery race is real, and the new regression test fails against the base implementation as expected. The production fix keeps the recovering walk current while invalidating the concurrent head refresh.
Requesting changes because one added test duplicates an existing behavioral test, and the new race test includes step-by-step comments that repeat its code. The focused suite, typecheck, ESLint, Oxlint, and diff check otherwise pass.
| expect(new Set(ids).size).toBe(ids.length) | ||
| }) | ||
|
|
||
| it('releases isLoadingMore when the offset-0 recovery retry also fails, so the next scroll is not dropped', async () => { |
There was a problem hiding this comment.
This test duplicates the preceding keeps pagination resumable when the offset-0 retry also fails case. That test already performs another loadMoreHistory(), asserts the fourth request, and checks the surfaced error, so it proves both that the guard released and that the walk adopted the recovery epoch. isLoadingMore is also released unconditionally in finally. Please delete this redundant test rather than adding another 35 lines for the same behavior.
There was a problem hiding this comment.
Deleted. You are right that it was redundant: keeps pagination resumable when the offset-0 retry also fails already issues the follow-up loadMoreHistory() and asserts the fourth request lands, which can only happen once the guard released, and isLoadingMore is cleared unconditionally in finally. Removed in 90390f0.
| ) | ||
| await store.updateHistory() | ||
|
|
||
| // A head refresh captures the current epoch and issues its offset-0 fetch. |
There was a problem hiding this comment.
Please remove the three added narration blocks from this test. The test name, controlled promise, mocked cursor failure, and before/after assertions already express each step. These comments paraphrase the code rather than preserving an invariant that the code cannot encode, contrary to the repository comment guidance.
There was a problem hiding this comment.
Removed all three narration blocks in 90390f0. The test name, controlled promise, mocked cursor failure, and before/after assertions carry the sequence on their own.
|
Fix has been subsumed by #15381 |
|
STACKED — merging lands on Addressed both review threads in 90390f0:
Also fixed a semantic conflict with the base that was invisible here — the PR merges cleanly and its own CI is green, but the merged result failed. The base reshaped
Threads replied to rather than resolved, per |
ELI-5
When the history list hits a stale pagination cursor, it throws the list away and starts over from the top. But it forgot to tell everyone else "I just reset — ignore what you were doing." So if a background "check for new items" refresh was mid-flight, it could wake up and scribble on the freshly-cleared list, or trigger a needless full reload. This teaches the recovery path to raise the shared "generation counter" so those concurrent readers correctly bail — while making sure the recovery's own follow-up fetch isn't fooled into discarding its own result.
Summary
Stacked on #12769 (base branch), addressing a review follow-up deferred from it.
The cursor-recovery path (
fetchHistoryPageWithCursorRecovery) clearedallHistoryItems/loadedIds/loadedJobIds/historyOffset/historyNextCursor/hadCursorThisWalkwithout incrementinghistoryFetchEpoch. Every other reset site (fetchHistoryAssets(false),replaceHistoryWithHeadPage) bumps the epoch, so a concurrent reader that captured the same epoch — notably an in-flightdoRefreshHistoryHead, which fetchesoffset:0directly and guards on the epoch — could pass its stale-check and act against the just-cleared list.The clean fix couldn't be a one-liner: bumping the epoch inside recovery also trips
loadMoreHistory's own stale-guard (suppressing a legitimate error) andfetchHistoryAssets's discard check (dropping the recovered page). A single counter can't tell self-recovery apart from external supersession without threading the post-recovery epoch back up.Approach
Recovery now takes ownership of the walk: it bumps
historyFetchEpochand records the new value on a small mutableHistoryWalkholder threaded fromloadMoreHistory→fetchHistoryAssets→ the recovery fetcher. The caller andloadMoreHistoryre-sync to that holder, so they honor their own self-recovery instead of misreading it as an external supersession. The bump + re-stamp happen before the fallbackoffset:0fetch (synchronously, no await between), so even if that retry throws, the holder reflects the new epoch and the error still surfaces with the walk resumable from offset 0.Preserved invariants (all covered by the existing concurrency suite):
isLoadingMorereleased, next scroll not dropped).doRefreshHistoryHeadnow correctly bails when recovery reset the list mid-flight.Tests
discards a concurrent head refresh when cursor recovery resets the walk mid-flight— the core regression (fails without the epoch bump: the un-guarded head refresh fires a spurious full reload, 5 fetches instead of 4).assetsStore.test.tssuite green (125 tests), including the cursor/epoch concurrency cases.Verification
pnpm test:unit src/stores/assetsStore.test.ts→ 125 passed, against the tree with the base branch merged in.pnpm typecheck,eslint,oxfmt --checkclean.Provenance
Verified:
pnpm test:unit src/stores/assetsStore.test.ts→ 125 passed with the base branch merged in;pnpm typecheck,eslint, andoxfmt --checkclean; regression guard re-confirmed by reverting the epoch bump (5 fetches vs 4). Fullpnpm test:unitrun is green exceptscripts/cicd/check-binary-size.test.ts, which is inherited from the base branch and fails only on macOS (itscheck-binary-size.shuses GNU-awk syntax that BSD awk rejects) — unrelated to this PR's two files.Deviations: Merged the base branch in to resolve a semantic conflict that was invisible on the PR: the base reshaped
JobsApiErrorto(status, body)and moved cursor classification onto theerrorCodeparsed from the body (#13781), so this branch's new race test still built the old(code, status)form and theINVALID_CURSORescapedloadMoreHistoryinstead of triggering recovery. No textual conflict — it only reproduced in the merged result. Test updated to the structured form. Review threads were replied to but not resolved, per this repo'sAGENTS.mdrule that resolution is the reviewer's prerogative on PRs where the agent is the author.