Skip to content

fix(computers): keep pages working when a linked computer stalls - #348

Merged
nixuuu merged 1 commit into
devfrom
fix/linked-timeouts
Nov 7, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/linked-timeouts

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

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/connectors and 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's active=5 message 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

  • Local aggregate reads return committed mirrors and cached peer snapshots immediately. Bounded, single-flight background reads refresh the linked part; completion events refresh interested catalogs. Ordinary reads allow 10 seconds; update checks allow 120 seconds and installs 15 minutes. A slow read keeps its prior value and cools down for 30 seconds without declaring the computer dead. The cache is limited to 128 keys/16 MiB and four active reads per peer.
  • Lost links open a per-peer circuit with 30/60/120-second backoff capped at 3 minutes. HTTP/2 PING runs every 15 seconds with a 10-second pong budget, alongside the existing application heartbeat. Authenticated reconnect/discovery, wake and network changes reset backoff. Wake and changed interfaces retire old sockets; route changes flush the new address before rotation, including outbound-only peers. Sessions close explicitly. Saved mTLS pins and TLS 1.3 remain enforced; sent actions are never replayed.
  • The BFF uses four HTTP/2 pools: local unary calls, linked unary calls, local subscriptions and linked subscriptions. A stalled linked stream cannot queue local thread streaming even when the server allows only one concurrent stream. Outgoing peer calls are bounded separately from incoming calls. Connectors polling and Update all ticks are single-flight. BFF failure logs include only RPC method, duration, status and sanitized message.
  • Shared domain reconciliation retains linked rows during partial refreshes, even before liveness expires. Presence dims rows and disables peer-dependent actions with a reason. Explicit deletions, authoritative home snapshots and unlink still reconcile removals. Thread reads, including paginated phone history, seed immediately from the durable local mirror.
  • Mirror frames retain the home's history version, so older pages can extend the immediate local window safely. Mirror cursors resume locally; reconnect replaces them with an authoritative home snapshot. A stale/legacy mirror with a different history version cannot extend a live window.

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

Surface Behavior while the peer is unavailable
Web/desktop/mobile overview, sidebar, thread lists, project filters and command search Retained mirrored/last-known rows; offline/read-only state; local navigation stays responsive.
Thread opening, streaming and paginated history Local mirror seed for reading; sending, steering and other home actions require availability.
New-thread worker/project/workspace/model choices; project picker; command worker choices Retained choices; offline execution targets disabled with reasons; a shared project with a local workspace remains usable.
Worker/project Settings lists and details Retained rows; remote administration is read-only when unavailable or configuration is not shared.
Bot lists, bot/schedule targets, schedules and worktrees Background cached lists; retained offline rows and disabled peer actions.
Updates and Connectors/access choices Local data immediately; peer loading/stale/unavailable notes and automatic refresh; cached offline update actions disabled.
Providers, proxies, agent environment, shared configuration and Devices Local owner-scoped records; no synchronous peer I/O in page reads. Explicit remote edits remain separate operations.
Linked agent catalogs/overview and agent/bot list_agents, list_threads, list_bots tools Local/last-known data from the same cache/mirrors; background refresh with availability/loading state.
Search and mentions Sidebar/command search uses retained overview. SearchThreads and # mentions remain local-home only; file/catalog requests explicitly target a worker rather than merging peers.

Validation

  • Passed: bun install, bun run gen:check, bun run typecheck, bun run lint, bun run format:check, and the web production build. After rebasing onto current dev, generation, typecheck, lint, formatting and the web build passed again.
  • Full bun run check:tmp --timeout 20000 on 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.
  • Focused linked-timeout regression: 7 passed, covering stalled/half-open peers, recovery with the same mTLS pin, slow healthy reads, outbound-only route changes, and four independent BFF pools with maxConcurrentStreams: 1. During a peer stall, local aggregate/settings/tool calls and local streaming stay below 500 ms.
  • Focused history paging: 6 passed, including mirror-first linked pages, matching home history versions, live handoff, offline pagination and durable resume. The full gate caught and this change fixes the missing history version in mirror frames.
  • Real browser: two isolated linked gateways with controlled connection blackholes; Updates and Connectors, retained mirrored threads, worker/project pickers, worker Settings, and recovery. Light/dark, 1280×800 and 390×844; short, typical and long computer names. Local APIs returned 200 in 17–64 ms during the outage. Desktop's shared frontend was checked in the browser and its pinned BFF transport in integration tests; an Electron shell was not launched.
  • Android: Linux-built isolated development client on the restored MacStudio device host, Canopy_Fold. Light/dark; repeated blackholes retain dimmed Read-only threads and readable mirror history, disable sending and remote targets with reasons, preserve local navigation, and recover normally without re-linking. Healthy remote model choices were also checked. The isolated app was removed afterward; the existing app was untouched. Fold closed/open was exercised, but cover-width layout was not independently established.
  • Own preview tab, gateways, web server, Metro, tunnels and database containers were stopped/removed; production apps were inspected read-only.

Copy audit (§8)

Before: global Update failed or whole-page The 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 existing Offline/Read-only vocabulary, 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

@nixuuu
nixuuu merged commit 4f03627 into dev Nov 7, 2026
11 checks passed
@nixuuu
nixuuu deleted the fix/linked-timeouts branch November 7, 2026 18:37
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
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant