Skip to content

fix(cli,web,agent): cover reaction + filter cleanup gaps (#562)#568

Open
axisrow wants to merge 3 commits into
mainfrom
worktree-issue-562-fix
Open

fix(cli,web,agent): cover reaction + filter cleanup gaps (#562)#568
axisrow wants to merge 3 commits into
mainfrom
worktree-issue-562-fix

Conversation

@axisrow
Copy link
Copy Markdown
Owner

@axisrow axisrow commented May 18, 2026

Summary

Closes the gaps audited in #562 across reaction action and filter cleanup commands.

  • Reaction: CLI dialogs react now requires confirmation (--yes to skip); new web endpoint POST /dialogs/react routed through the existing TelegramCommandDispatcher; new agent tool send_reaction with standard require_confirmation gate.
  • filter purge: massive message deletion now asks confirmation in CLI (--yes to skip). Web already shows the affected set via checkboxes.
  • filter reset: added selective --pks in CLI and a /filter/reset-selected endpoint + "Сбросить выбранные" button in web. New ChannelAnalyzer.reset_filters_for_pks keeps the analyzer API additive.
  • filter hard-delete: added /filter/hard-delete-all endpoint + red "Удалить все из БД" button (dev-mode only) so web matches the CLI capability.
  • Updated TELEGRAM_ACTION_INVENTORY (send_reaction now lists web_command + agent_tool) and the parity table.

Test plan

  • ruff check src/ tests/ conftest.py
  • pytest tests/test_telegram_action_contract.py -v (4 passed)
  • pytest tests/ -m "not aiosqlite_serial" -n auto (6947 passed, 2 skipped)
  • pytest tests/ -m aiosqlite_serial (821 passed)
  • Manual: python -m src.main dialogs react @chan 123 👍 shows confirm prompt
  • Manual: python -m src.main filter purge shows confirm prompt
  • Manual: python -m src.main filter reset --pks 1,2 resets only listed channels
  • Manual: /channels/filter/manage shows new "Сбросить выбранные" + "Удалить все из БД" buttons

🤖 Generated with Claude Code

- dialogs react: add --yes confirm in CLI, /dialogs/react web endpoint
  via TelegramCommandDispatcher, send_reaction agent tool with require_confirmation
- filter purge: require interactive confirmation in CLI (--yes to skip)
- filter reset: add --pks selective mode in CLI and /filter/reset-selected
  in web with new ChannelAnalyzer.reset_filters_for_pks helper
- filter hard-delete: add /filter/hard-delete-all web endpoint to mirror CLI
- update parity table and TELEGRAM_ACTION_INVENTORY for send_reaction
- update affected tests to pass yes=True

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 18, 2026 16:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR closes parity and safety gaps around Telegram reactions and filter cleanup by adding confirmation gates, web/agent entrypoints, and selective filter reset support.

Changes:

  • Adds CLI confirmation for dialogs react and filter purge, plus selective filter reset --pks.
  • Adds web endpoints/buttons for reaction, selective reset, and dev-mode hard-delete all.
  • Adds agent send_reaction tool and updates action inventory/parity docs.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/cli/commands/dialogs.py Adds confirmation before sending reactions.
src/cli/commands/filter.py Adds purge confirmation and selective filter reset handling.
src/cli/parser_domains/dialogs.py Adds --yes/-y to dialogs react.
src/cli/parser_domains/filter.py Adds reset --pks and purge --yes.
src/filters/analyzer.py Adds selective filter reset by channel PK.
src/web/routes/dialogs.py Adds POST /dialogs/react command enqueue route.
src/web/dialogs/forms.py Adds reaction form model.
src/web/routes/filter.py Adds filter hard-delete-all and reset-selected endpoints.
src/web/templates/filter_manage.html Adds web buttons/forms and selection syncing for new filter actions.
src/services/telegram_command_dispatcher.py Adds dispatcher handler for dialogs.react.
src/services/telegram_action_inventory.py Marks reaction as covered by web and agent surfaces.
src/agent/tools/messaging_write.py Adds agent send_reaction tool.
src/agent/tools/messaging_schemas.py Adds reaction tool schema.
src/agent/tools/permissions.py Adds reaction tool to write permissions and UI grouping.
docs/reference/parity.md Documents reaction parity across CLI/web/agent.
tests/test_cli.py Updates purge tests to skip new confirmation.
tests/test_cli_filter.py Updates filter purge tests for --yes.
tests/test_cli_commands_edge_cases.py Updates edge-case purge tests for --yes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/web/routes/filter.py
analyzer = ChannelAnalyzer(db)
count = await analyzer.reset_filters_for_pks(pks)
return RedirectResponse(
url=f"/channels/filter/manage?msg=filter_reset_selected&count={count}",
axisrow and others added 2 commits May 18, 2026 23:16
- reset_filters_for_pks: single bulk UPDATE in repo instead of N+1 per-pk loop
- _handle_dialogs_react: drop echoed message_id/emoji from payload to match
  sibling dispatcher handlers

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Closes the trust-boundary gap Codex flagged in PR #568 adversarial review:
on installs with a saved per-phone ACL, any tool missing from the JSON
(notably newly-introduced WRITE/DELETE actions like send_reaction)
implicitly received permission for every phone.

- _default_permissions(for_missing_in_saved=True): READ keeps default
  True, WRITE/DELETE default False. Used by load_tool_permissions,
  load_tool_permissions_all_phones, load_tool_permissions_union and
  the save-side seeding for unsaved accounts.
- require_phone_permission: branch on ToolCategory. READ keeps the
  legacy permissive fallbacks (no allowed_phones / phone not in perms
  → allow). WRITE/DELETE require an explicit per-phone grant once any
  ACL exists, route through PermissionGate when available, or return
  a text error pointing to the settings page. Legacy flat ACL is
  handled symmetrically: known-True allows, READ falls through,
  WRITE/DELETE without an entry deny.
- Clean installs without saved ACL keep the existing permissive
  behaviour (all tools enabled).
- Update three tests that previously locked in the bypass and add
  coverage: per-phone missing WRITE/DELETE → False; union missing
  WRITE/DELETE → False; legacy flat missing WRITE → deny; regression
  test for send_reaction blocked on restrictive legacy ACL.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.

2 participants