Skip to content

feat(brands): pause a brand — add is_active and skip inactive brands in daily tracking - #308

Merged
gkhngyk merged 1 commit into
mainfrom
feature/brand-pause-is-active
Jun 27, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feature/brand-pause-is-active

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an active / inactive (paused) state to a brand so it can be temporarily suspended without deleting it (which would destroy all history). Pausing suspends tracking and all related spend; resuming picks it back up on the next run.

  • Data — migration 00020_brand_is_active.sql: brands.is_active boolean NOT NULL DEFAULT true. Existing brands default to active, so behavior is unchanged on rollout.
  • Daily tracking — runDailyTracking (server/src/server.js) filters the brands query to .eq('is_active', true), so paused brands are skipped by the cron. The existing per-brand subscription / feature / prompt-count guards are untouched.
  • On-demand tracking — POST /api/tracking/check and /analyze-new (server/src/routes/tracking.js) reject a paused brand with 409 after the ownership check, so "paused" means no spend at all (per the issue's suggested decision).
  • Server action — setBrandActive(brandId, isActive) mirroring setBrandShoppingMode; isActive is surfaced on the Brand type and getBrands / getBrandById mappers.
  • UI — a Pause / Resume "Tracking" card in brand settings (admin-only) with a clear "historical data is kept, daily tracking is suspended" state, plus a "Paused" badge in the brand switcher and brand cards.

A paused brand keeps all historical data and stays selectable/viewable. The hosted migration has already been applied (column verified: boolean, NOT NULL, default true).

Deploy ordering: the migration must be applied before deploying the server code (the cron and on-demand queries reference is_active). The migration is already live on hosted.

Out of scope (per issue): exposing pause state via MCP, and seat/quota accounting changes.

Related issue

Closes #286

Type of change

  • feat — New feature

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a paused/active state to brands (brands.is_active) so tracking can be suspended without deleting historical data, and updates server + web surfaces to respect that state (daily cron skips paused brands; on-demand endpoints reject paused brands; UI exposes pause/resume and shows “Paused” indicators). The PR also includes additional in-product agent “Site Audit” tool exposure/prompting that is not described in the PR summary or issue scope.

Changes:

  • Add brands.is_active (default true) and surface it through web types/mappers as Brand.isActive.
  • Skip paused brands in daily tracking and block on-demand tracking routes for paused brands (409).
  • Add brand settings UI to pause/resume tracking and show “Paused” badges in brand switcher/cards.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
web/src/types/supabase.ts Adds is_active to Supabase-generated brand row types.
web/src/types/index.ts Adds Brand.isActive to the app-level Brand type.
web/src/lib/actions/brand.ts Maps is_active → isActive; adds setBrandActive server action.
web/src/components/layout/brand-switcher.tsx Displays a “Paused” badge for inactive brands in the switcher.
web/src/components/dashboard/brand-card.tsx Displays a “Paused” badge on brand cards.
web/src/app/[locale]/(onboarding)/dashboard/onboarding/page.tsx Ensures onboarding brand mapping includes isActive.
web/src/app/[locale]/(dashboard)/dashboard/brands/[id]/settings/page.tsx Adds Pause/Resume Tracking settings card (admin-only).
supabase/migrations/00020_brand_is_active.sql Migration to add brands.is_active boolean not null default true.
server/src/server.js Daily tracking cron filters brands to is_active = true.
server/src/routes/tracking.js Blocks /check and /analyze-new for paused brands (409).
web/src/lib/agent/tools.ts Adds Site Audit agent tools (run/get/list) in the in-product agent toolset.
web/src/lib/agent/system-prompt.ts Documents Site Audit agent tools + adds credit-spending rule for run_site_audit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread web/src/lib/actions/brand.ts Resolved
Comment thread web/src/lib/agent/tools.ts Resolved
Comment thread web/src/lib/agent/system-prompt.ts Resolved
…in tracking

Add an active/inactive (paused) state to brands so a brand can be
temporarily suspended without deleting it (and losing history).

- migration 00020: brands.is_active boolean NOT NULL DEFAULT true
- daily tracking cron filters brands on is_active = true
- on-demand tracking (/check, /analyze-new) rejects paused brands (409)
- setBrandActive server action + isActive on the Brand type/mappers
- Pause/Resume card in brand settings + paused badge in switcher/list
@gkhngyk
gkhngyk force-pushed the feature/brand-pause-is-active branch from d13be63 to d942073 Compare June 27, 2026 12:56
@gkhngyk
gkhngyk merged commit f5d2d10 into main Jun 27, 2026
3 checks passed
@gkhngyk
gkhngyk deleted the feature/brand-pause-is-active branch June 27, 2026 14:55
@gkhngyk gkhngyk mentioned this pull request Jul 6, 2026
5 tasks done
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.

feat(brands): pause a brand — add is_active and skip inactive brands in daily tracking

2 participants