diff --git a/.yoi/.gitignore b/.yoi/.gitignore index b6f03932..ef6e184d 100644 --- a/.yoi/.gitignore +++ b/.yoi/.gitignore @@ -1,2 +1,3 @@ /memory/ tickets/.ticket-backend.lock +/workspace.db* diff --git a/web/workspace/README.md b/web/workspace/README.md index 8fbb8038..8fc576ef 100644 --- a/web/workspace/README.md +++ b/web/workspace/README.md @@ -1,30 +1,69 @@ -# Workspace web SPA +# Workspace web UI -This is the static SvelteKit shell for the local Yoi Workspace control plane. -It is intentionally a read-only UI bootstrap: `.yoi/tickets` and -`.yoi/objectives` remain canonical, and the Rust backend owns all business/API -semantics. +SvelteKit static SPA for the Yoi workspace control plane. -Canonical frontend tooling: Deno. Dependency versions, tasks, and the committed -lockfile are managed by `deno.json` and `deno.lock`. +The frontend is intentionally static. Workspace authority, validation, and API behavior live in the Rust `yoi-workspace-server` backend. -`package.json` is intentionally kept only as minimal SvelteKit/Vite ecosystem -metadata (`type: module`, private package identity). It does not define scripts -or dependencies and is not the package-manager source of truth. +## Development -Commands: +Use two terminals from the repository checkout. -```sh -deno install -deno task check +Backend terminal: + +```bash +cd web/workspace +deno task dev:backend +``` + +Frontend terminal: + +```bash +cd web/workspace +deno task dev +``` + +The Vite dev server proxies `/api/*` to `http://127.0.0.1:8787`, so frontend hot reload works while the Rust backend serves the workspace API. Open the Vite URL printed by `deno task dev`. + +If you want to run the backend from the repository root instead: + +```bash +cargo run -p yoi-workspace-server -- serve \ + --workspace . \ + --db .yoi/workspace.db \ + --listen 127.0.0.1:8787 +``` + +## Static build served by Rust backend + +Build the SPA: + +```bash deno task build ``` -`deno task dev` and `deno task preview` are available for local frontend work. -Deno uses npm compatibility for the SvelteKit/Vite toolchain, so `node_modules/` -may be created as generated local state; do not check it in. +Then serve the static build and API from the Rust backend: -Build output is `web/workspace/build/` and is not checked in. Point the Rust -backend `ServerConfig.static_assets_dir` at that directory (or another static -asset directory) to serve the SPA. `node_modules/`, `.svelte-kit/`, and `build/` -are generated local state and must remain ignored/excluded from package sources. +```bash +cargo run -p yoi-workspace-server -- serve \ + --workspace ../.. \ + --db ../../.yoi/workspace.db \ + --frontend build \ + --listen 127.0.0.1:8787 +``` + +From the repository root, the equivalent command is: + +```bash +cargo run -p yoi-workspace-server -- serve \ + --workspace . \ + --db .yoi/workspace.db \ + --frontend web/workspace/build \ + --listen 127.0.0.1:8787 +``` + +## Checks + +```bash +deno task check +deno task build +``` diff --git a/web/workspace/deno.json b/web/workspace/deno.json index 018caee6..aaa013ca 100644 --- a/web/workspace/deno.json +++ b/web/workspace/deno.json @@ -4,6 +4,7 @@ "tasks": { "install": "deno install", "dev": "deno run -A npm:vite@7.2.7 dev", + "dev:backend": "cd ../.. && cargo run -p yoi-workspace-server -- serve --workspace . --db .yoi/workspace.db --listen 127.0.0.1:8787", "check": "deno run -A npm:@sveltejs/kit@2.49.4 sync && deno run -A npm:svelte-check@4.3.4 --tsconfig ./tsconfig.json", "build": "deno run -A npm:vite@7.2.7 build", "preview": "deno run -A npm:vite@7.2.7 preview" diff --git a/web/workspace/vite.config.ts b/web/workspace/vite.config.ts index 3406f32d..ef9074fe 100644 --- a/web/workspace/vite.config.ts +++ b/web/workspace/vite.config.ts @@ -2,5 +2,13 @@ import { sveltekit } from '@sveltejs/kit/vite'; import { defineConfig } from 'vite'; export default defineConfig({ - plugins: [sveltekit()] + plugins: [sveltekit()], + server: { + proxy: { + '/api': { + target: 'http://127.0.0.1:8787', + changeOrigin: true + } + } + } });