Skip to content

Fix jetpack snippets for android#3190

Closed
sacOO7 wants to merge 6 commits intomainfrom
fix/jetpack-snippets-for-android
Closed

Fix jetpack snippets for android#3190
sacOO7 wants to merge 6 commits intomainfrom
fix/jetpack-snippets-for-android

Conversation

@sacOO7
Copy link
Contributor

@sacOO7 sacOO7 commented Feb 10, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Added dedicated Android language support for chat documentation with improved Kotlin syntax highlighting and code examples.
  • Documentation

    • Updated chat documentation to enhance Android platform rendering and ensure code samples display correctly across multiple guides.

@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This PR migrates the codebase from "jetpack" to "chat_android" language annotations across UI and documentation. It adds chat_android support in language resolution logic, updates configuration files, and replaces all jetpack code blocks and language guards with chat_android/android equivalents in 13 chat MDX files.

Changes

Cohort / File(s) Summary
Core Language Configuration
src/data/languages/types.ts, src/data/languages/languageInfo.ts, src/data/languages/languageData.ts
Replaced jetpack language key with chat_android in type definitions, language metadata, and chat language data. Updated syntaxHighlighterKey to remain "kotlin" while changing label to "Android".
UI Language Support
ably-ui/.../languages.ts
Added new chat_android language entry with label "Android", icon "icon-tech-android-head", and syntaxHighlighterKey "kotlin". Removed jetpack entry. Updated resolution logic to support full-key lookup and fallback to stripped keys with prefix reconstruction for proper rendering.
Chat Documentation MDX Files
src/pages/docs/chat/setup.mdx, src/pages/docs/chat/connect.mdx, src/pages/docs/chat/getting-started/android.mdx, src/pages/docs/chat/rooms/index.mdx, src/pages/docs/chat/rooms/messages.mdx, src/pages/docs/chat/rooms/presence.mdx, src/pages/docs/chat/rooms/occupancy.mdx, src/pages/docs/chat/rooms/history.mdx, src/pages/docs/chat/rooms/media.mdx, src/pages/docs/chat/rooms/message-reactions.mdx, src/pages/docs/chat/rooms/reactions.mdx, src/pages/docs/chat/rooms/replies.mdx, src/pages/docs/chat/rooms/typing.mdx
Systematically replaced code fence language identifiers from \``jetpackto```chat_androidand updated conditional language guards fromto` across all 13 chat documentation files. Updated code samples to reference Android/Kotlin implementations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • AndyTWF
  • ttypic

Poem

🐰 Jetpack hops away, Android hops in,
Chat pages now render with cleaner discipline!
From UI to docs, a language refrain,
Compose becomes Android—much simpler, much sane! 🤖✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: replacing jetpack snippets with android equivalents across the codebase.
Linked Issues check ✅ Passed The PR fully addresses DX-553 by systematically replacing Jetpack language annotations with Android/chat_android across all chat documentation files and configuration, enabling LLMs to better identify Android-targeted snippets.
Out of Scope Changes check ✅ Passed All changes directly support the migration from Jetpack to Android annotations; no unrelated modifications to core logic, dependencies, or unrelated features were introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 fix/jetpack-snippets-for-android

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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.

@sacOO7 sacOO7 requested a review from Copilot February 11, 2026 06:30
@sacOO7 sacOO7 added the review-app Create a Heroku review app label Feb 11, 2026
@ably-ci ably-ci temporarily deployed to ably-docs-fix-jetpack-s-hzjzji February 11, 2026 06:31 Inactive
@sacOO7
Copy link
Contributor Author

sacOO7 commented Feb 11, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Chat documentation snippet language tagging to treat Android (Jetpack Compose) examples as an Android variant with Kotlin highlighting, addressing DX-553.

Changes:

  • Replaced jetpack language conditionals with android across Chat MDX pages.
  • Migrated Jetpack/Compose code fences to a new chat_android snippet key.
  • Updated language configuration (types, languageInfo, languageData) to support chat_android and include android for Chat.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/pages/docs/chat/setup.mdx Switches Jetpack conditionals/snippets to Android + chat_android for setup examples.
