Skip to content

fix(nav): Desktop crash on SearchScreen enum nav arg#606

Merged
rainxchzed merged 1 commit into
mainfrom
fix/desktop-nav-enum-arg
May 16, 2026
Merged

fix(nav): Desktop crash on SearchScreen enum nav arg#606
rainxchzed merged 1 commit into
mainfrom
fix/desktop-nav-enum-arg

Conversation

@rainxchzed
Copy link
Copy Markdown
Member

@rainxchzed rainxchzed commented May 15, 2026

Hotfix. Regression from #597 (Task 12 platform chips). SearchScreen(val initialPlatform: SearchPlatformUi? = null) works on Android but crashes Desktop:

```
IllegalArgumentException: Route ...SearchScreen could not find any NavType
for argument initialPlatform of type SearchPlatformUi? - typeMap received was {}
at RouteSerializerKt.forEachIndexedKType (RouteSerializer.kt:190)
at NavDestinationBuilder. (nonAndroid.kt:49)
```

Compose Navigation's non-Android serializer has no built-in NavType for enums. Cheapest fix: switch nav arg to String? (enum name), convert at composable<> boundary via SearchPlatformUi.valueOf(name).

Test plan

  • Android + JVM compile clean
  • Real device: Desktop launches without crash; platform chip on Details still opens filtered Search

Source: user-reported crash on desktop launch.

Summary by CodeRabbit

  • Bug Fixes
    • Improved stability and compatibility of the search screen's platform selection across different platforms by refining how platform information is passed through navigation.

Review Change Stack

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

rainxchzed has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

Walkthrough

Navigation route serialization for SearchScreen.initialPlatform is refactored from SearchPlatformUi? enum to String? type. AppNavigation adds safe parsing via runCatching to restore the enum, wires the parsed value to the viewModel, and updates DetailsScreen to pass platform names as strings.

Changes

Navigation Serialization

Layer / File(s) Summary
Navigation contract type change
composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/GithubStoreGraph.kt
SearchScreen.initialPlatform changes from SearchPlatformUi? to String? with comments explaining the enum-as-name string approach for Compose Navigation serialization compatibility on Desktop.
Safe parsing and viewModel wiring
composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/AppNavigation.kt
AppNavigation derives initialPlatform by safely parsing the route string argument with runCatching { valueOf(...) }, updates SearchRoot viewModel injection to use the parsed value, and DetailsScreen navigation passes platform.toSearchPlatformUi().name string.

Possibly related PRs

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A curious leap through navigation's thread,
From enum to string, where serialization spreads,
Safe parsing guards against the unknown,
DesktopNavigation has found its home! 🏡

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

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.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: fixing a Desktop crash caused by an enum navigation argument issue in SearchScreen.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/desktop-nav-enum-arg

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.

🧹 Nitpick comments (1)
composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/AppNavigation.kt (1)

117-123: 💤 Low value

Consider logging when enum parsing fails.

The runCatching { valueOf(name) }.getOrNull() approach silently discards invalid platform names. While defaulting to null for an optional navigation argument is reasonable, adding a log statement when parsing fails could help debug unexpected navigation state or catch typos in future call sites.

💡 Optional: Add logging on parse failure
 val initialPlatform =
     args.initialPlatform?.let { name ->
         runCatching {
             zed.rainxch.search.presentation.model.SearchPlatformUi
                 .valueOf(name)
-        }.getOrNull()
+        }.onFailure {
+            // Log: "Invalid platform name in nav args: $name"
+        }.getOrNull()
     }
🤖 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
`@composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/AppNavigation.kt`
around lines 117 - 123, The current silent parsing of args.initialPlatform via
runCatching { SearchPlatformUi.valueOf(name) }.getOrNull() should log failures
so invalid platform names are visible; change the expression to attach an
onFailure handler that logs the invalid name and the throwable (e.g., using the
app logger or println) before returning null—refer to the initialPlatform
variable, args.initialPlatform, and
zed.rainxch.search.presentation.model.SearchPlatformUi.valueOf to locate and
update the parsing block.
🤖 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.

Nitpick comments:
In
`@composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/AppNavigation.kt`:
- Around line 117-123: The current silent parsing of args.initialPlatform via
runCatching { SearchPlatformUi.valueOf(name) }.getOrNull() should log failures
so invalid platform names are visible; change the expression to attach an
onFailure handler that logs the invalid name and the throwable (e.g., using the
app logger or println) before returning null—refer to the initialPlatform
variable, args.initialPlatform, and
zed.rainxch.search.presentation.model.SearchPlatformUi.valueOf to locate and
update the parsing block.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 66d4bdd1-a328-40bd-a86e-d8e91e706446

📥 Commits

Reviewing files that changed from the base of the PR and between fcbaa1c and 1293747.

📒 Files selected for processing (2)
  • composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/AppNavigation.kt
  • composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/GithubStoreGraph.kt

@rainxchzed rainxchzed merged commit 7c119d7 into main May 16, 2026
1 check passed
@rainxchzed rainxchzed deleted the fix/desktop-nav-enum-arg branch May 16, 2026 05:17
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