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

Function processEvent

app/src/modules/renderer.js:481–548  ·  view source on GitHub ↗
(evt, seq)

Source from the content-addressed store, hash-verified

479
480// ---- Event Processing ----
481export function processEvent(evt, seq) {
482 try {
483 if (!evt) return;
484 if (Number.isInteger(seq) && seq > S.lastSeq) S.lastSeq = seq;
485 if (S.seenUuids.has(evt.uuid)) return;
486 if (evt.uuid) S.seenUuids.add(evt.uuid);
487 removeWelcome();
488
489 if (evt.isCompactSummary) {
490 renderCompactSummary(evt);
491 scrollEnd();
492 return;
493 }
494
495 if (evt.type === 'system' && evt.subtype === 'local_command') {
496 const raw = (evt.content || '').replace(/<\/?local-command-stdout>/g, '').replace(/\x1B\[[0-9;]*m/g, '').trim();
497 if (raw.includes('Total cost:')) {
498 renderCostCard(raw);
499 scrollEnd();
500 }
501 return;
502 }
503
504 if (evt.type === 'interrupt') {
505 finalizeOptimisticBubble();
506 renderInterruptBanner(evt);
507 scrollEnd();
508 return;
509 }
510
511 if (evt.type === 'user' && evt.message) {
512 const c = evt.message.content;
513 if (typeof c === 'string' && isJunkContent(c)) return;
514 if (typeof c === 'string' && /^\[Request interrupted by user/.test(c.trim())) return;
515 if (Array.isArray(c) && c.length === 1 && c[0].type === 'text' &&
516 /^\[Request interrupted by user/.test(c[0].text)) return;
517 const planPrefix = 'Implement the following plan:';
518 const rawText = typeof c === 'string' ? c
519 : (Array.isArray(c) && c.length >= 1 && c[0].type === 'text' ? c[0].text : '');
520 if (rawText.trimStart().startsWith(planPrefix)) {
521 let planBody = rawText.trimStart().slice(planPrefix.length).trim();
522 const boilerplateIdx = planBody.indexOf('\nIf you need specific details from before exiting plan mode');
523 if (boilerplateIdx !== -1) planBody = planBody.slice(0, boilerplateIdx).trim();
524 if (planBody) {
525 renderPlanCard(planBody);
526 return;
527 }
528 }
529 }
530 if (evt.type === 'assistant' && evt.message) {
531 const blocks = evt.message.content;
532 if (Array.isArray(blocks) && blocks.length === 1 && blocks[0].type === 'text') {
533 const txt = blocks[0].text;
534 if (isJunkContent(txt)) return;
535 }
536 }
537
538 if (evt.type === 'user' && evt.message) renderUser(evt);

Callers 1

connectFunction · 0.90

Calls 12

scrollEndFunction · 0.90
switchToWorkingFunction · 0.90
removeWelcomeFunction · 0.70
renderCompactSummaryFunction · 0.70
renderCostCardFunction · 0.70
finalizeOptimisticBubbleFunction · 0.70
renderInterruptBannerFunction · 0.70
isJunkContentFunction · 0.70
renderPlanCardFunction · 0.70
renderUserFunction · 0.70
renderAssistantFunction · 0.70
scheduleSessionCacheSaveFunction · 0.70

Tested by

no test coverage detected