feat: validate Ruby code by block conversion before saving#288
Merged
takaokouji merged 4 commits intodevelopfrom Mar 13, 2026
Merged
feat: validate Ruby code by block conversion before saving#288takaokouji merged 4 commits intodevelopfrom
takaokouji merged 4 commits intodevelopfrom
Conversation
RubyDownloader now validates Ruby code by converting to blocks before saving. If conversion fails, the save is aborted and onConversionError is called. On success, blocks are applied to update sprite/stage state (round-trip) before generating the final Ruby output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
🚀 Preview deployed: https://smalruby.jp/smalruby3-editor/feature/validate-before-save/ |
Change the Test AI menu to save the Ruby script first and open the Koshien test modal only after save succeeds (via onSaveFinished). Previously the modal opened immediately before save completed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When block conversion fails during save (from Ruby tab or Koshien menu), activate the Ruby tab, show the conversion error alert, and highlight errors in the Monaco editor. Add onConversionError callback to all RubyDownloader instances. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add tests verifying that file write is blocked when conversion fails and that File System API write succeeds after successful round-trip conversion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
github-actions bot
pushed a commit
that referenced
this pull request
Mar 13, 2026
…ate-before-save feat: validate Ruby code by block conversion before saving
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
Closes #287
Ruby タブの「ルビースクリプトを保存」実行前に、Ruby コードを命令ブロックに変換してバリデーションし、エラーがなければラウンドトリップでスプライト/ステージの状態を更新してから保存する。スモウルビー甲子園メニューも同様。
Implementation Steps
RubyDownloaderに変換バリデーション追加Changes Made
Phase 1:
RubyDownloaderに変換バリデーション追加RubyDownloaderにvalidateAndConvert()メソッド追加downloadProject()を async 化し、保存前に変換バリデーションを実行onConversionError/onSaveErrorコールバックで保存中断converter.apply()→convertedRubyCode()dispatch でラウンドトリップ完了Phase 2: 「AIを試す」の実行順序変更
getTestAIHandlerからモーダル表示を削除handleTestAISaveFinishedメソッド追加(保存完了後にモーダル表示)RubyDownloaderのonSaveFinishedにhandleTestAISaveFinishedを設定Phase 3: エラー時のユーザーフィードバック改善
handleConversionErrorメソッド追加(Ruby タブアクティブ化 + アラート表示 + エラー状態更新)handleConversionErrorコールバック追加(Monaco エディタでのエラーハイライト)RubyDownloaderインスタンスにonConversionErrorprop を設定Phase Final: テスト追加
Test Coverage
ruby-downloader.test.jsx(7 tests)