* refactor(web): share the tool-name alias table across presentation paths OpenCode reports built-in tools by lowercase ACP id (bash, write, edit, ...), and #2299 resolved them to the canonical result views with a local table in _results.tsx. Lift that table into toolNameAliases.ts with a resolveToolNameAlias helper so the upcoming presentation paths (card title/icon, input renderer, terminal detection) resolve through the same module instead of growing their own tables. No behavior change: getToolResultViewComponent keeps the exact-name lookup first and only falls back to the resolved alias. OpenCode ids whose dedicated views read Claude-shaped fields (skill, todowrite, patch, question) stay unresolved, as before. * fix(web): render OpenCode lowercase tool names like their canonical cards OpenCode v2 tool calls arrive with lowercase ACP ids (bash, write, edit, glob, grep, list, webfetch, websearch, task). The result views resolved them since #2299, but the card title/icon, the detail dialog's Input section and terminal-card detection still treated them as unknown tools: the bash card showed a wrench icon, a literal "bash" title, and its dialog dumped raw input JSON ({command, cwd, description}). Resolve every presentation path through the shared toolNameAliases module: - getToolPresentation resolves the alias before the knownTools lookup, so lowercase ids get the canonical icon/title/subtitle. - The terminal title prefers the invocation's own description field (OpenCode bash carries the model's command summary there) over an ACP title that merely repeats the tool name, then falls back to the formatted command and, for complex commands, the localized tool.semanticTitle.runShell label. Cards without any command keep the plain Terminal fallback. - The ToolCard input renderer renders the Command code block for the resolved Bash/CodexBash names, matching how Codex already hides the cwd and description keys from the input display. - TERMINAL_RELATED_TOOL_NAMES lists canonical names only; the display helpers resolve the incoming name first (OpenCode bash -> Bash). Exact-name lookups still win everywhere, so Claude, Codex, Gemini, agy and the v1 lowercase read alias render exactly as before. * fix(web): render shell-shaped unknown-tool cards like the terminal cards Live wire capture of OpenCode v2.2.5 shows running updates carry the raw command as the ACP title, so the final tool-call name is the command string ("ls") rather than the bash id — and Gemini ACP names shell calls after the command too. Those names never match the alias table, so they fell through to the generic wrench card and dumped raw input JSON ({command, description, cwd}) in the dialog. Route shell-shaped cards through the terminal presentation: - getToolPresentation falls back to the Bash presentation (TerminalIcon, description-first title, command subtitle) when the input carries a command, so an ACP title that merely repeats the command no longer promotes to the generic 'Run shell' label — the formatted command (or the invocation description) becomes the title instead. - renderToolInput switches from the canonical-name comparison to the existing isTerminalToolBlock predicate, which classifies these cards as 'command' via their execute native kind. Their input renders as the same Command code block as Codex, with cwd/description omitted. The transient pending card OpenCode emits before the command is known (name 'shell', input {cwd} only) keeps the generic fallback: it has no command to show yet and is replaced by the command-name card once the running update arrives. * fix(web): route shell-shaped card results through the terminal result view OpenCode command-name cards ("ls") resolved to GenericResultView: their result text rendered as generic markdown, collapsing the output onto one line and autolinking file names, while the canonical Bash card shows the same output in the terminal code block with line breaks preserved. getToolResultViewComponent takes the block now and, after the exact-name and alias lookups miss, falls back to the Bash result view when the block is terminal-shaped (isTerminalToolBlock). The predicate itself moves to chat/toolGroups.ts next to getToolGroupActionKind, which drives it, so the result registry can import it without a component cycle; ToolCard.tsx re-exports it for its existing consumers. Call sites (card, detail dialog, trace child rows) pass their block. Cards whose name already resolves to a dedicated view (OpenCode grep/glob/list via the alias table, CodexBash, exact names) keep that view; only unknown shell-shaped names change.
hapi-web
React Mini App / PWA for monitoring and controlling hapi sessions.
What it does
- Session list with status, pending approvals, todos, and summaries.
- Chat view with streaming updates and message sending.
- Permission approval and denial workflows.
- Codex
request_user_inputchoices honorisOther: None of the above focuses optional notes, supports empty notes, and preserves the canonical wire value across languages. Recorded other answers and notes remain visible in live and historical cards; Pi/MCP forms without the flag are unchanged. - Permission mode and model selection.
- Machine list and remote session spawn.
- File browser and git status/diff views.
- PWA install prompt and offline banner.
- Optional unread-session count on the Windows taskbar when installed as an Edge/Chrome PWA (toggleable in Display settings; off by default).
Runtime behavior
- When opened inside Telegram, auth uses Telegram WebApp init data.
- When opened in a normal browser, you can log in with
CLI_API_TOKEN:<namespace>(orCLI_API_TOKENfor the default namespace). - The login screen includes a top-right hub picker; if unset, the app uses the same origin it was loaded from.
- Live updates come from the hub via SSE.
- Session
@suggestions require conversation content, including untitled conversations. Names and directory labels affect display/search, not eligibility; empty stubs stay excluded. See the session list behavior guide for search and picker rules.
Routes
See src/router.tsx for route definitions.
/- Redirect to /sessions./sessions- Session list./sessions/$sessionId- Chat interface./sessions/new- Create new session./sessions/$sessionId/files- File browser with git status./sessions/$sessionId/file- File viewer with diff support./sessions/$sessionId/terminal- Terminal interface./browse- Workspace browser, enabled by the runner's configured workspace roots./share- Share-target landing (Web Share Target POST →?id=, or native/share#url=&text=&title=)./settings- Settings category hub (mobile) and responsive master-detail shell./settings/general- Language preferences./settings/display- Appearance, typography, colors, and session list preferences./settings/chat- Message input, concise view, tool card, and conversation color preferences./settings/voice- Everyday voice assistant preferences./settings/voice/voices- Full-page voice picker./settings/voice/advanced- Voice persona, tuning, and diagnostics./settings/machines- Machine management and runner status./settings/storage- SQLite storage sizes for the hub owner./settings/usage- Cache-aware token usage dashboard for the hub owner./settings/about- Application links and version information.
Features
Session list (src/components/SessionList.tsx)
- Active/inactive status indicator.
- Session title from name, summary, or path.
- Todo progress display.
- Pending permission request count.
- Agent name and model display.
- Metadata search with relevance ranking, wildcard matching, and date/unread/machine filters.
- Stable user-input ordering across sessions and machine/project groups; agent output and status updates do not reorder ordinary rows.
- Machine/project grouping, pinned and in-progress sections, and configurable collapsed previews.
Session title lock
The rename dialog has a per-session lock beside the title input. New and existing sessions are unlocked by default. Saving a manual name does not automatically lock it: agents may still rename an unlocked session. Locking prevents agent title updates; users can still edit or generate a title and save it while locked. Save applies the title and lock together; Cancel discards both changes. Unlocking allows future agent title updates without immediately changing the current title. The Hub persists and enforces the lock across clients, restarts, and resume.
Chat interface (src/components/SessionChat.tsx)
- Message thread with infinite scroll.
- Concise view (header toggle or
/settings/chat, per device): shows only user input and each round's final reply (src/chat/conciseView.ts). Permission requests, questions, plan proposals, user shell commands, and errors stay visible; the full thread returns while a search target is active. - Composer for sending messages.
- Permission mode and model selection for supported agents.
Cursor Auto uses CLI Auto for new/resumed sessions configured with Auto. Switching a live session to Auto when ACP does not advertise a literal Auto option relaunches the Cursor ACP process in place under
--model autowhile preserving the hub session id. - Session abort and handoff controls.
- Codex Continue planning hides the current proposal's action menu locally and focuses the composer without sending a message or replacing its draft. The plan document remains readable; recycled cards stay dismissed and new proposals get fresh action menus.
- Context size display.
- Per-session scratchlist (
src/components/AssistantChat/ScratchlistPanel.tsx)- Workbench panel for held notes/drafts; distinct from the queue.
- Add/delete/reorder entries; promote to composer (copy) or queue (send).
- Entries and attachments saved on the hub and synced across devices.
- Reordering affects only the current view and resets when entries refresh.
- Keyboard shortcut: Ctrl/Cmd+Shift+S to focus the add-input.
File browser (src/routes/sessions/files.tsx)
- Git status view (staged/unstaged files).
- File search with ripgrep.
- Navigate to file viewer.
File viewer (src/routes/sessions/file.tsx)
- File content display with syntax highlighting.
- Staged/unstaged diff view.
Terminal (src/routes/sessions/terminal.tsx)
- Remote terminal via xterm.js
- Real-time via Socket.IO
/terminal - Resize handling
Voice assistant
- ElevenLabs (@elevenlabs/react), Gemini Live, and Qwen Realtime backends
- Real-time voice control
- Standard and realtime composer dictation with provider capability selection
New session (src/components/NewSession/)
Modular session creation:
- Machine selector
- Directory input with recent paths. The path tail is revealed after loading or selecting a path and after leaving the editor. Unfocused inputs support horizontal touch scrolling; focused inputs retain native editing and text selection.
- Agent type selector
- Model selector
- Per-agent permission, effort, and collaboration controls when supported
First-User-Experience (FUE)
For a new, non-essential feature whose affordance would otherwise be hard to discover, consider the existing FUE primitive rather than a permanent UI block. Optional, not a requirement for every feature or a reason to expand a bug fix.
src/lib/use-fue.ts:useFue(featureId)returns{ status, engage, dismiss }; acknowledgement is isolated per feature inhapi.fue.v1.<featureId>localStorage keys.src/components/Fue.tsx:FueDotmarks the affordance;FueCalloutexplains it whilestatus === 'engaging'.- Dismissal requires an affirmative user action ("Got it"), never an auto-timeout.
- The FUE dot and feature-specific badges/counters are mutually exclusive; onboarding wins until acknowledged.
- Opt in per feature; skip the wrapper if an upstream component already supplies onboarding.
- Working example:
ScratchlistToggleButtoninsrc/components/AssistantChat/ComposerButtons.tsx. Use the source rather than maintaining a copied example here.
Authentication
See src/hooks/useAuth.ts and src/hooks/useAuthSource.ts.
- Telegram Mini App: Uses initData from WebApp SDK.
- Browser: Uses CLI_API_TOKEN from login prompt.
- JWT tokens with auto-refresh.
Data fetching
See src/hooks/queries/ for query hooks and src/hooks/mutations/ for mutations.
- Sessions, messages, machines via TanStack Query.
- Git status and file operations.
- Optimistic updates for message sending.
Real-time updates
See src/hooks/useSSE.ts.
- SSE connection to
/api/events. - Session/message/machine update events.
- Automatic cache invalidation on events.
Stack
React 19 + Vite + TanStack Router/Query + Tailwind + @assistant-ui/react + xterm.js + @elevenlabs/react + socket.io-client + workbox + shiki.
Source structure
src/router.tsx- Route definitions.src/components/- UI components.src/hooks/- Data fetching and state hooks.src/api/client.ts- API client.src/types/api.ts- Type definitions.
Development
From the repo root:
bun install
bun run dev:web
If testing in Telegram, set:
HAPI_PUBLIC_URLto the public HTTPS URL of the dev server.CORS_ORIGINSto include the dev server origin.
Tests
Unit tests run under vitest + jsdom:
bun run test:web
End-to-end browser tests for the scratchlist component (real Chromium, real
inert focus blocking, real localStorage round-trips) live at the repo root
under e2e/:
bun run test:e2e # headless
bun run test:e2e:ui # Playwright UI mode (debug)
The spec drives a Vite-served fixture page (web/e2e-fixtures/scratchlist-fixture.html)
that mounts the production ScratchlistPanel in isolation, so no hub /
auth / socket setup is required.
Build
bun run build:web
The built assets land in web/dist and are served by hapi-hub. The single executable can embed these assets.
Standalone hosting
You can host web/dist on a static host (GitHub Pages, Cloudflare Pages) and point it at any hapi hub:
- Build the web app. If your static host uses a subpath, set the Vite base:
bun run build:web -- --base /<repo>/
- Deploy
web/distto your static host. - Set hub CORS to allow the static origin (
HAPI_PUBLIC_URLorCORS_ORIGINS). - Open the static site, click the top-right Hub button on the login screen, and enter the hapi hub origin.
Clear the hub override in the same dialog to return to same-origin behavior.