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

Function TranscriptSearchBar

source code/screens/REPL.tsx:370–474  ·  view source on GitHub ↗

less-style / bar. 1-row, same border-top styling as TranscriptModeFooter * so swapping them in the bottom slot doesn't shift ScrollBox height. * useSearchInput handles readline editing; we report query changes and * render the counter. Incremental — re-search + highlight per keystroke.

({
  jumpRef,
  count,
  current,
  onClose,
  onCancel,
  setHighlight,
  initialQuery
}: {
  jumpRef: RefObject<JumpHandle | null>;
  count: number;
  current: number;
  /** Enter — commit. Query persists for n/N. */
  onClose: (lastQuery: string) => void;
  /** Esc/ctrl+c/ctrl+g — undo to pre-/ state. */
  onCancel: () => void;
  setHighlight: (query: string) => void;
  // Seed with the previous query (less: / shows last pattern). Mount-fire
  // of the effect re-scans with the same query — idempotent (same matches,
  // nearest-ptr, same highlights). User can edit or clear.
  initialQuery: string;
})

Source from the content-addressed store, hash-verified

368 * useSearchInput handles readline editing; we report query changes and
369 * render the counter. Incremental — re-search + highlight per keystroke. */
370function TranscriptSearchBar({
371 jumpRef,
372 count,
373 current,
374 onClose,
375 onCancel,
376 setHighlight,
377 initialQuery
378}: {
379 jumpRef: RefObject<JumpHandle | null>;
380 count: number;
381 current: number;
382 /** Enter — commit. Query persists for n/N. */
383 onClose: (lastQuery: string) => void;
384 /** Esc/ctrl+c/ctrl+g — undo to pre-/ state. */
385 onCancel: () => void;
386 setHighlight: (query: string) => void;
387 // Seed with the previous query (less: / shows last pattern). Mount-fire
388 // of the effect re-scans with the same query — idempotent (same matches,
389 // nearest-ptr, same highlights). User can edit or clear.
390 initialQuery: string;
391}): React.ReactNode {
392 const {
393 query,
394 cursorOffset
395 } = useSearchInput({
396 isActive: true,
397 initialQuery,
398 onExit: () => onClose(query),
399 onCancel
400 });
401 // Index warm-up runs before the query effect so it measures the real
402 // cost — otherwise setSearchQuery fills the cache first and warm
403 // reports ~0ms while the user felt the actual lag.
404 // First / in a transcript session pays the extractSearchText cost.
405 // Subsequent / return 0 immediately (indexWarmed ref in VML).
406 // Transcript is frozen at ctrl+o so the cache stays valid.
407 // Initial 'building' so warmDone is false on mount — the [query] effect
408 // waits for the warm effect's first resolve instead of racing it. With
409 // null initial, warmDone would be true on mount → [query] fires →
410 // setSearchQuery fills cache → warm reports ~0ms while the user felt
411 // the real lag.
412 const [indexStatus, setIndexStatus] = React.useState<'building' | {
413 ms: number;
414 } | null>('building');
415 React.useEffect(() => {
416 let alive = true;
417 const warm = jumpRef.current?.warmSearchIndex;
418 if (!warm) {
419 setIndexStatus(null); // VML not mounted yet — rare, skip indicator
420 return;
421 }
422 setIndexStatus('building');
423 warm().then(ms => {
424 if (!alive) return;
425 // <20ms = imperceptible. No point showing "indexed in 3ms".
426 if (ms < 20) {
427 setIndexStatus(null);

Callers

nothing calls this directly

Calls 1

useSearchInputFunction · 0.85

Tested by

no test coverage detected