Repository navigation
feat(gateway): show and drive linked computers' threads - #20
Merged
Merged
Conversation
Proxy GatewayService thread calls over the pinned link (remote_threads capability, chunked RemoteRequest/RemoteResponse frames), qualify ids by node, aggregate the overview, thread list and models, and fail fast for unreachable or outdated partners.
Machine badges in the sidebar, thread header, hover card and pickers, a read-only banner while a partner is away, a 'needs an update' state in Settings, and per-computer settings limited to this computer.
nixuuu
force-pushed
the
feat/linked-computers-2
branch
from
November 3, 2026 22:29
e56e2bc to
14955f3
Compare
nixuuu
marked this pull request as ready for review
November 4, 2026 05:57
nixuuu
added a commit
that referenced
this pull request
Nov 4, 2026
Stage 3 of linked computers (stacked on #20; the whole stack merges into `dev` together when the plan is complete). Keep linked-computer threads listed and readable offline using durable read-only mirrors: owner-scoped change journal on the home, separate mirror tables keyed by origin node, epoch/revision cursor replay, generation-based atomic full resync on a stale or mismatched cursor, deletion/archive reconciliation, `thread_mirror` capability with stage-2 fallback for older peers, and unlink purging the mirror. Online reads stay live-routed; offline reads come from the mirror; writes always require the home and are never queued. Blob metadata is mirrored, bytes load when the home is connected. Secrets and provider credentials are never mirrored. - Migration 0049 (renumber at merge if `dev` moved). - Additive proto; link protocol stays 1. - UI: greyed offline threads with "Last seen", read-only banner, attachments "available when … is connected". - Tests: 16 mirror scenarios with two gateways + separate databases (initial sync, live changes, offline read, resume from cursor, stale cursor resync, deletions/archival, unlink purge, capability fallback, restart durability) + schema tests; check:tmp 702 pass / 0 fail. - Docs: `docs/linked-computers.md` → "Konkretny protokół etapu 3".
nixuuu
added a commit
that referenced
this pull request
Nov 7, 2026
## 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
This was referenced Nov 13, 2026
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.
Stage 2 of linked computers (stacked on #13; the whole stack merges into
devtogether when the plan is complete). Threads, workers and projects of every connected linked computer appear next to your own, with a machine badge. Reading, sending, steer, queue, interrupt, approvals and creating a thread on a partner's worker are sent to the thread's home computer over the pinned link; nothing is copied or queued.canopy.link.v1: chunkedRemoteRequest/RemoteResponse/RemoteCancel, gated by the newremote_threadscapability (protocol stays 1).<uuid>~<node16>ids; the home only answers allowlisted thread methods, with no forwarding onward.tests/integration/remote-threads.test.ts(10), two gateways with separate databases and the real mTLS link; check:tmp 686 pass / 0 fail.docs/linked-computers.md→ "Konkretny protokół etapu 2".