Skip to content

refactor: SearchBox.js is 2692 lines — extract subcomponents for maintainability #2323

Description

@AshayK003

Problem

packages/web/src/components/search/SearchBox.js is 2,692 lines handling at least 6 distinct responsibilities:

  1. Search input management (value, focus, blur, keyboard)
  2. Suggestion rendering (8+ types: popular, recent, FAQ, featured, document, index, endpoint, predictive)
  3. AI Answer mode (full chat UI with session management)
  4. Voice/mic input
  5. Image search with camera
  6. URL param sync

The render method alone spans hundreds of lines with deeply nested ternaries.

Suggested Fix

Extract these as additive subcomponents (non-breaking, each can be a separate PR):

  1. AISection.js — The entire AI answer screen (~L1870-1988)
  2. SuggestionsSection.js — All 8 suggestion types rendering (~L1990-2180)
  3. SearchInput.js — The input element with mic, camera, and autofill addons

Each extraction is verifiable by existing snapshot tests since the composite output is unchanged.

Severity

High — maintainability bottleneck

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions