Skip to content

fix(computers): keep linked bots listed across home restarts - #509

Merged
nixuuu merged 1 commit into
devfrom
fix/linked-bots-resync
Nov 10, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/linked-bots-resync

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 10, 2026

Copy link
Copy Markdown
Member

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

Use the committed bot mirror while online list reads are cold or stale. Invalidate lists after mirror commits and consume linked list completion events in the web bot store so pushed feeds cannot leave remote bots missing.

Add two-gateway restart, version-change, live-watch and recovery coverage. The regression passed 30 sequential complete-file runs; related linked suites, typecheck, lint and formatting passed.

Fixes: #458

Related: #348
@nixuuu
nixuuu merged commit 21baef8 into dev Nov 10, 2026
9 checks passed
@nixuuu
nixuuu deleted the fix/linked-bots-resync branch November 10, 2026 15:55
nixuuu added a commit that referenced this pull request Nov 10, 2026
PR #503 allowed selecting individual repository files, which could
produce a partial checkout. Copy the whole repository state instead: Git
metadata, tracked files and nonignored untracked work are mandatory,
enforced by the source worker before any reads. Web and mobile show a
fixed repository summary and offer only ignored local files.

Ignored dependency, build and cache directories are pruned before
walking their contents and listed in a disclosure. Secret-like and local
configuration files retain explicit confirmation; large ignored groups
start collapsed. Old presets apply only to available ignored files and
are narrowed on their next save. Limits, chunk transfer, integrity
checks and cleanup remain in place.

The copy dialog has its own persistent footer alongside the shared
palette header action, including Enter handling and disabled/busy
states. Its full-width primary action stays visible while the preview
scrolls, explains disabled states and shows progress with a cancel
action. Scroll containers, including the file tree, use `scroll-stable`.
Both clients use a three-line repository summary, a truncated monospace
branch with access to its full name, animated kit disclosures, file lock
icons with contextual help and muted folder counts. The root keeps its
indeterminate checkbox without repeating a secrets warning.

Contracts are additive, generated code is included, and legacy
full-selection fields are deprecated. The new `workspace_copy_scope_v2`
capability requires updated workers and linked gateways. Polish
documentation is updated.

Fixes: #503

## Validation

Rebased onto `dev` at `26f61cce`, retaining the shared palette actions
from #511, scrollbar gutters from #512 and linked-bot fixes from #509.
Re-ran generation, typecheck, lint, format check, both focused
workspace-copy test files separately (14 tests, 98 assertions, no
temporary files left), and the web build; all passed. Browser
screenshots and mobile fingerprint evidence below were collected before
this rebase.

