diff --git a/src/browser/components/ChatInput/useCreationWorkspace.ts b/src/browser/components/ChatInput/useCreationWorkspace.ts index 83d9df36eb..89c0ba4ac7 100644 --- a/src/browser/components/ChatInput/useCreationWorkspace.ts +++ b/src/browser/components/ChatInput/useCreationWorkspace.ts @@ -1,10 +1,13 @@ import { useState, useEffect, useCallback } from "react"; import type { FrontendWorkspaceMetadata } from "@/common/types/workspace"; import type { RuntimeConfig, RuntimeMode } from "@/common/types/runtime"; +import type { UIMode } from "@/common/types/mode"; +import type { ThinkingLevel } from "@/common/types/thinking"; import { parseRuntimeString } from "@/browser/utils/chatCommands"; import { useDraftWorkspaceSettings } from "@/browser/hooks/useDraftWorkspaceSettings"; +import { readPersistedState, updatePersistedState } from "@/browser/hooks/usePersistedState"; import { useSendMessageOptions } from "@/browser/hooks/useSendMessageOptions"; -import { getProjectScopeId } from "@/common/constants/storage"; +import { getModeKey, getProjectScopeId, getThinkingLevelKey } from "@/common/constants/storage"; import { extractErrorMessage } from "./utils"; interface UseCreationWorkspaceOptions { @@ -12,6 +15,23 @@ interface UseCreationWorkspaceOptions { onWorkspaceCreated: (metadata: FrontendWorkspaceMetadata) => void; } +function syncCreationPreferences(projectPath: string, workspaceId: string): void { + const projectScopeId = getProjectScopeId(projectPath); + + const projectMode = readPersistedState(getModeKey(projectScopeId), null); + if (projectMode) { + updatePersistedState(getModeKey(workspaceId), projectMode); + } + + const projectThinking = readPersistedState( + getThinkingLevelKey(projectScopeId), + null + ); + if (projectThinking) { + updatePersistedState(getThinkingLevelKey(workspaceId), projectThinking); + } +} + interface UseCreationWorkspaceReturn { branches: string[]; trunkBranch: string; @@ -97,6 +117,7 @@ export function useCreationWorkspace({ // Check if this is a workspace creation result (has metadata field) if ("metadata" in result && result.metadata) { + syncCreationPreferences(projectPath, result.metadata.id); // Settings are already persisted via useDraftWorkspaceSettings // Notify parent to switch workspace (clears input via parent unmount) onWorkspaceCreated(result.metadata);