支持在会话输入框直接进行文件/图片的拖拽和粘贴
This commit is contained in:
@@ -33,6 +33,7 @@ import type {
|
||||
SessionConfigOptionInfo,
|
||||
SessionModeStateInfo,
|
||||
FixAction,
|
||||
PromptCapabilitiesInfo,
|
||||
PromptInputBlock,
|
||||
} from "@/lib/types"
|
||||
import { AGENT_LABELS } from "@/lib/types"
|
||||
@@ -80,6 +81,7 @@ export interface ConnectionState {
|
||||
contextKey: string
|
||||
agentType: AgentType
|
||||
status: ConnectionStatus
|
||||
promptCapabilities: PromptCapabilitiesInfo
|
||||
selectorsReady: boolean
|
||||
sessionId: string | null
|
||||
modes: SessionModeStateInfo | null
|
||||
@@ -157,6 +159,11 @@ type Action =
|
||||
type: "SELECTORS_READY"
|
||||
contextKey: string
|
||||
}
|
||||
| {
|
||||
type: "PROMPT_CAPABILITIES"
|
||||
contextKey: string
|
||||
promptCapabilities: PromptCapabilitiesInfo
|
||||
}
|
||||
| { type: "MODE_CHANGED"; contextKey: string; modeId: string }
|
||||
| {
|
||||
type: "PLAN_UPDATE"
|
||||
@@ -266,6 +273,17 @@ function sameModes(
|
||||
return true
|
||||
}
|
||||
|
||||
function samePromptCapabilities(
|
||||
a: PromptCapabilitiesInfo,
|
||||
b: PromptCapabilitiesInfo
|
||||
): boolean {
|
||||
return (
|
||||
a.image === b.image &&
|
||||
a.audio === b.audio &&
|
||||
a.embedded_context === b.embedded_context
|
||||
)
|
||||
}
|
||||
|
||||
function samePlanEntries(a: PlanEntryInfo[], b: PlanEntryInfo[]): boolean {
|
||||
if (a === b) return true
|
||||
if (a.length !== b.length) return false
|
||||
@@ -412,6 +430,11 @@ function connectionsReducer(
|
||||
contextKey: action.contextKey,
|
||||
agentType: action.agentType,
|
||||
status: "connecting",
|
||||
promptCapabilities: {
|
||||
image: false,
|
||||
audio: false,
|
||||
embedded_context: false,
|
||||
},
|
||||
selectorsReady: false,
|
||||
sessionId: null,
|
||||
modes: null,
|
||||
@@ -757,6 +780,25 @@ function connectionsReducer(
|
||||
return next
|
||||
}
|
||||
|
||||
case "PROMPT_CAPABILITIES": {
|
||||
const conn = state.get(action.contextKey)
|
||||
if (!conn) return state
|
||||
if (
|
||||
samePromptCapabilities(
|
||||
conn.promptCapabilities,
|
||||
action.promptCapabilities
|
||||
)
|
||||
) {
|
||||
return state
|
||||
}
|
||||
const next = new Map(state)
|
||||
next.set(action.contextKey, {
|
||||
...conn,
|
||||
promptCapabilities: action.promptCapabilities,
|
||||
})
|
||||
return next
|
||||
}
|
||||
|
||||
case "MODE_CHANGED": {
|
||||
const conn = state.get(action.contextKey)
|
||||
if (!conn?.modes) return state
|
||||
@@ -1307,6 +1349,14 @@ export function AcpConnectionsProvider({ children }: { children: ReactNode }) {
|
||||
contextKey,
|
||||
})
|
||||
break
|
||||
case "prompt_capabilities":
|
||||
flushStreamingQueue()
|
||||
dispatch({
|
||||
type: "PROMPT_CAPABILITIES",
|
||||
contextKey,
|
||||
promptCapabilities: e.prompt_capabilities,
|
||||
})
|
||||
break
|
||||
case "mode_changed":
|
||||
flushStreamingQueue()
|
||||
dispatch({
|
||||
|
||||
Reference in New Issue
Block a user