Skip to content

Expo mobile client (spike) + CI guard against mobile regressions - #425

Draft
frenchie4111 wants to merge 27 commits into
mainfrom
spike/expo-mobile-client
Draft

frenchie4111 wants to merge 27 commits into
mainfrom
spike/expo-mobile-client

Conversation

@frenchie4111

Copy link
Copy Markdown
Collaborator

A native iOS/Android client for Ness, built with Expo, plus CI checks that stop desktop and server changes from silently breaking it. Draft: it's a spike, still being tried out on a real phone through Expo Go.

The app (mobile/)

  • Works like the web client's phone UI:
    • worktree picker with aliases, pins, snoozes and status
    • Chat tabs with live status dots
    • the full chat transcript: tool cards, folds, approvals, images, loading state
    • composer with model and permission mode
    • the full right-column tools panel
  • Connects to several backends at once. Pairing is by QR code or deep link.
  • Ness colour themes: all 15 built-ins, custom themes and the Nessie colour. They follow the first backend's settings, and "system" follows the phone's light/dark setting.
  • Reuses code from src/ instead of copying it: the state slices and rootReducer, the WebSocket transport, build-backend.ts (the only way the app calls the server), and pure renderer modules such as merge-backend-states, worktree-list-model, turn-collapse, tool-display, themes and theme-apply.
  • Not yet: terminal tabs, a file/diff viewer, paged history loading, a "Switch to Chat mode" button. Each is planned for its own worktree.

Desktop changes in this branch

  • The phone web client shows the full right column (RightColumn is split into useRightPanelConfig and RightPanelStack), with touch-sized controls.
  • Chat tabs show live status on phones.
  • Waking a tab counts as activity. automationLabel is shared.

CI guard (new steps in ci.yml)

  • npm run typecheck:mobile: the app typechecks against the shared state, transport and typed API. Renaming a server request means updating build-backend.ts, and the phone either follows or fails to compile.
  • npm run test:mobile: unit tests, including a check that the generated theme palettes match styles.css.
  • npx expo export --platform ios: fails if a shared module picks up an import Metro can't bundle (Node, DOM or Electron-only).
  • npm run test:mobile:contract, after build:headless: the app's own client, worktree list and tab code drive a freshly built headless server. Covers the initial state, repo and worktree listing, aliases, pins and snoozes, worktree removal, panes and Chat tabs, and tools-panel data. I checked that it fails when a server request handler is renamed.

Documented in CLAUDE.md ("Mobile client guard on every PR").

Testing

  • Driven on the iOS 27 simulator through Xcode's device-interaction MCP, and on a real iPhone through Expo Go against a desktop Ness.
  • Mobile typecheck, unit tests (10), contract test (7) and the iOS export all pass locally on macOS. This PR is their first run on Linux CI.

🤖 Generated with Claude Code

frenchie4111 and others added 27 commits November 25, 2026 12:30
Adds a standalone Expo app under mobile/ that pairs with a Ness backend
(desktop WS server or harness-server) via the Settings QR, a pasted link,
or a deep link, then mirrors state with the shared rootReducer and
WebSocketClientTransport imported straight from src/shared.

Screens: worktree list with rolled-up status, a json-mode chat transcript,
send-message, and allow/deny for pending permission requests. Verified on
Expo web and in Expo Go on the iOS simulator against a headless backend.

