Skip to content

fix(prompts): clear every listed suggestion after a confirmation, measured ones included - #1793

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/suggestions-clear-all
Oct 29, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/suggestions-clear-all

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Customer feedback: on Prompt Suggestions, Clear All removed nothing and only said "Search Console and Analytics suggestions were kept — dismiss them individually to hide them for 30 days." Bulk clear deliberately kept suggestions measured from Search Console and Analytics. When every suggestion on screen came from them, nothing happened, which read as a bug.

Now

  • Confirmation first. Clear All opens a confirmation with copy from en.json (prompts.suggestions.clearAllConfirm.*):
    • "{n} suggestions listed will be dismissed."
    • When some are measured: "{m} of them come from Search Console or Analytics: once dismissed, they stay hidden for 30 days."
    • Cancel / Clear all.
  • On confirm, every listed (filtered) suggestion leaves the list at once, and a new server action dismissSuggestions(ids) dismisses them.
  • Failures: suggestions that failed come back with "N suggestion(s) couldn't be dismissed. Try again.". If the call can't run at all, all of them come back with "Couldn't clear the suggestions."
  • Cancel changes nothing. The old measuredSuggestionsKept toast is removed.
  • Roles are unchanged: Clear All still shows to admins, managers and analysts (not agency partners), behind the read-only guard. The single dismissSuggestion (used by Chat's registry and A4's Undo) is untouched.

Related issue

None (customer feedback).

Type of change

  • fix — Bug fix

How to test

  1. On a brand whose suggestions are all from Search Console or Analytics, go to Prompts › Suggestions › Clear All. The dialog says how many come from them and that they hide for 30 days. Confirm, and the list empties. Reload: they stay hidden.
  2. Cancel: nothing changes.
  3. cd web && yarn vitest run 'src/app/[locale]/(dashboard)/dashboard/prompts/_suggestions-card.test.tsx' src/lib/actions/prompt-suggestions.test.ts. 7 new tests cover:
    • mixed-list counts;
    • Cancel;
    • measured-only confirm;
    • partial failure coming back;
    • a call that can't run;
    • 12 ids sent once each;
    • 403 and network errors as failures.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • Web: related tests pass; typecheck and eslint clean
  • Browser check: in the next batched local test
  • Full suite and build: CI

🤖 Generated with Claude Code

cihan-gyk and others added 2 commits October 29, 2026 20:15
…ying what it will hide

Clear All kept the Search Console and Analytics suggestions on purpose,
so a list of only those did nothing but show a toast, which read as a
bug. It now asks first, in a dialog: how many suggestions it dismisses,
and how many of them come from Search Console or Analytics, which stay
hidden for 30 days once dismissed. Confirmed, it dismisses every one
listed, each through the route one by one uses, so the same 30-day rule
applies; cancelled, nothing changes.

- dismissSuggestions(ids): a few at a time, answers { ok } with what
  couldn't be dismissed and never throws (ansvisor#1777). The ones that failed
  come back to the list with a toast; a call that couldn't run puts
  them all back.
- The roles stay as they are: Clear All is for those who may dismiss
  (Admins, Managers and Analysts), not Agency partners. There is no Undo
  to keep.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good.

What I checked

  • dismissSuggestions sends each id through the same /api/prompts/suggestions/:id/dismiss route as a single dismiss, 10 at a time. So the API's role check, its read-only 402 and its demo-brand refusal all still apply, and measured suggestions get the 30-day rule. A refused id comes back as failed and the card puts it back in the list.
  • Read-only gate: the action writes through the API, like dismissSuggestion. subscription-guard-coverage.test.ts passes on the PR merged with main.
  • The confirmation counts what is actually listed (visible, after the search filter) and says how many are measured. Cancel changes nothing.
  • The old measuredSuggestionsKept key is gone, with no references left. Only en.json exists.
  • No embeds and no migration. Merges cleanly with main.

Follow-ups (not blocking)

  1. dismissSuggestions takes an unbounded id array. A cap (e.g. 500) would keep one call from sending thousands of API requests.
  2. Suggestions that couldn't be dismissed are appended to the end of the list, so its order changes. Calling load() after a partial failure would restore the server's order.

Tests (PR merged with main): web vitest _suggestions-card.test.tsx, prompt-suggestions.test.ts and subscription-guard-coverage.test.ts: 49 passed. tsc --noEmit clean; eslint and prettier clean on the touched files.

@gkhngyk
gkhngyk merged commit 312a6ae into ansvisor:main Oct 29, 2026
4 of 5 checks passed
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