From dae97eda617dc13424dd9f4fe82e8a4b97e97445 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Sun, 16 Nov 2025 13:34:05 -0500 Subject: [PATCH] fix: sync creation preferences on workspace handoff --- .../ChatInput/useCreationWorkspace.ts | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/browser/components/ChatInput/useCreationWorkspace.ts b/src/browser/components/ChatInput/useCreationWorkspace.ts index 83d9df36e..89c0ba4ac 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);