Repository navigation
fix(threads): keep retained views live and recover stalled watches - #799
Merged
Merged
Conversation
A desktop in remote mode could keep a thread view stuck on old state (a sent prompt missing, a finished turn still working) while the sidebar kept updating, until a reload. The overview-head self-check gave up for good after three repairs without progress and never reloaded the view. - Thread liveness never stops while the evidence lasts: it resumes from the applied cursor twice, then reloads a fresh window like a page reload, backing off from 30 s to 5 min. - The overview's thread status is a second witness: a running thread the view shows idle, or a settled thread it shows running, for 10 s triggers the same repair even when the cursor looks current. - The pinned remote transport no longer races TLS probes to every address before each RPC. A verified route is reused (each new connection still checks the pin) and is probed again after Unavailable or a session closing under a call, on route changes and at most every 30 s. - The BFF closes an SSE response when the gateway connection breaks without a scoped error (restart, reset session), so the browser reconnects with backoff instead of counting a thread failure. Related: #748, #777 Co-Authored-By: Claude Opus 5.5 <[email protected]>
nixuuu
enabled auto-merge (squash)
November 15, 2026 08:20
Retained thread views (threadViews, up to 12) are created inside the thread screen's effect. Their $derived fields (running, ownTurns, ownEntries, queued, pending, steering, ...) belong to that effect: once the screen is destroyed (leaving for settings or the overview), Svelte keeps returning their last value (derived_inert). After a return, the stream still applied updates and advanced the cursor, but the view kept showing a turn as working and missed new prompts until a reload. Mobile (React) never had this. The fields are now getters over $state memoized on input identity (lastResult), live in any reader regardless of where the view was made. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nixuuu
added a commit
that referenced
this pull request
Nov 18, 2026
…gs (#986) ## Nightly.75 console report - Reproduced the `actorAvatars` exception and `derived_inert` warnings by invalidating avatar reads just before a PR snapshot reset. Scheduled refreshes now use a mounted subscriber, and a later explicit read uses its own fetch function. - Preserve the saved timeline anchor through a slow initial snapshot. Start the positioning deadline once data arrives and compare watch liveness against loaded history. Routine history paging still contributes to the diagnostics counter. Actionable recovery warnings keep their reason. - Open a cold thread through the owner-scoped GetThread RPC while the overview stream is rebuilding. Skip Git scans for unavailable placements. Report busy, missing, oversized and timed-out checkouts in the panel, retain the last successful counts on a transient scan failure, and cancel an abandoned shared HTTP request when its last reader leaves. - Skip idle web, desktop and BFF diagnostics submissions. Reserve admission and checkpoint space for active sessions within the existing 6 MiB budget. A frozen minute carries its checkpoints even if RPC load exhausted the space for its metric series. The screenshots omit response bodies and the expanded recovery objects. The tests cover concrete paths to the reported statuses. Genuine connectivity and rate limits still surface. ## Local verification - Focused shared-query, overview invalidation, BFF state and reads, Git status, thread history/watch, client diagnostics and persistence tests. Gateway, domain and web typechecks passed. Lint and formatting checked on edited files. Full gate runs in CI. - Chromium at 1280 and 390 px, light and dark. PR reset and avatar reload produced no exception or Svelte warning after the fix. In a 1000-turn thread, a 2.25 s initial snapshot delay restored an 8 px scroll offset. A real checkout reported its changed file, and a removed worktree issued no Git request. Desktop rapid navigation cancelled the in-flight request. At phone width in both themes, closing thread details and navigating to the removed worktree started one Git read, cancelled it once and issued no further Git request. ## Copy audit Reviewed all ten items in docs/copy.md §8. Generic Git refresh failures now identify the missing directory, busy checkout, size limit or timeout and give a recovery action. Directory terminology matches the glossary. Short, typical and long names were checked at desktop and phone widths. All items pass or are inapplicable. Fixes: #456 Fixes: #569 Fixes: #672 Fixes: #799 Fixes: #847 Fixes: #900
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.
Problem
In the desktop app the open thread view could keep showing old state (a just-sent prompt missing, a finished turn still shown as working) while the sidebar and thread summary kept updating. Only a reload (Cmd+R) recovered it. The view stayed "live": no sync indicator, no error, composer enabled. Mobile never had this. The renderer console showed hundreds of
derived_inertwarnings.Root cause
Retained thread views (
threadViews, up to 12 threads) are created inside the thread screen's effect (openThreadMemoryin a$derivedon the page).ThreadState's$derivedfields (running,ownTurns,ownEntries,queued,pending,steering, …) belong to that effect. When the screen is destroyed (leaving for settings or the overview), Svelte 5 keeps returning their last value (derived_inert,execute_derivedin svelte 5.57). After a return, the stream still applied updates and advanced the cursor, so no recovery fired, but everything read through those fields was frozen. Reproduced in isolation: a class$derivedcreated in an effect stays at its old value after the effect is destroyed and the$statechanges, while a getter returns the new value.Fix: the fields are now getters over
$state, memoized on input identity (lib/shared/last-result.ts). They stay live in any reader regardless of where the view was created, and keep a stable result for unchanged inputs.docs/client-performance.mdrecords the rule: retained state must not hold$derived.Also in this PR (recovery and transport hardening)
packages/domain/src/thread-watch-liveness.ts). The overview-head self-check stopped for good after three repairs without progress, and never reloaded. Now it resumes from the applied cursor twice, then reloads a fresh window as a page reload would, backing off from 30 s up to 5 min while the evidence lasts.history.svelte.ts, thread page). If, for 10 s, the live overview reportsrunningwhile the view has no running turn, oridle/interrupted/failedwhile the view still runs one, the same repair starts even when the cursor looks current. This is the signal the user saw.packages/transport/src/routed-pinned.ts). Every RPC used to race fresh TLS probes to every address first: tens of thousands of aborted handshakes a day on the gateway, extra latency, and failures on a slow link while the session was fine. Now a verified route is reused (each new connection still checks the pin inclient.ts). It is probed again afterUnavailable, after a session closes under a call the caller did not abort, when routes change, and in the background at most every 30 s. Concurrent probes are shared.sse.ts,gateway-errors.ts). When the gateway connection breaks withoutcanopy-error-scope(canceled,unavailable,internal, e.g. a gateway restart), the BFF closes the response, so the browser reconnects with backoff. Before, it sentfailure, and three of those stopped the watch.ui-api.md,client-performance.md,mobile.md,desktop-remote-frontend.md. Mobile shares the liveness class: it keeps resuming incrementally, with backoff and no cap.Related: #748, #777
Verification
Ran locally:
check:tmponpackages/domain/src/thread-watch-liveness.test.ts.check:tmpon the integration testsdesktop-clients(new: route reuse without per-call probes, then replacement after the route dies),thread-watch-failures(new: SSE closes withoutfailurewhen the gateway session ends),thread-client-continuity,remote-threads,gateway-chatter,desktop-version-skew,mobile-network-port,desktop-updates,paired-app-updates.Typecheck of
packages/transport,packages/domainandapps/web(svelte-check).oxlint and oxfmt on the changed files.
After the root-cause fix:
apps/webtypecheck (svelte-check), oxlint and oxfmt on the changed files. There is no Svelte test harness for.svelte.tsstate and web UI tests are out of policy; the mechanism was confirmed with a standalone compile of a minimal module against the repo's Svelte. No visual change.Not run: the full CI gate (left to CI) and a physical remote desktop session. The repair path will log
Thread watch resumed from applied cursor/Thread watch reloadedin the renderer console.Copy audit (docs/copy.md §8)
No UI text changes: only console diagnostics were added. Nothing to audit.
🤖 Generated with Claude Code