Skip to content

Keep Markdown completions available when a sibling pane changes files - #34975

Merged
OrcaWin merged 2 commits into
mainfrom
OrcaWin/editor-completion-pane-ownership
Oct 29, 2026
Merged

OrcaWin merged 2 commits into
mainfrom
OrcaWin/editor-completion-pane-ownership

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​110 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​101
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​33 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​23

Problem

Split panes that show the same Markdown file share one Monaco model, because the model URI is keyed by file and host/worktree owner, not by pane. The [[ doc-link completion catalog was stored per model. When either pane closed or switched files, it cleared that model's catalog. The pane still open then got no [[ completions until its document list changed or it remounted.

Fix

  • monaco-markdown-doc-completions.ts: each model's entry now records which pane owns each catalog. Set and clear take an owner symbol.
  • Clearing removes only that owner's catalog and makes the most recently set surviving catalog current. The model's entry is deleted when its last owner releases it.
  • use-monaco-editor-decorations.ts: each hook instance has a stable owner symbol, which it passes on model swap, on language change and on unmount.
  • The catalog is still in a WeakMap keyed by model, so disposed models are still collected. The change is renderer-only, with no IPC or remote-protocol impact.

Tests

  • monaco-markdown-doc-completions-retention.test.ts: two hook-level tests render the real hook in two panes on a shared model and check the actual provider output:
    • The surviving pane keeps its completions after its sibling unmounts. When the last pane closes, the catalog is released.
    • A language change in one pane restores the sibling's catalog, and a replacement model with the same URI stays isolated.
  • The existing provider tests are updated for the new signature.
  • pnpm check:changed passes.

@OrcaWin
OrcaWin force-pushed the OrcaWin/editor-completion-pane-ownership branch from 5d7414e to 858315e Compare October 28, 2026 23:42
@OrcaWin
OrcaWin marked this pull request as ready for review October 29, 2026 00:08
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 15a0a64f-a6c4-4e45-8a68-c91383191ef2
Commits

Reviewing files that changed from the base of the PR and between 6f41a55 and bb1134d.

Files selected for processing: 3
  • src/renderer/src/components/editor/monaco-markdown-doc-completions-retention.test.ts
  • src/renderer/src/components/editor/monaco-markdown-doc-completions.ts
  • src/renderer/src/components/editor/use-monaco-editor-decorations.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Keeps Markdown [[ completions available when panes share a model and one pane closes or changes files.

  • Markdown completions stay available while a pane still owns the shared model.

No actionable issues were found. Tests were inspected, not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Pane supplies catalog] --> B[Shared model stores catalog by owner]
  B --> C[Provider uses latest catalog]
  D[Pane closes or changes files] --> E[Remove only that owner]
  E --> F{Any owners left?}
  F -->|Yes| G[Restore latest surviving catalog]
  F -->|No| H[Delete model entry]
Loading

Reviews (2) · Last reviewed commit: "Assign completion test editor ref in a l..." · Reviewed by Greptile

@OrcaWin
OrcaWin force-pushed the OrcaWin/editor-completion-pane-ownership branch from 858315e to bb1134d Compare October 29, 2026 00:37
@OrcaWin
OrcaWin merged commit 7827925 into main Oct 29, 2026
35 checks passed
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