Skip to content

feat(desktop): use the local frontend for remote gateways - #68

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

nixuuu merged 1 commit into
devfrom
feat/desktop-remote-frontend-1

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 4, 2026

Copy link
Copy Markdown
Member

Stage 1 of the desktop remote frontend stack: the desktop serves its own bundled frontend and BFF in remote mode too, so the app's settings, updates and startup screen keep working when the remote gateway or the internet is down.

  • Desktop client credential: the desktop pairs with the remote gateway over the Network access listener (pinned TLS, route fallback) and gets an owner-scoped, revocable credential, encrypted locally (client-vault.ts, Electron safeStorage). Listed, audited and revocable in the gateway's devices. The server's UI service token never leaves the gateway.
  • The local BFF calls the remote gateway's UI API with that credential.
  • Existing remote-mode desktops migrate automatically through their enrolled worker's authenticated link (one-time, recorded); guided step only when that is impossible.
  • Protocol handshake: a warning/update state only on a real protocol or capability difference; a different build with the same protocol shows nothing.
  • Migration 0057_desktop_clients.

Design (Polish): docs/desktop-remote-frontend.md. Stage 2: remote "Update Canopy app" from the Workers view. Stage 3 (optional): offline read cache.

Checks: install, gen:check, typecheck, lint, format:check, check:tmp (872 pass, 147 skip, 0 fail), web, desktop shell and runtime builds. Browser checked light/dark at desktop and phone widths. Needs real macOS verification: Keychain, signed package, Local Network, native IPC, reconnect.

Draft until the whole stack is done.

@nixuuu
nixuuu force-pushed the feat/desktop-remote-frontend-1 branch from d401a3e to c93f1ba Compare November 4, 2026 16:50
@nixuuu
nixuuu marked this pull request as ready for review November 4, 2026 16:57
@nixuuu
nixuuu merged commit 7db7faf into dev Nov 4, 2026
3 checks passed
@nixuuu
nixuuu deleted the feat/desktop-remote-frontend-1 branch November 4, 2026 16:58
nixuuu added a commit that referenced this pull request Nov 4, 2026
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 added a commit that referenced this pull request Nov 4, 2026
Releases no longer need a human: a scheduled workflow promotes soaked
changes.

**Schedule:** every 3 h (`0 */3 * * *`), first next → main, then dev →
next, inside the `release-branch-mutations` concurrency group. Promotion
stays fast-forward only: a continuous prefix of the source branch up to
a cutoff commit C, never backwards, never forced; Release is dispatched
on the target with `expected_sha`.

**Cutoff**
1. Soak: dev → next takes the newest commit on dev for ≥ 24 h; next →
main takes the newest published beta that has been complete for ≥ 72 h
(an older beta stays a candidate while a newer one soaks).
2. Follow-up fixes: a `fix`/`perf`/revert that landed after C and
corrects something in (target, C] holds that change and everything after
it, iterating to a fixpoint. Fixes already soaked are inside the prefix
and ship with their feature.
- Explicit links win: `Fixes: #68`, `Refs: #68` / `Refs: <sha>`,
`follow-up to #68`, the PR template line, standard reverts, GitHub
closing keywords.
- Otherwise line-level attribution (SZZ): `git diff -w -U0 F^ F` gives
the pre-image lines the fix changes, `git blame -w -M -C` (honouring
`.git-blame-ignore-revs`) gives the commits that introduced them; pure
additions use unambiguous adjacent lines. Shared/generated paths are
excluded; 7-day upper bound. Owners already released don't hold
anything.
3. Readiness: a successful Release run for exactly C (prefer a published
nightly), no open `release-blocker`, docs-only / no-version ranges are a
no-op.

**Controls:** repo variable `AUTO_PROMOTION=off` pauses it; label
`promotion-hold` on a merged PR holds it and everything after;
`release-blocker` blocks both paths; manual **Promote** uses the same
selector with a default dry-run and explicit overrides (never skipping
CI, beta, blockers, linked fixes or fast-forward). Job summaries show
C0, C, version, included and held commits with reasons; a history issue
records each promotion; a starvation issue opens when a change has been
held for more than 7 days.

**Manual smoke gates:** `live_smoke`/`update_smoke` stay as dispatch
inputs but no longer gate promotion. They are replaced by green Release
CI (incl. updater tests and the 4-platform binary smoke) plus soak;
stable also requires that verification on the beta. Not covered anymore
by a human: live provider smoke and a full self-update/rollback on a
real installation.

**Convention:** AGENTS.md, docs/contributing.md, docs/release.md and a
new PR template ask for an explicit link in follow-up fixes; commitlint
accepts the footers.

Dry-run on the real history (read-only): nothing to promote yet. #57 is
attributed to #18 by changed lines; with today's state the first beta
would be `0.2.0-beta.1` at #76 in the 2026-11-05 18:00 UTC cycle.

Checks: install, typecheck, lint, format:check, actionlint/shellcheck,
check:tmp (973 pass, 153 skip, 0 fail); promotion tests run against
local git fixtures and a mocked GitHub API.
nixuuu added a commit that referenced this pull request Nov 4, 2026
The macOS desktop job has failed on every nightly since ~18:47 UTC, so
no macOS update was published for nightly.33+ (Linux desktop built
fine). Three causes, all fixed:

1. **Pairing assertion (run 41903293146):**
`runtime.integration.test.ts:178` expected `worker.json` to be
byte-identical after re-configuring, but initial pairing legitimately
races the worker's secure-route migration (endpoint, certificate pin,
fallback fields). The assertion (from #68) now checks enrollment
identity and data preservation; a separate unchanged-save check verifies
identical process IDs, config bytes and modification times.
2. **Stapling (runs 41905804716, 41890651151):** notarization succeeded
but `stapler` failed with error 68 (`NSURLErrorDomain -1005`, Apple
ticket lookup). The pinned `@electron/notarize` never invoked its retry
callback; a patch (`patches/@electron%[email protected]`) makes
staple + validate retry up to five times with 15/30/60/60 s backoff.
Notarization stays mandatory.
3. **Partial publication:** when only one desktop target succeeded,
`publish-desktop` rejected `download-artifact@v5`'s flat single-artifact
layout, so even the Linux feeds weren't published. The merger now
accepts it; multi-target merging and checksums unchanged.

Checks: install, gen:check, typecheck, lint, format:check, check:tmp
(1,051 pass, 147 skip, 0 fail), web/desktop and shell builds; packaged
Linux CI-path integration tests (11 pass). macOS signing, Apple ticket
delivery, stapling and Gatekeeper are confirmed by the next nightly run.

Fixes: #2
Fixes: #14
Fixes: #68
nixuuu added a commit that referenced this pull request Nov 5, 2026
In the desktop app, "Sign in with Notion" ended on "Untrusted desktop
origin". The provider sends the system browser back to the app's
callback. That top-level navigation comes from notion.com, so
`Sec-Fetch-Site: cross-site`, and the desktop origin check in
`hooks.server.ts` blocked it. The system browser also has no Electron
cookie.

**The exception covers only `GET /api/connectors/oauth/callback`:**
- the request must be a top-level navigation (`Sec-Fetch-Mode:
navigate`, `Sec-Fetch-Dest: document`, when the browser sends them);
- the Host must still match `CANOPY_WEB_ORIGIN`, so DNS-rebinding
protection stays.

POST, fetch, other paths and a foreign Host are still blocked (403).
GitHub and MCP OAuth share this callback. Pairing needs no exception.

**The callback stays safe:**
- the gateway already makes `state` atomic and single-use, with a
10-minute TTL, bound to the owner and the account;
- the BFF keeps the flow's binding itself instead of relying on the
Electron cookie;
- tokens stay in the gateway, and the result page shows fixed text
without echoing what the provider sent.

**After sign-in,** a small result page says what happened and offers
"Return to Canopy" (`canopy://connectors`, which brings the desktop
window forward and refreshes the connectors). Errors and replayed states
get clear text.

**Tests:**
- BFF tests for the allow and block decisions;
- a gateway integration test for single-use, owner-bound state with
replay rejected.

Checked success, provider error and replay in light and dark, at 1280,
390 and 320 px.

Copy audit (`docs/copy.md` §8): the result page states one outcome, then
what to do. Text is sentence case, buttons start with verbs, and
provider errors are not echoed.

Fixes: #68
nixuuu added a commit that referenced this pull request Nov 19, 2026
## Changes

- Keep collapsed thread details above the transcript and keep submenu
actions reachable on narrow screens. Preserve typed MCP form responses
and hide the floating Cite button while the selection menu is open.
- Show the full desktop invitation or the phone code when clipboard
access fails. Explain the worker-wide automation grant before enabling
Preview and show the reported cause when the computer is unavailable.
- Show shared offline status once across pull request resources. The
combined retry reloads the affected resources. Independent review
failures retain their own retry.
- Simplify empty states, errors and progress across settings, workspace
and bot setup. Keep exact values and recovery actions available in their
relevant views.

## Verification

The UI audit covered all 927 Svelte files in the audit revision,
including 41 route, layout and error files. Verification included
Chromium at phone and desktop widths, both themes, and selected native
Electron windows on Linux. Some conditional states used synthetic
responses or isolated components. Components without their own DOM were
verified through their visible effects. Native macOS and Windows
sessions were outside this pass.

Web, desktop and domain typechecks, formatting, lint of edited files,
and the 19 desktop update tests passed locally during the audit. GitHub
Actions runs the full gate on the rebased revision.

## Copy audit

Reviewed the ten items in docs/copy.md §8. Replaced the thread-scoped
Preview permission description with the actual worker scope. A failed
clipboard copy now exposes the value the receiving device accepts. Empty
libraries show a single add action, connection failures retain their
recovery action, and progress announcements remain accessible. Checked
short and long labels at phone and desktop widths. Two repeated labels
in the versioned visual renderer are deferred to its next version to
preserve existing documents.

Fixes: #68
Fixes: #846
nixuuu added a commit that referenced this pull request Nov 20, 2026
…1050)

