Repository navigation
Description
Motivation
A learner can edit an exercise, let autosave persist it, and then restore the originally loaded text in the editor. The editor shows the revert, but the file on disk keeps the intermediate edit.
Current evidence
A Textual pilot on dev at e1d4dae37234b75124bd6a53f06734296ebbbdee reproduced this twice:
disk after edit: 'x = 99\n'
editor after undo: '# I AM NOT DONE\nx = ???\n'
disk after undo: 'x = 99\n'
disk after exit: 'x = 99\n'
TrackScreen.on_text_area_changed() returns whenever the editor equals _loaded_text. That comparison does not account for an earlier autosave that changed the file after _loaded_text was captured.
Exact scope
Persist a user-driven revert to the originally loaded text while continuing to ignore programmatic text changes during initial exercise loading. Keep debounce and verification behavior coherent after the revert.
Acceptance checklist
- Edit, autosave, and revert-to-loaded-text writes the reverted text to disk.
- Leaving through F4, Escape, or Ctrl+Q cannot lose that revert.
- The reverted text receives the same verification treatment as another learner edit.
- Initial programmatic loading does not trigger a redundant save or run loop.
- Rapid consecutive edits still persist only the latest editor content.
- A deterministic Textual pilot test covers the edit, autosave, revert, and exit sequence.
Explicit exclusions
Do not implement reset confirmation from #47, replace the editor widget, change the debounce interval, or add a filesystem watcher.
Likely files
pythonlings/screens/track.pytests/tui/test_app_pilot.py
Verification
python -m pytest tests/tui -q
python -m pytest -q
pythonlings --root tests/fixtures/passing_curriculum verifyThe pilot should assert editor text, file text, and current exercise before and after exit.
Sprint coordination
See Discussion #37 and tracker #52. This issue is intentionally unassigned. A coordination comment is welcome, but it does not reserve the issue. The first pull request that satisfies every acceptance criterion and verification requirement is considered for merge.
Activity
docs(tui): capture autosave and revert validation
style(docs): remove whitespace from TUI captures
fix(tui): persist reverted exercise text before leaving (#162)
abhiksark commentedon Nov 4, 2026
Completed in #162, squash-merged into
devase1025512a8adb4ae1c1863bbd9d69b1e25776da7.The saved-text baseline now tracks the text on disk, so reverting after an earlier autosave persists the original learner text. F4, Escape, Ctrl+Q, and quitting from docs flush pending edits. Regression pilots cover those exit paths, rapid edits, and initial loading without a redundant save.
Validation: 221 tests passed on the PR branch; 249 passed when integrated with current dev; passing curriculum verification, isolated source/wheel build, and installed-wheel TUI autosave/revert/Ctrl+Q smoke passed. Current TUI captures are attached to the PR. All eight platform/Python CI jobs passed at reviewed head
f3abd452e38aed00ed566107be2b9de3e3347bc4in run 41799235875.Closing as completed.