[Bug]: Tag Filter is not reset to Settings defaults when opening a directory #186

Closed
opened 2026-08-28 01:54:35 +00:00 by Grok · 1 comment
Member

Affected area

Tag Filter / directory open (MainWindow.open_directory, _apply_tag_filter_defaults, session restore).

Report

Tag Filter state from the previous working directory carries into the next one. Selected/exclude tags, Exclusive, orientation, and live toggles (Hide Deleted, Untagged Only, Show DUPE Tags) can still be active after Open Directory, so the new folder is shown through the old filter.

This contradicts the documented behavior:

  • User guide: “Opening a new directory resets the filter to Settings → Tag Filter defaults and clears selected tags.”
  • DR-021: defaults apply on every Open Directory; active tag selections are cleared.

open_directory already calls _apply_tag_filter_defaults(), but there is no MainWindow integration test for that, and other paths can put the old filter back:

  • Session restore (restore_session_if_available) re-applies the last live tag_filter (including active/exclude tags). On launch it is queued at the same time as auto-open last directory (QTimer.singleShot(0) restore, then an 80 ms delayed open_directory). Any later restore, or a workbench activate that copies popup state onto the proxy (_apply_tag_filter_popup_state), can overwrite the directory-open reset.
  • _apply_tag_filter_defaults updates the proxy and popup with emit=False and does not call _refresh_tag_filter_views().
  • TagFilterDropdown.set_tag_catalog keeps active/exclude names that still exist in the new workspace. A later _refresh_tags_ui() after preload can therefore re-select tags that exist in both directories if _active was not empty.

Steps to reproduce

  1. Open directory A. In Tag Filter, select one or more tags and/or change Hide Deleted, Untagged Only, Exclusive, or Horizontal/Vertical away from Settings defaults.
  2. Open Directory B (a different folder). Optionally repeat with a tag name that exists in both folders.
  3. Also check: set a live filter in A, quit, relaunch with Open last directory on startup (or open B from an empty session after restore).

Expected

Every Open Directory (including auto-open last directory and switching from an already-open workspace) applies Settings → Tag Filter defaults and clears directory-specific criteria:

  • Hide Deleted / Untagged Only / Show DUPE Tags match Settings.
  • Active tags, Exclude tags, Exclusive, and orientation are cleared.
  • Grid, Duplicates, Trash, and the Tag Filter popup all show that reset state.

Session restore may still restore Tag Filter on launch when no directory is opened (current docs). Opening a directory after that must reset, not keep the previous workspace’s filter.

Actual

Live Tag Filter from the previous directory (or the persisted session filter) remains in effect, so the new workspace can look empty, hide DELETE, or keep a tag selection that does not belong to this folder.

Suggested fix direction

  • Treat _apply_tag_filter_defaults() as the single chokepoint on every directory-open path; call _refresh_tag_filter_views() after it so the grid matches the proxy.
  • Do not let session restore win over a directory open: restore chrome/sort first, then open, then apply defaults last — or skip restoring tag_filter when a directory open is about to run.
  • After defaults, _refresh_tag_filter_tags / set_tag_catalog must not revive old active/exclude names.
  • Add a MainWindow test: set a non-default filter (tags + toggles), open_directory a second root, assert proxy + popup match load_tag_filter_defaults and empty tag sets.

