fix: harden multi-pane editor state handling#2444
Conversation
Greptile SummaryThis PR hardens the multi-pane editor state management in
Confidence Score: 4/5The PR is safe to merge; all four targeted concerns from the prior review are correctly addressed and the core listener-cleanup and pane-scoped dispatch logic is sound. The LSP async-guard ( The single changed file Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant User
participant PaneA as Pane A (active)
participant PaneB as Pane B (background)
participant EM as EditorManager
participant LSP as lspClientManager
User->>PaneA: switch active file
EM->>EM: scheduleLspForFile(file)
EM->>EM: configureLspForFile(file)
note over EM: getFilePane(file) → PaneA<br/>targetEditor = PaneA.editor<br/>token = ++lspRequestToken
EM->>LSP: getExtensionsForFile(metadata) [async]
LSP-->>EM: extensions[]
EM->>EM: isFileActiveInEditor(file, PaneA.editor)
note over EM: pane.editor === targetEditor &&<br/>pane.activeFile.id === file.id
alt file still active in PaneA
EM->>PaneA: dispatch(lspCompartment.reconfigure(ext))
EM->>EM: "file.session = PaneA.editor.state"
else file switched or pane changed
EM->>EM: return (stale dispatch suppressed)
end
User->>PaneB: open file in background pane
EM->>EM: applyFileToPaneEditor(file, PaneB)
note over EM: scheduleLsp = false (non-active pane)
EM->>PaneB: "setState + applyCurrentEditorOptions(targetEditor=PaneB.editor)"
EM->>PaneB: dispatchLanguageExtension(..., PaneB.editor)
EM->>EM: "file.session = PaneB.editor.state"
User->>EM: closePane(PaneA)
EM->>EM: pane.cleanupPaneListeners()
EM->>EM: cleanupPaneSplitHandles(parent.element)
EM->>PaneA: editor.destroy()
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant User
participant PaneA as Pane A (active)
participant PaneB as Pane B (background)
participant EM as EditorManager
participant LSP as lspClientManager
User->>PaneA: switch active file
EM->>EM: scheduleLspForFile(file)
EM->>EM: configureLspForFile(file)
note over EM: getFilePane(file) → PaneA<br/>targetEditor = PaneA.editor<br/>token = ++lspRequestToken
EM->>LSP: getExtensionsForFile(metadata) [async]
LSP-->>EM: extensions[]
EM->>EM: isFileActiveInEditor(file, PaneA.editor)
note over EM: pane.editor === targetEditor &&<br/>pane.activeFile.id === file.id
alt file still active in PaneA
EM->>PaneA: dispatch(lspCompartment.reconfigure(ext))
EM->>EM: "file.session = PaneA.editor.state"
else file switched or pane changed
EM->>EM: return (stale dispatch suppressed)
end
User->>PaneB: open file in background pane
EM->>EM: applyFileToPaneEditor(file, PaneB)
note over EM: scheduleLsp = false (non-active pane)
EM->>PaneB: "setState + applyCurrentEditorOptions(targetEditor=PaneB.editor)"
EM->>PaneB: dispatchLanguageExtension(..., PaneB.editor)
EM->>EM: "file.session = PaneB.editor.state"
User->>EM: closePane(PaneA)
EM->>EM: pane.cleanupPaneListeners()
EM->>EM: cleanupPaneSplitHandles(parent.element)
EM->>PaneA: editor.destroy()
Reviews (2): Last reviewed commit: "fix: harden multi-pane editor state hand..." | Re-trigger Greptile |
* feat: add multi pane view * add ability to drag one tab from one pane to other * add vertical pane support and keybinds and bug fixes - added vertical pane creation too - vscode style keybinds - resizing of pane - few bug fixes * fix resize pane empty space * fix: issues and bugs * fixed pane focus lifecycle * fix * fix debounce timer and load related issue * fix * fix the drag snap-back * fix * fix tab cleanup * added cleanup * fix * fixed bunch of issues introduced accidently * remove double doc sync and add Ctrl-touch for multi cursor too * correctly drop at carret * fix and use doc cache instead of direct doc.toString * cleanup * fix untiled.txt close the pane and remove ctrl-touch things * fix: harden multi-pane editor state handling (#2444) * fix: address multi-pane review concerns (#2443) --------- Co-authored-by: Ajit Kumar <me@ajitkumar.dev>
Addresses the current Greptile P1 concerns on PR #2416: target-editor async LSP dispatch, pane-scoped editor option dispatch, incremental open-file mirror sync, and pane/split listener cleanup. Validation: git diff --check; biome check src/lib/editorManager.js; git merge-tree origin/main HEAD. tsc --noEmit --pretty false still reports pre-existing LangStrings errors in src/cm/lsp.