Skip to content

fix(prompts): show an organization whose plan ended its own plan in Plan & usage, not Starter's - #1671

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/prompts-usage-ended-plan
Oct 28, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/prompts-usage-ended-plan

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Prompts › Plan & usage shows an organization whose plan ended its own plan, not Starter's.

Found in the read-only browser check (#1614). /api/prompts/usage read the plan with planFromOrgRow, which gives an organization without an active subscription Starter's limits. So an ended Growth workspace's Plan & usage fold said "Starter plan · 25 of 50 on Starter · Upgrade to Growth".

  • usagePlanFromOrgRow (plan-guard.ts) picks the plan to show usage against:
    • while the subscription is active or trialing, the same plan as planFromOrgRow;
    • once it has ended (cloud), the plan the row names, with Enterprise overrides merged, marked ended.
    • planFromOrgRow itself is unchanged, so limits and costs are untouched.
  • When the plan has ended, the summary's plan gets ended: true and a new cta, choose_plan. Other answers are as before.
  • The cards say "Growth plan · ended", 0 slots left, and "Your Growth plan has ended · Choose a plan". The link goes to the plan page, like the other upgrades. Once feat(web): let a workspace whose plan ended browse read-only, with one "Choose a plan" dialog #1599 merges, it could open the plan dialog instead.
  • The MCP's prompt usage read (getPromptUsageFor) reads the plan the same way.

Pre-push review fixes (8e2bc66):

  • locationQuotaFromUsage counts an ended plan's quota as full, so the Add Prompt dialog and bulk import agree with the card that no slot is left.
  • get_prompt_usage's description names ended and the choose_plan cta, and says no slot is left until a plan is chosen. Before, an agent would say an ended Growth plan had 154 slots left.

Checked in the browser (local, cloud mode, demo org set to Growth + canceled for the check, then restored): /api/prompts/usage answers plan: { key: 'growth', name: 'Growth plan', ended: true, cta: 'choose_plan' }. The page itself redirects an ended workspace on main; it opens once #1599 lands.

Follow-ups:

Related issue

Follow-up from the read-only work (#1599, #1614).

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

cd web && npx vitest run src/lib/guards/plan-guard.test.ts src/app/api/prompts/usage/route.test.ts "src/app/[locale]/(dashboard)/dashboard/prompts/_usage-cards.test.tsx"

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

Full checks were run in one tree with this batch's ten follow-up branches merged, and again after the review fixes:

  • server format, lint and npm test: 246 files, 3,343 tests passed;
  • web format, lint (0 errors; 7 warnings already on main), typecheck and build: all pass;
  • web vitest: 447 files, 4,352 tests passed (after the review fixes).

A pre-push review was run on all ten branches.

🤖 Generated with Claude Code

cihan-gyk and others added 2 commits October 28, 2026 05:44
…lan & usage, not Starter's

Follow-up from the read-only browser check. /api/prompts/usage read the
plan with planFromOrgRow, which gives an organization without an active
subscription Starter's limits, so an ended Growth workspace's Plan &
usage fold said "Starter plan · 25 of 50 on Starter · Upgrade to Growth".

- plan-guard.ts: usagePlanFromOrgRow is the plan to show usage against.
  While the subscription is active or trialing it's planFromOrgRow's; once
  it has ended (cloud), the plan the row names, Enterprise overrides
  merged, marked ended. planFromOrgRow is unchanged for every other caller.
- The summary's plan gets `ended: true` and the new cta `choose_plan`
  then (ended is left out otherwise, so other answers are as before).
- The cards say "Growth plan · ended", 0 slots left, and "Your Growth plan
  has ended · Choose a plan", linking to the plan page as the other
  upgrades do.
- The MCP's prompt usage read (getPromptUsageFor) reads it the same way.

Only seen once an ended workspace can open the dashboard (the read-only
web part, ansvisor#1599). The coach skills list plan.cta's values; they'll need
choose_plan in their own docs PR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd bulk import, and say so in get_prompt_usage

Review follow-up.

- locationQuotaFromUsage read only locationLimit, so with the plan ended
  the cards said 0 slots left while the Add Prompt dialog and bulk import
  still let 154 more in. An ended plan's quota now reads as full.
- get_prompt_usage's description told the agent "Slots left =
  locationLimit − locationsUsed" with no word of plan.ended, so it would
  say an ended Growth plan had 154 left. It now names `ended` and the
  choose_plan cta, and says no slot is left until a plan is chosen.

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, with follow-ups.

What I checked:

  • Own change. Two commits (10d7088, 8e2bc66) on 3f6a4d4. It merges cleanly on main (b591947) and with #1670, #1674 and #1675. With #1599 it has one small conflict, in web/src/lib/mcp/data.ts's imports (#1599 adds assertSubscriptionActive, this adds usagePlanFromOrgRow): keep both lines.
  • The plan shown.
    • usagePlanFromOrgRow gives the plan the row names, Enterprise overrides merged, once the subscription is not active or trialing on cloud. Otherwise it's planFromOrgRow, which is unchanged, so no limit or cost moves.
    • /api/prompts/usage and the MCP's getPromptUsageFor both read it, and the summary carries ended: true and cta: 'choose_plan' only then. Other answers are as before.
    • cta.choose_plan is in en.json, and the link goes to the plan page like the other upgrades.
  • Before the API deploy. Web only, so nothing waits on it. On main an ended workspace is still sent away from the Prompts page, so the new card text is only seen once #1599 lands. The MCP answer changes on merge.
  • Tests. The three named files, the rest of dashboard/prompts/ and lib/mcp pass at the head (143).

Follow-ups:

  1. The Add Prompt dialog and bulk import for an ended plan. locationQuotaFromUsage sets maxPrompts to used, so both read as full, which is right. But their text then names that number as the plan's limit: "Your Growth plan tracks up to 46 active prompt locations and 46 are in use … Pause or remove prompts or locations to free a slot" (prompts/page.tsx:837), and the same in bulk-import-prompts.tsx:265. Pausing frees nothing here. Passing ended through LocationQuota and showing "Your Growth plan has ended · Choose a plan" in both would match the card. This only shows once #1599 opens the page, so it can land with or right after #1599.
  2. The Slots left card's color. For an ended plan it shows 0, but tone comes from the old limit's meter (46 of 200 is "normal"), so the 0 and the Choose a plan link stay in the normal color. Treating ended as full for tone would match the "no slot left" message.
  3. As the description says, past_due and unpaid also read as ended here; one shared source with #1599's readOnlyReason would settle the wording.

@gkhngyk
gkhngyk merged commit 7ada1f6 into ansvisor:main Oct 28, 2026
6 checks passed
gkhngyk pushed a commit that referenced this pull request Nov 6, 2026
…and choose_plan (#2214)

The three coach-skill fixes #1808, #1694 and #1671 left for a docs PR,
in the MCP skill and its standalone copy:

- A brand needs a topic before any prompt: accept_prompt_suggestion is
  refused on a brand without one (#1808). The skill says so, and offers
  a topic suggestion first.
- list_action_history reads an action 7, 14 and 30 days after it
  closed (#1694): reading_day and final are documented, and an outcome
  before day 30 is reported as a reading so far. The outcome list gains
  mixed.
- get_prompt_usage marks an ended plan with plan.ended and the
  choose_plan cta (#1671): no slot is left until a plan is chosen.


Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
(cherry picked from commit 17b7ea8)

Co-authored-by: Claude <[email protected]>
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