Repository navigation
Ask the drive for its apps again when a view menu opens (#1846) - #1904
Closed
michielbdejong wants to merge 1 commit into
Closed
michielbdejong wants to merge 1 commit into
michielbdejong wants to merge 1 commit into
Conversation
useDriveApps published nothing until its whole mount chain had finished:
findSchema, the local app query, then an awaited getResource per app, one
after the other. Live events that landed meanwhile were held back too. After
a reload, an app whose sync delta could not apply to the page's copy
("incomplete Loro import ... missing base state") sits as a placeholder under
repair, and getResource waits up to 10 s on it, which is as long as the
money e2e waits for the "New app" menu item.
- Attach the listeners before anything else and fold every answer in as it
arrives, reading the live resource each time, so no answer overrules a
newer one and no slow read holds back the others.
- Read the query's members in parallel.
- Expose refresh(), and call it when "+ Add view" and a view tab's menu
open, so opening a menu re-runs the query and re-reads what it knows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Sep 29, 2026
Merged
joepio
added a commit
that referenced
this pull request
Sep 30, 2026
# Conflicts: # browser/data-browser/src/chunks/AppPage/useDriveApps.live.test.tsx # browser/data-browser/src/chunks/TablePage/TableViewTabs.tsx
Member
Member
|
Trekmeester: included in batch #1966 (run 36898843808). It lands when that run is green; if this PR breaks something there, I take it out and say why here. |
Member
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.
Refs #1846. Follow-up to #1847, which only partly fixed the flaky
money.spec.ts:220in ontola/atomic-plugins ("Add view" →menuitem 'New app'times out after 10 s, on both attempts).What the traces show
Traces from atomic-plugins runs 36584202173 and 36585675282, at candidate14 1432e24:
page.goto(showUrl(...))). The OPFS ClientDb is ready about 1 s later, and "+ Add view" opens about 0.5 s after that. The menu has no app in it./query?property=isA&value=<app class>request, so the app list came from the local OPFS query.ws-sync-pusharrives for the app, its agent and its entry point, and each logsincomplete Loro import … missing base state, fetching a full snapshot. The page's in-memory copy did not have the history that the delta was built on. That copy was either not loaded yet, or it was hydrated from query JSON, which builds a Loro doc from fresh ops. The store then keeps the resource as a placeholder under repair.Why the hook missed it
useDriveAppsfrom #1847:findSchemaresolved;if (queried) publish()) until the mount chain finished:findSchema, then the local query, then an awaitedstore.getResource(member)for each app, one at a time.getResourcewaits up to 10 s for a loading or recovering resource, which is exactly the test's click budget. Measured locally with timestamps (Vite dev, no load), the chain published 1 to 1.9 s after the schema lookup, and every time that was after the menu had already opened. With the repair placeholder in the way it gets much slower.Fix
decidedbookkeeping is no longer needed.useDriveAppsnow returns{ apps, refresh }. The "+ Add view" menu and the view-tab menu ("View type") callrefresh()frombindActive(true). Opening the menu re-runs the query and re-reads every app the hook already knows about, so a resource whose state changed without an announcement still shows up.Tests
In
useDriveApps.live.test.tsx(jsdom, realStore), two new cases. Both fail on the #1847 hook:lists, on refresh, an app the store took in without announcing it: the app goes into the store and the local index with no event. The menu opens and the app is listed.shows the other apps while one of them is still being repaired: one member is a loading placeholder thatgetResourcewaits on. The other apps show within 1 s, and the repaired app joins when the store announces it.vitest src/chunks/AppPage src/chunks/TablePage(453 tests),tsc, oxlint and oxfmt all pass.I did not add an e2e test. A Playwright version of the money flow (create table, app with
rendersset, reload, Add view) passed 30+ times locally on the old hook. It only fails when the incomplete sync push races the menu, and I couldn't reproduce that race outside CI.Not in this PR
The deeper store issue: a
ws-sync-pushdelta for a subject that is in OPFS but not yet in memory (or only hydrated from query JSON) is imported into a doc without that history, so the import is incomplete. That needs its own change inStore.applyIncoming/hydrateResourceFromJson.No screenshots, because nothing changes visually. The menu is just no longer stale.
🤖 Generated with Claude Code