Conversation
WalkthroughThe 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
8e8868b to
e866682
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
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_androidlanguage configuration with Android-specific icon and Kotlin syntax highlighting - Extended
stripSdkTypefunction to handlechat_prefixes alongside existingrealtime_andrest_prefixes - Improved language matching logic in
getLanguageInfoto 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.
There was a problem hiding this comment.
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 | 🟡 MinorDuplicate
"Android"label betweenandroidandchat_android.Both entries use
label: "Android". When a CodeSnippet includes both plainandroidandchat_androidcode blocks (with no SDK prefix context triggering filtering), theLanguageSelectordisplays 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 repeatedtoLowerCase()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]) {
e866682 to
68721e2
Compare
|
closing in favor of https://github.com/ably/website/pull/7828 |
Summary by CodeRabbit
New Features
Bug Fixes
Changes