Skip to content

Use weak self captures in background Tasks#77

Open
zmanian wants to merge 1 commit intomcintyre94:mainfrom
zmanian:fix/task-memory-safety
Open

Use weak self captures in background Tasks#77
zmanian wants to merge 1 commit intomcintyre94:mainfrom
zmanian:fix/task-memory-safety

Conversation

@zmanian
Copy link
Contributor

@zmanian zmanian commented Mar 14, 2026

Summary

  • Add [weak self] to auto-checkpoint Task in ChatViewModel.processStreamEvent (was capturing self strongly via self.createAutoCheckpoint)
  • Add [weak self] to manual checkpoint Task in createCheckpoint(for:modelContext:)
  • Add [weak self] to submitWispAskAnswer Task
  • Add [weak self] to upload result dismissal Task in SpriteOverviewViewModel

These Tasks are fire-and-forget (not stored or cancelled), so if the view model is deallocated while they're running, they would keep it alive unnecessarily. With [weak self], they gracefully bail out.

Test plan

  • Verify auto-checkpoint still creates after Claude makes file changes
  • Verify manual checkpoint button works
  • Verify WispAsk answer submission works
  • Verify file upload success banner dismisses after 3 seconds

Generated with Claude Code

Prevent potential retain cycles by capturing self weakly in
fire-and-forget Tasks for checkpoints, WispAsk answers, and
upload result dismissal.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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