提前检测Agent是否支持fork会话,避免无效展示和操作
This commit is contained in:
@@ -640,6 +640,15 @@ async fn run_connection(
|
||||
init_resp.agent_capabilities.load_session, supports_fork
|
||||
);
|
||||
|
||||
// Emit fork support capability
|
||||
let _ = handle.emit(
|
||||
"acp://event",
|
||||
AcpEvent::ForkSupported {
|
||||
connection_id: conn_id.clone(),
|
||||
supported: supports_fork,
|
||||
},
|
||||
);
|
||||
|
||||
// Emit connected status
|
||||
let _ = handle.emit(
|
||||
"acp://event",
|
||||
|
||||
@@ -105,6 +105,11 @@ pub enum AcpEvent {
|
||||
connection_id: String,
|
||||
prompt_capabilities: PromptCapabilitiesInfo,
|
||||
},
|
||||
/// Whether the agent supports session/fork
|
||||
ForkSupported {
|
||||
connection_id: String,
|
||||
supported: bool,
|
||||
},
|
||||
/// Current session mode changed
|
||||
ModeChanged {
|
||||
connection_id: String,
|
||||
|
||||
@@ -826,7 +826,9 @@ const ConversationTabView = memo(function ConversationTabView({
|
||||
onSaveQueueEdit={handleSaveQueueEdit}
|
||||
onCancelQueueEdit={handleQueueCancelEdit}
|
||||
onForkSend={
|
||||
connStatus === "connected" && hasPersistedConversation
|
||||
connStatus === "connected" &&
|
||||
hasPersistedConversation &&
|
||||
conn.supportsFork
|
||||
? handleForkSend
|
||||
: undefined
|
||||
}
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -30,6 +30,7 @@ export interface UseConnectionReturn {
|
||||
connectionId: string | null
|
||||
status: ConnectionStatus | null
|
||||
promptCapabilities: PromptCapabilitiesInfo
|
||||
supportsFork: boolean
|
||||
selectorsReady: boolean
|
||||
sessionId: string | null
|
||||
modes: SessionModeStateInfo | null
|
||||
@@ -76,6 +77,7 @@ export function useConnection(contextKey: string): UseConnectionReturn {
|
||||
const status = connection?.status ?? null
|
||||
const promptCapabilities =
|
||||
connection?.promptCapabilities ?? DEFAULT_PROMPT_CAPABILITIES
|
||||
const supportsFork = connection?.supportsFork ?? false
|
||||
const selectorsReady = connection?.selectorsReady ?? false
|
||||
const sessionId = connection?.sessionId ?? null
|
||||
const modes = connection?.modes ?? null
|
||||
@@ -133,6 +135,7 @@ export function useConnection(contextKey: string): UseConnectionReturn {
|
||||
connectionId,
|
||||
status,
|
||||
promptCapabilities,
|
||||
supportsFork,
|
||||
selectorsReady,
|
||||
sessionId,
|
||||
modes,
|
||||
@@ -154,6 +157,7 @@ export function useConnection(contextKey: string): UseConnectionReturn {
|
||||
connectionId,
|
||||
status,
|
||||
promptCapabilities,
|
||||
supportsFork,
|
||||
selectorsReady,
|
||||
sessionId,
|
||||
modes,
|
||||
|
||||
@@ -463,6 +463,11 @@ export type AcpEvent =
|
||||
connection_id: string
|
||||
prompt_capabilities: PromptCapabilitiesInfo
|
||||
}
|
||||
| {
|
||||
type: "fork_supported"
|
||||
connection_id: string
|
||||
supported: boolean
|
||||
}
|
||||
| {
|
||||
type: "mode_changed"
|
||||
connection_id: string
|
||||
|
||||
Reference in New Issue
Block a user