forked from bots-garden/ori
| ✨ Introduce new feature(s): ACP web client — Go backend (agent, bridge, httpserver, mockagent) + React SPA (Zed-like agent panel), tests, quality gate PASS | 1 | // Package ui embeds the production build of the single-page application so |
| 2 | // the ori server ships as a single binary. | |
| 3 | // | |
| 4 | // The Vite build writes to ui/dist (run `make build-ui`). When dist only | |
| 5 | // contains the committed .gitkeep placeholder, the server still compiles and | |
| 6 | // answers with an explanatory error page instead of the SPA. | |
| 7 | package ui | |
| 8 | ||
| 9 | import ( | |
| 10 | "embed" | |
| 11 | "io/fs" | |
| 12 | ) | |
| 13 | ||
| 14 | //go:embed all:dist | |
| 15 | var dist embed.FS | |
| 16 | ||
| 17 | // Dist returns the embedded SPA build as a filesystem rooted at the dist | |
| 18 | // directory, i.e. index.html lives at the root of the returned fs.FS. | |
| 19 | // | |
| 20 | // Example: | |
| 21 | // | |
| 22 | // http.Handle("/", http.FileServerFS(ui.Dist())) | |
| 23 | func Dist() fs.FS { | |
| 24 | sub, err := fs.Sub(dist, "dist") | |
| 25 | if err != nil { | |
| 26 | // The dist directory is embedded at compile time; its absence is a | |
| 27 | // build-system bug, not a runtime condition a caller could handle. | |
| 28 | panic(err) | |
| 29 | } | |
| 30 | return sub | |
| 31 | } |