Skip to content

feat(mobile-expo): CTARenderer section component#322

Open
up-tandem wants to merge 2 commits intomainfrom
feat/307-cta-renderer
Open

feat(mobile-expo): CTARenderer section component#322
up-tandem wants to merge 2 commits intomainfrom
feat/307-cta-renderer

Conversation

@up-tandem
Copy link
Contributor

@up-tandem up-tandem commented Mar 10, 2026

Summary

  • Replaces the CTA stub renderer with a real implementation displaying heading, body text, and a tappable button
  • Supports primary (filled) and secondary (outlined) variant styling
  • Defaults to primary when variant is null
  • Uses Pressable + Linking.openURL for button interaction
  • Graceful handling of missing optional fields
  • Accessible labels on button

Contracts Changed

No

Regeneration Required

No

Validation

  • pnpm --filter @forge/expo lint — passes with 0 warnings
  • pnpm --filter @forge/expo test -- --testPathPattern=CTARenderer — 5/5 tests pass
  • pnpm --filter @forge/expo test -- --testPathPattern=SectionDispatcher — 11/11 tests pass (no regressions)

Resolves #307

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Introduced a CTA component that renders customizable call-to-action sections with heading, body text, and pressable buttons. Supports primary and secondary button styling variants with URL navigation functionality.
  • Tests

    • Added comprehensive test coverage for the CTA component, validating rendering with full and minimal field configurations, variant handling, and default behavior.

Replace the CTA stub with a real renderer displaying heading, body text,
and a tappable button with primary/secondary variant styling.

Resolves #307

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

Warning

Rate limit exceeded

@up-tandem has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 31 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e02b9ddc-0146-463c-8a1a-c71b11813f05

📥 Commits

Reviewing files that changed from the base of the PR and between 35aae33 and de2d9b4.

📒 Files selected for processing (1)
  • mobile/expo/src/components/sections/CTARenderer.tsx

Walkthrough

Implements the CTARenderer component as a full React Native implementation to replace the temporary stub. The component renders call-to-action sections with optional heading and body text, a pressable button supporting primary and secondary variants, and URL navigation via Linking.openURL. Integration points are updated to use the new implementation.

Changes

