Skip to content

[codex] Show ad title when ad URL is missing#546

Merged
jahooma merged 2 commits intomainfrom
jahooma/show-ad-title
Apr 25, 2026
Merged

[codex] Show ad title when ad URL is missing#546
jahooma merged 2 commits intomainfrom
jahooma/show-ad-title

Conversation

@brandonkachen
Copy link
Copy Markdown
Collaborator

Summary

  • Show an ad title in the CLI choice ad banner when the normalized ad has no display URL.
  • Keep URL-backed ads rendering their underlined display domain.
  • Add a focused unit test for the display-label helper.

Why

Carbon ads intentionally omit the display URL because their click URL is a tracking redirect. That left the banner's secondary label blank. Falling back to the title preserves useful advertiser context without showing the tracking host.

Validation

  • bun test cli/src/components/__tests__/choice-ad-banner.test.tsx
  • bun run --cwd cli typecheck

@jahooma jahooma marked this pull request as ready for review April 25, 2026 18:34
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 25, 2026

Greptile Summary

This PR fixes a blank secondary label in the choice ad banner when Carbon ads omit the display URL by falling back to the ad title. The implementation is correct and well-tested.

Confidence Score: 5/5

Safe to merge — logic is correct, tests cover both branches, and remaining findings are minor style improvements.

All findings are P2: a redundant guard in truncateToWidth and an unnecessary export on extractDomain. No correctness, data-integrity, or security issues were found.

No files require special attention.

Important Files Changed

Filename Overview
cli/src/components/choice-ad-banner.tsx Adds getAdDisplayLabel helper and truncateToWidth to fall back to ad title when URL is absent; logic is correct but truncateToWidth has a redundant guard and extractDomain is unnecessarily exported.
cli/src/components/tests/choice-ad-banner.test.tsx New unit tests for getAdDisplayLabel covering the URL-present and URL-absent branches; coverage is appropriate for the introduced logic.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: cli/src/components/choice-ad-banner.tsx
Line: 28-33

Comment:
**Redundant guard and duplicated truncation logic**

The `width === 1` branch on line 31 is dead code — the final `return` already handles it correctly: `text.slice(0, 1 - 1) + '…'` = `'…'`. The branch can be removed. Additionally, `truncateToWidth` is essentially `truncateToLines(text, width, 1)` with a corrected `width ≤ 0` edge case (returning `''` instead of the full text). Consider consolidating into one utility or at least removing the redundant guard:

```suggestion
function truncateToWidth(text: string, width: number): string {
  if (width <= 0) return ''
  if (text.length <= width) return text
  return text.slice(0, width - 1) + '…'
}
```

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

---

This is a comment left during a code review.
Path: cli/src/components/choice-ad-banner.tsx
Line: 35

Comment:
**Unnecessary export on `extractDomain`**

`extractDomain` is not imported by the test file (only `getAdDisplayLabel` is), so the `export` added here is unneeded. Keeping it private prevents unintended coupling to callers outside this module.

```suggestion
const extractDomain = (url: string): string => {
```

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

Reviews (1): Last reviewed commit: "Show ad title without URL" | Re-trigger Greptile

Comment thread cli/src/components/choice-ad-banner.tsx
return text.slice(0, width - 1) + '…'
}

export const extractDomain = (url: string): string => {
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 Unnecessary export on extractDomain

extractDomain is not imported by the test file (only getAdDisplayLabel is), so the export added here is unneeded. Keeping it private prevents unintended coupling to callers outside this module.

Suggested change
export const extractDomain = (url: string): string => {
const extractDomain = (url: string): string => {
Prompt To Fix With AI
This is a comment left during a code review.
Path: cli/src/components/choice-ad-banner.tsx
Line: 35

Comment:
**Unnecessary export on `extractDomain`**

`extractDomain` is not imported by the test file (only `getAdDisplayLabel` is), so the `export` added here is unneeded. Keeping it private prevents unintended coupling to callers outside this module.

```suggestion
const extractDomain = (url: string): string => {
```

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

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@jahooma jahooma merged commit 3924d34 into main Apr 25, 2026
11 checks passed
@jahooma jahooma deleted the jahooma/show-ad-title branch April 25, 2026 18:38
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