Skip to content

step 1/6: LED基盤とCI/型設定の土台を追加 [dev/v1.0 corrected]#388

Merged
meganetaaan merged 62 commits intodev/v1.0from
step-pr/01-piu-migration-dev-v1.0
Apr 4, 2026
Merged

step 1/6: LED基盤とCI/型設定の土台を追加 [dev/v1.0 corrected]#388
meganetaaan merged 62 commits intodev/v1.0from
step-pr/01-piu-migration-dev-v1.0

Conversation

@meganetaaan
Copy link
Copy Markdown
Collaborator

@meganetaaan meganetaaan commented Apr 4, 2026

This PR recreates the logical diff from #363 on top of dev/v1.0.

Context:

This branch is a bridge branch:

  • first parent: dev/v1.0
  • second parent: original step-pr/01-piu-migration history

That keeps the diff equivalent to #363 while preserving ancestry for later stacked PRs.

Supersedes the base-branch intent of #363.

Summary by CodeRabbit

  • New Features

    • LED settings now load from user preferences instead of default configuration
    • Face rendering now supports palette-driven theming with enhanced animation effects
  • Chores

    • Updated build setup and TypeScript configuration

meganetaaan and others added 30 commits March 12, 2026 08:23
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 4, 2026

📝 Walkthrough

Walkthrough

This PR updates the build infrastructure to support fontbm installation, refactors face rendering with a new palette-driven theming system and Die-based clipping, switches LED configuration to use preferences instead of config, adds a DOMAIN.led constant, and removes a wildcard TypeScript path mapping.

Changes

Cohort / File(s) Summary
Build Infrastructure & Setup
.github/actions/setup/action.yml, firmware/tsconfig.json
Updated Moddable/ESP-IDF cache keys to include fontbm2, added composite action step to install fontbm from source when cache misses, and removed wildcard paths mapping from TypeScript configuration.
LED Configuration System
firmware/stackchan/utilities/consts.ts, firmware/stackchan/main.ts, firmware/stackchan/robot.ts
Added DOMAIN.led constant, switched LED configuration source in createRobot() from config.led to loadPreferences('led'), and reordered import statement.
Face Rendering Refactoring
firmware/stackchan/renderers-piu/face-view.ts
Introduced FACE_REGION anchor requirement in FaceViewAnchors, added Die-based face region with computed breath padding and clipping, replaced theme-driven logic with palette-driven onFaceSkin() hook that distributes updates to effects/overlay/appBar, and reorganized face rendering to render through the new region.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Feature/light #355: Directly introduces LED support and robot.led handling; this PR's LED configuration and DOMAIN.led changes align with that feature addition.
  • [CI]actions/setup cache moddable and esp32 #277: Prior changes to .github/actions/setup/action.yml Moddable/ESP-IDF caching; this PR extends that setup with fontbm2 cache key and installation logic.

Suggested reviewers

  • stc1988

Poem

🐰 A rabbit's refactoring rhyme:
Face regions dance with palette divine,
Fontbm caches align in time,
LED preferences hop and shine,
TypeScript paths trim so fine! 🎨✨

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is in Japanese and refers to LED foundation and CI/type settings (step 1/6 of a series), which aligns with the actual changes including LED configuration, CI setup for fontbm, and type configuration adjustments across multiple files.

✏️ 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 step-pr/01-piu-migration-dev-v1.0

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bdc8d0a4d5

ℹ️ 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".

Comment on lines 132 to +135
const currentFace = this.face
this.face = face
if (currentFace) this.main.remove(currentFace)
if (this.effects) this.main.insert(this.face, this.effects)
else this.main.add(this.face)
}

