MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getRenderContext

Function getRenderContext

source code/interactiveHelpers.tsx:301–367  ·  view source on GitHub ↗
(exitOnCtrlC: boolean)

Source from the content-addressed store, hash-verified

299 return onboardingShown;
300}
301export function getRenderContext(exitOnCtrlC: boolean): {
302 renderOptions: RenderOptions;
303 getFpsMetrics: () => FpsMetrics | undefined;
304 stats: StatsStore;
305} {
306 let lastFlickerTime = 0;
307 const baseOptions = getBaseRenderOptions(exitOnCtrlC);
308
309 // Log analytics event when stdin override is active
310 if (baseOptions.stdin) {
311 logEvent('tengu_stdin_interactive', {});
312 }
313 const fpsTracker = new FpsTracker();
314 const stats = createStatsStore();
315 setStatsStore(stats);
316
317 // Bench mode: when set, append per-frame phase timings as JSONL for
318 // offline analysis by bench/repl-scroll.ts. Captures the full TUI
319 // render pipeline (yoga → screen buffer → diff → optimize → stdout)
320 // so perf work on any phase can be validated against real user flows.
321 const frameTimingLogPath = process.env.CLAUDE_CODE_FRAME_TIMING_LOG;
322 return {
323 getFpsMetrics: () => fpsTracker.getMetrics(),
324 stats,
325 renderOptions: {
326 ...baseOptions,
327 onFrame: event => {
328 fpsTracker.record(event.durationMs);
329 stats.observe('frame_duration_ms', event.durationMs);
330 if (frameTimingLogPath && event.phases) {
331 // Bench-only env-var-gated path: sync write so no frames dropped
332 // on abrupt exit. ~100 bytes at ≤60fps is negligible. rss/cpu are
333 // single syscalls; cpu is cumulative — bench side computes delta.
334 const line =
335 // eslint-disable-next-line custom-rules/no-direct-json-operations -- tiny object, hot bench path
336 JSON.stringify({
337 total: event.durationMs,
338 ...event.phases,
339 rss: process.memoryUsage.rss(),
340 cpu: process.cpuUsage()
341 }) + '\n';
342 // eslint-disable-next-line custom-rules/no-sync-fs -- bench-only, sync so no frames dropped on exit
343 appendFileSync(frameTimingLogPath, line);
344 }
345 // Skip flicker reporting for terminals with synchronized output —
346 // DEC 2026 buffers between BSU/ESU so clear+redraw is atomic.
347 if (isSynchronizedOutputSupported()) {
348 return;
349 }
350 for (const flicker of event.flickers) {
351 if (flicker.reason === 'resize') {
352 continue;
353 }
354 const now = Date.now();
355 if (now - lastFlickerTime < 1000) {
356 logEvent('tengu_flicker', {
357 desiredHeight: flicker.desiredHeight,
358 actualHeight: flicker.availableHeight,

Callers 1

runFunction · 0.85

Calls 8

getMetricsMethod · 0.95
recordMethod · 0.95
appendFileSyncFunction · 0.90
getBaseRenderOptionsFunction · 0.85
logEventFunction · 0.85
createStatsStoreFunction · 0.85
setStatsStoreFunction · 0.85

Tested by

no test coverage detected