Skip to content

feat(koshien): 「AIを試す」で現スプライト・現バージョンの生成AIをplayer1で渡す (#762)#765

Merged
smalruby3-editor-bot[bot] merged 1 commit into
topic/koshien-epic-738from
feature/issue-762-koshien-test-ai-param
Jun 28, 2026
Merged

feat(koshien): 「AIを試す」で現スプライト・現バージョンの生成AIをplayer1で渡す (#762)#765
smalruby3-editor-bot[bot] merged 1 commit into
topic/koshien-epic-738from
feature/issue-762-koshien-test-ai-param

Conversation

@smalruby3-editor-bot

Copy link
Copy Markdown

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 で最新コードを再生成。
  • テスト(新規): ビューアと同じ復号手順(decodeURIComponent → data: 除去 → atob →
    TextDecoder utf-8)で往復を検証。空コード時に base URL のままになることも確認。

Test Coverage

  • test/unit/lib/koshien-test-url.test.js 7 件 pass(ASCII / 日本語 UTF-8 往復、空/空白フォールバック、
    player1 セット、player2 未セット、カスタム base URL)
  • 変更ファイルの eslint / prettier green(全体 lint は CI)

Notes

Related

Refs #762 / Epic #738

…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>
@github-actions

Copy link
Copy Markdown

@smalruby3-editor-bot smalruby3-editor-bot Bot merged commit 9ecd64c into topic/koshien-epic-738 Jun 28, 2026
9 checks passed
@smalruby3-editor-bot smalruby3-editor-bot Bot deleted the feature/issue-762-koshien-test-ai-param branch June 28, 2026 13:03
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.

0 participants