Skip to content

feat(bank): opt-in automatic bank-sync confirmation cards#97

Open
alex-mextner wants to merge 1 commit into
mainfrom
feat/bank-cards-opt-in
Open

feat(bank): opt-in automatic bank-sync confirmation cards#97
alex-mextner wants to merge 1 commit into
mainfrom
feat/bank-cards-opt-in

Conversation

@alex-mextner
Copy link
Copy Markdown
Owner

Что

Автоматические карточки подтверждения банк-синка теперь выключены по умолчанию с per-group тумблером для включения. Когда выключено — синк работает в режиме «только балансы/история»: транзакции пишутся в БД, но непрошеные карточки не шлются и AI-prefill не тратится.

Изменения

  • Миграция 050: groups.bank_cards_enabled INTEGER NOT NULL DEFAULT 0 (идемпотентная, существующие миграции не тронуты).

  • Group тип + репозиторий: чтение и запись bank_cards_enabled.

  • sync-service.ts: три автоматических пути отправки обёрнуты в if (group.bank_cards_enabled):

    1. Phase 2 — preFillTransactions (трата на Anthropic) — скипается целиком
    2. Phase 3 — per-tx карточки за сегодня
    3. notifyOldTransactions — сводка по старым транзакциям («Показать для подтверждения?»)

    Phase 1 (вставка транзакций) и все операционные/user-initiated пути (OTP, ack, алерт о 3 ошибках, обновление панели, колбэки bank_show_old/confirm/edit) остаются живыми.

  • /settings: тумблер «Карточки банковских транзакций: вкл/выкл» с ре-рендером на месте через ctx.editText; колбэк settings:bankcards (18 байт).

Решённые дефолты

Off по умолчанию, per-group, prefill скипается при off, все три пути загейчены, без ретроактивного флуда (notifyOldTransactions шлёт только то, что вставлено в текущем цикле).

Тесты

TDD: off-путь (транзакции вставлены, prefill НЕ вызван, карточки НЕ отправлены, notifyOldTransactions НЕ вызван) + on-путь (поведение как было) + миграция/репозиторий + тумблер в settings.

Полный сьют: 3417/3417 зелёные, tsc чисто.

Вне скоупа

Тумблер виден только в /settings — в панели /bank и /help не упомянут (по решению, можно добавить отдельно).

🤖 Generated with Claude Code

Bank sync previously pushed a transaction confirmation card to the group on
every cycle. Make all automatic cards opt-in per group.

Decided defaults:
- Off by default (migration 050 adds groups.bank_cards_enabled INTEGER NOT NULL
  DEFAULT 0).
- Per-group (shared across members), toggled like default_currency — not per-user.
- Prefill (Anthropic spend) is skipped when off — no point paying for prefill
  nobody sees.
- No retroactive flood on enable: notifyOldTransactions only fires for tx inserted
  in the current cycle, so flipping the toggle on later never dumps backlog.

When bank_cards_enabled is falsy, sync becomes balance/history-only: Phase 1 still
inserts every transaction (debit -> pending, credit -> skipped_reversal), but all
three automated push paths are gated off as a single block:
  1. Phase 2 — preFillTransactions (AI prefill)
  2. Phase 3 — per-transaction confirmation cards for today
  3. notifyOldTransactions — old-tx summary card

OTP prompts, the "Принято" ack, the 3-consecutive-failures alert, panel updates,
and the user-initiated bank_show_old / bank_confirm / bank_edit callbacks are NOT
gated — they stay operational.

Settings UI: /settings now shows the bank-cards state (вкл/выкл) with an inline
toggle button (callback_data "settings:bankcards"); the callback flips the flag via
the repository and re-renders in place.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

🤖 Stage bot deployed! Test it: https://t.me/ExpenseSyncStageBot

Branch: feat/bank-cards-opt-in @ 03d5de4

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