Skip to content

feat(web): open the plan dialog from the remaining areas' actions, and from every way to add a brand, while the plan has ended - #1612

Merged
gkhngyk merged 26 commits into
ansvisor:mainfrom
cihan-gyk:feature/read-only-guard-rest
Oct 28, 2026
Merged

gkhngyk merged 26 commits into
ansvisor:mainfrom
cihan-gyk:feature/read-only-guard-rest

Conversation

@cihan-gyk

@cihan-gyk cihan-gyk commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Read-only, part C3: the remaining areas' actions, and every way to add a brand, open the plan dialog. On a workspace whose plan ended, every action that writes or costs opens #1599's "Choose a plan to keep going" dialog, naming the action, and runs nothing. The areas are Site Audit, Action Center, Mentions, Citations, AI Referral Traffic, Shopping, Reports, Chat, brand settings and Settings. On an active plan, and self-hosted, nothing changes.

Stacked on #1609 (C2), on #1606 (C1), on #1599. This PR's own change is its commits after #1609's: 2e2fd65, 7f1ba51 (the pre-push review's fixes), b29df54 (found in the browser check), 20913b2 (brand deletion stays open), and 4da9280 and d6ce009 (main's new actions, after merging main through #1609). Web only.

Same pattern as C1 and C2:

  • guard(handler, { action }), with labels in readOnly.actions.* (66 new);
  • buttons aren't disabled;
  • a guard sits before any confirm dialog.

Adding a brand, every way:

  • A new AddBrandLink opens the dialog instead of /dashboard/brands/new. It's used for:
    • the brands page header;
    • the brands page's empty state;
    • brand-guard's Create Brand;
    • at the plan's brand limit, the header's link to Billing.
  • The sidebar's "+ Add Brand", and its button when there's no brand. The mobile menu closes first.
  • /dashboard/brands/new reached directly: step 2's Continue, which creates the brand, opens the dialog.

