新会话默认连接agent列表里面的第一个agent,不再固定使用codex
This commit is contained in:
@@ -694,6 +694,12 @@ const ConversationTabView = memo(function ConversationTabView({
|
|||||||
setDraftAgentType(nextAgentType)
|
setDraftAgentType(nextAgentType)
|
||||||
setModeId(null)
|
setModeId(null)
|
||||||
setAgentConnectError(null)
|
setAgentConnectError(null)
|
||||||
|
|
||||||
|
// If not yet connected, just update state — auto-connect will use the
|
||||||
|
// new agentType once canAutoConnect is satisfied.
|
||||||
|
const s = connStatusRef.current
|
||||||
|
if (!s || s === "disconnected" || s === "error") return
|
||||||
|
|
||||||
connDisconnect()
|
connDisconnect()
|
||||||
.catch((e) =>
|
.catch((e) =>
|
||||||
console.error("[ConversationTabView] disconnect old agent:", e)
|
console.error("[ConversationTabView] disconnect old agent:", e)
|
||||||
@@ -1090,7 +1096,7 @@ export function ConversationDetailPanel() {
|
|||||||
|
|
||||||
const handleNewConversation = useCallback(() => {
|
const handleNewConversation = useCallback(() => {
|
||||||
if (!folder) return
|
if (!folder) return
|
||||||
openNewConversationTab("codex", folder.path)
|
openNewConversationTab(folder.path)
|
||||||
}, [folder, openNewConversationTab])
|
}, [folder, openNewConversationTab])
|
||||||
|
|
||||||
const handleCloseActiveTab = useCallback(() => {
|
const handleCloseActiveTab = useCallback(() => {
|
||||||
@@ -1103,18 +1109,9 @@ export function ConversationDetailPanel() {
|
|||||||
if (!folder) return
|
if (!folder) return
|
||||||
|
|
||||||
if (hasNoTabs) {
|
if (hasNoTabs) {
|
||||||
openNewConversationTab(
|
openNewConversationTab(newConversation?.workingDir ?? folder.path)
|
||||||
newConversation?.agentType ?? "codex",
|
|
||||||
newConversation?.workingDir ?? folder.path
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}, [
|
}, [folder, hasNoTabs, newConversation?.workingDir, openNewConversationTab])
|
||||||
folder,
|
|
||||||
hasNoTabs,
|
|
||||||
newConversation?.agentType,
|
|
||||||
newConversation?.workingDir,
|
|
||||||
openNewConversationTab,
|
|
||||||
])
|
|
||||||
|
|
||||||
const canTile = isTileMode && tabs.length > 1
|
const canTile = isTileMode && tabs.length > 1
|
||||||
|
|
||||||
|
|||||||
@@ -373,7 +373,7 @@ export function SidebarConversationList({
|
|||||||
|
|
||||||
const handleNewConversation = useCallback(() => {
|
const handleNewConversation = useCallback(() => {
|
||||||
if (!folder) return
|
if (!folder) return
|
||||||
openNewConversationTab("codex", folder.path)
|
openNewConversationTab(folder.path)
|
||||||
}, [folder, openNewConversationTab])
|
}, [folder, openNewConversationTab])
|
||||||
|
|
||||||
const handleImport = useCallback(async () => {
|
const handleImport = useCallback(async () => {
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ export function FolderTitleBar() {
|
|||||||
if (matchShortcutEvent(e, shortcuts.new_conversation)) {
|
if (matchShortcutEvent(e, shortcuts.new_conversation)) {
|
||||||
if (!folderPath) return
|
if (!folderPath) return
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
openNewConversationTab("codex", folderPath)
|
openNewConversationTab(folderPath)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (matchShortcutEvent(e, shortcuts.open_folder)) {
|
if (matchShortcutEvent(e, shortcuts.open_folder)) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export function Sidebar() {
|
|||||||
|
|
||||||
const handleNewConversation = useCallback(() => {
|
const handleNewConversation = useCallback(() => {
|
||||||
if (!folder) return
|
if (!folder) return
|
||||||
openNewConversationTab("codex", folder.path)
|
openNewConversationTab(folder.path)
|
||||||
}, [folder, openNewConversationTab])
|
}, [folder, openNewConversationTab])
|
||||||
|
|
||||||
if (!isOpen) return null
|
if (!isOpen) return null
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import type {
|
|||||||
ConversationStatus,
|
ConversationStatus,
|
||||||
OpenedConversation,
|
OpenedConversation,
|
||||||
} from "@/lib/types"
|
} from "@/lib/types"
|
||||||
|
import { AGENT_DISPLAY_ORDER } from "@/lib/types"
|
||||||
|
|
||||||
interface TabItemInternal {
|
interface TabItemInternal {
|
||||||
id: string
|
id: string
|
||||||
@@ -54,7 +55,7 @@ interface TabContextValue {
|
|||||||
switchTab: (tabId: string) => void
|
switchTab: (tabId: string) => void
|
||||||
pinTab: (tabId: string) => void
|
pinTab: (tabId: string) => void
|
||||||
toggleTileMode: () => void
|
toggleTileMode: () => void
|
||||||
openNewConversationTab: (agentType: AgentType, workingDir: string) => void
|
openNewConversationTab: (workingDir: string) => void
|
||||||
bindConversationTab: (
|
bindConversationTab: (
|
||||||
tabId: string,
|
tabId: string,
|
||||||
conversationId: number,
|
conversationId: number,
|
||||||
@@ -419,7 +420,7 @@ export function TabProvider({ children }: TabProviderProps) {
|
|||||||
id: makeNewConversationTabId(),
|
id: makeNewConversationTabId(),
|
||||||
kind: "conversation",
|
kind: "conversation",
|
||||||
conversationId: null,
|
conversationId: null,
|
||||||
agentType: preferred?.agentType ?? "codex",
|
agentType: AGENT_DISPLAY_ORDER[0],
|
||||||
title: t("newConversation"),
|
title: t("newConversation"),
|
||||||
isPinned: true,
|
isPinned: true,
|
||||||
workingDir: preferred?.workingDir ?? folder?.path,
|
workingDir: preferred?.workingDir ?? folder?.path,
|
||||||
@@ -553,18 +554,27 @@ export function TabProvider({ children }: TabProviderProps) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const openNewConversationTab = useCallback(
|
const openNewConversationTab = useCallback(
|
||||||
(agentType: AgentType, workingDir: string) => {
|
(workingDir: string) => {
|
||||||
const existingTab = rawTabsRef.current.find(
|
const existingTab = rawTabsRef.current.find(
|
||||||
(t) => t.conversationId == null && t.agentType === agentType
|
(t) => t.conversationId == null
|
||||||
)
|
)
|
||||||
|
|
||||||
if (existingTab) {
|
if (existingTab) {
|
||||||
|
// Update workingDir if it differs from the request
|
||||||
|
if (existingTab.workingDir !== workingDir) {
|
||||||
|
setTabs((prev) =>
|
||||||
|
prev.map((t) =>
|
||||||
|
t.id === existingTab.id ? { ...t, workingDir } : t
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
setActiveTabId(existingTab.id)
|
setActiveTabId(existingTab.id)
|
||||||
syncFolderContext(existingTab)
|
syncFolderContext(existingTab)
|
||||||
activateConversationPane()
|
activateConversationPane()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const agentType = AGENT_DISPLAY_ORDER[0]
|
||||||
const tabId = makeNewConversationTabId()
|
const tabId = makeNewConversationTabId()
|
||||||
const newTab: TabItemInternal = {
|
const newTab: TabItemInternal = {
|
||||||
id: tabId,
|
id: tabId,
|
||||||
|
|||||||
Reference in New Issue
Block a user