Skip to content

perf: Migrate all-files search to Web Worker for UI responsiveness #293

@pedropaulovc

Description

@pedropaulovc

Problem

The current "Find in All Files" (Ctrl+Shift+F) search executes synchronously on the main thread. For large PRs with many files, this could block the UI and make the application feel unresponsive.

Location: src/app/[owner]/[repo]/[number]/page.tsx - handleExecuteSearch callback

Proposed Solution

Migrate the search logic to a Web Worker to keep the main thread free for UI updates.

Implementation Approach

  1. Create a new search worker in src/features/search/workers/search-worker.ts
  2. Move the search loop logic (file filtering, patch parsing, match finding) to the worker
  3. Use postMessage to send search parameters and receive results
  4. Show a progress indicator during search (already have isSearching state)
  5. Support cancellation for long-running searches

Benefits

  • UI remains responsive during search
  • Can show real-time progress (X of Y files searched)
  • Can cancel in-flight searches when user types new query
  • Consistent with existing src/features/diff/workers/diff-engine.ts pattern

Acceptance Criteria

  • Search executes in Web Worker, not main thread
  • UI remains responsive during search of large PRs (100+ files)
  • Progress indicator shows search status
  • User can cancel in-progress search
  • Unit tests for worker message handling

Context

Identified during PR #292 code review by Copilot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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