Skip to content

Save clipboard fallback images asynchronously and finish them before exit - #405

Merged
devmobasa merged 2 commits into
mainfrom
fix/clipboard-fallback-saving
Oct 3, 2026
Merged

devmobasa merged 2 commits into
mainfrom
fix/clipboard-fallback-saving

Conversation

@devmobasa

Copy link
Copy Markdown
Owner

Summary

Move clipboard fallback image saving off the event loop while ensuring that
accepted saves are not abandoned when the overlay exits.

Changes

Background saving

  • Run file writes on a bounded, single-flight backend worker.
  • Keep input handling and overlay updates responsive while a save is running.
  • Capture immutable image bytes and the destination when a save is accepted,
    rather than looking up the current fallback later.
  • Match completion results to their generation so an older save cannot clear
    or overwrite newer fallback state.

Reliable exit behavior

  • Queue accepted saves as owned input effects.
  • Drain those saves during common overlay teardown, including Save and Exit
    actions processed in the same event batch.
  • Finish queued saves in order, even if an earlier save fails.
  • Wait for accepted writes to finish before exit; this teardown wait has no timeout.
  • Preserve unrelated effects when draining pending saves.

Failure handling

  • Report save failures and retain unsaved fallback data for retry while the
    overlay remains active.
  • Log exit-time failures and request a “Failed to Save Image” notification.
  • Keep exit-after-save behavior tied to the matching successful completion.

Regression coverage

  • Verify saved file contents, failures, retries, and single-flight admission.
  • Cover stale completions and fallback replacement after save acceptance.
  • Exercise immediate Save followed by Exit and teardown with a held writer.
  • Verify FIFO ownership, unrelated-effect preservation, repeated teardown,
    and continued processing after I/O errors or worker panics.

@devmobasa
devmobasa merged commit d38bfc1 into main Oct 3, 2026
3 checks passed
@devmobasa
devmobasa deleted the fix/clipboard-fallback-saving branch October 5, 2026 12:49
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