Guarded:

  • Site Audit:
    • Run audit (button and Enter);
    • bulk Audit and Re-audit, Pin, Unpin, Exclude, Restore, Delete;
    • the audit page's Re-audit and Delete;
    • the settings dialog's Save and Unpin;
    • site trust's Check again.
    • A partial site trust result isn't re-read automatically while locked, since that read scrapes.
  • Action Center:
    • Getting started: Start, Skip, and each step's skip. The new-brand "run it?" prompt doesn't open itself.
    • Actions: status, assignee, due date and delete, from the table and the drawer.
    • Tasks: status, edit, add, delete, Send, Regenerate, Create content, Optimize page.
    • Signals: status.
    • KPIs: edit, add, remove, the framework drawer's Save. The ready-made set isn't seeded while locked; it shows as a preview.
    • Needs review: Approve, Dismiss.
    • The "page opened" mark isn't sent; its component moved inside the dialog's provider.
  • Mentions: Send to Action Center, Suggest content, sentiment correction.
  • Citations: Add competitor.
  • AI Referral Traffic:
    • Send, bulk audit, Suggest content, Audit page, Track and Track all;
    • Add prompts: its dialog calls the AI when it opens, so the opening is guarded;
    • the bot log connection;
    • Search Console and Analytics Connect, through useIntegrationConnect, which Settings shares.
  • Shopping: the direct feed checkbox.
  • Reports: Generate Report, Delete.
  • Chat: labels on feat(web): let a workspace whose plan ended browse read-only, with one "Choose a plan" dialog #1599's New chat and send guards; deleting a chat added.
  • Brand settings: Save, the Shopping switch, Pause and Resume, Domains, competitors add and remove, conversions, brand facts' Approve, Reject and Read again.
  • Settings:
    • organization name;
    • Invite, Resend and role changes;
    • AI keys' Add or Replace, and Use for Chat;
    • property mapping (auto-mapping doesn't save while locked);
    • catalog: add a feed or upload, Sync, remove a feed, connect a store, update a store's sign-in;
    • Webflow connect and Replace token, Save;
    • notifications, authors, content settings.

Brought in by main since, guarded here (4da9280, d6ce009):

Left open:

Related issue

None. Product decision (Ansvisor, 2026-10-27), including "adding a new brand, from Settings and everywhere". Follows #1599, #1606 and #1609.

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. cd web && yarn vitest run src/components/dashboard/add-brand-link.test.tsx src/components/layout/brand-switcher.test.tsx "src/app/[locale]/(dashboard)/dashboard/brands" "src/app/[locale]/(dashboard)/dashboard/audit" src/components/settings
  2. On a cloud set-up with an ended plan (see feat(web): let a workspace whose plan ended browse read-only, with one "Choose a plan" dialog #1599):
    • the sidebar's + Add Brand opens the dialog labelled "Adding brands needs a plan";
    • Settings › Team's Invite member opens it too;
    • Remove on a member still works.

Checked in the browser at 1024 px, light and dark, against the dev DB, with main's API in cloud mode and this web in cloud mode. The demo organization was set to a cancelled Growth plan, then put back. Each of these opened the dialog with its label, and the page stayed where it was:

  • the sidebar's + Add Brand;
  • /dashboard/brands' Add Brand, at the plan's brand limit (this check found the Billing link, fixed in b29df54);
  • /dashboard/brands/new's step 2 Continue;
  • Team's Invite member;
  • Reports' Generate Report;
  • an action's status from its row menu.

Afterwards the database had no new brand, report or action status. Nothing scrolls sideways.

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

Also run in web/:

  • yarn format, yarn lint (0 errors, the 7 earlier warnings);
  • yarn typecheck;
  • yarn test (4,321 tests);
  • yarn build.

For you, @gkhngyk:

🤖 Generated with Claude Code

cihan-gyk and others added 7 commits October 27, 2026 17:58
…e "Choose a plan" dialog

On the cloud, an ended trial, a cancel during the trial and a cancel
after the first payment can now sign in and look around. They used to
see a full-screen "subscription expired" notice that only signed out.
Onboarding is unchanged: an admin who never started a trial still goes
to the plan step.

- The dashboard layout lets these workspaces in, read-only. A thin
  banner says so, with "See plans".
- UpgradeDialogProvider and useUpgradeGate ({ guard, isLocked,
  openUpgrade }) open one "Choose a plan to keep going" dialog, with the
  action that was clicked as a label.
  - Admins go to Billing; members are told to ask their admin.
  - A failed payment (past_due, unpaid) says so and opens Stripe's
    portal.
  - A 402 subscription_inactive from the API opens the dialog
    (use-failure-toast, api-failure's subscription class, and the
    Webflow, catalog, publish and Send to CMS clients).
- Automatic calls (Library's Webflow status, the editor's link, source,
  claim and page reads, Improve's read) aren't sent while locked.
- Billing: an ended subscription starts a new Checkout ("Choose
  {plan}", monthly or annual). The checkout route takes admins only,
  refuses a second live subscription (409), and validates its body.
  Billing reads again after a change.
- MCP: list_ and get_ tools stay open; every other tool, and REST
  writes, answer subscription_inactive. Chat and new conversations
  answer 402, and runSiteAuditFor, generateBriefFor and
  createImproveActionFor check too. A chat message refused by a 402
  goes back to the input.

Self-hosted is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the plan has ended

Read-only, part C1. On an ended plan, every action in Prompts, Prompt
Suggestions, Topics, Query Fan-out, Brand Visibility and Competitors
opens the "Choose a plan" dialog with the action named, and runs
nothing. On an active plan they run as before. Buttons aren't disabled.
- Tracked Prompts: add, import, edit, analyze and refresh volumes, the
  bulk bar, work status and the row menu.
- Prompt and topic suggestions: generate, add, accept, dismiss.
- Manage prompts and topics: add, generate, locations, analyze, edit,
  delete.
- Query Fan-out's Track; Brand Visibility's Run All, Test Single Prompt,
  Opportunities' Track and Send, and pinning a competitor.
- Competitors: suggest (its dialog calls AI on opening), add, delete.
- The Positions panel: Improve's Generate and Regenerate, Send Actions,
  and Create or Optimize content.
- The labels live in readOnly.actions.* ("Adding prompts needs a plan").
- volumes.ts tells the API's 402 subscription_inactive from a feature
  the plan lacks, so a refused analysis opens the dialog instead of "not
  part of your current plan".
- While locked, Tracked Prompts doesn't warn that volume data is
  unavailable, and Query Fan-out doesn't send its intent classification.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…keep the editor read-only, while the plan has ended

Read-only, part C2. On an ended plan, every action that writes or costs
in Content Opportunities, the opportunity panel, Content Plan, Library,
New content and the Content Editor opens the "Choose a plan" dialog,
naming the action, and runs nothing.
- Opportunities: New, the bulk bar (send, done, dismiss and delete open
  the dialog instead of their confirm), the row menu, the webhook
  settings' Test and Save, and the panel's sends, brief, Reviewed,
  Restore and Dismiss.
- Plan: New content, Start, Assign, Priority, Hide and Show. A ?start=
  link starts nothing while locked.
- Library: New content (and ?new=1), status changes, archive, delete,
  and single and bulk Send to CMS.
- The editor:
  - Run Agent, Rewrite, Fix rules, hand-off;
  - accepting or rejecting suggestions;
  - Mark ready, Ready back to review, Mark published, Send to CMS,
    History Restore;
  - page and site type, author and reviewer;
  - Quality's confirms, sources and images, and Add line or Remove;
  - renaming, dropping files, the toolbar;
  - the Brief's run, rewrite and edit; the Sources and Rules changes;
    Your input.
- The editor itself is read-only while locked (editable: false, the
  HTML view readOnly), and autosave is off (useDraftAutosave { off }):
  nothing is saved, and leaving doesn't warn.
- Reading, filters, exports, Copy HTML and Stop stay open.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d from every way to add a brand, while the plan has ended

Site Audit, Action Center, Mentions, Citations, AI Referral Traffic,
Shopping, Reports, Chat, brand settings and Settings now guard their
actions with useUpgradeGate, as Prompts (ansvisor#1606) and Content (ansvisor#1609) do.
Every way to add a brand (sidebar, /dashboard/brands, brand guard,
/dashboard/brands/new) opens the dialog. Disconnects, key revokes and
API key creation stay open.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ng stores open while read-only, and stop the site trust card's automatic re-read

From the pre-push review: ending an access stays open, as disconnects
do; a partial site trust result isn't re-read while the plan has ended,
since that read scrapes. Adds tests for the audit page's Run audit and
the integrations' property mapping, resets shared mocks between tests,
closes the mobile menu before the dialog, and words the KPI preview for
a read-only workspace.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…it too, while read-only

At the limit, /dashboard/brands' Add Brand links to Billing; a read-only
workspace now gets the dialog there as on every other way to add a brand.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ansvisor's decision (2026-10-27): deleting a brand only removes what the
person gave us, so it stays open while the plan has ended. The API opens
DELETE /brands/:id in ansvisor#1611.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
cihan-gyk and others added 7 commits October 27, 2026 23:48
…essage test

main's catalog-client test (ansvisor#1583) asks for words for every StoreError
code; 'subscription' opens the upgrade dialog instead of saying one, so
the test leaves it out, as ansvisor#1613 does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd main's other new actions while the plan has ended

main's new writes, with C3's guard pattern and labels:
- Merchant Center (ansvisor#1583): picking and adding an account open the plan
  dialog ("Connecting a store needs a plan"); the server's 'subscription'
  refusal on Add opens it too, instead of looking up a missing
  settings.catalog.stores.errors.subscription message.
- Category pages (ansvisor#1587): Change, Save, No page and Use the match are
  guarded; the catalog client reads the server's 402
  subscription_inactive as 'subscription', which opens the dialog
  instead of the generic failure.
- Brief › Shopping path (ansvisor#1591): Pick from the catalog, Pick again, Add
  product, Lock, Swap and Remove are guarded.
- Action Center Check now (AC-010, ansvisor#1565) is guarded.

New labels: changeCategoryPages, changeShoppingPath, checkTasks.
Insert › Products (ansvisor#1607) already goes through the toolbar's guard and
the read-only editor shows no insert menu; a test now says so. The
Shopping rules (ansvisor#1610) change through the rules hook, already guarded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…g it during render

React's refs rule refuses passing add, which reads addingRef, to guard
while rendering. add now opens the plan dialog itself on a read-only
workspace.

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

Copy link
Copy Markdown
Collaborator Author

Merged #1609's new head in, then guarded what main brought in since (4da9280, d6ce009): Merchant Center account pick and add (#1583), catalog category pages' Change, Save, No page and Use the match (#1587, its 402 now opens the dialog), Brief › Shopping path's actions (#1591), and the Action Center's Check now (#1565). Insert › Products was already behind the toolbar's lock (test added). The description lists them. Checks on the chain's tops: typecheck on every branch; at #1614, yarn test (4,576 tests) and yarn build; at #1613, its tests and yarn build (the editor page's test file timed out under load in the full run and passes alone, 323 tests with the Library's).

cihan-gyk and others added 6 commits October 28, 2026 13:11
# Conflicts:
#	web/src/app/[locale]/(dashboard)/dashboard/brands/[id]/prompts/page.test.tsx
# Conflicts:
#	web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsx
#	web/src/app/[locale]/(dashboard)/dashboard/content/library/page.tsx
main's new brand page now reads BRAND_SETUP_LIMITS from ai-brand-setup
(ansvisor#1661), which the test's mock left out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The API (ansvisor#1613) leaves deleting a conversation open and the FAQ (ansvisor#1631)
lists it among what still works, so the chat page asks before deleting
instead of opening the plan dialog. It costs nothing, and people can
always remove their own conversations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	web/src/app/[locale]/(dashboard)/layout.tsx
#	web/src/lib/mcp/data.ts
…ntent

# Conflicts:
#	web/src/app/[locale]/(dashboard)/dashboard/content/_webhook-settings.tsx
#	web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx
# Conflicts:
#	web/src/app/[locale]/(dashboard)/layout.tsx
#	web/src/components/action-center/action-drawer.tsx
#	web/src/components/action-center/action-table.tsx
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

Merged main forward (8356ba3) via #1609: resolved (dashboard)/layout.tsx, action-drawer.tsx and action-table.tsx (dismissing asks why through the read-only guard; Check now is guarded and follows main's pageCheckable). The Check now test's task now carries its change (#1683), and a duplicate import the merge brought in is removed. Typecheck and drawer/table tests pass. Also new here: 3b2b9a0 keeps deleting a chat open on a read-only workspace (see #1631).

cihan-gyk added a commit to cihan-gyk/ansvisor that referenced this pull request Oct 28, 2026
…h its confirm

The test opened the confirm only; it now presses Delete and expects the
DELETE request, with no plan dialog. The file's header says deleting
stays open.

@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 with 8251153: your 3b2b9a0 already keeps deleting a chat open, as I had done in 235158a8 (below). On top of it I added a test that presses Delete while locked and expects the DELETE request with no plan dialog (yours only opened the confirm), and fixed the file header that still said deleting opens the plan dialog.

This PR guarded the chat list's trash button: on a read-only workspace it opened the plan dialog ("Deleting chats needs a plan"). But DELETE /api/agent/conversations/[id] stays open for such a workspace (#1599 left it out of the gate, and #1613 lists it as open on purpose: deleting a conversation starts no cost), and #1631's FAQ lists "deleting an Agent Chat conversation" among what still works. So the button and the server disagreed. I made the web match the server:

  • agent/page.tsx: the trash button always asks its usual confirm, and Delete deletes. New chat and sending still open the dialog.
  • en.json: readOnly.actions.deleteChats removed (nothing else used it).
  • agent/page.test.tsx: the read-only test now checks that New chat and sending open the dialog (2 calls, nothing sent), and a new test deletes a conversation on a read-only workspace through its confirm (one DELETE, the row gone). That test fails on d6ce009.

Deleting an audit or a report stays guarded, as you wrote: those match the server (audits through the API's 402, deleteReport through #1613's check).

What I checked:

  • Own change. origin/pr/1609..d6ce0099: 94 files, web only, no migration. Commits 2e2fd65, 7f1ba51, b29df54, 20913b2, 4da9280, d6ce009 and the merge of #1609.
  • The guards. Every handler in the description goes through guard(fn, { action }) or an explicit isLocked check before anything is sent, and each label exists in readOnly.actions.*. A guard sits before each confirm (Delete in audits, reports, competitors, actions; Skip; Regenerate; Invite, which cancels the dialog's opening). The guarded onChange/onValueChange/onCheckedChange handlers keep their controls as they were, since they're controlled.
  • What stays open matches the server and #1631: removing a member, revoking an invitation, creating and revoking API keys, removing an AI key, the disconnects (Search Console, Analytics, Webflow, the bot log connection, a store), deleting a brand, Billing and Account, reading and exports.
  • Automatic calls while locked. The KPI preset isn't seeded, the site trust card's partial read isn't repeated (it scrapes), property auto-mapping doesn't save, the new-brand "run it?" question doesn't open, and the "page opened" mark isn't sent (its component now sits inside the dialog's provider, so it can read the lock).
  • Adding a brand. AddBrandLink covers the brands header, its empty state, the brand-limit link to Billing and brand-guard's Create Brand; the sidebar and its mobile menu (closed first) open the dialog; /dashboard/brands/new reached directly can't create (step 2's Continue is guarded). Steps 3–5 need the created brand, so they're unreachable.
  • Paying workspaces. With isLocked false every guard() passes through, the effects run as on main, and the 'subscription' codes added to CategoryPageError and Merchant Center's add are never returned.
  • Merge state on main (8356ba3). Besides the conflicts from #1599, #1606 and #1609, this PR's own files conflict in:
    • (dashboard)/layout.tsx: <GettingStartedPageOpened /> moved inside UpgradeDialogProvider; keep it there, inside main's MenuAccessProvider nesting (see #1599).
    • components/action-center/action-drawer.tsx and action-table.tsx (#1692, the dismiss reason; #1683/#1684, Check now): keep main's dismiss-reason dialog behind this PR's status guard, so a locked workspace gets the plan dialog before the reason is asked.
  • Main's newer write buttons this PR doesn't reach yet (after the merge; the server refuses them through #1613, but they show a toast instead of the dialog): the Content Plan's Shopping "buying guide" create (#1617), the prompt page's demand card Track (#1651), and Settings › Menu access (#1704/#1705). Worth guarding in the merge or right after. Work areas (#1706/#1707) should stay open: see #1613.
  • Tests. On 235158a8, the PR's 43 test files pass, and the chat tests above. tsc --noEmit: no errors. eslint and prettier are clean on the files I touched.

Merge after #1609; #1614 is stacked on it (take-1614 merges this fix in).

@gkhngyk
gkhngyk merged commit b9f2ae5 into ansvisor:main Oct 28, 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