提前检测Agent是否支持fork会话,避免无效展示和操作
This commit is contained in:
@@ -640,6 +640,15 @@ async fn run_connection(
|
|||||||
init_resp.agent_capabilities.load_session, supports_fork
|
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
|
// Emit connected status
|
||||||
let _ = handle.emit(
|
let _ = handle.emit(
|
||||||
"acp://event",
|
"acp://event",
|
||||||
|
|||||||
@@ -105,6 +105,11 @@ pub enum AcpEvent {
|
|||||||
connection_id: String,
|
connection_id: String,
|
||||||
prompt_capabilities: PromptCapabilitiesInfo,
|
prompt_capabilities: PromptCapabilitiesInfo,
|
||||||
},
|
},
|
||||||
|
/// Whether the agent supports session/fork
|
||||||
|
ForkSupported {
|
||||||
|
connection_id: String,
|
||||||
|
supported: bool,
|
||||||
|
},
|
||||||
/// Current session mode changed
|
/// Current session mode changed
|
||||||
ModeChanged {
|
ModeChanged {
|
||||||
connection_id: String,
|
connection_id: String,
|
||||||
|
|||||||
@@ -826,7 +826,9 @@ const ConversationTabView = memo(function ConversationTabView({
|
|||||||
onSaveQueueEdit={handleSaveQueueEdit}
|
onSaveQueueEdit={handleSaveQueueEdit}
|
||||||
onCancelQueueEdit={handleQueueCancelEdit}
|
onCancelQueueEdit={handleQueueCancelEdit}
|
||||||
onForkSend={
|
onForkSend={
|
||||||
connStatus === "connected" && hasPersistedConversation
|
connStatus === "connected" &&
|
||||||
|
hasPersistedConversation &&
|
||||||
|
conn.supportsFork
|
||||||
? handleForkSend
|
? handleForkSend
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ export interface ConnectionState {
|
|||||||
agentType: AgentType
|
agentType: AgentType
|
||||||
status: ConnectionStatus
|
status: ConnectionStatus
|
||||||
promptCapabilities: PromptCapabilitiesInfo
|
promptCapabilities: PromptCapabilitiesInfo
|
||||||
|
supportsFork: boolean
|
||||||
selectorsReady: boolean
|
selectorsReady: boolean
|
||||||
sessionId: string | null
|
sessionId: string | null
|
||||||
modes: SessionModeStateInfo | null
|
modes: SessionModeStateInfo | null
|
||||||
@@ -180,6 +181,11 @@ type Action =
|
|||||||
contextKey: string
|
contextKey: string
|
||||||
promptCapabilities: PromptCapabilitiesInfo
|
promptCapabilities: PromptCapabilitiesInfo
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
type: "FORK_SUPPORTED"
|
||||||
|
contextKey: string
|
||||||
|
supported: boolean
|
||||||
|
}
|
||||||
| { type: "MODE_CHANGED"; contextKey: string; modeId: string }
|
| { type: "MODE_CHANGED"; contextKey: string; modeId: string }
|
||||||
| {
|
| {
|
||||||
type: "PLAN_UPDATE"
|
type: "PLAN_UPDATE"
|
||||||
@@ -500,6 +506,7 @@ function connectionsReducer(
|
|||||||
audio: false,
|
audio: false,
|
||||||
embedded_context: false,
|
embedded_context: false,
|
||||||
},
|
},
|
||||||
|
supportsFork: false,
|
||||||
selectorsReady: false,
|
selectorsReady: false,
|
||||||
sessionId: null,
|
sessionId: null,
|
||||||
modes: null,
|
modes: null,
|
||||||
@@ -889,6 +896,18 @@ function connectionsReducer(
|
|||||||
return next
|
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": {
|
case "MODE_CHANGED": {
|
||||||
const conn = state.get(action.contextKey)
|
const conn = state.get(action.contextKey)
|
||||||
if (!conn?.modes) return state
|
if (!conn?.modes) return state
|
||||||
@@ -1469,6 +1488,14 @@ export function AcpConnectionsProvider({ children }: { children: ReactNode }) {
|
|||||||
promptCapabilities: e.prompt_capabilities,
|
promptCapabilities: e.prompt_capabilities,
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
case "fork_supported":
|
||||||
|
flushStreamingQueue()
|
||||||
|
dispatch({
|
||||||
|
type: "FORK_SUPPORTED",
|
||||||
|
contextKey,
|
||||||
|
supported: e.supported,
|
||||||
|
})
|
||||||
|
break
|
||||||
case "mode_changed":
|
case "mode_changed":
|
||||||
flushStreamingQueue()
|
flushStreamingQueue()
|
||||||
dispatch({
|
dispatch({
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export interface UseConnectionReturn {
|
|||||||
connectionId: string | null
|
connectionId: string | null
|
||||||
status: ConnectionStatus | null
|
status: ConnectionStatus | null
|
||||||
promptCapabilities: PromptCapabilitiesInfo
|
promptCapabilities: PromptCapabilitiesInfo
|
||||||
|
supportsFork: boolean
|
||||||
selectorsReady: boolean
|
selectorsReady: boolean
|
||||||
sessionId: string | null
|
sessionId: string | null
|
||||||
modes: SessionModeStateInfo | null
|
modes: SessionModeStateInfo | null
|
||||||
@@ -76,6 +77,7 @@ export function useConnection(contextKey: string): UseConnectionReturn {
|
|||||||
const status = connection?.status ?? null
|
const status = connection?.status ?? null
|
||||||
const promptCapabilities =
|
const promptCapabilities =
|
||||||
connection?.promptCapabilities ?? DEFAULT_PROMPT_CAPABILITIES
|
connection?.promptCapabilities ?? DEFAULT_PROMPT_CAPABILITIES
|
||||||
|
const supportsFork = connection?.supportsFork ?? false
|
||||||
const selectorsReady = connection?.selectorsReady ?? false
|
const selectorsReady = connection?.selectorsReady ?? false
|
||||||
const sessionId = connection?.sessionId ?? null
|
const sessionId = connection?.sessionId ?? null
|
||||||
const modes = connection?.modes ?? null
|
const modes = connection?.modes ?? null
|
||||||
@@ -133,6 +135,7 @@ export function useConnection(contextKey: string): UseConnectionReturn {
|
|||||||
connectionId,
|
connectionId,
|
||||||
status,
|
status,
|
||||||
promptCapabilities,
|
promptCapabilities,
|
||||||
|
supportsFork,
|
||||||
selectorsReady,
|
selectorsReady,
|
||||||
sessionId,
|
sessionId,
|
||||||
modes,
|
modes,
|
||||||
@@ -154,6 +157,7 @@ export function useConnection(contextKey: string): UseConnectionReturn {
|
|||||||
connectionId,
|
connectionId,
|
||||||
status,
|
status,
|
||||||
promptCapabilities,
|
promptCapabilities,
|
||||||
|
supportsFork,
|
||||||
selectorsReady,
|
selectorsReady,
|
||||||
sessionId,
|
sessionId,
|
||||||
modes,
|
modes,
|
||||||
|
|||||||
@@ -463,6 +463,11 @@ export type AcpEvent =
|
|||||||
connection_id: string
|
connection_id: string
|
||||||
prompt_capabilities: PromptCapabilitiesInfo
|
prompt_capabilities: PromptCapabilitiesInfo
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
type: "fork_supported"
|
||||||
|
connection_id: string
|
||||||
|
supported: boolean
|
||||||
|
}
|
||||||
| {
|
| {
|
||||||
type: "mode_changed"
|
type: "mode_changed"
|
||||||
connection_id: string
|
connection_id: string
|
||||||
|
|||||||
Reference in New Issue
Block a user