private applyTheme(faceContext: Readonly<FaceContext>) {
if (!this.autoTheme || !this.main) return
const secondary = faceContext.theme.secondary
if (secondary === this.lastSecondary) return
this.lastSecondary = secondary
this.main.skin = new Skin({ fill: secondary })
if (currentFace) this.faceRegion.remove(currentFace)
this.faceRegion.add(this.face)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Recompute face region when swapping face instance

Update setFace to re-layout the replacement face inside FACE_REGION (and resize/reposition the region if needed). In this commit, FaceMainTemplate computes FACE_REGION geometry from the initial face and rewrites that face’s coordinates, but setFace now only does remove/add on the existing region. When RendererCompat.setFace() is called with a fresh face (e.g., normal left/top/width/height coordinates or different dimensions), the new face keeps its original coordinates relative to the region and can be offset or clipped by the stale region bounds.

Useful? React with 👍 / 👎.

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 (2)
firmware/stackchan/renderers-piu/face-view.ts (1)

154-157: Direct mutation of face.coordinates may cause unintended side effects.

The face object's coordinates property is mutated directly to offset it within the Die region. If the same face instance is reused elsewhere or inspected for its original position, this could lead to unexpected behavior. Consider whether this mutation is intentional or if a wrapper container would be more appropriate.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@firmware/stackchan/renderers-piu/face-view.ts` around lines 154 - 157, Avoid
mutating the shared face object: instead of modifying face.coordinates in place,
create a new coordinates object or a shallow clone of the face (e.g., newFace =
{ ...face, coordinates: { left: breathPad, top: breathPad } }) or wrap the face
in a container that applies the offset; update uses of face in
renderers-piu/face-view.ts to reference the newFace/container so the original
face.coordinates remains unchanged (look for occurrences of face and
face.coordinates to replace).
.github/actions/setup/action.yml (1)

67-67: Make FONTBM export idempotent to avoid duplicate env entries.

Repeated appends can accumulate duplicate export FONTBM=... lines in the same file.

Suggested idempotent write
-        printf '\nexport FONTBM=%s\n' "$HOME/.local/share/fontbm/build/fontbm" >> $HOME/.local/share/xs-dev-export.sh
+        grep -q '^export FONTBM=' "$HOME/.local/share/xs-dev-export.sh" \
+          && sed -i "s|^export FONTBM=.*|export FONTBM=$HOME/.local/share/fontbm/build/fontbm|" "$HOME/.local/share/xs-dev-export.sh" \
+          || printf '\nexport FONTBM=%s\n' "$HOME/.local/share/fontbm/build/fontbm" >> "$HOME/.local/share/xs-dev-export.sh"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/actions/setup/action.yml at line 67, Make the FONTBM export
idempotent by ensuring we don't append duplicate "export FONTBM=..." lines to
$HOME/.local/share/xs-dev-export.sh: check for an existing FONTBM export
(matching the literal "export FONTBM=" or the exact path) and either replace it
or remove it before appending the new export, or write the export only if grep
-q fails; update the action line that currently appends FONTBM so it performs
that existence check/replacement on $HOME/.local/share/xs-dev-export.sh instead
of unconditional printf append.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/actions/setup/action.yml:
- Around line 64-66: The git clone of
https://github.com/vladimirgamalyan/fontbm.git should be pinned to an immutable
ref instead of cloning the default branch; update the clone command in
action.yml (the line with "git clone --depth 1
https://github.com/vladimirgamalyan/fontbm.git $HOME/.local/share/fontbm") to
clone a specific tag or commit SHA (or reference an input/variable like
FONTBM_REF and default it to a release tag/commit) so CI uses a fixed,
reproducible ref before running the cmake/make steps.

In `@firmware/stackchan/renderers-piu/face-view.ts`:
- Around line 1-8: The class FaceMainTemplate extends Behavior but Behavior is
not imported from 'piu/MC', causing a runtime ReferenceError; fix by adding
Behavior to the import list from 'piu/MC' alongside Container, Die, Skin (i.e.,
include Behavior in the existing import statement) so that the FaceMainTemplate
class can extend it without error.

---

Nitpick comments:
In @.github/actions/setup/action.yml:
- Line 67: Make the FONTBM export idempotent by ensuring we don't append
duplicate "export FONTBM=..." lines to $HOME/.local/share/xs-dev-export.sh:
check for an existing FONTBM export (matching the literal "export FONTBM=" or
the exact path) and either replace it or remove it before appending the new
export, or write the export only if grep -q fails; update the action line that
currently appends FONTBM so it performs that existence check/replacement on
$HOME/.local/share/xs-dev-export.sh instead of unconditional printf append.

In `@firmware/stackchan/renderers-piu/face-view.ts`:
- Around line 154-157: Avoid mutating the shared face object: instead of
modifying face.coordinates in place, create a new coordinates object or a
shallow clone of the face (e.g., newFace = { ...face, coordinates: { left:
breathPad, top: breathPad } }) or wrap the face in a container that applies the
offset; update uses of face in renderers-piu/face-view.ts to reference the
newFace/container so the original face.coordinates remains unchanged (look for
occurrences of face and face.coordinates to replace).
🪄 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: e891ce30-7ccb-4755-8411-b09bc68b8c40

📥 Commits

Reviewing files that changed from the base of the PR and between f5c37b6 and bdc8d0a.

📒 Files selected for processing (6)
  • .github/actions/setup/action.yml
  • firmware/stackchan/main.ts
  • firmware/stackchan/renderers-piu/face-view.ts
  • firmware/stackchan/robot.ts
  • firmware/stackchan/utilities/consts.ts
  • firmware/tsconfig.json
💤 Files with no reviewable changes (1)
  • firmware/tsconfig.json

Comment on lines +64 to +66
git clone --depth 1 https://github.com/vladimirgamalyan/fontbm.git $HOME/.local/share/fontbm
cd $HOME/.local/share/fontbm && mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release && make -j$(nproc)
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 | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify all workflow/action files for unpinned git clone usage.
rg -n --type=yaml 'git clone\s+https://github.com/' .github -C2

Repository: stack-chan/stack-chan

Length of output: 47


🏁 Script executed:

# First, check if the action.yml file exists and examine its content
fd -t f 'action.yml' .github

# Then read the specific file to check lines 64-66
if [ -f .github/actions/setup/action.yml ]; then
  echo "=== Lines 60-70 of action.yml ==="
  sed -n '60,70p' .github/actions/setup/action.yml | cat -n
  echo ""
  echo "=== Full file for context ==="
  wc -l .github/actions/setup/action.yml
fi

Repository: stack-chan/stack-chan

Length of output: 945


🏁 Script executed:

# Search for all git clone patterns in .github (with different approach)
rg -n 'git clone' .github --type=yaml -A1 -B1

# Also check for any pinned references to see the convention
rg -n '@|ref=|checkout' .github --type=yaml | head -20

Repository: stack-chan/stack-chan

Length of output: 1632


Pin fontbm to an immutable ref for reproducible and safer CI builds.

This is the only unpinned external dependency in the CI workflow. Cloning the default branch at runtime makes builds non-deterministic and increases supply-chain risk, which contradicts the pinned versions used for all other external actions (e.g., actions/checkout@v4).

Suggested fix
         sudo apt-get install -y cmake libfreetype6-dev
-        git clone --depth 1 https://github.com/vladimirgamalyan/fontbm.git $HOME/.local/share/fontbm
+        FONTBM_REF="<reviewed-commit-sha-or-tag>"
+        git clone https://github.com/vladimirgamalyan/fontbm.git "$HOME/.local/share/fontbm"
+        git -C "$HOME/.local/share/fontbm" checkout --detach "$FONTBM_REF"
         cd $HOME/.local/share/fontbm && mkdir -p build && cd build
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
git clone --depth 1 https://github.com/vladimirgamalyan/fontbm.git $HOME/.local/share/fontbm
cd $HOME/.local/share/fontbm && mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release && make -j$(nproc)
FONTBM_REF="<reviewed-commit-sha-or-tag>"
git clone https://github.com/vladimirgamalyan/fontbm.git "$HOME/.local/share/fontbm"
git -C "$HOME/.local/share/fontbm" checkout --detach "$FONTBM_REF"
cd $HOME/.local/share/fontbm && mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release && make -j$(nproc)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/actions/setup/action.yml around lines 64 - 66, The git clone of
https://github.com/vladimirgamalyan/fontbm.git should be pinned to an immutable
ref instead of cloning the default branch; update the clone command in
action.yml (the line with "git clone --depth 1
https://github.com/vladimirgamalyan/fontbm.git $HOME/.local/share/fontbm") to
clone a specific tag or commit SHA (or reference an input/variable like
FONTBM_REF and default it to a release tag/commit) so CI uses a fixed,
reproducible ref before running the cmake/make steps.

Comment on lines 1 to 8
import {
Container,
Die,
Skin,
type Container as PiuContainer,
type Content as PiuContent,
type Skin as PiuSkin,
} from 'piu/MC'
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 | 🔴 Critical

Missing Behavior import causes runtime error.

Behavior is used at line 166 (extends Behavior) but is not imported from 'piu/MC'. This will throw a ReferenceError at runtime when FaceMainTemplate is instantiated.

🐛 Proposed fix
 import {
+  Behavior,
   Container,
   Die,
   Skin,
   type Container as PiuContainer,
   type Content as PiuContent,
   type Skin as PiuSkin,
 } from 'piu/MC'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import {
Container,
Die,
Skin,
type Container as PiuContainer,
type Content as PiuContent,
type Skin as PiuSkin,
} from 'piu/MC'
import {
Behavior,
Container,
Die,
Skin,
type Container as PiuContainer,
type Content as PiuContent,
type Skin as PiuSkin,
} from 'piu/MC'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@firmware/stackchan/renderers-piu/face-view.ts` around lines 1 - 8, The class
FaceMainTemplate extends Behavior but Behavior is not imported from 'piu/MC',
causing a runtime ReferenceError; fix by adding Behavior to the import list from
'piu/MC' alongside Container, Die, Skin (i.e., include Behavior in the existing
import statement) so that the FaceMainTemplate class can extend it without
error.

@meganetaaan meganetaaan merged commit 599c076 into dev/v1.0 Apr 4, 2026
4 checks passed
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