Cohort / File(s) Summary
CTARenderer Implementation
mobile/expo/src/components/sections/CTARenderer.tsx, mobile/expo/src/components/sections/CTARenderer.test.tsx
New CTARenderer component with TypeScript prop interface, conditional rendering of heading and body text, styled pressable button with variant support (primary/secondary), pressed-state styling, and URL opening via Linking API. Basic test coverage for full props, minimal props, variant handling, and null variant defaults.
Stub Removal
mobile/expo/src/components/sections/CTAStub.tsx
Removed stub CTARenderer implementation and CTARendererProps interface (42 lines deleted).
Integration Updates
mobile/expo/src/components/sections/SectionDispatcher.tsx, mobile/expo/src/components/sections/index.ts
Updated import and public export of CTARenderer to reference new implementation file instead of stub module.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and concisely describes the main change: introducing a new CTARenderer section component for the mobile-expo codebase.
Linked Issues check ✅ Passed All acceptance criteria from issue #307 are met: heading and body rendering, tappable button with buttonLabel/buttonLink, primary/secondary variant support, graceful null handling, stub replacement, and accessibility considerations.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the CTARenderer component and removing the stub as specified in issue #307; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/307-cta-renderer

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@mobile/expo/src/components/sections/CTARenderer.tsx`:
- Around line 13-16: The CTA currently calls Linking.openURL inside handlePress
and discards Promise rejections and the UI still renders as an active link when
buttonLink is null; update the CTARenderer so the clickable control derives a
disabled state from buttonLink (e.g., treat null/empty/invalid URL as disabled)
and reflect that in the rendered button/Touchable (so it is not
accessible/pressable when disabled), and modify handlePress to await or call
Linking.openURL(buttonLink).catch(...) to handle and log/show failures instead
of discarding the rejection; reference the handlePress function and the
conditional around buttonLink in CTARenderer to implement these changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8047f923-c65b-42d1-9723-e406179442ae

📥 Commits

Reviewing files that changed from the base of the PR and between 2bc0bcd and 35aae33.

📒 Files selected for processing (5)
  • mobile/expo/src/components/sections/CTARenderer.test.tsx
  • mobile/expo/src/components/sections/CTARenderer.tsx
  • mobile/expo/src/components/sections/CTAStub.tsx
  • mobile/expo/src/components/sections/SectionDispatcher.tsx
  • mobile/expo/src/components/sections/index.ts
💤 Files with no reviewable changes (1)
  • mobile/expo/src/components/sections/CTAStub.tsx

Comment on lines +13 to +16
const handlePress = () => {
if (buttonLink) {
void Linking.openURL(buttonLink)
}
Copy link

@coderabbitai coderabbitai bot Mar 10, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, locate the file
find . -type f -name "CTARenderer.tsx" 2>/dev/null | head -20

Repository: JesusFilm/forge

Length of output: 112


🏁 Script executed:

# Also check for sectionModels.ts
find . -type f -name "sectionModels.ts" 2>/dev/null | head -20

Repository: JesusFilm/forge

Length of output: 97


🏁 Script executed:

# List the mobile directory structure to understand the layout
ls -la mobile/ 2>/dev/null || echo "mobile directory not found"

Repository: JesusFilm/forge

Length of output: 451


🏁 Script executed:

# Read the CTARenderer.tsx file to verify the code
cat -n ./mobile/expo/src/components/sections/CTARenderer.tsx

Repository: JesusFilm/forge

Length of output: 3524


🏁 Script executed:

# Read the sectionModels.ts file to verify buttonLink is nullable
cat -n ./mobile/expo/src/lib/sectionModels.ts

Repository: JesusFilm/forge

Length of output: 6199


Disable the CTA when there is no target, and handle failed URL opens.

Line 15 discards the Linking.openURL Promise rejection, and lines 33–45 still expose the control as an active link when buttonLink is null. With CMS-driven data, missing or malformed URLs become either a dead accessible control or an unhandled rejection on tap. Derive a disabled state from buttonLink and catch the open failure.

Suggested fix
 export function CTARenderer({ section }: CTARendererProps) {
   const { heading, body, buttonLabel, buttonLink, variant } = section
   const isPrimary = variant !== "secondary"
+  const isDisabled = buttonLink == null
 
-  const handlePress = () => {
-    if (buttonLink) {
-      void Linking.openURL(buttonLink)
-    }
+  const handlePress = async () => {
+    if (buttonLink == null) return
+    try {
+      await Linking.openURL(buttonLink)
+    } catch {
+      console.warn(`CTARenderer: failed to open CTA link for section "${section.id}"`)
+    }
   }
 
   return (
@@
       <Pressable
@@
         onPress={handlePress}
+        disabled={isDisabled}
         accessibilityRole="link"
         accessibilityLabel={buttonLabel}
+        accessibilityState={{ disabled: isDisabled }}
       >
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mobile/expo/src/components/sections/CTARenderer.tsx` around lines 13 - 16,
The CTA currently calls Linking.openURL inside handlePress and discards Promise
rejections and the UI still renders as an active link when buttonLink is null;
update the CTARenderer so the clickable control derives a disabled state from
buttonLink (e.g., treat null/empty/invalid URL as disabled) and reflect that in
the rendered button/Touchable (so it is not accessible/pressable when disabled),
and modify handlePress to await or call Linking.openURL(buttonLink).catch(...)
to handle and log/show failures instead of discarding the rejection; reference
the handlePress function and the conditional around buttonLink in CTARenderer to
implement these changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in de2d9b4 — added disabled prop and reduced opacity styling when buttonLink is null. The button is now visually muted and non-interactive when there is no target URL.

Copy link

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
cat -n ./mobile/expo/src/components/sections/CTARenderer.tsx

Length of output: 3667


@up-tandem, the disabled prop, isDisabled derivation, and the buttonDisabled opacity style are all correctly in place — the control is now properly non-interactive and visually muted when buttonLink is null. Thanks for addressing that.

One part of the original comment is still open though: Line 16 still uses void Linking.openURL(buttonLink), which silently swallows any rejection (e.g. a malformed URL from the CMS). The handlePress could be updated to catch and log the failure:

const handlePress = async () => {
  if (buttonLink == null) return
  try {
    await Linking.openURL(buttonLink)
  } catch {
    console.warn(`CTARenderer: failed to open URL "${buttonLink}"`)
  }
}

Would you like to address that as well, or defer it to a follow-up?


🧠 Learnings used
Learnt from: up-tandem
Repo: JesusFilm/forge PR: 321
File: mobile/expo/src/components/sections/VideoHeroRenderer.tsx:30-84
Timestamp: 2026-03-10T00:46:57.860Z
Learning: Do not flag ts-expect-error on JSX elements in the section renderers under mobile/expo/src/components/sections/. This is a project-wide convention (introduced in scaffold PR `#317`) to address React 19 vs React Native type incompatibilities. Treat migrations to import { JSX } from 'react' as a separate cross-cutting chore applied uniformly across the codebase.

Add disabled state and reduced opacity when buttonLink is missing to
prevent exposing a dead accessible control.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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(mobile-expo): CTARenderer section component

1 participant