Skip to content

fix(export): make cancellation cooperative#1366

Open
VailElla wants to merge 4 commits into
CyberTimon:mainfrom
VailElla:codex/cooperative-export-cancellation
Open

fix(export): make cancellation cooperative#1366
VailElla wants to merge 4 commits into
CyberTimon:mainfrom
VailElla:codex/cooperative-export-cancellation

Conversation

@VailElla

@VailElla VailElla commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description

Fix export cancellation so it cooperatively stops dispatching work and lets already-started workers exit at safe checkpoints. The active export remains registered through worker cleanup and terminal event emission, preventing stale cancellation or completion events from racing with a later export.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Performance improvement
  • Code refactoring
  • Documentation update
  • UI/UX improvement
  • Build/CI or Dependency update

Changes Made

  • Replaced abort-only coordinator cancellation with a per-export atomic cancellation token.
  • Preserved cancellation requested during startup and made repeated cancellation requests idempotent.
  • Stopped dispatching new work after cancellation and added checkpoints around loading, rendering, mask/LUT processing, metadata writes, and file writes.
  • Kept the active export slot through worker cleanup and terminal event serialization, preventing stale task events from affecting a later export.
  • Added a visible Cancelling UI state; export settings stay locked while workers clean up, and a failed cancel invoke restores the retryable exporting state.
  • Added the new status translation to all supported locales and kept the locale files extractor-sorted.
  • Routed batch failures through export-error so the UI does not remain stuck at the final progress count.
  • Added five unit tests covering startup cancellation, duplicate cancellation, overlapping exports, completion races, and stale task cleanup.
  • Registered the legacy objc macro's feature = "cargo-clippy" condition so full clippy with -D warnings passes locally.

Screenshots/Videos

N/A — the UI change is a transient cancellation status rather than a persistent layout change.

Testing

  • I have tested these changes locally and confirmed that they work as expected without issues

Test Configuration:

  • OS: macOS 26.5.2
  • Hardware: Apple M4 Pro, 14 logical cores, 48 GiB RAM

Automated:

  • cargo +1.96.1 fmt --manifest-path src-tauri/Cargo.toml --check — passed
  • cargo +1.96.1 check --manifest-path src-tauri/Cargo.toml — passed
  • cargo +1.96.1 test --manifest-path src-tauri/Cargo.toml export_processing::tests:: -- --nocapture — 5 passed, 0 failed
  • cargo +1.96.1 test --manifest-path src-tauri/Cargo.toml -- --nocapture — 5 passed, 0 failed
  • cargo +1.96.1 clippy --manifest-path src-tauri/Cargo.toml --all-targets --all-features -- -D warnings — passed
  • npm run build — passed
  • npm run i18n:check — passed; 952 plural resolutions validated across 12 locales
  • Changed-file Prettier check — passed
  • Targeted ESLint results match the current main baseline exactly; no new findings
  • git diff --check — passed

Checklist

  • My code follows the project's code style
  • I haven't added unnecessary AI-generated code comments
  • My changes generate no new warnings or errors

Additional Notes

  • Rebased onto main at 41d92c8f; the old upstream export-handle guard was removed because this PR's token lifecycle now owns registration, cancellation, cleanup, and terminal-event serialization.
  • No RAW decoding or image-processing algorithm changes are included.
  • A new export can start only after the previous workers have been cleaned up and its terminal event has been emitted.

AI Disclaimer:

Please state the involvement of AI in this PR:

  • This PR is entirely AI-generated
  • This PR is AI-generated but guided by a human
  • This PR was handwritten with AI assistance (spell check, logic suggestions, error resolving)
  • This PR contains only blood, sweat, and coffee (AI-free)

@VailElla
VailElla marked this pull request as ready for review July 13, 2026 05:58
@VailElla
VailElla requested a review from CyberTimon as a code owner July 13, 2026 05:58
@VailElla
VailElla force-pushed the codex/cooperative-export-cancellation branch from a324dc3 to 003aa4d Compare July 18, 2026 10:49
@VailElla
VailElla force-pushed the codex/cooperative-export-cancellation branch from 003aa4d to 59028ec Compare July 20, 2026 04:11
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