Skip to content

feat(example): Update sample app#1

Merged
komodgn merged 9 commits into
developfrom
feature/demo
May 6, 2026
Merged

feat(example): Update sample app#1
komodgn merged 9 commits into
developfrom
feature/demo

Conversation

@komodgn
Copy link
Copy Markdown
Owner

@komodgn komodgn commented May 5, 2026

Summary by CodeRabbit

  • New Features

    • Interactive code editor with live preview added to the example app (separate editor and preview panes).
    • Code view now supports an optional font selection for rendering code.
  • Improvements

    • Responsive layout: editor and preview stack on narrow screens and sit side-by-side on wide screens.
    • Improved keyboard/window inset handling for smoother typing.
    • App theme provides a custom code font.
  • Documentation

    • README: added Live Playground link, table of contents, and contributing section.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7c9d61b6-e913-4789-b605-f9f936615013

📥 Commits

Reviewing files that changed from the base of the PR and between e36eee6 and 3613de5.

📒 Files selected for processing (1)
  • README.md

📝 Walkthrough

Walkthrough

The example app was made into a live, editable playground with a responsive two‑pane editor/preview. New composables (EditorSection, CodeViewSection), a CodeView optional fontFamily parameter, app theme/font provider, README updates, an Android IME manifest flag, and a JS platform stub were added.

Changes

Interactive Editor, Theme, and Example Wiring

Layer / File(s) Summary
Data Shape / Initial Content
example/src/commonMain/kotlin/.../Application.kt
getInitialCode(version: String) generates the initial editor code string (interpolates library version) and seeds userInput.
Core UI Components
example/src/commonMain/kotlin/.../component/EditorSection.kt, example/src/commonMain/kotlin/.../component/CodeViewSection.kt
Added EditorSection(code: String, onValueChange: (String) -> Unit, modifier: Modifier) and CodeViewSection(code: String, modifier: Modifier) composables for editing and previewing code.
Theme & Font Provision
example/src/commonMain/kotlin/.../theme/CodeViewTheme.kt, example/src/commonMain/kotlin/.../theme/Font.kt
Added CodeViewTheme composable and LocalAppFontFamily composition local; defines and provides the app font family via MaterialTheme.
App Wiring & Layout
example/src/commonMain/kotlin/.../Application.kt
App() refactored to stateful editor/preview: initializes userInput, tracks scroll state, overrides insets, and uses BoxWithConstraints to switch stacked vs side‑by‑side layouts with appropriate paddings.
Library API Change (rendering)
codeview/compose/src/commonMain/kotlin/.../CodeView.kt
CodeView gains optional parameter fontFamily: FontFamily? = null; Text uses fontFamily ?: FontFamily.Monospace.
Platform & Manifest
example/src/jsMain/kotlin/.../Platform.js.kt, example/src/androidMain/AndroidManifest.xml
Added JS actual fun platform() = "Web with JS"; MainActivity now sets android:windowSoftInputMode="adjustResize".
Documentation
README.md
Added "Live Playground" link, a Table of Contents, completed Usage example, and a Contributing section/link.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit taps keys with delight,
The preview wakes in morning light.
Type a line, watch panes align,
Fonts and code in tidy design.
Hop, preview, hop—your playground's right.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'feat(example): Update sample app' is vague and overly broad, using generic language that doesn't convey specific information about the changeset. Use a more specific title that highlights the primary change, such as 'feat(example): Add interactive editor with live code preview' or 'feat(example): Implement responsive editor-preview layout'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/demo

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.

Copy link
Copy Markdown
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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 19ed0ec and 3258d35.

📒 Files selected for processing (2)
  • example/src/androidMain/AndroidManifest.xml
  • example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt

Comment thread example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt Outdated
…ation.kt


- [skip ci]

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Copy Markdown
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.

♻️ 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 contentWindowInsets is set to zero, bottom system insets must be reapplied explicitly. Without navigationBarsPadding(), 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3258d35 and 188abed.

📒 Files selected for processing (1)
  • example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt

Copy link
Copy Markdown
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.

Actionable comments posted: 2

🧹 Nitpick comments (4)
example/src/commonMain/kotlin/io/github/komodgn/example/component/EditorSection.kt (1)

32-32: ⚡ Quick win

Add = Modifier default to the modifier parameter.

Same Compose API convention issue as in CodeViewSection: modifier: Modifier should default to Modifier.

♻️ 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 win

Memoize codeFont and typography to avoid spurious full-tree recompositions.

Both FontFamily(...) and Typography(...) are new object instances on every recomposition. Because LocalAppFontFamily is backed by staticCompositionLocalOf, a changed reference (even with the same logical value) invalidates the entire composition tree. Wrap them with remember:

♻️ 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 value

Simplify 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 win

Add = Modifier default to the modifier parameter.

Compose's API guidelines require all composable Modifier parameters to default to Modifier. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 188abed and e36eee6.

⛔ Files ignored due to path filters (3)
  • example/src/commonMain/composeResources/font/NotoColorEmoji.ttf is excluded by !**/*.ttf
  • example/src/commonMain/composeResources/font/NotoSansKR-Regular.ttf is excluded by !**/*.ttf
  • kotlin-js-store/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (8)
  • README.md
  • codeview/compose/src/commonMain/kotlin/io/github/komodgn/codeview/compose/CodeView.kt
  • example/src/commonMain/kotlin/io/github/komodgn/example/Application.kt
  • example/src/commonMain/kotlin/io/github/komodgn/example/component/CodeViewSection.kt
  • example/src/commonMain/kotlin/io/github/komodgn/example/component/EditorSection.kt
  • example/src/commonMain/kotlin/io/github/komodgn/example/theme/CodeViewTheme.kt
  • example/src/commonMain/kotlin/io/github/komodgn/example/theme/Font.kt
  • example/src/jsMain/kotlin/io/github/komodgn/example/Platform.js.kt

Comment on lines +92 to +110
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()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

Comment thread README.md Outdated
- Fixed broken TOC link.
@komodgn komodgn merged commit ea3e5eb into develop May 6, 2026
1 check passed
@komodgn komodgn deleted the feature/demo branch May 6, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant