fix(backend): forward workspace to tht config selection (MVP backend-side)

POST /sessions no longer silently drops `workspace`. ThtRunner.run/json
take an optional workspace; configArg() selects workspaces/<ws>.yaml when
it exists under harnessDir, else falls back to default configPath.
sessionNew threads workspace through. Route forwards b.workspace with an
MVP note (gate/Pi side still single-workspace via symlinked config/tht.yaml).

19/19 tests pass, tsc clean.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-27 21:26:09 +02:00
co-authored by Claude Sonnet 4.6
parent b4b26e313b
commit 061002f85c
4 changed files with 61 additions and 9 deletions
+5 -1
View File
@@ -7,7 +7,11 @@ import { getUser } from "../auth/auth.js";
export function sessionRoutes(app: FastifyInstance, d: { mgr: PiProcessManager; tht: ThtRunner; hub: SseHub }) {
app.post("/sessions", async (req, reply) => {
const b = req.body as any;
const { id } = await d.tht.sessionNew({ question: b.question, provider: b.provider, model: b.model, thinking: b.thinking, name: b.name });
// NOTE (MVP): `workspace` selects the tht `-c <config>` for the backend's own
// tht calls (session new/list/show). The gate/Pi side still uses the symlinked
// `config/tht.yaml` (single-workspace). Full multi-workspace on the Pi side is
// future work — the gate would need a THT_CONFIG/workspace env passed at spawn.
const { id } = await d.tht.sessionNew({ question: b.question, provider: b.provider, model: b.model, thinking: b.thinking, name: b.name, workspace: b.workspace });
const rt = await d.mgr.spawnFor(id, { provider: b.provider, model: b.model, thinking: b.thinking, author: getUser(req).id });
rt.bridge.onClientEvent((e) => d.hub.publish(id, e.type, e));
return { id };