Merge branch 'dev' into hugo-shipping-notice
This commit is contained in:
commit
9f5493185d
29 files changed
+3957
-12
No files matched your search
@@ -2,7 +2,7 @@
|
||||
* features/chat/composables/useChatPage.ts
|
||||
* 对话页主编排:组合 SSE、Agent、附件、请假/出货、路由同步与 page/* 子模块。
|
||||
*/
|
||||
import { computed, markRaw, ref, watch } from 'vue';
|
||||
import { computed, markRaw, nextTick, ref, watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
@@ -26,6 +26,7 @@ import { useChatSessions } from './useChatSessions';
|
||||
import { useChatShipping } from './useChatShipping';
|
||||
import { useChatSourceFiles } from './useChatSourceFiles';
|
||||
import { useChatStore } from '../stores/chat.store';
|
||||
import { useTrainingWorkspace, matchesTrainingAgent } from './useTrainingWorkspace';
|
||||
import {
|
||||
createChatPageConversationApi,
|
||||
createChatPageLocalMessageApi,
|
||||
@@ -34,6 +35,7 @@ import {
|
||||
createLeaveMessageHandlers,
|
||||
createShippingMappingHandlers,
|
||||
createShippingPickerRefHolder,
|
||||
createTrainingHandlers,
|
||||
useChatPageDialogs,
|
||||
useChatPageUser,
|
||||
useChatPageVoice,
|
||||
@@ -212,6 +214,34 @@ export function useChatPage() {
|
||||
currentAgentId,
|
||||
});
|
||||
|
||||
const pushLocalAssistantMessage = async (content: string) => {
|
||||
const msgText = String(content || '').trim();
|
||||
if (!msgText) return;
|
||||
const isFirstMessage = messages.value.length === 0;
|
||||
const isTraining = matchesTrainingAgent(agent.currentAgent.value);
|
||||
|
||||
// 如果是培训 Agent 的首条消息(欢迎语),强制重置滚动贴底状态,防止自动滚到底部
|
||||
if (isFirstMessage && isTraining) {
|
||||
scroll.isNearBottom.value = false;
|
||||
}
|
||||
|
||||
const assistantMsg: ChatMessage = {
|
||||
role: 'assistant',
|
||||
type: 'text',
|
||||
content: msgText,
|
||||
local_id: newLocalMessageId('local-assistant'),
|
||||
local_only: true,
|
||||
};
|
||||
messages.value.push(assistantMsg);
|
||||
await saveLocalMessageToBackend(assistantMsg);
|
||||
|
||||
// 再次确保滚到顶部展示欢迎语
|
||||
if (isFirstMessage && isTraining) {
|
||||
await nextTick();
|
||||
scroll.scrollToTop();
|
||||
}
|
||||
};
|
||||
|
||||
const presetQuestion = computed(() => {
|
||||
const q = route.query.preset;
|
||||
return typeof q === 'string' ? q : '';
|
||||
@@ -286,6 +316,27 @@ export function useChatPage() {
|
||||
t,
|
||||
});
|
||||
|
||||
const pushLocalUserMessage = async (content: string) => {
|
||||
const msgText = String(content || '').trim();
|
||||
if (!msgText) return;
|
||||
const userMsg: ChatMessage = {
|
||||
role: 'user',
|
||||
type: 'text',
|
||||
content: msgText,
|
||||
local_id: newLocalMessageId('local-user'),
|
||||
local_only: true,
|
||||
};
|
||||
messages.value.push(userMsg);
|
||||
await saveLocalMessageToBackend(userMsg);
|
||||
};
|
||||
|
||||
const training = useTrainingWorkspace({
|
||||
currentAgent: computed(() => agent.currentAgent.value),
|
||||
currentUser: computed(() => currentUser.value),
|
||||
pushLocalAssistantMessage,
|
||||
pushLocalUserMessage,
|
||||
});
|
||||
|
||||
const markdown = createChatPageMarkdownApi({
|
||||
messages,
|
||||
isThinking,
|
||||
@@ -361,6 +412,7 @@ export function useChatPage() {
|
||||
|
||||
const leaveMessageHandlers = createLeaveMessageHandlers(leave);
|
||||
const shippingMappingHandlers = createShippingMappingHandlers(shipping);
|
||||
const trainingHandlers = createTrainingHandlers(training);
|
||||
const shippingPickerRefHolder = markRaw(createShippingPickerRefHolder(shipping.shippingInventoryPickerRef));
|
||||
const shippingNoticePickerRefHolder = markRaw(createShippingPickerRefHolder(shipping.shippingNoticePickerRef));
|
||||
|
||||
@@ -452,9 +504,11 @@ export function useChatPage() {
|
||||
isVoiceRecording: voice.isVoiceRecording,
|
||||
isVoiceTranscribing: voice.isVoiceTranscribing,
|
||||
handleVoiceFeatureClick: voice.handleVoiceFeatureClick,
|
||||
training,
|
||||
...leave,
|
||||
leaveMessageHandlers,
|
||||
shippingMappingHandlers,
|
||||
trainingHandlers,
|
||||
shippingPickerRefHolder,
|
||||
shippingNoticePickerRefHolder,
|
||||
shouldShowThinkingBubble: markdown.shouldShowThinkingBubble,
|
||||
@@ -462,6 +516,7 @@ export function useChatPage() {
|
||||
shouldRenderMessage: markdown.shouldRenderMessage,
|
||||
canSendMessage: sendApi.canSendMessage,
|
||||
handleSend: sendApi.handleSend,
|
||||
pushLocalAssistantMessage,
|
||||
copyToClipboard: sendApi.copyToClipboard,
|
||||
regenerate: sendApi.regenerate,
|
||||
handleOpenFeedback: dialogs.handleOpenFeedback,
|
||||
|
||||
Reference in new issue
Block a user