mirror of
https://github.com/moeru-ai/airi.git
synced 2026-08-14 08:52:42 +00:00
fix(stage-ui): shallow copy on chat (#926)
This commit is contained in:
@@ -286,6 +286,7 @@ export const useChatStore = defineStore('chat', () => {
|
||||
function cleanupMessages(sessionId = activeSessionId.value) {
|
||||
bumpSessionGeneration(sessionId)
|
||||
sessionMessages.value[sessionId] = [generateInitialMessage()]
|
||||
activeContexts.value = {}
|
||||
|
||||
// Reject pending sends for this session so callers don't hang after cleanup
|
||||
for (const queued of pendingQueuedSends.value) {
|
||||
@@ -358,7 +359,7 @@ export const useChatStore = defineStore('chat', () => {
|
||||
const sendingCreatedAt = Date.now()
|
||||
const streamingMessageContext: ChatStreamEventContext = {
|
||||
input: { role: 'user', content: sendingMessage, createdAt: sendingCreatedAt },
|
||||
contexts: { ...activeContexts.value },
|
||||
contexts: toRaw(activeContexts.value),
|
||||
composedMessage: [],
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { isStageTamagotchi, isStageWeb } from '@proj-airi/stage-shared'
|
||||
import { useBroadcastChannel } from '@vueuse/core'
|
||||
import { Mutex } from 'es-toolkit'
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, watch } from 'vue'
|
||||
import { ref, watch, toRaw } from 'vue'
|
||||
|
||||
import { CHAT_STREAM_CHANNEL_NAME, CONTEXT_CHANNEL_NAME, useChatStore } from '../../chat'
|
||||
import { useModsServerChannelStore } from './channel-server'
|
||||
@@ -37,7 +37,7 @@ export const useContextBridgeStore = defineStore('mods:api:context-bridge', () =
|
||||
|
||||
disposeHookFns.value.push(serverChannelStore.onContextUpdate((event) => {
|
||||
chatStore.ingestContextMessage({ source: event.source, createdAt: Date.now(), ...event.data })
|
||||
broadcastContext(event.data as ContextMessage)
|
||||
broadcastContext(toRaw(event.data) as ContextMessage)
|
||||
}))
|
||||
|
||||
disposeHookFns.value.push(
|
||||
@@ -45,7 +45,7 @@ export const useContextBridgeStore = defineStore('mods:api:context-bridge', () =
|
||||
if (isProcessingRemoteStream)
|
||||
return
|
||||
|
||||
broadcastStreamEvent({ type: 'before-compose', message, sessionId: chatStore.activeSessionId, context })
|
||||
broadcastStreamEvent({ type: 'before-compose', message, sessionId: chatStore.activeSessionId, context: toRaw(context) })
|
||||
}),
|
||||
chatStore.onAfterMessageComposed(async (message, context) => {
|
||||
if (isProcessingRemoteStream)
|
||||
|
||||
Reference in New Issue
Block a user