Files
Toju/electron/diagnostics/high-memory-alert.store.spec.ts
Myx bb0ac930ad
All checks were successful
Queue Release Build / prepare (push) Successful in 20s
Deploy Web Apps / deploy (push) Successful in 9m2s
Queue Release Build / build-windows (push) Successful in 28m8s
Queue Release Build / build-linux (push) Successful in 47m26s
Queue Release Build / build-android (push) Successful in 19m52s
Queue Release Build / finalize (push) Successful in 4m42s
Improve attachment memory safety, downloads, and high-memory alert UX.
Stream large receives to disk with chunk acks to cap renderer RAM, evict
off-screen display blobs, and route exports through a disk-aware download
service. Fix the high-memory dialog (backdrop dismiss, copy, log actions),
allow diagnostics paths in the path jail, and restore persisted image
hydration after reload.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-14 00:25:22 +02:00

66 lines
1.7 KiB
TypeScript

import * as fsp from 'fs/promises';
import * as os from 'os';
import * as path from 'path';
import {
afterEach,
describe,
expect,
it
} from 'vitest';
import {
clearHighMemoryAlert,
readHighMemoryAlert,
resolveHighMemoryAlertPath,
writeHighMemoryAlert
} from './high-memory-alert.store';
describe('high-memory-alert.store', () => {
const tempDirs: string[] = [];
afterEach(async () => {
await Promise.all(tempDirs.splice(0).map((dir) => fsp.rm(dir, {
recursive: true,
force: true
})));
});
it('writes and reads a pending startup alert record', async () => {
const userDataPath = await fsp.mkdtemp(path.join(os.tmpdir(), 'metoyou-high-memory-'));
tempDirs.push(userDataPath);
const record = {
logFilePath: path.join(userDataPath, 'diagnostics', 'perf-session.jsonl'),
detectedAt: 1_700_000_000_000,
peakWorkingSetKb: 2_200_000,
sessionId: 'session-1',
reason: 'threshold' as const
};
await writeHighMemoryAlert(userDataPath, record);
expect(resolveHighMemoryAlertPath(userDataPath)).toBe(
path.join(userDataPath, 'diagnostics', 'high-memory-pending.json')
);
expect(await readHighMemoryAlert(userDataPath)).toEqual(record);
});
it('clears the pending startup alert record', async () => {
const userDataPath = await fsp.mkdtemp(path.join(os.tmpdir(), 'metoyou-high-memory-'));
tempDirs.push(userDataPath);
await writeHighMemoryAlert(userDataPath, {
logFilePath: '/tmp/perf.jsonl',
detectedAt: Date.now(),
peakWorkingSetKb: 2_100_000,
sessionId: 'session-2'
});
await clearHighMemoryAlert(userDataPath);
expect(await readHighMemoryAlert(userDataPath)).toBeNull();
});
});