diff --git a/src/components/AgentAssistantWidget.vue b/src/components/AgentAssistantWidget.vue index ea320861..a024be64 100644 --- a/src/components/AgentAssistantWidget.vue +++ b/src/components/AgentAssistantWidget.vue @@ -167,7 +167,8 @@ md.use(mdLinkAttributes, { }) const canSend = computed( - () => (inputText.value.trim().length > 0 || pendingAttachments.value.length > 0) && !sending.value && !recording.value, + () => + (inputText.value.trim().length > 0 || pendingAttachments.value.length > 0) && !sending.value && !recording.value, ) const canRecord = computed(() => !sending.value && !recording.value) const recordingTimeText = computed(() => { @@ -254,7 +255,9 @@ function normalizeServerSession(item: AgentServerSession, withMessages = false): return { sessionId: sessionIdValue, clientSessionId: item.client_session_id, - title: item.title?.trim() || (messages.length ? buildSessionHistoryTitle(messages) : t('agentAssistant.untitledSession')), + title: + item.title?.trim() || + (messages.length ? buildSessionHistoryTitle(messages) : t('agentAssistant.untitledSession')), preview: item.preview, channel: item.channel, source: item.source, @@ -320,7 +323,9 @@ async function loadServerHistorySessions() { try { const data = await fetchAgentApi(`message/agent/sessions?page=1&count=${HISTORY_PAGE_SIZE}`) const sessions = Array.isArray(data) - ? data.map(item => normalizeServerSession(item as AgentServerSession)).filter(Boolean) as AgentSessionHistoryItem[] + ? (data + .map(item => normalizeServerSession(item as AgentServerSession)) + .filter(Boolean) as AgentSessionHistoryItem[]) : [] historySessions.value = dedupeHistorySessions(sessions) historyHasMore.value = sessions.length >= HISTORY_PAGE_SIZE @@ -344,14 +349,15 @@ async function loadMoreServerHistorySessions(options?: { done?: (status: Infinit const nextPage = historyPage.value + 1 const data = await fetchAgentApi(`message/agent/sessions?page=${nextPage}&count=${HISTORY_PAGE_SIZE}`) const sessions = Array.isArray(data) - ? data.map(item => normalizeServerSession(item as AgentServerSession)).filter(Boolean) as AgentSessionHistoryItem[] + ? (data + .map(item => normalizeServerSession(item as AgentServerSession)) + .filter(Boolean) as AgentSessionHistoryItem[]) : [] const existingIds = new Set(historySessions.value.map(item => item.sessionId)) historySessions.value = dedupeHistorySessions([ ...historySessions.value, ...sessions.filter(item => !existingIds.has(item.sessionId)), - ]) - .slice(0, MAX_LOCAL_HISTORY_SESSIONS) + ]).slice(0, MAX_LOCAL_HISTORY_SESSIONS) historyPage.value = nextPage historyHasMore.value = sessions.length >= HISTORY_PAGE_SIZE persistHistorySessions() @@ -377,8 +383,10 @@ async function loadServerHistorySession(targetSessionId: string) { const session = normalizeServerSession(data as AgentServerSession, true) if (!session) throw new Error(t('agentAssistant.historyLoadFailed')) - historySessions.value = dedupeHistorySessions([session, ...historySessions.value.filter(item => item.sessionId !== targetSessionId)]) - .slice(0, MAX_LOCAL_HISTORY_SESSIONS) + historySessions.value = dedupeHistorySessions([ + session, + ...historySessions.value.filter(item => item.sessionId !== targetSessionId), + ]).slice(0, MAX_LOCAL_HISTORY_SESSIONS) persistHistorySessions() return session @@ -483,8 +491,10 @@ function upsertCurrentSessionHistory() { messages: storedMessages, } - historySessions.value = dedupeHistorySessions([nextSession, ...historySessions.value.filter(item => item.sessionId !== sessionId.value)]) - .slice(0, MAX_LOCAL_HISTORY_SESSIONS) + historySessions.value = dedupeHistorySessions([ + nextSession, + ...historySessions.value.filter(item => item.sessionId !== sessionId.value), + ]).slice(0, MAX_LOCAL_HISTORY_SESSIONS) persistHistorySessions() } @@ -1317,11 +1327,7 @@ onScopeDispose(() => { class="agent-assistant-history-infinite" @load="handleHistoryInfiniteLoad" > - +