MCPcopy Create free account
hub / github.com/RioArisk/claudecode_api_RemoteControl / persistSessionCache

Function persistSessionCache

app/src/modules/renderer.js:399–429  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

397}
398
399async function persistSessionCache() {
400 if (!serverCacheAddr || !S.sessionId) return;
401 const todoSnapshot = getTodoSnapshot();
402 const snapshotRoot = $msgs.cloneNode(true);
403 snapshotRoot.querySelectorAll('[data-optimistic], .working-indicator').forEach(el => el.remove());
404 const record = {
405 cacheKey: buildCacheKey(serverCacheAddr, S.sessionId),
406 serverAddr,
407 sessionId: S.sessionId,
408 html: snapshotRoot.innerHTML,
409 seenUuids: Array.from(S.seenUuids),
410 todoTasks: todoSnapshot.tasks,
411 todoPanelOpen: todoSnapshot.panelOpen,
412 cwd: S.cwd,
413 model: S.model,
414 lastSeq: S.lastSeq,
415 updatedAt: Date.now(),
416 };
417 record.sizeBytes = estimateCacheBytes(record);
418
419 try {
420 if (record.sizeBytes > CHAT_CACHE_MAX_SESSION_BYTES) {
421 await chatCacheDelete(record.cacheKey).catch(() => {});
422 return;
423 }
424 await chatCacheWrite(record);
425 await pruneChatCache();
426 } catch (err) {
427 console.warn('[chat-cache]', err);
428 }
429}
430
431export function scheduleSessionCacheSave() {
432 if (!serverCacheAddr || !S.sessionId) return;

Callers 2

flushSessionCacheSaveFunction · 0.70
scheduleSessionCacheSaveFunction · 0.70

Calls 6

getTodoSnapshotFunction · 0.90
buildCacheKeyFunction · 0.90
estimateCacheBytesFunction · 0.90
chatCacheDeleteFunction · 0.90
chatCacheWriteFunction · 0.90
pruneChatCacheFunction · 0.90

Tested by

no test coverage detected