- Rust 100%
μ (mu) #
A standalone native app for mathematical conversations, built in Rust with GPUI.
Run #
The initial development target is macOS. Install a current stable Rust toolchain and Xcode command-line tools, then run:
cargo run
The first build compiles GPUI and its platform dependencies and may take a while. Other platforms have not been validated.
GPUI also needs the Metal compiler. If a build reports a missing Metal Toolchain, install it through Xcode or run:
xcodebuild -downloadComponent MetalToolchain
Current scope #
The native UI supports Codex connection and browser sign-in, model selection, message entry, streamed replies, stopping a reply, and starting a new conversation. An illustrative sample with a clickable Typst-source preview is shown until the first message is sent. Messages currently display as plain text; Markdown/Typst rendering, saved conversations, and comments are not implemented.
Chat in the app #
- Install the Codex CLI and ensure
codexis onPATH, then runcargo run. - The app makes one automatic Codex connection attempt at startup, reusing existing credentials. If it fails, click the context ring in the composer toolbar and retry manually. If needed, choose Sign in, then Open browser sign-in.
- Select a model in the compact bottom-right toolbar. The effort label (for example, Low) opens that model's advertised reasoning levels. The blue lightbulb requests streamed provider summaries, which can be expanded or collapsed in the conversation. Turning summaries off does not disable the model's internal reasoning.
- Type a message and click the paper-plane button or press Cmd+Enter. Enter (or Shift+Enter) inserts a newline. Drafts can be edited during generation.
- During generation the send button becomes a stop square, which interrupts the current reply. New thread clears the in-memory conversation and allows selecting a different model.
The context ring shows the fraction of the context window consumed, using Codex's latest token-usage report rather than cumulative billing totals. Until valid usage and a context limit are reported, it remains neutral and says usage is unavailable. Click it for token counts and Codex connection/account settings. On macOS, toolbar icons use the system's SF Symbols (lightbulb, brain, paper plane, and stop), generated in memory and cached rather than hand-drawn or bundled. Other platforms use standard Unicode fallback glyphs. The context ring remains a data-driven usage visualization. Menus open immediately above their controls, mark the selected item, and dismiss on outside click or Escape. Hover controls for their labels and shortcuts. The toolbar is borderless except for the send/stop button; the message field blends into the conversation. The composer starts at one line and grows for explicit newlines, with compact toolbar and menu row spacing.
Provider I/O runs on a background worker so login and streaming do not block the UI. Connection/provider errors appear in the status bar. Refresh reloads account/model state; reconnecting after a broken connection starts a fresh conversation rather than silently continuing with lost context.
Conversations are ephemeral and disappear when the app closes. Sign out of Codex affects all clients sharing the same Codex credential store. Startup connects and reads account/model state but never starts browser login or sends a prompt. There is no automatic reconnection loop.
The sidebar contains a single Threads section. Threads are still ephemeral; the sidebar does not imply saved history. Reasoning effort can change between turns; model selection is locked until a new thread is started. Only public provider thinking summaries are shown, when available, not hidden reasoning.
The intended interaction is:
- Messages are Markdown source with Typst math.
- Equations render normally; opening one reveals its source.
- Comments attach to selected prose or Typst source.
- Messages are editable; the conversation itself is the artifact.
- There is no backing document, worktree, or landing workflow.
Next milestone: selectable prose, inline and display Typst rendering, and a source-anchored comment on one hard-coded message.
Development checks #
cargo fmt --check
cargo check --locked
cargo test --locked
Chat backend (Codex) #
The mu::chat::ChatProvider interface supports account state, browser login,
login cancellation, logout, paginated model discovery, conversations, streamed
events, and turn interruption. Codex implements it using the official
Codex app-server JSONL protocol.
Codex handles credential storage/refresh and requests to the provider endpoint;
mu does not implement private OAuth endpoints or read access tokens.
Install the Codex CLI and make codex available on PATH. The integration is
validated against codex-cli 0.163.0; the protocol is version-sensitive.
# Local initialization only; does not start login or send a prompt.
cargo run --locked --example chat -- check
cargo run --locked --example chat -- login
cargo run --locked --example chat -- models
cargo run --locked --example chat -- send MODEL_ID 'Explain the epsilon-delta definition of a limit.'
cargo run --locked --example chat -- logout
Replace MODEL_ID with an identifier returned by models. Login prints a
sensitive, short-lived browser URL; do not share or persist it. Login is only
complete after account/login/completed reports success. Authentication uses
Codex's existing credential store, so logout also signs out other Codex clients
using that store.
All backend methods block and must run off GPUI's UI thread. Keep the provider
alive for the conversation lifetime. Call send for subsequent messages on the
same thread; then consume next_event until turn/completed. Events preserve
the original method and parameters, including routing IDs:
item/agentMessage/delta: appendparams.deltato the matching item.item/completed: authoritative final item contents.turn/completed: terminal status (completed,failed, orinterrupted).error: generation failures, distinct from request-level RPC errors.
Unknown notification methods should be ignored. A request timeout has an unknown outcome: do not automatically retry login or a turn, which might duplicate work. Dropping the backend terminates and reaps its subprocess. Conversations are ephemeral; reconnect/resume and durable message storage are not implemented.
Scope and security #
This is a local Codex runtime integration, not a direct generic HTTP client. It inherits the user's Codex provider configuration. Other provider adapters remain future work.
Codex is an agent runtime, not a tool-free completion endpoint. Threads use a read-only sandbox, untrusted-command approvals, and instructions not to use tools; mu rejects all server-initiated requests, including approval requests. These settings do not guarantee zero tool execution or file reads: Codex can run operations allowed without approval, and configured MCP services may have their own capabilities. Only run this against a trusted local Codex configuration. A hard tool-free math chat requires a direct provider adapter or an isolated runtime; instructions alone are not a security boundary.
Consult OpenAI's current authentication terms before distributing this integration. App-server authentication is not intended as an authentication service for commercial/hosted products; those require an approved sign-in integration.