Repository navigation
feat(mobile): client-owned terminal light/dark color scheme [CHE-1303] - #6
Merged
Merged
Conversation
The mobile terminal rendered whatever palette the host baked in, so a paired
iPad mirrored the host Mac's light/dark. CHE-1302 made the host ship both
palettes; this lets the client pick its own.
- preferences.ts: terminalColorScheme ('system'|'light'|'dark', default
'system') load/save, following the appAppearance precedent. A separate
per-device choice from app-chrome appearance.
- theme-context.tsx: ThemeProvider also resolves the terminal scheme
(resolvedTerminalScheme) from the stored pref + useColorScheme(), so a
change in settings or an OS appearance flip re-renders the session live.
- terminal-color-scheme.ts: pure resolveTerminalThemeForScheme() picks
palettes[scheme] into {mode, theme}; falls back to the host's single
palette unchanged when palettes are absent (older host).
- session screen: applies the pick to each terminal's theme at render.
- terminal-settings.tsx: a Color theme picker (System / Light / Dark).
- tests for the pref round-trip and the palette-pick helper.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Extract the appearance→effective-scheme resolver into a pure resolve-scheme.ts (theme-context now imports it instead of defining it inline) and test the full decision the feature makes end-to-end without rendering: a stored terminalColorScheme plus the device OS scheme compose through resolveScheme → resolveTerminalThemeForScheme to the palette that renders. Covers: 'system' tracks the OS, an override wins over the OS, flipping the OS flips the palette on 'system', and the older-host single-palette fallback — the wiring a screenshot of the helper alone didn't exercise. Co-Authored-By: Claude Opus 4.8 <[email protected]>
smk508
pushed a commit
that referenced
this pull request
Jul 22, 2026
* Restructure mobile pairing setup into a clear stepped layout * Rework mobile pairing UI: radio-style path selector with sign-in gate fo * fix(mobile): resolve mobile-pairing review findings Applies the code-review findings for the reworked pairing UI: - Clear a displayed Relay QR on sign-out in both MobilePage and MobilePane (the rework dropped the wasSignedInRef watcher, leaving a stale Relay QR next to a "sign in required" prompt). Anywhere stays selected; the QR re-mints as local-only. [#1, #3] - Extract useMobilePairingConnectionMode so both panes resolve the saved preference identically instead of duplicating the state + resync effect. [#6] - Delete ~24 i18n keys the rework left unreferenced; sync locale catalogs to parity. [#4] - Give the connection-path radiogroup roving tabindex + arrow-key nav and document why it diverges from SettingsSegmentedControl. [#7] - Add MobilePane.test.tsx (previously untested safety logic) and a MobilePage saved-local-only restore test. [#2, #5] Verified: 22 targeted tests pass, typecheck + oxlint clean, localization catalog/coverage and max-lines ratchet green. * fix(mobile): resolve adversarial-review findings for pairing UI Address accepted findings from the mobile pairing UI rework: - MobilePane: add a request-generation epoch so a late getPairingQR response can't paint a stale Relay QR after sign-out, a mode switch, or an address change; arm rotation when discarding a pending mint. - MobilePage: on sign-in, upgrade a signed-out local-only fallback QR to Relay (invalidate + rotate-regenerate); handle null->connected too. - Extract useMobilePairingQrInvalidation so both sign-in/out edges and cross-window preference syncs invalidate/re-mint the QR consistently. - MobilePane: clear + rotate the QR when the selected address changes (manual pick or refresh-driven) so it can't encode the old endpoint. - MobilePairingConnectionOptions: guard the Sign in CTA on configured; show an Unavailable panel on unconfigured builds instead of dead CTA. - Drop the duplicate sign-in helper from MobilePairingSetupSection. - Remove dead i18n keys (title, recommended, signInToGenerate) and add relayUnavailable across all locale catalogs. - Add tests: deferred sign-out/mode-switch races, sign-in upgrade, cross-window sync, unconfigured build, arrow-key radiogroup. TODO left for the relay-label-honesty finding: getPairingQR does not expose the actually-encoded mode when an automatic offer degrades to local-only, so the mismatch can't be surfaced without a new return field. * fix(mobile): resolve relay-pairing deep-review regressions - MobilePane: invalidatePairing now clears loading so a superseded mid-flight generate can't wedge Generate disabled forever - MobilePage: stop auto-minting a local-only QR under the Relay label when signed out with Anywhere; gate Step 2 auto-generate and the Generate button on a shared canMintMobilePairingOffer helper, align with Settings, clear QR + loading on sign-out, mint Relay on sign-in - qr-invalidation: clear pairQrDataUrl (and loading) on every invalidation path so a stale QR can't stay scannable during rotation - Strengthen MobilePane/MobilePage tests for the aligned behavior and stuck-loading coverage - Translate relayUnavailable in es/ja/ko/zh Co-authored-by: Orca <[email protected]> * fix(mobile): refuse to mint QR when signed-out with Anywhere selected Replace silent degradation of Anywhere mode to local-only QR with explicit refusal. Add canMintMobilePairingOffer guard across all mint paths (address change, network invalidation, connection mode switch). This ensures the UI honestly encodes the selected pairing path. Improve keyboard focus visibility on the path selector by adding a persistent focus ring. * fix(mobile): detect and flag Relay provisioning degradation When Relay provisioning fails during automatic (Anywhere) pairing offer creation, the offer silently degrades to local-only. This confuses users who selected Anywhere expecting cellular capability. Add connectionMode field to the pairing offer result to expose what the offer actually encodes. The UI now flags degradation when the offered mode mismatches the user's selection. Also move credential rotation logic to the main process: rotate when requested mode differs from the pending token's encoded mode. This ensures QR codes displayed under an old policy can't pair under a new one, and windows reminting after preference sync converge on one token. Rename MobileRelayBetaAvailability → MobileRelayBetaNotice. * test(mobile): verify pairing codes don't flash during Relay mint Assert that the pairing QR and URL remain hidden while the Relay mint is pending, preventing confusing intermediate states when signing in unlocks Relay. --------- Co-authored-by: Orca <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The mobile terminal rendered whatever light/dark palette the desktop host baked into the runtime graph, so a paired iPad always mirrored the host Mac's appearance. CHE-1302 (merged) made the host ship both the light and dark resolved palettes; this PR lets the client pick its own — the user-visible payoff of the "Client-owned display preferences" effort (CHE-1301 ADR: the host owns palette resolution, the client owns the trivial light-vs-dark pick).
Closes CHE-1303.
What changed:
preferences.ts—terminalColorScheme('system' | 'light' | 'dark', default'system') load/save, following theappAppearanceprecedent. A separate per-device choice from app-chrome appearance, so a user can run light chrome with a dark terminal.theme-context.tsx—ThemeProvidernow also resolvesresolvedTerminalSchemefrom the stored pref +useColorScheme(). Putting it in the shared context is what makes the change apply live: changing the setting, or toggling the device's OS appearance, re-renders the session with no reconnect and no focus-reload hack.terminal-color-scheme.ts— pureresolveTerminalThemeForScheme(theme, scheme): pickspalettes[scheme]into{mode, theme}; returns the host theme unchanged whenpalettesis absent (older host — the AC's backward-compatible fallback).Verification
Rung-1 (green):
pnpm test979 passed / 2 skipped (146 files),pnpm lint(oxlint) clean,tsc --noEmit0 errors. Tests cover:terminalColorSchemeAsyncStorage round-trip + fallback; the palette-pick helper (light / dark / host-fallback / undefined); and the resolution seam —resolveSchemeextracted to a pure module and composed with the pick to provepreference + OS scheme → which palette rendersend-to-end ('system'tracks the OS, an override wins, flipping the OS flips the palette, older-host fallback) without rendering the session screen.Rung-2 (simulator) — the new control rendered in the running dev client (this branch's JS via Metro on iPad Pro 11" M4):
Rung-2 (terminal palette) — light vs dark, rendered through the app's own xterm webview (
terminal-webview-html.ts) driven by the sameset-thememessage the session screen sends, fed the two palettesresolveTerminalThemeForScheme()selects:Same content, palette differs — confirms the AC's "content unchanged; only the palette differs."
Risks / scope notes
set-themepath with representative palettes; the selection logic ('system'→OS, override, host-fallback) is covered by the helper unit tests. The one path no screenshot here exercises end-to-end is a real paired host streamingpalettes— that needs a fork-built desktop host (the desktop host on this machine is the release build, pre-CHE-1302, so it sends a single palette and the client correctly falls back). Cheap to eyeball later against a fork host.terminal-settings.tsxitself is not theme-migrated (uses the static darkcolors, like its sibling sections) — its own chrome stays dark; unchanged by this PR.Built on the cohort integration branch
main(this fork), which already carries CHE-1302/1305/1308.