@@ -31,7 +31,6 @@ import cc.unitmesh.devins.workspace.WorkspaceManager
3131import cc.unitmesh.llm.KoogLLMService
3232import cc.unitmesh.llm.ModelConfig
3333import kotlinx.coroutines.launch
34- // Import UnifiedApp components for Session Management
3534import cc.unitmesh.devins.ui.app.UnifiedAppContent
3635
3736@OptIn(ExperimentalMaterial3Api ::class )
@@ -111,13 +110,9 @@ private fun AutoDevContent(
111110
112111 val workspaceState by WorkspaceManager .workspaceFlow.collectAsState()
113112
114- // Agent 类型切换处理函数 - 统一保存到配置
115113 fun handleAgentTypeChange (type : String ) {
116- println (" 🔄 切换 Agent Type: $type " )
117114 if (type == " Remote" ) {
118- val hasValidServerConfig = serverUrl.isNotBlank() &&
119- serverUrl != " http://localhost:8080"
120-
115+ val hasValidServerConfig = serverUrl.isNotBlank() && serverUrl != " http://localhost:8080"
121116 if (! hasValidServerConfig) {
122117 showRemoteConfigDialog = true
123118 return
@@ -296,22 +291,18 @@ private fun AutoDevContent(
296291 chatHistoryManager = chatHistoryManager,
297292 currentSessionId = chatHistoryManager.getCurrentSession().id,
298293 onSessionSelected = { sessionId ->
299- // Agent 模式:调用 Agent ViewModel 的处理器
300294 if (useAgentMode && agentSessionSelectedHandler != null ) {
301295 agentSessionSelectedHandler?.invoke(sessionId)
302296 } else {
303- // Chat 模式:直接更新本地状态
304297 chatHistoryManager.switchSession(sessionId)
305298 messages = chatHistoryManager.getMessages()
306299 currentStreamingOutput = " "
307300 }
308301 },
309302 onNewChat = {
310- // Agent 模式:调用 Agent ViewModel 的处理器
311303 if (useAgentMode && agentNewChatHandler != null ) {
312304 agentNewChatHandler?.invoke()
313305 } else {
314- // Chat 模式:直接更新本地状态
315306 chatHistoryManager.createSession()
316307 messages = emptyList()
317308 currentStreamingOutput = " "
@@ -386,32 +377,37 @@ private fun AutoDevContent(
386377 }
387378
388379 if (useAgentMode) {
389- // Conditional rendering based on agent type
390380 if (selectedAgentType == " Local" ) {
391381 AgentChatInterface (
392382 llmService = llmService,
393383 isTreeViewVisible = isTreeViewVisible,
394384 onConfigWarning = { showModelConfigDialog = true },
395385 onToggleTreeView = { isTreeViewVisible = it },
396- // 传入会话管理(Agent 模式也支持会话历史)
397386 chatHistoryManager = chatHistoryManager,
398- // 会话切换回调
399387 onSessionSelected = { sessionId ->
400- // Agent 模式的 session 切换由 ViewModel 处理
401- println (" ✅ [Agent] Switched to session: $sessionId " )
388+ if (useAgentMode && agentSessionSelectedHandler != null ) {
389+ agentSessionSelectedHandler?.invoke(sessionId)
390+ } else {
391+ chatHistoryManager.switchSession(sessionId)
392+ messages = chatHistoryManager.getMessages()
393+ currentStreamingOutput = " "
394+ }
402395 },
403396 onNewChat = {
404- // Agent 模式的 new session 由 ViewModel 处理
405- println (" ✅ [Agent] Created new session" )
397+ if (useAgentMode && agentNewChatHandler != null ) {
398+ agentNewChatHandler?.invoke()
399+ } else {
400+ chatHistoryManager.createSession()
401+ messages = emptyList()
402+ currentStreamingOutput = " "
403+ }
406404 },
407- // 导出内部处理器给 SessionSidebar 使用
408405 onInternalSessionSelected = { handler ->
409406 agentSessionSelectedHandler = handler
410407 },
411408 onInternalNewChat = { handler ->
412409 agentNewChatHandler = handler
413410 },
414- // TopBar 参数
415411 hasHistory = messages.isNotEmpty(),
416412 hasDebugInfo = compilerOutput.isNotEmpty(),
417413 currentModelConfig = currentModelConfig,
0 commit comments