You've already forked agentic-coding-workflow
fix(web): code review pass — scroll watch, SSE same-origin, store concurrency, modal reset, admin validation
This commit is contained in:
+14
-6
@@ -8,7 +8,7 @@ import {
|
||||
type ListConversationsParams,
|
||||
} from '@/api/chat'
|
||||
import {
|
||||
useChatStream,
|
||||
startChatStream,
|
||||
type ChatStreamEvent,
|
||||
type ChatStreamHandle,
|
||||
} from '@/composables/useChatStream'
|
||||
@@ -61,6 +61,7 @@ export const useChatStore = defineStore('chat', () => {
|
||||
|
||||
async function sendMessage(content: string, attachmentIds: string[] = []) {
|
||||
if (!currentConversation.value) return
|
||||
if (streamingMessageId.value !== null) return
|
||||
const conv = currentConversation.value
|
||||
const resp = await chatApi.sendMessage(conv.id, {
|
||||
content,
|
||||
@@ -119,16 +120,20 @@ export const useChatStore = defineStore('chat', () => {
|
||||
await chatApi.deleteConversation(id)
|
||||
conversations.value = conversations.value.filter((c) => c.id !== id)
|
||||
if (currentConversation.value?.id === id) {
|
||||
currentConversation.value = null
|
||||
messages.value = []
|
||||
detachStream()
|
||||
closeCurrent()
|
||||
}
|
||||
}
|
||||
|
||||
function closeCurrent() {
|
||||
detachStream()
|
||||
currentConversation.value = null
|
||||
messages.value = []
|
||||
streamingMessageId.value = null
|
||||
}
|
||||
|
||||
function attachStream(streamUrl: string, sinceMessageID: number) {
|
||||
detachStream()
|
||||
const stream = useChatStream()
|
||||
streamHandle.value = stream.start(streamUrl, sinceMessageID, {
|
||||
streamHandle.value = startChatStream(streamUrl, sinceMessageID, {
|
||||
onEvent: (ev) => applyStreamEvent(ev),
|
||||
onClose: () => {
|
||||
streamHandle.value = null
|
||||
@@ -183,6 +188,8 @@ export const useChatStore = defineStore('chat', () => {
|
||||
break
|
||||
}
|
||||
case 'done':
|
||||
// 后端事件顺序:EventUsage → EventDone(参见 internal/chat/streamer.go)。
|
||||
// tokens 已在 'usage' 分支写入;某些 provider 不发 usage 时此处不会兜底。
|
||||
msg.status = 'ok'
|
||||
streamingMessageId.value = null
|
||||
break
|
||||
@@ -204,6 +211,7 @@ export const useChatStore = defineStore('chat', () => {
|
||||
isStreaming,
|
||||
loadConversations,
|
||||
openConversation,
|
||||
closeCurrent,
|
||||
sendMessage,
|
||||
cancelMessage,
|
||||
retryMessage,
|
||||
|
||||
Reference in New Issue
Block a user