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

Function restoreSessionCache

app/src/modules/renderer.js:348–389  ·  view source on GitHub ↗
(sessionId)

Source from the content-addressed store, hash-verified

346
347// ---- Session cache integration ----
348export async function restoreSessionCache(sessionId) {
349 debugLog('restore_session_cache_start', { sessionId });
350 if (!serverCacheAddr || !sessionId) return false;
351
352 let record;
353 try {
354 record = await chatCacheRead(buildCacheKey(serverCacheAddr, sessionId));
355 } catch {
356 return false;
357 }
358 if (!record || !record.html) {
359 debugLog('restore_session_cache_miss', { sessionId });
360 return false;
361 }
362
363 $msgs.innerHTML = record.html;
364 $msgs.querySelectorAll('[data-optimistic], .working-indicator').forEach(el => el.remove());
365 S.seenUuids = new Set(Array.isArray(record.seenUuids) ? record.seenUuids : []);
366 S.lastSeq = Number.isInteger(record.lastSeq) ? record.lastSeq : 0;
367 S.cwd = record.cwd || S.cwd;
368 S.model = record.model || '';
369 restoreTodoSnapshot({
370 tasks: Array.isArray(record.todoTasks) ? record.todoTasks : [],
371 panelOpen: !!record.todoPanelOpen,
372 });
373 rebuildRuntimeStateFromDom();
374 removeWorkingIndicator();
375 $input.disabled = false;
376 $('btn-send').disabled = false;
377 $('input-area').classList.remove('waiting');
378 $input.placeholder = INPUT_PLACEHOLDER_DEFAULT;
379 updateHeaderInfo();
380 updateSendBtn();
381 updateScrollBtn();
382 requestAnimationFrame(() => { $chat.scrollTop = $chat.scrollHeight; });
383 debugLog('restore_session_cache_done', {
384 sessionId,
385 lastSeq: S.lastSeq,
386 waiting: S.waiting,
387 });
388 return true;
389}
390
391export async function flushSessionCacheSave() {
392 if (S.cacheSaveTimer) {

Callers 1

syncSessionStateFunction · 0.90

Calls 10

debugLogFunction · 0.90
chatCacheReadFunction · 0.90
buildCacheKeyFunction · 0.90
restoreTodoSnapshotFunction · 0.90
removeWorkingIndicatorFunction · 0.90
$Function · 0.90
updateSendBtnFunction · 0.90
updateScrollBtnFunction · 0.90
updateHeaderInfoFunction · 0.70

Tested by

no test coverage detected