Skip to content

Commit 8668dbd

Browse files
loganjLarryclaude
authored
fix(navigation): keep a shown page when a background reopen times out (#2270)
## Summary - A channel that had already loaded could be replaced, with no click, by the full-page "This page isn’t available — It didn’t load this time" card. - The cause: when something re-opens the page that is already on screen (a retry, an open of the same channel, a reopen after the organization sign-in refreshes), Buzz waits up to 15 seconds for that page to say "loaded" again. If the answer did not come in time, the card replaced a page that was working. - Now a page or Settings section that is already on screen stays on screen when such a repeat open times out. If the page answers late, it is back to normal. The card still appears when the page itself reports a problem (for example, the channel was deleted or you lost access), for a page that never loaded, and for a failed incoming link. ## Details - The rule lives in the navigation controller (`src/features/navigation/controller.ts`), which already owns each open and its 15 s deadline. It remembers the visit whose page is on screen. A timeout on a later open of that same visit is recorded as "presented in place", so the host keeps the page mounted and its request live. - Only the controller's own deadline is treated this way: `finish` is told whether its deadline fired, so the reason string alone does not decide. Failures a page reports itself (`unavailable`, `denied`, `not-found`, and `timeout` too) still draw the host card and its Retry, because the page has nothing useful to show. - A kept open stays answerable: it can still update its address (`resolve`) and answer late. A late `opened` returns the visit to normal, and a late failure is handled exactly like an on-time one (the card replaces the page). The original caller's promise is settled once, at the deadline. - Once the host card covers a page, that visit no longer counts as on screen, so a later timeout cannot reveal a page that never answered. - The exact background trigger in the original report was not identified: the dev build kept no webview log. This change does not depend on which trigger fired. - Settings used the same card for any failed open. `src/app/App.tsx` (FOUNDATION; the owner approved this edit) now applies the same rule as pages, so a kept timeout leaves the Settings section on screen. - A kept timeout keeps only content that is drawn. This is decided once, when the deadline passes. If the host was drawing its loading state in place of the page or Settings editor then (for example, a Settings section whose authorization is reloading), the host reports the timeout as its own failure: the card and Try again show and stay, as on `main`. If loading starts later, over a kept page, the host shows its loading state, never the card, and the page's late answer reopens the visit. ## Not covered - A page whose plugin registration disappears still gets the "may have been removed" card. That page can no longer render, so the card stays. ## Tests - `controller.test.ts`: a timed-out repeat open keeps the page; a late `opened` recovers it; a kept page can update its address and then answer; the host can turn a kept timeout into its own failure; a late or early `unavailable` / `denied`, or a `timeout` the page reports itself, still shows the card; a card covering the page clears the kept state; another visit, Back to an older visit, and a failed incoming link still show their cards. - `src/app/retained-page.test.tsx` (new, real `App`; it passes the controller's own 15 s timer, with only timeouts faked): a background reopen that times out keeps the page content with no card; a page that reports `unavailable`, on time or after the deadline (through its own request), or reports a `timeout` itself, gets the card; another page's open rejects the kept page's late answers; a Settings section kept through a timeout never draws the card in any rendered frame; a timeout while the host shows its loading state draws the card, which stays until Try again; loading that starts after a kept timeout (a background plugin restart) never draws the card, and the page's late answer reopens it. - The "keeps the page", Settings, address-update and loading-state tests fail without their changes and pass here. Browser cases: 0 added, 0 removed. - Not yet exercised in the running desktop app. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Logan Johnson <[email protected]> Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent cbc71c8 commit 8668dbd

5 files changed

Lines changed: 678 additions & 13 deletions

File tree

‎docs/shell-design.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ required, including when older preferences saved it disabled. Navigation removes
1010
disabled optional plugins
1111
from page choices; a retained destination whose provider is unavailable displays
1212
an explicit failure with retry instead of silently selecting another page.
13+
A page or Settings section already on screen is not replaced when a later
14+
attempt on the same visit (a retry, a same-target open, a reopen after sign-in)
15+
reaches the host's own deadline without an answer: it stays, and may still
16+
update its address and answer late. A failure the page reports itself (a timeout
17+
included), lost access, a removed page and a rejected incoming link
18+
still show the host's failure, as does that timeout when it passes while the
19+
host shows its loading state in place of the page. Loading that starts later over
20+
a kept page shows the loading state, not the failure.
1321
Browser controls, host shortcuts and toolbar arrows traverse the same visit history.
1422
Settings sections are destinations presented as a modal over the last workspace.
1523
The host retains that workspace presentation while Settings is current, without

‎src/app/App.tsx‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,29 @@ function ConnectedAppContent({ services }: { services: AppServices }) {
301301
);
302302
// A page that presents its own failure in place stays on screen.
303303
const failedPage = route.state.status === "failed" && !route.state.presented;
304+
// A kept timeout keeps only a page that is drawn. If the deadline passed
305+
// while the host drew its loading state instead, report it as the host's own
306+
// failure, so its card and Retry show. Loading that starts later over a kept
307+
// page stays a loading state.
308+
const drawsLoading =
309+
route.waiting || (!settings && (startup === "loading" || restoring));
310+
const keptTimeout =
311+
route.state.status === "failed" &&
312+
route.state.presented &&
313+
route.state.reason === "timeout"
314+
? route.state.attempt
315+
: undefined;
316+
// By attempt id: a late address update replaces the attempt object, not it.
317+
const decidedTimeout = useRef<string | undefined>(undefined);
318+
useLayoutEffect(() => {
319+
if (!keptTimeout || decidedTimeout.current === keptTimeout.id) return;
320+
decidedTimeout.current = keptTimeout.id;
321+
if (drawsLoading)
322+
services.navigationHost.complete(keptTimeout, {
323+
status: "failed",
324+
reason: "timeout",
325+
});
326+
}, [services, keptTimeout, drawsLoading]);
304327
const pageOwnsCompanion =
305328
!!workspace.page?.companion &&
306329
(settings
@@ -367,9 +390,9 @@ function ConnectedAppContent({ services }: { services: AppServices }) {
367390
: { scope: null }),
368391
});
369392
};
393+
// As for pages, a timed-out reopen of the shown section keeps its editor.
370394
const settingsUnavailable =
371-
(!route.state.ingress && !!route.failure) ||
372-
route.state.status === "failed";
395+
(!route.state.ingress && !!route.failure) || failedPage;
373396
const settingsBlocked = settingsUnavailable || route.waiting;
374397
const settingsScope =
375398
route.target.kind === "settings"

0 commit comments

Comments
 (0)