web: review fixes for projects/stats SPA routes
- ProjectsTable: drop the inner navigate call from handleOpen;
the parent route already navigates via the onOpen callback,
so the second push was creating a duplicate history entry
on every row click. Matches the SessionsTable pattern.
- HorizontalBars: replace href:string with onActivate(row)
callback. The earlier shape passed a pre-encoded path
string straight into TanStack <Link to={...}>; routing the
navigation through the typed (to, params) form via the
caller avoids any double-encoding ambiguity around splat
params and decouples the primitive from a specific route.
- stats.css: drop duplicated .card / .card-head / .card-body
blocks. The same rules already live in shell.css (loaded
globally), so any future divergence between the two copies
would silently desync.
web: regenerate embedded SPA bundle for stats route
Vite stamps content-hash asset filenames; the Phase 5 source changes
flipped both bundle hashes. The Phase 5 commit (e048bdf) shipped the
source but not the regenerated index.html, which the Go server embeds
via embed.FS to serve the SPA. Re-stage so the embedded asset path
matches the actual bundle on disk.
web: stats route with backend-driven chart primitives
web: project detail route scoped via ?cwd= sessions filter
web: projects index route with real /projects data
stats: add /api/v1/stats aggregate endpoint
Implements Phase 2 of lethe-web-ui-aggregates: a single-round-trip
/api/v1/stats endpoint that bundles per-tool rollup, daily time-series,
84-cell activity heatmap, top-cwd ranking, hour-of-day distribution, and
host split. All six aggregations run fresh per request; no server cache.
- internal/domain/stats/buckets.go: pure helpers DailyWindow, FillDaily,
HeatmapWindow, HourWindow — fully deterministic, tested independently.
- internal/domain/stats/repository.go: Filter/Stats types and Repository.Stats
— six SQL queries joined via sessions+turns, owner scope via OwnerScope
(AllOwners / SpecificOwner / default), sparkline capped at 60 buckets.
- internal/domain/stats/handler.go: Handler.List — ?range=7d|30d|90d|all
(default 30d); ?range=<other> → 400 INVALID; ?owner= non-admin → 403.
- internal/server/server.go: register *stats.Handler alongside project/sessions.
- cmd/lethe/main.go: add statsRepo/statsHnd to var block and steward graph.
- cmd/lethe/main_e2e_test.go: add stats.Repository/Handler to e2e graph.
project: add /api/v1/projects aggregation; sessions: add ?cwd= filter
- session.ListFilter gains Cwd *string; List appends working_dir = ?
clause between Host and Since in fixed order (parameterised, column
name is a literal)
- session.Handler reads ?cwd= and threads it to filter.Cwd; empty
string treated as absent, consistent with other optional filters
- new package internal/domain/project:
- Repository.List groups sessions by non-NULL working_dir in a single
SQL round-trip; correlated subquery picks top_tool with tie-broken
by tool ASC; Hosts/Tools deduped and sorted in Go after
GROUP_CONCAT
- Handler mounts GET /projects; resolveScope/clampLimit/clampOffset
duplicated from session handler; ?owner= admin gating identical
- server.Server gains Projects *project.Handler inject field; mounted
in /api/v1 Route block
- main.go and e2e test register projectRepo + projectHnd with steward
docs(lethe-web-ui-aggregates): add implementation plan
docs: add roadmap TODO and lethe-web-ui-aggregates design
TODO.md indexes all 9 task specs (4 done/in-progress, 5 deferred or
blocked) plus the carry-overs from the foundation Conclusion. New task
file lethe-web-ui-aggregates covers the backend /projects + /stats
endpoints and the three frontend screens (Projects index, Project
detail, Stats), replacing three of the foundation's stub routes.
docs(lethe-web-ui-foundation): record review conclusion, mark Reviewed
Two Important findings from the independent review pass were resolved:
keyboard g-leader / palette-input interference (4ef7a02), and Dockerfile
web-builder path fragility plus uncovered Go-1.26 requirement (0cf348a).
Future work captured: composite-id URL, aggregates absent on Get, Turn
meta-line timestamp, stray flatted/ Go package. CI config remains
deferred pending user choice between .github/ and .sourcecraft/.
docker: stabilize web-builder paths and bump builder Go to 1.26
Two related Dockerfile correctness fixes uncovered while validating the
review pass:
1. The web-builder stage used WORKDIR /web with vite's relative
outDir ../internal/server/web/dist resolving to /internal/server/web/dist
at the container root — working only by relative-path coincidence.
Mirror the host repo layout inside /src so the path is /src/internal/server/web/dist
in both stages, making the COPY --from explicit and stable against any
future WORKDIR or outDir change.
2. golang:1.25-alpine no longer compiles the codebase: the auxilia/culpa
dep uses errors.AsType which is in 1.26+. Bump the builder image to
golang:1.26-alpine and the go.mod directive from 1.25.0 to 1.26.0
so they agree on the actual minimum.
Verified: docker build (full multi-stage) green; produced binary runs.
keyboard: guard g-leader and j/k against palette and editable targets
Add an early return after the ⌘K and Esc handlers so the g-prefix
dispatch, g-start, j/k cursor, and Enter activation skip when the
palette is open or the focused element is an input/textarea/contenteditable.
Without it, typing "gh" into the palette search input fires go("home")
mid-query, navigating away while the palette stays open.
Two regression tests added: g+h with palette open → no navigation; g
on a focused input → no pending state, follow-up h does nothing.
docs(lethe-web-ui-foundation): record verify section, mark Verified
End-to-end browser smoke confirmed shell, Home (with real ingested data
showing all aggregate columns), Session view (markdown rendering, role
glyphs, breadcrumb), ⌘K palette, tab navigation. Three minor follow-ups
captured in Notes (composite-id URL encoding, zero aggregates on Get
path, stray flatted Go package in npm dep).
docs(lethe-web-ui-foundation): record execute deviations across all 6 phases
All six phases implemented, signed, and tested green. Backend aggregates
(Phase 1) ship a strict superset of the prior /api/v1/sessions response.
Web SPA (Phases 2-6) is embedded into the Go binary; vite dev mode
proxies the API with a Remote-User header injection so forward-auth
passes without a real reverse proxy. Status flipped to "Execute (verify
pending)" pending up:uverify.
web: session view with turn list and transcript
Phase 6: replace the placeholder session route with the real implementation.
Adds useSession hook (TanStack Query), TurnList aside, Transcript with
react-markdown rendering, session.css, and the updated session route with
SubBar breadcrumb, error/loading states, and turn selection/scroll.
web: home route with real session list, filters, keyboard cursor
- api/client.ts: apiFetch with AuthError/APIError, 401 and problem+json handling
- api/adapters.ts: SessionDTO→Session adapter with composite id and epoch conversion
- api/adapters.test.ts: 6 TDD tests covering all specified edge cases
- features/home/useSessions.ts: TanStack Query hook with since/tool/host params
- features/home/FilterChips.tsx: chip-bar with popovers, Esc/outside-click dismiss
- features/home/SessionsTable.tsx: grid table with cursor row highlight, formatStarted/formatTok
- features/home/useHomeCursor.ts: cursor hook with move/activate/jumpTo
- routes/index.tsx: Home route wired to real data, URL-driven filters, keyboard cursor
- routes/__root.tsx: cursorRef + KeyboardCursorContext for route-local cursor registration
- routes/session.$tool.$host.$id.tsx: stub for Phase 6
- styles/home.css: .home-table/.home-thead/.home-row/.home-row.cursor grid rules
- primitives/ToolDot.tsx: widened tool prop to string (Tool type is open-ended)
web: shell, theme, keyboard, stub routes, palette skeleton
- lib/theme.ts: bootstrapTheme() + setTheme() with OS/localStorage sync
- lib/keyboard.ts: g-prefix nav, j/k cursor, ⌘K palette, Esc, Enter
- lib/theme.test.ts + lib/keyboard.test.ts: 26 vitest tests (TDD)
- shell/TopBar.tsx: brand crumb, search trigger, tab nav using router pathname
- shell/SubBar.tsx: slot component with optional right section
- shell/Palette.tsx: modal overlay, JUMP items, synthetic SEARCH row
- styles/shell.css + styles/palette.css: ported verbatim from prototype.css
- routes/__root.tsx: wires TopBar, Outlet, Palette, keyboard controller, bootstrapTheme
- routes/index.tsx + projects/stats/health/settings/search.tsx: EmptyState stubs
- main.tsx: replace scaffold div with RouterProvider
- vitest.config.ts: add jsdom url for localStorage support (Node 25 compat)
server: embed web SPA at /, wire build pipeline
- Add internal/server/web/embed.go with //go:embed all:dist and a
SPA fallback shim: file-not-found → serve index.html at 200.
- Commit dist/.gitkeep and dist/index.html (placeholder) so go build
works on a fresh clone; real build output stays gitignored.
- Mount web.Handler() as GET /* catch-all in server.go after /api/v1
so API routes and probe endpoints shadow the wildcard.
- Add three server tests: ServesSPAAtRoot, SPAFallbackForNonAPIPath,
APIPathsBypassSPA; update NotFoundReturnsProblemJSON for SPA era.
- Extend Justfile with web-{install,dev,build,test,lint,clean} targets;
build now depends on web-build.
- Add node:20-alpine web-builder stage to Dockerfile; COPY dist into
the Go builder stage before compiling.
web: scaffold vite/react/ts project, port design tokens and primitives
- package.json with runtime (react, tanstack-query, tanstack-router) and
dev deps (vite, typescript, vitest, eslint, prettier, testing-library)
- vite.config.ts: @vitejs/plugin-react + TanStack Router file-based plugin;
dev proxy for /api/v1, /healthz, /readyz, /metrics with Remote-User header;
build.outDir set to ../internal/server/web/dist (Go embed target)
- tsconfig.json (strict, ES2022, react-jsx, bundler resolution) + tsconfig.node.json
- .eslintrc.cjs (eslint 8 + @typescript-eslint + react-hooks), .prettierrc (single quotes, no semis)
- index.html: Inter + JetBrains Mono fonts, body.density-compact, #root mount
- src/main.tsx: React root with QueryClientProvider, temporary scaffold div
- src/styles/tokens.css: verbatim :root and [data-theme="dark"] blocks from prototype.css
- src/styles/primitives.css: .tag, .tooldot, .spark, .statusdot, .empty, .sub rules
- src/primitives/{Tag,ToolDot,Spark,StatusDot,EmptyState,Sub}.tsx with typed signatures
- src/primitives/index.ts re-exports all primitives
- web/.gitignore: node_modules/, coverage/
- root .gitignore: web/node_modules/, internal/server/web/dist/* with .gitkeep exception
- vitest.config.ts separate from vite to avoid router plugin scan error on empty routes dir
- src/routes/__root.tsx minimal root route to satisfy TanStack Router plugin at build time
session: extend List response with summary, turn_count, token totals, model
Add five aggregate fields to Session struct (Summary, TurnCount,
TokensInTotal, TokensOutTotal, Model) populated via a new
sessionListSelectColumns const that wraps correlated subqueries.
List uses the new const; Get is unchanged.
TestList_Aggregates covers: zero turns, long-content truncation to 200
chars, mixed-role model tracking (newest turn wins), and NULL token sums.