src/pages/docs/chat/rooms/typing.mdx Updates Android-specific typing indicator sections/snippets to use android + chat_android.
src/pages/docs/chat/rooms/replies.mdx Migrates Compose-related code fences to chat_android.
src/pages/docs/chat/rooms/reactions.mdx Migrates Compose-related code fences and conditionals to android + chat_android.
src/pages/docs/chat/rooms/presence.mdx Migrates presence Compose snippets/conditionals to android + chat_android.
src/pages/docs/chat/rooms/occupancy.mdx Migrates occupancy Compose snippets/conditionals to android + chat_android.
src/pages/docs/chat/rooms/messages.mdx Migrates message Compose snippets/conditionals to android + chat_android.
src/pages/docs/chat/rooms/message-reactions.mdx Migrates message reaction snippets/conditionals to android + chat_android.
src/pages/docs/chat/rooms/media.mdx Migrates media Compose snippets to chat_android.
src/pages/docs/chat/rooms/index.mdx Migrates room lifecycle snippets/conditionals to android + chat_android.
src/pages/docs/chat/rooms/history.mdx Migrates history Compose snippets/conditionals to android + chat_android.
src/pages/docs/chat/getting-started/android.mdx Migrates Android getting-started Kotlin snippets to chat_android.
src/pages/docs/chat/connect.mdx Migrates connection-status Compose snippets/conditionals to android + chat_android.
src/data/languages/types.ts Replaces jetpack language key with chat_android in the LanguageKey set.
src/data/languages/languageInfo.ts Adds chat_android language info (Android label, Kotlin highlighter).
src/data/languages/languageData.ts Switches Chat product language key from jetpack to android.
jetpack_to_android.md Adds an implementation plan/migration notes for the language-key change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

swift: '1.0',
kotlin: '1.1',
jetpack: '1.1',
android: '1.1',
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

chat_android code fences are now being used in Chat MDX pages, but languageData.chat is keyed on android. This only works if the runtime language normalization (via stripSdkType from @ably/ui) strips the chat_ prefix and the CodeSnippet component can map the active android selection back to chat_android blocks. If @ably/ui in this repo doesn’t yet support chat_ prefixes, Android snippets/conditionals will fail to render. Please ensure the required @ably/ui changes/version bump lands alongside this PR (or adjust the docs to use the currently supported language key).

Suggested change
android: '1.1',
android: '1.1',
chat_android: '1.1',

