Skip to content

fix(commerce-pdp-management): resolve scope-only rules, debounce product picker, fix review queue filter - #48

Merged
jarodreyes merged 4 commits into
mainfrom
fix/commerce-pdp-management-review-bugs
Sep 18, 2026
Merged

jarodreyes merged 4 commits into
mainfrom
fix/commerce-pdp-management-review-bugs

Conversation

@plsrd

@plsrd plsrd commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What this PR does

Fixes three bugs from the internal review of the commerce-pdp-management starter: attribute rules that only appear in a product-type scope were silently dropped by the resolver, the Studio product picker could show stale Shopify results, and a rule sent back to draft after approval never reappeared in the Review queue. Docs are updated where the behavior an editor relies on changed.

Changes

1. Scope-only attribute rules resolve instead of being dropped

What was wrong: selectPriorityList built its id map from the global controlPlane.priorityList only, and the controlPlaneQuery projected each productTypeScope as bare ruleIds. A rule referenced only by a scope was looked up in a map it was never in, so it vanished with no signal to the merchandiser.

What changed:

  • frontend/sanity/queries.ts dereferences each scope's priorityList with the same rule projection as the global list.
  • ProductTypeScope now carries priorityList: Array<AttributeRule | null> (GROQ returns null for a deleted or unpublished reference), and ControlPlane.priorityList is typed the same way.
  • resolvePdp.ts puts the scope's own rules first (in scope order, including scope-only rules) and appends the remaining global rules. Unresolvable entries are skipped with a console.warn naming the list they came from.
  • packages/@starter/sanity-types/sanity.types.ts regenerated for the new query shape.

2. Product picker search is debounced and sequenced

What was wrong: ProductPickerInput called searchShopify directly on every keystroke with no debounce or request ordering, so a slow earlier response could overwrite the suggestions for a later, more specific term.

What changed: New studio/hooks/useDebouncedSearch.ts (no existing debounce utility in this starter to reuse) debounces keystrokes (250ms), numbers each request, aborts the previous one via AbortController, and only applies the result for the latest request. searchShopify takes the signal; the component now just calls search(term). studio/tsconfig.json includes the new hooks/ dir.

3. Review queue shows everything not yet approved; review-stamp resets

What was wrong: The Review queue filtered attributeRule on status == "in-review" only, so flipping an approved rule back to draft removed it from the queue entirely. Meanwhile skuEnrichment used draft as its queue state, so the two types behaved inconsistently. The README describes the queue as where "drafts land ... before anything reaches a customer", so the queue now matches that.

What changed:

  • studio/structure.ts filter is _type in ["attributeRule", "skuEnrichment"] && status != "approved".
  • functions/review-stamp/index.ts now also clears aiEnrichment.reviewedAt when a rule leaves approved, so a re-approval gets a fresh timestamp instead of keeping the old one. Both patches are guarded on current state so neither re-fires itself. The blueprint event filter already covered all published attributeRule updates; no blueprint change needed.
  • AGENT.md documents the status flow, the new queue semantics, scope resolution, and the picker hook.

Testing

Run from commerce-pdp-management/ with dummy SANITY_STUDIO_PROJECT_ID / SANITY_STUDIO_DATASET set:

  • pnpm typegen — regenerated types (3 queries, 23 schema types)
  • pnpm -r typecheck — passes in functions, packages/@starter/commerce, studio, frontend
  • pnpm lint — clean
  • pnpm format:check — clean (root npx oxfmt also run via the pre-commit hook)
  • pnpm --filter @starter/functions build — both bundles build
  • pnpm validate — template validated
  • Ad-hoc node:test suite against resolveAttributeRules (not committed; the starter has no test runner): scope-only rule resolves and wins its category, non-matching product type falls back to global, scope reorders shared rules and appends unscoped globals, null refs skipped with one warning per list, null/empty control plane yields []. 5/5 pass.

Not verified live: the Studio picker UI against a real Shopify store, and the review-stamp Function against a deployed dataset (logic is a straightforward extension of the existing guarded patch).

🤖 Generated with Claude Code

plsrd and others added 4 commits September 3, 2026 12:25
…ead of dropping them

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… stale responses

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ew queue

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…tion, and picker search

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@plsrd
plsrd had a problem deploying to agentic-localization September 3, 2026 19:28 — with GitHub Actions Error
@plsrd
plsrd deployed to knowledge-base September 3, 2026 19:28 — with GitHub Actions Active
@plsrd
plsrd deployed to commerce-pdp-management September 3, 2026 19:28 — with GitHub Actions Active
@plsrd
plsrd deployed to ai-shopping-assistant September 3, 2026 19:28 — with GitHub Actions Active
@plsrd
plsrd deployed to knowledge-base September 3, 2026 19:28 — with GitHub Actions Active
@plsrd
plsrd deployed to commerce-pdp-management September 3, 2026 19:28 — with GitHub Actions Active
@plsrd
plsrd deployed to commerce-plp-management September 3, 2026 19:28 — with GitHub Actions Active
@plsrd
plsrd deployed to commerce-plp-management September 3, 2026 19:28 — with GitHub Actions Active
@plsrd
plsrd had a problem deploying to agentic-localization September 3, 2026 19:28 — with GitHub Actions Failure
@vercel

vercel Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
agentic-localization Ready Ready Preview Sep 3, 2026 7:29pm UTC
ai-shopping-assistant Ready Ready Preview Sep 3, 2026 7:29pm UTC
commerce-pdp-starter Ready Ready Preview Sep 3, 2026 7:29pm UTC
commerce-plp-starter Ready Ready Preview Sep 3, 2026 7:29pm UTC
content-analytics-starter Ready Ready Preview Sep 3, 2026 7:29pm UTC

Request Review

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

Approved. Cursor Bugbot was not present after the first check poll, so that automated-review signal was skipped; no approval policy required human review. Reviewers were not assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

@jarodreyes jarodreyes self-assigned this Sep 18, 2026
@jarodreyes

Copy link
Copy Markdown
Contributor

Looks good @plsrd !

@jarodreyes
jarodreyes merged commit 6985222 into main Sep 18, 2026
16 of 20 checks passed
@jarodreyes
jarodreyes deleted the fix/commerce-pdp-management-review-bugs branch September 18, 2026 20:39

This branch had an error being deployed

1 failed and 9 active deployments
Preview – ai-shopping-assistant — 5ab36300 Deployed Sep 3, 2026 by vercel[bot]
Preview – content-analytics-starter — 5ab36300 Deployed Sep 3, 2026 by vercel[bot]
Preview – commerce-plp-starter — 5ab36300 Deployed Sep 3, 2026 by vercel[bot]
Preview – commerce-pdp-starter — 5ab36300 Deployed Sep 3, 2026 by vercel[bot]
Preview – agentic-localization — 5ab36300 Deployed Sep 3, 2026 by vercel[bot]
agentic-localization — 5ab36300 Deployed Sep 3, 2026 by plsrd via agentic-localization (Node 22) #194
knowledge-base — 5ab36300 Deployed Sep 3, 2026 by plsrd via knowledge-base (Node 22) #194
commerce-pdp-management — 5ab36300 Deployed Sep 3, 2026 by plsrd via commerce-pdp-management (Node 22) #194
ai-shopping-assistant — 5ab36300 Deployed Sep 3, 2026 by plsrd via ai-shopping-assistant #194
commerce-plp-management — 5ab36300 Deployed Sep 3, 2026 by plsrd via commerce-plp-management (Node 22) #194
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