feat: add Stack-chan WASM build support - #446
Conversation
This reverts commit 04bf80e.
…esolution # Conflicts: # .github/workflows/build.yml # firmware/package.json # firmware/tsconfig.test.json
|
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 (6)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR adds WASM facade module entrypoints for servo and LED drivers, validates their manifest routing and import patterns, enhances rotation payload validation in the driver bridge, and refactors CI Moddable SDK pinning to use action inputs. ChangesWASM Facade Modules and Validation
CI Moddable SDK Setup
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
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 docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 197a76fbd6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
🧹 Nitpick comments (2)
.github/workflows/build.yml (1)
64-67: ⚡ Quick winAlign SDK pinning with setup action input for deterministic caching.
Line 64-67 pins a SHA after setup, but setup/cache-key resolution still follows its default ref path. Pass the same SHA via
target-branchso install + cache + build all use one source of truth.Proposed change
- - uses: ./.github/actions/setup - - name: Pin Moddable SDK - run: | - git -C "$HOME/.local/share/moddable" fetch origin b0411457e4577ea5560c780cb7824f3b00c2b2af - git -C "$HOME/.local/share/moddable" checkout --detach FETCH_HEAD + - uses: ./.github/actions/setup + with: + target-branch: b0411457e4577ea5560c780cb7824f3b00c2b2af🤖 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 @.github/workflows/build.yml around lines 64 - 67, The workflow currently pins the Moddable SDK by checking out a SHA in the "Pin Moddable SDK" step but does not pass that SHA to the earlier setup action; update the setup/install step for the Moddable SDK to receive the same SHA via the target-branch input so install, cache-key resolution, and the later checkout use the same ref; locate the setup action step (the Moddable SDK setup or install step) and add target-branch: "<the same SHA currently used in the Pin Moddable SDK step>" so the cache and build are deterministic.firmware/stackchan/drivers/wasm/wasm-driver.ts (1)
28-31: ⚡ Quick winConsider validating the rotation parameter structure.
The
applyRotationmethod accepts arotationparameter but does not validate that it contains valid numericy,p, andrproperties. If called with malformed data (e.g., missing fields, non-numeric values), the spread operation on line 29 would silently accept invalid state, and the host bridge might receive unexpected data.🛡️ Proposed validation guard
async applyRotation(rotation: Rotation, time?: number): Promise<void> { + if (typeof rotation.y !== 'number' || typeof rotation.p !== 'number' || typeof rotation.r !== 'number') { + throw new TypeError('Invalid rotation: y, p, r must be numbers') + } this.#rotation = { ...rotation } globalThis.Host?.Driver?.applyRotation?.({ rotation, time }) }🤖 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 `@firmware/stackchan/drivers/wasm/wasm-driver.ts` around lines 28 - 31, The applyRotation method currently assigns and forwards whatever is passed, risking invalid state; add a validation guard inside applyRotation to ensure the rotation object has numeric y, p, and r properties (e.g., Number.isFinite checks) before setting this.#rotation and calling globalThis.Host?.Driver?.applyRotation; if validation fails, do not mutate this.#rotation and either throw or log an error (use existing logging pattern) so malformed inputs are rejected and the host bridge never receives invalid data.
🤖 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 @.github/workflows/build.yml:
- Around line 64-67: The workflow currently pins the Moddable SDK by checking
out a SHA in the "Pin Moddable SDK" step but does not pass that SHA to the
earlier setup action; update the setup/install step for the Moddable SDK to
receive the same SHA via the target-branch input so install, cache-key
resolution, and the later checkout use the same ref; locate the setup action
step (the Moddable SDK setup or install step) and add target-branch: "<the same
SHA currently used in the Pin Moddable SDK step>" so the cache and build are
deterministic.
In `@firmware/stackchan/drivers/wasm/wasm-driver.ts`:
- Around line 28-31: The applyRotation method currently assigns and forwards
whatever is passed, risking invalid state; add a validation guard inside
applyRotation to ensure the rotation object has numeric y, p, and r properties
(e.g., Number.isFinite checks) before setting this.#rotation and calling
globalThis.Host?.Driver?.applyRotation; if validation fails, do not mutate
this.#rotation and either throw or log an error (use existing logging pattern)
so malformed inputs are rejected and the host bridge never receives invalid
data.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c103ccc2-a8a2-49e0-851f-3319ed1cef25
📒 Files selected for processing (32)
.github/PULL_REQUEST_TEMPLATE.md.github/actions/setup/action.yml.github/workflows/build.ymlfirmware/mods/chat_audioio/mod.jsfirmware/package.jsonfirmware/scripts/README_ja.mdfirmware/stackchan/default-mods/wasm/on-launch.tsfirmware/stackchan/drivers/wasm/driver-stub.tsfirmware/stackchan/drivers/wasm/dynamixel-driver.tsfirmware/stackchan/drivers/wasm/none-driver.tsfirmware/stackchan/drivers/wasm/rs30x-driver.tsfirmware/stackchan/drivers/wasm/scservo-driver.tsfirmware/stackchan/drivers/wasm/sg90-driver.tsfirmware/stackchan/drivers/wasm/wasm-driver.tsfirmware/stackchan/main.tsfirmware/stackchan/manifest_wasm.jsonfirmware/stackchan/renderers-piu/manifest_wasm_renderer_piu.jsonfirmware/stackchan/services/wasm/network-service.tsfirmware/stackchan/services/wasm/preference-server.tsfirmware/stackchan/speeches/wasm/tts-elevenlabs.tsfirmware/stackchan/speeches/wasm/tts-local.tsfirmware/stackchan/speeches/wasm/tts-openai.tsfirmware/stackchan/speeches/wasm/tts-remote.tsfirmware/stackchan/speeches/wasm/tts-stub.tsfirmware/stackchan/speeches/wasm/tts-voicevox-web.tsfirmware/stackchan/speeches/wasm/tts-voicevox.tsfirmware/stackchan/utilities/manifest_wasm_utility.jsonfirmware/stackchan/wasm/led.tsfirmware/stackchan/wasm/microphone.tsfirmware/stackchan/wasm/tone.tsfirmware/tests/unit/wasm-stubs.test.tsfirmware/tsconfig.test.json
faef7ee to
70a0807
Compare
|
レビューコメント対応しました。 対応内容:
検証:
CI は push 後に再実行中です。 |
Summary
What Changed
manifest_wasm.jsonand WASM renderer/utility manifests.Verification
cd firmware && npm run formatcd firmware && npm run lintcd firmware && npm run testNot run locally in this PR-opening step; relying on CI and the branch's existing verification history.
Affected Areas
Breaking Changes
Related Issues
dev/v1.0.Summary by CodeRabbit
New Features
Tests
Chores