Skip to content

feat(desktop): update desktop apps remotely from the workers view - #70

Merged
nixuuu merged 1 commit into
feat/desktop-remote-frontend-1from
feat/desktop-remote-frontend-2
Nov 4, 2026
Merged

nixuuu merged 1 commit into
feat/desktop-remote-frontend-1from
feat/desktop-remote-frontend-2

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 4, 2026

Copy link
Copy Markdown
Member

Stage 2 of the desktop remote frontend stack (on top of #68): update the whole Canopy desktop app remotely from the gateway's Workers view.

  • Workers whose install kind is desktop offer "Update Canopy app" (Electron + bundled runtime + worker), not just a worker binary update.
  • The request travels over a desktop control stream on the same pinned TLS, authenticated with the stage 1 desktop client credential; Electron main runs its own updater (signed builds only, own channel, no downgrades, macOS codesign/Developer ID check kept). The gateway never sends binaries.
  • Waits for the desktop worker's running turns; the owner can force it; the desktop shows a notification, restarts and reconnects.
  • Live state in the Workers view: available version, download %, waiting for idle, restarting, failed with reason; disabled with a reason when offline, not paired or too old.
  • Owner-scoped and audited. Migration 0058_desktop_updates.

Checks: install, gen:check, typecheck, lint, format:check, check:tmp (879 pass, 147 skip, 0 fail), web, desktop shell and runtime builds. Browser checked light/dark at desktop and phone widths. Needs real macOS verification: signed upgrade, refusal of unsigned/older builds, notification, full idle/force → Squirrel → restart/reconnect (integration tests fake the updater at its boundary).

Draft until the whole stack is done.

@nixuuu
nixuuu added this pull request to stack #71 November 4, 2026 16:00
@nixuuu
nixuuu force-pushed the feat/desktop-remote-frontend-2 branch from dfaab82 to 89e92c9 Compare November 4, 2026 16:50
@nixuuu
nixuuu marked this pull request as ready for review November 4, 2026 16:58
@nixuuu
nixuuu merged commit 16648d3 into dev Nov 4, 2026
3 checks passed
@nixuuu
nixuuu deleted the feat/desktop-remote-frontend-2 branch November 4, 2026 16:58
nixuuu added a commit that referenced this pull request Nov 10, 2026
Share check promises, bound updater work, recover stale attempts on wake, and preserve staged updates. Report persisted overlap through the live updater state.

Related: #70

Related: #373, #459
nixuuu added a commit that referenced this pull request Nov 10, 2026
A remote app-update request could reach a desktop that was already
checking or downloading automatically. `checkRemote()` rejected that
overlap, and `RemoteAppUpdate` persisted it as a failed installation.
Preparation, metadata checks and downloads also had no controller
deadlines, so an unresolved request after sleep could retain the running
lock indefinitely. The overlap guard originates in #70; #373's
check-only command calls `check()`, so it did not introduce that guard.
Without logs from the affected Mac, whether its operation was still
progressing or hung cannot be distinguished.

Manual and remote checks now share the current operation and its actual
checking/downloading progress. Channel changes queue behind it and
retain downgrade confirmation. Preparation and metadata checks have
60-second deadlines; downloads have a 30-minute total limit and a
90-second stall limit based on increasing transferred bytes.
Cancellation propagates to release-feed requests and downloads. Recovery
replaces the updater and isolates its download directory, ignoring
retired events and late responses. Previously staged updates retain
their installable updater. On macOS, module-level commit tokens track
the shared native feed: ordinary installs call Squirrel synchronously
without replaying `task.done`. Only a displaced feed is replayed,
serialized behind any pending finalizer. Local ZIP replay has no
controller deadline and propagates actual staging failures through
installation error handling; a failed replay remains eligible for retry.

Suspend pauses the automatic timer. Resume/unlock recovery is debounced
for 5 seconds, restarts stale work through the original shared promise,
and restores the schedule. If a timeout finishes before the wake
handler, automatic checks retry once; Never suppresses that automatic
retry. A persisted busy-only failure reports the live updater phase,
while real installation failures remain Failed. Gateway mapping and
protobuf contracts are unchanged, including the frozen update service.
Updated the Polish operational docs.

Validation:
- `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run
lint`, `bun run format:check`, and `bun run --filter @canopy/web build`
passed for the initial change. After the native-feed revision, focused
desktop tests, full typecheck, lint and format:check passed again, with
a final focused desktop typecheck after the replay-retry refinement.
- 29 focused desktop tests passed: 12 controller/remote-coordinator
regressions, 13 existing updater/feed/staging tests, and 4 native-feed
tests using fakes. Coverage includes joining during checks/downloads,
hung prepare/metadata, stale resume, stalled and total download
deadlines, repeated progress, error cleanup, queued channels, retained
staged updates, Never, and persisted busy versus genuine failures. The
native-feed tests verify synchronous installation without re-staging,
replay after another commit, serialization behind an unfinished
replacement, and real failure propagation followed by a safe retry.
- No web UI tests, E2E, or full local `check:tmp` run. CI remains the
full-suite gate. Signed macOS sleep/resume and installation were not
exercised on this Linux machine; native-feed ownership and replay are
covered with fakes, while actual Squirrel staging remains unverified on
a real Mac. The web build completed with chunk-size warnings.

Copy audit (`docs/copy.md` §8):
- Busy-only `Wait for the current app update operation to finish, then
retry.` → existing live checking/downloading/ready statuses. Overlap
requires no user action and is no longer presented as a failure.
- Unbounded wait → `Update timed out. Check the connection, then retry.`
Two short sentences identify the event and next action; no protocol
names or internal jargon.
- Existing action names, genuine failure messages, confirmations, and
status layouts remain in use. No new terms, repeated facts, humor, or
color-only meaning. No UI templates changed;
name-length/responsive/browser review was not run for this
controller-only change.

Related: #70

Related: #373, #459
nixuuu added a commit that referenced this pull request Nov 12, 2026
Reconcile desktop journals, persisted gateway history and client snapshots with current versions or completed feed checks. Add durable owner-scoped dismissal and restart integration coverage.

Fixes: #70
Fixes: #210
Related: #536
nixuuu added a commit that referenced this pull request Nov 12, 2026
Reconcile desktop journals, persisted gateway history and client snapshots with current versions or completed feed checks. Add durable owner-scoped dismissal and restart integration coverage.

Fixes: #70
Fixes: #210
Related: #536
nixuuu added a commit that referenced this pull request Nov 12, 2026
Reconcile desktop journals, persisted gateway history and client snapshots with current versions or completed feed checks. Add durable owner-scoped dismissal and restart integration coverage.

Fixes: #70
Fixes: #210
Related: #536
nixuuu added a commit that referenced this pull request Nov 12, 2026
Reconcile desktop journals, persisted gateway history and client snapshots with current versions or completed feed checks. Add durable owner-scoped dismissal and restart integration coverage.

Fixes: #70
Fixes: #210
Related: #536
nixuuu added a commit that referenced this pull request Nov 12, 2026
Reconcile desktop journals, persisted gateway history and client snapshots with current versions or completed feed checks. Add durable owner-scoped dismissal and restart integration coverage.

Fixes: #70
Fixes: #210
Related: #536
nixuuu added a commit that referenced this pull request Nov 12, 2026
An interrupted remote app update can leave a failed journal and a
stopped Update all run visible after the target is already current.
Reconcile those records with the target's version or a completed Up to
date check, so obsolete failures stop driving the Updates header and
sidebar badge.

Restart recovery accepts the requested version or any newer SemVer
version, including an interrupted journal saved before `restarting`.
Returning on the old version remains a failure. Relevant failures offer
Request again and Dismiss on web and mobile. Dismissals require the
current request or run ID, remain owner-scoped, and survive gateway/app
restarts. Dismissing a stopped run also acknowledges its matching app
failure; it never acknowledges a newer request.

Reconciliation persists the result without starting queued later steps.
Linked-computer action responses replace cached snapshots, and clients
reject reads started before a newer action. Contracts are additive;
frozen `canopy.update.v1` is unchanged. Mobile edits are TypeScript
only, with no native configuration changes.

Caller audit: web popover, linked-computer settings, mobile rows and
stopped-run dismissal preserve the request IDs returned in snapshots.
Electron has no separate renderer dismissal IPC; control commands carry
the target-local ID unchanged to its journal. Linked-app dismissal now
also accepts a plain UUID scoped to the explicitly selected direct peer
of this owner. Existing qualified IDs retain their suffix, so another
computer's ID is rejected; the target still checks its exact current
failed request. Integration coverage exercises both forms, mismatched
requests, foreign computer suffixes, cache replacement and the target
journal acknowledgement.

### Validation

- Added gateway/desktop integration coverage for equal/newer version
recovery, old-version failure, completed Up to date checks, retry
success, durable owner-scoped dismissal, linked snapshot replacement,
and gateway replacement without launching later steps. Updated the
existing orchestration fixture to report the installed version on
success. No web UI tests added.
- Rebased onto the requested `origin/dev` (`f7ad51cc`). `bun install`
and `bun run gen:check` passed with a clean working tree. Changed-file
lint/formatting and whitespace review passed. Static self-review covered
persistence, request identity, owner boundaries, restart classification,
cache ordering, stopped-run safety, and copy.
- Focused local verification passed: `bun test
tests/integration/stale-app-updates.test.ts
tests/integration/desktop-updates.test.ts
tests/integration/update-center.test.ts` — **27 pass, 0 fail, 139
assertions**. Fixtures ran sequentially. The linked-computer suite stays
on CI because it needs two gateways. The maintainer explicitly requested
no local full `check:tmp`; full static/typecheck/test/build validation
runs in GitHub CI.
- Real-browser review passed at 1280×800 and 390×844 in light/dark, with
short, typical and long names. Reviewed the production sidebar/popover
using controlled snapshots: a relevant failure retains Request again and
Dismiss plus the other row; equal/newer target versions and a reconciled
stopped run remove the old failure, header and red badge. Clicking row
Dismiss through the real client request path preserved the qualified ID
and replaced the snapshot using a mocked acknowledgement. Backend
durability/ownership were verified separately by real gRPC integration
tests. The web shell intentionally had no live gateway; its connection
warning/502s were expected fixture-environment noise. No web UI test
suite was added. Browser tab and local web server were stopped after
review.
- EAS production-profile fingerprints match the `dev` baseline on both
platforms: iOS `6ddec9ef559ee0095ac33e94ff9418a942053b17`; Android
`5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. Mobile remains JS/TS-only;
no native runtime change.
- CI log follow-up kept rejected downgrades as failures, restored
refreshes after replacing a linked action snapshot, and corrected the
linked/request and persisted-settings test setup. Linked-app dismiss
accepts both ID forms while retaining foreign-target and stale-request
rejection.

### Copy audit — docs/copy.md §8

| Before → after | Reason |
| --- | --- |
| Failure with no acknowledgement → **Request again** and **Dismiss** |
Offer recovery and acknowledgement while keeping other update rows
visible. |
| Generic update icon label → **Request update again on {computer
name}** for a failed request | Give the retry icon a concrete accessible
action. |
| No resolved/dismissed result → **Resolved** and **Dismissed** in
mobile history | Explain terminal results without protocol terms. |
| No dismissal precondition → **Choose the current failed update to
dismiss.** / **Choose the current stopped updates to dismiss.** | State
the action when the selected request is obsolete. |
| No dismissal outcome → **The app update was dismissed. Request it
again to continue.** / **Pair this desktop app again to dismiss its
update.** | Explain the state and next action in plain English. |

- New text uses sentence case, plain glossary terms, imperative actions,
and the sentence-length limits. Action labels/statuses have no trailing
punctuation; sentences have periods.
- Error messages name the condition or the required action. Existing
restart confirmation is reused. No new empty state, external-data
warning, or humorous copy is introduced.
- Each action and outcome has one purpose. No new explanatory copy
repeats a badge or tooltip. Important information stays visible or in
existing expandable details.
- Meaning does not depend on red text or an icon alone: failures retain
text, retry icons have labels, and Dismiss has a visible label.
- Short/typical/long-name checks at desktop/phone widths and light/dark
visual review passed. Names truncate cleanly, error text wraps, recovery
actions remain available, both rows stay visible and there is no
horizontal overflow.

### Attribution

The exact-version restart classification was introduced by #70
(`16648d37b`), and #210 (`155406fc7`) introduced the linked-app
orchestration that retains the stopped result. Both predate #536; #536
is context rather than the introducing change.

Fixes: #70
Fixes: #210
Related: #536
nixuuu added a commit that referenced this pull request Nov 27, 2026
## What changed

Registered workers shows the WorkerLink connection and the registered
worker version. App updates uses the desktop control stream and the most
recent app report, matched by worker and device IDs. A new pairing could
authenticate the same worker but fail to attach its updater while an
older pairing still had device access, even after its stream ended.

Allow the new pairing to bind after it proves the same worker credential
and the previous control stream is gone. An active stream keeps its
binding. Rebinding starts with fresh update state and device access can
still be revoked per entry.

The regression covers two pairings for one registered worker, recovery
without revoking the old pairing, and fresh reports from current and
older desktops after switching back to an earlier pairing. A transaction
regression verifies that detecting a closed session before accepting the
binding leaves the previous request intact.

## Verification

- Linux worker, revision `b485d3056`. Formatting and lint passed for the
three edited TypeScript files. Commitlint and `git diff --check` passed.
- GitHub CI runs the pinned TLS and PostgreSQL regression in the
existing desktop updates integration suite, alongside the required
repository checks.

Thanks to @marcinniewinski for reporting the mismatch and confirming the
workaround.

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