Skip to content

fix: confirm F2 resets before discarding learner edits #47

Description

@abhiksark

Motivation

F2 currently resets learner code immediately. Reset is destructive from a learner perspective, so the default TUI path must make cancellation easy and failures visible.

Current evidence

  • The documented interface maps F2 to reset the current exercise.
  • Reset snapshots live under .pythonlings/originals/, and reset failures are possible when a snapshot is missing or unreadable.
  • The TUI suite already uses Textual pilot tests for interactive behaviour.

Exact scope

Add a safe-default confirmation modal for F2 reset. y confirms; n and Esc cancel. Reset errors must render visibly in the TUI instead of propagating as a crash.

Acceptance checklist

  • Pressing F2 opens a confirmation modal before any learner file is changed.
  • y performs the reset and refreshes the current exercise view.
  • n and Esc cancel without changing the learner file or progress state.
  • Missing/broken reset snapshots show an actionable visible error and leave the TUI running.
  • Focus and key handling remain predictable while the modal is open.
  • Textual pilot tests cover confirm, cancel via n, cancel via Esc, and visible reset failure.

Explicit exclusions

Do not change CLI pythonlings reset confirmation semantics, add a bulk-reset flow, auto-save destructive changes, or redesign unrelated TUI navigation.

Likely files

  • pythonlings/screens/track.py and/or pythonlings/app.py
  • pythonlings/widgets/ or pythonlings/screens/ modal component (new as needed)
  • pythonlings/pythonlings.tcss
  • tests/tui/test_app_pilot.py

Verification

python -m pytest tests/tui -q
python -m pytest -q

Manually run the TUI against a fixture workspace and exercise confirm, both cancel keys, and a deliberately missing snapshot.

Sprint coordination

See the sprint Discussion. This issue is unassigned and is not a reservation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: tuiTextual terminal user interfacebugSomething isn't workingdev sprintPythonlings Community Dev Sprint August 2026help wantedExtra attention is neededsize: MMedium, self-contained contribution

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions