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>
58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import { c as _c } from "react-compiler-runtime";
|
|
import { createContext, type RefObject, useContext } from 'react';
|
|
import type { ScrollBoxHandle } from '../ink/components/ScrollBox.js';
|
|
|
|
/**
|
|
* Set by FullscreenLayout when rendering content in its `modal` slot —
|
|
* the absolute-positioned bottom-anchored pane for slash-command dialogs.
|
|
* Consumers use this to:
|
|
*
|
|
* - Suppress top-level framing — `Pane` skips its full-terminal-width
|
|
* `Divider` (FullscreenLayout already draws the ▔ divider).
|
|
* - Size Select pagination to the available rows — the modal's inner
|
|
* area is smaller than the terminal (rows minus transcript peek minus
|
|
* divider), so components that cap their visible option count from
|
|
* `useTerminalSize().rows` would overflow without this context.
|
|
* - Reset scroll on tab switch — Tabs keys its ScrollBox by
|
|
* `selectedTabIndex`, remounting on tab switch so scrollTop resets to 0
|
|
* without scrollTo() timing games.
|
|
*
|
|
* null = not inside the modal slot.
|
|
*/
|
|
type ModalCtx = {
|
|
rows: number;
|
|
columns: number;
|
|
scrollRef: RefObject<ScrollBoxHandle | null> | null;
|
|
};
|
|
export const ModalContext = createContext<ModalCtx | null>(null);
|
|
export function useIsInsideModal() {
|
|
return useContext(ModalContext) !== null;
|
|
}
|
|
|
|
/**
|
|
* Available content rows/columns when inside a Modal, else falls back to
|
|
* the provided terminal size. Use instead of `useTerminalSize()` when a
|
|
* component caps its visible content height — the modal's inner area is
|
|
* smaller than the terminal.
|
|
*/
|
|
export function useModalOrTerminalSize(fallback) {
|
|
const $ = _c(3);
|
|
const ctx = useContext(ModalContext);
|
|
let t0;
|
|
if ($[0] !== ctx || $[1] !== fallback) {
|
|
t0 = ctx ? {
|
|
rows: ctx.rows,
|
|
columns: ctx.columns
|
|
} : fallback;
|
|
$[0] = ctx;
|
|
$[1] = fallback;
|
|
$[2] = t0;
|
|
} else {
|
|
t0 = $[2];
|
|
}
|
|
return t0;
|
|
}
|
|
export function useModalScrollRef() {
|
|
return useContext(ModalContext)?.scrollRef ?? null;
|
|
}
|