feat(koshien): 「AIを試す」で現スプライト・現バージョンの生成AIをplayer1で渡す (#762)#765
Merged
smalruby3-editor-bot[bot] merged 1 commit intoJun 28, 2026
Conversation
…s player1 The "Test AI" modal embedded the Koshien WEB viewer with no query params, so it always ran the default AI. The viewer accepts `?player1=data:<base64(utf8)>` (game_viewer/js/player-ai-client.js): a data: blob is decoded to Ruby source, and with no param it falls back to the default AI. - koshien-test-url.js: encodeAiToPlayerParam / buildKoshienTestUrl helpers (UTF-8-safe base64, blank code -> base URL so the default AI still runs). - koshien-test-modal.jsx: connect to vm + rubyVersion, generate the current editing target's runnable Ruby (generatePreviewCode, current version) and pass it as player1. player2 stays the default AI. Regenerated on Reload. - unit tests round-trip the param exactly as the game viewer decodes it. Refs #762 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
🚀 Preview deployed: https://smalruby.jp/smalruby3-editor/feature/issue-762-koshien-test-ai-param/ |
9ecd64c
into
topic/koshien-epic-738
9 checks passed
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
「AIを試す」(
koshien-test-modal) は甲子園 WEB ビューアをクエリ無しで iframe 表示しており、常にデフォルト AI が動いていた。編集中スプライトの生成 Ruby を
player1クエリパラメータで渡し、ユーザー自身の AI を試せるようにする。
ビューア (WASM版) は
?player1=data:<base64(utf8)>を解釈し、data:blob を Ruby ソースにdecode して実行する。パラメータ無しなら従来どおりデフォルト AI(
game_viewer/js/player-ai-client.js)。Changes Made
src/lib/koshien-test-url.js(新規):encodeAiToPlayerParam/buildKoshienTestUrl。UTF-8 安全な base64 化、コードが空なら base URL を返してデフォルト AI にフォールバック。
koshien-test-modal.jsx: redux に connect して vm + rubyVersion を取得し、現編集ターゲットのランナブル Ruby(
generatePreviewCode, 現バージョン)を生成してplayer1に渡す。player2 はデフォルト AI のまま。Reload で最新コードを再生成。
data:除去 → atob →TextDecoder utf-8)で往復を検証。空コード時に base URL のままになることも確認。
Test Coverage
test/unit/lib/koshien-test-url.test.js7 件 pass(ASCII / 日本語 UTF-8 往復、空/空白フォールバック、player1 セット、player2 未セット、カスタム base URL)
Notes
topic/koshien-epic-738(v2 koshien ジェネレータ feat(scratch-gui): 甲子園 Ruby v2 対応(when_connect_game イベント hat + リスト引数 $配列構文) #744 を前提とするため)。develop へはEpic 取り込み PR feat: 甲子園拡張機能の本格対応 (Epic #738: MockClient + ゴールデン契約 + Ruby v2 + RemoteClient) #761 経由で反映。
Related
Refs #762 / Epic #738