Skip to content

feat(web): show "No active plan" instead of a used-up quota while the plan has ended, and keep the buttons opening the plan dialog - #1614

Merged
gkhngyk merged 37 commits into
ansvisor:mainfrom
cihan-gyk:feature/read-only-no-plan-display
Oct 28, 2026
Merged

gkhngyk merged 37 commits into
ansvisor:mainfrom
cihan-gyk:feature/read-only-no-plan-display

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Read-only, part F: the web reads #1611's answers, so an ended workspace sees "No active plan" instead of a used-up quota, and its buttons still open the plan dialog.

With #1611, an ended workspace's quota reads come back with noPlan: true and every limit 0. Without this PR the web read that as "used up":

  • red "0/0 left";
  • "Monthly analysis limit reached. Resets when your subscription renews";
  • disabled buttons that never opened the dialog.

The AI bot report also read the 0 cap as "comes with Growth" and showed sample data and the upsell, hiding the workspace's own data. On an active plan, and self-hosted, nothing changes: noPlan never comes and the workspace isn't locked.

Stacked on #1612 (C3), on #1609, #1606 and #1599. Pairs with #1611: until it's live, these reads still answer 402 and the quotas stay empty, as today. This PR's own change is its commits after #1612's: 7a0d064, f660b0a (the pre-push review's fixes) and 8a2f84a (#1612's last commit merged in). Web only.

One rule: isNoPlan(quota, isLocked) (web/src/lib/billing/no-plan.ts) is true when the server says noPlan or the workspace is locked. Where it's true, a quota doesn't count as used up. One muted line says "No active plan" (readOnly.noPlan), never red. The pure helpers (auditBlock, bulkSuggestBlock, the bot states) take isLocked too, so every place follows the same rule.

Where:

  • Site Audit:
    • Run Audit, the bulk Audit and Re-audit stay clickable and open the dialog.
    • The red "0/0 audits left" is gone.
    • "Audits this month" shows "—" and "No active plan".
    • The settings dialog says "No active plan" instead of "Off: all 0 audits a month are yours."
  • Prompts:
    • "No active plan" replaces "0/0 analyses left" and "Monthly analysis limit reached".
    • Analyze, Re-analyze, Refresh and the "Analyze N prompts" banner stay clickable.
    • The row menu still finds an open content suggestion ("Open content suggestion"), a free read.
  • Content:
    • The usage card shows the counts with "No active plan", no bar, no "Limit reached", and no "resets when your subscription renews".
    • "+ New" and the opportunity panel's two Generate Brief buttons stay clickable.
  • AI bot report: an ended workspace sees its own connections and data ("This month: X detailed rows. · No active plan"), and Create connection opens the dialog. A workspace whose old plan had no bot report (Starter) keeps the upsell, read from the plan the web already knows.
  • Traffic: the bulk Audit and Suggest content stay clickable.
  • Setup's suggestions: fix(server): return a workspace's stored data on reads while its plan has ended, bound setup suggestions without a plan, and name billing's open writes #1611's daily limit (429 onboarding_daily_limit) gets its own line in the topics, prompts and competitors steps: "Setup suggestions are used up for today. Try again tomorrow, or add your own."
    • The prompts step adds "to each topic below to continue".
    • Try again is hidden then.
    • Other errors are unchanged.

Related issue

None. The web side of #1611 (your #1589 follow-up 1), and the product decision (Ansvisor, 2026-10-27).

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/lib/billing src/lib/ai-bots.test.ts src/lib/ai-brand-setup.test.ts "src/app/[locale]/(dashboard)/dashboard/audit" "src/app/[locale]/(dashboard)/dashboard/traffic" "src/app/[locale]/(onboarding)"
  2. On a cloud set-up with fix(server): return a workspace's stored data on reads while its plan has ended, bound setup suggestions without a plan, and name billing's open writes #1611's API and an ended plan:
    • Site Audit's Run Audit opens the dialog;
    • "Audits this month" says "No active plan";
    • Content's usage card shows its counts with "No active plan".

Checked in the browser at 1024 px, light and dark, against the dev DB, with #1611's API and this web, both in cloud mode. The demo organization was set to a cancelled Growth plan, then put back.

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,357 tests): the Library's "fifty at a time" test failed under load and its 43 tests pass alone;
  • yarn build.

For you, @gkhngyk:

🤖 Generated with Claude Code

cihan-gyk and others added 19 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]>
… plan has ended, and keep the buttons opening the plan dialog

With ansvisor#1611, an ended workspace's quota reads come back as `noPlan` with
0 limits. isNoPlan(quota, isLocked) keeps those from reading as used up:
Site Audit, Prompts, the content usage card, Improve and the opportunity
panel say "No active plan" instead of a red 0/0 or "limit reached", and
their buttons stay clickable so the guard opens the dialog. The AI bot
report shows the workspace's own data instead of the Starter upsell.
Setup's suggestions name the onboarding daily limit (429) on their own.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…upsell and one lock rule while the plan has ended

