fix(macos): chat history loading slow problem (#212)

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Haze <hazeone@users.noreply.github.com>
This commit is contained in:
Haze
2026-02-28 00:01:44 +08:00
committed by GitHub
Unverified
parent 386d4c5454
commit 96bd37d1b1
2 changed files with 22 additions and 9 deletions

View File

@@ -38,14 +38,19 @@ export function Chat() {
const messagesEndRef = useRef<HTMLDivElement>(null);
const [streamingTimestamp, setStreamingTimestamp] = useState<number>(0);
// Load data when gateway is running
// Load data when gateway is running.
// When the store already holds messages for this session (i.e. the user
// is navigating *back* to Chat), use quiet mode so the existing messages
// stay visible while fresh data loads in the background. This avoids
// an unnecessary messages → spinner → messages flicker.
useEffect(() => {
if (!isGatewayRunning) return;
let cancelled = false;
const hasExistingMessages = useChatStore.getState().messages.length > 0;
(async () => {
await loadSessions();
if (cancelled) return;
await loadHistory();
await loadHistory(hasExistingMessages);
})();
return () => {
cancelled = true;