Skip to content

feat(prompts): Add prompt dialog on the All Prompts tab - #483

Merged
gkhngyk merged 2 commits into
mainfrom
feature/add-prompt-dialog
Jul 19, 2026
Merged

gkhngyk merged 2 commits into
mainfrom
feature/add-prompt-dialog

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

The main Prompts page — the primary prompt surface in the sidebar — told users to add prompts in several places but offered no way to do it there; creation lived only under Brands → [brand] → Prompts. This adds an Add prompt button to the All Prompts tab header and to the empty state (previously a dead end), opening a dialog for the active brand.

The dialog mirrors the brand page's Add Prompt card mechanism:

  • Topic select — the brand's topics, fetched lazily on dialog open only (zero cost on page load), defaulting to the first topic; a hint is shown when the brand has no topics yet.
  • Platform & Models picker — the same grouped select (scraper groups + API model groups, label + mono id), plan-filtered, with chatgpt-shopping hidden unless the brand opted in (feat(shopping): org-level "Shopping mode" toggle + ChatGPT Shopping platform + Insights isolation #155). All allowed engines are pre-selected and removable as badges, matching the brand page's defaults.
  • Plan-limit errors render inside the dialog: the new addPromptToBrand action returns user-facing failures as a value (the trackFanoutQuery pattern) instead of throwing — production masks thrown server-action errors into a useless digest message (Query fan-out: long hang then production-masked server error surfaced raw in the UI #427), so the real "plan limit reached" text now reaches the user.
  • The write path is the existing addPromptToSet (same validation, plan filtering, shopping stripping, topic resolution). Target is the brand's earliest prompt set, created on the fly when the brand has none yet.
  • After a successful add: dialog closes, the list refreshes, and a toast notes the prompt will be picked up by the next tracking run.
  • Role-gated: the button (header and empty state) only renders for admin/manager (useUserRole().canManage).

Related issue

Closes #460

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. As admin/manager on /dashboard/prompts?tab=all, click Add prompt in the header: the dialog opens with the brand's topics and all plan-allowed engines pre-selected.
  2. Add a prompt: it appears in the list immediately (active), with a toast about the next tracking run.
  3. Remove all engines from the picker: the Add button disables.
  4. On a brand at its plan's prompt limit, the actual limit message renders inside the dialog — not a generic error.
  5. On a brand with no prompts, the empty state shows the same Add prompt button next to Manage prompts.
  6. As a member (read-only role), neither button renders.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

gkhngyk added 2 commits July 19, 2026 17:46
The main Prompts page told users to add prompts in several places but
offered no way to do it there — creation lived only under
Brands → [brand] → Prompts. The All Prompts tab header (and the empty
state, previously a dead end) now open a quick-add dialog for the active
brand.

The new addPromptToBrand action mirrors trackFanoutQuery's promote flow:
earliest prompt set, platforms/models derived from its most recent
active prompt, and user-facing failures (plan limit, no prompt set)
returned as a value so the real message renders in the dialog instead of
production's masked digest (#427). On success the list refreshes and a
toast notes the prompt joins the next tracking run. The button is
role-gated to admin/manager via useUserRole().canManage.
The quick-add dialog now mirrors the brand page's Add Prompt card
instead of deriving everything server-side: a Topic select (defaulting
to the brand's first topic) and the grouped Platform & Models picker
(plan-filtered, chatgpt-shopping hidden unless the brand opted in),
with all allowed engines pre-selected and removable as badges.

addPromptToBrand now takes the caller's category/platform/model choices,
and creates the brand's first prompt set on the fly instead of erroring
when none exists. Topics are fetched lazily on dialog open only.
@gkhngyk
gkhngyk merged commit d95142e into main Jul 19, 2026
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.

Prompts: add an "Add prompt" action to the main Prompts page

1 participant