Skip to content

Persist draft attachments across navigation#69

Merged
mcintyre94 merged 1 commit intomainfrom
persist-attachments-ui-0550afff
Mar 13, 2026
Merged

Persist draft attachments across navigation#69
mcintyre94 merged 1 commit intomainfrom
persist-attachments-ui-0550afff

Conversation

@mcintyre94
Copy link
Copy Markdown
Owner

@mcintyre94 mcintyre94 commented Mar 13, 2026

Summary

  • Adds draftAttachmentPaths: [String]? to SpriteChat SwiftData model
  • saveDraft now persists attached file paths alongside draft text; clears to nil when empty
  • loadSession restores attachedFiles from persisted paths (reconstructing AttachedFile via lastPathComponent)
  • ChatView triggers saveDraft on attachedFiles.count changes, in addition to text changes

SwiftData handles the new optional column automatically — no migration needed.

Test plan

  • Attach a file in chat, navigate away, return — attachment chip should reappear
  • Send the message after returning — file path is correctly prefixed as before
  • Navigate away without attaching anything — no regressions to empty state
  • New unit tests: saveDraft_persistsAttachmentPaths, saveDraft_clearsAttachmentPathsWhenEmpty, loadSession_restoresDraftAttachments, loadSession_doesNotOverwriteExistingAttachments

🤖 Generated with Claude Code

When a user attaches a file, save its path to SwiftData alongside the
draft text so the attachment chip reappears when returning to the chat.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@claude
Copy link
Copy Markdown

claude bot commented Mar 13, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@mcintyre94 mcintyre94 merged commit eec3483 into main Mar 13, 2026
2 checks passed
@mcintyre94 mcintyre94 deleted the persist-attachments-ui-0550afff branch March 13, 2026 23:22
@mcintyre94 mcintyre94 restored the persist-attachments-ui-0550afff branch March 14, 2026 19:15
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