Add support for fe_/be_ language prefixes in CodeSnippet#1060
Add support for fe_/be_ language prefixes in CodeSnippet#1060GregHolmes wants to merge 2 commits intomainfrom
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe CodeSnippet component is extended to support frontend ("fe") and backend ("be") SDK types alongside existing "realtime" and "rest" types. Language detection is enhanced with a new helper function, SDK prefix handling is expanded, and a fixed-language label rendering path is introduced. The languages utility adds new language definitions and a helper function to retrieve language information. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
kennethkalmer
left a comment
There was a problem hiding this comment.
These changes support dual language selection in documentation, allowing separate client and agent language selectors for AI Transport guides.
This differs from be_ and fe_, and I think we should put a bit more thought into the names of these values as they will be with us for a long time :)
@GregHolmes is there some more context to help come up with better names?
src/core/CodeSnippet.tsx
Outdated
|
|
||
| // Define SDK type | ||
| export type SDKType = "realtime" | "rest" | null; | ||
| export type SDKType = "realtime" | "rest" | "fe" | "be" | null; |
There was a problem hiding this comment.
do we need to add null here? since its not really a valid SDK type?
src/core/CodeSnippet/languages.ts
Outdated
| export const stripSdkType = (lang: string) => { | ||
| if (lang.startsWith("realtime_") || lang.startsWith("rest_")) { | ||
| return lang.split("_").slice(1).join("_"); | ||
| const prefixes = ["realtime_", "rest_", "fe_", "be_"]; |
There was a problem hiding this comment.
since we already have SDKType should we use it here than using a prefixes to unify them and just append the '_' in the comparison
0a0cda2 to
2e6d3b1
Compare
|
@kennethkalmer @aralovelace I've made a few changes following your feedback. I realise I need to move this over to the other repository, but is it possible to get the review so far of the changes so the context isn't lost please? |
- Add 'fe' and 'be' to SDKType union for frontend/backend code blocks - Update stripSdkType() to handle fe_ and be_ prefixes - Add findCodeElement helper to handle array children (fixes code extraction when pre element has multiple children) - Add showFixedLanguageLabel to display read-only language indicator when code block is controlled by external selector (fixed=true) These changes support dual language selection in documentation, allowing separate client and agent language selectors for AI Transport guides.
Test stripSdkType, getLanguageInfo, and SDK_PREFIXES in languages.ts Test CodeSnippet rendering, SDK selector, and language resolution Update vite config to include test files Update stories with client/agent examples
2e6d3b1 to
77588d4
Compare
SDK_PREFIXESconstant with derivedSDKTypestripSdkType()to useSDK_PREFIXESloop instead of hardcoded conditionsfindCodeElementhelper to handle array children (fixes code extraction when pre element has multiple children)renderLanguageLabelto deduplicate language label JSXshowFixedLanguageLabelto display read-only language indicator when code block is controlled by external selector (fixed=true)These changes support dual language selection in documentation, allowing separate client and agent language selectors for AI Transport guides.
Summary by CodeRabbit
Release Notes