How friuns2/codex-mobile works
1. Overall shape
- codexapp is a Node.js 18+ local bridge that exposes a Vue browser UI for Codex app-server workflows.
- The main architecture is three-tier: browser client → local HTTP server → Codex app-server / provider proxies / local OS services.
2. Frontend application
- The UI lives under src/ and is a Vue 3 single-page app with main.ts, App.vue, router/, layouts, sidebar, and content panels.
- Major surface areas are chat/thread handling, skills, review panes, account/config panels, terminal panels, and project/worktree controls.
- Mobile behavior is treated as a first-class concern via dedicated composables and responsive layout components.
3. Backend entry and HTTP surface
- The server side is centered on src/server/httpServer.ts, which wires the local web server and mounts feature routes.
- Important route modules include accountRoutes.ts, skillsRoutes.ts, localBrowseUi.ts, customEndpointProxy.ts, openRouterProxy.ts, unifiedResponsesProxy.ts, zenProxy.ts, and telegramThreadBridge.ts.
- authMiddleware.ts, password.ts, and runtime config logic enforce access control and environment-specific startup behavior.
4. Codex app-server bridge
- src/api/codexGateway.ts, codexRpcClient.ts, and src/server/codexAppServerBridge.ts form the core integration layer to the upstream Codex app-server.
- This bridge translates UI actions into app-server requests and turns app-server events/notifications back into UI state updates.
- The repository includes a large contract surface for this integration under documentation/app-server-schemas/, which acts as the canonical protocol boundary.
5. Protocol typing and normalization
- src/api/appServerDtos.ts and src/api/normalizers/v2.ts adapt app-server payloads into UI-friendly shapes.
- The repo carries extensive generated or schema-derived types in documentation/app-server-schemas/typescript/ and JSON schemas in documentation/app-server-schemas/json/.
- This implies a strong contract-driven architecture: UI logic depends on normalized domain objects rather than raw wire payloads.
6. Provider/model routing
- The server includes explicit proxy/broker layers for multiple upstream model formats: openRouterProxy.ts, zenProxy.ts, unifiedResponsesProxy.ts, and customEndpointProxy.ts.
- freeMode.ts, rateLimitDecodeRecovery.ts, and provider/model-related tests indicate that model selection, auth state, and request format translation are separate concerns from the chat UI itself.
- The UI therefore sits above a provider abstraction layer, not directly on one backend API.
7. Conversation, thread, and project state
- Thread lifecycle and persistence are a major subsystem: list, load, resume, fork, archive, rollback, and diff behavior are represented throughout the UI and server.
- Git-aware project behavior is built in via reviewGit.ts, commandResolution.ts, and worktree/rollback features in the UI and tests.
- This repo treats “thread” and “project/worktree” as coupled domains, with the server responsible for canonical file-system and git operations.
8. Terminal and command execution
- src/server/terminalManager.ts and the terminal panels in the UI provide an integrated shell experience inside the app.
- Command execution is mediated through approval-oriented request/response flows in the app-server protocol rather than being a raw shell passthrough.
- The architecture separates terminal orchestration from UI rendering, which matters for approvals, streaming output, and cancellation/interruption.
9. Skills and plugin discovery
- Skills are handled as a dedicated subsystem with skillsRoutes.ts, the SkillsHub UI, composer skill picker, and GitHub sync composables.
- The repo supports both local and remote skill sources, plus startup sync and live refresh behavior.
- The architecture distinguishes “skill metadata/discovery” from “skill execution”, with the former surfaced in the UI and the latter mediated by the app-server bridge.
10. Authentication, account, and runtime config
- Account/session state is handled server-side and reflected in the UI through account menus, rate-limit panels, and login flows.
- The app supports multiple auth modes and dynamic runtime/provider configuration, which is why there are dedicated routes and DTOs for auth status, token refresh, and model lists.
- This is not a stateless browser app: the server maintains operational context and forwards account state into the UI.
11. Optional external bridges
- telegramThreadBridge.ts adds an alternate entry point where Telegram messages map to Codex threads, including allowlist-based authorization.
- The README’s tunnel and Tailscale guidance show that the server is designed to be reachable through local, LAN, or private remote exposure patterns.
- These integrations sit outside the core chat UI but share the same thread/control plane.
12. Packaging and runtime delivery
- The repo uses Vite for the browser app, tsup for Node-side bundling, and a PWA layer (public/sw.js, manifest, icons) for installable browser use.
- The workflows and scripts support cross-platform launch, Android/Termux usage, APK-related publishing, and test/debug helpers.
- Architecture-wise, the same codebase ships both a browser SPA and a local Node server, with the server acting as the boundary to the filesystem, terminal, git, and upstream Codex services.
Main entry points: httpServer.ts HTTP server · App.vue Browser UI · codexAppServerBridge.ts App-server bridge · ThreadConversation.vue Thread workspace
Components 22
Vue UI
Browser SPA and presentation layer
- Browser UI · Main browser application shell and navigation.
src/App.vue - App boot · Bootstraps the client app and router.
src/main.ts - Desktop layout · Primary responsive shell for desktop and mobile surfaces.
src/components/layout/DesktopLayout.vue - Thread workspace · Core chat, composer, pending actions, and terminal panels.
src/components/content/ThreadConversation.vue - Sidebar nav · Thread tree, project controls, and primary navigation.
src/components/sidebar/SidebarPrimaryNav.vue - Accounts panel · Login, auth state, and rate-limit/account views.
src/components/content/AccountMenu.vue - Skills hub · Skill discovery, selection, detail, and sync surfaces.
src/components/content/SkillsHub.vue - Review pane · Git-aware review, diff, and rollback-oriented UI.
src/components/content/ReviewPane.vue - Mobile state · Responsive/mobile behavior and UI state helpers.
src/composables/useMobile.ts
Local Server
Node.js HTTP surface and bridge logic
- HTTP server · Local web server that mounts the app and feature routes.
src/server/httpServer.ts - App-server bridge · Translates UI intents into Codex app-server requests and events.
src/server/codexAppServerBridge.ts - Gateway client · Client-side gateway and RPC wiring to the upstream app-server.
src/api/codexGateway.ts - Auth config · Access control, password checks, and runtime-specific startup rules.
src/server/authMiddleware.ts - Account routes · Account/session endpoints and related state propagation.
src/server/accountRoutes.ts - Skills routes · Routes for listing, syncing, and updating skills metadata.
src/server/skillsRoutes.ts - Provider proxies · Model/provider translation and passthrough layers for multiple upstream formats.
src/server/openRouterProxy.ts - Terminal mgr · Integrated shell/session orchestration and streaming output handling.
src/server/terminalManager.ts - Git worktrees · Project, rollback, diff, and worktree operations.
src/server/reviewGit.ts - Telegram bridge · Alternate message ingress that maps Telegram messages to threads.
src/server/telegramThreadBridge.ts
Protocol
Codex app-server schemas and normalized DTOs
- DTO normalize · Normalizes raw protocol payloads into UI-friendly shapes.
src/api/appServerDtos.ts - Protocol schemas · Canonical app-server JSON and TypeScript schema boundary.
documentation/app-server-schemas/json/codex_app_server_protocol.schemas.json
Runtime
Packaging, CLI, and delivery entrypoints
- CLI entry · Command-line bootstrap for local runtime and launch modes.
src/cli/index.ts
Connections 24
- App boot → Browser UI: mounts · Bootstraps the Vue application shell.
- Browser UI → Desktop layout: uses · Main app renders through the responsive layout shell.
- Desktop layout → Thread workspace: contains · Primary content area for threads and composer flows.
- Desktop layout → Sidebar nav: contains · Sidebar provides thread and project navigation.
- Thread workspace → Review pane: opens · Conversation views can surface review and diff context.
- Thread workspace → Terminal mgr: drives · Terminal panel mirrors server-managed terminal sessions.
- Browser UI → Accounts panel: shows · Account state is surfaced in the client UI.
- Browser UI → Skills hub: shows · Skill discovery and sync are part of the main UI.
- Browser UI → Mobile state: adapts with · Responsive and mobile-first behavior influences layout and controls.
- HTTP server → App-server bridge: wires · Server mounts the Codex app-server integration boundary.
- HTTP server → Account routes: mounts · Exposes account/session HTTP endpoints.
- HTTP server → Skills routes: mounts · Exposes skills discovery and sync HTTP endpoints.
- HTTP server → Provider proxies: mounts · Hosts upstream provider/model proxy endpoints.
- HTTP server → Telegram bridge: mounts · Optional alternate ingress for Telegram thread control.
- App-server bridge → Gateway client: calls · Bridge delegates protocol traffic through the gateway client.
- Gateway client → DTO normalize: maps to · Raw responses are normalized before reaching the UI.
- DTO normalize → Protocol schemas: follows · Normalization is defined against the contract schemas.
- App-server bridge → Protocol schemas: speaks · Bridge behavior is constrained by the app-server contract.
- Account routes → Auth config: depends on · Account handling is gated by auth and runtime config.
- Skills routes → App-server bridge: queries · Skills metadata comes from the app-server bridge.
- Provider proxies → Gateway client: feeds · Provider/model proxies integrate with the same upstream control plane.
- Thread workspace → App-server bridge: syncs with · Thread lifecycle and turn actions flow through the bridge.
- Sidebar nav → Git worktrees: uses · Project and worktree controls depend on git-aware server operations.
- CLI entry → HTTP server: starts · CLI bootstraps the local server runtime.