Skip to content

Fix android annotation for jetpack#1071

Closed
sacOO7 wants to merge 1 commit intomainfrom
feature/chat-android-lang-support
Closed

Fix android annotation for jetpack#1071
sacOO7 wants to merge 1 commit intomainfrom
feature/chat-android-lang-support

Conversation

@sacOO7
Copy link
Contributor

@sacOO7 sacOO7 commented Feb 11, 2026

Summary by CodeRabbit

  • New Features

    • Added Android language support for code snippets with syntax highlighting.
  • Bug Fixes

    • Improved language resolution logic to better match language identifiers across various code snippet formats and SDK types.
  • Changes

    • Removed Jetpack language option from available languages.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

Walkthrough

The changes replace the "jetpack" language annotation with "chat_android" and enhance language resolution logic. Language matching now prioritizes exact lowercased key lookups, then attempts SDK prefix-stripping fallbacks, with support for the new "chat_" prefix pattern.

Changes

Cohort / File(s) Summary
Language Resolution Enhancement
src/core/CodeSnippet.tsx
Enhanced language fallback logic to return exact matches, attempt prefixed language matching by stripping SDK type, and fall back to the original lang value when no match is found.
Language Map Update
src/core/CodeSnippet/languages.ts
Replaced "jetpack" entry with "chat_android" (label: "Android", icon: "icon-tech-android-full"). Extended stripSdkType to handle "chat_" prefixed keys. Updated getLanguageInfo to prefer exact lowercased key matches before attempting prefix-stripping resolution.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Jetpack hops away, Android takes the stage,
With chat_android leading, a new page!
Language matching logic, now so refined,
Prefixes stripped with precision in mind—
LLMs will read clearer, snippets realigned!

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning PR description is minimal with only Jira ticket and GitHub PR links, missing required sections like motivation, summary of changes, testing steps, and checklists. Expand PR description to include: detailed motivation/context, summary of changes (language replacement from Jetpack to Android, logic updates), manual testing steps, and completion of merge checklist items.
Title check ⚠️ Warning The title references 'android annotation for jetpack' but the primary change is replacing jetpack with chat_android and adding support for Android language annotation to improve LLM selection. Update title to reflect the main objective: 'Replace jetpack annotation with chat_android for better LLM snippet selection' or similar, clarifying that jetpack is being replaced, not fixed.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code changes successfully address DX-553 by replacing the jetpack language entry with chat_android and updating language resolution logic to support this change, meeting the stated objective to improve LLM snippet selection.
Out of Scope Changes check ✅ Passed All changes are directly scoped to DX-553: replacing jetpack with chat_android entry, extending SDK type stripping to handle chat_ prefix, and improving language key resolution logic.
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 docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/chat-android-lang-support

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 force-pushed the feature/chat-android-lang-support branch 2 times, most recently from 8e8868b to e866682 Compare February 12, 2026 05:22
@sacOO7 sacOO7 requested a review from Copilot February 12, 2026 06:39
@sacOO7
Copy link
Contributor Author

sacOO7 commented Feb 12, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 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

This pull request adds support for the chat_android language annotation in code snippets. It replaces the unused jetpack language entry with a new chat_android entry that uses Kotlin syntax highlighting and an Android-specific icon. The PR also enhances the language resolution logic to support SDK-prefixed languages like chat_android.

Changes:

  • Added chat_android language configuration with Android-specific icon and Kotlin syntax highlighting
  • Extended stripSdkType function to handle chat_ prefixes alongside existing realtime_ and rest_ prefixes
  • Improved language matching logic in getLanguageInfo to check full language keys before attempting to strip SDK prefixes
  • Enhanced language resolution in CodeSnippet component to find SDK-prefixed language matches when exact matches don't exist

Reviewed changes

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

File Description
src/core/CodeSnippet/languages.ts Adds chat_android language entry, updates stripSdkType to handle chat_ prefix, and improves getLanguageInfo fallback logic
src/core/CodeSnippet.tsx Enhances language resolution to match prefixed languages when direct matches aren't found

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

Copy link
Contributor

@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 (1)
src/core/CodeSnippet/languages.ts (1)

118-132: ⚠️ Potential issue | 🟡 Minor

Duplicate "Android" label between android and chat_android.

Both entries use label: "Android". When a CodeSnippet includes both plain android and chat_android code blocks (with no SDK prefix context triggering filtering), the LanguageSelector displays two tabs labeled "Android"—differentiated only by icon. Consider disambiguating one label (e.g., "Android (Compose)") or documenting the constraint that these two should never coexist in the same snippet.

🧹 Nitpick comments (1)
src/core/CodeSnippet/languages.ts (1)

148-151: Cache the lowercased key to avoid repeated toLowerCase() calls.

langKey.toLowerCase() is computed twice. Minor, but easy to clean up.

♻️ Proposed fix
 export const getLanguageInfo = (langKey: string): LanguageInfo => {
-  // Check full key first (e.g., "chat_android" has its own entry)
-  if (languages[langKey.toLowerCase()]) {
-    return languages[langKey.toLowerCase()];
-  }
+  const lowerKey = langKey.toLowerCase();
+  // Check full key first (e.g., "chat_android" has its own entry)
+  if (languages[lowerKey]) {
+    return languages[lowerKey];
+  }
 
-  // Then try stripping the SDK type prefix
-  const key = stripSdkType(langKey).toLowerCase();
+  // Then try stripping the SDK type prefix
+  const key = stripSdkType(lowerKey);
   if (languages[key]) {

@sacOO7 sacOO7 force-pushed the feature/chat-android-lang-support branch from e866682 to 68721e2 Compare February 12, 2026 07:38
@sacOO7 sacOO7 marked this pull request as ready for review February 12, 2026 07:39
@sacOO7 sacOO7 requested a review from aralovelace February 12, 2026 07:40
@sacOO7 sacOO7 changed the title Added support for chat_android code snippet annotation Fix android annotation for jetpack Feb 12, 2026
@sacOO7 sacOO7 requested review from GregHolmes and ttypic February 12, 2026 07:56
@sacOO7
Copy link
Contributor Author

sacOO7 commented Feb 12, 2026

closing in favor of https://github.com/ably/website/pull/7828

@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

None yet

Development

Successfully merging this pull request may close these issues.

1 participant