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

Function attachResult

app/src/modules/renderer.js:836–881  ·  view source on GitHub ↗
(b)

Source from the content-addressed store, hash-verified

834}
835
836function attachResult(b) {
837 const info = S.toolMap.get(b.tool_use_id);
838 if (!info) return;
839 info.item.classList.remove('loading');
840 const isErr = b.is_error === true;
841 if (isErr) info.detail.classList.add('error');
842
843 let text = '';
844 let images = [];
845 if (typeof b.content === 'string') {
846 text = b.content;
847 } else if (Array.isArray(b.content)) {
848 const textParts = [];
849 for (const c of b.content) {
850 if (c.type === 'image' && c.source && c.source.data) {
851 const mediaType = c.source.media_type || 'image/png';
852 images.push({ data: c.source.data, mediaType });
853 } else if (c.text) {
854 textParts.push(c.text);
855 } else {
856 textParts.push(JSON.stringify(c));
857 }
858 }
859 text = textParts.join('\n');
860 }
861
862 const resultEl = info.detail.querySelector('.detail-result');
863 if (resultEl) {
864 resultEl.textContent = trunc(text, 3000);
865 if (isErr) resultEl.style.color = 'var(--error)';
866 }
867
868 if (images.length > 0) {
869 closeGroup();
870 for (const img of images) {
871 const wrapper = document.createElement('div');
872 wrapper.className = 'result-image-block';
873 const imgEl = document.createElement('img');
874 imgEl.src = `data:${img.mediaType};base64,${img.data}`;
875 imgEl.addEventListener('click', () => showImageOverlay(imgEl.src));
876 wrapper.appendChild(imgEl);
877 $msgs.appendChild(wrapper);
878 }
879 scrollEnd();
880 }
881}
882
883// ---- Init delegated click handlers ----
884export function initRenderer() {

Callers 1

renderUserFunction · 0.70

Calls 4

truncFunction · 0.90
scrollEndFunction · 0.90
closeGroupFunction · 0.70
showImageOverlayFunction · 0.70

Tested by

no test coverage detected