Skip to content

fix(mobile): keep the reconnect status steady while retrying - #507

Merged
nixuuu merged 1 commit into
devfrom
fix/mobile-reconnect-jitter
Nov 10, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/mobile-reconnect-jitter

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 10, 2026

Copy link
Copy Markdown
Member

Repeated failures against an unreachable paired gateway made the mobile sheet alternate between “Reconnecting…” and “Gateway unavailable”. Route probes erased their previous results, the sheet changed height, and the sidebar banner could unmount an open sheet. Independent requests could also start another failed route race as soon as the preceding race finished.

Availability and retry activity now use one shared domain state machine across mobile and web/desktop. After 3 failures or 12 seconds without success, “Gateway unavailable” stays until a successful stream snapshot/resynchronization. Retry activity appears in a reserved line. Retries use 1/2/4/8/16/30-second backoff with 80–100% jitter; network/foreground/manual reconnect reset the delay without clearing unavailable.

  • Mobile route rows retain their last result while checking, use fixed heights and a bounded scroll area. All requests share the failed route race’s cooldown; no sent RPC is replayed.
  • The mobile sheet remains mounted through retries, manual reconnect and recovery. The sidebar banner overlays the list. Web/desktop has a matching status popover, manual reconnect and an overlay banner below the header.
  • Documented states, transitions, route cooldown and lifecycle resets in docs/mobile.md and docs/ui-api.md. No native, dependency or protocol changes.

Validation

  • Passed: bun install, bun run gen:check, bun run typecheck, root bun run lint, bun run format:check, and the production web build.
  • Focused domain/transport/route tests: 32 passed, 333 assertions, 0 failed. Coverage includes sticky unavailable, hanging opens, exponential backoff/cap/jitter, lifecycle/manual resets, late callbacks, linked-computer outages, diagnostics retention and independent-request cooldown.
  • Browser: stopped and restarted a disposable gateway; sampled title, open state, panel/button geometry and content positions every 200 ms. No unavailable-to-reconnecting bounce, sheet closure or content movement; automatic recovery succeeded. Checked light/dark and desktop/phone widths with short and long thread names. Measured retry intervals grew exponentially to the capped range; manual reconnect restarted immediately without clearing unavailable.
  • Both production fingerprints generated with [email protected] are unchanged: iOS 6ddec9ef559ee0095ac33e94ff9418a942053b17, Android 5f6eae3ab278f1cd543e9ed763f923a319b65ec9.

Limitations: native iOS/Android visual QA was unavailable. Full check:tmp was not run; this task’s verification scope permits focused tests. Additional Expo ESLint reports existing errors in unchanged files; changed mobile UI files have no ESLint errors (the keyed recovery memo has one dependency warning). Root oxlint and all requested checks above pass. Evidence is kept outside the repository.

Copy audit — docs/copy.md §8

  1. “No route in use” / “Checking routes…” → “Routes”; per-route replacement status → last result plus “Checking route” activity. These distinguish availability from an attempt without rewriting the heading. Added “Retrying in N s” / “Retrying…” in a reserved line; digits are localized, units spaced, sentence case retained.
  2. Glossary unchanged. “Reconnect now”, “Copy details” and “Open Tailscale” name actions. The web popover explains the last known state and automatic reconnect; technical failures remain in Details. Tailscale guidance stays in the description while the availability title remains stable.
  3. No new empty states, duplicated availability heading, optional-dependency warning or expressive sentence. Existing failure copy retains its automatic resolution/manual reconnect action.
  4. Short, typical and long thread titles checked at desktop and phone widths in both themes; route hosts keep middle truncation and results have a fixed row. Native text sizing/layout remains unverified as noted above.
  5. Availability and countdown have text labels; checking activity has an accessible label. Color is supplementary and spinners respect reduced motion.

Regression attribution

The merged diff for #361 explicitly introduced down && stale === subscriptionKey && !routes.pending, which returns the availability presentation to reconnecting whenever a new probe begins. This fixes that condition and the resulting presentation instability. #366’s Tailscale hint and fixed retry interval were checked as context; they did not introduce that condition.

Fixes: #361
Related: #366

Separate sticky availability from retry activity across mobile and web.
Preserve route results and sheet geometry, share failed-route cooldown,
and apply capped exponential backoff with lifecycle/manual resets.

Fixes: #361
Related: #366
@nixuuu
nixuuu merged commit afaae21 into dev Nov 10, 2026
9 checks passed
@nixuuu
nixuuu deleted the fix/mobile-reconnect-jitter branch November 10, 2026 14:53
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
nixuuu added a commit that referenced this pull request Nov 11, 2026
A phone paired to a desktop gateway can see its linked computers' update
actions, but cannot update its own paired computer. Remote web clients
have the same gap.

Expose the home desktop app as an update target and send confirmed owner
UI requests through the existing LocalAppControl → RemoteAppUpdate path.
Keep the installer, durable journal/receipts, idle barrier, Windows
silent install and planned-departure/reconnect handling. The UI shows
real updater progress and refusal reasons. Older gateways/desktops show
a one-time manual-update instruction.

