Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
chat: reopening a chat restores its workspace and the turn runs in that folder (#3754)
Niko12211d20d3e2b063
diff --git a/apps/host/src/lib/session-workspace.ts b/apps/host/src/lib/session-workspace.tsnew file mode 100644index 000000000..9c7752cba--- /dev/null+++ b/apps/host/src/lib/session-workspace.ts@@ -0,0 +1,8 @@+import type { Session, Workspace } from './types';++/** The workspace a chat was made in: the sidebar groups chats by this same rule (the saved path, or an earlier folder of the workspace). */+export function workspaceIdForSession(workspaces: Workspace[], session: Pick<Session, 'workspace'> | null | undefined): string | null {+ const path = session?.workspace;+ if (!path) return null;+ return workspaces.find(w => w.path === path || !!w.aliases?.includes(path))?.id ?? null;+}diff --git a/apps/host/src/lib/store.ts b/apps/host/src/lib/store.tsindex 7475e4dad..3449089ab 100644--- a/apps/host/src/lib/store.ts+++ b/apps/host/src/lib/store.ts@@ -1,3 +1,4 @@+import { workspaceIdForSession } from './session-workspace';import { plainFailure, plainFailureText } from './plain-errors';import { showcaseMessages, SHOWCASE_AGENTS } from './chat-showcase';import { updateAgent } from './agents';@@ -721,7 +722,7 @@ export async function bootstrap() {skills,workspacePath: workspaceState.workspaces[0]?.path ?? '',workspaces: workspaceState.workspaces,- activeWorkspace: workspaceState.workspaces.some(w => w.id === state.activeWorkspace) ? state.activeWorkspace : workspaceState.workspaces[0]?.id ?? null,+ activeWorkspace: workspaceState.workspaces.some(w => w.id === state.activeWorkspace) ? state.activeWorkspace : workspaceIdForSession(workspaceState.workspaces, state.sessions.find(s => s.id === state.activeSession)) ?? workspaceState.workspaces[0]?.id ?? null,connection: 'live',});applyProviders(providers);@@ -1104,7 +1105,11 @@ export function continueTaskInNewChat(task: Task) {}export function selectSession(id: string) {- set({ activeSession: id });+ // A chat comes back in the workspace it was made in, so its next turn runs in the same folder (#3754).+ const workspace = workspaceIdForSession(state.workspaces, state.sessions.find(s => s.id === id));+ const change = workspace && workspace !== state.activeWorkspace;+ set(change ? { activeSession: id, activeWorkspace: workspace } : { activeSession: id });+ if (change) void loadWorkspaceFiles();markRead(id);}@@ -1728,7 +1733,7 @@ export async function sendMessage(text: string, options: { fromLoop?: boolean; g// The Mode menu's choice for this chat, read when the turn starts; the host applies it to the agent.mode:state.sessions.find(s=>s.id===sessionId)?.preferences?.mode??'manual',// So a skill narrowed to another workspace does not fire here.- workspaceId: state.activeWorkspace,+ workspaceId: workspaceIdForSession(state.workspaces, state.sessions.find(s => s.id === sessionId)) ?? state.activeWorkspace,},(frame) => {// A line from the app itself carries `key` (the English sentence): shown in the person's language.diff --git a/apps/host/tests/session-workspace.test.mjs b/apps/host/tests/session-workspace.test.mjsnew file mode 100644index 000000000..39c339011--- /dev/null+++ b/apps/host/tests/session-workspace.test.mjs@@ -0,0 +1,17 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import { readFile } from 'node:fs/promises';+import { transform } from 'esbuild';++const { code } = await transform(await readFile(new URL('../src/lib/session-workspace.ts', import.meta.url), 'utf8'), { loader: 'ts', format: 'esm' });+const { workspaceIdForSession } = await import(`data:text/javascript;base64,${Buffer.from(code).toString('base64')}`);+const workspaces = [{ id: 'a', name: 'A', path: 'C:\A', aliases: ['C:\old'] }, { id: 'b', name: 'B', path: 'D:\Project' }];++test('a chat finds the workspace it was made in, by path or by an earlier folder (#3754)', () => {+ assert.equal(workspaceIdForSession(workspaces, { workspace: 'D:\Project' }), 'b');+ assert.equal(workspaceIdForSession(workspaces, { workspace: 'C:\old' }), 'a');+});+test('a chat with an unknown or no workspace changes nothing', () => {+ assert.equal(workspaceIdForSession(workspaces, { workspace: 'E:\gone' }), null);+ assert.equal(workspaceIdForSession(workspaces, undefined), null);+});