- Passed: `bun install`, `bun run gen:check`, `bun run typecheck`, `bun
run lint`, `bun run format:check`, and the web build. The final layout
adjustment also passed web typecheck and build.
- Focused gRPC tests ran one file at a time through `check:tmp`:
workspace-copy (12 tests, 90 assertions) and workspace-copy-durability
(2 tests, 8 assertions). Coverage includes mandatory tracked and
nonignored untracked files, direct worker rejection of partial
selections, dependency requests, ignored choices, old presets, linked
transfers, integrity and recovery. Both left no temporary files. The
full repository test suite was not run.
- Real browser: light/dark at 1280, 760 and 390 px, with long names,
`.env` files, local configuration, over 100,000 dependency entries,
`target`, and a 205-file unusual ignored data directory. Replaced all
six screenshots after checking the visible, clickable footer before and
after scrolling, animated disclosure, branch/file tooltips, fixed row
heights and disabled confirmation with a reason. A real 64 MB browser
transfer exercised the busy state and completed successfully; the copied
tracked file matched byte-for-byte and Git retained the tracked
modification and nonignored untracked file. Screenshot artifacts stay
outside the repository; the before image is the maintainer-supplied
screenshot.
- Mobile: changed-file ESLint, Expo Doctor (20/20) and iOS/Android JS
exports passed. Production fingerprints generated before/after with
`[email protected]` are unchanged: iOS
`6ddec9ef559ee0095ac33e94ff9418a942053b17`, Android
`5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. No native device runtime
validation.

## Copy audit

1. Selectable “Repository files” / “Git metadata” → compact fixed
summary: “Repository · …”, a separate monospace branch and a line of
unpushed commits/changes. Describes what is copied without implying a
choice or producing a paragraph on phones.
2. “Ignored build files start excluded” → “Skipped: node_modules, target
and … (dependencies and build output)” with disclosure. Explains that
these directories are omitted; a separate hint asks users to check
unusually large ignored groups.
3. “Secrets?” / repeated row warnings → a small lock icon with “May
contain secrets: …” contextual help for files and “N may contain
secrets” for folders. The synthetic root omits the repeated warning.
Desktop tooltips and native help preserve the meaning without adding a
second line; explicit confirmation and verb-led actions remain.
4. “Your selection is remembered” → “Ignored file choices are remembered
for this project”. Accurately scopes the preset. Empty state: “No
ignored local files to choose”. Repository errors state the problem and
recovery action.
5. Added “Confirm the files above to continue.” to explain a disabled
action; loading/copying actions show busy states. Checked sentence case,
glossary, punctuation, one idea per sentence, empty/error states,
confirmation wording and absence of decorative humour. Checked short,
typical and long names at desktop, narrow and phone widths in light/dark
themes; warnings have accessible text and contextual help.
nixuuu added a commit that referenced this pull request Nov 10, 2026
The native cursor-handoff test can overlap the five-second durable
revision probe while its turn runs. Probe deadlines align to wall-clock
intervals, so this can happen even during a short test. The gateway
supervisor correctly opens a new `WatchThread` when the revision
advances, but the test counted that new RPC's initial snapshot against
the original subscription's native-event assertion. CI attempt 1 shows
`reason: "revision"` immediately before the failure:
https://github.com/itsoltech/canopy/actions/runs/42855632346/attempts/1.

Observe a single home `WatchThread` over the real gateway link, wait for
its initial delta against the committed mirror cursor, and then require
both a completed turn and an advanced `watch_cursor`. Liveness and
coalescing stay enabled. Keep the native-event assertion and the
prohibition on any further snapshot or delta, including across that
revision heartbeat. The existing mirror-first/UI-checkpoint tests and
the separate liveness suite retain coverage of routed reads and
automatic recovery. Document this distinction in
`docs/linked-computers.md`.

This is a test race with intentional recovery, with no production or
protocol change. PR #484 fixed the separate ended-stream readiness race
in this file. PR #509's bot-list cache invalidations do not enter this
thread revision path; the shared probe in #410 compares durable
revisions against snapshot checkpoints even when native events arrived
successfully.

## Verification

- Unchanged baseline: **30/30 sequential full-file runs passed**, 360
tests, zero failures or skips, with private temp cleanup passing every
time. The natural flake did not reproduce locally.
- Finished change: **30/30 sequential full-file runs passed**, another
360 tests, zero failures or skips, with private temp cleanup passing
every time. Every native-handoff test waited for the normal revision
heartbeat; no sleeps or timing overrides remain.
- Controlled reproduction with a temporary 1 ms home revision probe: the
original test failed at the reported no-extra-snapshot/delta assertion
after `reason: "revision"`; the revised test passed with the same fast
probe and liveness/coalescing enabled. The timing override was removed.
- Mutation check: temporarily duplicating the home stream's initial
delta made the revised test fail at the retained no-extra-snapshot/delta
assertion while still receiving native events. The mutation was removed.
- `bun install`, `bun run format`, `bun run typecheck`, `bun run lint`,
`bun run format:check`, and `git diff --check` passed. Self-review
covered the test boundary, cursor acknowledgement, native-event
coverage, revision heartbeat, cancellation, and unchanged recovery
behavior. No UI copy changed.

All repeated file runs used `TMPDIR=/var/tmp bun run check:tmp
tests/integration/thread-mirror-deltas.test.ts`, one test process at a
time. Broader unfiltered tests, generation checks, and the web build
were not run under the workspace's focused verification limits. Based on
latest `dev` at task start, `7317c3bc6`.

Related: #484
Related: #410
Related: #509
nixuuu added a commit that referenced this pull request Nov 12, 2026
The linked-bot restart test can fail after the home reconnects even
though the mirror has reconciled correctly. `ListBots({ includeArchived:
true })` and `ListBots({})` have separate request cache keys, and each
refreshes in the background. An updated inclusive snapshot does not
establish that the active-only snapshot has refreshed. The immediate
active-list assertion can therefore see a deleted bot and a newly
archived bot from its previous snapshot.

Wait for the active-only request to return exactly the expected
unarchived bot, with a bounded 15-second deadline. Keep the deletion,
preview, mirror and client-error assertions. Production caching and
background refresh behavior are unchanged.

## Validation

Extracted from the change that passed CI in #546 and removed from that
branch. This PR targets the latest `dev` directly and contains only the
10-line test diff; it can merge independently. Fresh CI runs on this
independent branch. No local tests, typecheck, builds or browser were
run while the maintainer's performance measurement continues.

History: commit `21baef8c8` (#509) introduced both the linked-bot cache
fallback and this test's immediate filtered-list assertion. This is a
test synchronization correction, so it uses a context reference rather
than a release-hold footer.

Copy audit: not applicable; no user-facing text changes.

Related: #509
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