Home app installation requires explicit restart confirmation, lists
known running turns and checks unsent-work blockers before dispatch.
Update all continues to exclude the home app. Standalone gateway and
worker updaters keep their existing actions. Phone credentials cannot
open or report on the desktop control channel. Changes are additive in
canopy.ui.v1; canopy.update.v1 is untouched.

Validation:
- Paired-app gRPC integration: 7 passing tests / 55 assertions,
including owner refusal, confirmation, old/disconnected/disabled
desktop, rate limits/admin failures, receipts, idle barrier, gateway
replacement and recovery using the same paired token.
- Existing linked-updates (10), desktop-updates (8), gateway-departures
(3) and updates-bundled (2) tests pass, one file at a time.
- bun install, gen:check, typecheck, lint, format:check and web build
pass.
- Full check:tmp: passed once, sequentially: 2367 pass, 165 skip, 0 fail
across 440 files (29325 assertions); “nothing left in the temp dir”.
- Manual web fixture review in light/dark at 390, 768 and 1440 px: home
action, progress, older-desktop instructions, running turns, Cancel
focus, long names and blockers. The blocker was also checked again after
opening confirmation.
- EAS CLI 27.4.1 production fingerprints match on both platforms: iOS
6ddec9ef559ee0095ac33e94ff9418a942053b17; Android
5f6eae3ab278f1cd543e9ed763f923a319b65ec9. Mobile changes are JS/TS only.
- Native mobile visual QA is unverified: local device platforms are
unavailable, and the remote device host still reported “Could not
communicate with device support” after its suggested refresh. No native
install or Windows GUI installer was exercised; those paths are reused
unchanged.

Copy audit (§8):
- Before: the home app row had no usable update action. After: named
computer + “Update Canopy on {name}”; the confirmation repeats “Update”
and explains restart, automatic reconnection and the idle barrier.
- Before: the own app needed an update from its computer without a clear
route. After: “Update this computer from its own window once to enable
remote updates.” The dependency and next action stay visible.
- “Send or discard your drafts and files before updating this computer.”
gives a concrete action. Existing failure details remain expandable. New
text uses the glossary, sentence case, present tense, typographic quotes
and correct plurals; no new jargon, empty states or decorative copy.
- Reviewed typical/short and long names on desktop and phone widths.
Actions have accessible text labels; statuses and blocker explanations
do not depend on color. Native layout remains the visual-verification
gap above.

Related: #373
Related: #471
Related: #479
Related: #507
nixuuu added a commit that referenced this pull request Nov 19, 2026
…1009)

## Mobile thread catch-up

Opening a saved conversation started the outage deadline before the
first history window arrived. Each partial batch briefly set the view to
syncing while the same deadline continued to run. After 12 seconds the
thread could report an unavailable gateway even as the replay advanced.

The initial thread watch now waits for its window. An incoming controls
frame or partial batch confirms transport activity. The view stays in
catch-up until a ready snapshot or batch arrives. A real drop, premature
end, or permission error still goes through normal watch recovery. The
sidebar continues to use its own overview stream. This change addresses
the misleading status during successful loads and does not establish a
cause for a separate HTTP 403.

## Verification

Tested locally on nix-pc at 449af29.
- The new Connect regression exercises initial controls, partial replay
across the outage deadline, an actual stream error, reconnection,
catch-up completion, a controls refresh, and a terminal permission
error.
- All 22 distinct cases passed across mobile-thread-sync-status,
connection-recovery, and thread-watch-failures. The checks covered
exponential backoff, permission failures, a premature end, and
checkpoint recovery. The temporary directory checks passed.
- A local run of the same Connect scenario held the partial replay open
for 13 real seconds, then dropped the stream. It completed successfully
in 14.0 seconds on the PR revision.
- Mobile TypeScript and oxlint on the changed files passed. Native
device verification is pending. Auto-merge is off.

## Copy audit

“Reconnecting…” becomes “Connecting…” on initial open and “Syncing…”
during catch-up. “Retrying…” is reserved for recovery. The accessible
label derives from the displayed status. Existing thread progress and
retry actions are reused. No new terms, errors, empty states or
variable-length names. The two fixed labels fit the reserved status
width in Chromium text-fit checks at 320, 390 and 1280 px in both
themes. This was a copy fit check, not a native device run.

Fixes: #507
nixuuu added a commit that referenced this pull request Nov 19, 2026
The mobile Threads and Bots lists use the measured header height to
position their first row. The update and connection strip used a
zero-height absolute overlay in the sidebar, so a persistent or wrapped
message could cover the first item and intercept taps.

Render the strip inside the measured header, as on the other mobile
screens. The list now reserves the visible message's actual height and
reclaims it when the message clears. This applies to both the phone list
and the tablet sidebar.

Local verification passed for the mobile TypeScript project, Expo lint
and oxlint on both edited components, and the diff whitespace check. CI
owns the repository-wide checks.

Fixes: #507
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