You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 75a4de0
Browse filesBrowse the repository at this point in the historyBrowse files
fix(editor): move a tab off an older build by itself, and stop flashing the home panel
Two things a user hit after the font sweep shipped.
**Refreshing did not get them the new build.** A deploy whose vendored tree
changed leaves its worker waiting -- activating it deletes the caches the
outgoing build is still reading. The page promotes it only when no document is
open, and the landing page only when no editor window is open at all, so
someone who goes straight to /editor and keeps a document open is never asked:
reloading serves the old build back. With that build's fonts deleted from the
origin by the same deploy, their screen stayed garbled for a day after the
revert had shipped.
The page can fix this itself, because the navigation is network-first: the HTML
and bundle a stale tab loads are already the new ones, only the vendored tree
underneath is not. healStaleController() promotes the waiting worker and
reloads once, at boot, silently -- no prompt, at most once per tab
(sessionStorage), never over unsaved edits. No interruption was the ask.
Deciding *when* to do that took three attempts, and the two failures are worth
keeping:
- The vendored editor registers a worker of its own into the same scope from
inside its iframe (/document_editor_service_worker.js, an empty stub here).
A scope holds one registration, so the script alternates and `waiting` is
almost always non-null -- and whoever promotes it can hand the whole origin
to an empty worker. Both promotion paths now check the script URL.
- Asking the *controller* which build it is looked reasonable and was not: a
busy worker misses the timeout, silence read as "it is old", and tabs
reloaded themselves mid-run. The full suite failed 2 of 138 on this branch
while the same machine ran the baseline green; disabling the wiring made it
122 green and two minutes faster. The evidence is local instead: sw.js names
its runtime cache after the vendor hash, so "does this browser hold that
build's cache" answers the question without a conversation. Silence now
means do nothing.
**The home-state panel flashed during load.** It is built visible and only
hidden once a document takes over, and `?saved=` adds two dynamic imports
before that -- long enough on a cold load to read "View/Edit Document / New
Word / New Excel / New PowerPoint" under the spinner. When the URL already
names a document, the panel is never painted.
Tests, each reverse-validated: sw-silent-update.spec.ts deploys a second build
by rewriting the vendor stamp in the served sw.js and requires the next load to
be on it with no notice element; entry-paths samples the panel from first paint;
unit cases cover the script-URL guard, the cache-name evidence and the
once-per-tab heal.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|`test/unit/sw-update.test.ts` 的 `onWaitingWorker` 四条(三种到达方式 + 没有新 worker) | 删掉 `updatefound` 那一支 → "reports one that turns up after the page has loaded" 变红 |
|`test/e2e/entry-paths.spec.ts` 的"the home-state panel never shows while a named document loads"(从首帧起连采 12 次) | 去掉 `opening-document` 那一行 → 用例报 `the panel was painted while the document was loading`|
0 commit comments