fix(conversation): derive ACP working dir from tab folder, not active folder

This commit is contained in:
xintaofei
2026-04-21 22:03:57 +08:00
parent 753e312c13
commit b77842ee66

View File

@@ -271,12 +271,11 @@ const ConversationTabView = memo(function ConversationTabView({
} }
return buildNewConversationDraftStorageKey({ tabId }) return buildNewConversationDraftStorageKey({ tabId })
}, [dbConversationId, tabId, selectedAgent]) }, [dbConversationId, tabId, selectedAgent])
const workingDirForConnection = useMemo(() => { // Use the per-tab workingDir (derived from the tab's own folderId by the
if (dbConversationId != null) { // parent) rather than the active folder's path — otherwise switching tabs
return detailLoading ? undefined : folder?.path // briefly exposes the previous folder's path to the ACP auto-connect
} // effect, and the connection sticks with the wrong cwd.
return workingDir ?? folder?.path const workingDirForConnection = workingDir ?? folder?.path
}, [dbConversationId, detailLoading, folder?.path, workingDir])
const { const {
conn, conn,
@@ -1037,8 +1036,12 @@ export function ConversationDetailPanel() {
removeConversation: runtimeRemoveConversation, removeConversation: runtimeRemoveConversation,
} = useConversationRuntime() } = useConversationRuntime()
const { activeFolder: folder } = useActiveFolder() const { activeFolder: folder } = useActiveFolder()
const { conversations, refreshConversations, updateConversationLocal } = const {
useAppWorkspace() conversations,
refreshConversations,
updateConversationLocal,
getFolder,
} = useAppWorkspace()
const { const {
tabs, tabs,
activeTabId, activeTabId,
@@ -1426,7 +1429,7 @@ export function ConversationDetailPanel() {
tabId={tab.id} tabId={tab.id}
conversationId={tab.conversationId} conversationId={tab.conversationId}
agentType={tab.agentType} agentType={tab.agentType}
workingDir={tab.workingDir ?? folder?.path} workingDir={tab.workingDir ?? getFolder(tab.folderId)?.path}
isActive={active} isActive={active}
reloadSignal={reloadByTabId[tab.id] ?? 0} reloadSignal={reloadByTabId[tab.id] ?? 0}
/> />