Skip to content

feat(content): put catalog products in a page as a card or a grid, by hand or with the agent (shopping path, part 5) - #1607

Merged
gkhngyk merged 27 commits into
ansvisor:mainfrom
cihan-gyk:feature/shopping-product-blocks
Oct 27, 2026
Merged

gkhngyk merged 27 commits into
ansvisor:mainfrom
cihan-gyk:feature/shopping-product-blocks

Conversation

@cihan-gyk

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

Copy link
Copy Markdown
Collaborator

Summary

E-commerce Shopping path, part 5 of 7: product blocks. The person can put catalog products in a page as a card or a grid. The Content Agent's new page gets the same grid from its shopping path.

Stacked on #1592 (part 4), which is stacked on #1591, #1588, #1587, #1583 and #1582. This PR's own change is its commits after #1592's:

Insert › Products (toolbar and the empty-line menu), on an online shop's draft:

  • Search the catalog by name, pick 1 to 4, then Insert.
    • Hits show their price, or "Sold out" or "No page to link". Such a product can't be picked.
    • Picks stay through a new search and can be taken back.
    • The count is aria-live, and Insert shows it's working.
  • One product shows as a card, more as a grid. Each shows its picture, name and price, linked to its page.
    • The price is the cheapest variant in stock, sale price first. A price of 0 counts as none.
    • Links and images are https only, without tracking parameters or a hash.
  • The block is an HTML block with inline styles and no words of its own, so it reads the same in any language. Its markup has line breaks between cards and a space before each price, so a text export reads each product apart.
  • At insert, a product sold out meanwhile is left out, with a toast. Cancel or Esc while inserting inserts nothing.
  • The image alt is the product name, since a text export reads an image by its alt.

The agent's new page on a best-of list, a buying guide or a comparison gets the grid from its shopping path:

Send to Webflow turns the grid into a list (<ul><li><a>Name</a> $189.00</li>…), so each product reads on its own line in Webflow's rich text.

The markup is written twice, on the web (lib/content/product-block.ts) and on the server (lib/shopping-blocks.js). Both tests read one fixture (__fixtures__/product-block.json), so the two can't drift.

Reads:

  • actions/shopping-path.ts getProductsForBlock and searchProductsForBlock read through RLS, each product's variants and image on their own. An image with no variant comes first.
  • Stock is read one way with the feed check (feed-match.ts variantStock).
  • catalog_images is added to types/supabase.ts.

Docs: the Content Editor guide has a paragraph on Insert › Products and the agent's grid.

Related issue

Part of the e-commerce Shopping path plan (Drive › E-commerce › ECOM-shopping-journey-plan.md §6), part 5 of 7. Builds on #1270 (#1582, #1583) and #1587–#1592.

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 server && npx vitest run src/lib/shopping-blocks.test.js src/lib/shopping-links.test.js src/lib/content-writer.test.js src/lib/cms/webflow-items.test.js
  2. cd web && yarn vitest run src/lib/content/product-block.test.ts src/lib/actions/shopping-path.test.ts "src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_product-block-dialog.test.tsx" "src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_toolbar.test.tsx"
  3. On an e-commerce brand's draft with a catalog (part 1), open Insert › Products:
    • search, pick two, and Insert: a grid block goes in;
    • a sold-out product can't be picked.

Checked in the browser at 1024 px, light and dark, with this branch's API and web against the dev DB. Temporary data, all removed afterwards:

  • the demo brand set to e-commerce;
  • a feed with six espresso machines and grinders, one sold out and one on sale;
  • a buying guide draft.

What the check showed:

  • Insert › Products searched "espresso" and listed five products with their prices; the sale price showed ($799.00).
  • "Acme Lever Espresso Machine" read "Sold out" and couldn't be picked.
  • Picking two showed them as chips with "2 of 4 picked". Insert put an HTML block ("2 lines") with the grid into the page.
  • Nothing scrolls sideways.

Seen in passing, and not from this PR: inserting into an empty draft with no H1 empties its title, since the editor takes the title from the page's H1 on every edit.

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:

  • server/: npm run format, npm run lint and npm test (3,129 tests). One fix-path test needed the fresh variant its price is now read from (22d4d74); a timing test that failed under load passes alone.
  • web/: yarn format, yarn lint (0 errors), yarn typecheck, yarn test (4,263 tests) and yarn build.

The pre-push review's findings are folded into bf34aec, with tests:

The agent's price line now uses the card's rule too: a sale price only under the price, never 0.

🤖 Generated with Claude Code

cihan-gyk and others added 26 commits October 27, 2026 12:56
…m issues (00296, ansvisor#1270 part 1)

A Merchant Center account becomes a catalog source, read with the
workspace's own Google sign-in through Composio (like Search Console and
Analytics), so the token never reaches us. Calls go to the Merchant API v1
through Composio's proxy.

- Connector merchant_center: lists the accounts the sign-in opens (plus an
  advanced account's sub-accounts), checks the picked one, reads every
  product page (1,000 a page) into the feed parsers' item shape (price from
  micros, first GTIN, availability and condition enums), keeps an offer
  listed again under another language or feed label once, and returns each
  product's item-level issues. syncOrders is a no-op.
- 00296 catalog_item_issues: code, severity, attribute, reporting context,
  description per item; replaced each sync, removed with the source;
  members read, the server writes.
- Plumbing: sign-in connectors (signIn instead of fields/connect),
  lib/catalog/sign-in.js (proxy request with 429/5xx waits, 'auth' when
  the sign-in is gone or refused), issue counts on last_counts, plain
  "Reconnect it in Settings › Integrations" words.
- API: GET /api/catalog/accounts, POST /sources with input.account,
  signIns in GET /connectors, googleMerchantCenter in /integrations/config.
