blob: 49ca0e8935c914b4ab96b34467a9d504b5cb4fee [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
Earl Lee2e463fb2025-04-17 11:22:22 -070023# Type checking only
24make 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.
36p
37
38#### VSCode
39
40If 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 -070041
42## Integration with Go Server
43
44The 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.
45
46The server code accesses the built web UI through the `webui.GetBundle()` function, which returns a filesystem that can be used to serve the files.
47
48## File Structure
49
50- `src/`: TypeScript source files
51- `dist/`: Generated JavaScript bundle
52- `esbuild.go`: Go code for bundling TypeScript files
53- `Makefile`: Build tasks
Sean McCullough86b56862025-04-18 13:04:03 -070054
55## Bundle Analysis
56
57You can analyze the size and dependency structure of the TypeScript bundles:
58
59```bash
60# Generate bundle metafiles in a temporary directory
61go run sketch.dev/cmd/bundle-analyzer
62```
63
64The tool generates metafiles that can be analyzed by dragging them onto the esbuild analyzer at https://esbuild.github.io/analyze/