fix(mobile): screenshot/file downloads now work on iOS Safari (#833)#837
Conversation
iOS/iPadOS Safari silently ignores the anchor `download` attribute, so the screenshot buttons (Code tab BlocksScreenshotButton, Ruby tab ruby-screenshot) and other blob downloads produce no visible result on mobile. Add a mobile-friendly path in the shared download-blob helper: on iOS/iPadOS it uses the Web Share API (save to Photos/Files) when files are shareable, and otherwise opens the blob in a new tab for long-press save. Desktop keeps the existing anchor-click behavior unchanged. The branch-selection logic is a pure function (chooseDownloadStrategy) covered by jest unit tests. Real-device mobile save verification is left to a human (HITL). Refs #833 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🤖 autopilot status
Linked issue #833. Maintained by autopilot (single writer); do not edit. |
|
🚀 Preview deployed: https://smalruby.jp/smalruby3-editor/topic/autopilot-833/ |
navigator.share rejects with AbortError on a deliberate user cancel. The previous catch treated cancel and failure alike, so cancelling the iOS share sheet surprised the user with a new tab. Only fall back to opening the blob on a genuine share failure. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🤖 敵対的レビュー (autopilot-review)差分を批判的観点でレビューしました。1 件は安全に自動修正済み、もう 1 件は実機確認で必ず見てほしい設計リスクとして残します。 ✅ 自動修正済み — 共有キャンセル時の不要な新規タブ
|
🧪 DoD 引き継ぎ(headful Playwright / ホスト Claude 用)このコメントは DoD フェーズの引き継ぎドキュメントです。コンテナ内 autopilot は headless の
役割: PR smalruby/smalruby3-editor #837(Issue #833)の DoD を headful Playwright MCP(ホストの実 Chrome)で 対象
事前準備
検証手順(Issue の DoD チェックリスト)以下は Issue #833 の DoD をそのまま転記したもの。各項目を headful で確認し、結果を記録する。
報告(完了の出口)
検証は 本番 Chrome で行うこと(Playwright の Chromium はポリシーが緩く誤検知することがある)。 |
…ot-833 fix(mobile): screenshot/file downloads now work on iOS Safari (#833)
Summary
モバイル(特に iOS / iPadOS Safari)でプログラムのスクリーンショット撮影ボタンが「動かない」(無反応)不具合の修正です。
BlocksScreenshotButton(blocks-screenshot-button_screenshotButton_*)ruby-tab_zoomButton_*/data-testid="ruby-screenshot")原因
画像生成(SVG→canvas→PNG / Monaco→PNG)自体は成功していますが、最終的な保存はどちらも共有ヘルパー
src/lib/download-blob.jsの<a download>.click()方式に依存しています。iOS / iPadOS Safari は anchor のdownload属性を無視するため、'download' in HTMLAnchorElement.prototypeはtrueでも実際の保存が起きず、ユーザーには「何も起きない」ように見えます。この
download-blob.jsは 7 箇所(スクショ2経路、sb3 保存、コスチューム/音/モニタ出力)から使われる共有ヘルパーなので、パターンの根本(中央)を直しました。Changes Made
src/lib/download-blob.js(upstream ファイル, Smalruby マーカー付き)に保存方式の分岐を追加:downloadクリック(挙動変更なし)。navigator.share({files}))で「写真 / ファイルに保存」。共有不可なら blob を新規タブで開いて長押し保存にフォールバック。msSaveOrOpenBlob)は従来どおり。maxTouchPointsで判定。Android Chrome はdownloadが効くのでモバイル扱いにしない(無用な回帰を避ける)。chooseDownloadStrategy()に切り出し、isAppleMobile()とともに jest で単体テスト。docs/maintenance/smalruby-markers-gui.md)と.prettierignoreホワイトリストを更新。Test Coverage
test/unit/lib/download-blob.test.js(新規, 12 tests):chooseDownloadStrategy: msSave / desktop=anchor / mobile+share / mobile→newTab / mobile が anchor を選ばない / 旧ブラウザ=newTab。isAppleMobile: iPhone / iPad / iPadOS13+(touch) / 実 Mac(非touch=false) / Android(false) / Windows(false)。blocks-screenshot.test.js/ruby-screenshot.test.jsも green(回帰なし)。実機モバイルでの保存挙動は人間による確認が必要です。プレビュー環境で以下を確認してください:
Related Issues
Closes #833