fix: restore document state cleanup and use direct panel selection on document show#4822
Merged
Conversation
…ment on panel dismiss Address review feedback on PR #4502: - Replace togglePanel(.documentEditor) with direct selection assignment to avoid accidentally closing the panel when a second document_editor_show or document_load_response message arrives while the panel is already open - Call documentManager.closeDocument() when closing the document editor panel to reset stale editorCoordinator state, ensuring reopened documents load correctly Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses review feedback on #4585
Fix 1 (
MainWindow.swift): ReplacewindowState.togglePanel(.documentEditor)withwindowState.selection = .panel(.documentEditor)in bothhandleDocumentEditorShowandhandleDocumentLoadResponse. UsingtogglePanelwould accidentally close the panel if a second show message arrived while the panel was already open.Fix 2 (
MainWindowView.swift): RestoredocumentManager.closeDocument()in theonClosehandler forDocumentEditorPanelView. Without this call, document state (surfaceId, sessionId, currentContent, etc.) was never cleared when the panel was dismissed, leading to stale state on the next document open.Test plan
document_editor_showwhile panel is open: verify panel stays open with new contentdocument_load_responsewhile panel is open: verify panel stays open with new content🤖 Generated with Claude Code