blob: 6a9e257c705f809da965a3652af660408e5dc41d [file] [log] [blame] [view]
Earl Lee2e463fb2025-04-17 11:22:22 -07001# Loop WebUI
2
3A modern web interface for the CodingAgent loop.
4
5The server in the sibling directory (../server) exposes an HTTP API for
6the CodingAgent.
7
8## Development
9
10This module contains a TypeScript-based web UI for the Loop service. The TypeScript code is compiled into JavaScript using esbuild, and the resulting bundle is served by the Go server.
11
12### Prerequisites
13
14- Node.js and npm
15- Go 1.20 or later
16
17### Setup
18
19```bash
20# Install dependencies
21make install
22
Pokey Rule4de8a912025-04-25 21:01:30 +010023# Run tests
Earl Lee2e463fb2025-04-17 11:22:22 -070024make check
25```
26
27### Development Mode
28
29For development, you can use watch mode:
30
31```bash
Pokey Rulee2a8c2f2025-04-23 15:09:25 +010032make demo
Earl Lee2e463fb2025-04-17 11:22:22 -070033```
34
Pokey Rulee2a8c2f2025-04-23 15:09:25 +010035This will launch a local web server that serves the demo pages for the web components. You can edit the TypeScript files, and the changes will be reflected in real-time.
Pokey Rule4de8a912025-04-25 21:01:30 +010036
Pokey Rulee2a8c2f2025-04-23 15:09:25 +010037#### VSCode
38
39If you are using Visual Studio Code, you can use the `Launch Chrome against localhost` launch configuration to run the demo server. This configuration is set up to automatically open a sketch page with dummy data in Chrome when you start debugging, supporting hot module reloading and breakpoints.
Earl Lee2e463fb2025-04-17 11:22:22 -070040
41## Integration with Go Server
42
43The TypeScript code is bundled into JavaScript using esbuild and then served by the Go HTTP server. The integration happens through the `webui` package, which provides a function to retrieve the built bundle.
44
45The server code accesses the built web UI through the `webui.GetBundle()` function, which returns a filesystem that can be used to serve the files.
46
47## File Structure
48
49- `src/`: TypeScript source files
50- `dist/`: Generated JavaScript bundle
51- `esbuild.go`: Go code for bundling TypeScript files
52- `Makefile`: Build tasks
Sean McCullough86b56862025-04-18 13:04:03 -070053
54## Bundle Analysis
55
56You can analyze the size and dependency structure of the TypeScript bundles:
57
58```bash
59# Generate bundle metafiles in a temporary directory
60go run sketch.dev/cmd/bundle-analyzer
61```
62
63The tool generates metafiles that can be analyzed by dragging them onto the esbuild analyzer at https://esbuild.github.io/analyze/