Skip to content

feat(query-editor): add code mirror search and replace in query editor - #9042

Merged
sachin-thakur-bruno merged 4 commits into
usebruno:mainfrom
sachin-thakur-bruno:feat/codemirror-search-api-spec-graphql-query
Aug 27, 2026
Merged

sachin-thakur-bruno merged 4 commits into
usebruno:mainfrom
sachin-thakur-bruno:feat/codemirror-search-api-spec-graphql-query

Conversation

@sachin-thakur-bruno

@sachin-thakur-bruno sachin-thakur-bruno commented Aug 20, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds the search/replace bar to the GraphQL query editor, which was still using CodeMirror's legacy findPersistent dialog.

BRU-4215

Problem

Current Query editor didn't integrated code mirror search at all so cmd/ctrl+f showing the code mirror search.

Fix

Query editor

  • Replaced findPersistent with buildSearchKeyBindings(...) and to use CodeMirror’s standard search shortcuts: Cmd/Ctrl+F, Cmd+Alt+F / Ctrl+H, and Esc.
  • Added a dedicated .editor-container for CodeMirror, matching the CodeEditor pattern and preventing React and CodeMirror from sharing the same node.
  • Kept the container as a flex column with position: relative so hintOptions.container preserves autocomplete popup positioning.
  • Added a min-height guard to prevent the editor from collapsing in a squeezed pane.

Highlight styles

  • Consolidated the three .cm-search-* rules into the existing .CodeMirror block in globalStyles.js and removed the scattered duplicates.
  • Kept the existing .CodeMirror .cm-search-* specificity so styling behavior remains unchanged.
  • Updated search highlights to use the theme values with transparency:

Screenshots

Before After
image image

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.
  • I've run the claude code review skill locally.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • New Features

    • Added a dedicated search bar to the query editor.
    • Search bar visibility now adjusts the editor layout automatically.
    • Search results and the active match are highlighted with theme-aware colors.
  • Bug Fixes

    • Improved search behavior and keyboard shortcut integration within the query editor.
    • Removed outdated search styling that could cause inconsistent highlighting.

@coderabbitai

coderabbitai Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5babbff2-e2d1-48fc-8341-fd288d2427b4

📥 Commits

Reviewing files that changed from the base of the PR and between b807de9 and cd014cf.

📒 Files selected for processing (5)
  • packages/bruno-app/src/components/CodeEditor/StyledWrapper.js
  • packages/bruno-app/src/components/CodeMirrorSearch/StyledWrapper.js
  • packages/bruno-app/src/components/RequestPane/QueryEditor/StyledWrapper.js
  • packages/bruno-app/src/components/RequestPane/QueryEditor/index.js
  • packages/bruno-app/src/globalStyles.js
💤 Files with no reviewable changes (2)
  • packages/bruno-app/src/components/CodeMirrorSearch/StyledWrapper.js
  • packages/bruno-app/src/components/CodeEditor/StyledWrapper.js

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


Walkthrough

QueryEditor now renders a controlled CodeMirror search bar with shared key bindings and a dedicated editor container. Search highlight styles move to global styles, while duplicate component styles are removed.

Changes

CodeMirror search integration

Layer / File(s) Summary
QueryEditor search flow
packages/bruno-app/src/components/RequestPane/QueryEditor/*
QueryEditor tracks search-bar visibility, configures shared search bindings, renders CodeMirrorSearch, and mounts CodeMirror in a dedicated container.
Search highlight styling
packages/bruno-app/src/components/CodeEditor/StyledWrapper.js, packages/bruno-app/src/components/CodeMirrorSearch/StyledWrapper.js, packages/bruno-app/src/globalStyles.js
Global styles define current-line, regular-match, and active-match highlights. Duplicate wrapper rules are removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to cd014

The change adds standard search and replace behavior to the query editor while preserving editor lifecycle and current-match highlighting; no actionable merge-blocking risk remains beyond normal checks.

Suggested reviewers: bijin-bruno

Sequence Diagram(s)

sequenceDiagram
  participant QueryEditor
  participant CodeMirrorSearch
  participant CodeMirror
  QueryEditor->>CodeMirrorSearch: render search bar
  QueryEditor->>CodeMirror: configure search bindings
  CodeMirrorSearch->>CodeMirror: execute search
  QueryEditor->>CodeMirror: mount editor in dedicated container
Loading

Poem

Search bar opens,
Matches glow in themed light,
Editor finds its place.
Bindings guide the way,
CodeMirror keeps the pace.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding CodeMirror search and replace functionality to the query editor.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@Gopi-bruno Gopi-bruno left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sid-bruno

sid-bruno commented Aug 26, 2026 •

Copy link
Copy Markdown
Collaborator

Missing coverage

  • opening search in the GraphQL query editor (Cmd/Ctrl+F)
  • replace (Cmd+Alt+F / Ctrl+H)
  • closing with Esc
  • pre-filling search from a selection
  • replace being blocked in read-only mode
  • the search bar layout when it’s open (making sure it doesn’t get clipped)
  • No check that Shift-Ctrl-F still runs Prettify and doesn’t clash with search

Can we consider adding the search to ApiSpec file editor as well? Will need more changes, moved to another ticket

@sachin-thakur-bruno
sachin-thakur-bruno merged commit ed1e1c3 into usebruno:main Aug 27, 2026
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants