Skip to content

feat: persist document widget in chat after app reload#4639

Merged
marinatrajk merged 1 commit into
mainfrom
marina/persist-document-widget-after-reload
Feb 18, 2026
Merged

feat: persist document widget in chat after app reload#4639
marinatrajk merged 1 commit into
mainfrom
marina/persist-document-widget-after-reload

Conversation

@marinatrajk

@marinatrajk marinatrajk commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Intercept ui_surface_show in createToolExecutor to push document preview surfaces into currentTurnSurfaces, so they are serialized as ui_surface blocks on message_complete and restored from history on reload
  • Fix click-to-open: openDocumentEditor notification now calls sendDocumentLoad when the document isn't already in memory; handleDocumentLoadResponse recreates the document state and opens the panel
  • Fix empty editor: track content in DocumentManager.currentContent as daemon streams updates, apply it in webView(_:didFinish:) to handle WebView initialization races, and auto-save to DB 2s after streaming completes so content survives reload

🤖 Generated with Claude Code


Open with Devin

- 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>
@marinatrajk marinatrajk merged commit 22e7d69 into main Feb 18, 2026
@marinatrajk marinatrajk deleted the marina/persist-document-widget-after-reload branch February 18, 2026 21:19

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread clients/macos/vellum-assistant/Features/MainWindow/MainWindow.swift

@devin-ai-integration devin-ai-integration Bot 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.

Devin Review found 1 potential issue.

View 5 additional findings in Devin Review.

Open in Devin Review

marinatrajk pushed a commit that referenced this pull request Feb 19, 2026
…-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>
marinatrajk added a commit that referenced this pull request Feb 19, 2026
…-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>
marinatrajk added a commit that referenced this pull request Feb 19, 2026
…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>
marinatrajk added a commit that referenced this pull request Feb 19, 2026
…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>
marinatrajk added a commit that referenced this pull request Feb 19, 2026
…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>
@marinatrajk

Copy link
Copy Markdown
Contributor Author

Addressed in #4834

Applied two fixes from the review:

  • Fix 1: createDocument now seeds self.currentContent = initialContent so subsequent append-mode updateDocument calls don't lose the loaded content
  • Fix 2: scheduleAutoSave() moved before the guard let coordinator block so the document is persisted even when the WebView coordinator isn't ready yet

Fix 3 (use selection = .panel(.documentEditor) instead of togglePanel) was already applied in commit d3f8015 and included in #4822.

@marinatrajk

Copy link
Copy Markdown
Contributor Author

@lead Task 3 complete. PR: #4834 (squash-merged to main)

Changes made in clients/macos/vellum-assistant/Features/MainWindow/DocumentManager.swift:

  1. Fix 1 (P1): createDocument now seeds self.currentContent = initialContent before marking the document active. Prevents data loss when a document is loaded via document_load_response and a subsequent append-mode streaming update drops the original text.

  2. Fix 2 (P1): Moved scheduleAutoSave() to before the guard let coordinator = editorCoordinator block in updateDocument. Ensures auto-save fires even when all streaming updates complete before the WebView coordinator initializes.

Fix 3 (P2) (togglePanelselection = .panel(.documentEditor)) was already applied in commit d3f80158 (#4822) on main - not included here.

All 4 review threads on #4639 resolved.

@marinatrajk

Copy link
Copy Markdown
Contributor Author

All review feedback has already been addressed in main via prior PRs:

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.

2 participants