Skip to content

fix(ui): dedupe @codemirror/state to fix Environment tab crash (#1780)#1781

Merged
kgabryje merged 2 commits into
mainfrom
fix-1780-codemirror-state-dedupe
Jul 6, 2026
Merged

fix(ui): dedupe @codemirror/state to fix Environment tab crash (#1780)#1781
kgabryje merged 2 commits into
mainfrom
fix-1780-codemirror-state-dedupe

Conversation

@Vitor-Avila

@Vitor-Avila Vitor-Avila commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Opening the Environment tab in a branch's config modal crashed with:

Error: Unrecognized extension value in extension set ([object Object]). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.

Root cause: pnpm-lock.yaml resolved two @codemirror/state versions — 6.6.0 (pulled in by @codemirror/lang-*, language, commands, autocomplete) and 6.7.0 (pulled in by @uiw/react-codemirror@4.25.10 + the codemirror meta-package). CM6 validates extensions via instanceof checks against @codemirror/state classes, so having two physically-installed copies breaks those checks and throws when the CodeEditor component (apps/agor-ui/src/components/CodeEditor/) mounts inside the Environment tab. Root package.json's pnpm.overrides already pinned @codemirror/view: 6.43.0 but had no equivalent pin for @codemirror/state, and vite.config.ts's resolve.dedupe alone can't collapse two physically-installed versions.

Fix: Added "@codemirror/state": "6.7.0" to pnpm.overrides in root package.json, mirroring the existing @codemirror/view pin, then regenerated the lockfile.

  • Before: grep -c "'@codemirror/state@6" pnpm-lock.yaml → 8 occurrences (4× 6.6.0, 4× 6.7.0 across overrides/packages/snapshots sections)
  • After: grep "'@codemirror/state@" pnpm-lock.yaml → only 6.7.0, single version

Test plan

  • Confirmed root cause: pnpm-lock.yaml had both @codemirror/state@6.6.0 and @codemirror/state@6.7.0 before the fix
  • Added override, ran pnpm install, confirmed lockfile now resolves a single @codemirror/state@6.7.0
  • Built dependent workspace packages (@agor/git, @agor/core, @agor-live/client) needed for a full typecheck in this fresh worktree
  • pnpm --filter agor-ui build succeeds (tsc -b && vite build), exit code 0, no errors
  • Verified the production bundle contains only a single copy of @codemirror/state's internals (one chunk, editor-*.js, carries the "Unrecognized extension value" string and EditorState class — no duplicate definitions in other chunks)
  • Not verified: could not start the dev server / open the app in a browser in this headless environment (per repo convention, the dev server is user-managed and wasn't already running). Relying on the lockfile-single-version + successful production build as verification instead.

Fixes #1780

pnpm-lock.yaml resolved two @codemirror/state versions (6.6.0 pulled by
@codemirror/lang-*/language/commands/autocomplete, 6.7.0 pulled by
@uiw/react-codemirror + the codemirror meta-package). CM6 validates
extensions with instanceof against @codemirror/state, so loading two
copies breaks the check and throws "Unrecognized extension value in
extension set" when the Environment tab mounts its CodeMirror editor.

Pin @codemirror/state to 6.7.0 in pnpm.overrides, mirroring the existing
@codemirror/view override, so pnpm collapses both to a single version.

Fixes #1780

Co-Authored-By: Claude <noreply@anthropic.com>
@richardfogaca

Copy link
Copy Markdown
Contributor

Richard's agent here: I reviewed this and the fix direction makes sense to me.

No blocking code findings. The PR addresses the reported CodeMirror crash at the right layer: the lockfile had two physical @codemirror/state versions, and adding the root pnpm.overrides entry collapses the CM6 graph to a single 6.7.0 copy while keeping the existing @codemirror/view override. That matches the Unrecognized extension value... multiple instances of @codemirror/state console error from the Slack thread.

Small cleanup before merge, if easy: could we keep the lockfile diff limited to the CodeMirror collapse by restoring the unrelated libsql@0.5.29 cpu metadata change? I’d also drop the generated-by footer from the PR body.

Validation looks reasonable: CI is green and the PR includes build + bundle-level verification. The only remaining gap is a live Environment tab smoke-test, so I’d be comfortable merging after either a quick preview click-through or accepting that as the post-merge/manual verification step.

@richardfogaca richardfogaca 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.

Approving — no blocking code findings from my review. The cleanup notes I left are non-blocking.

…rror-only

Addresses review feedback on #1781 — the pnpm install regenerated an
unrelated libsql@0.5.29 `cpu` field drop; restore it so the diff is
limited to the @codemirror/state collapse.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kgabryje kgabryje merged commit 1dd88ca into main Jul 6, 2026
4 checks passed
@kgabryje kgabryje deleted the fix-1780-codemirror-state-dedupe branch July 6, 2026 15:56
@kgabryje kgabryje added the ai-reviewed-gpt-5-5 Reviewed by GPT-5.5 AI reviewer label Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-reviewed-gpt-5-5 Reviewed by GPT-5.5 AI reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Environment tab (CodeEditor) crashes: duplicate @codemirror/state (6.6.0 + 6.7.0) breaks instanceof — missing pnpm override

3 participants