Restore the desktop connection manager's local server destination alongside saved remotes. - Add a Local Server card for desktop-shell switching with active state handling. - Switch remote profile selection into remote mode before activating the profile. - Cover desktop local/remote switching behavior with tests and localized labels. - Document the switch-server local option and add the published package changeset. Files changed: .changeset/fn-7478-local-server-switch-option.md | 7 +++ docs/native-shell.md | 3 +- .../components/NativeShellConnectionManager.css | 19 ++++++ .../components/NativeShellConnectionManager.tsx | 55 ++++++++++++++--- .../NativeShellConnectionManager.test.tsx | 71 ++++++++++++++++++++-- packages/i18n/locales/en/app.json | 5 +- packages/i18n/locales/es/app.json | 5 +- packages/i18n/locales/fr/app.json | 5 +- packages/i18n/locales/ko/app.json | 5 +- packages/i18n/locales/zh-CN/app.json | 5 +- packages/i18n/locales/zh-TW/app.json | 5 +- packages/i18n/src/resources.d.ts | 3 + 12 files changed, 168 insertions(+), 20 deletions(-) Fusion-Task-Id: FN-7478 Fusion-Task-Lineage: 86a94faa-4799-46cc-aaed-b7901ee9698c Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
4.0 KiB
Native Shell Connection Guide
This is the canonical guide for how Fusion native shells (mobile and desktop) connect to remote Fusion dashboards, persist saved connections, and hand off shell state to the dashboard.
Overview
Native shells expose a shared window.fusionShell bridge that the dashboard reads through ShellContext.
- Mobile shell always runs in remote mode and requires an active connection profile.
- Desktop shell supports both Local Fusion and Remote Server modes.
- Web/PWA does not use shell onboarding.
First-run onboarding flow
The dashboard gates first-run shell onboarding in requiresNativeShellOnboarding(...) (packages/dashboard/app/App.tsx):
host === "mobile-shell": onboarding is required untilactiveProfileIdis set.host === "desktop-shell":desktopMode === "local": onboarding is not required.desktopMode === "remote"(or unset): onboarding is required untilactiveProfileIdis set.
NativeShellOnboardingModal then provides:
- Desktop mode choice (desktop only):
- Local Fusion → calls
setDesktopMode("local"). - Remote Server → stays in remote flow.
- Local Fusion → calls
- Remote connection entry (mobile + desktop remote mode):
- Scan QR (
startQrScan()) - Manual fields: profile name, server URL, optional auth token
- Scan QR (
- Continue:
- Saves profile via
saveProfile(...) - Sets desktop mode to remote when relevant
- Activates profile via
setActiveProfile(...) - Redirects to selected remote dashboard URL (adds
rt=<token>query when token is present)
- Saves profile via
QR scan and manual fallback
QR scan is optional convenience. Manual entry is always supported.
QR payload parsing accepts either:
- JSON payload with
serverUrland optionalauthToken - URL payload, reading token from
authTokenorrt
If scanning fails or is unavailable, users can continue with manual URL + token entry.
Saved connection profiles
Profiles are first-class saved objects shared by onboarding and Connection Manager:
nameserverUrl- optional
authToken - timestamps (
createdAt,updatedAt,lastUsedAt)
Connection Manager supports:
- Desktop Switch server shows Local Server as a selectable destination in the same list as saved remote/server profiles. Selecting Local Server calls
setDesktopMode("local")and returns the shell to the embedded/local Fusion server without deleting remote profiles. - Use (activate a saved remote profile). In desktop local mode, using a remote profile first switches desktop mode back to
remote, then activates the selected profile. - Edit (update name/URL/token)
- Delete
- Add connection
Activation updates activeProfileId and stamps lastUsedAt on the selected profile.
Desktop remote handoff behavior
Desktop shell stores shell settings separately from Fusion project/global settings.
When desktop mode is remote and an active profile exists, App.tsx redirects to that profile URL and appends rt when a token exists.
When desktop mode is local and the local server reports ready with a port, App.tsx redirects to http://localhost:<port>.
Persistence model
- Mobile shell: connection profiles + active profile are persisted through Capacitor Preferences (
packages/mobile/src/plugins/connection-profiles.ts). - Desktop shell: shell settings are persisted in app-owned JSON at
app.getPath("userData")/shell-connections.json(packages/desktop/src/shell-settings.ts).
Security guidance
Tokenized URLs and QR payloads are secrets.
- Treat
rt/authTokenvalues like passwords. - Do not paste tokenized links into chats, screenshots, or tickets.
- Prefer short-lived token workflows when sharing access.
For canonical token caveats and operator guidance, see Remote Access runbook.