From the pre-push review: the Prompts row menu still looks up an open
content suggestion with no plan; an ended Starter workspace keeps the
bot report's upsell (its old plan has no report), read from the plan
the web already knows; auditBlock, bulkSuggestBlock and the bot states
take isLocked as the pages do; the audit settings and the content usage
tooltip don't speak of a plan that renews; setup's prompt step keeps its
own "add your own" line. Improve's unreachable no-plan branch is gone.
Tests for the onboarding limit and the quota meter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…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 #1612's new head in (8c8f1ea), no conflicts. 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).

# Conflicts:
#	web/src/app/[locale]/(dashboard)/dashboard/brands/[id]/prompts/page.test.tsx
cihan-gyk and others added 12 commits October 28, 2026 13:14
# Conflicts:
#	web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsx
#	web/src/app/[locale]/(dashboard)/dashboard/content/library/page.tsx
# Conflicts:
#	web/src/app/[locale]/(onboarding)/dashboard/onboarding/page.tsx
#	web/src/lib/ai-brand-setup.test.ts
#	web/src/lib/ai-brand-setup.ts
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
…play

# Conflicts:
#	web/src/app/[locale]/(onboarding)/dashboard/onboarding/page.tsx
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

Merged main forward (8356ba3) via #1612: resolved onboarding/page.tsx (kept both translation hooks). Typecheck and the onboarding page test pass.

…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.
… test

Main's "What do you work on?" step brought menu access's server actions
into the onboarding page, and with them the service client, which the test
can't build without its keys: the file failed to load.

@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 e2ce275: it carries #1612's test, and the onboarding page test now mocks @/lib/actions/menu-access, since main's work-areas step pulls in the admin client, which doesn't load in tests.

What I checked:

  • Own change. origin/pr/1612..8c8f1eae: 42 files, web only, no migration (7a0d064, f660b0a and the merges of #1612).
  • One rule. isNoPlan(quota, isLocked) is true when the server sends noPlan or the workspace is locked, and every place that used to read 0 of 0 as "used up" now asks it first: Site Audit (Run, both bulk bars, the overview card's "—" and "No active plan", the settings dialog's line, the empty-pool message), Prompts (the analyses line, the Analyze banner, the bulk Suggest block, the row menu), Content (the usage card, + New, the opportunity panel's briefs line), Traffic (auditBlock) and the AI bot report. Where it's true, the buttons stay clickable and their guards open the dialog. On an active plan noPlan never comes and isLocked is false, so every branch is as before.
  • The AI bot report. Without an active plan both caps read 0, so the lock is now decided by the plan the workspace was on (PLANS[planId].limits.maxBotEventsPerMonth === 0): a former Starter keeps its Upgrade; a former Growth sees its connections and stored rows, and Create connection opens the dialog (#1612's guard). The usage line says "This month: N detailed rows · No active plan" rather than "of 0".
  • The row menu's open suggestion. A prompt with a written content suggestion still shows "Open content suggestion" while locked: the menu reads it when the quota is used up or there's no plan, and opening costs nothing.
  • Setup's daily limit. failure() turns only a 429 with code: 'onboarding_daily_limit' into SetupDailyLimitError, which matches the API's ONBOARDING_LIMIT_REACHED on main. Each step then says the suggestions are used up for today and hides Try again; any other failure reads as before.
  • Copy. "No active plan" is muted, never red. The content usage tooltip drops "Both reset on {date}…" when there's no renewal. The two setup lines read well.
  • Merge state on main (8356ba3). Besides the conflicts from #1599, #1606, #1609 and #1612, this PR's own files conflict in:
    • web/src/lib/ai-brand-setup.ts (#1661 sends the prompts call in batches of 20 topics): put this PR's throw await failure(res, 'Failed to generate prompts') inside main's per-batch call, where main has throw new Error(…). A batch past the limit then rejects the whole Promise.all with SetupDailyLimitError, which is what the step reads.
    • web/src/lib/ai-brand-setup.test.ts: add/add (#1661 added a test file at the same path). Keep both sets of tests in one file, or move this PR's to ai-brand-setup.daily-limit.test.ts.
    • (onboarding)/dashboard/onboarding/page.tsx (#1661's BRAND_SETUP_LIMITS, #1707's tWelcome): keep both imports and both useTranslations lines.
    • dashboard/content/page.tsx (#1672): keep both imports.
  • Your note on Prompts' "Plan & usage" fold is done on main by #1671 (an ended workspace shows its own plan there).
  • Tests. On 0f142e99, the PR's 17 test files pass, and the chat tests. tsc --noEmit: no errors.

Merge after #1612.

@gkhngyk
gkhngyk merged commit 0e3dff1 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