- Tests with fixtures: paged list, items with and without issues, expired
  and refused sign-in, 429 wait, account picker, not set up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…account in Settings › Integrations (ansvisor#1270 part 2)

- Settings › Integrations gets a "Stores and marketplaces" group: a Google
  Merchant Center card that connects the workspace's Google sign-in like
  Search Console and Analytics, then lets the active brand pick one of the
  accounts it opens (GET /api/catalog/accounts) and add it as a catalog
  source.
- Product catalog names the account "Google Merchant Center · Name (id)"
  and its row reads "N products · M with issues · synced …"; no sign-in
  button for it (the sign-in is the workspace's). The card reads its
  sources again when an account is added above.
- The Shopping page's My Products tab links to Settings › Integrations to
  bring in the catalog.
- catalog-client: signIns in listStoreConnectors, listSignInAccounts,
  connectSignInAccount, not_connected; CatalogCounts.issues;
  IntegrationProvider 'google-merchant-center'. Words in en.json.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…and keep repeated offers' issues (ansvisor#1270 review)

- sign-in.js: Composio's own 401/403 and Google's 403 are not_set_up, not
  auth; each refusal is logged by name, status and Google's reason; only
  the connector's hosts (merchantapi.googleapis.com) are reached.
- An offer listed again under another language or feed label is counted
  on its own (last_counts.repeated), its issues gathered from every listing,
  and the kept one chosen by a fixed rule (no DISAPPROVED issue, then feed
  label, then content language).
- Account listing and connecting share a 30 s deadline; the sub-account
  walk stops on a rate limit; a catalog cut at the page limit says so.
- entityIdFor moves to composio.js. Tests for paging, deadlines, limits,
  the proxy helper and the refusal codes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… integrations by kind, and say what the catalog is for (ansvisor#1270 review)

- The picked account belongs to the brand it was picked for: switching
  brands clears it, an add goes to the brand clicked for, one add at once.
  Accounts already added are marked and can't be picked; a failed list read
  offers Try again; members get their own line.
- Integrations' group headings are h3 headings; Webflow moves to a
  "Content management systems" group (IntegrationGroup).
- Shopping › My Products' catalog note says what the catalog does (the
  editor's product-page checks), only while the brand has no source.
- "1 with an issue"; a fixed platform name before /connectors is read;
  stores.errors.not_connected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eated offers, and note advanced accounts (ansvisor#1270 review)

- settings.merchantCenter.errors.not_configured says who fixes it (the
  server's set-up, or the Google account's access), with Try again.
- A source's line shows "N listed again, kept once" (last_counts.repeated).
- With several accounts, a note says an advanced account holds no products:
  pick the store's own sub-account.
- Every StoreError has a message (checked at typecheck); the Shopping note
  is _catalog-note.tsx.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… site (00350, shopping path part 1)

The shopping path links a buying guide or a comparison to the category's own
page, so each catalog category is matched, on every read, to one of the
brand's site pages whose address reads as a category page (the editor's
page-type rule: /collections/, /category/, /c/, /shop/, WooCommerce's
/product-category/; never a product page or a themed collection). Best
match: the last path segment is the category's name, then the title or h1
holds it, then most of its words; ties go to the more cited, then visited
page.

- 00350: catalog_category_pages keeps a person's decision (a page, or none)
  by category name; catalog_category_counts(brand) gives live products and
  how many are in stock (service role only).
- lib/catalog/category-pages.js: categorySlug, matchCategoryPages,
  categoryPages(brandId), setCategoryPage (page must be on the brand's
  domains).
- API: GET /api/catalog/categories (members), PUT and DELETE (admins and
  managers).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rations and let admins change it (shopping path part 1)

- Category pages, under the product catalog in Stores and marketplaces:
  each category of the active brand with its products and how many are
  in stock, its page on the site, and how it was found (its address or
  title names the category, most of its words, set by hand). Shown once
  the catalog has categories.
- Admins and managers change a page (it must be on the brand's site), set
  none, or put a hand-set one back to the automatic match; members see
  the table.
- catalog-client: listCategoryPages, setCategoryPage, resetCategoryPage;
  words in settings.catalog.categories.
- The API calls a person's decision 'manual' whether it's a page or none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…(00351, shopping path part 2)

On an online shop, a buying guide, a best-of list or a comparison links the
right category page and products in stock that Merchant Center accepts. The
API picks them for the draft's topic and keeps them on the draft:

- Topic: the title's words count 3, the brief's keywords 2, its goal and
  headings 1.
- Categories: with a page on the site (00350) and stock, the best first,
  a second only when it scores half the first's (2 at most).
- Products: the picked categories' first, then the brand's (2,000 scored,
  the best 40 read in full); offered when they have a link, a variant in
  stock and Merchant Center doesn't refuse that variant; the cheapest such
  variant's price, and its non-refusing issues (e.g. missing GTIN). How
  many by page type: best-of 8, buying guide 5, comparison and
  alternatives 4, guide 4, blog post 3. The best left out are kept with
  why (sold out, refused, no link).
- The person's choices survive a rebuild: locked and added products stay
  (counted in the page's number), removed ones never come back.
- 00351 content_drafts.shopping_path jsonb (64 KB at most); members edit
  it like the brief.
- POST /api/content-drafts/:draftId/shopping-path { brandId }: { path },
  or { path: null, reason } ('not_a_shop', 'page_type', 'no_catalog').

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s Brief tab (shopping path part 3)

Brief › Shopping path, above the brief, for a page type that links products
(best-of, buying guide, comparison, alternatives, guide, blog post) on an
e-commerce brand:

- Pick from the catalog the first time (POST /:draftId/shopping-path), Pick
  again after; why a draft takes none (not a shop, page type, no catalog).
- The category page with where it goes (in the intro and at the end).
- Each product with its price (sale price first, en-US in its currency),
  In stock or Low stock, its Merchant Center issues, and its place by page
  type (Top picks #n, Compared #n, linked in the text).
- Lock (kept when picked again or rewritten), Remove (saved at once),
  Swap (removed, then picked again for the next best), Add product (search
  the catalog's names, then picked again with it kept).
- The best products left out, with why (sold out, Merchant Center refuses
  it, no page to link).
- actions/shopping-path.ts: read and save through RLS like the brief,
  build through the API, search the catalog. lib/content/shopping-path.ts:
  the path's schema, which pages take one, places, changes. Words in
  contentEditor.editor.shopping; shopping_path in types/supabase.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ts only (shopping path part 4)

The Content Agent now writes with the draft's shopping path:

- A new page: the writer is told the category page (name it in the
  opening, point to it again at the end) and the products in order with
  the catalog's price and stock only, never another spec (a placeholder
  instead). It writes text, so the names it wrote are linked afterwards
  (shopping-links.js linkShoppingPath): each target the first time a
  paragraph or a list item names it, never in a heading or inside a link;
  products first, longest names first; a category's last word singular or
  plural too.
- A page it changes (rewrite from brief, suggestions, rule fixes): the
  path's pages join the pages it may link to, first in the prompt whatever
  the rules, and in the allow list (anything else is still unwrapped).
- The path's names and prices are given to the number and people guards,
  so the catalog's price isn't turned into a placeholder.
- content-links.js: linkTargetsPrompt and linkAllowList read
  targets.shopping; startDraftWriting and fixDraftRules read
  shopping_path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… hand or with the agent (shopping path part 5)

- + Insert › Products (the toolbar and the empty-line menu), on an online
  shop's draft: search the catalog by name, pick 1 to 4, Insert. One shows
  as a card, more as a grid: each product's picture, name and price (its
  cheapest variant in stock, sale price first), linked to its page. An HTML
  block with inline styles and no words of its own, so every export and
  CMS shows it as written, in any language.
- The agent's new page on a list, a buying guide or a comparison with two
  products or more gets the same grid from its shopping path, at the end of
  the section that links the products most (else before the last H2, else
  at the end).
- The markup is written twice, web (lib/content/product-block.ts) and
  server (lib/shopping-blocks.js); both tests expect the same string.
- actions/shopping-path.ts getProductsForBlock reads products, variants
  and images through RLS; catalog_images added to types/supabase.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s own rule (shopping path part 1 review)

- A malformed % in a page address no longer breaks the read.
- Pages and categories are prepared once, with a word index; site_pages
  isn't read when nothing can match.
- GET uses the general limiter; PUT/DELETE get their own bucket.
- The category-page rule is the editor's (page-types.ts), checked on both
  sides by one fixture list; /blog/category/ and pages marked first
  (best-of, size guides, -vs-, policies) aren't category pages.
- Parent words count; a one-word category matches by address only.
- Turkish and German letters fold (lib/letters.js, shared with Webflow).
- The table is read again when sources change; editing resets per brand.
- catalog_category_counts counts the web's four in-stock values.
- PUT refuses a category the catalog doesn't have; messages fit the routes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…talog row, with one stock rule (shopping path part 2 review)

- Locked and added products are read by id from the brand's own catalog,
  always kept; a removed or unknown one is left out as 'gone'.
- Every read is chunked and paged past PostgREST's 1,000-row cap.
- The route has its own bucket (shoppingPathLimiter); descriptions are cut
  to 400 characters once read.
- More stop words and years, letters folded as category pages do, and
  'no_match' when nothing fits.
- A refusal counts only for free listings or an empty context.
- One stock list (catalog/stock.js), the same as feed-match.ts and 00350.
- The saved path is read through Zod; a bad one is taken as none and
  logged. Writes are capped to 64 KB and conditional on builtAt/savedAt
  (409 'changed').

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The table was 640 px wide in a 417 px card at 1024 px. The Change buttons
sat out of sight, and the header's screen-reader label, outside the
scroll box, scrolled the whole page sideways.

- How a page was found is now a line under it, so four columns fit.
- While a category is being changed, its form takes the button's cell
  as well.
- The scroll box contains its label (`relative`).
- Addresses wrap only where they must ([overflow-wrap:anywhere]).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… new path shape (shopping path part 3 review)

- The schema takes the API's shape: 'gone' and a missing title for a
  product left out, 'no_match', savedAt, availability in lowercase with
  underscores, and the same caps as the server. A reason it doesn't
  know reads as a general line instead of failing.
- A change is saved before the path is picked again, so a failed pick
  (429, 502) doesn't lose it.
- A save writes only locked, removed and added, and only over the path
  that was read (builtAt and savedAt). Otherwise it answers 'changed' and
  the tab reads the path again. A build's 409 'changed' and 429 have
  their own lines.
- An unreadable saved path, 'no_match' or an unknown reason offers "Pick
  from the catalog".
- Links must be http(s); others show without a link.
- The search has its own error; the Lock button has a fixed name with
  aria-pressed.
- Removed: the unused fromCatalog string.
- Rows are keyed by their place and name; the category path wraps with
  [overflow-wrap:anywhere].

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the catalog and the brand's site give them (shopping path part 4 review)

- shoppingPathFor reads the path once per run through readShoppingPath. A
  bad shape counts as no path and is logged; the run goes on.
- Prices pass in their usual forms ($189, 189 USD, ₺1.299,00), with the
  sign matching the currency; any other price becomes a placeholder.
- Stock is read fresh from catalog_variants at write time and named
  through stock.js. Unknown stock says nothing.
- Links: https and the brand's own domains only (brandSite, shared with
  category pages).
- Product names match case-sensitively and category names don't. Letters
  are folded, and singulars come from category pages.
- The fix path guards prices and names too.
- A name or address is used once. A product name's numbers are free only
  where the name stands.
- The prompt takes as many products as the page type links, 40 at most,
  locked and added ones kept.

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

# Conflicts:
#	server/src/lib/content-writer.js
…he grid as a list (shopping path part 5 review)

- The agent's grid takes only products in stock, counted after the
  filter, with the price and stock read fresh by shoppingPathFor.
- Insert › Products:
  - A product is offered only when it's in stock and has an https page.
    Search hits show the price, or "Sold out" or "No page to link", and
    can't be picked when they're out.
  - At insert, a product sold out meanwhile is left out with a toast.
  - Each product's variants and image are read on their own: no shared
    row cap; an image with no variant first.
  - The cheapest variant in stock is picked by sale_price ?? price, with
    one stock reading shared with feed-match.ts (variantStock).
  - Cancel or Esc while inserting inserts nothing.
  - The search has its own error; picks survive a new search and can be
    taken back; Insert shows it's working; the count is aria-live.
- The markup has spaces and line breaks, so text exports read each
  product apart. Webflow gets the grid as a <ul> list. Links are https,
  without tracking or a hash, the same on both sides (a shared
  fixture). A price of 0 is none; a sale price counts only under the
  price, for the agent's price line too.
- The grid goes before the last H2 when no section links the products.
- Tests for the writer's grid, getProductsForBlock and the toolbar's
  Products button. Docs: Insert › Products in the Content Editor guide.

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

mintlify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 15f00b2.

Approve preview

@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 27, 2026
@github-actions github-actions Bot removed the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 27, 2026
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

Merged main forward (15f00b2) now that #1588, #1591 and #1592 are squashed. The conflicts were #1592's final price read against this PR's own variant pick in shopping-links.js: #1592's withOffer stays as you left it (price and stock from one variant), and this PR's pricedVariant/sellsAt/variantsOf are gone. Only amountOf's rule stays: a 0 price is none, and a sale price counts only below the price. The description says so. Server 3,338 tests and web 4,364 tests + build pass on the top of the chain.

@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.

Needs changes.

What this PR's own change is. The commits after the part 4 head it merged (96e6194): 09e2328, 63384c7 (the merge of 96e6194; its one conflict, in content-writer.js, is resolved correctly: the grid now takes the checked shoppingPath), bf34aec and 22d4d74. That comes to 28 files, +1746/−70.

It doesn't apply on main. #1592 was squashed from a later head, ad2f900 ("write a product's price as the catalog has it now, with its stock"), and this branch doesn't have that commit. Replayed on current main, its own diff conflicts in five files:

  1. server/src/lib/shopping-links.js. This is a real conflict, not just text. Main's withOffer and this PR's withStock + pricedVariant both re-read the price at write time, but they pick a different variant:

    • main takes the price from the variant whose stock it reports (best stock first, then the lowest price at that stock);
    • this PR takes the cheapest in-stock variant, or with none in stock, the cheapest of all.

    Keep main's withOffer, since the price and the stock then come from the same variant, and drop pricedVariant. Keep this PR's amountOf change (a price of 0 is no price; a sale price counts only when it's below the price). Move the 0-price and sale-above-price cases into main's tests.

  2. server/src/lib/shopping-links.test.js, content-writer.test.js and content-agent.test.js. The variant fixtures conflict. Keep main's rows and add sale_price where a test needs it.

  3. docs/guides/content-editor.mdx. Main's Send to CMS line now mentions Webflow. Keep that line and add the Products line before it.

After the rebase, rerun the server suite. The code itself is in good shape, and the items below are follow-ups.

Checked

  • Escaping. Names, URLs and image addresses from the catalog are escaped in every text and attribute position, on both sides (product-block.ts, shopping-blocks.js):

    • links are https only, with tracking parameters and the hash removed;
    • images are https only;
    • the shared fixture covers a quoted name and a javascript: URL.

    Dropping the escape, or allowing http, makes the tests fail.

  • Reads. The reads go through RLS, and products are filtered by brand.

  • Stock at insert. A product that sold out since it was picked is left out, and Cancel during Insert inserts nothing. Both are covered by failing-without-the-change tests.

  • Agent grid. It holds only in-stock products, needs at least two, and appears only on new pages (not rewrites). The stored block matches the format extractKeptBlocks accepts.

  • Webflow. Send to Webflow turns the grid into a list.

Follow-ups

  1. One price rule on both sides. The web's blockVariant treats in-stock and low-stock variants the same and takes the cheapest. Main's server rule prefers in stock first. So a product with an in-stock $199 variant and a low-stock $149 variant shows $149 in a card inserted by hand and $199 in the agent's grid. Use the same rule in shopping-path.ts as on the server.
  2. Grid placement test. The tests still pass when the grid always goes before the last H2, or into the first section that links any product. That's because the most-linked section in the test page is always the one just before the FAQ. Add a page where the section that links the most products comes earlier.
  3. "Sold out" for unknown stock. A product whose variants are pre-order, back-order, or have no availability shows "Sold out" in the dialog. "Not in stock" (or a separate "No stock given") would be accurate.

Before the API deploy. Insert › Products works as soon as the web ships, because it reads the catalog tables directly. The agent's grid and the grid-as-list for Webflow come with the API. Until then, a page with a grid sent to Webflow arrives as one paragraph with the product links side by side.

@gkhngyk
gkhngyk merged commit 13b3ff7 into ansvisor:main Oct 27, 2026
6 checks passed
@gkhngyk

gkhngyk commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Correction to the review above: that was the earlier draft, written before 15f00b2. As merged, this looks good. The main merge resolves #1592's final price read as asked: withOffer stays (price and stock from one variant), and only amountOf's rule comes in (a 0 price is none; a sale price counts only below the price).

Checked: catalog names, URLs and images are escaped everywhere and linked https only; a product sold out since it was picked is left out at Insert; the agent's grid takes in-stock products only, two at least, on new pages only. The tests fail with each of those broken.

Follow-ups (low):

  • A test for "the section that links the most products": the grid's placement passes today if it always goes before the last H2.
  • The dialog and the agent pick a card's price differently (the lowest in-stock price vs. the best stock's): a product with an in-stock $199 variant and a low-stock $149 one shows $149 by hand and $199 from the agent.
  • Pre-order, back-order and unknown availability all read "Sold out" in the dialog.
  • amountOf drops a sale price when there's no regular price.

Before the API deploy: Insert › Products works on merge; the agent's grid and the Webflow list need the API (a hand-inserted grid sent to Webflow arrives as one paragraph of links until then).

cihan-gyk added a commit to cihan-gyk/ansvisor that referenced this pull request Oct 27, 2026
…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]>
cihan-gyk added a commit to cihan-gyk/ansvisor that referenced this pull request Oct 28, 2026
Main's product blocks (ansvisor#1607) are a grid of linked cards; Framer's formatted
text has no grid, so the cards ran together in one paragraph. They now go as
Webflow's do (productsAsList): a list, a product an item, its name linked and
its price after it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
gkhngyk pushed a commit that referenced this pull request Oct 28, 2026
…linked section isn't the last (#1653)

Follow-up from #1607 (item 2). The grid goes at the end of the H2 section
that links the path's products most. In the tests that section was always
the one before the FAQ, so the tests still passed if the grid always went
before the last H2, or after the first section that links any product.

A page now links one product before the most-linked section and one after
it, with a section and the FAQ last; and two sections that link them as
often take the first. Each of these breaks the new test: the grid before
the last H2 always, after the first section that links any, and the later
of two on a tie.

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
gkhngyk pushed a commit that referenced this pull request Oct 28, 2026
…t stock, then its lowest price there (#1663)

Follow-ups from #1607 (items 1 and 4).

One variant rule. The agent's grid and what the agent is told
(shopping-links.js withOffer) take the price of the best stock first, in
stock before low stock, then the lowest price there. The path's offer
(shopping-path.js offerOf) and a card put in by hand (getProductsForBlock)
took the cheapest variant in stock whatever its stock, so a product with an
in-stock $199 variant and a low-stock $149 one showed $149 by hand and $199
from the agent. All three now pick with one rule: bestInStock in the new
server/src/lib/catalog/offer.js, mirrored in web/src/lib/content/
shopping-path.ts.

A sale price alone. A variant with a sale price and no price showed no
price at all. priceAmount (the same two files) now takes the sale price
when there's no price; a price of 0 is still none, and a sale price above
the price still isn't a sale. The server's card text (shopping-blocks.js
priceText), the agent's offer line and price spellings, and the editor's
priceText all read it.

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 28, 2026
…log in Before you publish (#1664)

* fix(content): show a catalog product at one price everywhere: its best stock, then its lowest price there

Follow-ups from #1607 (items 1 and 4).

One variant rule. The agent's grid and what the agent is told
(shopping-links.js withOffer) take the price of the best stock first, in
stock before low stock, then the lowest price there. The path's offer
(shopping-path.js offerOf) and a card put in by hand (getProductsForBlock)
took the cheapest variant in stock whatever its stock, so a product with an
in-stock $199 variant and a low-stock $149 one showed $149 by hand and $199
from the agent. All three now pick with one rule: bestInStock in the new
server/src/lib/catalog/offer.js, mirrored in web/src/lib/content/
shopping-path.ts.

A sale price alone. A variant with a sale price and no price showed no
price at all. priceAmount (the same two files) now takes the sale price
when there's no price; a price of 0 is still none, and a sale price above
the price still isn't a sale. The server's card text (shopping-blocks.js
priceText), the agent's offer line and price spellings, and the editor's
priceText all read it.

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

* feat(content): name the product cards whose price changed in the catalog in Before you publish

Follow-up from #1610 (item 4). A product card's price is written when it
goes in, by hand or in the agent's grid, and stays. Before you publish
checked the stock and refusals of the products a page links, not the
prices its cards show.

- getShoppingCheck reads each product's price now, as a card would show
  it: its best stock's variant (bestInStock), priceText.
- readPage collects the product cards in the page's HTML blocks, each with
  the price it shows (the editor's own card markup, product-block.ts).
- shoppingLinks compares them: a card of a product that sells whose price
  isn't the catalog's now, each product once (`prices`). A card without a
  price, a product that no longer sells (listed to remove already) or one
  whose price wasn't read is left alone.
- Before you publish shows a row of its own beside Shopping links: "2
  product cards show an old price", each with the page's price and the
  price now ("no price" when the catalog has none), and to put the product
  in again to show today's.

priceText moves to lib/content/shopping-path.ts so the server action can
use it; _shopping-path.tsx re-exports it. Stacked on
fix/shopping-one-price-rule: the price now is that branch's rule.

Only the products the shopping path checks are compared: a card put in by
hand of a product outside the path isn't read here.

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

* fix(content): tell a person to replace a card with an old price, through Add › Products

Before you publish's old-price line said to put the product in again
through "Insert › Products", but the menu is Add › Products, and it
didn't say to delete the old card: the check lists every card whose price
doesn't match, so a card left in place keeps the warning. It now reads
"To show today's, replace the card: delete it and add the product again
(Add › Products)." The editor guide says the same.

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

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 28, 2026
…nt in stock, not "sold out" (#1662)

Follow-ups from #1610 (item 2) and #1607 (item 3). A product is taken as
not selling when none of its variants is in stock: sold out, but also
pre-order, back-order and no stock given. The editor called all of them
"sold out": the Insert › Products dialog, the shopping path's Left out
list, the Rules tab's and Before you publish's Shopping rule and its
items, and the note that Content Agent doesn't change product links.
They now say "not in stock" ("No out-of-stock or refused product linked"
for the rule). The API's `sold_out` reason and state stay as they are;
the product dialog's message key is renamed to notInStock to match.

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 28, 2026
…d from every way to add a brand, while the plan has ended (#1612)

* feat(web): let a workspace whose plan ended browse read-only, with one "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]>

* feat(web): open the plan dialog from the Prompts area's actions while 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]>

* feat(web): open the plan dialog from the content area's actions, and 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]>

* feat(web): open the plan dialog from the remaining areas' actions, and 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 (#1606) and Content (#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]>

* fix(web): keep removing members, revoking invitations and disconnecting 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]>

* fix(web): open the plan dialog from Add Brand at the plan's brand limit 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]>

* feat(web): let a read-only workspace delete a brand

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 #1611.

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

* fix(web): leave the plan dialog's store error out of the every-code message test

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

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

* fix(web): open the plan dialog from Merchant Center, category pages and main's other new actions while the plan has ended

main's new writes, with C3's guard pattern and labels:
- Merchant Center (#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 (#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 (#1591): Pick from the catalog, Pick again, Add
  product, Lock, Swap and Remove are guarded.
- Action Center Check now (AC-010, #1565) is guarded.

New labels: changeCategoryPages, changeShoppingPath, checkTasks.
Insert › Products (#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 (#1610) change through the rules hook, already guarded.

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

* fix(web): check the plan inside Merchant Center's Add, not by wrapping 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]>

* test(web): keep brand setup's limits in the new brand page test's mock

main's new brand page now reads BRAND_SETUP_LIMITS from ai-brand-setup
(#1661), which the test's mock left out.

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

* fix(web): keep deleting a chat open on a read-only workspace

The API (#1613) leaves deleting a conversation open and the FAQ (#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]>

* test(web): delete a chat conversation on a read-only workspace through 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.

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 28, 2026
… plan has ended, and keep the buttons opening the plan dialog (#1614)

* feat(web): let a workspace whose plan ended browse read-only, with one "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]>

* feat(web): open the plan dialog from the Prompts area's actions while 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]>

* feat(web): open the plan dialog from the content area's actions, and 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]>

* feat(web): open the plan dialog from the remaining areas' actions, and 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 (#1606) and Content (#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]>

* fix(web): keep removing members, revoking invitations and disconnecting 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]>

* fix(web): open the plan dialog from Add Brand at the plan's brand limit 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]>

* feat(web): let a read-only workspace delete a brand

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 #1611.

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

* 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

With #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]>

* fix(web): keep a saved content suggestion reachable, the Starter bot 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]>

* fix(web): leave the plan dialog's store error out of the every-code message test

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

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

* fix(web): open the plan dialog from Merchant Center, category pages and main's other new actions while the plan has ended

main's new writes, with C3's guard pattern and labels:
- Merchant Center (#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 (#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 (#1591): Pick from the catalog, Pick again, Add
  product, Lock, Swap and Remove are guarded.
- Action Center Check now (AC-010, #1565) is guarded.

New labels: changeCategoryPages, changeShoppingPath, checkTasks.
Insert › Products (#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 (#1610) change through the rules hook, already guarded.

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

* fix(web): check the plan inside Merchant Center's Add, not by wrapping 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]>

* test(web): keep brand setup's limits in the new brand page test's mock

main's new brand page now reads BRAND_SETUP_LIMITS from ai-brand-setup
(#1661), which the test's mock left out.

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

* fix(web): keep deleting a chat open on a read-only workspace

The API (#1613) leaves deleting a conversation open and the FAQ (#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]>

* test(web): delete a chat conversation on a read-only workspace through 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(onboarding): mock the menu access actions in the onboarding page 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.

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 28, 2026
…1331) (#1576)

* feat(cms): connect a brand's WordPress site with an Application Password and send pages to it as draft posts (#1331)

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

* feat(cms): mark a page published once its WordPress post is put live, read when the Library opens and daily (#1331)

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

* chore(server): run the API on Node 24

Node 20 is end of life since 2026-04-30, and Framer's official Server API
package (framer-api, for Send to CMS #1331) needs Node 22 or later for its
global WebSocket. Node 24 is LTS until April 2028. The Dockerfile, CI's
server job and the server README move to 24; the web job stays on 20.

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

* feat(cms): connect a brand's Framer project for Send to CMS (#1331)

Framer's official Server API (framer-api, needs Node 22+): a brand's
project connects with an API key made in it, sealed as WordPress's
sign-in is. 00295 adds provider 'framer' (site_id = project id) and the
'framer' delivery target, and reserve_content_deliveries keeps one queued
send per page for it too. Routes check the project, list the user's own
collections with their fields, save the collection and field map (title
to text, page to formatted text, required fields refused as for Webflow)
and disconnect (Framer has no API to revoke a key).

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

* feat(cms): send pages to a brand's Framer collection as draft items (#1331)

writeItem adds a draft item (draft: true) or updates the one the page's
last Framer send made in that collection, keeping its state; the new id is
read back by slug among new items, a clashing slug stops the send, and a
draft with the page's slug and title left by a send that broke halfway is
taken back. framer-items.js keeps tables (Framer's rich text has them),
leaves media out and counts it, and maps title, page, meta and JSON-LD to
the brand's fields. content-delivery.js gains the 'framer' target.

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

* fix(cms): let a brand's WordPress site be disconnected while the plan has ended

Since #1589 a workspace whose plan has ended can't write, but taking back an
outside account's access stays open (COST_STOPPING), as Webflow's disconnect
does. WordPress's disconnect revokes the Application Password where the site
allows, so it joins the list.

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

* fix(cms): let a brand's Framer project be disconnected while the plan has ended

Since #1589 a workspace whose plan has ended can't write, but taking back an
outside account's access stays open (COST_STOPPING), as Webflow's and
WordPress's disconnects do. Framer's disconnect deletes the project's API
key, so it joins the list.

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

* fix(cms): send a product card or grid to Framer as a list, as to Webflow

Main's product blocks (#1607) are a grid of linked cards; Framer's formatted
text has no grid, so the cards ran together in one paragraph. They now go as
Webflow's do (productsAsList): a list, a product an item, its name linked and
its price after it.

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

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 28, 2026
…site (#1331) (#1579)

* feat(cms): connect a brand's WordPress site with an Application Password and send pages to it as draft posts (#1331)

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

* feat(cms): mark a page published once its WordPress post is put live, read when the Library opens and daily (#1331)

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

* chore(server): run the API on Node 24

Node 20 is end of life since 2026-04-30, and Framer's official Server API
package (framer-api, for Send to CMS #1331) needs Node 22 or later for its
global WebSocket. Node 24 is LTS until April 2028. The Dockerfile, CI's
server job and the server README move to 24; the web job stays on 20.

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

* feat(cms): connect a brand's Framer project for Send to CMS (#1331)

Framer's official Server API (framer-api, needs Node 22+): a brand's
project connects with an API key made in it, sealed as WordPress's
sign-in is. 00295 adds provider 'framer' (site_id = project id) and the
'framer' delivery target, and reserve_content_deliveries keeps one queued
send per page for it too. Routes check the project, list the user's own
collections with their fields, save the collection and field map (title
to text, page to formatted text, required fields refused as for Webflow)
and disconnect (Framer has no API to revoke a key).

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

* feat(cms): send pages to a brand's Framer collection as draft items (#1331)

writeItem adds a draft item (draft: true) or updates the one the page's
last Framer send made in that collection, keeping its state; the new id is
read back by slug among new items, a clashing slug stops the send, and a
draft with the page's slug and title left by a send that broke halfway is
taken back. framer-items.js keeps tables (Framer's rich text has them),
leaves media out and counts it, and maps title, page, meta and JSON-LD to
the brand's fields. content-delivery.js gains the 'framer' target.

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

* feat(cms): mark a page published once its Framer item is live on the site (#1331)

framer-status.js reads each page's latest Framer send (Library open and a
daily sweep): an item out of draft, with a production publish after the
send and after the item's last change, is published at the site's address
plus the collection page's path with its slug; an item gone closes its
send as "Removed in Framer". readPublished reads items, the publish and
the detail page over one connection. POST /api/content-drafts/framer-status.

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

* fix(cms): let a brand's WordPress site be disconnected while the plan has ended

Since #1589 a workspace whose plan has ended can't write, but taking back an
outside account's access stays open (COST_STOPPING), as Webflow's disconnect
does. WordPress's disconnect revokes the Application Password where the site
allows, so it joins the list.

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

* fix(cms): let a brand's Framer project be disconnected while the plan has ended

Since #1589 a workspace whose plan has ended can't write, but taking back an
outside account's access stays open (COST_STOPPING), as Webflow's and
WordPress's disconnects do. Framer's disconnect deletes the project's API
key, so it joins the list.

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

* fix(cms): send a product card or grid to Framer as a list, as to Webflow

Main's product blocks (#1607) are a grid of linked cards; Framer's formatted
text has no grid, so the cards ran together in one paragraph. They now go as
Webflow's do (productsAsList): a list, a product an item, its name linked and
its price after it.

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

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 29, 2026
…ying or a free trial (demo brand, part 5) (#1738)

* feat(web): let a workspace whose plan ended browse read-only, with one "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]>

* feat(billing): show the plans in the read-only dialog, with Monthly or Annual and a promo code

The "Choose a plan to keep going" dialog for an ended plan now carries
the plans, as the approved design has them.
- Starter and Growth (Popular) have "Choose {plan}"; Custom has "Starting
  at $499/mo" and "Contact us". Each lists the Billing cards' features,
  through a shared usePlanFeatures.
- Monthly or Annual ("Save 20%"): an annual price shows its struck 12×
  price and what it is a month.
- A promo code is checked by the API (POST /api/stripe/promo-code, admins
  only), through the same Stripe lookup #1300 uses (findPromotionCode,
  takesPromoCode: monthly plans only).
  - A valid code shows its chip, the first month's price on each card and
    in the button ("Choose Growth · $124.50 today").
  - A bad one says so; on Annual a note offers Switch to Monthly.
- Choose opens Stripe Checkout for that plan and period, with the code
  applied as a discount. The checkout route checks the code again and
  refuses it on an annual plan.
- Members see "Ask your admin to choose a plan", with no code field.
- The footer reads "Prices in USD." with a link to the pricing page.
- A failed payment keeps its "Update payment method" dialog.

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

* fix(billing): word the dialog's custom AI usage "from 10x", as Billing does after #1598

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

* feat(web): open the plan dialog from the Prompts area's actions while 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]>

* feat(web): open the plan dialog from the content area's actions, and 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]>

* feat(web): open the plan dialog from the remaining areas' actions, and 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 (#1606) and Content (#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]>

* feat(web): refuse direct database writes from a workspace whose plan has ended, on the server

Server actions and Next routes that write to Supabase without going
through the API now call assertWritable() first: on the cloud, an
organization without an active plan gets SubscriptionInactiveError
(routes: 402 subscription_inactive), so the read-only rule holds even if
a guarded button is bypassed. Setup's writes stay open to an
organization that never subscribed, as the API's onboarding routes do.
Profile, invitations accepted, revokes, removals, API keys and billing
stay open. A static test pins every writing action to the check or to
the open list.

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

* fix(web): keep removing members, revoking invitations and disconnecting 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]>

* fix(web): open the plan dialog from Add Brand at the plan's brand limit 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]>

* feat(web): let a read-only workspace delete a brand

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 #1611.

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

* fix(web): keep setup's Shopping mode working for a new workspace, read the plan in one query, and pin the write check's place

From the pre-push review: markBrandAsEcommerce no longer goes through
the strictly guarded setBrandShoppingMode (a shared applyShoppingMode
does the writes), so a setup detected as e-commerce turns Shopping on
again. assertWritable reads the profile and its organization in one
query. The coverage test now requires the check as each writer's first
await, sees writers kept in variables and signed upload URLs, refuses a
setup-open function that reaches a strictly guarded one, and keeps brand
deletion open (Ansvisor, 2026-10-27). main's saveDraftShoppingPath is
guarded; catalog-client's every-code test leaves out 'subscription',
which opens the plan dialog instead of a message.

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

* 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

With #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]>

* fix(web): keep a saved content suggestion reachable, the Starter bot 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]>

* fix(web): leave the plan dialog's store error out of the every-code message test

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

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

* fix(web): open the plan dialog from Merchant Center, category pages and main's other new actions while the plan has ended

main's new writes, with C3's guard pattern and labels:
- Merchant Center (#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 (#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 (#1591): Pick from the catalog, Pick again, Add
  product, Lock, Swap and Remove are guarded.
- Action Center Check now (AC-010, #1565) is guarded.

New labels: changeCategoryPages, changeShoppingPath, checkTasks.
Insert › Products (#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 (#1610) change through the rules hook, already guarded.

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

* fix(web): check the plan inside Merchant Center's Add, not by wrapping 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]>

* test(web): keep brand setup's limits in the new brand page test's mock

main's new brand page now reads BRAND_SETUP_LIMITS from ai-brand-setup
(#1661), which the test's mock left out.

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

* feat(demo): open the plan dialog with the demo's offer on a demo brand

The selected brand being the organization's demo brand (brands.is_demo,
sample data) locks the dashboard as a read-only workspace is locked, with
its own reason: guarded actions open the plan dialog with the demo's offer.
A workspace that never subscribed is offered the free trial, then 50% off
("Start free trial"); one whose plan ended gets 50% off its first month
("Choose {plan}"). The label names what was clicked as something that
works on your own brand, and an admin finds SAVE50 applied (quietly left
empty when Stripe refuses it). With a plan active, the dialog points back
to the workspace's own brand; a payment being retried still asks for the
payment method. The server's 402 demo_brand opens the same dialog.

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

* feat(demo): show a band across the dashboard while the demo brand is open

Where the read-only band sits, and instead of it: "You're exploring
{brand}, a demo brand with sample data", with a small button to the plan
dialog's offer ("Try it on your brand · 50% off" for a workspace that never
subscribed, "Use it for your brand · 50% off" once its plan ended), or back
to the own brand while a plan is active. The band asks the API once per page
load to bring the demo brand up to date (POST /api/demo) and reads the
pages again when its sample data was written anew, so the demo follows the
product by itself.

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

* feat(demo): add a demo brand per organization, kept out of the plan's counts

Migration 00380 adds brands.is_demo, demo_version, demo_built_at and
demo_hidden_at, one demo brand per organization (partial unique index) and
policies that let members read it but never insert, change or delete one.
The plan's prompt-location quota, the usage cards' account totals and the
web's brand limit leave the demo brand out; the health report's fan-out
share leaves out its answers. The brand delete route refuses it: the demo
brand is hidden, not deleted.

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

* feat(demo): skip demo brands in every nightly sweep and job

The daily tracking list, the job claim and recovery (activeBrandFilter /
isBrandActive), the signal catch-up, the pulse, the task writer, executor
and checks, action validation and Improve outcomes, the Insights sweep,
brand facts, Search Console and Analytics syncs, page opportunities, the
traffic digest, auto-audits, catalog feeds, Webflow status and volume
analysis all leave demo brands out: their data is sample data and nothing
may track, write or spend for it.

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

* feat(demo): mark the demo brand in the brand switcher, with Show or Hide

The demo brand reads "Demo · sample data" under its name, in place of a
domain, and a brand of a workspace that never had a plan reads "Not tracked
yet". For an admin or a manager, the menu ends with "Hide the demo brand"
(PATCH /api/demo), or "Show the demo brand" once it is hidden, which brings
it back and opens it: the demo brand is hidden after a purchase, never
deleted. A hidden demo brand stays out of the dashboard's brand list and
the brands page, and the demo brand never counts toward the plan's brands,
there or when a brand is added.

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

* feat(demo): show Chat as coming next week on the demo brand, with its v2 preview

On the demo brand, the menu's Chat item carries "Soon (next week)" in its
badge, ahead of "Set up" (the badge rule now lives in dashboardNavBadge, for
the sidebar and the mobile menu alike), and /dashboard/agent shows the Chat
v2 mockups themselves in a full-height frame, opening on Home, under a thin
line that Chat arrives next week. The five mockup files are copied as they
are into public/demo/chat (about 720 KB), outside Prettier's scope. On any
other brand, Chat is unchanged.

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

* feat(demo): show the demo brand's integrations connected, and those to come as coming soon

On the demo brand, Settings › Integrations shows the real cards with the
demo's states, kept in one list (lib/demo/integrations.ts): Google Search
Console, Google Analytics and Webflow as connected, the way they look with
a live connection, marked "Sample data", the demo brand mapped to a sample
property and Webflow sending to a sample collection, with nothing read from
the API or Composio and no set-up lines. Disconnect and Replace token open
the plan dialog. Merchant Center shows Coming soon on its own card, and
Shopify, WordPress, Framer and Wix, which have no card yet, a Coming soon
row in their group. When one goes live, its line in the list turns
connected.

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

* feat(demo): build the Brewline Coffee demo brand's core data

lib/demo/ builds an organization's demo brand in its own brands: Brewline
Coffee (brewline.example) with fictional `.example` competitors and
publishers, 12 prompts in 3 topics, 6 engines and a run every 3 days over
a month (720 short answers) with citations, product cards, searches and
volumes. Answers are raw engine responses run through tracking's own
parseScraperResponse, parseResponse and the result and shopping card rows
(now pure resultRow and shoppingCardRows in cloro-result-handler.js), and
the rollups are rebuilt by the nightly run's own functions.

ensureDemoBrand creates it, rebuilds it in place (same ids) when
DEMO_VERSION moves on or its data is three days old, and leaves it alone
otherwise; concurrent visits share one build (one-per-org index, a
compare-and-set claim, a lease). Modules are { name, tables, build }, and
a coverage test fails on any brand_id table the demo neither builds nor
lists as skipped or pending.

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

* feat(demo): open and hide the demo brand through /api/demo

POST /api/demo creates or rebuilds the organization's demo brand for any
member and returns { brandId, version, rebuilt }; PATCH /api/demo
{ hidden } hides or shows it for admins and managers ({ brandId, hidden },
404 no_demo without one). Both stay open once a plan has ended.

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

* feat(demo): let a workspace with no plan explore the demo brand

Onboarding's plan step gets a second way in under the plan cards: "Not
ready to add a card? Explore a demo brand", whose button makes the demo
brand (POST /api/demo), selects it and opens the Action Center, the
person's own brand kept as set up. An admin who never subscribed used to be
sent back to that step from the dashboard; with a demo brand in the
organization, they now browse read-only instead (evaluateSubscriptionAccess
takes hasDemoBrand). The read-only band of an ended or canceled plan gets
"See the demo", for an admin or a manager, or anyone once the demo brand is
listed: the same flow, which shows a hidden demo brand again. The plan
step's preview reads the own brand, never the demo brand.

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

* feat(demo): offer the free trial on the own brand of a workspace that never had a plan

A workspace that never subscribed now gets the trial offer on its own
brand too, not only on the demo brand: the read-only band says the brand
isn't tracked yet ("Start your 14-day free trial, then get 50% off your
first month") with Start free trial for admins, and the dialog's title is
"Start your 14-day free trial: then 50% off your first month", with SAVE50
applied and Start free trial on each plan. Members are asked to have an
admin start it. ChoosePlanDialog takes the offer as a `pitch` (from the
demo brand, or the own brand).

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

* feat(demo): show what is paid today on the demo's first-month offer

With SAVE50 applied, the demo's 50%-off-first-month offer words its
buttons as the plan dialog does everywhere else: "Choose Starter · $24.50
today"; "Choose {plan}" alone when the code didn't apply.

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

* feat(demo): say the demo brand is hidden, not deleted, in its Danger tab

On the demo brand, brand settings' Danger tab says "The demo brand can't
be deleted; hide it from the brand menu instead." in place of the name to
confirm, and Delete brand stays disabled. The server refuses the delete
too.

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

* feat(demo): cancel a demo brand's jobs as demo_brand, not as an ended plan

A job claimed for a demo brand ("Run now", the internal trigger, a retry
or the recovery) was cancelled as subscription_inactive, as if the plan had
ended. It now says demo_brand: brandStopReasons tells why no work may start
for a brand, and activeBrandFilter is built on it. Nothing is tracked,
generated or counted before the cancel: the on-demand cap counts the
brand's own jobs, and AI usage is recorded by the workers, which never run.

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

* feat(demo): refuse the web app's own writes on the demo brand

assertWritable takes the brand an action writes for and refuses the demo
brand (DemoBrandError, digest demo_brand), whatever the plan, reading the
brand beside the plan through the person's session. Every gated server
action that takes a brand id hands it over (52 of them, the brand's own id
in updateBrand); actions that name no brand, such as the profile or the
organization, read nothing more. A route's refusal answers 402 demo_brand,
and the browser reads the digest as it reads subscription_inactive: an
uncaught refusal opens the plan dialog. The read-only coverage test now
also fails a gated action that takes a brand id without handing it to the
check.

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

* feat(demo): refuse writes and costs on the demo brand with 402 demo_brand

The demo brand's data is sample data, so nothing asked of it may change it
or start a cost. A middleware after decodeToken (before the plan's check,
so the answer is the same with a plan or without) refuses every write that
names a demo brand: in the path, the body, the query, or through the row it
acts on (a draft, an opportunity, a prompt, a task...). Every write route
under /api is named, guarded or open with its reason (onboarding, the
organization's own integrations, stopping work, the demo routes, brand
delete's own 409); a test reads the route files and fails on one that
isn't. Reads and exports stay open; brand facts are read only as kept on a
demo brand, so its site is never fetched.

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

* feat(demo): hide the demo brand once a plan is bought

When a subscription starts (Stripe's checkout.session.completed, trial
included, and the return from Checkout, whichever comes first), the
organization's demo brand gets demo_hidden_at, through the service role:
hidden, never deleted. Only a demo brand still shown is touched, and
subscription updates, renewals and payments never touch it, so one an admin
shows again stays shown. A first payment still open hides nothing, and a
failed write never fails the purchase. Hidden before the dashboard opens,
the demo brand leaves the brand list, so the person lands on their own
brand.

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

* feat(demo): refuse people's writes to a demo brand's rows in the database

Members can write a brand's rows straight through Supabase, under RLS,
past the API's 402. Migration 00381 adds refuse_demo_brand_writes(), a
BEFORE INSERT/UPDATE/DELETE row trigger that raises 42501 'demo_brand' for
a demo brand's row unless the role bypasses RLS (the service role the
server and the demo generator write with). It is attached to the 24 tables
people can write that carry a brand_id, and, through their parent row, to
the 13 that reach their brand another way (prompts through prompt_sets,
prompt notes and target URLs through prompts, a draft's inputs and sources
through content_drafts, tasks and events through actions...). A test reads
the policies and triggers from the migrations and fails on a table people
can write that belongs to a brand and lacks it.

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

* feat(demo): refuse the MCP's brief, audit and Improve endpoints on a demo brand

The internal endpoints the MCP calls (a content brief, a Site Audit, an
Improve action) trust CRON_SECRET and never meet the API's middleware.
Each now answers a demo brand with 402 demo_brand before it calls the
model, starts an audit or writes an action; the MCP relays the message.

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

* feat(demo): clear demo brands nobody opened for two weeks, nightly

Every organization gets a demo brand, so its sample rows would pile up
for workspaces that left. The daily run now clears the data of demo brands
built over 14 days ago (a visit rebuilds every few days, so these weren't
opened since), 200 a night at most: through clearDemoData, the path a
rebuild takes, so rows go in the modules' reverse order. The brand row
stays with no version and no build time, and the next visit builds it
again in place, with the same ids. The clear holds the brand as a build
does, so a visit at the same moment waits for it.

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

* test(demo): look rows up by a set in the demo guard's fake database

The cache test reads 10,000 brands; filtering them with includes() took
seconds and timed out under a full run.

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

* feat(demo): build the demo brand's Action Center, Content, suggestions and reports

Four demo modules over core's answers: signals and a month of actions
(tasks, trail, measured outcomes, a task waiting for review, ready-made
KPIs, Getting started with its page steps opened), prompt clusters,
content opportunities, Editor drafts and Plan marks, prompt, topic and
Improve suggestions, and two saved reports. Numbers are counted from the
demo's own answers; shapes come from the engine's own functions. detect.js
exports single and promptTarget so the demo writes signals in their shape.

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

* feat(demo): register the workflow modules and rebuild demos at version 2

DEMO_MODULES runs core, suggestions, actionCenter, content and reports;
DEMO_VERSION 2 rebuilds existing demo brands on their next visit. The
coverage lists move the workflow tables to built, skip the engine's
internal queues and logs and the org-level author default, and leave the
draft shopping check to demo-site with the catalog.

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

* refactor(audit): read a page already fetched into the audit context with auditContextOf

buildAuditContext fetches the page, robots.txt and llms.txt, then hands
them to auditContextOf, which parses the HTML once and extracts its text
as before. A page that isn't fetched (the demo brand's) is read exactly as
a fetched one.

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

* feat(demo): build the demo brand's AI Referral Traffic over a quarter

Brewline's website (site-world.js) and its traffic: 90 days of Google
Analytics as GA4 reports mapped by ga-sync.js (AI sessions by source and
page, ChatGPT Shopping's feed visits, pages, channels, items), Search
Console's query and page rows mapped by gsc-sync.js, four weeks of snippet
visits (a removed guide's 404s for Broken AI links) and journeys made by
traffic-events.js's eventRow, a month of AI crawler counts with a
Cloudflare Worker connection whose secret hash matches no secret, and the
page opportunities detectPageOpportunities finds in them. The brand maps
the sample GA4 and Search Console properties and has conversions on.

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

* feat(demo): build the demo brand's Site Audit from the audit engine's own verdicts

Brewline's pages are rendered as HTML round by round and scored by
runSignals and scoreAudit: six key pages audited three times as fixes
land, every page in the latest auto-audit. The model-judged signals,
Wikidata's brand entity and the recommendations are written in the shapes
those steps store. The page inventory goes through selectPages and
parseHead, site trust through site-trust.js's checks (4/5: no editorial
policy), and the brand facts through factText and keptFacts.

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

* feat(demo): fill the demo brand's catalog from its product feed

A Google XML feed of 22 products read by the feed parser and kept as
catalogRecords and hashOf keep them, with stable demo ids: a removed
seasonal blend, an out-of-stock size, a sale, no images. The products the
demo's AI answers show as cards are the same page, title and price. Two
categories get their page by hand; the rest match their collection pages.

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

* feat(demo): classify the demo's fan-out searches ahead in the intent cache

The demo writes the intent of each search its answers ran into
fanout_query_intents, keyed as the route keys it (normalizeIntentQuery,
moved to intent-extraction.js), adding only what the shared cache lacks,
so Query Fan-out never needs a model for the demo.

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

* feat(demo): build traffic, Site Audit, the catalog and fan-out intents with the demo brand (version 3)

The demo-site modules join the core in DEMO_MODULES, and DEMO_VERSION is
3, so every demo brand is rebuilt with them on its next visit. Their
tables leave the coverage test's pending list; a CMS connection, sent
drafts, product images and Merchant Center item issues are skipped, with
why.

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

* test(demo): audit the demo's pages once more, not twice, to check its rows stay the same

One rebuild for another brand two days later checks both that only the
ids and dates change, with room past the default 5 s on a busy machine.

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

* feat(demo): give the demo brand its own logo

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

* fix(web): read a new sign-up's free plan as Starter's

A new sign-up's organization holds plan 'free' until it picks one. With the
demo brand it reaches the dashboard, where PLANS[planId].limits threw on the
Prompts page. toPlanId maps an unknown plan to Starter's.

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

* feat(demo): give the demo's made-up sites real-looking logos

.example is reserved, so no favicon service knows the demo's brand,
competitors or cited sites. Their logos ship in public/demo/logos; any
other .example site gets a letter mark, so no page asks Google for one.

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

* feat(billing): offer two ways to start a plan: buy now at 50% off the first month, or the free trial

Every plan choice now offers two ways to start, each with a card. Buy now
bills the full plan from day one, with the first-month offer on a monthly
plan ("$24.50 first month, then $49/month", a Limited offer mark); a year
up front is the plain "Choose {plan}". The 14-day free trial comes without
the offer, with limited AI usage ("Free for 14 days, then $49/month"), and
only for an organization that never had a subscription. Checkout takes the
way explicitly (mode: 'buy' | 'trial'): buying never starts a trial, the
trial takes no promotion code and is refused (409 trial_unavailable) to an
organization that had a subscription, and both collect a card. The offer
is one setting, FIRST_MONTH_OFFER in config/plans.ts, turned off with
NEXT_PUBLIC_FIRST_MONTH_OFFER=off; its code no longer redeemable falls back
to the plain price.

The plan dialog (demo, a brand not tracked yet, a plan that ended), the
demo band and the "not tracked yet" band ("Start a 14-day free trial, or
get 50% off your first month." with See plans) and onboarding's plan step
("Choose how to start", two buttons per plan, the demo card below) say it
this way; the "14 days free, then 50% off" wording is gone. Billing's
Checkout for a plan that ended buys now.

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

* feat(demo): start the demo brand's setup ahead, where the demo is offered

The demo brand's first setup takes a while, and "Explore the demo" waited
for all of it. Onboarding's plan step, for an organization with no demo
brand yet, and the read-only band's "See the demo", for an admin or a
manager with none yet, now start POST /api/demo in the background once, as
they show (failures stay quiet). The click waits for that same request,
done at once when it is (prepareDemoBrand, asked once per page, again
after a failure), and its button says "Setting up the demo…" meanwhile.

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

* fix(billing): show the first-month offer when its code can't be checked

Stripe unreachable, or not set up on a local server: the plan dialog still
shows the configured offer; checkout applies the code and says so by the
field if Stripe turns it down.

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

* perf(demo): build the demo's modules side by side after the core

The first module lays down what the others point at; the rest write their
own tables together, each after the module it names in `after`.

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

* feat(demo): tell Chat's preview story with Google AI Overviews

The Chat preview's running example (citations that dropped, why, and the
fix) now follows Google AI Overviews instead of Perplexity. Engine lists,
the logo map and the mockup's own matching rules are unchanged.

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

* feat(demo): show Chat preview's citation changes as small pills

Since you left's drop and win were big bold numbers with ▼/▲; they are now
small pills with a thin arrow on a soft red or green ground.

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

* feat(demo): show the demo brand with Growth, the whole product

While the demo brand is the brand on screen, the plan context reads
Growth whatever the workspace's plan (or none): Product Visibility and
the AI bot report open, every engine shows in the Positions panel and
column, and the Growth marks go. One rule, effectivePlanIdForBrand,
feeds the client's plan context and the server actions' position
reads. Billing keeps reading the organization's own plan (ownPlanId).
Writes and costs are unchanged: on the demo brand they still open the
plan dialog.

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

* fix(billing): show the first month's price once on the plan dialog's cards

With the first-month offer, the card's price already reads "$24.50 first
month, then $49/mo"; the same line under Buy now said it again. Only
"Full plan from day one" stays there, beside the free trial. The
upgrade dialog's test now answers the offer's code check itself, so it
no longer depends on the network to read "Choose Starter".

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

* perf(demo): build the demo faster and rebuild it over its old rows

A first build no longer clears 70 empty tables, and the core writes each
step's independent tables side by side through a shared queue of four
statements (write.js: insertChunks, demoWriter). Its rollups move to a
refresh step that runs alongside the other modules, Insights, Citations and
Mentions together, the month's answer terms in one call (refreshMentionsDaily
takes an optional termDays). The core alone went from about 17 s to 7 s on
the dev database.

A rebuild (new DEMO_VERSION, or data older than three days) no longer
deletes the demo first: an `inPlace` module writes over its rows by key
(ids are deterministic) and deletes only the rows it didn't write again,
then rebuilds the rollups over the old and new days, each refresh call
rewriting its days in one statement. Someone opening the demo meanwhile sees
last week's data, not empty pages. Modules not marked `inPlace` still have
their tables cleared, now just before they are built.

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

* feat(billing): start a plan from Billing the way the plan dialog does

With no plan active, Settings › Billing's cards now offer the plan
dialog's ways to start: Buy now, at 50% off the first month on a monthly
plan while the offer runs, and, for a workspace that never had a plan,
the 14-day free trial. A plan that ended gets Buy now alone. The cards'
price and buttons, the first-month code check and Checkout are one set
of parts (billing/plan-start.tsx) that the dialog and Billing share.

A workspace that never started a plan reads "No plan yet" under Current
Plan, with "Choose how to start" over the cards, instead of
"Starter incomplete".

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

* fix(demo): write over what a new brand's triggers made

A brand just created isn't empty: its insert trigger starts Getting started,
so skipping every clear on a first build made the Action Center's insert hit
getting_started_pkey. An in-place module now always writes over by key (the
first build only skips reading back and pruning); a module that isn't
rebuilt in place clears its own tables just before it is built, on a first
build too, alongside the other modules rather than all up front.

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

* perf(demo): clear the other modules' tables alongside the core on a first build

Nobody looks at a demo being built for the first time, so every module not
rebuilt in place starts clearing what the new brand's triggers made at once,
while the core writes, instead of each in turn later, when its deletes queue
behind the rollups. A rebuild still clears each module just before it is
built, so its old rows stay on show as long as they can.

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

* feat(demo): build a new workspace's demo brand while onboarding goes on

As soon as onboarding has the organization (step 2 on a new account, at
once on a resume), an admin of a workspace without a plan and without a
demo brand starts its setup in the background (wantsDemoAhead +
usePreloadDemo): the first build takes a few seconds, the topics, prompts
and competitors steps longer, so "Explore the demo" on the plan step opens
at once. The plan step's own preload stays. The resume step now reads the
person's own brand only (is_demo false): the demo brand may exist by then.

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

* feat(demo): show the demo being prepared, step by step, while it builds

"Explore the demo" and "See the demo" open the demo at once when its setup
is done. While it is still being prepared, a setup screen (DemoSetupDialog)
shows what the server writes, in its order, as the Content Agent's card
shows a run: the steps done with a check, the one under way with the
agent's sweep and dots and its count going up (720 sample answers from 6
platforms, 2,694 sources, 18 pages audited, 9 actions, 10 opportunities, 2
reports: the generator's own counts). It starts from where a setup asked
ahead already is (demoPreparation), holds on the last step until the
answer comes, then runs through the rest quickly and opens the Action
Center. A failure says so in the screen, with Try again and Close; closing
it lets the setup finish in the background. Counts show whole at once with
reduced motion; the sweep and dots stop. StepSweep moves to components/ui,
shared with the editor's agent card.

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

* fix(demo): drop the Chat preview's own copy of the app menu

The Chat preview sits beside the app's left menu; the mockup's icon rail
(and the governance and signature screens' app menus) showed the same menu
twice, so the demo copies hide them.

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

* feat(demo): replace a table's rows whose ids the database gives

A table with an identity id and no other unique columns (ai_bot_events)
can't be written over by key. write(table, rows, { generated: true })
inserts the new rows and, on a rebuild, deletes the brand's rows that were
there before right after: never empty, both there for a moment.

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

* perf(demo): rebuild the Action Center, Content, suggestions and reports in place

The four workflow modules write through the build's writer (ctx.write):
each step's independent tables side by side, and on a rebuild over their
old rows by key, deleting only what isn't written again, so their pages
never empty while the demo is rebuilt. Keys where a row has no id:
getting_started (brand_id, also what a new brand's trigger made),
getting_started_steps, action_signals, the cluster members, searches and
scopes, and the plan marks; the action and cluster children are found
through their parent (scopes).

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

* test(demo): pin the build order with gates instead of timers

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

* perf(demo): rebuild AI traffic, Site Audit and the catalog in place

The three site modules write through the build's writer (ctx.write): their
independent tables side by side (traffic's thirteen at once, a visit before
its pageviews), and on a rebuild over their old rows by key, deleting only
what isn't written again, so their pages never empty while the demo is
rebuilt. Google Analytics and Search Console rows are keyed by their day and
what they count (their unique columns, as their syncs write them), the
audits' signals by audit and signal (found through their audit), the
single-row settings by brand. ai_bot_events has an identity id and no other
key: its rows are replaced, the old ones deleted right after the new are in.
site-common's insertRows goes.

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

* perf(demo): refresh the demo's mention rollups beside its answer terms

refreshMentionsDaily takes `together`: the rollups (refresh_mentions_daily)
and the answer terms (refresh_mention_terms) take their own locks and write
their own tables, so the demo runs them side by side instead of one after
the other, a second off the longest step of its build. The nightly run
keeps them in turn.

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

* feat(demo): move the Chat preview's inbox into the chat menu and add archived chats

Home keeps the composer in view: Inbox gets its own screen in the chat
menu, the skill cards are shorter with the description on hover, Home to
Files fold under a Menu header, and All chats has Active/Archived tabs.

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

* feat(demo): show Brewline Coffee in the Chat preview, raise its Home and add skill creation

The preview now tracks the demo brand: its pages, rivals, prompts and
sources come from the demo data, and Ansvisor stays only where it names
the product. Home starts higher with more room above the composer, both
cards say when their change happened, One win lists its citations, and
Create a skill opens the chat, upload and URL import flows from CHAT-13.

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

* fix(web): name the profiles→organizations relationship so the plan check reads again

The read-only check before every write embedded organizations from
profiles without naming the relationship. A second foreign key between the
two tables made the embed ambiguous, so the check failed and every write
returned 500 for every workspace, active plans included. Same fix for
getMyProfile.

(cherry picked from commit 62eb7b7658388c1614b38dea93fbe316b8910311)

* test(web): read the demo brand's plan check with the named relationship

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

* feat(billing): start a plan from one choice that fits on one screen

The plan dialog, Settings › Billing with no plan active and onboarding's
plan step now share the same start flow (components/billing/plan-start):

- One choice above the cards: 14-day trial / Monthly, 50% off the first
  month / Yearly, Save 20%. Each card then has one button, one "Due
  today" line (the trial says when it ends and what follows, "Free until
  Nov 11, then $49/month") and "Secure checkout with Stripe · Cancel any
  time" beside the button. The promo code field sits behind "Have a
  code?".
- The first-month offer shows from the first frame, from the config: no
  $49 → $24.50 jump once Stripe answers. A code Stripe can't redeem takes
  it away; one that couldn't be checked keeps it as configured.
- Onboarding's plan step drops its own copy (PLAN_STEP_COPY) for the
  shared cards and Billing's features, with the discounted price large,
  and says what is ready to track for the brand, from its real prompt,
  topic and competitor counts.
- Everything fits 1024×768 and up without scrolling: the plans' features
  open behind "Show plan details" inside the cards, which keep their
  height; on Billing the plan choice comes first while no plan is active.
- A Checkout that doesn't open (Stripe down or not set up, no answer in
  30 s, a refusal) says why by the plan's button instead of spinning.

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

* feat(demo): name the workspace's own brand in the demo band and plan dialog

On the demo brand the band says "Start tracking Acme Coffee with a
14-day free trial…" and, with a plan active, "Switch to Acme Coffee"; the
plan dialog's demo and new-brand pitches name the brand too. Before the
workspace has a brand of its own, the general wording stays.

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

* fix(demo): wait for the brand on screen before showing a page or a band

In a new browser the brand store starts empty until BrandLoader puts the
layout's brands in it, just after the first render. Until then BrandGuard
read the empty list as "No brands yet", the read-only band showed the
workspace's own state before the demo brand's band, and the brand switcher
offered Add Brand. The store now says when it holds the server's list
(loaded, never persisted); pages wait on the skeleton, the read-only band
and Add Brand wait for it, and leaving the dashboard clears it.

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

* fix(demo): keep the nightly prompt demand read off demo brands and cover main's new tables

sweepPromptDemand chose brands by their organization's plan only, so an
active workspace's demo brand would have had its sample prompts read and
DataForSEO's paid tasks set for them. It now leaves demo brands out, as
the other sweeps do. The demo coverage list names the two brand tables
main added: prompt_table_views (skipped: the demo starts on the default
columns) and prompt_demand (pending a demo follow-up).

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

* fix(demo): refuse main's new write routes on a demo brand and keep column layouts open

Main added write routes that name a brand: Action Center's audits and
products, WordPress and Framer connections, and their publish-status
checks. Each now answers 402 demo_brand on a demo brand, as the Webflow
ones do. The Tracked Prompts column layouts (prompt_table_views, 00363)
stay writable on a demo brand: they change no sample data and cost
nothing, and the web keeps them open while read-only too.

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

* feat(demo): follow the app's dark theme in the Chat preview

The preview reads the app's .dark class from its parent page and follows it live; standalone it follows the system setting. Its colours moved to variables with a dark palette close to the app's.

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

* fix(demo): check a topic write once, with its brand, now that the check comes first

Merging main left createTopics, createTopic and updateTopic with two
plan checks each: main's, moved ahead of the name check, and the demo's,
which hands the brand over. Each now checks once, first, with its brand
where it has one.

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

* feat(demo): answer the Chat preview's shortcuts from anywhere on its page

⌘ or Ctrl with ⇧O (new chat), K (search), J (side panel) or \ (menu)
reach the preview while the app around it has the focus: the page hands
them to the frame, which answers them as it does inside. The frame takes
the focus when it opens, and on a Mac the preview shows ⌘ for Ctrl.

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

* fix(demo): keep the competitor timeline off demo brands and cover main's new tables

sweepCompetitorTimeline (learning C3, on main) chose brands by their
organization's plan only, so a demo brand's sample answers would have had
their cited pages read every night. It now leaves demo brands out, as the
other sweeps do. The demo coverage list names the brand tables main added:
cited_page_features, competitor_page_events and competitor_timeline_scans
(pending a demo follow-up) and chat_conversations (with Chat).

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

* feat(chat): read a call's demo flag from brands.is_demo

Chat's precedence (#1776) left readBrandIsDemo false until the demo chain
added brands.is_demo, with a type check that stops compiling once the
column exists. It now reads the column, as the server's demo guard does,
so a tool that changes or spends on the demo brand is refused with
demo_brand; a brand that isn't found isn't one, and a failed read throws.

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

* fix(demo): guard the brand site type detection on the demo brand

POST /brands/:id/detect-site-type (#1761, on main) reads the brand's home
page and may ask AI for its kind. The demo guard's coverage test fails on a
write route in neither list, so it is now guarded by the brand in its path.

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

* fix(demo): name main's new Chat tables in the demo write guard's lists

chat_user_prefs (00400) and chat_auto_choices (00401) are a person's own
rows, not a brand's: the write guard's coverage test fails on a writable
table in no list, so both are named as no brand's rows.

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

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 29, 2026
…rand, part 6) (#1739)

* feat(web): let a workspace whose plan ended browse read-only, with one "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]>

* feat(billing): show the plans in the read-only dialog, with Monthly or Annual and a promo code

The "Choose a plan to keep going" dialog for an ended plan now carries
the plans, as the approved design has them.
- Starter and Growth (Popular) have "Choose {plan}"; Custom has "Starting
  at $499/mo" and "Contact us". Each lists the Billing cards' features,
  through a shared usePlanFeatures.
- Monthly or Annual ("Save 20%"): an annual price shows its struck 12×
  price and what it is a month.
- A promo code is checked by the API (POST /api/stripe/promo-code, admins
  only), through the same Stripe lookup #1300 uses (findPromotionCode,
  takesPromoCode: monthly plans only).
  - A valid code shows its chip, the first month's price on each card and
    in the button ("Choose Growth · $124.50 today").
  - A bad one says so; on Annual a note offers Switch to Monthly.
- Choose opens Stripe Checkout for that plan and period, with the code
  applied as a discount. The checkout route checks the code again and
  refuses it on an annual plan.
- Members see "Ask your admin to choose a plan", with no code field.
- The footer reads "Prices in USD." with a link to the pricing page.
- A failed payment keeps its "Update payment method" dialog.

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

* fix(billing): word the dialog's custom AI usage "from 10x", as Billing does after #1598

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

* feat(web): open the plan dialog from the Prompts area's actions while 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]>

* feat(web): open the plan dialog from the content area's actions, and 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]>

* feat(web): open the plan dialog from the remaining areas' actions, and 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 (#1606) and Content (#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]>

* feat(web): refuse direct database writes from a workspace whose plan has ended, on the server

Server actions and Next routes that write to Supabase without going
through the API now call assertWritable() first: on the cloud, an
organization without an active plan gets SubscriptionInactiveError
(routes: 402 subscription_inactive), so the read-only rule holds even if
a guarded button is bypassed. Setup's writes stay open to an
organization that never subscribed, as the API's onboarding routes do.
Profile, invitations accepted, revokes, removals, API keys and billing
stay open. A static test pins every writing action to the check or to
the open list.

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

* fix(web): keep removing members, revoking invitations and disconnecting 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]>

* fix(web): open the plan dialog from Add Brand at the plan's brand limit 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]>

* feat(web): let a read-only workspace delete a brand

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 #1611.

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

* fix(web): keep setup's Shopping mode working for a new workspace, read the plan in one query, and pin the write check's place

From the pre-push review: markBrandAsEcommerce no longer goes through
the strictly guarded setBrandShoppingMode (a shared applyShoppingMode
does the writes), so a setup detected as e-commerce turns Shopping on
again. assertWritable reads the profile and its organization in one
query. The coverage test now requires the check as each writer's first
await, sees writers kept in variables and signed upload URLs, refuses a
setup-open function that reaches a strictly guarded one, and keeps brand
deletion open (Ansvisor, 2026-10-27). main's saveDraftShoppingPath is
guarded; catalog-client's every-code test leaves out 'subscription',
which opens the plan dialog instead of a message.

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

* 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

With #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]>

* fix(web): keep a saved content suggestion reachable, the Starter bot 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]>

* fix(web): leave the plan dialog's store error out of the every-code message test

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

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

* fix(web): open the plan dialog from Merchant Center, category pages and main's other new actions while the plan has ended

main's new writes, with C3's guard pattern and labels:
- Merchant Center (#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 (#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 (#1591): Pick from the catalog, Pick again, Add
  product, Lock, Swap and Remove are guarded.
- Action Center Check now (AC-010, #1565) is guarded.

New labels: changeCategoryPages, changeShoppingPath, checkTasks.
Insert › Products (#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 (#1610) change through the rules hook, already guarded.

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

* fix(web): check the plan inside Merchant Center's Add, not by wrapping 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]>

* test(web): keep brand setup's limits in the new brand page test's mock

main's new brand page now reads BRAND_SETUP_LIMITS from ai-brand-setup
(#1661), which the test's mock left out.

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

* feat(demo): open the plan dialog with the demo's offer on a demo brand

The selected brand being the organization's demo brand (brands.is_demo,
sample data) locks the dashboard as a read-only workspace is locked, with
its own reason: guarded actions open the plan dialog with the demo's offer.
A workspace that never subscribed is offered the free trial, then 50% off
("Start free trial"); one whose plan ended gets 50% off its first month
("Choose {plan}"). The label names what was clicked as something that
works on your own brand, and an admin finds SAVE50 applied (quietly left
empty when Stripe refuses it). With a plan active, the dialog points back
to the workspace's own brand; a payment being retried still asks for the
payment method. The server's 402 demo_brand opens the same dialog.

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

* feat(demo): show a band across the dashboard while the demo brand is open

Where the read-only band sits, and instead of it: "You're exploring
{brand}, a demo brand with sample data", with a small button to the plan
dialog's offer ("Try it on your brand · 50% off" for a workspace that never
subscribed, "Use it for your brand · 50% off" once its plan ended), or back
to the own brand while a plan is active. The band asks the API once per page
load to bring the demo brand up to date (POST /api/demo) and reads the
pages again when its sample data was written anew, so the demo follows the
product by itself.

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

* feat(demo): add a demo brand per organization, kept out of the plan's counts

Migration 00380 adds brands.is_demo, demo_version, demo_built_at and
demo_hidden_at, one demo brand per organization (partial unique index) and
policies that let members read it but never insert, change or delete one.
The plan's prompt-location quota, the usage cards' account totals and the
web's brand limit leave the demo brand out; the health report's fan-out
share leaves out its answers. The brand delete route refuses it: the demo
brand is hidden, not deleted.

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

* feat(demo): skip demo brands in every nightly sweep and job

The daily tracking list, the job claim and recovery (activeBrandFilter /
isBrandActive), the signal catch-up, the pulse, the task writer, executor
and checks, action validation and Improve outcomes, the Insights sweep,
brand facts, Search Console and Analytics syncs, page opportunities, the
traffic digest, auto-audits, catalog feeds, Webflow status and volume
analysis all leave demo brands out: their data is sample data and nothing
may track, write or spend for it.

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

* feat(demo): mark the demo brand in the brand switcher, with Show or Hide

The demo brand reads "Demo · sample data" under its name, in place of a
domain, and a brand of a workspace that never had a plan reads "Not tracked
yet". For an admin or a manager, the menu ends with "Hide the demo brand"
(PATCH /api/demo), or "Show the demo brand" once it is hidden, which brings
it back and opens it: the demo brand is hidden after a purchase, never
deleted. A hidden demo brand stays out of the dashboard's brand list and
the brands page, and the demo brand never counts toward the plan's brands,
there or when a brand is added.

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

* feat(demo): show Chat as coming next week on the demo brand, with its v2 preview

On the demo brand, the menu's Chat item carries "Soon (next week)" in its
badge, ahead of "Set up" (the badge rule now lives in dashboardNavBadge, for
the sidebar and the mobile menu alike), and /dashboard/agent shows the Chat
v2 mockups themselves in a full-height frame, opening on Home, under a thin
line that Chat arrives next week. The five mockup files are copied as they
are into public/demo/chat (about 720 KB), outside Prettier's scope. On any
other brand, Chat is unchanged.

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

* feat(demo): show the demo brand's integrations connected, and those to come as coming soon

On the demo brand, Settings › Integrations shows the real cards with the
demo's states, kept in one list (lib/demo/integrations.ts): Google Search
Console, Google Analytics and Webflow as connected, the way they look with
a live connection, marked "Sample data", the demo brand mapped to a sample
property and Webflow sending to a sample collection, with nothing read from
the API or Composio and no set-up lines. Disconnect and Replace token open
the plan dialog. Merchant Center shows Coming soon on its own card, and
Shopify, WordPress, Framer and Wix, which have no card yet, a Coming soon
row in their group. When one goes live, its line in the list turns
connected.

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

* feat(demo): build the Brewline Coffee demo brand's core data

lib/demo/ builds an organization's demo brand in its own brands: Brewline
Coffee (brewline.example) with fictional `.example` competitors and
publishers, 12 prompts in 3 topics, 6 engines and a run every 3 days over
a month (720 short answers) with citations, product cards, searches and
volumes. Answers are raw engine responses run through tracking's own
parseScraperResponse, parseResponse and the result and shopping card rows
(now pure resultRow and shoppingCardRows in cloro-result-handler.js), and
the rollups are rebuilt by the nightly run's own functions.

ensureDemoBrand creates it, rebuilds it in place (same ids) when
DEMO_VERSION moves on or its data is three days old, and leaves it alone
otherwise; concurrent visits share one build (one-per-org index, a
compare-and-set claim, a lease). Modules are { name, tables, build }, and
a coverage test fails on any brand_id table the demo neither builds nor
lists as skipped or pending.

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

* feat(demo): open and hide the demo brand through /api/demo

POST /api/demo creates or rebuilds the organization's demo brand for any
member and returns { brandId, version, rebuilt }; PATCH /api/demo
{ hidden } hides or shows it for admins and managers ({ brandId, hidden },
404 no_demo without one). Both stay open once a plan has ended.

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

* feat(demo): let a workspace with no plan explore the demo brand

Onboarding's plan step gets a second way in under the plan cards: "Not
ready to add a card? Explore a demo brand", whose button makes the demo
brand (POST /api/demo), selects it and opens the Action Center, the
person's own brand kept as set up. An admin who never subscribed used to be
sent back to that step from the dashboard; with a demo brand in the
organization, they now browse read-only instead (evaluateSubscriptionAccess
takes hasDemoBrand). The read-only band of an ended or canceled plan gets
"See the demo", for an admin or a manager, or anyone once the demo brand is
listed: the same flow, which shows a hidden demo brand again. The plan
step's preview reads the own brand, never the demo brand.

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

* feat(demo): offer the free trial on the own brand of a workspace that never had a plan

A workspace that never subscribed now gets the trial offer on its own
brand too, not only on the demo brand: the read-only band says the brand
isn't tracked yet ("Start your 14-day free trial, then get 50% off your
first month") with Start free trial for admins, and the dialog's title is
"Start your 14-day free trial: then 50% off your first month", with SAVE50
applied and Start free trial on each plan. Members are asked to have an
admin start it. ChoosePlanDialog takes the offer as a `pitch` (from the
demo brand, or the own brand).

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

* feat(demo): show what is paid today on the demo's first-month offer

With SAVE50 applied, the demo's 50%-off-first-month offer words its
buttons as the plan dialog does everywhere else: "Choose Starter · $24.50
today"; "Choose {plan}" alone when the code didn't apply.

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

* feat(demo): say the demo brand is hidden, not deleted, in its Danger tab

On the demo brand, brand settings' Danger tab says "The demo brand can't
be deleted; hide it from the brand menu instead." in place of the name to
confirm, and Delete brand stays disabled. The server refuses the delete
too.

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

* feat(demo): cancel a demo brand's jobs as demo_brand, not as an ended plan

A job claimed for a demo brand ("Run now", the internal trigger, a retry
or the recovery) was cancelled as subscription_inactive, as if the plan had
ended. It now says demo_brand: brandStopReasons tells why no work may start
for a brand, and activeBrandFilter is built on it. Nothing is tracked,
generated or counted before the cancel: the on-demand cap counts the
brand's own jobs, and AI usage is recorded by the workers, which never run.

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

* feat(demo): refuse the web app's own writes on the demo brand

assertWritable takes the brand an action writes for and refuses the demo
brand (DemoBrandError, digest demo_brand), whatever the plan, reading the
brand beside the plan through the person's session. Every gated server
action that takes a brand id hands it over (52 of them, the brand's own id
in updateBrand); actions that name no brand, such as the profile or the
organization, read nothing more. A route's refusal answers 402 demo_brand,
and the browser reads the digest as it reads subscription_inactive: an
uncaught refusal opens the plan dialog. The read-only coverage test now
also fails a gated action that takes a brand id without handing it to the
check.

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

* feat(demo): refuse writes and costs on the demo brand with 402 demo_brand

The demo brand's data is sample data, so nothing asked of it may change it
or start a cost. A middleware after decodeToken (before the plan's check,
so the answer is the same with a plan or without) refuses every write that
names a demo brand: in the path, the body, the query, or through the row it
acts on (a draft, an opportunity, a prompt, a task...). Every write route
under /api is named, guarded or open with its reason (onboarding, the
organization's own integrations, stopping work, the demo routes, brand
delete's own 409); a test reads the route files and fails on one that
isn't. Reads and exports stay open; brand facts are read only as kept on a
demo brand, so its site is never fetched.

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

* feat(demo): hide the demo brand once a plan is bought

When a subscription starts (Stripe's checkout.session.completed, trial
included, and the return from Checkout, whichever comes first), the
organization's demo brand gets demo_hidden_at, through the service role:
hidden, never deleted. Only a demo brand still shown is touched, and
subscription updates, renewals and payments never touch it, so one an admin
shows again stays shown. A first payment still open hides nothing, and a
failed write never fails the purchase. Hidden before the dashboard opens,
the demo brand leaves the brand list, so the person lands on their own
brand.

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

* feat(demo): refuse people's writes to a demo brand's rows in the database

Members can write a brand's rows straight through Supabase, under RLS,
past the API's 402. Migration 00381 adds refuse_demo_brand_writes(), a
BEFORE INSERT/UPDATE/DELETE row trigger that raises 42501 'demo_brand' for
a demo brand's row unless the role bypasses RLS (the service role the
server and the demo generator write with). It is attached to the 24 tables
people can write that carry a brand_id, and, through their parent row, to
the 13 that reach their brand another way (prompts through prompt_sets,
prompt notes and target URLs through prompts, a draft's inputs and sources
through content_drafts, tasks and events through actions...). A test reads
the policies and triggers from the migrations and fails on a table people
can write that belongs to a brand and lacks it.

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

* feat(demo): refuse the MCP's brief, audit and Improve endpoints on a demo brand

The internal endpoints the MCP calls (a content brief, a Site Audit, an
Improve action) trust CRON_SECRET and never meet the API's middleware.
Each now answers a demo brand with 402 demo_brand before it calls the
model, starts an audit or writes an action; the MCP relays the message.

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

* feat(demo): clear demo brands nobody opened for two weeks, nightly

Every organization gets a demo brand, so its sample rows would pile up
for workspaces that left. The daily run now clears the data of demo brands
built over 14 days ago (a visit rebuilds every few days, so these weren't
opened since), 200 a night at most: through clearDemoData, the path a
rebuild takes, so rows go in the modules' reverse order. The brand row
stays with no version and no build time, and the next visit builds it
again in place, with the same ids. The clear holds the brand as a build
does, so a visit at the same moment waits for it.

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

* test(demo): look rows up by a set in the demo guard's fake database

The cache test reads 10,000 brands; filtering them with includes() took
seconds and timed out under a full run.

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

* feat(demo): build the demo brand's Action Center, Content, suggestions and reports

Four demo modules over core's answers: signals and a month of actions
(tasks, trail, measured outcomes, a task waiting for review, ready-made
KPIs, Getting started with its page steps opened), prompt clusters,
content opportunities, Editor drafts and Plan marks, prompt, topic and
Improve suggestions, and two saved reports. Numbers are counted from the
demo's own answers; shapes come from the engine's own functions. detect.js
exports single and promptTarget so the demo writes signals in their shape.

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

* feat(demo): register the workflow modules and rebuild demos at version 2

DEMO_MODULES runs core, suggestions, actionCenter, content and reports;
DEMO_VERSION 2 rebuilds existing demo brands on their next visit. The
coverage lists move the workflow tables to built, skip the engine's
internal queues and logs and the org-level author default, and leave the
draft shopping check to demo-site with the catalog.

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

* refactor(audit): read a page already fetched into the audit context with auditContextOf

buildAuditContext fetches the page, robots.txt and llms.txt, then hands
them to auditContextOf, which parses the HTML once and extracts its text
as before. A page that isn't fetched (the demo brand's) is read exactly as
a fetched one.

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

* feat(demo): build the demo brand's AI Referral Traffic over a quarter

Brewline's website (site-world.js) and its traffic: 90 days of Google
Analytics as GA4 reports mapped by ga-sync.js (AI sessions by source and
page, ChatGPT Shopping's feed visits, pages, channels, items), Search
Console's query and page rows mapped by gsc-sync.js, four weeks of snippet
visits (a removed guide's 404s for Broken AI links) and journeys made by
traffic-events.js's eventRow, a month of AI crawler counts with a
Cloudflare Worker connection whose secret hash matches no secret, and the
page opportunities detectPageOpportunities finds in them. The brand maps
the sample GA4 and Search Console properties and has conversions on.

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

* feat(demo): build the demo brand's Site Audit from the audit engine's own verdicts

Brewline's pages are rendered as HTML round by round and scored by
runSignals and scoreAudit: six key pages audited three times as fixes
land, every page in the latest auto-audit. The model-judged signals,
Wikidata's brand entity and the recommendations are written in the shapes
those steps store. The page inventory goes through selectPages and
parseHead, site trust through site-trust.js's checks (4/5: no editorial
policy), and the brand facts through factText and keptFacts.

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

* feat(demo): fill the demo brand's catalog from its product feed

A Google XML feed of 22 products read by the feed parser and kept as
catalogRecords and hashOf keep them, with stable demo ids: a removed
seasonal blend, an out-of-stock size, a sale, no images. The products the
demo's AI answers show as cards are the same page, title and price. Two
categories get their page by hand; the rest match their collection pages.

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

* feat(demo): classify the demo's fan-out searches ahead in the intent cache

The demo writes the intent of each search its answers ran into
fanout_query_intents, keyed as the route keys it (normalizeIntentQuery,
moved to intent-extraction.js), adding only what the shared cache lacks,
so Query Fan-out never needs a model for the demo.

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

* feat(demo): build traffic, Site Audit, the catalog and fan-out intents with the demo brand (version 3)

The demo-site modules join the core in DEMO_MODULES, and DEMO_VERSION is
3, so every demo brand is rebuilt with them on its next visit. Their
tables leave the coverage test's pending list; a CMS connection, sent
drafts, product images and Merchant Center item issues are skipped, with
why.

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

* test(demo): audit the demo's pages once more, not twice, to check its rows stay the same

One rebuild for another brand two days later checks both that only the
ids and dates change, with room past the default 5 s on a busy machine.

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

* feat(demo): read the demo brand over MCP, and write, run or spend nothing on it

The MCP tools run in the web app, so the API's demo_brand refusal didn't
reach them. Now, on Ansvisor Cloud, every tool that writes, runs or spends
answers the demo brand with the web app's DEMO_BRAND body. That happens
whatever the plan, and before the read-only check, in gateWriteTools.
- lib/mcp/demo-gate.ts names how each of the 14 tools finds the brand it
  acts on: a suggestion, opportunity, task, prompt, answer or draft read
  back to its brand.
- A test fails on a new such tool until it is added there.
- Reading stays open.

The costly calls also refuse it inside their data functions, beside
assertSubscriptionActive, so their REST routes (402 demo_brand) and the
in-product agent do too: a brief, a Site Audit, an Improve action.

list_brands marks the demo brand (is_demo) and leaves it out once the
organization hid it, and its description tells the agent what that means.

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

* feat(demo): give the demo brand its own logo

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

* fix(web): read a new sign-up's free plan as Starter's

A new sign-up's organization holds plan 'free' until it picks one. With the
demo brand it reaches the dashboard, where PLANS[planId].limits threw on the
Prompts page. toPlanId maps an unknown plan to Starter's.

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

* feat(demo): give the demo's made-up sites real-looking logos

.example is reserved, so no favicon service knows the demo's brand,
competitors or cited sites. Their logos ship in public/demo/logos; any
other .example site gets a letter mark, so no page asks Google for one.

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

* feat(billing): offer two ways to start a plan: buy now at 50% off the first month, or the free trial

Every plan choice now offers two ways to start, each with a card. Buy now
bills the full plan from day one, with the first-month offer on a monthly
plan ("$24.50 first month, then $49/month", a Limited offer mark); a year
up front is the plain "Choose {plan}". The 14-day free trial comes without
the offer, with limited AI usage ("Free for 14 days, then $49/month"), and
only for an organization that never had a subscription. Checkout takes the
way explicitly (mode: 'buy' | 'trial'): buying never starts a trial, the
trial takes no promotion code and is refused (409 trial_unavailable) to an
organization that had a subscription, and both collect a card. The offer
is one setting, FIRST_MONTH_OFFER in config/plans.ts, turned off with
NEXT_PUBLIC_FIRST_MONTH_OFFER=off; its code no longer redeemable falls back
to the plain price.

The plan dialog (demo, a brand not tracked yet, a plan that ended), the
demo band and the "not tracked yet" band ("Start a 14-day free trial, or
get 50% off your first month." with See plans) and onboarding's plan step
("Choose how to start", two buttons per plan, the demo card below) say it
this way; the "14 days free, then 50% off" wording is gone. Billing's
Checkout for a plan that ended buys now.

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

* feat(demo): start the demo brand's setup ahead, where the demo is offered

The demo brand's first setup takes a while, and "Explore the demo" waited
for all of it. Onboarding's plan step, for an organization with no demo
brand yet, and the read-only band's "See the demo", for an admin or a
manager with none yet, now start POST /api/demo in the background once, as
they show (failures stay quiet). The click waits for that same request,
done at once when it is (prepareDemoBrand, asked once per page, again
after a failure), and its button says "Setting up the demo…" meanwhile.

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

* fix(billing): show the first-month offer when its code can't be checked

Stripe unreachable, or not set up on a local server: the plan dialog still
shows the configured offer; checkout applies the code and says so by the
field if Stripe turns it down.

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

* perf(demo): build the demo's modules side by side after the core

The first module lays down what the others point at; the rest write their
own tables together, each after the module it names in `after`.

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

* feat(demo): tell Chat's preview story with Google AI Overviews

The Chat preview's running example (citations that dropped, why, and the
fix) now follows Google AI Overviews instead of Perplexity. Engine lists,
the logo map and the mockup's own matching rules are unchanged.

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

* feat(demo): show Chat preview's citation changes as small pills

Since you left's drop and win were big bold numbers with ▼/▲; they are now
small pills with a thin arrow on a soft red or green ground.

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

* feat(demo): show the demo brand with Growth, the whole product

While the demo brand is the brand on screen, the plan context reads
Growth whatever the workspace's plan (or none): Product Visibility and
the AI bot report open, every engine shows in the Positions panel and
column, and the Growth marks go. One rule, effectivePlanIdForBrand,
feeds the client's plan context and the server actions' position
reads. Billing keeps reading the organization's own plan (ownPlanId).
Writes and costs are unchanged: on the demo brand they still open the
plan dialog.

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

* fix(billing): show the first month's price once on the plan dialog's cards

With the first-month offer, the card's price already reads "$24.50 first
month, then $49/mo"; the same line under Buy now said it again. Only
"Full plan from day one" stays there, beside the free trial. The
upgrade dialog's test now answers the offer's code check itself, so it
no longer depends on the network to read "Choose Starter".

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

* perf(demo): build the demo faster and rebuild it over its old rows

A first build no longer clears 70 empty tables, and the core writes each
step's independent tables side by side through a shared queue of four
statements (write.js: insertChunks, demoWriter). Its rollups move to a
refresh step that runs alongside the other modules, Insights, Citations and
Mentions together, the month's answer terms in one call (refreshMentionsDaily
takes an optional termDays). The core alone went from about 17 s to 7 s on
the dev database.

A rebuild (new DEMO_VERSION, or data older than three days) no longer
deletes the demo first: an `inPlace` module writes over its rows by key
(ids are deterministic) and deletes only the rows it didn't write again,
then rebuilds the rollups over the old and new days, each refresh call
rewriting its days in one statement. Someone opening the demo meanwhile sees
last week's data, not empty pages. Modules not marked `inPlace` still have
their tables cleared, now just before they are built.

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

* feat(billing): start a plan from Billing the way the plan dialog does

With no plan active, Settings › Billing's cards now offer the plan
dialog's ways to start: Buy now, at 50% off the first month on a monthly
plan while the offer runs, and, for a workspace that never had a plan,
the 14-day free trial. A plan that ended gets Buy now alone. The cards'
price and buttons, the first-month code check and Checkout are one set
of parts (billing/plan-start.tsx) that the dialog and Billing share.

A workspace that never started a plan reads "No plan yet" under Current
Plan, with "Choose how to start" over the cards, instead of
"Starter incomplete".

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

* fix(demo): write over what a new brand's triggers made

A brand just created isn't empty: its insert trigger starts Getting started,
so skipping every clear on a first build made the Action Center's insert hit
getting_started_pkey. An in-place module now always writes over by key (the
first build only skips reading back and pruning); a module that isn't
rebuilt in place clears its own tables just before it is built, on a first
build too, alongside the other modules rather than all up front.

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

* perf(demo): clear the other modules' tables alongside the core on a first build

Nobody looks at a demo being built for the first time, so every module not
rebuilt in place starts clearing what the new brand's triggers made at once,
while the core writes, instead of each in turn later, when its deletes queue
behind the rollups. A rebuild still clears each module just before it is
built, so its old rows stay on show as long as they can.

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

* feat(demo): build a new workspace's demo brand while onboarding goes on

As soon as onboarding has the organization (step 2 on a new account, at
once on a resume), an admin of a workspace without a plan and without a
demo brand starts its setup in the background (wantsDemoAhead +
usePreloadDemo): the first build takes a few seconds, the topics, prompts
and competitors steps longer, so "Explore the demo" on the plan step opens
at once. The plan step's own preload stays. The resume step now reads the
person's own brand only (is_demo false): the demo brand may exist by then.

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

* feat(demo): show the demo being prepared, step by step, while it builds

"Explore the demo" and "See the demo" open the demo at once when its setup
is done. While it is still being prepared, a setup screen (DemoSetupDialog)
shows what the server writes, in its order, as the Content Agent's card
shows a run: the steps done with a check, the one under way with the
agent's sweep and dots and its count going up (720 sample answers from 6
platforms, 2,694 sources, 18 pages audited, 9 actions, 10 opportunities, 2
reports: the generator's own counts). It starts from where a setup asked
ahead already is (demoPreparation), holds on the last step until the
answer comes, then runs through the rest quickly and opens the Action
Center. A failure says so in the screen, with Try again and Close; closing
it lets the setup finish in the background. Counts show whole at once with
reduced motion; the sweep and dots stop. StepSweep moves to components/ui,
shared with the editor's agent card.

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

* fix(demo): drop the Chat preview's own copy of the app menu

The Chat preview sits beside the app's left menu; the mockup's icon rail
(and the governance and signature screens' app menus) showed the same menu
twice, so the demo copies hide them.

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

* feat(demo): replace a table's rows whose ids the database gives

A table with an identity id and no other unique columns (ai_bot_events)
can't be written over by key. write(table, rows, { generated: true })
inserts the new rows and, on a rebuild, deletes the brand's rows that were
there before right after: never empty, both there for a moment.

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

* perf(demo): rebuild the Action Center, Content, suggestions and reports in place

The four workflow modules write through the build's writer (ctx.write):
each step's independent tables side by side, and on a rebuild over their
old rows by key, deleting only what isn't written again, so their pages
never empty while the demo is rebuilt. Keys where a row has no id:
getting_started (brand_id, also what a new brand's trigger made),
getting_started_steps, action_signals, the cluster members, searches and
scopes, and the plan marks; the action and cluster children are found
through their parent (scopes).

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

* test(demo): pin the build order with gates instead of timers

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

* perf(demo): rebuild AI traffic, Site Audit and the catalog in place

The three site modules write through the build's writer (ctx.write): their
independent tables side by side (traffic's thirteen at once, a visit before
its pageviews), and on a rebuild over their old rows by key, deleting only
what isn't written again, so their pages never empty while the demo is
rebuilt. Google Analytics and Search Console rows are keyed by their day and
what they count (their unique columns, as their syncs write them), the
audits' signals by audit and signal (found through their audit), the
single-row settings by brand. ai_bot_events has an identity id and no other
key: its rows are replaced, the old ones deleted right after the new are in.
site-common's insertRows goes.

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

* perf(demo): refresh the demo's mention rollups beside its answer terms

refreshMentionsDaily takes `together`: the rollups (refresh_mentions_daily)
and the answer terms (refresh_mention_terms) take their own locks and write
their own tables, so the demo runs them side by side instead of one after
the other, a second off the longest step of its build. The nightly run
keeps them in turn.

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

* feat(demo): move the Chat preview's inbox into the chat menu and add archived chats

Home keeps the composer in view: Inbox gets its own screen in the chat
menu, the skill cards are shorter with the description on hover, Home to
Files fold under a Menu header, and All chats has Active/Archived tabs.

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

* feat(demo): show Brewline Coffee in the Chat preview, raise its Home and add skill creation

The preview now tracks the demo brand: its pages, rivals, prompts and
sources come from the demo data, and Ansvisor stays only where it names
the product. Home starts higher with more room above the composer, both
cards say when their change happened, One win lists its citations, and
Create a skill opens the chat, upload and URL import flows from CHAT-13.

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

* fix(web): name the profiles→organizations relationship so the plan check reads again

The read-only check before every write embedded organizations from
profiles without naming the relationship. A second foreign key between the
two tables made the embed ambiguous, so the check failed and every write
returned 500 for every workspace, active plans included. Same fix for
getMyProfile.

(cherry picked from commit 62eb7b7658388c1614b38dea93fbe316b8910311)

* test(web): read the demo brand's plan check with the named relationship

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

* feat(billing): start a plan from one choice that fits on one screen

The plan dialog, Settings › Billing with no plan active and onboarding's
plan step now share the same start flow (components/billing/plan-start):

- One choice above the cards: 14-day trial / Monthly, 50% off the first
  month / Yearly, Save 20%. Each card then has one button, one "Due
  today" line (the trial says when it ends and what follows, "Free until
  Nov 11, then $49/month") and "Secure checkout with Stripe · Cancel any
  time" beside the button. The promo code field sits behind "Have a
  code?".
- The first-month offer shows from the first frame, from the config: no
  $49 → $24.50 jump once Stripe answers. A code Stripe can't redeem takes
  it away; one that couldn't be checked keeps it as configured.
- Onboarding's plan step drops its own copy (PLAN_STEP_COPY) for the
  shared cards and Billing's features, with the discounted price large,
  and says what is ready to track for the brand, from its real prompt,
  topic and competitor counts.
- Everything fits 1024×768 and up without scrolling: the plans' features
  open behind "Show plan details" inside the cards, which keep their
  height; on Billing the plan choice comes first while no plan is active.
- A Checkout that doesn't open (Stripe down or not set up, no answer in
  30 s, a refusal) says why by the plan's button instead of spinning.

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

* feat(demo): name the workspace's own brand in the demo band and plan dialog

On the demo brand the band says "Start tracking Acme Coffee with a
14-day free trial…" and, with a plan active, "Switch to Acme Coffee"; the
plan dialog's demo and new-brand pitches name the brand too. Before the
workspace has a brand of its own, the general wording stays.

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

* fix(demo): wait for the brand on screen before showing a page or a band

In a new browser the brand store starts empty until BrandLoader puts the
layout's brands in it, just after the first render. Until then BrandGuard
read the empty list as "No brands yet", the read-only band showed the
workspace's own state before the demo brand's band, and the brand switcher
offered Add Brand. The store now says when it holds the server's list
(loaded, never persisted); pages wait on the skeleton, the read-only band
and Add Brand wait for it, and leaving the dashboard clears it.

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

* fix(demo): keep the nightly prompt demand read off demo brands and cover main's new tables

sweepPromptDemand chose brands by their organization's plan only, so an
active workspace's demo brand would have had its sample prompts read and
DataForSEO's paid tasks set for them. It now leaves demo brands out, as
the other sweeps do. The demo coverage list names the two brand tables
main added: prompt_table_views (skipped: the demo starts on the default
columns) and prompt_demand (pending a demo follow-up).

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

* fix(demo): refuse main's new write routes on a demo brand and keep column layouts open

Main added write routes that name a brand: Action Center's audits and
products, WordPress and Framer connections, and their publish-status
checks. Each now answers 402 demo_brand on a demo brand, as the Webflow
ones do. The Tracked Prompts column layouts (prompt_table_views, 00363)
stay writable on a demo brand: they change no sample data and cost
nothing, and the web keeps them open while read-only too.

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

* feat(demo): follow the app's dark theme in the Chat preview

The preview reads the app's .dark class from its parent page and follows it live; standalone it follows the system setting. Its colours moved to variables with a dark palette close to the app's.

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

* fix(demo): check a topic write once, with its brand, now that the check comes first

Merging main left createTopics, createTopic and updateTopic with two
plan checks each: main's, moved ahead of the name check, and the demo's,
which hands the brand over. Each now checks once, first, with its brand
where it has one.

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

* feat(demo): answer the Chat preview's shortcuts from anywhere on its page

⌘ or Ctrl with ⇧O (new chat), K (search), J (side panel) or \ (menu)
reach the preview while the app around it has the focus: the page hands
them to the frame, which answers them as it does inside. The frame takes
the focus when it opens, and on a Mac the preview shows ⌘ for Ctrl.

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

* fix(demo): keep the competitor timeline off demo brands and cover main's new tables

sweepCompetitorTimeline (learning C3, on main) chose brands by their
organization's plan only, so a demo brand's sample answers would have had
their cited pages read every night. It now leaves demo brands out, as the
other sweeps do. The demo coverage list names the brand tables main added:
cited_page_features, competitor_page_events and competitor_timeline_scans
(pending a demo follow-up) and chat_conversations (with Chat).

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

* feat(chat): read a call's demo flag from brands.is_demo

Chat's precedence (#1776) left readBrandIsDemo false until the demo chain
added brands.is_demo, with a type check that stops compiling once the
column exists. It now reads the column, as the server's demo guard does,
so a tool that changes or spends on the demo brand is refused with
demo_brand; a brand that isn't found isn't one, and a failed read throws.

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

* fix(demo): guard the brand site type detection on the demo brand

POST /brands/:id/detect-site-type (#1761, on main) reads the brand's home
page and may ask AI for its kind. The demo guard's coverage test fails on a
write route in neither list, so it is now guarded by the brand in its path.

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

* fix(demo): name main's new Chat tables in the demo write guard's lists

chat_user_prefs (00400) and chat_auto_choices (00401) are a person's own
rows, not a brand's: the write guard's coverage test fails on a writable
table in no list, so both are named as no brand's rows.

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

* fix(mcp): refuse main's new write tools on the demo brand

approve_task_review, dismiss_task_review (#1713) and
mark_content_draft_published (#1715) write a brand's data, and the demo
gate's test fails on a write tool WRITE_TOOL_BRANDS doesn't name. A task
review finds its brand through its action; a draft through its own row.
The test's API key now carries the role main's McpAuthContext requires.

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

* fix(mcp): refuse the demo brand on the REST mirrors that write, as their tools do

The tools refused a write on the demo brand in their gate, but the REST
mirrors call the same data functions with no gate in front, and those write
with the service role. Each mirror that writes now asks demoBrandRefusal with
its tool's name and arguments first, and answers 402 demo_brand. A test fails
on a REST write route that checks neither this nor a data function that
refuses the demo brand itself.

* fix(mcp): refuse the demo brand on the REST mirrors of main's new write tools

The task review approve and dismiss routes and the draft published route
call demoBrandRefusal before their data functions, as their tools do. The
routes test's auth carries main's role, and the notes that waited for
this part say where the demo brand is refused.

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk added a commit that referenced this pull request Oct 29, 2026
…and, part 7) (#1740)

* feat(web): let a workspace whose plan ended browse read-only, with one "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]>

* feat(billing): show the plans in the read-only dialog, with Monthly or Annual and a promo code

The "Choose a plan to keep going" dialog for an ended plan now carries
the plans, as the approved design has them.
- Starter and Growth (Popular) have "Choose {plan}"; Custom has "Starting
  at $499/mo" and "Contact us". Each lists the Billing cards' features,
  through a shared usePlanFeatures.
- Monthly or Annual ("Save 20%"): an annual price shows its struck 12×
  price and what it is a month.
- A promo code is checked by the API (POST /api/stripe/promo-code, admins
  only), through the same Stripe lookup #1300 uses (findPromotionCode,
  takesPromoCode: monthly plans only).
  - A valid code shows its chip, the first month's price on each card and
    in the button ("Choose Growth · $124.50 today").
  - A bad one says so; on Annual a note offers Switch to Monthly.
- Choose opens Stripe Checkout for that plan and period, with the code
  applied as a discount. The checkout route checks the code again and
  refuses it on an annual plan.
- Members see "Ask your admin to choose a plan", with no code field.
- The footer reads "Prices in USD." with a link to the pricing page.
- A failed payment keeps its "Update payment method" dialog.

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

* fix(billing): word the dialog's custom AI usage "from 10x", as Billing does after #1598

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

* feat(web): open the plan dialog from the Prompts area's actions while 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]>

* feat(web): open the plan dialog from the content area's actions, and 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]>

* feat(web): open the plan dialog from the remaining areas' actions, and 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 (#1606) and Content (#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]>

* feat(web): refuse direct database writes from a workspace whose plan has ended, on the server

Server actions and Next routes that write to Supabase without going
through the API now call assertWritable() first: on the cloud, an
organization without an active plan gets SubscriptionInactiveError
(routes: 402 subscription_inactive), so the read-only rule holds even if
a guarded button is bypassed. Setup's writes stay open to an
organization that never subscribed, as the API's onboarding routes do.
Profile, invitations accepted, revokes, removals, API keys and billing
stay open. A static test pins every writing action to the check or to
the open list.

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

* fix(web): keep removing members, revoking invitations and disconnecting 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]>

* fix(web): open the plan dialog from Add Brand at the plan's brand limit 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]>

* feat(web): let a read-only workspace delete a brand

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 #1611.

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

* fix(web): keep setup's Shopping mode working for a new workspace, read the plan in one query, and pin the write check's place

From the pre-push review: markBrandAsEcommerce no longer goes through
the strictly guarded setBrandShoppingMode (a shared applyShoppingMode
does the writes), so a setup detected as e-commerce turns Shopping on
again. assertWritable reads the profile and its organization in one
query. The coverage test now requires the check as each writer's first
await, sees writers kept in variables and signed upload URLs, refuses a
setup-open function that reaches a strictly guarded one, and keeps brand
deletion open (Ansvisor, 2026-10-27). main's saveDraftShoppingPath is
guarded; catalog-client's every-code test leaves out 'subscription',
which opens the plan dialog instead of a message.

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

* 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

With #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]>

* fix(web): keep a saved content suggestion reachable, the Starter bot 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]>

* fix(web): leave the plan dialog's store error out of the every-code message test

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

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

* fix(web): open the plan dialog from Merchant Center, category pages and main's other new actions while the plan has ended

main's new writes, with C3's guard pattern and labels:
- Merchant Center (#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 (#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 (#1591): Pick from the catalog, Pick again, Add
  product, Lock, Swap and Remove are guarded.
- Action Center Check now (AC-010, #1565) is guarded.

New labels: changeCategoryPages, changeShoppingPath, checkTasks.
Insert › Products (#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 (#1610) change through the rules hook, already guarded.

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

* fix(web): check the plan inside Merchant Center's Add, not by wrapping 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]>

* test(web): keep brand setup's limits in the new brand page test's mock

main's new brand page now reads BRAND_SETUP_LIMITS from ai-brand-setup
(#1661), which the test's mock left out.

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

* feat(demo): open the plan dialog with the demo's offer on a demo brand

The selected brand being the organization's demo brand (brands.is_demo,
sample data) locks the dashboard as a read-only workspace is locked, with
its own reason: guarded actions open the plan dialog with the demo's offer.
A workspace that never subscribed is offered the free trial, then 50% off
("Start free trial"); one whose plan ended gets 50% off its first month
("Choose {plan}"). The label names what was clicked as something that
works on your own brand, and an admin finds SAVE50 applied (quietly left
empty when Stripe refuses it). With a plan active, the dialog points back
to the workspace's own brand; a payment being retried still asks for the
payment method. The server's 402 demo_brand opens the same dialog.

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

* feat(demo): show a band across the dashboard while the demo brand is open

Where the read-only band sits, and instead of it: "You're exploring
{brand}, a demo brand with sample data", with a small button to the plan
dialog's offer ("Try it on your brand · 50% off" for a workspace that never
subscribed, "Use it for your brand · 50% off" once its plan ended), or back
to the own brand while a plan is active. The band asks the API once per page
load to bring the demo brand up to date (POST /api/demo) and reads the
pages again when its sample data was written anew, so the demo follows the
product by itself.

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

* feat(demo): add a demo brand per organization, kept out of the plan's counts

Migration 00380 adds brands.is_demo, demo_version, demo_built_at and
demo_hidden_at, one demo brand per organization (partial unique index) and
policies that let members read it but never insert, change or delete one.
The plan's prompt-location quota, the usage cards' account totals and the
web's brand limit leave the demo brand out; the health report's fan-out
share leaves out its answers. The brand delete route refuses it: the demo
brand is hidden, not deleted.

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

* feat(demo): skip demo brands in every nightly sweep and job

The daily tracking list, the job claim and recovery (activeBrandFilter /
isBrandActive), the signal catch-up, the pulse, the task writer, executor
and checks, action validation and Improve outcomes, the Insights sweep,
brand facts, Search Console and Analytics syncs, page opportunities, the
traffic digest, auto-audits, catalog feeds, Webflow status and volume
analysis all leave demo brands out: their data is sample data and nothing
may track, write or spend for it.

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

* feat(demo): mark the demo brand in the brand switcher, with Show or Hide

The demo brand reads "Demo · sample data" under its name, in place of a
domain, and a brand of a workspace that never had a plan reads "Not tracked
yet". For an admin or a manager, the menu ends with "Hide the demo brand"
(PATCH /api/demo), or "Show the demo brand" once it is hidden, which brings
it back and opens it: the demo brand is hidden after a purchase, never
deleted. A hidden demo brand stays out of the dashboard's brand list and
the brands page, and the demo brand never counts toward the plan's brands,
there or when a brand is added.

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

* feat(demo): show Chat as coming next week on the demo brand, with its v2 preview

On the demo brand, the menu's Chat item carries "Soon (next week)" in its
badge, ahead of "Set up" (the badge rule now lives in dashboardNavBadge, for
the sidebar and the mobile menu alike), and /dashboard/agent shows the Chat
v2 mockups themselves in a full-height frame, opening on Home, under a thin
line that Chat arrives next week. The five mockup files are copied as they
are into public/demo/chat (about 720 KB), outside Prettier's scope. On any
other brand, Chat is unchanged.

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

* feat(demo): show the demo brand's integrations connected, and those to come as coming soon

On the demo brand, Settings › Integrations shows the real cards with the
demo's states, kept in one list (lib/demo/integrations.ts): Google Search
Console, Google Analytics and Webflow as connected, the way they look with
a live connection, marked "Sample data", the demo brand mapped to a sample
property and Webflow sending to a sample collection, with nothing read from
the API or Composio and no set-up lines. Disconnect and Replace token open
the plan dialog. Merchant Center shows Coming soon on its own card, and
Shopify, WordPress, Framer and Wix, which have no card yet, a Coming soon
row in their group. When one goes live, its line in the list turns
connected.

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

* feat(demo): build the Brewline Coffee demo brand's core data

lib/demo/ builds an organization's demo brand in its own brands: Brewline
Coffee (brewline.example) with fictional `.example` competitors and
publishers, 12 prompts in 3 topics, 6 engines and a run every 3 days over
a month (720 short answers) with citations, product cards, searches and
volumes. Answers are raw engine responses run through tracking's own
parseScraperResponse, parseResponse and the result and shopping card rows
(now pure resultRow and shoppingCardRows in cloro-result-handler.js), and
the rollups are rebuilt by the nightly run's own functions.

ensureDemoBrand creates it, rebuilds it in place (same ids) when
DEMO_VERSION moves on or its data is three days old, and leaves it alone
otherwise; concurrent visits share one build (one-per-org index, a
compare-and-set claim, a lease). Modules are { name, tables, build }, and
a coverage test fails on any brand_id table the demo neither builds nor
lists as skipped or pending.

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

* feat(demo): open and hide the demo brand through /api/demo

POST /api/demo creates or rebuilds the organization's demo brand for any
member and returns { brandId, version, rebuilt }; PATCH /api/demo
{ hidden } hides or shows it for admins and managers ({ brandId, hidden },
404 no_demo without one). Both stay open once a plan has ended.

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

* feat(demo): let a workspace with no plan explore the demo brand

Onboarding's plan step gets a second way in under the plan cards: "Not
ready to add a card? Explore a demo brand", whose button makes the demo
brand (POST /api/demo), selects it and opens the Action Center, the
person's own brand kept as set up. An admin who never subscribed used to be
sent back to that step from the dashboard; with a demo brand in the
organization, they now browse read-only instead (evaluateSubscriptionAccess
takes hasDemoBrand). The read-only band of an ended or canceled plan gets
"See the demo", for an admin or a manager, or anyone once the demo brand is
listed: the same flow, which shows a hidden demo brand again. The plan
step's preview reads the own brand, never the demo brand.

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

* feat(demo): offer the free trial on the own brand of a workspace that never had a plan

A workspace that never subscribed now gets the trial offer on its own
brand too, not only on the demo brand: the read-only band says the brand
isn't tracked yet ("Start your 14-day free trial, then get 50% off your
first month") with Start free trial for admins, and the dialog's title is
"Start your 14-day free trial: then 50% off your first month", with SAVE50
applied and Start free trial on each plan. Members are asked to have an
admin start it. ChoosePlanDialog takes the offer as a `pitch` (from the
demo brand, or the own brand).

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

* feat(demo): show what is paid today on the demo's first-month offer

With SAVE50 applied, the demo's 50%-off-first-month offer words its
buttons as the plan dialog does everywhere else: "Choose Starter · $24.50
today"; "Choose {plan}" alone when the code didn't apply.

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

* feat(demo): say the demo brand is hidden, not deleted, in its Danger tab

On the demo brand, brand settings' Danger tab says "The demo brand can't
be deleted; hide it from the brand menu instead." in place of the name to
confirm, and Delete brand stays disabled. The server refuses the delete
too.

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

* feat(demo): cancel a demo brand's jobs as demo_brand, not as an ended plan

A job claimed for a demo brand ("Run now", the internal trigger, a retry
or the recovery) was cancelled as subscription_inactive, as if the plan had
ended. It now says demo_brand: brandStopReasons tells why no work may start
for a brand, and activeBrandFilter is built on it. Nothing is tracked,
generated or counted before the cancel: the on-demand cap counts the
brand's own jobs, and AI usage is recorded by the workers, which never run.

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

* feat(demo): refuse the web app's own writes on the demo brand

assertWritable takes the brand an action writes for and refuses the demo
brand (DemoBrandError, digest demo_brand), whatever the plan, reading the
brand beside the plan through the person's session. Every gated server
action that takes a brand id hands it over (52 of them, the brand's own id
in updateBrand); actions that name no brand, such as the profile or the
organization, read nothing more. A route's refusal answers 402 demo_brand,
and the browser reads the digest as it reads subscription_inactive: an
uncaught refusal opens the plan dialog. The read-only coverage test now
also fails a gated action that takes a brand id without handing it to the
check.

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

* feat(demo): refuse writes and costs on the demo brand with 402 demo_brand

The demo brand's data is sample data, so nothing asked of it may change it
or start a cost. A middleware after decodeToken (before the plan's check,
so the answer is the same with a plan or without) refuses every write that
names a demo brand: in the path, the body, the query, or through the row it
acts on (a draft, an opportunity, a prompt, a task...). Every write route
under /api is named, guarded or open with its reason (onboarding, the
organization's own integrations, stopping work, the demo routes, brand
delete's own 409); a test reads the route files and fails on one that
isn't. Reads and exports stay open; brand facts are read only as kept on a
demo brand, so its site is never fetched.

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

* docs(demo): explain the demo brand, and keep it covered in CONTRIBUTING

A new guide, Demo brand, covers:
- who sees Brewline Coffee: a sign-up without a card, a workspace whose
  plan ended, everyone once it exists;
- what it shows: the live product with fictional sample data on `.example`
  domains, Chat as Soon, integrations with sample data;
- what it can't do, and the offers the plans dialog makes from it;
- hiding and showing it, never deleting it;
- how it stays current: DEMO_VERSION, the 3-day rebuild, the 14-day
  clear-out;
- that it's an Ansvisor Cloud feature.

The FAQ gets "Can I try Ansvisor without a card?".

CONTRIBUTING: a migration that adds a brand-scoped table says what the demo
shows for it (a module under server/src/lib/demo/, or SKIPPED in
coverage.js with the reason); a change to the demo data's shape bumps
DEMO_VERSION.

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

* feat(demo): hide the demo brand once a plan is bought

When a subscription starts (Stripe's checkout.session.completed, trial
included, and the return from Checkout, whichever comes first), the
organization's demo brand gets demo_hidden_at, through the service role:
hidden, never deleted. Only a demo brand still shown is touched, and
subscription updates, renewals and payments never touch it, so one an admin
shows again stays shown. A first payment still open hides nothing, and a
failed write never fails the purchase. Hidden before the dashboard opens,
the demo brand leaves the brand list, so the person lands on their own
brand.

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

* feat(demo): refuse people's writes to a demo brand's rows in the database

Members can write a brand's rows straight through Supabase, under RLS,
past the API's 402. Migration 00381 adds refuse_demo_brand_writes(), a
BEFORE INSERT/UPDATE/DELETE row trigger that raises 42501 'demo_brand' for
a demo brand's row unless the role bypasses RLS (the service role the
server and the demo generator write with). It is attached to the 24 tables
people can write that carry a brand_id, and, through their parent row, to
the 13 that reach their brand another way (prompts through prompt_sets,
prompt notes and target URLs through prompts, a draft's inputs and sources
through content_drafts, tasks and events through actions...). A test reads
the policies and triggers from the migrations and fails on a table people
can write that belongs to a brand and lacks it.

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

* feat(demo): refuse the MCP's brief, audit and Improve endpoints on a demo brand

The internal endpoints the MCP calls (a content brief, a Site Audit, an
Improve action) trust CRON_SECRET and never meet the API's middleware.
Each now answers a demo brand with 402 demo_brand before it calls the
model, starts an audit or writes an action; the MCP relays the message.

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

* feat(demo): clear demo brands nobody opened for two weeks, nightly

Every organization gets a demo brand, so its sample rows would pile up
for workspaces that left. The daily run now clears the data of demo brands
built over 14 days ago (a visit rebuilds every few days, so these weren't
opened since), 200 a night at most: through clearDemoData, the path a
rebuild takes, so rows go in the modules' reverse order. The brand row
stays with no version and no build time, and the next visit builds it
again in place, with the same ids. The clear holds the brand as a build
does, so a visit at the same moment waits for it.

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

* test(demo): look rows up by a set in the demo guard's fake database

The cache test reads 10,000 brands; filtering them with includes() took
seconds and timed out under a full run.

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

* feat(demo): build the demo brand's Action Center, Content, suggestions and reports

Four demo modules over core's answers: signals and a month of actions
(tasks, trail, measured outcomes, a task waiting for review, ready-made
KPIs, Getting started with its page steps opened), prompt clusters,
content opportunities, Editor drafts and Plan marks, prompt, topic and
Improve suggestions, and two saved reports. Numbers are counted from the
demo's own answers; shapes come from the engine's own functions. detect.js
exports single and promptTarget so the demo writes signals in their shape.

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

* feat(demo): register the workflow modules and rebuild demos at version 2

DEMO_MODULES runs core, suggestions, actionCenter, content and reports;
DEMO_VERSION 2 rebuilds existing demo brands on their next visit. The
coverage lists move the workflow tables to built, skip the engine's
internal queues and logs and the org-level author default, and leave the
draft shopping check to demo-site with the catalog.

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

* refactor(audit): read a page already fetched into the audit context with auditContextOf

buildAuditContext fetches the page, robots.txt and llms.txt, then hands
them to auditContextOf, which parses the HTML once and extracts its text
as before. A page that isn't fetched (the demo brand's) is read exactly as
a fetched one.

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

* feat(demo): build the demo brand's AI Referral Traffic over a quarter

Brewline's website (site-world.js) and its traffic: 90 days of Google
Analytics as GA4 reports mapped by ga-sync.js (AI sessions by source and
page, ChatGPT Shopping's feed visits, pages, channels, items), Search
Console's query and page rows mapped by gsc-sync.js, four weeks of snippet
visits (a removed guide's 404s for Broken AI links) and journeys made by
traffic-events.js's eventRow, a month of AI crawler counts with a
Cloudflare Worker connection whose secret hash matches no secret, and the
page opportunities detectPageOpportunities finds in them. The brand maps
the sample GA4 and Search Console properties and has conversions on.

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

* feat(demo): build the demo brand's Site Audit from the audit engine's own verdicts

Brewline's pages are rendered as HTML round by round and scored by
runSignals and scoreAudit: six key pages audited three times as fixes
land, every page in the latest auto-audit. The model-judged signals,
Wikidata's brand entity and the recommendations are written in the shapes
those steps store. The page inventory goes through selectPages and
parseHead, site trust through site-trust.js's checks (4/5: no editorial
policy), and the brand facts through factText and keptFacts.

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

* feat(demo): fill the demo brand's catalog from its product feed

A Google XML feed of 22 products read by the feed parser and kept as
catalogRecords and hashOf keep them, with stable demo ids: a removed
seasonal blend, an out-of-stock size, a sale, no images. The products the
demo's AI answers show as cards are the same page, title and price. Two
categories get their page by hand; the rest match their collection pages.

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

* feat(demo): classify the demo's fan-out searches ahead in the intent cache

The demo writes the intent of each search its answers ran into
fanout_query_intents, keyed as the route keys it (normalizeIntentQuery,
moved to intent-extraction.js), adding only what the shared cache lacks,
so Query Fan-out never needs a model for the demo.

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

* feat(demo): build traffic, Site Audit, the catalog and fan-out intents with the demo brand (version 3)

The demo-site modules join the core in DEMO_MODULES, and DEMO_VERSION is
3, so every demo brand is rebuilt with them on its next visit. Their
tables leave the coverage test's pending list; a CMS connection, sent
drafts, product images and Merchant Center item issues are skipped, with
why.

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

* test(demo): audit the demo's pages once more, not twice, to check its rows stay the same

One rebuild for another brand two days later checks both that only the
ids and dates change, with room past the default 5 s on a busy machine.

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

* feat(demo): read the demo brand over MCP, and write, run or spend nothing on it

The MCP tools run in the web app, so the API's demo_brand refusal didn't
reach them. Now, on Ansvisor Cloud, every tool that writes, runs or spends
answers the demo brand with the web app's DEMO_BRAND body. That happens
whatever the plan, and before the read-only check, in gateWriteTools.
- lib/mcp/demo-gate.ts names how each of the 14 tools finds the brand it
  acts on: a suggestion, opportunity, task, prompt, answer or draft read
  back to its brand.
- A test fails on a new such tool until it is added there.
- Reading stays open.

The costly calls also refuse it inside their data functions, beside
assertSubscriptionActive, so their REST routes (402 demo_brand) and the
in-product agent do too: a brief, a Site Audit, an Improve action.

list_brands marks the demo brand (is_demo) and leaves it out once the
organization hid it, and its description tells the agent what that means.

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

* feat(demo): give the demo brand its own logo

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

* fix(web): read a new sign-up's free plan as Starter's

A new sign-up's organization holds plan 'free' until it picks one. With the
demo brand it reaches the dashboard, where PLANS[planId].limits threw on the
Prompts page. toPlanId maps an unknown plan to Starter's.

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

* feat(demo): give the demo's made-up sites real-looking logos

.example is reserved, so no favicon service knows the demo's brand,
competitors or cited sites. Their logos ship in public/demo/logos; any
other .example site gets a letter mark, so no page asks Google for one.

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

* feat(billing): offer two ways to start a plan: buy now at 50% off the first month, or the free trial

Every plan choice now offers two ways to start, each with a card. Buy now
bills the full plan from day one, with the first-month offer on a monthly
plan ("$24.50 first month, then $49/month", a Limited offer mark); a year
up front is the plain "Choose {plan}". The 14-day free trial comes without
the offer, with limited AI usage ("Free for 14 days, then $49/month"), and
only for an organization that never had a subscription. Checkout takes the
way explicitly (mode: 'buy' | 'trial'): buying never starts a trial, the
trial takes no promotion code and is refused (409 trial_unavailable) to an
organization that had a subscription, and both collect a card. The offer
is one setting, FIRST_MONTH_OFFER in config/plans.ts, turned off with
NEXT_PUBLIC_FIRST_MONTH_OFFER=off; its code no longer redeemable falls back
to the plain price.

The plan dialog (demo, a brand not tracked yet, a plan that ended), the
demo band and the "not tracked yet" band ("Start a 14-day free trial, or
get 50% off your first month." with See plans) and onboarding's plan step
("Choose how to start", two buttons per plan, the demo card below) say it
this way; the "14 days free, then 50% off" wording is gone. Billing's
Checkout for a plan that ended buys now.

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

* feat(demo): start the demo brand's setup ahead, where the demo is offered

The demo brand's first setup takes a while, and "Explore the demo" waited
for all of it. Onboarding's plan step, for an organization with no demo
brand yet, and the read-only band's "See the demo", for an admin or a
manager with none yet, now start POST /api/demo in the background once, as
they show (failures stay quiet). The click waits for that same request,
done at once when it is (prepareDemoBrand, asked once per page, again
after a failure), and its button says "Setting up the demo…" meanwhile.

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

* docs(demo): say how a plan starts from the demo: buy now, or the free trial, both with a card

The pricing changed. Each plan now starts one of two ways, both with a card:
- Buy now: the full plan from day one, 50% off the first month on a monthly
  plan while the offer runs.
- The 14-day free trial: limited AI usage, no discount, only for a
  workspace that never had a plan.

A workspace whose plan ended can buy now.

The demo brand guide and the FAQ say so. "14 days free, then 50% off" is
gone, and the sign-up step is "Choose how to start". The demo brand is
hidden when a workspace first starts a plan.

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

* fix(billing): show the first-month offer when its code can't be checked

Stripe unreachable, or not set up on a local server: the plan dialog still
shows the configured offer; checkout applies the code and says so by the
field if Stripe turns it down.

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

* perf(demo): build the demo's modules side by side after the core

The first module lays down what the others point at; the rest write their
own tables together, each after the module it names in `after`.

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

* feat(demo): tell Chat's preview story with Google AI Overviews

The Chat preview's running example (citations that dropped, why, and the
fix) now follows Google AI Overviews instead of Perplexity. Engine lists,
the logo map and the mockup's own matching rules are unchanged.

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

* feat(demo): show Chat preview's citation changes as small pills

Since you left's drop and win were big bold numbers with ▼/▲; they are now
small pills with a thin arrow on a soft red or green ground.

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

* feat(demo): show the demo brand with Growth, the whole product

While the demo brand is the brand on screen, the plan context reads
Growth whatever the workspace's plan (or none): Product Visibility and
the AI bot report open, every engine shows in the Positions panel and
column, and the Growth marks go. One rule, effectivePlanIdForBrand,
feeds the client's plan context and the server actions' position
reads. Billing keeps reading the organization's own plan (ownPlanId).
Writes and costs are unchanged: on the demo brand they still open the
plan dialog.

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

* fix(billing): show the first month's price once on the plan dialog's cards

With the first-month offer, the card's price already reads "$24.50 first
month, then $49/mo"; the same line under Buy now said it again. Only
"Full plan from day one" stays there, beside the free trial. The
upgrade dialog's test now answers the offer's code check itself, so it
no longer depends on the network to read "Choose Starter".

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

* perf(demo): build the demo faster and rebuild it over its old rows

A first build no longer clears 70 empty tables, and the core writes each
step's independent tables side by side through a shared queue of four
statements (write.js: insertChunks, demoWriter). Its rollups move to a
refresh step that runs alongside the other modules, Insights, Citations and
Mentions together, the month's answer terms in one call (refreshMentionsDaily
takes an optional termDays). The core alone went from about 17 s to 7 s on
the dev database.

A rebuild (new DEMO_VERSION, or data older than three days) no longer
deletes the demo first: an `inPlace` module writes over its rows by key
(ids are deterministic) and deletes only the rows it didn't write again,
then rebuilds the rollups over the old and new days, each refresh call
rewriting its days in one statement. Someone opening the demo meanwhile sees
last week's data, not empty pages. Modules not marked `inPlace` still have
their tables cleared, now just before they are built.

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

* feat(billing): start a plan from Billing the way the plan dialog does

With no plan active, Settings › Billing's cards now offer the plan
dialog's ways to start: Buy now, at 50% off the first month on a monthly
plan while the offer runs, and, for a workspace that never had a plan,
the 14-day free trial. A plan that ended gets Buy now alone. The cards'
price and buttons, the first-month code check and Checkout are one set
of parts (billing/plan-start.tsx) that the dialog and Billing share.

A workspace that never started a plan reads "No plan yet" under Current
Plan, with "Choose how to start" over the cards, instead of
"Starter incomplete".

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

* fix(demo): write over what a new brand's triggers made

A brand just created isn't empty: its insert trigger starts Getting started,
so skipping every clear on a first build made the Action Center's insert hit
getting_started_pkey. An in-place module now always writes over by key (the
first build only skips reading back and pruning); a module that isn't
rebuilt in place clears its own tables just before it is built, on a first
build too, alongside the other modules rather than all up front.

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

* perf(demo): clear the other modules' tables alongside the core on a first build

Nobody looks at a demo being built for the first time, so every module not
rebuilt in place starts clearing what the new brand's triggers made at once,
while the core writes, instead of each in turn later, when its deletes queue
behind the rollups. A rebuild still clears each module just before it is
built, so its old rows stay on show as long as they can.

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

* feat(demo): build a new workspace's demo brand while onboarding goes on

As soon as onboarding has the organization (step 2 on a new account, at
once on a resume), an admin of a workspace without a plan and without a
demo brand starts its setup in the background (wantsDemoAhead +
usePreloadDemo): the first build takes a few seconds, the topics, prompts
and competitors steps longer, so "Explore the demo" on the plan step opens
at once. The plan step's own preload stays. The resume step now reads the
person's own brand only (is_demo false): the demo brand may exist by then.

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

* feat(demo): show the demo being prepared, step by step, while it builds

"Explore the demo" and "See the demo" open the demo at once when its setup
is done. While it is still being prepared, a setup screen (DemoSetupDialog)
shows what the server writes, in its order, as the Content Agent's card
shows a run: the steps done with a check, the one under way with the
agent's sweep and dots and its count going up (720 sample answers from 6
platforms, 2,694 sources, 18 pages audited, 9 actions, 10 opportunities, 2
reports: the generator's own counts). It starts from where a setup asked
ahead already is (demoPreparation), holds on the last step until the
answer comes, then runs through the rest quickly and opens the Action
Center. A failure says so in the screen, with Try again and Close; closing
it lets the setup finish in the background. Counts show whole at once with
reduced motion; the sweep and dots stop. StepSweep moves to components/ui,
shared with the editor's agent card.

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

* fix(demo): drop the Chat preview's own copy of the app menu

The Chat preview sits beside the app's left menu; the mockup's icon rail
(and the governance and signature screens' app menus) showed the same menu
twice, so the demo copies hide them.

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

* feat(demo): replace a table's rows whose ids the database gives

A table with an identity id and no other unique columns (ai_bot_events)
can't be written over by key. write(table, rows, { generated: true })
inserts the new rows and, on a rebuild, deletes the brand's rows that were
there before right after: never empty, both there for a moment.

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

* perf(demo): rebuild the Action Center, Content, suggestions and reports in place

The four workflow modules write through the build's writer (ctx.write):
each step's independent tables side by side, and on a rebuild over their
old rows by key, deleting only what isn't written again, so their pages
never empty while the demo is rebuilt. Keys where a row has no id:
getting_started (brand_id, also what a new brand's trigger made),
getting_started_steps, action_signals, the cluster members, searches and
scopes, and the plan marks; the action and cluster children are found
through their parent (scopes).

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

* test(demo): pin the build order with gates instead of timers

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

* perf(demo): rebuild AI traffic, Site Audit and the catalog in place

The three site modules write through the build's writer (ctx.write): their
independent tables side by side (traffic's thirteen at once, a visit before
its pageviews), and on a rebuild over their old rows by key, deleting only
what isn't written again, so their pages never empty while the demo is
rebuilt. Google Analytics and Search Console rows are keyed by their day and
what they count (their unique columns, as their syncs write them), the
audits' signals by audit and signal (found through their audit), the
single-row settings by brand. ai_bot_events has an identity id and no other
key: its rows are replaced, the old ones deleted right after the new are in.
site-common's insertRows goes.

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

* perf(demo): refresh the demo's mention rollups beside its answer terms

refreshMentionsDaily takes `together`: the rollups (refresh_mentions_daily)
and the answer terms (refresh_mention_terms) take their own locks and write
their own tables, so the demo runs them side by side instead of one after
the other, a second off the longest step of its build. The nightly run
keeps them in turn.

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

* feat(demo): move the Chat preview's inbox into the chat menu and add archived chats

Home keeps the composer in view: Inbox gets its own screen in the chat
menu, the skill cards are shorter with the description on hover, Home to
Files fold under a Menu header, and All chats has Active/Archived tabs.

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

* feat(demo): show Brewline Coffee in the Chat preview, raise its Home and add skill creation

The preview now tracks the demo brand: its pages, rivals, prompts and
sources come from the demo data, and Ansvisor stays only where it names
the product. Home starts higher with more room above the composer, both
cards say when their change happened, One win lists its citations, and
Create a skill opens the chat, upload and URL import flows from CHAT-13.

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

* fix(web): name the profiles→organizations relationship so the plan check reads again

The read-only check before every write embedded organizations from
profiles without naming the relationship. A second foreign key between the
two tables made the embed ambiguous, so the check failed and every write
returned 500 for every workspace, active plans included. Same fix for
getMyProfile.

(cherry picked from commit 62eb7b7658388c1614b38dea93fbe316b8910311)

* test(web): read the demo brand's plan check with the named relationship

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

* feat(billing): start a plan from one choice that fits on one screen

The plan dialog, Settings › Billing with no plan active and onboarding's
plan step now share the same start flow (components/billing/plan-start):

- One choice above the cards: 14-day trial / Monthly, 50% off the first
  month / Yearly, Save 20%. Each card then has one button, one "Due
  today" line (the trial says when it ends and what follows, "Free until
  Nov 11, then $49/month") and "Secure checkout with Stripe · Cancel any
  time" beside the button. The promo code field sits behind "Have a
  code?".
- The first-month offer shows from the first frame, from the config: no
  $49 → $24.50 jump once Stripe answers. A code Stripe can't redeem takes
  it away; one that couldn't be checked keeps it as configured.
- Onboarding's plan step drops its own copy (PLAN_STEP_COPY) for the
  shared cards and Billing's features, with the discounted price large,
  and says what is ready to track for the brand, from its real prompt,
  topic and competitor counts.
- Everything fits 1024×768 and up without scrolling: the plans' features
  open behind "Show plan details" inside the cards, which keep their
  height; on Billing the plan choice comes first while no plan is active.
- A Checkout that doesn't open (Stripe down or not set up, no answer in
  30 s, a refusal) says why by the plan's button instead of spinning.

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

* feat(demo): name the workspace's own brand in the demo band and plan dialog

On the demo brand the band says "Start tracking Acme Coffee with a
14-day free trial…" and, with a plan active, "Switch to Acme Coffee"; the
plan dialog's demo and new-brand pitches name the brand too. Before the
workspace has a brand of its own, the general wording stays.

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

* fix(demo): wait for the brand on screen before showing a page or a band

In a new browser the brand store starts empty until BrandLoader puts the
layout's brands in it, just after the first render. Until then BrandGuard
read the empty list as "No brands yet", the read-only band showed the
workspace's own state before the demo brand's band, and the brand switcher
offered Add Brand. The store now says when it holds the server's list
(loaded, never persisted); pages wait on the skeleton, the read-only band
and Add Brand wait for it, and leaving the dashboard clears it.

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

* fix(demo): keep the nightly prompt demand read off demo brands and cover main's new tables

sweepPromptDemand chose brands by their organization's plan only, so an
active workspace's demo brand would have had its sample prompts read and
DataForSEO's paid tasks set for them. It now leaves demo brands out, as
the other sweeps do. The demo coverage list names the two brand tables
main added: prompt_table_views (skipped: the demo starts on the default
columns) and prompt_demand (pending a demo follow-up).

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

* fix(demo): refuse main's new write routes on a demo brand and keep column layouts open

Main added write routes that name a brand: Action Center's audits and
products, WordPress and Framer connections, and their publish-status
checks. Each now answers 402 demo_brand on a demo brand, as the Webflow
ones do. The Tracked Prompts column layouts (prompt_table_views, 00363)
stay writable on a demo brand: they change no sample data and cost
nothing, and the web keeps them open while read-only too.

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

* feat(demo): follow the app's dark theme in the Chat preview

The preview reads the app's .dark class from its parent page and follows it live; standalone it follows the system setting. Its colours moved to variables with a dark palette close to the app's.

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

* docs(demo): say which integrations the demo brand shows connected, now that WordPress and Framer are live

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

* fix(demo): check a topic write once, with its brand, now that the check comes first

Merging main left createTopics, createTopic and updateTopic with two
plan checks each: main's, moved ahead of the name check, and the demo's,
which hands the brand over. Each now checks once, first, with its brand
where it has one.

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

* feat(demo): answer the Chat preview's shortcuts from anywhere on its page

⌘ or Ctrl with ⇧O (new chat), K (search), J (side panel) or \ (menu)
reach the preview while the app around it has the focus: the page hands
them to the frame, which answers them as it does inside. The frame takes
the focus when it opens, and on a Mac the preview shows ⌘ for Ctrl.

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

* fix(demo): keep the competitor timeline off demo brands and cover main's new tables

sweepCompetitorTimeline (learning C3, on main) chose brands by their
organization's plan only, so a demo brand's sample answers would have had
their cited pages read every night. It now leaves demo brands out, as the
other sweeps do. The demo coverage list names the brand tables main added:
cited_page_features, competitor_page_events and competitor_timeline_scans
(pending a demo follow-up) and chat_conversations (with Chat).

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

* feat(chat): read a call's demo flag from brands.is_demo

Chat's precedence (#1776) left readBrandIsDemo false until the demo chain
added brands.is_demo, with a type check that stops compiling once the
column exists. It now reads the column, as the server's demo guard does,
so a tool that changes or spends on the demo brand is refused with
demo_brand; a brand that isn't found isn't one, and a failed read throws.

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

* fix(demo): guard the brand site type detection on the demo brand

POST /brands/:id/detect-site-type (#1761, on main) reads the brand's home
page and may ask AI for its kind. The demo guard's coverage test fails on a
write route in neither list, so it is now guarded by the brand in its path.

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

* fix(demo): name main's new Chat tables in the demo write guard's lists

chat_user_prefs (00400) and chat_auto_choices (00401) are a person's own
rows, not a brand's: the write guard's coverage test fails on a writable
table in no list, so both are named as no brand's rows.

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

* fix(mcp): refuse main's new write tools on the demo brand

approve_task_review, dismiss_task_review (#1713) and
mark_content_draft_published (#1715) write a brand's data, and the demo
gate's test fails on a write tool WRITE_TOOL_BRANDS doesn't name. A task
review finds its brand through its action; a draft through its own row.
The test's API key now carries the role main's McpAuthContext requires.

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

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[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