Skip to content

fix(culling): guard stale viewer loads and serialize culling updates - #585

Merged
julyx10 merged 3 commits into
julyx10:mainfrom
billecart:fix/culling-persistence
Nov 23, 2026
Merged

julyx10 merged 3 commits into
julyx10:mainfrom
billecart:fix/culling-persistence

Conversation

@billecart

@billecart billecart commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes culling flag changes (pick / reject / unreviewed) made in Image Viewer or the grid occasionally not persisting or reverting incorrectly:

  1. Surface missing-row / failed culling writes (src-tauri/src/t_cmds.rs, src-vite/src/common/api.js, src-vite/src/components/Content.vue)
    • set_file_culling_flag now returns an error when 0 rows are updated instead of returning Ok(0).
    • setFileCullingFlag rejects non-positive/non-integer IDs (e.g. collapsed group placeholders) and treats 0 updated rows as failure (null), with toast.error(t('file_info.metadata_save_failed')) surfaced on failure.
  2. Guard stale getFileInfo loads & serialize per-file culling writes (src-vite/src/common/cullingSync.ts, src-vite/src/views/ImageViewer.vue)
    • Guards per-pane getFileInfo watchers with request tokens so out-of-order responses cannot overwrite the active file info.
    • Stops silently dropping culling shortcuts while getFileInfo is still loading and preserves pending/committed culling flags across delayed getFileInfo responses.
    • Serializes culling writes per fileId and tracks the last confirmed DB value separately from the user's latest desired value, so if Reject succeeds and a subsequent Pick fails, the UI rolls back to Reject rather than the original Unreviewed state.

Testing

  • Frontend:
    • node --test src-vite/tests/cullingPersistence.test.mjs (4/4 pass, including serialized consecutive Reject → failed Pick rollback)
    • pnpm build (802 modules transformed)
  • Backend:
    • cargo test culling_persistence_tests (1 passed; 0 failed)

@julyx10

julyx10 commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Thanks for investigating this. The stale getFileInfo protection and write-failure checks look useful, but I’d like to address two points before merging:

  1. Consecutive updates: If Reject succeeds and a subsequent Pick fails, the UI currently rolls back to the original Unreviewed state rather than the successfully saved Reject state. Could we serialize writes per file and track the last confirmed value separately from the user’s latest intent? Please also add a test for this case.

  2. WAL checkpointing: Committed transactions in the WAL should survive an app restart without an explicit checkpoint. Do we have evidence that checkpointing is the underlying cause? I’d prefer to leave the exit checkpoint out of this PR unless we can demonstrate why it is needed.

With those changes, this would be a more focused and reliable fix.

@billecart billecart changed the title fix(culling): checkpoint WAL on exit and harden viewer persistence fix(culling): guard stale viewer loads and serialize culling updates Nov 23, 2026
@billecart

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Both points are addressed in fe10fe8a:

  1. Serialized per-file updates & separate confirmed vs. desired state: cullingSync.ts now serializes culling writes per fileId and tracks confirmed independently from the user's latest desired intent (also syncing external update-file-meta updates). Added a regression test in src-vite/tests/cullingPersistence.test.mjs covering consecutive Reject (succeeds) → Pick (fails) rolling back to Reject instead of Unreviewed, plus failed earlier write followed by a newer queued intent succeeding.
  2. Removed exit WAL checkpointing: Reverted the main.rs / t_storage.rs exit checkpoint changes to keep the PR focused on the viewer race and write-failure handling.

@julyx10
julyx10 merged commit 0ee4370 into julyx10:main Nov 23, 2026
2 checks passed
@julyx10

julyx10 commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Merged!, thanks for the PR!

I added a small fix in c0aeebb2 to preserve the latest auto-advance intent when consecutive updates set the same culling flag.

Previously, the queue captured the advance settings before the write started. It now reads the latest settings when the write settles, including the originating pane.

Added a regression test covering both enabling and cancelling auto-advance during an in-flight write. All five frontend tests and the build pass.

Thanks for updating the PR and addressing the earlier feedback!

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