fix(webui): refresh file list and detail when agent executes asset creation tools

This commit is contained in:
yiling
2026-07-24 20:16:58 +08:00
parent 3eb7894df9
commit 8ec970e2bf
3 changed files with 66 additions and 4 deletions
+12 -1
View File
@@ -42,6 +42,7 @@ interface ChatbotState {
text: string,
projectId: string,
contextAssetId?: string,
onAssetMutation?: () => void,
) => Promise<void>
abortActiveSession: (teamId: string) => Promise<void>
}
@@ -151,7 +152,7 @@ export const useChatbotStore = create<ChatbotState>((set) => ({
})
},
sendMessage: async (teamId, text, projectId, contextAssetId) => {
sendMessage: async (teamId, text, projectId, contextAssetId, onAssetMutation) => {
const state = useChatbotStore.getState()
if (state.isStreaming) return
@@ -251,6 +252,16 @@ export const useChatbotStore = create<ChatbotState>((set) => ({
}
} else if (data.type === 'entry') {
const entry = data.entry as ChatMessage
const entryObj = entry as unknown as Record<string, unknown>
if (
entryObj.role === 'toolResult' &&
typeof entryObj.toolName === 'string' &&
['create_file', 'create_folder', 'create_version'].includes(entryObj.toolName) &&
!entryObj.isError
) {
onAssetMutation?.()
}
set((s) => {
const isExisting = s.messages.some((m) => m.id === entry.id)
// Replace temp/optimistic message when the real counterpart streams back