Skip to content

feat: tmpo undo to revert a previous action#119

Merged
DylanDevelops merged 6 commits into
mainfrom
ravel/undo-command
May 9, 2026
Merged

feat: tmpo undo to revert a previous action#119
DylanDevelops merged 6 commits into
mainfrom
ravel/undo-command

Conversation

@DylanDevelops
Copy link
Copy Markdown
Owner

Pull Request Checklist

  • I have read and followed the contribution guidelines.
  • My pull request targets the main branch of tmpo.
  • I have tested these changes locally on my machine.

Closes #116

Description

This pull request introduces an "undo" feature to the application, allowing users to revert their most recent time-tracking action. The implementation tracks user actions (such as start, stop, pause, resume, manual entry creation, and deletion) and provides a new undo command to roll back the last action. The change also includes comprehensive tests for the new undo functionality and its integration with the storage layer.

Undo Feature Implementation

  • Added a new undo command (UndoCmd) that allows users to undo their most recent time-tracking action. The command provides user feedback, confirmation prompts, and handles various action types appropriately.
  • Integrated action tracking into all major time entry commands (start, stop, pause, resume, manual, delete) by saving an UndoAction to the database after each action. [1] [2] [3] [4] [5] [6]
  • Registered the new undo command in the application's root command.

Storage Layer Enhancements

  • Added a new UndoAction type and related methods to the storage layer for saving, retrieving, and clearing the last action. Also added methods to "uncomplete" (re-open) an entry and restore deleted entries, supporting the undo logic.

Testing

  • Added comprehensive tests for both the undo command logic and the storage layer's undo functionality, including edge cases and error handling. [1] [2]

User Interface

  • Added a new emoji constant (EmojiUndo) to visually indicate undo actions in the UI.

Save undo actions only after the associated DB operation succeeds by moving db.SaveLastAction calls to after DeleteTimeEntry/StopEntry in delete, tracking pause and stop commands. This prevents stale/incorrect undo state when the DB operation fails. Additionally, UncompleteEntry now checks RowsAffected and returns an explicit error if no rows were updated (entry not found), improving error handling.
@DylanDevelops DylanDevelops merged commit 38d52af into main May 9, 2026
5 checks passed
@DylanDevelops DylanDevelops deleted the ravel/undo-command branch May 9, 2026 19:59
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.

tmpo undo Command

1 participant