Inline base64 source maps had been checked into tracked src files. This strips those comments from the repository without changing runtime behavior or adding ongoing guardrails, per the requested one-time cleanup scope. Constraint: Keep this change limited to tracked source cleanup only Rejected: Add CI/source verification guard | user requested one-time cleanup only Confidence: high Scope-risk: narrow Reversibility: clean Directive: If these directives reappear, fix the producing transform instead of reintroducing repo-side cleanup code Tested: rg -n "sourceMappingURL" ., bun run smoke, bun run verify:privacy, bun run test:provider, npm run test:provider-recommendation Not-tested: bun run typecheck (repository has many pre-existing unrelated failures) Co-authored-by: anandh8x <test@example.com>
44 lines
1.8 KiB
TypeScript
44 lines
1.8 KiB
TypeScript
import React, { useContext, useRef } from 'react';
|
|
import { useTerminalViewport } from '../ink/hooks/use-terminal-viewport.js';
|
|
import { Box } from '../ink.js';
|
|
import { InVirtualListContext } from './messageActions.js';
|
|
type Props = {
|
|
children: React.ReactNode;
|
|
};
|
|
|
|
/**
|
|
* Freezes children when they scroll above the terminal viewport (into scrollback).
|
|
*
|
|
* Any content change above the viewport forces log-update.ts into a full terminal
|
|
* reset (it cannot partially update rows that have scrolled out). For content that
|
|
* updates on a timer — spinners, elapsed counters — this produces a reset per tick.
|
|
*
|
|
* When offscreen, returns the same ReactElement reference that was cached during
|
|
* the last visible render. React's reconciler bails on identical element refs, so
|
|
* the subtree never re-renders, producing zero diff.
|
|
*
|
|
* The cache is one slot deep: the first re-render after scrolling back into view
|
|
* picks up the live children. Content still updates normally while visible.
|
|
*/
|
|
export function OffscreenFreeze({
|
|
children
|
|
}: Props): React.ReactNode {
|
|
// React Compiler: reading cached.current in the return is the entire
|
|
// freeze mechanism — memoizing this component would defeat it. Opt out.
|
|
'use no memo';
|
|
|
|
const inVirtualList = useContext(InVirtualListContext);
|
|
const [ref, {
|
|
isVisible
|
|
}] = useTerminalViewport();
|
|
const cached = useRef(children);
|
|
// Virtual list has no terminal scrollback — the ScrollBox clips inside the
|
|
// viewport, so there's nothing to freeze. Freezing there also blocks
|
|
// click-to-expand since useTerminalViewport's visibility calc can disagree
|
|
// with the ScrollBox's virtual scroll position.
|
|
if (isVisible || inVirtualList) {
|
|
cached.current = children;
|
|
}
|
|
return <Box ref={ref}>{cached.current}</Box>;
|
|
}
|