Merge branch 'codex/0702-optimization'
This commit is contained in:
@@ -129,7 +129,6 @@ export function ChatPanel({
|
|||||||
const [pendingImages, setPendingImages] = useState<PendingChatImage[]>([]);
|
const [pendingImages, setPendingImages] = useState<PendingChatImage[]>([]);
|
||||||
const [uploadingImage, setUploadingImage] = useState(false);
|
const [uploadingImage, setUploadingImage] = useState(false);
|
||||||
const [imageError, setImageError] = useState<string | null>(null);
|
const [imageError, setImageError] = useState<string | null>(null);
|
||||||
const [showHistoryFullyLoadedNotice, setShowHistoryFullyLoadedNotice] = useState(false);
|
|
||||||
const [voiceStopSignal, setVoiceStopSignal] = useState(0);
|
const [voiceStopSignal, setVoiceStopSignal] = useState(0);
|
||||||
const [randomPrompt] = useState(
|
const [randomPrompt] = useState(
|
||||||
() => CHAT_PLACEHOLDER_PROMPTS[Math.floor(Math.random() * CHAT_PLACEHOLDER_PROMPTS.length)],
|
() => CHAT_PLACEHOLDER_PROMPTS[Math.floor(Math.random() * CHAT_PLACEHOLDER_PROMPTS.length)],
|
||||||
@@ -197,22 +196,8 @@ export function ChatPanel({
|
|||||||
initializedSessionRef.current = null;
|
initializedSessionRef.current = null;
|
||||||
pendingOlderLoadRef.current = null;
|
pendingOlderLoadRef.current = null;
|
||||||
nearBottomRef.current = true;
|
nearBottomRef.current = true;
|
||||||
setShowHistoryFullyLoadedNotice(false);
|
|
||||||
}, [session?.id]);
|
}, [session?.id]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const isHomeWelcome = variant !== 'compact' && messages.length === 0;
|
|
||||||
if (isHomeWelcome || historyTotal <= 0 || historyHasMore || historyLoadingMore) {
|
|
||||||
setShowHistoryFullyLoadedNotice(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setShowHistoryFullyLoadedNotice(true);
|
|
||||||
const timer = window.setTimeout(() => {
|
|
||||||
setShowHistoryFullyLoadedNotice(false);
|
|
||||||
}, 5000);
|
|
||||||
return () => window.clearTimeout(timer);
|
|
||||||
}, [historyHasMore, historyLoadingMore, historyTotal, messages.length, variant]);
|
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const container = mainRef.current;
|
const container = mainRef.current;
|
||||||
if (!container) return;
|
if (!container) return;
|
||||||
@@ -555,13 +540,11 @@ export function ChatPanel({
|
|||||||
className={compact ? 'space-chat-panel-body' : `main${showHomeWelcome ? ' main-home' : ''}`}
|
className={compact ? 'space-chat-panel-body' : `main${showHomeWelcome ? ' main-home' : ''}`}
|
||||||
onScroll={handleMainScroll}
|
onScroll={handleMainScroll}
|
||||||
>
|
>
|
||||||
{!showHomeWelcome && (historyLoadingMore || historyHasMore || showHistoryFullyLoadedNotice) && (
|
{!showHomeWelcome && (historyLoadingMore || historyHasMore) && (
|
||||||
<div className="chat-history-loader" role="status">
|
<div className="chat-history-loader" role="status">
|
||||||
{historyLoadingMore
|
{historyLoadingMore
|
||||||
? `正在加载更早消息… 已加载 ${messages.length}${historyTotal > 0 ? ` / ${historyTotal}` : ''}`
|
? `正在加载更早消息… 已加载 ${messages.length}${historyTotal > 0 ? ` / ${historyTotal}` : ''}`
|
||||||
: historyHasMore
|
: `向上滚动加载更早消息${historyTotal > 0 ? ` · 已加载 ${messages.length} / ${historyTotal}` : ''}`}
|
||||||
? `向上滚动加载更早消息${historyTotal > 0 ? ` · 已加载 ${messages.length} / ${historyTotal}` : ''}`
|
|
||||||
: `历史消息已全部加载${historyTotal > 0 ? ` · ${messages.length} / ${historyTotal}` : ''}`}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<MessageList
|
<MessageList
|
||||||
|
|||||||
@@ -377,12 +377,8 @@ export function useTKMindChat(
|
|||||||
setMemoryLoading(true);
|
setMemoryLoading(true);
|
||||||
try {
|
try {
|
||||||
const result = await bootstrapProjectMemory(sessionId, appConfig.memoryQuery, force);
|
const result = await bootstrapProjectMemory(sessionId, appConfig.memoryQuery, force);
|
||||||
if (force) {
|
if (force && !result.summary) {
|
||||||
setNotice(
|
setNotice('未找到可用的项目记忆,当前会话仍可正常使用');
|
||||||
result.summary
|
|
||||||
? `项目记忆已刷新(${result.source})`
|
|
||||||
: '未找到可用的项目记忆,当前会话仍可正常使用',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user