Fully autonomous AI Agents system capable of performing complex penetration testing tasks
Go ai-agentsai-security-toolanthropicautonomous-agentsgolanggptgraphqlmulti-agent-systemoffensive-securityopen-sourceopenaipenetration-testingpenetration-testing-toolsreactsecurity-automationsecurity-testingsecurity-toolsself-hosted
style(frontend): trim war-story comments in InputSearch
Sergey Kozyrenko4396aa774fa2
diff --git a/frontend/src/components/ui/input-search.tsx b/frontend/src/components/ui/input-search.tsxindex eee3e795..8349e54d 100644--- a/frontend/src/components/ui/input-search.tsx+++ b/frontend/src/components/ui/input-search.tsx@@ -9,27 +9,17 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltipimport { cn } from '@/lib/utils';import { isMac } from '@/lib/utils/platform';-// Keystrokes hit `localValue` synchronously for an instant UI response; the-// upstream emit is debounced via `useDebouncedCallback` (see below). Same-// shape and timing as `DataTableFilter` so both search inputs on a page-// share one "feels responsive" target.+// Matches `DataTableFilter`'s debounce so both search inputs on a page settle+// at the same pace.const COMMIT_DEBOUNCE_MS = 150;interface InputSearchProps {- /** Accessible label for the trigger button + the input. */+ /** Accessible label for the trigger and the input. */ariaLabel?: string;className?: string;- /**- * Lowercase character that, combined with the platform modifier (⌘ on- * macOS, Ctrl elsewhere), expands and focuses the input from anywhere on- * the page. Pass `null` to disable the global hotkey entirely — useful on- * pages that should not steal the browser's own bindings. Default `'f'`.- */+ /** Lowercase key combined with the platform modifier (⌘/Ctrl) to expand from anywhere. `null` disables. */hotkey?: null | string;- /**- * Width (px or any CSS length) the input grows to once expanded. The- * collapsed state is always just the icon. Default `140`.- */+ /** Expanded input width (default `140`). Collapsed state is always icon-only. */maxWidth?: number | string;onSearchChange: (value: string) => void;placeholder?: string;@@ -37,33 +27,10 @@ interface InputSearchProps {}/**- * Collapsible search input. Idle state shows only a `<Search>` icon button;- * clicking it (or pressing the configured hotkey) expands a controlled text- * input with a smooth width animation. Blurring an empty input collapses it- * back.- *- * Clearing the value has two equivalent entry points:- * - A trailing `<X>` button rendered only while the field has content- * (mirrors `DataTableFilter` so every search field across the app shares- * the same shape).- * - First `Escape` press — same effect, useful when the user's hand is on- * the keyboard. A second `Escape` on an already-empty field collapses- * and blurs.- *- * Both paths route through `handleClear`, which cancels any pending- * debounce, emits `''` upstream, and keeps focus on the input — so the- * field stays open and ready for fresh typing rather than collapsing out- * from under the user.- *- * The trigger is a real `<button>` (via `InputGroupButton`) — never a `<div>`- * with `onClick` — so the control is reachable with Tab and announced by- * screen readers. The input lives outside that button, so we don't nest- * interactive elements (an `<input>` inside a `<button>` is invalid HTML).- *- * The component is controlled — parent owns `searchQuery` and reacts to- * `onSearchChange`. The only local state is the expand/collapse presentation- * flag; the initial value mirrors whether the controlled query is non-empty,- * so deep-linking to `?qs=foo` lands directly in the expanded state.+ * Collapsible search input. Icon-only when idle; clicking it (or pressing+ * `Mod`+`hotkey`) expands a controlled text input. Clearing has two equivalent+ * paths — the trailing `<X>` button and the first `Escape` press; both route+ * through `handleClear`. A second `Escape` on an empty field collapses + blurs.*/export function InputSearch({ariaLabel = 'Search',@@ -74,17 +41,8 @@ export function InputSearch({placeholder = 'Search...',searchQuery,}: InputSearchProps) {- // Initialise expanded if the parent already has a non-empty query: a- // shared link with `?qs=foo` should land expanded, not behind the icon.const [isExpanded, setIsExpanded] = useState(() => searchQuery.trim().length > 0);const inputRef = useRef<HTMLInputElement>(null);-- // Same two-cell shape as `DataTableFilter`: `localValue` drives the input- // (synchronous, instant caret response); `lastEmittedReference` records- // the most recent value we handed upstream so the external-sync effect- // can distinguish our own round-trip from a true external change. All- // timer logic lives inside `useDebouncedCallback` — see its docstring- // for the rationale.const [localValue, setLocalValue] = useState(searchQuery);const lastEmittedReference = useRef(searchQuery);@@ -97,10 +55,8 @@ export function InputSearch({onSearchChange(next);}, COMMIT_DEBOUNCE_MS);- // External → local sync. Runs only when `searchQuery` is something we- // didn't emit ourselves — programmatic wipe of `?qs=`, back button,- // sibling control. Any in-flight debounce of locally-typed text is- // cancelled synchronously; the external value wins, by design.+ // External → local sync. Outside source (back button, programmatic clear,+ // sibling control) wins; in-flight typed debounce is dropped.useEffect(() => {if (searchQuery === lastEmittedReference.current) {return;@@ -113,13 +69,6 @@ export function InputSearch({const expand = useCallback(() => setIsExpanded(true), []);- // Hint shown over the collapsed trigger. The hotkey badge mirrors the- // platform's modifier glyph (⌘ on Apple, Ctrl elsewhere) so the tooltip- // is actionable — the user sees the exact keys they can press without- // having to discover them by trial. `<Kbd>` already self-themes for- // `[data-slot=tooltip-content]` containers (see `components/ui/kbd.tsx`),- // so no extra styling is needed to make the chip readable on the dark- // tooltip surface.const tooltipContent = useMemo(() => {if (!hotkey) {return placeholder;@@ -138,10 +87,8 @@ export function InputSearch({);}, [hotkey, placeholder]);- // Focus the input the frame after it appears. `rAF` defers past the same- // commit so motion's transform has started, otherwise focus can land on- // a still-zero-width box and the user's caret blinks invisibly until the- // animation completes.+ // `rAF` so motion's transform has started before we focus — otherwise the+ // caret lands on a zero-width box.useEffect(() => {if (!isExpanded) {return;@@ -152,9 +99,6 @@ export function InputSearch({return () => cancelAnimationFrame(id);}, [isExpanded]);- // Global hotkey: Mod+<hotkey> from anywhere on the page. We hijack the- // browser default (e.g. Ctrl+F's "find in page") only for the exact- // configured key — pass `null` to opt out entirely.useEffect(() => {if (!hotkey) {return;@@ -180,20 +124,16 @@ export function InputSearch({return () => document.removeEventListener('keydown', handleKeyDown);}, [expand, hotkey]);- // Blur collapses when the value is empty — the classic "lost interest"- // exit. Reads `localValue`, not the prop: a user who typed then blurred- // before the debounce flushed still has visible text in the field, and- // collapsing that out from under them would feel like a data-loss bug.+ // Reads `localValue`, not the prop: a user who typed and blurred before+ // the debounce flushed should keep seeing their text.const handleInputBlur = useCallback(() => {if (localValue.trim().length === 0) {setIsExpanded(false);}}, [localValue]);- // Belt-and-braces for programmatic clears: if the controlled query drops- // to empty while focus is somewhere else entirely (e.g. another effect- // wipes `?qs=` from the URL), this still collapses. The user-blur path- // above handles the common case.+ // Auto-collapse when an external source clears the query while focus is+ // elsewhere; user-initiated blur is handled by `handleInputBlur`.useEffect(() => {if (searchQuery.trim().length > 0) {return;@@ -212,11 +152,8 @@ export function InputSearch({[debouncedEmit],);- // Shared clear path used by both the trailing `<X>` button and the first- // `Escape` press. Focus stays on the input so the programmatic-clear- // collapse effect (the one keyed on `searchQuery`) doesn't fire — the- // user just emptied the value and is presumably about to type again,- // not exit the search.+ // Focus the input at the end so the auto-collapse effect above doesn't+ // fire — the user just emptied the value and is likely to type again.const handleClear = useCallback(() => {setLocalValue('');debouncedEmit.cancel();@@ -229,10 +166,6 @@ export function InputSearch({inputRef.current?.focus();}, [debouncedEmit, onSearchChange]);- // Escape: first press clears the value (via `handleClear`), second press- // collapses + blurs. The clear path cancels any pending debounce- // synchronously, then emits `''` directly — no chance for an in-flight- // typed value to land after.const handleInputKeyDown = useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {if (event.key !== 'Escape') {@@ -256,9 +189,6 @@ export function InputSearch({return (<InputGroupclassName={cn(- // Mirror the `size="sm"` button geometry used by `HeaderButton`- // so the search control lines up vertically with sibling- // actions in any page header (h-8 / rounded-md / px-3).'h-8 w-auto shrink-0 transition-[background-color,border-color,box-shadow] duration-100',isExpanded? 'border-input dark:bg-input/30 shadow-xs'@@ -268,11 +198,6 @@ export function InputSearch({><InputGroupAddonalign="inline-start"- // Collapsed trigger sits flush with the addon edge — the- // addon's default `pl-3` would otherwise add a 12 px gutter- // that wastes header real estate when only the icon is on- // screen. `has-[>button]:ml-[-0.45rem]` already handles the- // analogous adjustment when expanded.className={cn(!isExpanded && '-mx-1.5')}>{isExpanded ? (@@ -308,11 +233,6 @@ export function InputSearch({><InputGroupInputaria-label={ariaLabel}- // `Input` defaults to `h-9` — that's 4 px taller than our- // `h-8` group, which would let the input edge poke past- // the bordered group container. Pin it to the group's- // height; the `min-w-0` is to keep flexbox from- // bottoming out on the implicit `min-content` width.className="h-8 min-w-0 py-0 pl-2"onBlur={handleInputBlur}onChange={handleChange}