Skip to content

fix: Mesh ステータス/接続モーダルが scanning で固まる不具合を修正#657

Merged
takaokouji merged 1 commit intodevelopfrom
fix/mesh-host-connected-status
May 8, 2026
Merged

fix: Mesh ステータス/接続モーダルが scanning で固まる不具合を修正#657
takaokouji merged 1 commit intodevelopfrom
fix/mesh-host-connected-status

Conversation

@takaokouji
Copy link
Copy Markdown

Summary

Mesh拡張機能を有効にしてホストになっても、メッシュのステータス(! 切断アイコン)が更新されず、接続モーダルがスキャン画面のまま固まる不具合を修正します。

Root cause

Blockly v12 の ContinuousToolboxtoolboxitemid 属性 からカテゴリ id を読みます (iI.id_ = e.toolboxitemid || genUid())。runtime.js が拡張機能カテゴリ XML を生成する際、id="..." のみを付与していたため、v12 のパーサは genUid() にフォールバックし、blockly-1aw のような auto id をカテゴリに付けます。

StatusIndicatorLabel constructor (scratch-blocks v12):
  this.extensionId = E.id   // ← "blockly-1aw" になっていた

ユーザーが ! 警告アイコンをクリックすると、その auto id (blockly-1aw) が statusButtonCallback に渡され、連鎖的に:

  • 接続モーダルが extensionId="blockly-1aw" で開く
  • extensionData.find(ext => ext.extensionId === 'blockly-1aw') が undefined → MeshV2InitialStep に行かず scanning フェーズへフォールバック
  • vm.connectPeripheral('blockly-1aw', 'meshV2_host') は no-op(runtime.peripheralExtensions['blockly-1aw'] が undefined)
  • PERIPHERAL_CONNECTED が永遠に発火しないので、モーダルは「デバイスを探索中」の scanning ステップのまま固まる
  • 別経路で接続成功してもステータスアイコンの更新キーが拡張 id と一致せず、! のまま

ライブの workspace で flyout の StatusIndicatorLabel.extensionId を覗くと、修正前は "blockly-1aw"、修正後は "meshV2" になることを確認しました。

Fix

packages/scratch-vm/src/engine/runtime.js で拡張機能カテゴリ XML に toolboxitemid="${id}"id="${id}" と並べて付与します(v12 推奨の toolboxitemid を新規・古い id を残す)。

これは upstream ファイルへの修正のため Smalruby マーカーを使用し、.claude/rules/scratch-vm/development.md の一覧も更新しました。

Changes

  • packages/scratch-vm/src/engine/runtime.js — XML に toolboxitemid を追加
  • packages/scratch-vm/test/unit/runtime_extension_category_xml.js (新規) — XML が toolboxitemid / id / showStatusButton をすべて含むことを検証する tap テスト
  • .claude/rules/scratch-vm/development.md — マーカー一覧を更新

Test plan

  • tap unit test 3 件 pass
  • Playwright で実機確認: Mesh 拡張機能を有効化 → flyout の StatusIndicatorLabel.extensionId === "meshV2"(修正前は "blockly-1aw")→ statusButtonCallback 経由で接続モーダルが extensionId="meshV2" で開く
  • CI 全テスト pass

🤖 Generated with Claude Code

…rves the real extension id

Blockly v12's ContinuousToolbox parses category id from the
toolboxitemid attribute (iI.id_ = e.toolboxitemid || genUid()). Our
extension category XML only carried the legacy id attribute, so v12
fell back to genUid() and assigned the category an auto id like
blockly-1aw. That id propagated to StatusIndicatorLabel.extensionId.

When the user clicked the warning ! status icon next to a mesh / micro:bit
/ similar extension, the connection modal opened with extensionId set to
the bogus blockly-* id. The container could not resolve the extension,
so it skipped meshV2Initial and fell through to the default scanning
step. vm.connectPeripheral was a no-op because no peripheral extension
matches blockly-1aw, so PERIPHERAL_CONNECTED never fired and the modal
stayed at scanning forever (header showed blockly-1aw, status icon stayed !).

Emit toolboxitemid alongside id so the v12 parser keeps the extension's
real id, and add a tap test pinning the XML format.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

@takaokouji takaokouji merged commit 0c0fe2d into develop May 8, 2026
9 checks passed
@takaokouji takaokouji deleted the fix/mesh-host-connected-status branch May 8, 2026 04:01
github-actions Bot pushed a commit that referenced this pull request May 8, 2026
…-connected-status

fix: Mesh ステータス/接続モーダルが scanning で固まる不具合を修正
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