2026-06-16 19:52:16 +08:00
# nanobot WebUI Source
2026-04-18 18:51:53 +00:00
2026-10-10 11:48:50 +08:00
This directory contains the React/TypeScript source for the nanobot WebUI. If you installed `nanobot-ai` from PyPI and only want to use the bundled browser UI, read the user guide in [`docs/webui.md` ](../docs/webui.md ). You do not need Node.js, Bun, Vite, or anything in this directory unless you are changing the frontend.
2026-04-19 13:10:36 +00:00
2026-06-10 00:36:22 +08:00
For the project overview, install guide, and general docs map, see the root [`README.md` ](../README.md ) and [`docs/README.md` ](../docs/README.md ).
## Pick a Path
| Goal | Start with | Opens at |
|---|---|---|
2026-06-16 19:52:16 +08:00
| Use the bundled browser UI | [`docs/webui.md` ](../docs/webui.md ) | `http://127.0.0.1:8765` |
| Use the WebUI from another device | [`docs/webui.md#lan-access` ](../docs/webui.md#lan-access ) | `http://<your-ip>:8765` |
2026-06-10 00:36:22 +08:00
| Change WebUI source code | [Develop the WebUI (Vite HMR) ](#develop-the-webui-vite-hmr ) | `http://127.0.0.1:5173` |
| Debug setup failures | [`docs/troubleshooting.md#webui-problems` ](../docs/troubleshooting.md#webui-problems ) | Diagnosis order and common fixes |
2026-04-19 13:10:36 +00:00
2026-10-10 11:48:50 +08:00
The source app is built with Vite + React 18 + TypeScript + Tailwind 3 + shadcn/ui. It talks to the gateway over the WebSocket multiplex protocol and reads session metadata from the embedded REST surface on the same port.
2026-04-18 18:51:53 +00:00
## Layout
2026-04-19 13:10:36 +00:00
```text
2026-04-18 18:51:53 +00:00
webui/ source tree (this directory)
2026-04-21 14:33:44 +00:00
nanobot/web/dist/ build output served by the gateway
2026-04-18 18:51:53 +00:00
```
2026-05-16 13:38:11 +00:00
## Develop the WebUI (Vite HMR)
2026-04-19 13:10:36 +00:00
### 1. Install nanobot from source
From the repository root:
```bash
2026-06-10 00:36:22 +08:00
python -m pip install -e .
2026-04-19 13:10:36 +00:00
```
2026-05-16 13:38:11 +00:00
> Editable installs intentionally **skip** the WebUI bundle step — Vite HMR is faster than rebuilding `dist/` on every change.
2026-08-04 16:14:32 +08:00
### 2. Start the gateway and Vite
From the repository root:
```bash
nanobot webui --dev
```
2026-10-10 11:48:50 +08:00
The command safely prepares the local WebSocket channel, starts both the gateway and Vite, and opens `http://127.0.0.1:5173` . Vite proxies to the configured WebSocket channel and applies frontend changes with HMR. Press Ctrl+C in that terminal to stop both processes.
2026-08-04 16:14:32 +08:00
2026-10-10 11:48:50 +08:00
Use `--no-open` to skip opening a browser. `--dev` is foreground-only and cannot be combined with `--background` .
2026-08-04 16:14:32 +08:00
## Manual development setup
The two-terminal workflow remains available when you want to manage each process separately.
### 1. Enable the WebSocket channel
2026-04-21 12:46:17 +00:00
2026-06-10 00:36:22 +08:00
In `~/.nanobot/config.json` , merge:
2026-04-21 12:46:17 +00:00
```json
{ "channels" : { "websocket" : { "enabled" : true } } }
```
2026-08-04 16:14:32 +08:00
### 2. Start the gateway
2026-04-19 13:10:36 +00:00
In one terminal:
```bash
nanobot gateway
```
2026-08-04 16:14:32 +08:00
### 3. Start the WebUI dev server
2026-04-19 13:10:36 +00:00
In another terminal:
2026-04-18 18:51:53 +00:00
```bash
cd webui
bun install # npm install also works
2026-04-19 13:10:36 +00:00
bun run dev
2026-04-18 18:51:53 +00:00
```
2026-04-19 13:10:36 +00:00
Then open `http://127.0.0.1:5173` .
2026-04-18 18:51:53 +00:00
2026-05-16 13:38:11 +00:00
By default the dev server proxies `/api` , `/webui` , `/auth` , and WebSocket traffic to `http://127.0.0.1:8765` .
2026-04-18 18:51:53 +00:00
2026-04-19 13:10:36 +00:00
If your gateway listens on a non-default port, point the dev server at it:
2026-04-18 18:51:53 +00:00
```bash
NANOBOT_API_URL = http://127.0.0.1:9000 bun run dev
```
2026-04-19 13:10:36 +00:00
## Build for packaged runtime
2026-04-18 18:51:53 +00:00
2026-05-16 13:38:11 +00:00
You usually do not need to run this by hand: `python -m build` invokes the WebUI build automatically when packaging the wheel.
If you want to preview the production bundle locally without rebuilding the wheel:
2026-04-18 18:51:53 +00:00
```bash
2026-04-19 13:10:36 +00:00
cd webui
2026-05-16 13:38:11 +00:00
bun run build # writes to ../nanobot/web/dist
2026-04-18 18:51:53 +00:00
```
2026-05-16 13:38:11 +00:00
The gateway picks up the new bundle on the next restart.
2026-04-19 13:10:36 +00:00
2026-04-18 18:51:53 +00:00
## Test
```bash
2026-04-19 13:10:36 +00:00
cd webui
bun run test
2026-04-18 18:51:53 +00:00
```
2026-04-19 13:10:36 +00:00
## Acknowledgements
2026-06-10 00:36:22 +08:00
- [`agent-chat-ui` ](https://github.com/langchain-ai/agent-chat-ui ) for UI and interaction inspiration across the chat surface.