Skip to content

fix(action-center): run Getting started for the first real brand when a demo brand came first - #1799

Merged
gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:fix/getting-started-demo-first
Oct 30, 2026
Merged

gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:fix/getting-started-demo-first

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Found while testing onboarding: after adding a card, the Action Center said No actions yet instead of Getting started's 17 steps.

Why:

00383:

  • start_brand_getting_started counts only the organization's other real brands (not b.is_demo). The demo brand itself is unchanged; its builder writes its own row.
  • Backfill: a real brand still waiting for an answer runs Getting started now. That is one with confirmed_at and dismissed_at null and no real brand before it in its organization. A real second brand still asks, as before.

Related issue

None. Found in onboarding testing, after the demo brand chain (#1734–#1740).

Type of change

  • fix — Bug fix

How to test

  1. Rolled-back run on the dev DB: an organization with a demo brand, then two real brands. The first real brand runs (confirmed_at set) and the second asks (null). The run ended with ROLLBACK.
  2. web/src/lib/getting-started/start-trigger.test.ts: the latest trigger definition in schema.sql leaves demo brands out.
  3. On staging after applying 00383: start without a card (demo brand), add a card and finish setup. Action Center › Actions opens on Getting started with the 17 steps.

Deploy: apply 00383 (no app change needed). Its backfill also fixes brands created since the demo brand went live.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • bash supabase/build-schema.sh: schema.sql is current (00383)
  • Tests added (src/lib/getting-started 24/24; server demo/coverage.test.js 7/7)

🤖 Generated with Claude Code

… a demo brand came first

00197 runs Getting started at once for an organization's first brand and
asks first for a later one. Since the demo brand (00380) comes first for a
person who starts without a card, the brand they set up after adding a card
counted as a later one, so the Actions page said "No actions yet" instead of
the 17 steps. 00383 leaves demo brands out of that check and runs it now for
the real brands it caught.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 29, 2026
…rand"

00383's backfill also confirmed a second brand whose first brand was
deleted, in an organization that never had a demo brand. Limit it to
organizations with a demo brand. The demo brand's created_at is counted
back from each rebuild, so it isn't compared.

Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with acf56dd: I made one change to the backfill (below) and it's ready.

The change

  • The backfill could also confirm a brand the demo brand didn't affect. Take an organization that never had a demo brand: its first brand was deleted, and the second still asks "Run Getting started?". It has no real brand before it, so the backfill started Getting started for it without an answer.
  • take-1799 adds one condition: the organization has a demo brand. The demo brand's created_at isn't compared, because the demo builder counts it back from each rebuild (server/src/lib/demo/core.js). So it can land after a real brand that was really made later.
  • The migration's comment says the same. schema.sql is rebuilt with build-schema.sh.
  • A second test in start-trigger.test.ts checks the condition. It fails on this branch's migration and passes with the fix.

What I checked

  • The trigger. It's the same function as 00197, with and not b.is_demo added. It's still security definer with search_path = public, and still revoked from public, anon and authenticated. Its trigger from 00196 is unchanged.
    • A demo brand inserted into an organization with no real brand still runs at once, as before. The demo builder then upserts its own row.
  • The demo brand's rows.
    • The backfill updates only rows with not b.is_demo, so 00381's trigger never sees a demo brand's row here.
    • The trigger's insert runs inside the brands trigger (depth 2), so 00381 lets it through, the same as on main.
  • Existing state.
    • Only rows with both confirmed_at and dismissed_at null change. A brand someone started or skipped is left alone.
    • started_at and getting_started_steps are untouched. Nothing is reset.
    • A real second brand still asks.
    • The page reads confirmed_at only as a yes/no (steps.ts), so the backfill's now() doesn't move any step.
  • Size. getting_started has one row per brand. The update locks only the rows it changes. There's no rewrite and no new index.
  • Merge and numbering.
    • The branch is on the current main and merges clean.
    • 00383 is unique among main and the open PRs.
    • Every open PR with a migration also changes schema.sql. Whichever merges second rebuilds it with build-schema.sh.
  • Tests.
    • src/lib/getting-started: 25/25 with the fix.
    • Server src/lib/demo: 118/118.
    • plan-row.test.ts passes. No client code changes.

Deploy

Apply 00383 (from take-1799) on prod, then merge. No app change.

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

Merging in order with the other approved PRs. This head merges current main; its tree is what main will be after this squash, checked with the full server and web suites, tsc, lint, format and next build. Migration 00383 is applied on production just before the merge.

@gkhngyk
gkhngyk merged commit 60c482c into ansvisor:main Oct 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-migration Adds or edits a migration — apply it to the hosted database

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants