Repository navigation
fix(computers): keep pages working when a linked computer stalls - #348
Merged
Merged
Conversation
nixuuu
added a commit
that referenced
this pull request
Nov 8, 2026
## Change Mobile's Project picker now shows one “No project” and one choice per shared project identity, using the same global-id/Git-origin model as web. Distinct same-name projects show computer/workspace details. Worker choices have one row per worker and stable computer groups. The sidebar filter, thread defaults and project settings use the same projection; settings still edit the original local record. Two causes were reproduced: - The standalone Project picker introduced in #229 rendered raw overview records. Those include a scratch project per computer and configuration replicas, even when only one computer has the directory. - Retention introduced in #348 can keep an old peer project after an aggregate starts representing it through a local alias. Both records can reference the same remote workspace. The prior projection concatenated that workspace twice; snapshots/retention also preserved repeated resource IDs. The critical-state regression failed before the fix and passes afterward, including preservation of the current aggregate's workspace metadata. Shared reconciliation now enforces stable resource IDs, replaces a home's snapshot atomically and preserves other homes' workspaces. The shared projection deduplicates workspace and project references. Real two-gateway coverage replays phone subscriptions through aggregate snapshots, peer snapshots and compatibility upserts, then checks original home/workspace selection and routing. Existing owner-scoping and offline coverage remains intact. The inspected gateway path serves peer RPCs through local-only handlers and qualifies home IDs; no A→B→A aggregation was found. This change requires no gateway update or protocol change. Mobile ships through OTA; web/desktop reconciliation hardening accompanies the next desktop update. ## Verification - Passed: `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run lint`, `bun run format:check`, and `bun run --filter @canopy/web build`. - Passed: `bun run check:tmp --timeout 20000` — 1,822 passed, 161 skipped, 0 failed across 325 files; `check:tmp: nothing left in the temp dir`. - Focused checks: 8 state/project-identity tests and 5 linked-project integration tests passed. Multi-gateway files ran sequentially. Mobile's `bun run lint` also passed. - Manual device/browser visual checks were not run. The web edit changes state reconciliation; mobile reuses the existing picker/settings layout. ## OTA compatibility Only JS/TS and documentation changed. Native dependencies, app configuration and protocol descriptors are unchanged. No EAS builds or APKs were produced. Ran `bunx [email protected] fingerprint:generate --platform <ios|android> --build-profile production --json --non-interactive` before editing and after the final commit. Full fingerprint JSON files compare byte for byte: | Platform | Before = after | | --- | --- | | iOS | `2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3` | | Android | `c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d` | ## Copy audit (§8) Before: repeated “No project”/project rows and worker names without their computer. After: one scratch choice, searchable aliases (“Also named …”), computer/path details for distinct same-name projects, and “Worker · Computer” in settings. Missing scratch workspaces use the existing web instruction: “No scratch directory. Configure this worker.” Text follows sentence case and the existing glossary, with action verbs and accessible text cues. No new confirmations, error flows, glossary terms or humor. Details use existing compact text slots. Short/typical/long-name rendering at phone and wide widths remains unverified (§8.9); no visual verification is claimed. Fixes: #348 Fixes: #229
nixuuu
added a commit
that referenced
this pull request
Nov 8, 2026
Background refreshes changed a successful peer snapshot from fresh to
stale and back on every poll. The waiting message became a transient
disclosure on mobile and a changing status line on web. Keep the cached
snapshot fresh during refreshes; failed reads still expose stale status
and retain details.
Manual checks from mobile and web now reach the desktop app that owns
the gateway through the existing app-control channel. Linked checks use
the same path at their home. Requests coalesce, have a 10-second
cooldown, and wait up to 30 seconds for a newer completed check report.
Older desktops receive the existing check command without waiting for
unsupported fields. Owner checks remain enforced; checking the app does
not grant permission to replace gateway binaries.
Canopy rows show the app's actual check time, including the phone's OTA
check time. Older apps show `Check time unavailable`. Browser clients of
a desktop gateway also show its local app row.
Validation:
- `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run
lint`, `bun run format:check`, `bun run check:tmp`, and the web build.
- Focused peer-cache regression coverage plus linked update/control and
timeout integration checks, one test file at a time. Includes completion
waiting, throttling, older desktops, non-admin owner checks, and
rejection of an unlinked owner.
- Browser review on an isolated port: light/dark, desktop/phone widths,
short/typical/long names, downloaded/error/offline states and check
timestamps. No UI test suites added.
- EAS CLI 27.4.1 production fingerprint generation before/after for both
platforms: iOS `2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3`, Android
`c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d`; unchanged. Mobile edits are
JS/TS only. No native builds or publication.
Copy audit (`docs/copy.md` §8):
- Missing freshness information → `Checked {time}` / `Check time
unavailable`; short sentence-case labels distinguish app checks from
gateway polling.
- Browser omission → `Canopy on this computer`; uses the existing
product and computer terms. Local update guidance uses the existing
compact information control.
- No new errors, confirmations, jargon, repeated facts, or humor.
Existing action names remain verbs. Checked labels and long names at
desktop and phone widths; meaning remains visible without color or icon
shape.
The stale/fresh flip originates in #348; #369–#371 expose or share the
affected data. The local manual-check omission predates them. Release
publishing scripts/workflows and the frozen update protocol are
unchanged. Signed macOS installation/restart remains outside this
check-only verification.
Fixes: #348
Related: #369, #370, #371
nixuuu
added a commit
that referenced
this pull request
Nov 9, 2026
…386) ## Change A linked thread could remain on its last snapshot while its computer link and BFF SSE heartbeats stayed healthy. Peer watches had no application-level deadline. Live thread events also accepted sequence gaps. Restarting the receiving gateway recreated these streams, but a healthy transport alone could not repair them. Watches now validate durable revisions, resubscribe automatically, and surface a stale/unavailable state if recovery fails. ### Trace and evidence - `REMOTE_THREADS` forwards a qualified thread ID through the pinned computer link to the home's owner-scoped `WatchThread`. Each client watch owns an independent remote call. The home subscribes to Hub before reading its snapshot. Re-opening already creates a fresh watch; no shared client consumer-count leak was found. - `THREAD_MIRROR` separately maintains one background subscription per peer. Committed snapshots/cursors live in the owner-scoped mirror tables; staged reset generations remain invisible until commit. The runtime's existing subscription entry could remain occupied indefinitely by an open stream without progress. Existing mirror predecessor, delta-base, epoch, generation and subscription fences already rejected inconsistent updates; they lacked a deadline for missing final frames. - Web and desktop receive the forwarded watch over the BFF's linked-subscription HTTP/2 pool and SSE. Four BFF pools isolate local/linked unary calls and subscriptions. SSE heartbeats prove BFF reachability; they do not prove upstream thread freshness. The browser cache keeps an atomic checkpoint and reopens through the gateway. `linked-snapshot` retains aggregate linked rows and applies presence separately; it does not deduplicate thread watches. - #348's peer HTTP/2 PING (15-second interval, 10-second pong budget), link heartbeats, circuit breaker and reconnect handling remain intact. Transport loss terminates calls and reconnect resumes from committed cursors. These checks cannot detect lost application fan-out while the transport still responds. - The new gateway-to-gateway tests failed before the fix for live-watch stalls, accepted event gaps, a mirror missing its final checkpoint, and an older peer without heartbeat recovery. Re-opening already passed. #350 fixed an earlier Hub cleanup race consistent with the report, but the inaccessible affected app's cause cannot be established from the available logs. A home event-loop pause alone does not erase the durable journal; the tests additionally suppress fan-out while changing durable metadata. ### Recovery - Negotiate `thread_watch_liveness`. The home sends an independent durable revision heartbeat every 5 seconds. A changed revision revalidates the snapshot checkpoint, using existing deltas for incremental clients. The owner-wide revision can conservatively revalidate another open thread too. - Missing initial snapshots/heartbeats expire after 15 seconds. An established live watch enters the existing syncing state and retries once with an empty cursor. A failed repair returns a computer-scoped unavailable error to the existing client reconnect path. Live event gaps and invalid delta bases also force a full snapshot. Sequence checks run before BFF text-delta coalescing, which intentionally skips sequence numbers. Loaded history boundaries are retained. - Mirror heartbeats must match the receiver's committed cursor and arrive outside partial projections. A gap or 15-second stall clears the cursor and restarts from a full generation on the next link tick (within 5 seconds). The last committed generation remains readable. A sync failure projects the existing unreachable state; a commit or matching checkpoint heartbeat clears it. Ordinary transport loss retains the checkpoint for resume. - Older peers are revalidated every 30 seconds without requiring new frames: reopen the live read from its supported checkpoint, and refresh the mirror generation. Only reads are retried. Bounds assume the receiving event loop can run. - Subscribe/end/resubscribe diagnostics use debug; unexpected stalls, gaps, probe failures and stream failures use warn. Both sides log IDs and safe protocol metadata only, without hosts, names, thread content, credentials or raw errors. All protobuf changes are additive. The frozen update protocol, worker link compatibility, schema and mobile/web source are unchanged. The Polish linked-computers document now describes the liveness and recovery rules. ## Verification - `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run lint`, `bun run format:check`, and `bun run --filter @canopy/web build` passed. - New gateway-to-gateway suite: 11 passed. Covers open stalls, missing heartbeat frames, event gaps, invalid bases, missed metadata fan-out, re-opening with a stale mirror, lost mirror checkpoints, unreachable/recovered status, idle reconnect confirmation, and an older home without new frames. - Existing mirror suites ran one file at a time: 19 durable mirror tests and 12 incremental mirror tests passed, including restart, fencing, owner scoping and legacy negotiation. The existing linked-list retention test also passed in isolation after distinguishing ordinary transport loss from application-stream failure. - Full `bun run check:tmp --timeout 20000`: **1,865 passed, 161 skipped, 0 failed across 330 files** (982.07 seconds), with nothing left in the test temp directory. This includes all 11 new liveness tests and the existing linked-list retention regression. Multi-gateway files ran sequentially. - The preceding full attempt had one updater handover test fail with `ENOSPC` on the shared temp filesystem (1,864 passed, 161 skipped). Repeating the full gate with a disk-backed private `TMPDIR` passed, including that test; no updater code was changed. - No UI tests added. No web or mobile source changes; no browser/device run was required. Packaged apps and the originally affected computer were not exercised. Copy audit: uses existing Syncing/reconnect/unreachable states and the existing computer unavailable reason; no new frontend copy. Related: #348 Related: #350 Related: #265
nixuuu
added a commit
that referenced
this pull request
Nov 9, 2026
Linked thread lists read and protobuf-decoded every complete mirrored history to obtain the small `ui.Thread` row. Lists and header reads now use the existing atomic metadata projection, with a backfill that makes it mandatory. Healthy aggregate lists use the bounded live-read cache; the mirror remains the loading/offline/failure fallback. ## Evidence - The home log repeatedly executes `SELECT t.snapshot ... computer_mirror_threads ... ORDER BY t.thread_id`, followed by connection resets/broken pipes. The supplied client's PostgreSQL log has no matching statement: the expensive direction is the home listing the client's mirrored threads. - Call path: sidebar/overview `ListThreads` → `gather` → `forward` → `ThreadMirror.threads()`. Qualified project lists use the metadata mirror directly. Web and mobile reload on reconnect and linked-read completion; no independent fixed sidebar polling timer was found. Live results refresh after 5 s, reads have a 10 s budget, failed refreshes cool down for 30 s. - No SQL read/query deadline is configured on this path. The SQL driver pinned in nightly.108 (4.1.1) rejects backend messages above 16 MiB and fatally closes the socket. The integration test reproduces its parser failure with a 17 MiB snapshot row while metadata listing succeeds. This is consistent with the observed resets; the historical row sizes and client-side SQL errors are unavailable, so their exact cause remains unproven. Synchronous full-history decodes also add event-loop pressure. ## Cost | Path | Before | After | How measured | | --- | --- | --- | --- | | Mirror list, 100 threads × 3 MiB | 314,583,794 bytes, 378 ms | 9,294 bytes, 4 ms | Real PostgreSQL integration fixture, query plus protobuf decode; representative run | | Healthy aggregate linked list | Re-read the mirror for every call | Bounded cached live result; no mirror call | Linked-gateway regression test | Migration 0097 extracts the protobuf header inside PostgreSQL, handles reordered fields, then sets `thread_metadata NOT NULL`. Existing writes already update metadata and snapshot in one transaction. Owner/project/archive/sidebar filtering remains enforced. Cache bounds remain 128 keys/16 MiB and four active reads per peer. Slow metadata lists log duration, count and bytes above 250 ms, without content or hosts. ## Validation Focused metadata/backfill/oversized-row and healthy-cache tests pass. Top-of-stack validation passed: `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run lint`, `bun run format:check`, `bun run check:tmp`, and the web production build. The full test run finished with **1,904 passed, 161 skipped, 0 failed across 339 files** (982.19 s), with nothing left in the private disk-backed temp directory. Multi-gateway files ran sequentially. All three stack heads have green CI; the stack is ready for review and has not been merged. Copy audit §8: no UI text changes. Fixes: #348 Related: #27 Related: #386
nixuuu
added a commit
that referenced
this pull request
Nov 10, 2026
Linked bots can stay missing in web/desktop even when both computers
show connected. `ListBots` served only the in-memory peer-read cache
while a home was online, so a cold/evicted cache or an A gateway restart
returned no remote bots despite a committed bot mirror. The background
read eventually completed, but the web bot store ignored
`linkedReadCompleted("ListBots")`. Since #458 disabled polling when the
gateway advertises pushed bots, that incomplete list could persist until
another bot change or client reload.
Use the committed mirror while the online read cache is loading or
stale, and continue refreshing the authoritative home list in the
background. Bot mirror commits also mark the home's list cache due and
announce a list invalidation. The web bot store now handles that
invalidation. Mobile already handles it through `OverviewInvalidation`
in its shared query bus, so its implementation remains unchanged.
Existing dimmed/read-only rows and gateway rejection of offline writes
remain in place. Updating A restarts its gateway and client
subscription, restores the persisted mirror immediately and refreshes
from B automatically; no manual resync, database repair or re-pairing is
required.
The original cold-cache behavior comes from #348; #458 turned a
transient incomplete web list into persistent missing rows. History does
not implicate #502 (worker command delivery), #507 (connection
recovery), #500 (workspace/config sharing) or #475 (row badge
rendering). A plain warm-cache B restart did not fail in the baseline.
The cold-cache and A-restart cases reproduce a failure path matching the
report; the maintainer's live stack and databases were not inspected or
changed.
Extract the unchanged feed-negotiation helper from `routed-overview.ts`
to keep the file and watch function within the repository's size limits.
Update the Polish bot and linked-computer documentation.
## Verification
- RED, before the production fix: `TMPDIR=/var/tmp bun run check:tmp
tests/integration/linked-bots-resync.test.ts` — 2 failed, 2 passed. The
cold online-cache read and first list after A restarted omitted B's bots
despite their persisted mirror. Temp cleanup passed.
- GREEN: **30/30 sequential complete-file runs passed**, one test
process at a time using the same `check:tmp` command. Each final-file
run passed all five integration scenarios (150 scenario passes in total)
and left nothing in its private temp directory.
- Coverage: two real gateways, separate PostgreSQL databases and an
actual mTLS link; active and archived bots with last-message previews;
same-version B restart and restart with advertised app version changing
from nightly.119 to nightly.121; A's one ongoing overview watch and
fresh API reads; read-only/offline write rejection; A gateway restart
with its database retained; deletion, archive/unarchive and message
changes made while B was away, then convergence after a fresh B runtime.
Version coverage changes the handshake version on the current
implementation; it does not run historical release binaries. The client
is exercised at the public API/feed boundary; no UI test suite was
added.
- Related suites, run sequentially one file at a time through
`check:tmp`: `linked-reads` (4 passed), `linked-list-retention` (1
passed), `linked-agents` (16 passed). All three temp cleanup checks
passed.
- `bun install`, `bun run typecheck`, `bun run lint`, `bun run
format:check`: passed. Implementation and regression coverage received a
self-review. Full unfiltered tests, `gen:check`, a web build and
browser/device checks were not run locally under the workspace
verification limits; CI covers the broader automated checks.
Copy audit (`docs/copy.md` §8): no UI text added or changed.
Fixes: #458
Related: #348
This was referenced Nov 13, 2026
M-Zajace
added a commit
that referenced
this pull request
Nov 16, 2026
#890) ## Summary A worker of a linked computer that does not share configuration is read-only on this computer ("Manage this worker on its own computer. Configuration is not shared."). Settings → Workers treated read-only as away (`worker.online && !linked?.readOnly`), so such a worker always showed **Disconnected**, was dimmed and was left out of the "N of M connected" count, even while it ran. - `LinkedWorker` gets `away`: the worker's home does not answer now (no live worker, or the computer has an away reason). - The status badge, the row's dimming and the connected count follow `worker.online && !away`. - Read-only still only blocks changes (rename, tags, settings). Related: #348 ## Verification - Seen on two real linked desktops (macOS and Windows, configuration not shared): each showed the other's running worker as Disconnected. - Locally: `@canopy/web` typecheck, lint and format on edited files. Not yet checked in a browser with two linked computers carrying the fix; the full gate is left to CI. ## Copy audit (docs/copy.md §8) No UI text changes: n/a.
nixuuu
added a commit
that referenced
this pull request
Nov 27, 2026
## Changes **Root cause.** A gateway starts its linked-computer runtime before network access opens its listener. The runtime's first tick already dials every partner. When the listener opened, the first address advertisement treated the listener's addresses as a network change and rotated every link (`computersReconnect` with the 100 ms flush). A link that had finished its handshake in that window was marked retiring and closed 100 ms later. The partner then stayed "unreachable" until the next dial, after a backoff of about a second. In `tests/integration/computer-moves.test.ts`, the restarted source (A) settled the committed move over such a short-lived link, so `finalState(id1)` returned `done` and the test continued. The next `StartMove` failed with `Laptop C is unreachable since …`. The two tests after it ran inside the same backoff window and failed the same way (CI run 46031074683, shard 8/12). Delaying the fixture's `network.start()` by 300 ms reproduced the same three failures, plus the earlier "interrupted before the decision" test. - `runtime-lan.ts`: opening the listener (gateway start, or network access turned on) is not treated as a network change. No partner can hold a link to an earlier address, and links this computer dialled keep working. Partners still get the new routes in a `routes` frame. Closing the listener and interface or address changes still rotate links. - `computer-moves.test.ts`: waits for the link after restarting the source. An `afterEach` clears crash hooks and restarts link runtimes a test left stopped, so a failure cannot carry over to later tests. - `lan-routes.test.ts` + `support/computers.ts`: a fixture hook (`beforeListening`) runs between runtime start and listener start, the same order as a gateway. A new test checks that a link dialled before the listener opens is not retired. It fails on the old code (2/2 runs) and passes with the fix. - `docs/linked-computers.md`: documents the behaviour and adds a status line. Fixes: #348 ## Verification Ran locally: - `computer-moves.test.ts` via `check:tmp`: 15/15 passes in a row, 5/5 under 18 busy-loop CPU hogs (load average about 20), and passing with a 300 ms delay before the listener opens (this delay made 4 tests fail before the fix). - `lan-routes`, `linked-routes-status`, `linked-computers`, `computer-relay`, `network-access`, `linked-relocation`, `tailscale-network`: all pass. - `tsc --noEmit` for `tests/integration` and `apps/gateway`; oxfmt and oxlint on the edited files. Left to CI: the full gate (all test shards, repo-wide typecheck/lint/format, `gen:check`, builds). Copy audit: no UI text changed. ## Follow-up: thread mirror regression The first version made `thread-mirrors.test.ts` fail in every run (3/3 locally, CI run 46036520107): opening the listener no longer called `computersReconnect`, which was also what cleared dial retries and read circuits. A partner that failed while this computer was unreachable stayed blocked for the 30 s circuit backoff. Opening the listener now calls `computersRedial` (clear retries, reset read circuits) without aborting dials: a dial controller owns its live link, so aborting it would drop the link this PR keeps. Verified locally: `thread-mirrors` 3/3 (was 0/3), `computer-moves` + `lan-routes` 3/3, and `linked-computers`, `linked-routes-status`, `network-access`, `computer-relay`, `linked-relocation`, `linked-thread-liveness` 58/58 through `check:tmp`. Gateway typecheck, oxlint, oxfmt. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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 and cause
A linked computer could stall local pages because aggregate RPCs synchronously waited for peer responses. The original peer gathering budget was 3 seconds, matching the BFF's existing 3-second deadline (#20,
66f30fef), so the BFF could time out before the gateway discarded the failed peer response.Updates loads
/api/updates→GetUpdates→GetComputerUpdates. Connectors loads both local/api/connectorsand merged/api/bots→ListBots. Overview, threads, models, schedules, worktrees and the linked-agent catalog had the same coupling. Updates and Connectors poll every few seconds; each refresh could repeat the wait. The supplied desktop log contains 425 recurring 504s beginning at 2026-11-07T15:38:55Z, with failures still occurring during read-only inspection at 16:05:26Z, while local health returned 200 in under 1 ms. These failures were current. The old logs cannot identify the exact production RPC or prove a particular half-open socket. The worker governor'sactive=5message is not evidence of causation: linked reads do not consume worker process slots.Mobile also replaced its list with incomplete reconnect snapshots. Available peers were excluded from the offline mirror fallback, so a flap could remove their rows. Paginated mobile thread opening bypassed the mirror seed while a stale link still looked reachable.
Change
All timing constants and cache/availability rules are documented in
docs/linked-computers.md; architecture, desktop, mobile, UI API and update docs describe the changed behavior. Proto changes are additive; the frozen update protocol is untouched.Covered surfaces
list_agents,list_threads,list_botstoolsSearchThreadsand#mentions remain local-home only; file/catalog requests explicitly target a worker rather than merging peers.Validation
bun install,bun run gen:check,bun run typecheck,bun run lint,bun run format:check, and the web production build. After rebasing onto currentdev, generation, typecheck, lint, formatting and the web build passed again.bun run check:tmp --timeout 20000on the submitted head: 1,764 passed, 161 skipped, 0 failed across 316 files (862.22 seconds), with nothing left in the temp directory. Multi-gateway integration files ran sequentially.maxConcurrentStreams: 1. During a peer stall, local aggregate/settings/tool calls and local streaming stay below 500 ms.Copy audit (§8)
Before: global
Update failedor whole-pageThe gateway request timed out, despite healthy local data. After:Waiting for {name}. Local updates are ready.during background refresh, or a named unavailable note with automatic retry; Connectors explains an incomplete linked bot list beside working local accounts. Retained rows use the existingOffline/Read-onlyvocabulary, with short reasons for disabled actions and remote administration.Text uses sentence case, plain language, active voice and the existing glossary. No new confirmations, empty states, humor or glossary terms. Controls use verbs; loading, offline and read-only states have text cues as well as dimming. No transport jargon is exposed in the new notes. Short, typical and long-name browser/device checks are recorded with validation below.
Fixes: #20
Related: #324