Root build untouched apart from excluding mobile/** from vitest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ports the web client's mobile layout to RN: top bar with worktree
switcher + chat tabs, the grouped worktree sheet (shared groupWorktrees),
turn-folded chat, Ness approval card and composer, using the web theme's
colour tokens and lucide icons.

Adds a backends manager: any number of saved backends with enable
switches, one NessClient per enabled backend, and a worktree sheet that
lists every backend's repos. Verified against two harness-servers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
panes:wakeTab now bumps the worktree's lastActive before waking. Without
it, AutoSleepMonitor's next sweep (<=60s) saw the stale timestamp and
slept the tab straight back, so opening an idle chat from a phone (web
client or app), where nothing else touches lastActive until a keystroke,
woke the session only to kill it again.

Moves automationLabel out of JsonModeChat.tsx into its own pure module
so the Expo client can render automated turns from the same labels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rebuilds the Expo app on the renderer's own model code instead of
re-implementations: getMergedWorktrees + buildWorktreeListBase for the
worktree picker (cross-host repo merging, accordion, groups, tail), and
grouping / turn-collapse / tool-timeline / tool-display for the chat.
Metro watches ../src with a resolver guard (one React) and serves
lucide-react / react-icons/si as RN shims so tool icons and labels are
the desktop's.

Ports MobileApp's shell (all tab types, initial-tab rule, rising-edge
wake, convert menu), the touch worktree list and action sheet (alias,
pin, snooze), and JsonModeChat (lifecycle, transcript window, tool
cards with diffs, sub-agent nesting, every approval mode, question
card, permission pill, interrupt & send, slash + /model popover).

Phone-specific: remembered selection, 44pt targets, open/pair deep
links, in-tree overlays instead of RN Modal. Findings in SPIKE.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RightColumn's panel rendering moves into a shared RightPanelStack +
useRightPanelConfig (tools list, effective order/visibility, repo-config
writers). The desktop column is unchanged; MobileRightPanel now renders
the same stack and toolbar, so the phone gets every panel (todos, agents,
subscriptions, changed/all files, context, scratchpad, custom tools …)
in the repo's configured order, plus visibility/reorder and "Build a
custom tool…" (pre-fills the new-worktree screen, like desktop).

Diff/file openers are optional now; the phone omits them, so those rows
don't open a tab it can't render. Send-to-agent uses the desktop's
routing from the phone's selected tab. Removing a worktree from the
phone sheet asks first.

Also fixes *-error / text-text classes that aren't theme tokens (Context
meter, Cost/Context totals, GitHub API log, perf HUD, Linux window
controls rendered colourless) -> danger / fg.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PanelsHost mirrors RightColumn as a full-screen sheet behind the
header's details button: the repo's own rightPanelOrder /
hiddenRightPanels (shared effective* helpers), a visibility + reorder
screen that writes repoConfig:set exactly like the desktop toolbar, and
tools:list custom tools. RN ports of every panel: PR status, Merge
Locally (asks before removing a worktree), Branch Commits (commit
popover, copy via expo-clipboard), Changed Files, All Files, Todos,
Agents, Subscriptions, Cost and Context (same interest gates),
Scratchpad and custom tools. useWatchedQuery is ported over NessClient
(watch/invalidate signals + fallback poll). Send-to-agent follows the
desktop's tab routing from the phone's selected tab.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pointer-coarse variants only, so the desktop is unchanged: the TOOLS
toolbar buttons and visibility-menu rows, every RightPanel header
action (refresh, view toggles, …) and the list/tree toggle get 44px
targets; panel headers grow from 36 to 44px. Measured in the phone web
client: all 16 buttons in the sheet are now >=44x44 (they were 12x12 to
40x40).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Connect/Cancel were ~28pt tall; now 44pt (min 88pt wide) with larger
labels. Scan QR, the link/label inputs (16pt text) and the remove
button get 44pt boxes too. Verified in the iOS 27 simulator hierarchy:
Connect is 95x44.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Chat: tool cards with the Ness mark or the generic MCP plug drew raw
  DOM <svg>, which threw a full-screen Render Error in dev the moment a
  fold containing one expanded. Both are now redrawn with
  react-native-svg from the same data (NESS_MARK_PATHS).
- Backends screen opened from the picker rendered underneath it (Fabric
  flattening puts the overlays in one stacking context); now above it,
  with a labelled 44pt close button.
- Opening the picker or the panels sheet dismisses the composer
  keyboard, which otherwise covered half the sheet.
- The selected tab scrolls into view in the tab strip (it sat under the
  details button).
- 44pt: header (45 incl. border), Send / interrupt, Jump to bottom,
  panel header actions and section headers, PR badge + checks/reviewers
  expanders, commit popover buttons (now separate a11y elements), panel
  visibility rows (whole row toggles).
- Panels: no FlatList inside the sheet's ScrollView (nested
  VirtualizedList warning); commits list no longer overlaps the next
  section; scratchpad scrolls its own text.
- No autocorrect on name fields (backend label, alias).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- useBackends' unmount cleanup closed every client but left them in the
  live map, so after Fast Refresh (or any remount) reconcile kept the
  closed clients and a backend sat at "close code 1000 — retrying"
  forever. The map is cleared now, and reconcile also recreates a client
  when its URL/token changes (it only compared the label). Verified on
  the iOS 27 simulator: both backends reconnect after a hot reload.
- Overlays (worktree picker, action sheet, backends, panels) are
  accessibilityViewIsModal so VoiceOver doesn't wander into the screen
  behind; opening Backends closes the picker so only one is ever modal.
- Labels: backend switches ("Connect to <name>"), Scratchpad input,
  commit-popover file rows include the path; the composer no longer
  reads "Message Message Claude". Panel header actions no longer
  overlap the title's touch area.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Images: tool-result screenshots, attachments in prompts and markdown
  `![](path)` images now render. Local paths are fetched through
  jsonClaude:readAttachmentImage (base64 -> data URI, bounded cache),
  like the web's JsonModeChatImageThumb/MarkdownImage; http(s) loads
  directly. Collapsed tool cards, tool groups and folded turns show a
  thumbnail strip; tap opens a zoomable fullscreen view.
- Transcript keeps its position while you're scrolled up and follows
  the bottom only when you're at it (maintainVisibleContentPosition),
  matching the web's stick-to-bottom rule — new tokens no longer shift
  what you're reading.
- Ness-control tools / automated turns / held notices use the brand
  green (+ Ness mark), not the purple accent; non-brand automated turns
  use Bot like desktop.
- Keyboard: react-native-keyboard-controller's KeyboardAvoidingView
  (frame-synced on the UI thread; RN's LayoutAnimation moved the
  composer's row and text box at different speeds) inside
  safe-area-context's SafeAreaView, which also removes the gap above
  the keyboard. All bundled in Expo Go (+ reanimated/worklets peers).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The transcript is a virtualized list, so rows that scroll off screen
unmount and a card's local useState forgot it had been opened (the web
keeps every row mounted). Cards, tool groups, finished turns, Task
cards and thinking blocks now keep the user's choice in a per-chat
store keyed by stable ids (tool_use id / group / turn / block key);
null still means "follow the default" (e.g. Task's new-approval
override).

Jump to bottom snaps non-animated after the animated scroll: on a long
transcript the animated scroll could stop short across unmeasured rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
iOS / Expo Go return the same initial URL on every cold start and full
reload of an app opened from a link. The pairing QR's …/pair?url= was
re-processed each time, re-adding and re-enabling its backend after the
user had moved to their real Ness — and because both served the same
worktree paths, the re-added (later) one won the merge, so the phone
showed its terminal "Claude Code" tabs and no aliases. consumeLaunchUrl
acts on a launch URL the first time only (open?wt= had the same replay).

The Backends screen now says when two enabled backends serve the same
worktrees and which one is shown, instead of one silently replacing the
other's tabs, statuses and aliases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Over a phone's Wi-Fi the lazy getEntries fetch takes long enough that
the web's deliberate blank (fine on desktop, where it lands in a frame)
read as broken. The chat now shows "Starting Claude…" while an awake
tab has no session yet and "Loading conversation…" while history is
unhydrated or historyPending (slow providers), after a 250ms delay so a
fast fetch doesn't flash a spinner. A hydrated, empty chat shows the
web's "What are we going to build today?" card, which the port lacked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The phone headers (web client's MobileApp and the Expo app) gave chat
tabs a fixed accent dot, so you couldn't see which chat was working,
waiting on you or needed approval. The desktop tab strip colours every
agent/chat tab by its terminals.statuses entry (TAB_STATUS_DOT); both
phone headers now do the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The screen ran inside the bottom safe area, leaving 46pt (12 composer
padding + 34 inset) below the message box with the keyboard closed. The
app now extends to the bottom edge; a strip of (inset - 12) keeps the
box clear of the home indicator, and the KeyboardAvoidingView's padding
is offset by the same amount so the keyboard slides over the strip and
the box still sits 12pt above it. Only the KAV animates, so the keyboard
motion stays in sync. Verified on the iOS 27 simulator: 34pt below the
box collapsed, ~12pt above the keyboard open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A failed readAttachmentImage (socket not up yet / dropped, which a
  phone does constantly) was cached as "unavailable", so the image never
  loaded until the chat was reopened. Only real answers are cached now
  (image, or the backend saying there's none); a failed request retries
  twice, 2s apart, and again whenever the backend reconnects.
- Markdown images use the desktop's shared chat-image-src parsing:
  `#w=300` / `![alt|400]` / `"=400x300"` are size hints rather than part
  of the path (with the desktop's precedence and clamping), file:// URLs
  resolve, and images size to the column at their own aspect ratio.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous change kept a home-indicator strip, so the box only moved
from 46pt to 34pt above the bottom — barely visible. The screen now
ignores the bottom safe area entirely: with the keyboard down the
composer is 12pt (its own padding) from the bottom edge. Keyboard-up
position is unchanged (~12pt above the keyboard). Verified on the
iOS 27 simulator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sending (Send, interrupt & send, send-on-Enter, a whole-command slash
pick) blurs the field and dismisses the keyboard once the cleared draft
has rendered, so the box drops back to the bottom edge and the
transcript is in view. Verified on the iOS 27 simulator with the
on-screen keyboard: one tap on Send sends and collapses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With Send/interrupt at 44pt, the state dot, "running" and the mode pill
floated mid-height beside them. They're grouped and aligned to the row's
bottom edge now, level with the bottom of the buttons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app follows the first backend's theme settings (mode, light/dark
theme, custom themes, Nessie colour), with 'system' resolved against the
phone's appearance. Built-in palettes are generated from the desktop's
styles.css (scripts/gen-themes.mjs); custom themes layer their semantic
keys over their base exactly like renderer/theme-apply.ts.

The palette is one mutable object applied before render; module-level
styles and colour tables go through themed() so they rebuild per theme,
and the UI subtree remounts on a theme change while backend connections
stay up. Status bar and keyboard appearance follow the theme.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NessClient now exposes `api`, the renderer's own build-backend.ts bound
to the client's WebSocket transport, and every request and signal goes
through it instead of a hand-written channel string. A server-side rename
or signature change updates build-backend.ts, so the phone either follows
automatically or fails its typecheck. (It already caught one cast the
desktop makes for setRepoConfig's legacy nulls.)

Also pulls the list model's input mapping (fleet.ts) and the tab helpers
(src/tabs.ts) out of hooks/App.tsx into plain functions, so tests can run
the same code the screens do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- typecheck:mobile: the app against the shared state, transport and
  typed API it imports from src/.
- test:mobile: unit tests, including generated theme palettes vs
  styles.css (gen-themes.mjs is now importable for the check).
- expo export (iOS): a shared module gaining an import Metro can't bundle.
- test:mobile:contract: the app's NessClient / Fleet / list model against
  a freshly built headless server (snapshot, repo and worktree listing,
  aliases / pins / snoozes, worktree removal, panes and Chat tabs,
  tools-panel data). Verified it fails on a renamed handler.

Documented in CLAUDE.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pickInitialTab preferred 'agent' (a Claude Code terminal), then 'shell',
so a worktree with Chat + Shell tabs — the default now — opened on the
Shell. It now takes the first conversation tab, Chat or Claude Code, in
tab order. Same bug in the phone web client and the Expo app; both now
share one copy (renderer/pick-initial-tab.ts), and the mobile contract
test checks a server-seeded worktree opens on a conversation tab.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
React Native can't select across a message the way the web chat does
(iOS 'selectable' only offers Copy for one whole Text). Like the native
chat apps, long-pressing a prompt, a reply or a thought opens Copy /
Select Text; Select Text shows the message in a read-only text view with
real selection handles, Select All, Look Up and Share, plus Copy All.
A code block's long-press covers just the code. Paragraphs drop
'selectable', whose own Copy bubble fired alongside the menu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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