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 { isQuitting, setQuitting } from './app-state';
|
||||
|
||||
// Disable GPU acceleration only on Linux where GPU driver issues are common.
|
||||
// On Windows and macOS, hardware acceleration is essential for responsive UI;
|
||||
// forcing CPU rendering makes the main thread compete with sync I/O and
|
||||
// contributes to "Not Responding" hangs.
|
||||
if (process.platform === 'linux') {
|
||||
app.disableHardwareAcceleration();
|
||||
}
|
||||
// Disable GPU hardware acceleration globally for maximum stability across
|
||||
// all GPU configurations (no GPU, integrated, discrete).
|
||||
//
|
||||
// Rationale (following VS Code's philosophy):
|
||||
// - Page/file loading is async data fetching — zero GPU dependency.
|
||||
// - 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
|
||||
let mainWindow: BrowserWindow | null = null;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user