Skip to content

Commit 14deb86

Browse files
committed
fix:修复双模式bug
1 parent cc486cf commit 14deb86

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎app1/app/src/main/java/com/android/everytalk/statecontroller/SimpleModeManager.kt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ class SimpleModeManager(
428428
// 5. 设置对话ID(必须在消息加载前设置)
429429
val stableId = conversationToLoad.firstOrNull()?.id ?: "image_history_${UUID.randomUUID()}"
430430
stateHolder._currentImageGenerationConversationId.value = stableId
431+
stateHolder.applyCurrentImageConversationFunctionToggleState()
431432

432433
// 🔧 修复:恢复会话使用的图像生成配置
433434
val savedConfigId = stateHolder.conversationApiConfigIds.value[stableId]

‎app1/app/src/main/java/com/android/everytalk/statecontroller/ViewModelStateHolder.kt‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ val _isStreamingPaused = MutableStateFlow(false)
170170
return conversationFunctionToggleStates.value[_currentConversationId.value] ?: ConversationFunctionToggleState()
171171
}
172172

173+
fun getCurrentImageConversationFunctionToggleState(): ConversationFunctionToggleState {
174+
return conversationFunctionToggleStates.value[_currentImageGenerationConversationId.value]
175+
?: ConversationFunctionToggleState()
176+
}
177+
173178
fun updateCurrentConversationFunctionToggleState(
174179
update: (ConversationFunctionToggleState) -> ConversationFunctionToggleState
175180
) {
@@ -253,6 +258,13 @@ val _isStreamingPaused = MutableStateFlow(false)
253258
_isMcpEnabledForNextRequest.value = toggleState.mcpEnabled
254259
}
255260

261+
fun applyCurrentImageConversationFunctionToggleState() {
262+
val toggleState = getCurrentImageConversationFunctionToggleState()
263+
_isWebSearchEnabled.value = toggleState.webSearchEnabled
264+
_isCodeExecutionEnabled.value = toggleState.codeExecutionEnabled
265+
_isMcpEnabledForNextRequest.value = toggleState.mcpEnabled
266+
}
267+
256268
fun updateOpenClawSessionId(sessionId: String?) {
257269
_currentOpenClawSessionId.value = sessionId?.takeIf { it.isNotBlank() } ?: "main"
258270
}
@@ -438,6 +450,7 @@ val _isStreamingPaused = MutableStateFlow(false)
438450
_apiHandler.clearImageChatResources()
439451
}
440452
isImageConversationDirty.value = false
453+
applyCurrentImageConversationFunctionToggleState()
441454
}
442455

443456
val selectedMediaItems: SnapshotStateList<SelectedMediaItem> =

‎app1/app/src/test/java/com/android/everytalk/statecontroller/AddMenuPreferenceStateTest.kt‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.android.everytalk.statecontroller
22

33
import org.junit.Assert.assertEquals
4+
import org.junit.Assert.assertFalse
45
import org.junit.Test
56

67
class AddMenuPreferenceStateTest {
@@ -13,4 +14,32 @@ class AddMenuPreferenceStateTest {
1314
assertEquals(false, state.codeExecutionEnabled)
1415
assertEquals(false, state.mcpEnabled)
1516
}
17+
18+
@Test
19+
fun `image conversation applies its own toggle state instead of text conversation state`() {
20+
val holder = ViewModelStateHolder()
21+
val textConversationId = holder._currentConversationId.value
22+
val imageConversationId = "image_history_1"
23+
24+
holder.conversationFunctionToggleStates.value = mapOf(
25+
textConversationId to ConversationFunctionToggleState(
26+
webSearchEnabled = true,
27+
codeExecutionEnabled = true,
28+
mcpEnabled = true
29+
),
30+
imageConversationId to ConversationFunctionToggleState(
31+
webSearchEnabled = false,
32+
codeExecutionEnabled = false,
33+
mcpEnabled = false
34+
)
35+
)
36+
37+
holder._currentImageGenerationConversationId.value = imageConversationId
38+
holder.applyCurrentImageConversationFunctionToggleState()
39+
40+
assertFalse(holder._isWebSearchEnabled.value)
41+
assertFalse(holder._isCodeExecutionEnabled.value)
42+
assertFalse(holder._isMcpEnabledForNextRequest.value)
43+
}
44+
1645
}

0 commit comments

Comments
 (0)