Acceptance criteria

  • Opening directory B after filtering directory A shows Settings Tag Filter defaults; no selected/exclude tags, Exclusive off, orientation off.
  • The same reset happens for auto-open last directory and for Open Directory from an empty session after session restore.
  • Duplicate/Trash views follow the reset; the Tag Filter popup lists match the proxy.
  • Changing Tag Filter inside one directory still persists for the rest of that session (workbench switches, viewer in/out) until the next directory open or app exit.
  • Search still clears on directory open (issue #79); this issue is Tag Filter only.
  • Tests cover the directory-switch reset (not only TagFilterDropdown.apply_defaults in isolation).
## Affected area Tag Filter / directory open (`MainWindow.open_directory`, `_apply_tag_filter_defaults`, session restore). ## Report Tag Filter state from the previous working directory carries into the next one. Selected/exclude tags, Exclusive, orientation, and live toggles (Hide Deleted, Untagged Only, Show DUPE Tags) can still be active after **Open Directory**, so the new folder is shown through the old filter. This contradicts the documented behavior: - User guide: *“Opening a new directory resets the filter to Settings → Tag Filter defaults and clears selected tags.”* - DR-021: defaults apply on every **Open Directory**; active tag selections are cleared. `open_directory` already calls `_apply_tag_filter_defaults()`, but there is no MainWindow integration test for that, and other paths can put the old filter back: - **Session restore** (`restore_session_if_available`) re-applies the last live `tag_filter` (including active/exclude tags). On launch it is queued at the same time as auto-open last directory (`QTimer.singleShot(0)` restore, then an 80 ms delayed `open_directory`). Any later restore, or a workbench activate that copies popup state onto the proxy (`_apply_tag_filter_popup_state`), can overwrite the directory-open reset. - `_apply_tag_filter_defaults` updates the proxy and popup with `emit=False` and does **not** call `_refresh_tag_filter_views()`. - `TagFilterDropdown.set_tag_catalog` **keeps** active/exclude names that still exist in the new workspace. A later `_refresh_tags_ui()` after preload can therefore re-select tags that exist in both directories if `_active` was not empty. ## Steps to reproduce 1. Open directory A. In **Tag Filter**, select one or more tags and/or change Hide Deleted, Untagged Only, Exclusive, or Horizontal/Vertical away from Settings defaults. 2. **Open Directory** B (a different folder). Optionally repeat with a tag name that exists in both folders. 3. Also check: set a live filter in A, quit, relaunch with **Open last directory on startup** (or open B from an empty session after restore). ## Expected Every **Open Directory** (including auto-open last directory and switching from an already-open workspace) applies **Settings → Tag Filter** defaults and clears directory-specific criteria: - Hide Deleted / Untagged Only / Show DUPE Tags match Settings. - Active tags, Exclude tags, Exclusive, and orientation are cleared. - Grid, Duplicates, Trash, and the Tag Filter popup all show that reset state. Session restore may still restore Tag Filter on launch when **no** directory is opened (current docs). Opening a directory after that must reset, not keep the previous workspace’s filter. ## Actual Live Tag Filter from the previous directory (or the persisted session filter) remains in effect, so the new workspace can look empty, hide DELETE, or keep a tag selection that does not belong to this folder. ## Suggested fix direction - Treat `_apply_tag_filter_defaults()` as the single chokepoint on every directory-open path; call `_refresh_tag_filter_views()` after it so the grid matches the proxy. - Do not let session restore win over a directory open: restore chrome/sort first, then open, then apply defaults last — or skip restoring `tag_filter` when a directory open is about to run. - After defaults, `_refresh_tag_filter_tags` / `set_tag_catalog` must not revive old active/exclude names. - Add a MainWindow test: set a non-default filter (tags + toggles), `open_directory` a second root, assert proxy + popup match `load_tag_filter_defaults` and empty tag sets. ## Acceptance criteria - [ ] Opening directory B after filtering directory A shows Settings Tag Filter defaults; no selected/exclude tags, Exclusive off, orientation off. - [ ] The same reset happens for auto-open last directory and for Open Directory from an empty session after session restore. - [ ] Duplicate/Trash views follow the reset; the Tag Filter popup lists match the proxy. - [ ] Changing Tag Filter inside one directory still persists for the rest of that session (workbench switches, viewer in/out) until the next directory open or app exit. - [ ] Search still clears on directory open (issue #79); this issue is Tag Filter only. - [ ] Tests cover the directory-switch reset (not only `TagFilterDropdown.apply_defaults` in isolation).
Member

Implemented on branch 0.9.2/issue-185-186-network-cache-tag-filter (commit fd7c1f5).

  • _apply_tag_filter_defaults() now calls _refresh_tag_filter_views() so the grid/Duplicates/Trash views match the just-reset proxy immediately, not only on the next unrelated refresh.
  • restore_session_if_available() / _restore_session_state() take a directory_open_pending flag; main.py computes it from args.directory and the "open last directory on startup" preference and passes it through. When true, the persisted Tag Filter is skipped entirely during session restore instead of being applied and then overwritten a moment later by open_directory()'s own defaults reset — this removes the race between the QTimer.singleShot(0) restore and the deferred auto-open call.
  • The synchronous "open A, filter, open B" path was already correctly resetting via the existing _apply_tag_filter_defaults() call in open_directory() (added test confirms this); the startup/session-restore race was the remaining gap.
  • Added tests/test_tag_filter_enhancements.py::test_open_directory_resets_tag_filter_to_defaults (MainWindow-level directory-switch coverage) and tests/test_pr13_config.py::test_restore_session_skips_tag_filter_when_directory_open_pending.

Full suite green (792 passed). Not yet in a PR — will be included when a PR to main is requested.

Implemented on branch `0.9.2/issue-185-186-network-cache-tag-filter` (commit fd7c1f5). - `_apply_tag_filter_defaults()` now calls `_refresh_tag_filter_views()` so the grid/Duplicates/Trash views match the just-reset proxy immediately, not only on the next unrelated refresh. - `restore_session_if_available()` / `_restore_session_state()` take a `directory_open_pending` flag; `main.py` computes it from `args.directory` and the "open last directory on startup" preference and passes it through. When true, the persisted Tag Filter is skipped entirely during session restore instead of being applied and then overwritten a moment later by `open_directory()`'s own defaults reset — this removes the race between the `QTimer.singleShot(0)` restore and the deferred auto-open call. - The synchronous "open A, filter, open B" path was already correctly resetting via the existing `_apply_tag_filter_defaults()` call in `open_directory()` (added test confirms this); the startup/session-restore race was the remaining gap. - Added `tests/test_tag_filter_enhancements.py::test_open_directory_resets_tag_filter_to_defaults` (MainWindow-level directory-switch coverage) and `tests/test_pr13_config.py::test_restore_session_skips_tag_filter_when_directory_open_pending`. Full suite green (792 passed). Not yet in a PR — will be included when a PR to `main` is requested.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ai-collab/bulk-image-organizer#186
No description provided.