feat(example): Update sample app#1
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe example app was made into a live, editable playground with a responsive two‑pane editor/preview. New composables (EditorSection, CodeViewSection), a CodeView optional ChangesInteractive Editor, Theme, and Example Wiring
Sequence DiagramsequenceDiagram
participant User
participant EditorSection
participant AppState
participant CodeViewSection
participant CodeView
User->>EditorSection: type text
EditorSection->>AppState: onValueChange(newCode)
AppState->>AppState: update userInput
AppState->>CodeViewSection: supply updated code
CodeViewSection->>CodeView: render(code, fontFamily)
CodeView-->>CodeViewSection: rendered output
CodeViewSection-->>User: display preview
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt`:
- Around line 90-96: The TextField currently lacks a label for accessibility;
remove the separate Text("Edit Code") and add the label parameter to the
TextField (e.g., label = { Text("Edit Code") }) so the field exposes a semantic
label to assistive tech; keep existing props like value = code, onValueChange =
onValueChange, modifier = Modifier.fillMaxWidth(), and textStyle =
MaterialTheme.typography.bodyMedium when updating the invocation of TextField.
- Around line 54-63: The BoxWithConstraints modifier chain inside the composable
(the block using innerPadding and modifiers
.padding(innerPadding).fillMaxSize().statusBarsPadding().displayCutoutPadding().imePadding())
is missing navigation bar insets; add .navigationBarsPadding() into that
Modifier chain (e.g., before or after imePadding()) so bottom content isn't
obscured by persistent Android navigation bars.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8feb7135-7d44-4c8b-b903-838644c4d8bd
📒 Files selected for processing (2)
example/src/androidMain/AndroidManifest.xmlexample/src/commonMain/kotlin/io/github/komodgn/example/Application.kt
…ation.kt - [skip ci] Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt (1)
54-62:⚠️ Potential issue | 🟠 Major | ⚡ Quick win
navigationBarsPadding()is still missing after zeroing Scaffold insets.Because
contentWindowInsetsis set to zero, bottom system insets must be reapplied explicitly. WithoutnavigationBarsPadding(), bottom content can still sit under persistent Android nav bars when IME is hidden.Suggested fix
BoxWithConstraints( modifier = Modifier .padding(innerPadding) .fillMaxSize() .statusBarsPadding() .displayCutoutPadding() + .navigationBarsPadding() .imePadding(), ) {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt` around lines 54 - 62, The Scaffold zeroes window insets via contentWindowInsets = WindowInsets(0, 0, 0, 0) but you didn't reapply bottom system inset padding, so add navigationBarsPadding() to the Modifier chain inside BoxWithConstraints (where you already call .statusBarsPadding(), .displayCutoutPadding(), .imePadding()) so the bottom navigation bar inset is reapplied and content won't sit under persistent Android nav bars; update the Modifier used in BoxWithConstraints to include .navigationBarsPadding() alongside the existing padding modifiers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt`:
- Around line 54-62: The Scaffold zeroes window insets via contentWindowInsets =
WindowInsets(0, 0, 0, 0) but you didn't reapply bottom system inset padding, so
add navigationBarsPadding() to the Modifier chain inside BoxWithConstraints
(where you already call .statusBarsPadding(), .displayCutoutPadding(),
.imePadding()) so the bottom navigation bar inset is reapplied and content won't
sit under persistent Android nav bars; update the Modifier used in
BoxWithConstraints to include .navigationBarsPadding() alongside the existing
padding modifiers.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 342c5eb8-ac86-4fe3-8fb6-53087645a8a0
📒 Files selected for processing (1)
example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt
- Support custom fonts to fix CJK character rendering. - Provide LocalAppFontFamily via CompositionLocal.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (4)
example/src/commonMain/kotlin/io/github/komodgn/example/component/EditorSection.kt (1)
32-32: ⚡ Quick winAdd
= Modifierdefault to themodifierparameter.Same Compose API convention issue as in
CodeViewSection:modifier: Modifiershould default toModifier.♻️ Proposed fix
-fun EditorSection(code: String, onValueChange: (String) -> Unit, modifier: Modifier) { +fun EditorSection(code: String, onValueChange: (String) -> Unit, modifier: Modifier = Modifier) {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@example/src/commonMain/kotlin/io/github/komodgn/example/component/EditorSection.kt` at line 32, The EditorSection function's modifier parameter lacks a default value (should follow Compose convention like CodeViewSection); update the EditorSection signature to set modifier: Modifier = Modifier so callers can omit the modifier and preserve API consistency with CodeViewSection, and then rebuild/check any call sites that relied on the old non-default signature.example/src/commonMain/kotlin/io/github/komodgn/example/theme/CodeViewTheme.kt (1)
30-49: ⚡ Quick winMemoize
codeFontandtypographyto avoid spurious full-tree recompositions.Both
FontFamily(...)andTypography(...)are new object instances on every recomposition. BecauseLocalAppFontFamilyis backed bystaticCompositionLocalOf, a changed reference (even with the same logical value) invalidates the entire composition tree. Wrap them withremember:♻️ Proposed fix
val codeFont = FontFamily( Font(Res.font.NotoSansKR_Regular), Font(Res.font.NotoColorEmoji), ) + // Replace with:+ val fontRegular = Font(Res.font.NotoSansKR_Regular) + val fontEmoji = Font(Res.font.NotoColorEmoji) + val codeFont = remember(fontRegular, fontEmoji) { FontFamily(fontRegular, fontEmoji) } - val typography = Typography( - bodyMedium = TextStyle( - fontFamily = codeFont, - ), - labelLarge = TextStyle( - fontFamily = codeFont, - ), - ) + val typography = remember(codeFont) { + Typography( + bodyMedium = TextStyle(fontFamily = codeFont), + labelLarge = TextStyle(fontFamily = codeFont), + ) + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@example/src/commonMain/kotlin/io/github/komodgn/example/theme/CodeViewTheme.kt` around lines 30 - 49, The code creates new instances for codeFont and typography on every recomposition which causes LocalAppFontFamily (a staticCompositionLocalOf) to change its reference and trigger full-tree recompositions; fix by memoizing both values using remember (e.g., use remember { FontFamily(...) } for codeFont and remember { Typography(...) } for typography) before passing them into CompositionLocalProvider and MaterialTheme so their references remain stable across recompositions.example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt (1)
81-81: 💤 Low valueSimplify horizontal-only padding.
padding(16.dp, 0.dp, 16.dp, 0.dp)can be expressed more clearly with the named parameter.♻️ Proposed fix
- Row(modifier = Modifier.fillMaxWidth().padding(16.dp, 0.dp, 16.dp, 0.dp)) { + Row(modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp)) {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt` at line 81, The Row modifier uses padding(16.dp, 0.dp, 16.dp, 0.dp); replace this with the named horizontal parameter for clarity by calling Modifier.fillMaxWidth().padding(horizontal = 16.dp) (keep the same zero vertical padding implicitly or add vertical = 0.dp if you prefer explicitness) so the Row declaration (Row(modifier = Modifier.fillMaxWidth().padding(...))) is simplified and more readable.example/src/commonMain/kotlin/io/github/komodgn/example/component/CodeViewSection.kt (1)
30-30: ⚡ Quick winAdd
= Modifierdefault to themodifierparameter.Compose's API guidelines require all composable
Modifierparameters to default toModifier. Without a default, callers cannot omit the parameter even when no customization is needed.♻️ Proposed fix
-fun CodeViewSection(code: String, modifier: Modifier) { +fun CodeViewSection(code: String, modifier: Modifier = Modifier) {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@example/src/commonMain/kotlin/io/github/komodgn/example/component/CodeViewSection.kt` at line 30, The CodeViewSection composable's modifier parameter lacks a default, forcing callers to pass a Modifier; update the function signature for fun CodeViewSection(code: String, modifier: Modifier) to provide a default value (modifier: Modifier = Modifier) so callers can omit it, and ensure the proper Modifier import is present if needed; keep the rest of the implementation unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt`:
- Around line 92-110: The snippet returned by getInitialCode contains a type
error: in CodeDisplay the line creating greeting uses println(...) which yields
Unit and then is passed to CodeView as code:String; change the assignment in the
CodeDisplay example so greeting is a String (e.g., val greeting = "Hello,
CodeView!") and ensure CodeView(code = greeting, language = CodeLanguage.KOTLIN)
uses that string.
In `@README.md`:
- Line 18: The TOC link "3. [Contributing](`#contributing`)" is broken because the
heading is "## ⭐ Contributing" (emoji creates a different anchor); update the
heading text by removing the emoji so it reads "## Contributing" (or
alternatively change the TOC link to match the generated anchor
"#-contributing"), and also apply the same fix to the other affected occurrences
referenced (lines 91-92) so the TOC links and headings match exactly.
---
Nitpick comments:
In `@example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt`:
- Line 81: The Row modifier uses padding(16.dp, 0.dp, 16.dp, 0.dp); replace this
with the named horizontal parameter for clarity by calling
Modifier.fillMaxWidth().padding(horizontal = 16.dp) (keep the same zero vertical
padding implicitly or add vertical = 0.dp if you prefer explicitness) so the Row
declaration (Row(modifier = Modifier.fillMaxWidth().padding(...))) is simplified
and more readable.
In
`@example/src/commonMain/kotlin/io/github/komodgn/example/component/CodeViewSection.kt`:
- Line 30: The CodeViewSection composable's modifier parameter lacks a default,
forcing callers to pass a Modifier; update the function signature for fun
CodeViewSection(code: String, modifier: Modifier) to provide a default value
(modifier: Modifier = Modifier) so callers can omit it, and ensure the proper
Modifier import is present if needed; keep the rest of the implementation
unchanged.
In
`@example/src/commonMain/kotlin/io/github/komodgn/example/component/EditorSection.kt`:
- Line 32: The EditorSection function's modifier parameter lacks a default value
(should follow Compose convention like CodeViewSection); update the
EditorSection signature to set modifier: Modifier = Modifier so callers can omit
the modifier and preserve API consistency with CodeViewSection, and then
rebuild/check any call sites that relied on the old non-default signature.
In
`@example/src/commonMain/kotlin/io/github/komodgn/example/theme/CodeViewTheme.kt`:
- Around line 30-49: The code creates new instances for codeFont and typography
on every recomposition which causes LocalAppFontFamily (a
staticCompositionLocalOf) to change its reference and trigger full-tree
recompositions; fix by memoizing both values using remember (e.g., use remember
{ FontFamily(...) } for codeFont and remember { Typography(...) } for
typography) before passing them into CompositionLocalProvider and MaterialTheme
so their references remain stable across recompositions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ec6748d3-97e3-4914-ac8d-fdde06b639e2
⛔ Files ignored due to path filters (3)
example/src/commonMain/composeResources/font/NotoColorEmoji.ttfis excluded by!**/*.ttfexample/src/commonMain/composeResources/font/NotoSansKR-Regular.ttfis excluded by!**/*.ttfkotlin-js-store/yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (8)
README.mdcodeview/compose/src/commonMain/kotlin/io/github/komodgn/codeview/compose/CodeView.ktexample/src/commonMain/kotlin/io/github/komodgn/example/Application.ktexample/src/commonMain/kotlin/io/github/komodgn/example/component/CodeViewSection.ktexample/src/commonMain/kotlin/io/github/komodgn/example/component/EditorSection.ktexample/src/commonMain/kotlin/io/github/komodgn/example/theme/CodeViewTheme.ktexample/src/commonMain/kotlin/io/github/komodgn/example/theme/Font.ktexample/src/jsMain/kotlin/io/github/komodgn/example/Platform.js.kt
| private fun getInitialCode(version: String) = """ | ||
| package io.github.komodgn.example | ||
|
|
||
| /** | ||
| * Welcome to Compose CodeView v$version Demo! | ||
| * | ||
| * This library provides syntax highlighting for Compose Multiplatform. | ||
| * Feel free to edit the code on the left to see real-time updates. | ||
| */ | ||
| @Composable | ||
| fun CodeDisplay() { | ||
| val greeting = println("Hello, CodeView!") | ||
|
|
||
| CodeView( | ||
| code = greeting, | ||
| language = CodeLanguage.KOTLIN, | ||
| ) | ||
| } | ||
| """.trimIndent() |
There was a problem hiding this comment.
Demo snippet in getInitialCode contains a type error.
println("Hello, CodeView!") returns Unit, so greeting is Unit. Passing it as code: String to CodeView is a type mismatch — users copying this snippet from the playground will get a compilation error. Replace with a string literal assignment:
🐛 Proposed fix
- val greeting = println("Hello, CodeView!")
+ val greeting = "Hello, CodeView!"
CodeView(
code = greeting,🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt`
around lines 92 - 110, The snippet returned by getInitialCode contains a type
error: in CodeDisplay the line creating greeting uses println(...) which yields
Unit and then is passed to CodeView as code:String; change the assignment in the
CodeDisplay example so greeting is a String (e.g., val greeting = "Hello,
CodeView!") and ensure CodeView(code = greeting, language = CodeLanguage.KOTLIN)
uses that string.
- Fixed broken TOC link.
Summary by CodeRabbit
New Features
Improvements
Documentation