## Change

This update preserves existing access when gateways and workers upgrade
and tightens how Canopy issues new credentials, approves connector
actions and serves private files.

- New desktop clients pair with an owner invitation. Previously paired
phones, desktops and workers keep their credentials and certificate
pins. Revoking a device closes its active streams.
- MCP approvals bind to the saved account, tool and arguments. Slack
deliveries and linked-computer reports check which conversation supplied
the data. An older approval with incomplete arguments requires a new
decision.
- Worker file changes and previews are scoped to the thread. Migrations
0180–0184 preserve each owner's existing valid image previews, including
historical images with only a saved path and hash. They also migrate
connector approvals and confirmed computer redirects.
- Compose isolates the worker network and runs database migrations
separately from the gateway's restricted PostgreSQL login. Web, Android
and SSH worker enrollment accept the one-use token through a prompt or
stdin.
- Release jobs check the source revision before using signing or
publication credentials. The updater checks the official manifest's
repository and tag. Independent manifest signatures still require a
publisher key.

## Rollout

Update the Compose file together with the gateway and worker images.
Existing remote workers using plain HTTP need HTTPS or an explicitly
trusted bootstrap origin. Desktop installations that only ever held a
worker credential need an owner invitation for UI access.

Configure the protected GitHub environments `release-automation`,
`release-signing` and `release-publication` before using the updated
release workflows. Move the existing deployment and signing credentials
as documented. At PR creation the repository listed only `github-pages`.
[Release
setup](https://github.com/itsoltech/canopy/blob/189be6983213442471579b2c2aceb0ded8a40fa0/docs/release.md)

## Verification

- At `189be698`, 238 targeted tests passed across 46 files on top of the
merged #1049. Six scoped typechecks and lint on the overlapping changes
passed.
- Upgraded the final Linux packages from schema 178 directly and from
179 after a PostgreSQL dump and restore. The original phone and desktop
sessions, pin and unused invitation remained usable. Revoked access
stayed revoked. Separate upgrade checks verified the worker credential,
saved OAuth login, connector grants and both peers of a paired gateway
link. With the worker offline, the phone retrieved the original GIF and
path-only PNG with identical bytes and MIME types.
- Compared production Chromium builds using 2,160 items and 19
subagents, with 48 measured openings per revision across two widths and
both themes. Median time to the visible last answer was 476.3 → 480.2 ms
at 1280 px and 415.8 → 415.4 ms at 390 px. Both revisions requested zero
older pages on open, one on scroll and eight for the selected multi-page
turn, keeping the same SSE connection. The 10,000-row header update
measured 4.49 → 4.53 µs. Inactive expanded content retained 7.5 MiB on
both revisions.
- Native Android kept the existing pairing after a cold start. A send
reached the worker once and the app resumed from its saved checkpoint
after returning from the background. Twelve pairs of unchanged controls
and heartbeats produced zero React commits on both revisions.
- Copy audit (§8) covered the enrollment instructions and image
fallback. The wizard now labels the separate token and tells the user
when to paste it. Inspected the web wizard with short, typical and
200-character names at desktop and phone widths in both themes and
exercised the same flow in the native Android app.

For the CI fixes on `0878d0e7`, 34 targeted tests passed across worker
Git reads, process limits, the thread file panel and subagent
permissions. A Git trace of 100 simultaneous status requests across 30
worktrees showed one filter lookup and one status process per worktree,
with up to four scans in flight. A subsequent cache hit spawned zero
processes. Forcing a refresh read the current filter configuration and
ran status again. An idle parent can still pass its default permissions
to a child or narrow them. An explicitly unknown turn ID is rejected.

Local coverage used Linux, Chromium and an Android emulator. Signed
packages, native Windows/macOS and iOS remain outside these results.
GitHub CI runs the full repository checks.

Fixes: #68

Related: #1049
nixuuu added a commit that referenced this pull request Nov 23, 2026
## Change

- Open Settings while the first gateway sync is pending. The outage
screen and connection popover can open the local Desktop connection
form.
- Probe the saved HTTPS address alongside the gateway's advertised
routes. An address change for the same paired gateway keeps its
certificate pin, device credential, and worker profile across a restart.
- Verify the entered address against the invitation pin when pairing. A
different pin selects a separate worker profile.

## Verification

- Desktop and web typechecks, focused lint and formatting, and `git diff
--check` passed locally.
- Five focused Desktop tests passed under `check:tmp`. They cover
configuration validation, recovery after changing the address and
restarting, and rejecting a pairing route with the wrong pin.
- Chromium at 1280 px and 390 px exercised an unreachable gateway using
the local BFF and a simulated Desktop bridge. The checks covered opening
Settings, closing a direct Settings route with Escape, and opening the
Desktop connection form from the outage UI.
- Native macOS Keychain and the affected MacBook connection remain
unverified. GitHub CI runs the repository-wide gate.

## Copy audit

- The outage screen and popover add **Open desktop settings**, matching
the startup recovery action. The label identifies the local destination
without relying on the status dot.
- **The secure Network access address. Use your existing address when
reconnecting.** → **Use an HTTPS address from Network access on your
gateway.** The field now explains where to get an alternate address.
- Pairing and address errors give a recovery action. Chromium checks
verified that the recovery button fits in the narrow layout.

Fixes: #68
nixuuu added a commit that referenced this pull request Nov 24, 2026
## Summary

- Record a desktop app's first contact when it first uses the issued
credential. Fresh and replacement invitations both create an entry that
initially shows “Not connected yet”.
- Publish the first contact to Devices and keep “Last seen” as a
historical timestamp. Remote Desktop pairing grants access to the chosen
gateway. Linked computers come from a separate link between local
desktop gateways.
- Thanks to @marcinniewinski for reporting the re-pairing scenario.

The previous Devices state was reproduced locally before the fix. The
report also shows a registered Windows worker as disconnected. A paired
Desktop can read the live gateway while a registered worker is offline.
The Windows worker's reason for being offline remains unconfirmed.

## Verification

Local Linux verification of 02044f9 passed 13 focused integration
checks. These covered new and replacement desktop credentials,
revocation, restart, pinned route recovery, gateway and client version
negotiation, phone pairing, and linking and re-linking two gateways.
Targeted lint, formatting and diff checks passed.

In Chromium on the same revision, both desktop invitations showed
acceptance followed by “Not connected yet” and then “Last seen” as the
new credential was used. The authenticated Desktop read a live overview
that included a registered offline worker. The message fit at the
standard dialog width and with the dialog constrained to 350 px. GitHub
CI runs the full gate.

## Copy audit

“Device paired.” becomes “Desktop app invitation accepted” with a
sentence directing users to Device access. The confirmation names the
event the gateway observed. The visible text gives the next step without
relying on the status icon or color.

Fixes: #68
nixuuu added a commit that referenced this pull request Nov 24, 2026
nixuuu added a commit that referenced this pull request Nov 24, 2026
Recover the bundled worker using a verified alternate route of its paired gateway while keeping the saved profile intact.

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