Skip to content

Conversation

@ucswift
Copy link
Member

@ucswift ucswift commented Jan 25, 2026

Summary by CodeRabbit

  • Chores
    • Improved Android package resolution to reliably detect the app base package for native module registration.
    • Ensured module import and registration use the resolved base package across build variants for more consistent behavior.
    • Added clarifying comments and documentation for the package-resolution logic and modification flow.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 25, 2026

📝 Walkthrough

Walkthrough

Reads Android base package name from android/app/build.gradle (Groovy or Kotlin DSL) via a new resolveBasePackageName(projectRoot, fallback) helper and uses that base package for the MediaButtonPackage import when patching MainApplication.kt; falls back to com.resgrid.unit.

Changes

Cohort / File(s) Summary
MediaButton plugin
plugins/withMediaButtonModule.js
Added resolveBasePackageName(projectRoot, fallback) to extract namespace from android/app/build.gradle or android/app/build.gradle.kts (regex probe). Replaced inline package-derivation logic with the helper, used resolved basePackageName for MediaButtonPackage import, added logging and comments, and introduced a local projectRoot reference. Lines: +47/-17

Sequence Diagram(s)

sequenceDiagram
  participant CLI as Plugin (withMediaButtonModule)
  participant FS as File System
  participant Gradle as android/app/build.gradle(.kts)
  participant MainApp as android/app/src/.../MainApplication.kt

  CLI->>FS: read projectRoot config
  CLI->>Gradle: probe for namespace via regex
  Gradle-->>CLI: return basePackageName (or fallback)
  CLI->>MainApp: open MainApplication.kt
  CLI->>MainApp: insert import using basePackageName
  CLI->>FS: write patched MainApplication.kt
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • RU-T46 Native PPT Android fix #200 — Also modifies plugins/withMediaButtonModule.js to add MediaButtonPackage import to MainApplication.kt, but derives the package from MainApplication.kt content rather than reading Gradle namespace.

Poem

🐰 I sniffed the Gradle, found the namespace true,
No more file-guessing, just a clearer view,
projectRoot leads where the namespaces play,
I hop in to patch imports — hooray! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'RU-T46 Fixing build' is too vague and generic. It lacks specificity about what aspect of the build is being fixed, making it difficult for reviewers scanning history to understand the primary change. Replace with a more descriptive title that specifies the actual change, such as 'Resolve Android base package name detection in MediaButtonModule' or 'Fix MediaButtonPackage import path resolution for Android builds'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings

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

🤖 Fix all issues with AI agents
In `@plugins/withMediaButtonModule.js`:
- Around line 487-495: Extract the namespace-parsing logic into a helper (e.g.,
getAndroidNamespace or resolveBasePackageName) and replace the duplicated blocks
at the sites that build the package name (the blocks around the existing
namespaceMatch usage and the duplicate at lines near 448 and 492) with calls to
that helper; the helper should probe both android/app/build.gradle and
android/app/build.gradle.kts (and fall back to the existing default
'com.resgrid.unit'), read file content, and use an expanded regex that accepts
an optional equals sign such as /namespace\s*(?:=)?\s*['"]([^'"]+)['"]/ to
reliably capture the namespace across Groovy and Kotlin DSLs, then return the
captured namespace or the fallback.
🧹 Nitpick comments (1)
plugins/withMediaButtonModule.js (1)

481-495: Consider extracting namespace resolution into a helper.

The same build.gradle parsing logic now exists in two places (Android mod and MainApplication update). A small helper (e.g., getAndroidNamespace(projectRoot)) would keep behavior consistent and reduce maintenance overhead.

@ucswift
Copy link
Member Author

ucswift commented Jan 25, 2026

Approve

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This PR is approved.

@ucswift ucswift merged commit 2cbb039 into master Jan 25, 2026
13 of 14 checks passed
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