Skip to content

feat(telegram): confirmed edit/delete/undo on transactions#42

Merged
square-story merged 1 commit into
mainfrom
bot-improvements
Jul 5, 2026
Merged

feat(telegram): confirmed edit/delete/undo on transactions#42
square-story merged 1 commit into
mainfrom
bot-improvements

Conversation

@square-story

Copy link
Copy Markdown
Owner

What & why

Adds the ability to edit, delete, and undo transactions from Telegram, each behind a Yes/No confirmation (previously undo deleted silently and there was no edit at all). Works for both expenses and income.

How it works

One confirm→act pipeline, several entry points:

  • Reply to a transaction confirmation — a delete word (delete/remove/…) → delete confirm; a correction (250, groceries, 250 groceries) → before→after edit confirm.
  • [✏️ Edit] / [🗑 Delete] buttons under every expense/income confirmation ([🗑 Delete all] on batch summaries).
  • undo now asks to confirm.
  • Confirmations resolve in place ("Deleted ✔ / Updated ✔"), toast the tap, and leave an [↩️ Undo] restore button.

Key pieces

  • New txn: callback namespace (dependency-free txnCallback.ts) + transactionActions.ts flow module centralizing delete/restore/edit + prompts.
  • TransactionReplyProcessor (post-parse) and TransactionActionProcessor (pre-parse); UndoProcessor now resolves the latest entry and confirms.
  • Income parity: Income.confirmationMessageId migration + repo methods; expense/income repos gain update() + restore()/restoreByBatchId(). Edit re-derives the bucket via resolveExpenseCategory extracted from recordExpense.
  • Messaging: reply-threaded prompts + toast on answerCallbackQuery; controller acks after handling.

⚠️ Migration

prisma/migrations/*_add_income_confirmation_message_id is committed but not applied — run prisma migrate deploy in the target environment before/at deploy.

Verification

  • pnpm build ✅ · pnpm lint ✅ · pnpm test:unit 129 passed (added specs for both new processors; rewrote UndoProcessor spec for confirm-first).
  • Not verified: live Telegram flow (needs webhook + DB) — manual runbook in the design doc.

🤖 Generated with Claude Code

Reply to a transaction (or tap the new [✏️ Edit]/[🗑 Delete] buttons) to edit or
delete it behind a Yes/No confirmation; `undo` now confirms too instead of
deleting silently. Works for both expenses and income.

- New txn: callback namespace (dependency-free grammar in txnCallback.ts) and a
  transactionActions.ts flow module that centralizes delete/restore/edit + the
  confirm prompts and keyboards.
- TransactionReplyProcessor (post-parse) routes a reply to a delete or edit
  confirm using the already-parsed reply; TransactionActionProcessor (pre-parse)
  handles every txn: tap, resolving the prompt in place with a toast and an
  [↩️ Undo] restore button.
- UndoProcessor now resolves the latest entry and confirms; the delete + budget
  summary moved into transactionActions (shared with reply/undo).
- Income parity: add Income.confirmationMessageId (migration) + repo methods;
  capture/store the confirmation message id in IncomeProcessor. Expense/income
  repos gain update() + restore()/restoreByBatchId(). Edit re-derives the bucket
  via resolveExpenseCategory extracted from recordExpense.
- Messaging: sendInteractiveMessage gains reply threading; acknowledgeInteraction
  gains toast text; the controller acks after handling to surface the toast.

Migration prisma/migrations/*_add_income_confirmation_message_id created offline
(not applied) — run migrate deploy in the target environment.

Tests: added TransactionReply/TransactionAction specs, rewrote UndoProcessor for
the confirm-first behavior; 129 unit tests pass. build + lint green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@square-story square-story merged commit 416a5c3 into main Jul 5, 2026
3 checks passed
@square-story square-story deleted the bot-improvements branch July 5, 2026 04:24
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.

1 participant