[Bug] TUI session rollback (from #704) uses the global DB for namespaced sessions, leaks a DBWorker, and its "Force" option is misleading
Maintainers usually reply within 1 day
A pull request for this has already been merged.
- #756 by @fderuiter — merged
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start with run_rollback_worker in app/ui/tui.py:5842-5876, then read the CLI undo path and the related issue #709 to understand how session database paths are resolved. Review tests/test_tui_history_rollback.py:98-197 for existing coverage and worker waiting behavior. Done means rollback uses the session's database set, releases its worker, handles the Force option and modal state correctly, and has deterministic tests.
Written by the indexing model from the issue text.
Description
Summary
The History modal rollback added in #704 (merged as a7ae7a8) has several problems. It was merged while a review of it was in progress, so they are filed here instead.
Location
app/ui/tui.py:5842-5876:run_rollback_workertests/test_tui_history_rollback.py:98-197
Problems
- Wrong database for namespaced sessions. The worker always opens
get_app_dir()/autosorter.dbandget_app_dir()/cache.db(tui.py:5856-5857), even whenhistory_db_pathpoints to a per-sessionhistory.db. The CLIundopath uses the database that sits next to the session's history DB, so a TUI rollback of a namespaced session updates the wrong document index and cache. - Thread leak. A new
DBWorker()is created for every rollback (tui.py:5855) and is never stopped, so each rollback leaves a worker thread running. - "Force rollback" option is misleading.
ignore_missinghas no effect for sessions with step-ledger rows, which is every session the TUI produces. That path already skips missing files. When a file already exists at the original location, it deletes the moved file instead of restoring it (see #715). The confirm dialog mentions neither behaviour. - Escape closes the modal mid-rollback. While the worker is running, Escape still dismisses the History modal, so the success or failure result is never shown.
- Flaky tests.
tests/test_tui_history_rollback.pywaits for the thread worker with a fixed number ofpilot.pause()calls instead of waiting for the worker to finish. This caused a macOS CI failure on #704 and also fails locally under load.
Expected vs actual
- Expected: rollback writes to the same DB set the CLI
undouses for that session, releases its worker, and accurately describes what "Force" does. The modal stays open until the rollback finishes, and the tests are deterministic. - Actual: see above.
Suggested fix
- Resolve the
autosorter.dbandcache.dbpaths the same way the CLI undo path does, from the session's history DB location (ideally through one shared helper; see #709). - Stop the
DBWorkerin afinallyblock. - Either make
ignore_missingmeaningful for ledger-backed sessions or remove the checkbox, and spell out the collision behaviour in the confirm dialog. - Block Escape and Cancel while a rollback is in flight.
- In the tests, await the worker with
app.workers.wait_for_complete()or poll for the status label.
Severity
High. Items 1 and 3 can leave the index wrong or lose data on a user-triggered undo.
- Dominant language
- Python
- Stars
- 1
- Forks
- 0
- Avg merge
- 10h 6m
- Merged PRs (30d)
- 367
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fderuiter/sortify
-
bug ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
priority:urgent security severity:critical
Difficulty 2/5 1-3 hours Newbie friendliness 57/100
Maintainers usually reply within 1 day
-
architecture enhancement ready-for-agent
Difficulty 5/5 Over a week Newbie friendliness 35/100
fderuiter/sortify#783 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement ready-for-human
Difficulty 4/5 3-5 days Newbie friendliness 48/100
fderuiter/sortify#740 · 1 comment ·
Maintainers usually reply within 1 day
-
architecture enhancement ready-for-human
Difficulty 5/5 Over a week Newbie friendliness 25/100
fderuiter/sortify#726 · 1 comment ·
Maintainers usually reply within 1 day
All issues in fderuiter/sortify
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
RunestoneInteractive/rs#1661 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
streamlink/streamlink#7192 · 4 comments ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
aws-samples/sample-per-model-bedrock#795 ·
Maintainers usually reply within 1 day