{"id":50234809,"url":"https://github.com/lhr0909/pi-mobile","last_synced_at":"2026-06-22T16:02:55.094Z","repository":{"id":358175165,"uuid":"1239923903","full_name":"lhr0909/pi-mobile","owner":"lhr0909","description":"Mobile client and SDK host MVP for Pi coding-agent sessions","archived":false,"fork":false,"pushed_at":"2026-06-10T09:50:23.000Z","size":428,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-10T11:23:08.514Z","etag":null,"topics":["pi-coding-agent","react-native","slop"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lhr0909.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-15T15:28:20.000Z","updated_at":"2026-06-10T09:50:28.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/lhr0909/pi-mobile","commit_stats":null,"previous_names":["lhr0909/pi-mobile"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lhr0909/pi-mobile","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhr0909%2Fpi-mobile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhr0909%2Fpi-mobile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhr0909%2Fpi-mobile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhr0909%2Fpi-mobile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lhr0909","download_url":"https://codeload.github.com/lhr0909/pi-mobile/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhr0909%2Fpi-mobile/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34655727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pi-coding-agent","react-native","slop"],"created_at":"2026-05-26T19:00:32.294Z","updated_at":"2026-06-22T16:02:55.088Z","avatar_url":"https://github.com/lhr0909.png","language":"TypeScript","funding_links":[],"categories":["Miscellaneous"],"sub_categories":[],"readme":"# Pi Mobile\n\nPi Mobile is a pnpm-workspace MVP for controlling `pi` coding-agent sessions from an iPhone-first native app. The repository now contains both sides of the prototype:\n\n- `apps/host` — a Node/TypeScript mobile host that embeds Pi through the SDK (`AgentSessionRuntime` + `AgentSession`).\n- `apps/mobile` — an Expo / React Native app that connects to a configured host, opens a session, streams timeline updates, and sends prompt/steer/follow-up/abort commands.\n- `packages/shared` — shared protocol types, validation helpers, timeline projection, and mobile client reducer logic used by both apps.\n\nThe implementation follows the research decision: **SDK-hosted TypeScript daemon first, `pi --mode rpc` only as a future fallback**.\n\n## Current MVP capabilities\n\n### Host daemon\n\n- Embeds `@earendil-works/pi-coding-agent` with `AgentSessionRuntime`.\n- Creates, opens, continues, and lists Pi sessions through `SessionManager`.\n- Binds a mobile-compatible extension UI context for `select`, `confirm`, `input`, `editor`, `notify`, `setStatus`, `setWidget`, `setTitle`, and `set_editor_text`.\n- Projects raw Pi SDK events into mobile timeline updates.\n- Exposes HTTP APIs for host status, session list/open/snapshot/events, prompt, steer, follow-up, abort, and extension UI responses.\n- Broadcasts live host/session events over WebSocket at `/ws`.\n- Supports optional bearer-token auth through `PI_MOBILE_HOST_TOKEN` and explicit dev CORS through `PI_MOBILE_HOST_CORS_ORIGIN`.\n\n### Mobile app\n\n- Expo / React Native + TypeScript.\n- iPhone-first MVP with separate connection and session screens.\n- Connects to a configured host URL and optional token.\n- Uses Expo Router / React Navigation native-stack pages for Home, Host, Workspace, Path Explorer, Stored Sessions, and active Session navigation instead of one stacked setup form.\n- Presents a recents-first mobile home for resuming sessions, connecting hosts, and jumping into the relevant navigation page only when needed.\n- Persists recent hosts and recent host/path/session combinations on the client for quick reconnects, with client-side remove-from-recents actions for keeping the mobile home concise without deleting anything on the host machine.\n- Seeds directory browsing from `~/Documents` by default, includes quick Home (`~`) and Documents shortcuts, and supports `~/...` workspace paths.\n- Lists stored Pi sessions for the selected workspace path so desktop sessions can be continued from mobile.\n- Opens a new Pi session for the selected workspace path, opens a listed stored session, or reopens a previous persisted session when a saved session file is available, then switches into the session view.\n- Shows live status, expanded tool, thinking, user, and assistant timeline items with a dark monospaced style based on Pi's session export/TUI palette.\n- Keeps streamed thinking/text blocks and tool calls in event order, with exact tool-call arguments and tool input/output shown fully expanded for now.\n- Renders bash/read tool cards with TUI-like call lines, command output, read path/range headers, and syntax-highlighted read file contents.\n- Renders user, thinking, and assistant text as Markdown with Pi TUI-inspired colors.\n- Records accepted mobile prompts as user timeline cards so the submitted message appears before assistant output.\n- Shows a compact animated TUI-style `Working...` spinner while Pi is streaming/compacting instead of adding `Agent started` / `Agent finished` timeline prompts.\n- Includes a collapsible session header for reducing metadata height during active chat.\n- Sends prompt, steer, follow-up, and abort commands from a TUI-like composer.\n\n## Repository layout\n\n```text\n.\n├── apps/\n│   ├── host/                 # Node/TS SDK host daemon\n│   └── mobile/               # Expo React Native app\n├── packages/\n│   └── shared/               # Shared protocol and reducers\n├── package.json              # Root scripts\n├── pnpm-workspace.yaml\n├── tsconfig.base.json\n└── vitest.config.ts\n```\n\n## Setup\n\n```bash\npnpm install\n```\n\nPi itself must be configured on the host machine before running real sessions:\n\n```bash\nnpm install -g @earendil-works/pi-coding-agent\npi\n```\n\n## Run the SDK host\n\n```bash\npnpm dev:host\n```\n\nDefaults:\n\n- Bind: `localhost`\n- Port: `4739`\n- URL: `http://localhost:4739`\n\nEnvironment:\n\n```bash\nPI_MOBILE_HOST_BIND=0.0.0.0 \\\nPI_MOBILE_HOST_PORT=4739 \\\nPI_MOBILE_HOST_TOKEN=dev-secret \\\npnpm dev:host\n```\n\nIf `PI_MOBILE_HOST_TOKEN` is set, HTTP clients must send `Authorization: Bearer \u003ctoken\u003e` and WebSocket clients may connect with `/ws?token=\u003ctoken\u003e`.\n\nFor local Expo Web smoke tests, opt into browser CORS explicitly:\n\n```bash\npnpm dev:host:web\n```\n\n## Run the mobile app\n\n```bash\npnpm dev:app\n```\n\nThe app defaults to `http://localhost:4739`, which works for an iOS simulator talking to a host daemon running on the same Mac. For a physical phone, use a LAN/Tailscale-reachable host URL and set `PI_MOBILE_HOST_BIND=0.0.0.0` on the host.\n\nFlow:\n\n1. Open the mobile home. It is now a navigation hub rather than a long setup form.\n2. Resume from a saved session row, connect to a recent host row, or remove stale recent host/session references from this client device.\n3. Open **Host** to enter the host URL/token and tap **Connect host**. The app reads `/api/host/status`, remembers the host locally, and advances to **Workspace**.\n4. Use **Workspace** to paste or confirm an absolute/`~/...` path, open a new session, jump to **Path explorer**, or browse **Stored sessions** for the selected path.\n5. Use **Path explorer** with **Documents**, **Home ~**, and **Up** shortcuts or folder rows, then tap **Use this path** to return to **Workspace**.\n6. Use **Stored sessions** / **Refresh** to list desktop/mobile Pi sessions for the selected path, then **Continue** a listed session, choose **New here** from recents, or open a fresh session from **Workspace**.\n7. Use the active **Session** page bottom composer to send prompts, steer/follow up, or abort the active turn.\n\nWhen simulator tapping is unreliable, use Expo Web for browser-based mobile viewport smoke tests. Start these in separate terminals:\n\n```bash\npnpm dev:host:web\npnpm web:test\n```\n\nThen open `http://localhost:8082`, or drive it with `agent-browser`:\n\n```bash\nagent-browser --session pi-mobile-web batch \"set device \\\"iPhone 14\\\"\" \"open http://localhost:8082\" \"snapshot -i\"\n```\n\nExpo Web is a fast UI/protocol smoke test; keep the iOS simulator or a dev-client/device run for native-specific behavior.\n\n## Host API sketch\n\n| Method | Path | Purpose |\n|---|---|---|\n| `GET` | `/api/health` | unauthenticated health check |\n| `GET` | `/api/host/status` | host metadata |\n| `GET` | `/api/sessions?cwd=/path` | list stored sessions for a workspace path (`~/...` paths are expanded by the host) |\n| `GET` | `/api/directories?path=~` | list child directories for the mobile path explorer (`~/Documents` is the mobile default) |\n| `POST` | `/api/sessions` | open/create a session with `{ cwd, mode?, sessionFile? }` |\n| `GET` | `/api/sessions/:id/snapshot` | current session snapshot |\n| `GET` | `/api/sessions/:id/events?since=N` | replay host events after `N` |\n| `POST` | `/api/sessions/:id/commands/prompt` | send `{ message, streamingBehavior? }` |\n| `POST` | `/api/sessions/:id/commands/steer` | send `{ message }` |\n| `POST` | `/api/sessions/:id/commands/follow-up` | send `{ message }` |\n| `POST` | `/api/sessions/:id/commands/abort` | abort current turn |\n| `POST` | `/api/sessions/:id/extension-ui/:requestId` | answer extension UI |\n| WS | `/ws` | live `HostEvent` stream |\n\n## Test and validation commands\n\n```bash\npnpm typecheck\npnpm test\npnpm build\npnpm test:coverage\n```\n\nThe tests cover:\n\n- Shared timeline projection, mobile reducer, and protocol validation.\n- SDK host runner behavior with fake SDK sessions.\n- Host HTTP/WebSocket API behavior and auth.\n- Mobile host-client URL handling and app view-model transitions.\n\n## iOS simulator e2e\n\nThe intended e2e loop is:\n\n```bash\nagent-device ensure-simulator --platform ios\npnpm dev:host\npnpm --filter @pi-mobile/app start:metro\nagent-device open \"Expo Go\" \u003cexpo-url\u003e --platform ios\nagent-device snapshot -i --platform ios\n```\n\nThis depends on local simulator/Expo availability. If Expo Go reports an SDK-version mismatch, uninstall the simulator's old Expo Go and let Expo CLI install the SDK-matched build:\n\n```bash\nxcrun simctl uninstall \u003csimulator-udid\u003e host.exp.Exponent\nCI=1 pnpm --filter @pi-mobile/app exec expo start --ios --go --localhost --port 8081\n```\n\nIf the simulator automation runner cannot interact with the app, capture a screenshot with `agent-device screenshot` and use an Expo dev build (`expo run:ios`) for deeper follow-up testing.\n\n## MVP limitations\n\n- No hosted relay yet; use direct LAN, localhost, Tailscale, or an SSH tunnel.\n- No QR pairing yet; recent hosts/sessions are saved locally on the mobile client only. Removing recents clears only the client-side reference records and never deletes host sessions, files, or directories.\n- No push notifications yet.\n- Mobile extension UI requests are emitted by the host, but the current app does not yet render response dialogs.\n- SDK host process owns active turns; a daemon crash ends in-flight work, while persisted Pi sessions can be reopened.\n- `pi --mode rpc` subprocess fallback is not implemented in this MVP.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flhr0909%2Fpi-mobile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flhr0909%2Fpi-mobile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flhr0909%2Fpi-mobile/lists"}