现在会话输入框会记住用户的配置选项和模型选择,避免每次都要重新勾选

This commit is contained in:
xintaofei
2026-03-27 22:19:07 +08:00
parent f50c85ce84
commit 10725df8ab
3 changed files with 283 additions and 7 deletions

View File

@@ -47,6 +47,10 @@ import {
type MessageTurn,
type PromptDraft,
} from "@/lib/types"
import {
getSavedModeId,
saveModePreference,
} from "@/lib/selector-prefs-storage"
import {
buildConversationDraftStorageKey,
buildNewConversationDraftStorageKey,
@@ -724,7 +728,7 @@ const ConversationTabView = memo(function ConversationTabView({
if (dbConvIdRef.current) return
setDraftAgentType(nextAgentType)
setModeId(null)
setModeId(getSavedModeId(nextAgentType))
setAgentConnectError(null)
const s = connStatusRef.current
@@ -759,6 +763,20 @@ const ConversationTabView = memo(function ConversationTabView({
[connConnect, connDisconnect, workingDirForConnection]
)
const handleModeChange = useCallback(
(newModeId: string) => {
setModeId(newModeId)
// Persist mode selection to localStorage immediately
if (conn.modes) {
saveModePreference(selectedAgent, {
...conn.modes,
current_mode_id: newModeId,
})
}
},
[conn.modes, selectedAgent]
)
const handleAnswerQuestion = useCallback(
(answer: string) => {
if (connStatus !== "connected") return
@@ -853,7 +871,7 @@ const ConversationTabView = memo(function ConversationTabView({
configOptionsLoading={configOptionsLoading}
selectorsLoading={selectorsLoading}
selectedModeId={selectedModeId}
onModeChange={setModeId}
onModeChange={handleModeChange}
onConfigOptionChange={handleSetConfigOption}
availableCommands={connectionCommands}
attachmentTabId={tabId}
@@ -924,7 +942,7 @@ const ConversationTabView = memo(function ConversationTabView({
configOptionsLoading={configOptionsLoading}
selectorsLoading={selectorsLoading}
selectedModeId={selectedModeId}
onModeChange={setModeId}
onModeChange={handleModeChange}
onConfigOptionChange={handleSetConfigOption}
availableCommands={connectionCommands}
attachmentTabId={tabId}