提前检测Agent是否支持fork会话,避免无效展示和操作

This commit is contained in:
xintaofei
2026-03-17 16:03:08 +08:00
parent db4ff9d1ae
commit 35f5e16c11
6 changed files with 53 additions and 1 deletions

View File

@@ -90,6 +90,7 @@ export interface ConnectionState {
agentType: AgentType
status: ConnectionStatus
promptCapabilities: PromptCapabilitiesInfo
supportsFork: boolean
selectorsReady: boolean
sessionId: string | null
modes: SessionModeStateInfo | null
@@ -180,6 +181,11 @@ type Action =
contextKey: string
promptCapabilities: PromptCapabilitiesInfo
}
| {
type: "FORK_SUPPORTED"
contextKey: string
supported: boolean
}
| { type: "MODE_CHANGED"; contextKey: string; modeId: string }
| {
type: "PLAN_UPDATE"
@@ -500,6 +506,7 @@ function connectionsReducer(
audio: false,
embedded_context: false,
},
supportsFork: false,
selectorsReady: false,
sessionId: null,
modes: null,
@@ -889,6 +896,18 @@ function connectionsReducer(
return next
}
case "FORK_SUPPORTED": {
const conn = state.get(action.contextKey)
if (!conn) return state
if (conn.supportsFork === action.supported) return state
const next = new Map(state)
next.set(action.contextKey, {
...conn,
supportsFork: action.supported,
})
return next
}
case "MODE_CHANGED": {
const conn = state.get(action.contextKey)
if (!conn?.modes) return state
@@ -1469,6 +1488,14 @@ export function AcpConnectionsProvider({ children }: { children: ReactNode }) {
promptCapabilities: e.prompt_capabilities,
})
break
case "fork_supported":
flushStreamingQueue()
dispatch({
type: "FORK_SUPPORTED",
contextKey,
supported: e.supported,
})
break
case "mode_changed":
flushStreamingQueue()
dispatch({