Skip to content

Use waiting room Gravity placements#549

Merged
jahooma merged 2 commits intomainfrom
jahooma/waiting-room-ads
Apr 25, 2026
Merged

Use waiting room Gravity placements#549
jahooma merged 2 commits intomainfrom
jahooma/waiting-room-ads

Conversation

@jahooma
Copy link
Copy Markdown
Contributor

@jahooma jahooma commented Apr 25, 2026

Summary

Route Freebuff waiting room ad requests through a new waiting_room ads surface.
Gravity maps that surface to waiting-room-1 through waiting-room-4, while existing chat ad placements keep their current banner/choice behavior.

Validation

  • bun run --cwd cli typecheck
  • bun run --cwd web typecheck

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 25, 2026

Greptile Summary

This PR routes the Freebuff waiting room ad requests through a new waiting_room surface, which Gravity maps to four dedicated placement IDs (waiting-room-1 through waiting-room-4), while existing chat ad placements continue using their current banner/choice logic. The change is well-scoped and flows cleanly from the CLI hook through the API layer to the Gravity provider.

Confidence Score: 5/5

Safe to merge; only one minor style suggestion remains.

All findings are P2. The single comment is a simplification of an intermediate variable in gravity.ts that doesn't affect correctness or runtime behavior.

web/src/lib/ad-providers/gravity.ts — minor simplification opportunity in the placement/variant derivation block.

Important Files Changed

Filename Overview
web/src/lib/ad-providers/gravity.ts Adds WAITING_ROOM_PLACEMENT_IDS and routes waiting_room surface requests to those placements; variant/placement derivation logic can be simplified by removing the intermediate requestedPlacementIds variable.
cli/src/hooks/use-gravity-ad.ts Adds AdSurface type and surface option; correctly threads it into the fetch body and adds it to the useEffect dependency array.
web/src/app/api/v1/ads/_post.ts Adds surfaceSchema validation and passes surface through to the ad provider; straightforward and correct.
web/src/lib/ad-providers/types.ts Adds AdSurface type and optional surface field to FetchAdInput; clean addition.
cli/src/components/waiting-room-screen.tsx Passes surface: 'waiting_room' to useGravityAd; minimal, correct one-liner change.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: web/src/lib/ad-providers/gravity.ts
Line: 114-128

Comment:
**Simplify placement/variant derivation**

The intermediate `requestedPlacementIds` variable is checked twice with `?.length`, and the `length === 1 ? 'banner' : 'choice'` branch will never be `'banner'` because `WAITING_ROOM_PLACEMENT_IDS` always has 4 entries. Checking `input.surface` directly removes the extra variable and the duplicate guards.

```suggestion
      const variant =
        input.surface === 'waiting_room' ? 'choice' : getGravityVariant(userId)
      const filteredMessages = prepareGravityMessages(messages)

      const placementIds =
        input.surface === 'waiting_room'
          ? WAITING_ROOM_PLACEMENT_IDS
          : variant === 'choice'
            ? CHOICE_PLACEMENT_IDS
            : [BANNER_PLACEMENT_ID]
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "Use waiting room Gravity placements" | Re-trigger Greptile

Comment thread web/src/lib/ad-providers/gravity.ts Outdated
Comment on lines +114 to +128
const requestedPlacementIds =
input.surface === 'waiting_room' ? WAITING_ROOM_PLACEMENT_IDS : undefined
const variant = requestedPlacementIds?.length
? requestedPlacementIds.length === 1
? 'banner'
: 'choice'
: getGravityVariant(userId)
const filteredMessages = prepareGravityMessages(messages)

const placements =
variant === 'choice'
? CHOICE_PLACEMENT_IDS.map((id) => ({
placement: 'below_response',
placement_id: id,
}))
: [{ placement: 'below_response', placement_id: BANNER_PLACEMENT_ID }]
const placementIds = requestedPlacementIds?.length
? requestedPlacementIds
: variant === 'choice'
? CHOICE_PLACEMENT_IDS
: [BANNER_PLACEMENT_ID]

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.

P2 Simplify placement/variant derivation

The intermediate requestedPlacementIds variable is checked twice with ?.length, and the length === 1 ? 'banner' : 'choice' branch will never be 'banner' because WAITING_ROOM_PLACEMENT_IDS always has 4 entries. Checking input.surface directly removes the extra variable and the duplicate guards.

Suggested change
const requestedPlacementIds =
input.surface === 'waiting_room' ? WAITING_ROOM_PLACEMENT_IDS : undefined
const variant = requestedPlacementIds?.length
? requestedPlacementIds.length === 1
? 'banner'
: 'choice'
: getGravityVariant(userId)
const filteredMessages = prepareGravityMessages(messages)
const placements =
variant === 'choice'
? CHOICE_PLACEMENT_IDS.map((id) => ({
placement: 'below_response',
placement_id: id,
}))
: [{ placement: 'below_response', placement_id: BANNER_PLACEMENT_ID }]
const placementIds = requestedPlacementIds?.length
? requestedPlacementIds
: variant === 'choice'
? CHOICE_PLACEMENT_IDS
: [BANNER_PLACEMENT_ID]
const variant =
input.surface === 'waiting_room' ? 'choice' : getGravityVariant(userId)
const filteredMessages = prepareGravityMessages(messages)
const placementIds =
input.surface === 'waiting_room'
? WAITING_ROOM_PLACEMENT_IDS
: variant === 'choice'
? CHOICE_PLACEMENT_IDS
: [BANNER_PLACEMENT_ID]
Prompt To Fix With AI
This is a comment left during a code review.
Path: web/src/lib/ad-providers/gravity.ts
Line: 114-128

Comment:
**Simplify placement/variant derivation**

The intermediate `requestedPlacementIds` variable is checked twice with `?.length`, and the `length === 1 ? 'banner' : 'choice'` branch will never be `'banner'` because `WAITING_ROOM_PLACEMENT_IDS` always has 4 entries. Checking `input.surface` directly removes the extra variable and the duplicate guards.

```suggestion
      const variant =
        input.surface === 'waiting_room' ? 'choice' : getGravityVariant(userId)
      const filteredMessages = prepareGravityMessages(messages)

      const placementIds =
        input.surface === 'waiting_room'
          ? WAITING_ROOM_PLACEMENT_IDS
          : variant === 'choice'
            ? CHOICE_PLACEMENT_IDS
            : [BANNER_PLACEMENT_ID]
```

How can I resolve this? If you propose a fix, please make it concise.

@jahooma jahooma merged commit f58c850 into main Apr 25, 2026
34 checks passed
@jahooma jahooma deleted the jahooma/waiting-room-ads branch April 25, 2026 21:30
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.

1 participant