Skip to content

refactor(web): remove redundant double parse of diff route search params#598

Merged
t3dotgg merged 1 commit intopingdotgg:mainfrom
binbandit:refactor/remove-redundant-diff-search-parse
Mar 9, 2026
Merged

refactor(web): remove redundant double parse of diff route search params#598
t3dotgg merged 1 commit intopingdotgg:mainfrom
binbandit:refactor/remove-redundant-diff-search-parse

Conversation

@binbandit
Copy link
Contributor

@binbandit binbandit commented Mar 9, 2026

Summary

rawSearch in ChatView is produced by useSearch with a select transform that runs parseDiffRouteSearch. A subsequent useMemo re-parsed the already-parsed result through the same function using an unsafe as Record<string, unknown> cast, producing an identical DiffRouteSearch object.

This removes the redundant useMemo + re-parse and reads rawSearch.diff directly, since rawSearch is already typed as DiffRouteSearch.

Change

  • Removed the diffSearch useMemo that called parseDiffRouteSearch(rawSearch as Record<string, unknown>)
  • Replaced diffSearch.diff === "1" with rawSearch.diff === "1"
  • Net: -5 lines, eliminates an unnecessary re-parse and an unsafe type cast

Verification

  • bun lint — passes (only pre-existing warnings)
  • bun typecheck — passes across all 7 packages
  • bun run test — passes (pre-existing terminalStateStore.test.ts failures unrelated)

Note

Remove redundant double parse of diff route search params by deriving ChatView diff state directly from rawSearch.diff in ChatView.tsx

Remove useMemo for diffSearch and compute diffOpen directly from rawSearch.diff in ChatView.tsx.

📍Where to Start

Start with the ChatView component changes in ChatView.tsx.

Macroscope summarized a7a2fae.

`rawSearch` is already the output of `parseDiffRouteSearch` via the
`useSearch` select transform. The `useMemo` at line 760 re-parsed it
through the same function with an unsafe `as Record<string, unknown>`
cast, producing an identical result. Use `rawSearch` directly instead.
@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a5c67c15-a68a-4a51-a82d-fd58497d72fb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Mar 9, 2026
@t3dotgg t3dotgg merged commit 8e8904a into pingdotgg:main Mar 9, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants