fix(sample): restore missing wasmJs browser target - #105
Conversation
The release workflow's linux-x64 sample job ran :sample:androidApp:assembleRelease,
:sample:packageReleaseDistributionForCurrentOS and :sample:wasmJsBrowserDistribution
in a single Gradle invocation, but the sample declared no wasmJs target, so the third
task did not exist. Gradle failed at task-selection time and the whole job died,
costing the release its .apk and .deb as well as the wasm zip.
Restore the target and give the orphaned sample/src/wasmJsMain a compilation:
- Add wasmJs { browser(); binaries.executable() } — the executable binary is what
registers the wasmJsBrowserDistribution task.
- Move :transport-tcp off commonMain onto androidMain/desktopMain/iosMain. It has
no wasmJs variant because a browser cannot open a raw TCP socket.
- Add internal expect fun platformTransportFactory() so common code no longer
references TcpTransportFactory directly: non-web targets get
TcpTransportFactory() + WebSocketTransportFactory(), wasmJs gets WebSockets only.
- Regenerate kotlin-js-store/wasm/yarn.lock for Compose's @js-joda/core npm dep.
|
Warning Review limit reached
Next review available in: 14 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (8)
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.
Pull request overview
Restores the :sample module’s missing wasmJs browser target so the release workflow can successfully select and execute :sample:wasmJsBrowserDistribution, preventing the entire sample-artifacts job from failing at Gradle task-selection time.
Changes:
- Added a
wasmJs { browser(); binaries.executable() }target tosample/build.gradle.ktsto register thewasmJsBrowserDistributiontask. - Refactored the sample’s transport wiring to avoid
:transport-tcpincommonMain(so wasmJs can compile) by introducing anexpect/actualplatformTransportFactory()and moving the TCP dependency to non-web source sets. - Updated the sample README and regenerated the wasm yarn lockfile for the restored wasm build graph.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| sample/build.gradle.kts | Adds wasmJs browser executable target; moves :transport-tcp dependency out of commonMain and into per-platform source sets. |
| sample/src/commonMain/kotlin/org/meshtastic/mqtt/sample/PlatformTransport.kt | Introduces internal expect fun platformTransportFactory() to select transports per platform. |
| sample/src/androidMain/kotlin/org/meshtastic/mqtt/sample/PlatformTransport.android.kt | Android actual uses TCP + WebSocket transport factories. |
| sample/src/desktopMain/kotlin/org/meshtastic/mqtt/sample/PlatformTransport.desktop.kt | Desktop actual uses TCP + WebSocket transport factories. |
| sample/src/iosMain/kotlin/org/meshtastic/mqtt/sample/PlatformTransport.ios.kt | iOS actual uses TCP + WebSocket transport factories. |
| sample/src/wasmJsMain/kotlin/org/meshtastic/mqtt/sample/PlatformTransport.wasmJs.kt | wasmJs actual uses WebSocket-only transport factory (no TCP on browser). |
| sample/src/commonMain/kotlin/org/meshtastic/mqtt/sample/MqttSampleViewModel.kt | Switches client config to use platformTransportFactory() instead of directly referencing TCP/WS factories in common code. |
| sample/README.md | Documents the new PlatformTransport.kt in the module layout. |
| kotlin-js-store/wasm/yarn.lock | Regenerated lockfile for wasm build (adds @js-joda/core). |
What broke
release.yml'ssample-artifactsjob builds the linux-x64 leg with one Gradle invocation::sample:wasmJsBrowserDistributiondid not exist, becausesample/build.gradle.ktsdeclared nowasmJstarget. Gradle fails at task-selection time, before running anything — so the whole job died and the release lost the.apkand the.deb, not just the wasm zip. v0.6.0's GitHub Release shows the damage: only.dmg,.msiand SBOMs.sample/src/wasmJsMain/was fully populated the whole time (Main.ktwithComposeViewport,index.html, favicons) — an orphaned source set with no compilation. The target was almost certainly dropped when the library split into per-transport modules:MqttSampleViewModelreferencedTcpTransportFactoryfromcommonMain, and:transport-tcpdeliberately omits wasmJs (a browser cannot open a raw TCP socket), so a wasmJs target could not have compiled as the code stood.What changed
Took the "properly restore it" path rather than deleting the task from the workflow.
sample/build.gradle.kts— addwasmJs { browser(); binaries.executable() }, matching the idiom intransport-ws/build.gradle.kts.binaries.executable()is the part that registerswasmJsBrowserDistribution.sample/build.gradle.kts— moveimplementation(project(":transport-tcp"))offcommonMainand ontoandroidMain,desktopMainandiosMain.:coreand:transport-wsstay incommonMain— both support wasmJs.PlatformTransport.kt(new, commonMain + 4 actuals) —internal expect fun platformTransportFactory(): MqttTransportFactory. Android/desktop/iOS returnTcpTransportFactory() + WebSocketTransportFactory(); wasmJs returnsWebSocketTransportFactory()alone. Four small explicitactualfiles, no hand-wireddependsOnintermediate source set.MqttSampleViewModel.kt— callsplatformTransportFactory(); the three transport imports are gone from common code. No behaviour change on any existing platform.kotlin-js-store/wasm/yarn.lock— regenerated viakotlinWasmUpgradeYarnLock. Compose's wasm target pulls in@js-joda/core; purely additive, and the existingws@8.21.0security pin is untouched.sample/README.md— one line for the new file. The README already documented wasmJs as a supported target and already told browser users to switch to aws://URI, so no other doc change was needed.kotlinx-browserwas not needed —kotlinx.browser.documentresolves transitively through Compose on Kotlin 2.4.10 / CMP 1.11.1.The UI is untouched. The default broker URI stays
tls://mqtt.meshtastic.org:8883(asserted by acommonTesttest); in the browser you switch it tows:///wss://, exactly as the README already says.Verification (local, macOS, JDK 21)
:sample:wasmJsBrowserDistributionsample/build/dist/wasmJs/productionExecutable, the exact path the workflow's zip stepcds into, containingindex.html,sample.js(the filenameindex.htmlreferences), both.wasmblobs and the favicons:sample:androidApp:assembleReleaseandroidApp-release-unsigned.apk(10.8 MB) at the workflow'sartifact_globpath:sample:packageReleaseDistributionForCurrentOSmqtt-sample-1.6.0.dmgon this macOS host, proving the task graph the linux.debleg uses:sample:compileKotlinDesktop :sample:compileKotlinWasmJs:sample:compileKotlinIosArm64 :sample:compileKotlinIosSimulatorArm64spotlessCheck detekt:sample:desktopTest:sample:wasmJsBrowserTesttests="7" failures="0" errors="0"That last one is new surface worth flagging:
ci.yml'stest-wasmjob runs./gradlew wasmJsBrowserTestunscoped, so the sample'scommonTestnow also executes in headless Chrome. All 7 existing tests pass there.One thing I could not verify locally:
:sample:linkReleaseFrameworkIosArm64OOMs (Java heap space) on this machine. I confirmed it fails identically on unmodifiedorigin/main, so it is pre-existing and environmental — this box pinsorg.gradle.jvmargs=-Xmx2048Mand Compose's iOS release framework link needs more. Neitherci.ymlnorrelease.ymlbuilds iOS release frameworks;ci.ymllinks only the debug test binary, which passes here with a larger heap.