Copilot uses AI. Check for mistakes.
@@ -26,7 +26,7 @@ export const languageKeys = [
'css',
'laravel',
'typescript',
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

languageKeys contains typescript twice. This is harmless at runtime but adds noise and can make grepping / maintenance harder; consider removing the duplicate entry so the list stays canonical.

Suggested change
'typescript',

Copilot uses AI. Check for mistakes.
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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (5)
src/pages/docs/chat/getting-started/android.mdx (1)

966-971: ⚠️ Potential issue | 🟡 Minor

Links point to ?lang=kotlin — should these use ?lang=android instead?

Since this is the Android getting-started guide, users following these links would be switched to the Kotlin tab rather than the Android tab on the target pages. If those pages have chat_android code blocks (which many do per this PR), the links should arguably use ?lang=android to maintain continuity.

src/pages/docs/chat/rooms/media.mdx (1)

609-638: ⚠️ Potential issue | 🟡 Minor

The chat_android snippet uses coil.compose.AsyncImage (line 613) without mentioning the Coil dependency.

Users following this documentation would get a compilation error since Coil isn't included in the project dependencies mentioned earlier. Consider adding a note about the required Coil dependency, or use a placeholder/comment like the kotlin block does (line 595-596: // Load image from URL (using Coil, Glide, or Picasso)).

src/pages/docs/chat/rooms/messages.mdx (2)

339-364: ⚠️ Potential issue | 🟡 Minor

Uninitialized val inside @Composable function won't compile.

Line 351: val originalMessage: Message // assume this is available — this is a declaration without initialization, which is a Kotlin compile error. In the kotlin block (Line 332–337), originalMessage is similarly declared but in a non-Composable context where it reads as pseudocode. Inside a @Composable function with a full component structure, this looks like broken code.

Consider accepting originalMessage as a parameter or using a remember/state variable.

Proposed fix
 `@Composable`
-fun MyComponent(room: Room) {
+fun MyComponent(room: Room, originalMessage: Message) {
   val coroutineScope = rememberCoroutineScope()
-  val originalMessage: Message // assume this is available

594-618: ⚠️ Potential issue | 🟡 Minor

Same uninitialized val issue in delete message sample.

Line 605: val messageToDelete: Message // assume this is available has the same compile error as the update sample. Should be a function parameter.

Proposed fix
 `@Composable`
-fun MyComponent(room: Room) {
+fun MyComponent(room: Room, messageToDelete: Message) {
   val coroutineScope = rememberCoroutineScope()
-  val messageToDelete: Message // assume this is available
src/pages/docs/chat/rooms/presence.mdx (1)

213-242: ⚠️ Potential issue | 🟡 Minor

Incomplete DisposableEffect with empty onDispose is confusing.

Lines 234–240 show a DisposableEffect with an empty onDispose and a comment suggesting the developer should "consider using a coroutine scope." This is unhelpful in documentation — it introduces a pattern without completing it, leaving the reader unsure how to properly leave presence on disposal.

Either show a working pattern (e.g., using rememberCoroutineScope or LaunchedEffect with try/finally) or remove the DisposableEffect block entirely and add a note explaining that presence leave on disposal requires additional handling.

Proposed fix — use try/finally in LaunchedEffect
 `@Composable`
 fun EnterPresenceComponent(room: Room) {
   LaunchedEffect(room) {
-    // Ensure room is attached before entering presence
-    if (room.status != RoomStatus.Attached) {
-      room.attach()
-    }
-
-    room.presence.enter(
-      jsonObject {
-        put("status", "Online")
-      }
-    )
-  }
-
-  // Leave presence when component is disposed
-  DisposableEffect(room) {
-    onDispose {
-      // Note: Consider using a coroutine scope for leave()
-      // as DisposableEffect doesn't support suspend functions directly
+    try {
+      // Ensure room is attached before entering presence
+      if (room.status != RoomStatus.Attached) {
+        room.attach()
+      }
+      room.presence.enter(
+        jsonObject {
+          put("status", "Online")
+        }
+      )
+      // Keep the coroutine alive until disposal
+      kotlinx.coroutines.awaitCancellation()
+    } finally {
+      room.presence.leave()
     }
   }
 }
🧹 Nitpick comments (13)
src/pages/docs/chat/rooms/replies.mdx (1)

194-204: The chat_android prepareReply function is nearly identical to the kotlin block (lines 183–192).

The only difference is the added import line. This is acceptable for documentation to ensure tab content isn't empty, but if the intent is to differentiate Android snippets, consider whether a Compose-based variant would be more useful here.

src/pages/docs/chat/rooms/media.mdx (1)

97-121: The chat_android uploadMedia function is identical to the kotlin block (lines 71–95).

Same observation as in replies.mdx — this is acceptable for tab completeness but adds no Android/Compose-specific value.

src/pages/docs/chat/rooms/message-reactions.mdx (2)

871-892: Inconsistent subscription pattern in raw reactions Android sample.

The summary reactions subscription (Line 593) uses the asFlow().collect pattern with LaunchedEffect, but the raw reactions subscription here uses the callback-based subscribeRaw with DisposableEffect. If subscribeRaw doesn't have a Flow equivalent, consider adding a brief comment explaining why the pattern differs to avoid confusion for developers reading both snippets.


62-68: Several chat_android blocks are identical to their kotlin counterparts.

Lines 62–68 and 805–811 (and similarly Line 522–550) contain chat_android code blocks that are exact duplicates of the adjacent kotlin blocks. While this is part of the migration strategy to show a separate Android tab, these identical snippets provide no additional value to the reader and will create a maintenance burden — every future edit must be mirrored in both blocks.

Consider whether non-Compose snippets (pure Kotlin API calls with no UI) truly need a separate chat_android variant. Reserving chat_android for Compose-specific examples (like Lines 173–208, 593–604) would reduce duplication.

Also applies to: 805-811

src/pages/docs/chat/rooms/history.mdx (1)

75-86: Duplicate of Kotlin block — same concern as in message-reactions.mdx.

This chat_android block is byte-for-byte identical to the kotlin block above (Lines 62–73). Same recommendation: consider omitting chat_android variants that contain no Compose-specific code.

src/pages/docs/chat/connect.mdx (1)

60-62: Same duplication pattern — chat_android block identical to kotlin.

val connectionStatus = chatClient.connection.status is pure Kotlin with no Compose involvement. Same recommendation as other files.

src/pages/docs/chat/rooms/index.mdx (1)

74-76: Multiple chat_android blocks are exact duplicates of kotlin blocks.

Six chat_android code blocks in this file are identical to their kotlin counterparts (e.g., rooms.get, rooms.release, room.attach, room.detach, room.status). This amplifies the maintenance burden across the docs. Consider a consolidated approach where only Compose-specific examples get a dedicated chat_android block.

Also applies to: 128-140, 175-177, 229-231, 260-262, 334-336

src/pages/docs/chat/rooms/messages.mdx (1)

272-274: Duplicate of Kotlin block — messages.get() call has no Compose-specific content.

src/pages/docs/chat/rooms/occupancy.mdx (1)

206-208: Two more chat_android blocks identical to kotlinoccupancy.current and occupancy.get().

Same duplication concern as across other files.

Also applies to: 255-257

src/pages/docs/chat/rooms/typing.mdx (1)

335-337: chat_android block identical to kotlin for typing.current.

Same duplication concern.

src/pages/docs/chat/rooms/presence.mdx (1)

498-504: Two more chat_android blocks identical to kotlinpresence.get() and isUserPresent().

Same duplication concern as across other files.

Also applies to: 522-524

jetpack_to_android.md (2)

348-381: Specify language for the data flow diagram code fence.

The data flow walkthrough is excellent and provides valuable end-to-end verification of the approach. However, the fenced code block at line 348 should specify a language to satisfy the linter.

📝 Suggested fix
-```
+```text
 MDX file: ```chat_android

325-393: Consider adding testing and verification strategy.

The implementation plan is comprehensive, but it would benefit from a section describing how to test and verify the changes work correctly. Given the complexity and cross-repository coordination, consider adding:

  1. Manual testing checklist: Verify code blocks render with Kotlin highlighting, language selector shows "Android", <If> conditionals display correctly, etc.
  2. Automated tests: If applicable, unit tests for stripSdkType(), getLanguageInfo(), and activeLanguage resolution logic
  3. Visual regression tests: Screenshots comparing before/after rendering of chat pages
  4. Verification in both contexts: Test that pub/sub android pages still work with Java highlighting

The risk assessment (lines 383-393) is thorough, but explicit test cases would provide additional confidence in the migration.

@ably-ci ably-ci temporarily deployed to ably-docs-fix-jetpack-s-glsge5 February 11, 2026 09:35 Inactive
@ably-ci ably-ci temporarily deployed to ably-docs-fix-jetpack-s-xjjymh February 12, 2026 06:35 Inactive
@sacOO7
Copy link
Contributor Author

sacOO7 commented Feb 12, 2026

closing in favor of #3195

@sacOO7 sacOO7 closed this Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-app Create a Heroku review app

Development

Successfully merging this pull request may close these issues.

2 participants