feat: persist document widget in chat after app reload#4639
Conversation
- Track ui_surface_show in currentTurnSurfaces so document preview surfaces are serialized to DB on message_complete and restored in history - Wire openDocumentEditor notification to send document_load IPC request, falling back to sendDocumentLoad when document is not in memory - Add handleDocumentLoadResponse to MainWindow to recreate document state from daemon DB on click after reload - Track currentContent in DocumentManager.updateDocument() so content survives WebView recreation and initialization races - Apply accumulated content in webView(_:didFinish:) after editor initializes - Auto-save document to DB 2s after streaming completes so reload can recover content Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 89936198d9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…-close Address review feedback on PR #4512 (#4639 follow-up): - Replace windowState.togglePanel(.documentEditor) with windowState.selection = .panel(.documentEditor) in handleDocumentEditorShow and handleDocumentLoadResponse to avoid accidentally closing the editor panel when a second document_editor_show or document_load_response message arrives while the panel is already open (e.g. when multiple document preview widgets are present in chat and the user clicks one whose document is already loaded) Co-Authored-By: Claude <noreply@anthropic.com>
…-close (#4828) Address review feedback on PR #4512 (#4639 follow-up): - Replace windowState.togglePanel(.documentEditor) with windowState.selection = .panel(.documentEditor) in handleDocumentEditorShow and handleDocumentLoadResponse to avoid accidentally closing the editor panel when a second document_editor_show or document_load_response message arrives while the panel is already open (e.g. when multiple document preview widgets are present in chat and the user clicks one whose document is already loaded) Co-authored-by: marinatrajk <marina@odyseek.com> Co-authored-by: Claude <noreply@anthropic.com>
…ore guard Addresses review feedback on #4639: - createDocument now sets self.currentContent = initialContent so subsequent append-mode updateDocument calls do not lose the loaded content - scheduleAutoSave() is now called before the guard let coordinator check so the document is persisted even when the WebView coordinator is not yet ready Co-Authored-By: Claude <noreply@anthropic.com>
…ore guard Addresses review feedback on #4639: - createDocument now sets self.currentContent = initialContent so subsequent append-mode updateDocument calls do not lose the loaded content - scheduleAutoSave() is now called before the guard let coordinator check so the document is persisted even when the WebView coordinator is not yet ready Co-Authored-By: Claude <noreply@anthropic.com>
…ore guard (#4834) Addresses review feedback on #4639: - createDocument now sets self.currentContent = initialContent so subsequent append-mode updateDocument calls do not lose the loaded content - scheduleAutoSave() is now called before the guard let coordinator check so the document is persisted even when the WebView coordinator is not yet ready Co-authored-by: Claude <noreply@anthropic.com>
|
Addressed in #4834 Applied two fixes from the review:
Fix 3 (use |
|
@lead Task 3 complete. PR: #4834 (squash-merged to main) Changes made in
Fix 3 (P2) ( All 4 review threads on #4639 resolved. |
|
All review feedback has already been addressed in main via prior PRs:
|
Summary
ui_surface_showincreateToolExecutorto push document preview surfaces intocurrentTurnSurfaces, so they are serialized asui_surfaceblocks onmessage_completeand restored from history on reloadopenDocumentEditornotification now callssendDocumentLoadwhen the document isn't already in memory;handleDocumentLoadResponserecreates the document state and opens the panelDocumentManager.currentContentas daemon streams updates, apply it inwebView(_:didFinish:)to handle WebView initialization races, and auto-save to DB 2s after streaming completes so content survives reload🤖 Generated with Claude Code