blob: 90e88778e85798f96ce0579599c2ff33c5998cd8 [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 Rule07e98cc2025-05-07 16:01:33 +010032make dev
Earl Lee2e463fb2025-04-17 11:22:22 -070033```
34
Pokey Rule07e98cc2025-05-07 16:01:33 +010035This will launch a local web server at http://127.0.0.1:5173/ that serves the demo pages for the web components. You can edit the TypeScript files, and the changes will be reflected in real-time.
36
37To access the main app shell interface on the dev server (the primary UI component for Sketch):
38
391. Start the dev server as above
402. Navigate to http://127.0.0.1:5173/src/web-components/demo/sketch-app-shell.demo.html
41 or click on the "sketch-app-shell" link from the demo index page
42
43### UI Component Demos
44
45The development server provides access to individual component demos including:
46
47- Main app shell: http://127.0.0.1:5173/src/web-components/demo/sketch-app-shell.demo.html
48- Chat input: http://127.0.0.1:5173/src/web-components/demo/sketch-chat-input.demo.html
49- Timeline: http://127.0.0.1:5173/src/web-components/demo/sketch-timeline.demo.html
50- And more...
51
52You can access these demos from the index page or navigate directly to the specific component demo URL.
Pokey Rule4de8a912025-04-25 21:01:30 +010053
Pokey Rulee2a8c2f2025-04-23 15:09:25 +010054#### VSCode
55
56If 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 -070057
58## Integration with Go Server
59
60The 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.
61
62The server code accesses the built web UI through the `webui.GetBundle()` function, which returns a filesystem that can be used to serve the files.
63
64## File Structure
65
66- `src/`: TypeScript source files
67- `dist/`: Generated JavaScript bundle
68- `esbuild.go`: Go code for bundling TypeScript files
69- `Makefile`: Build tasks
Sean McCullough86b56862025-04-18 13:04:03 -070070
71## Bundle Analysis
72
73You can analyze the size and dependency structure of the TypeScript bundles:
74
75```bash
76# Generate bundle metafiles in a temporary directory
77go run sketch.dev/cmd/bundle-analyzer
78```
79
80The tool generates metafiles that can be analyzed by dragging them onto the esbuild analyzer at https://esbuild.github.io/analyze/