Skip to content

fix: exclude decorative images from alt-text PLG grant selection (SITES-44253)#2831

Open
yashrathore11 wants to merge 2 commits into
mainfrom
SITES-44253/alt-text-decorative-suggestions-grant-filter
Open

fix: exclude decorative images from alt-text PLG grant selection (SITES-44253)#2831
yashrathore11 wants to merge 2 commits into
mainfrom
SITES-44253/alt-text-decorative-suggestions-grant-filter

Conversation

@yashrathore11

Copy link
Copy Markdown

Summary

Decorative-image suggestions (data.recommendations[].isDecorative === true) were competing for a PLG customer's limited alt-text grant slots (3 per month) alongside suggestions that actually need an alt-text fix. Since decorative images don't need alt text, granting one wasted a slot that should have gone to a real fix — silently reducing how many actionable suggestions a PLG customer saw that cycle.

This adds an alt-text grouping strategy to OPPORTUNITY_STRATEGIES in grant-suggestions-handler.js that excludes decorative suggestions before grant selection, so all 3 monthly slots go to suggestions that actually need fixing. If fewer than 3 non-decorative suggestions exist, fewer than 3 are granted — slots are no longer backfilled with decorative suggestions just to hit the cap.

No public API contract change: same endpoints, same response shape — only which suggestions get a grant record (and therefore surface to sites-optimizer-ui PLG callers via the existing filterByGrantStatus gate) changes.

Testing

  • Added 6 unit tests in test/support/grant-suggestions-handler.test.js covering: exclusion of decorative suggestions, exclusion when any of multiple recommendations is decorative, retention of non-decorative suggestions, missing/empty recommendations treated as non-decorative, plain-object data support, and default rank-ascending sort of survivors.
  • Full grant-suggestions-handler.test.js (58/58) and the suggestions/opportunities controller suites (528/528) pass.
  • Lint clean.

If the PR is changing the API specification:

  • N/A — no API specification change (no new/modified endpoint, request, or response shape)

If the PR is changing the API implementation or an entity exposed through the API:

  • N/A — internal grant-selection logic only; no entity or API-facing contract change

If the PR is introducing a new audit type:

  • N/A — not an audit type change

Related Issues

SITES-44253

…ES-44253)

Decorative suggestions (data.recommendations[].isDecorative) needed no
alt-text fix and shouldn't consume one of a PLG customer's 3 monthly
grant token slots, but the alt-text opportunity had no grouping
strategy and fell through to the unfiltered default, letting them
compete for grants alongside real fixes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown

This PR will trigger a patch release when merged.

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

Hey @yashrathore11,

Verdict: Approve - clean, well-scoped fix with thorough test coverage.
Complexity: LOW - small diff, single service, internal logic only.
Changes: Adds an alt-text grouping strategy to OPPORTUNITY_STRATEGIES that excludes decorative-image suggestions from PLG grant selection (2 files).

Non-blocking (2): minor issues and suggestions
  • nit: The comment (lines 144-147) says data.recommendations[].isDecorative - consider rewording to "Suggestions where any recommendation is marked decorative are excluded" to make the any-match semantics explicit without needing to read the filter body. - src/support/grant-suggestions-handler.js:144
  • suggestion: The test "works with plain object data (no getData())" proves the filter handles plain objects, but if the downstream default sort calls getId()/getRank() methods, plain objects without those methods would fail end-to-end. Consider whether this fallback path occurs at runtime - if not, the test overstates the supported contract. - test/support/grant-suggestions-handler.test.js:361

Skill: pr-review | Model: us.anthropic.claude-opus-4-6-v1[1m] | Duration: 1m 3s | Cost: $3.43 | Commit: e18bbe7c999822b48bda194e1b99a3d7c174d1b0
If this code review was useful, please react with 👍. Otherwise, react with 👎.

@MysticatBot MysticatBot added ai-reviewed Reviewed by AI complexity:low AI-assessed PR complexity: LOW labels Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-reviewed Reviewed by AI complexity:low AI-assessed PR complexity: LOW

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants