Skip to content

fix(web): reuse CodeMirror search language - #1580

Merged
brendan-kellam merged 3 commits into
mainfrom
brendan/fix-SOU-1978
Aug 13, 2026
Merged

fix(web): reuse CodeMirror search language#1580
brendan-kellam merged 3 commits into
mainfrom
brendan/fix-SOU-1978

Conversation

@brendan-kellam

@brendan-kellam brendan-kellam commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • create the Zoekt CodeMirror StreamLanguage and LanguageSupport once per module
  • keep the existing zoekt() API while returning the shared instance
  • add a regression test that verifies repeated calls return the same object

Root cause

Every server render of the browse SearchBar called StreamLanguage.define(). CodeMirror permanently registers each language document NodeType in a module-global array, retaining the per-render language and closures after GC. The singleton prevents one permanently rooted language instance from being created per browse request.

Linear: SOU-1978

Validation

  • yarn workspace @sourcebot/web test --run "src/app/(app)/components/searchBar/zoektLanguageExtension.test.ts"
  • ESLint on both changed files
  • git diff --check

The repository-wide web TypeScript check currently reports unrelated pre-existing errors in review-agent, MCP Prisma-scope, file-source, and auth test fixtures; neither changed file reports an error.


Note

Cursor Bugbot is generating a summary for commit 2a019d5. Configure here.

Summary by CodeRabbit

  • Performance
    • Improved search editor responsiveness and reduced memory usage by reusing language support.
  • Bug Fixes
    • Fixed a CodeMirror memory leak caused by unreleased allocations.
  • Tests
    • Added coverage verifying consistent language-support reuse across repeated calls.

@github-actions

This comment has been minimized.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c9f1ebd-68c6-4a62-85f9-318da386c997

📥 Commits

Reviewing files that changed from the base of the PR and between 518c604 and c2eb72d.

📒 Files selected for processing (1)
  • CHANGELOG.md

Walkthrough

The change initializes Zoekt CodeMirror language support once at module load time. The zoekt() function returns the cached instance. A Vitest test verifies identical results across repeated calls. The changelog documents the memory leak correction.

Changes

Zoekt language support reuse

Layer / File(s) Summary
Singleton initialization and validation
packages/web/src/app/(app)/components/searchBar/zoektLanguageExtension.ts, packages/web/src/app/(app)/components/searchBar/zoektLanguageExtension.test.ts, CHANGELOG.md
The module caches the language-support instance. The test verifies repeated calls return the same object. The changelog records the CodeMirror memory leak correction.

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

Suggested reviewers: msukkari

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: reusing the CodeMirror search language in the web application.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch brendan/fix-SOU-1978

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.

@brendan-kellam
brendan-kellam merged commit e7bf8f0 into main Aug 13, 2026
12 of 13 checks passed
@brendan-kellam
brendan-kellam deleted the brendan/fix-SOU-1978 branch August 13, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant