Changeset 0.22.5 (#147)

Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit is contained in:
2026-03-03 09:58:23 +00:00
committed by xcaliber
parent 3953dcf364
commit 45fe965c32
32 changed files with 3021 additions and 11 deletions

View File

@@ -2,6 +2,47 @@
All notable changes to Chat Switchboard.
## [0.22.5] — 2026-03-03
### Added
- **Go template engine.** Server-side HTML rendering via `html/template` with `//go:embed` for compiled-in templates. Custom `FuncMap` with helpers (`roleFilterType`, `toJSON`, `hasPrefix`, `dict`). CSP nonce generation per request. Replaces monolithic `index.html` + client-side DOM construction with composable, server-rendered surfaces.
- **Surface architecture.** Each page route renders a dedicated surface template that owns its full layout below the classification banner. Surfaces compose from reusable components (`model-select`, `team-select`, `file-upload`) without sharing CSS layout rules. Banner height handled via CSS custom properties (`--banner-top-h`, `--banner-bot-h`, `--surface-h`).
- **Chat surface.** Server-rendered shell at `/` and `/chat/:chatID`. Go template renders banner + layout + script tags; existing JS builds DOM inside the container. Bridge pattern preserves all current chat functionality.
- **Admin surface.** Full admin panel at `/admin/:section` with 5 category tabs (People, AI, Routing, System, Monitoring) and section sidebar. Server-rendered pages for providers, models, teams, users, and settings. Hybrid fallback for JS-loaded sections (groups, presets, knowledge, memory, health, capabilities, extensions, storage, usage, audit, stats).
- **Editor surface.** Server-rendered layout shell at `/editor/:wsId` with proper CSS height ownership. `mountServerRendered()` method on `EditorMode` bypasses the Surfaces registry for Go template mode. Dedicated CSS owns full viewport below banners — no layout collision with other surfaces. **(Fixes bugs #4, #5: editor layout collapse)**
- **Notes surface.** Server-rendered layout at `/notes/:noteId` with notes-main + notes-assist split. Boot script calls `openNotes()` in standalone mode. Responsive: assist pane hidden on mobile.
- **Settings surface.** Full-page settings at `/settings/:section` replacing modal-based settings. Left nav with all sections (general, appearance, providers, models, presets, roles, knowledge, memory, notifications, usage). General and Appearance sections server-rendered with form controls; dynamic sections populated by existing JS.
- **Login page.** Standalone Go template at `/login` with cookie-based auth. Sets `redirect_after_login` cookie for post-login navigation.
- **`AuthOrRedirect` middleware.** Cookie-based JWT validation for page routes. Reads `sb_token` cookie, redirects to `/login` on missing/invalid token (instead of 401 JSON). `RequireAdminPage()` helper aborts with 403 for non-admin users. Skips auth entirely in unmanaged mode.
- **Cookie-based auth sync.** `api.js` `saveTokens()` now sets `sb_token` cookie alongside localStorage on every token save/refresh. `clearTokens()` clears the cookie. Bridges API auth (Bearer header) with page auth (cookie).
- **Reusable `model-select` component.** Go template partial renders `<select>` with models filtered by type. Server passes filtered list; client-side cascade handler re-filters from `window.__PAGE_DATA__.models` on provider change. **(Fixes bug #1: admin model roles missing embedding models)**
- **Reusable `team-select` component.** Go template partial renders team dropdown with pre-populated options from server data loader. **(Fixes bug #2: routing policy team scope as text field)**
- **Reusable `file-upload` component.** Go template partial for drop zone + file picker. Used by editor surface.
- **Editor file upload.** Upload button in editor toolbar + drag-and-drop on file tree with visual feedback. `API.uploadWorkspaceFile()` sends File objects as raw body to existing `WriteFile` handler (binary-safe, respects workspace quota). Auto-opens single uploaded text files. **(Fixes bug #3: unable to upload files to a project)**
- **Page route data loaders.** Each surface registers a loader that pre-fetches exactly what its template needs: `chatLoader`, `adminLoader` (with section-specific data), `editorLoader`, `notesLoader`, `settingsLoader`. No over-fetching, no client-side fetch waterfall.
- **Admin provider CRUD.** Server-rendered provider table with add/edit form, type dropdown, sync button. Client-side handlers for create, update, delete, sync operations.
- **Admin model table.** Server-rendered catalog table with client-side search + type/provider filters.
- **Admin user management.** Server-rendered user table with search, role edit, enable/disable toggles.
- **Admin settings page.** Registration policy, permissions, banner config, and system prompt — all server-rendered with save handlers.
- **`pages.js` client handlers.** Role CRUD, routing policy CRUD, provider/model/team/user management, settings save — all working against existing API endpoints with proper token resolution.
### Changed
- `nginx.conf`: Added page route proxy blocks (`/`, `/login`, `/chat`, `/admin`, `/editor`, `/notes`, `/settings`) before SPA fallback. Static assets still served directly by nginx. Removed `/legacy` proxy block.
- `server/main.go`: Template engine init, `pages.SetVersion()`, route wiring for all surfaces with auth middleware groups. Removed `/legacy` fallback route.
- `src/js/api.js`: `saveTokens()` / `clearTokens()` sync `sb_token` cookie. New `uploadWorkspaceFile()` method for binary file upload to workspaces.
- `src/js/editor-mode.js`: Upload button + hidden file input in header. Drag-and-drop on file tree container with `.drag-over` visual state. `_uploadFiles()` method with text-file auto-open. `mountServerRendered()` for Go template boot path.
- `src/css/editor-mode.css`: `.drag-over` style for file tree drop target.
### Fixed
- **Bug #1**: Admin model roles now show embedding models. Server-side `roleFilterType()` sets `FilterType="embedding"` for the embedding role; `model-select` component filters by `model_type`.
- **Bug #2**: Routing policy team scope uses proper dropdown instead of free-text field. `adminLoader` pre-fetches team list; `team-select` component renders options.
- **Bug #3**: Editor file upload works. Upload button + drag-and-drop + `uploadWorkspaceFile()` API method.
- **Bug #4**: Editor chat assist pane is functional. Server-rendered layout with dedicated mount points.
- **Bug #5**: Editor and chat pane no longer squashed. Each surface owns its full viewport height via dedicated CSS — no shared flex container conflicts.
### Removed
- `/legacy` route and nginx proxy block. All page routes are now server-rendered.
## [0.22.4] — 2026-03-02
### Added