MCPcopy
hub / github.com/steipete/oracle / renderLiveChunk

Function renderLiveChunk

src/cli/sessionDisplay.ts:183–212  ·  view source on GitHub ↗
(chunk: string)

Source from the content-addressed store, hash-verified

181
182 let lastLength = 0;
183 const renderLiveChunk = (chunk: string): void => {
184 if (!liveRenderState || chunk.length === 0) {
185 process.stdout.write(chunk);
186 return;
187 }
188 if (liveRenderState.fallback) {
189 process.stdout.write(chunk);
190 return;
191 }
192
193 liveRenderState.pending += chunk;
194 const { chunks, remainder } = extractRenderableChunks(liveRenderState.pending, liveRenderState);
195 liveRenderState.pending = remainder;
196
197 for (const candidate of chunks) {
198 const projected = liveRenderState.renderedBytes + Buffer.byteLength(candidate, 'utf8');
199 if (projected > MAX_RENDER_BYTES) {
200 if (!liveRenderState.noticedFallback) {
201 console.log(dim(`Render skipped (log too large: > ${MAX_RENDER_BYTES} bytes). Showing raw text.`));
202 liveRenderState.noticedFallback = true;
203 }
204 liveRenderState.fallback = true;
205 process.stdout.write(candidate + liveRenderState.pending);
206 liveRenderState.pending = '';
207 return;
208 }
209 process.stdout.write(renderMarkdownAnsi(candidate));
210 liveRenderState.renderedBytes += Buffer.byteLength(candidate, 'utf8');
211 }
212 };
213
214 const flushRemainder = (): void => {
215 if (!liveRenderState || liveRenderState.fallback) {

Callers 1

printNewFunction · 0.85

Calls 3

extractRenderableChunksFunction · 0.85
renderMarkdownAnsiFunction · 0.85
dimFunction · 0.70

Tested by

no test coverage detected