Repository navigation
fix(computers): resync linked thread views when their stream stalls - #386
Merged
Merged
Conversation
This was referenced Nov 9, 2026
nixuuu
added a commit
that referenced
this pull request
Nov 9, 2026
Mobile now previews and moves an individual thread or bot to another linked computer, opens the moved result, converts provider environment proxy settings into a reusable proxy, and shows per-item import results with Open thread actions. Suggested library items are preselected; conflicts and secrets still require an explicit choice. Environment review shares file and text change summaries with web. Selecting a stored skill version fetches that version's artifact before Save becomes available. The existing GetAgentEnvironment request/response gains additive preview fields; the gateway checks ownership and retrieves the immutable artifact without changing assignments or the environment revision. An older gateway that omits the artifact leaves Save blocked and asks the owner to update that computer. Proxy migration sends only instance identity, name and revision; saved credentials stay in the gateway. Validation: - On the final top branch, `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run lint`, `bun run format:check`, foreground `bun run check:tmp` and `apps/web`'s `bun run build` passed. Full suite: 1868 passed, 162 skipped, zero failures, 21587 assertions across 330 files; no test temp entries left. The web build reports a chunk-size warning. All layers were rebased onto `acd4a9f1` (including #386/#387) before the full checks. Final fingerprint generation was repeated on every layer after squashing review fixes; the final tree matches the tested tree. - Focused `tests/integration/agent-skills.test.ts`: 9 passed, 126 assertions, zero failures. Covers the selected historical artifact, unchanged assignment/revision, unavailable versions and foreign-owner rejection. - No dependencies, native configuration, native builds, system notifications or UI tests added. Production runtime fingerprints, before → after this layer: | Platform | Before | After | | --- | --- | --- | | iOS | `2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3` | `2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3` | | Android | `c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d` | `c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d` | Generated with `bunx [email protected] fingerprint:generate --platform <ios|android> --build-profile production --json --non-interactive`. Copy audit (docs/copy.md §8): reviewed new labels, states, errors and confirmations for sentence case, glossary, action wording and recovery. “These files belong to the currently assigned version. Saving restores the selected library version.” → “Review the selected version before saving. Saving syncs these files to the assigned computers.” The review now refers to the artifact actually fetched. Aggregate import status → item statuses/errors and “Open thread”; the action names its destination. No humour or new glossary terms. All new icon actions have text labels. Visual text-length audit remains manual and unverified. Manual QA still required; installed simulator clients cannot execute this checkout. Use an existing compatible client after the JS changes are available. Repeat in light/dark, phone width (~390 dp) and Fold width (~720 dp), with short, typical and 80-character names and long paths: 1. Thread header menu / bot menu → Move to a computer. Check offline and unsupported targets, preview blocks, workspace placement, confirmation, completion and Open moved item. Verify the destination and offline home gates. 2. Settings → Providers → an instance with saved proxy environment → Move to a proxy. Name and save it; verify the instance uses the proxy while the saved secret remains masked. Retry a stale revision. 3. Settings → Import → expand a completed and a partly failed run. Check each result, warning/error, Open thread and suggested library selection. Open import from an available computer and the empty thread list. 4. Settings → Agent environment → edit a skill → select an older version → Review files. Confirm selected contents, added/removed/binary/script files, complete before/after text, fetch failure/retry and blocked Save until the selected artifact loads. Review an instruction change too. 5. Check compact overlays, nested scrolling, long labels and loading/error states for clipping, gaps and layout shifts. Web shares the change summaries and also needs a light/dark narrow/wide visual check. Keep this PR and the entire stack in draft; do not merge individual layers.
nixuuu
added a commit
that referenced
this pull request
Nov 9, 2026
Mobile bot details now pause, activate and delete routines and cancel reminders. Sidebar bot menus add pin/unpin and movement, preserve editing/archive/delete, and expose archived conversations. Actions respect the available home and live connection; routine deletion explains its effect and asks for confirmation. Bot creation starts with model selection. Web and mobile share pure duplicate-name validation and shorthand colour normalization through `packages/domain`. A pending approval card opens the bot's approval-policy picker through the existing update route; changing policy does not answer the card, and the gateway remains authoritative. Validation: - On the final top branch, `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run lint`, `bun run format:check`, foreground `bun run check:tmp` and `apps/web`'s `bun run build` passed. Full suite: 1868 passed, 162 skipped, zero failures, 21587 assertions across 330 files; no test temp entries left. The web build reports a chunk-size warning. All layers were rebased onto `acd4a9f1` (including #386/#387) before the full checks. Final fingerprint generation was repeated on every layer after squashing review fixes; the final tree matches the tested tree. - Mobile TypeScript, repository lint and formatting passed during implementation. Existing gateway integration suites cover bot routines, lifecycle and approval enforcement; no new UI or trivial unit tests. - No dependencies or native configuration changed. Production runtime fingerprints, before → after this layer: | Platform | Before | After | | --- | --- | --- | | iOS | `2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3` | `2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3` | | Android | `c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d` | `c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d` | Generated with `bunx [email protected] fingerprint:generate --platform <ios|android> --build-profile production --json --non-interactive`. Copy audit (docs/copy.md §8): read-only routine/reminder rows → “Pause routine”, “Activate routine”, “Delete routine” and “Cancel reminder”; each action names its object. Delete confirmation repeats the verb and explains queued/active runs and irreversibility. Silent duplicate-name rejection → shared “A bot with this name already exists. Choose another name.” Errors state the failure and recovery; titles use sentence case and bot/routine terminology. No humour, new glossary terms or icon-only meaning. Visual short/typical/long-name audit remains manual and unverified. Manual QA still required; installed simulator clients cannot execute this checkout. Use an existing compatible client after the JS changes are available. Repeat light/dark at phone (~390 dp) and Fold (~720 dp) widths, with short, typical and 80-character names: 1. Open bot details on a live home. Pause/reactivate a routine, cancel a reminder, cancel and confirm routine deletion. Disconnect its home and verify all mutations become unavailable. 2. Sidebar Bots → ellipsis and long press. Pin/unpin, edit, archive, expand Archived, unarchive and delete. Check pin order, confirmation preferences, stale settings retry and move entry. Verify read-only home behavior. 3. Create bot. Choose the first model, enter an existing name with case/space variations, enter `#abc`, then save. Verify duplicate feedback and normalized colour. Retry an unconfirmed creation unchanged. 4. Open a pending approval → Change approval policy. Pick a policy, verify the existing countdown stays in the header, then separately answer the card. Repeat offline and after expiry. 5. Inspect compact menus, reserved row action space, wrapped schedule metadata and keyboard interaction for clipping, seams or layout shifts. Web's shared validation also needs a creation/edit smoke check. Keep this PR and the entire stack in draft; do not merge individual layers.
nixuuu
added a commit
that referenced
this pull request
Nov 9, 2026
This was referenced Nov 9, 2026
nixuuu
added a commit
that referenced
this pull request
Nov 9, 2026
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 9, 2026
Overview, sidebar and watch paths repeatedly read large settings/configuration or whole turn/journal collections to obtain small metadata. This layer stores metadata projections, bounds page and turn reads, batches scratch workspace reconciliation and avoids unrelated watch refreshes. ## Cost | Path | Before | After | How measured | | --- | --- | --- | --- | | Scratch overview, 101 workers | 106 SQL statements on an unchanged listing | 6; only missing/changed workspaces write | Real SQL spans and owner/root-change assertions | | Worker profile-name lookup | 20,971,600-byte saved config | 23-byte stored name map | Synthetic large config, actual JSON sizes; listing preserves names | | Thread list/header/watch metadata | Up to 40 MiB of instructions/title context in the fixture | Stored UI settings only | Oversized fields plus successful list, header, broadcast and paged snapshot reads | | Activity timestamp | Scan all turns per listed thread | One indexed row | 10,000-turn fixture, `EXPLAIN ANALYZE` | | History page IDs | 10,000 IDs / 360,000 ID bytes | 24 IDs / 864 ID bytes | Real PostgreSQL window query; fork/target/from/reset tests | | Turn broadcast/enqueue confirmation | Read every turn and input, then find one | Read the requested turn only | 10,000-turn fixture with an unrelated 20 MiB input; real broadcast | | Moved history version | Hash 8 MiB on every snapshot | Read a stored 32-byte hash | Generated-column backfill/update checks and query plan | | Mirror journal | Transfer 1,000 repeated changes to JS; unrelated changes copied per watch | One distinct sync key; zero unrelated per-thread delta keys | Real journal fixture, continuity/gap checks | | Watch heartbeat | Any owner revision could reopen every watch | Relevant thread/fork/shared metadata only | Unrelated/relevant/pruned-journal regression; linked liveness suite | Migration 0098 adds stored thread settings, worker profile names and moved-history hashes, plus activity and mutable-source indexes. PostgreSQL backfills them and maintains them on every write. Before building indexes it validates deferred constraint events from earlier data repairs in the same upgrade transaction; the migration-0096 upgrade fixture covers this path. Metadata polling no longer detoasts the full saved configuration. Workspace grouping is linear. Update snapshots project status fields and omit install-command decoding. Mirror publishers coalesce keys in SQL and leave retention to the existing commit trigger, removing a redundant DELETE every 250 ms per subscriber. ## Audit boundaries - Existing `PeerReads`, workspace-origin caches and update-center single-flight work are already bounded; their freshness and invalidation behavior is retained. - Complete thread indexes still return the required metadata rows; no silent truncation changes list semantics. Normal history pages cap at 100 turns, while explicit target/from requests intentionally expand a window. - A cold durable mirror reset and applying a content delta still need complete content. They remain distinct from metadata-only reads. Very large direct snapshot reads retain the SQL driver's wire-message limit; this layer does not claim to remove every content serialization cost. Focused PostgreSQL cost, paging, upgrade and linked-liveness checks 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. Related: #301 Related: #386
nixuuu
added a commit
that referenced
this pull request
Nov 9, 2026
…402) A linked send could commit at its home after the BFF reported a timeout and unlocked the draft. Uncertain sends now stay pending and retry the same immutable `clientRequestId`; the home stores a durable admission receipt atomically with the effect. Local watches independently recover missed durable changes. ## Root causes and evidence - The supplied client BFF log records `SendMessage`, `durationMs: 3002`, HTTP 504, `The gateway request timed out` at 2026-11-09 11:43:23Z and 12:19:44Z. This confirms the banner came from the inherited 3 s BFF default. Linked writes allow 30 s (reads 10 s); cancelling a response cannot undo a committed home mutation. Read markers and other metadata calls also hit the 3 s deadline. - The mirror-list cost and SQL parser limit are handled in the lower layers. Only the home log contains the repeated mirror-snapshot statement. Client gateway shutdowns are consistent with restarts but do not establish why the UI had become stale. - #386 already protects linked thread watches with revision heartbeats, leases, gaps and resubscription. Local watches lacked an independent durable revision check. The regression withholds Hub fan-out during a title change and turn finish, then verifies recovery without reopening the view. Hub queues are unbounded: an event-loop stall does not itself prove dropped events. The historical local stale-view mechanism, SSE backpressure and browser cache involvement remain unproven. ## Behavior - The messages BFF uses 10 s and returns HTTP 202 for an unknown transport outcome. Web/desktop and mobile retry every 2 s using the same request and id. The editor and draft stay locked with `Sending…` / `Still waiting for <computer>…`; explicit application rejections remain errors. - Migration 0099 records the admission response under an owner-scoped thread lock in the same transaction as its effect, including `/goal`. Concurrent retries cannot become a second message after the original turn finishes. Replays return the current turn/steer state. A different request id on another device is a distinct message: **no cross-device content deduplication**. - BFF defaults are method-aware: local reads 10 s, qualified linked reads 15 s, other writes 35 s; explicit budgets win. Ordinary JSON fetch allows 40 s. Read markers return immediately, coalesce to the highest pending sequence per thread and cap active threads at 256; their failures do not surface in the UI. - Local watches probe durable relevant revisions every 5 s and recover a gap, revision change or event-loop stall while retaining the loaded history window. Both linked and local probes avoid resnapshotting for unrelated threads, with conservative fallback for mutable sources and pruned journals. - Content-free diagnostics record slow/timeout linked send outcomes with request id, side, peer id and duration; slow mirror lists and local watch stalls/resubscriptions also leave evidence. No content, hosts, credentials or raw transport errors are added to logs. ## Validation Focused tests cover: a delayed home applying a steer after the caller deadline → `steered`, exactly one steer and one worker command; retry after completion; eight concurrent admission retries; receipt replay after recreated core/archival; `/goal`; owner rejection; lost local fan-out recovery; #386 linked liveness; 100 read markers → two RPCs; and a real BFF read beyond the old three-second deadline. 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. Real-browser inspection passed at desktop and phone widths, light/dark, short/default and long synthetic names: pending state, locked editor, no error/overflow/control shift, then confirmed delivery clears and unlocks the composer. No UI test suite was added. Mobile changes are JS/TS only. Both requested production fingerprints are unchanged; no native mobile runtime verification is claimed. ## Copy audit §8 Before: an unknown delivery displayed `The gateway request timed out` and released the composer. After: `Sending…`, then `Still waiting for <computer>…` until confirmation. These are English sentence-case live statuses with one purpose, no jargon, repeated error, new action or color-only meaning. Existing definitive rejection text is retained. No new buttons, glossary terms, decorative sentences or empty states. The reserved status row keeps controls stationary; long text truncates with the full status retained in the live region and title. ## Limits The supplied logs do not include historical snapshot sizes or the home send trace. No direct production reproduction or native mobile run was possible. Pending client retries require the client to remain mounted/running; gateway receipts survive reconnect/restart. Other linked mutations are not automatically retried. Direct exceptionally large complete snapshot reads retain the driver's wire limit. Related: #386
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.
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_THREADSforwards a qualified thread ID through the pinned computer link to the home's owner-scopedWatchThread. 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_MIRRORseparately 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.linked-snapshotretains aggregate linked rows and applies presence separately; it does not deduplicate thread watches.Recovery
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.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, andbun run --filter @canopy/web buildpassed.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.ENOSPCon the shared temp filesystem (1,864 passed, 161 skipped). Repeating the full gate with a disk-backed privateTMPDIRpassed, including that test; no updater code was changed.Copy audit: uses existing Syncing/reconnect/unreachable states and the existing computer unavailable reason; no new frontend copy.
Related: #348
Related: #350
Related: #265