PWA起動時に前回の途中画面が復元されるのを防ぐ (#197) - #209
Merged
Merged
Conversation
standalone 表示はOSが最後のURLでアプリを復元することがあり、start_url("/")
ではなくおみくじ・参拝画面から始まってしまう。セッション初回(=起動直後)
かつ standalone のときだけ、途中画面ならトップへ戻すプラグインを追加。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015NjEjZtmCpVdJtCeFumYzG
This was referenced Jul 25, 2026
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.
Closes #197
問題
PWA(ホーム画面追加/standalone表示)から起動すると、manifest の
start_url: "/"ではなく前回表示していたURL(おみくじ・参拝画面)が復元されてしまう。OSやブラウザが「最後に表示していたURL」でアプリを復元するためで、クライアント側に起動時の画面リセット処理がなかった。変更内容
web/plugins/pwa-start.client.jsを追加:display-mode: standalone/ iOS のnavigator.standalone)を検知sessionStorageで「セッション初回=アプリ起動直後」を判定(タブ切替・同一セッション内の遷移では何もしない)/omikuji・/sanpai)にいる場合だけトップへrouter.replaceなお Issue 起票時に挙げた自己破壊型SW(
web/static/sw.js)は gitignore 済みのローカル生成物で、リポジトリに存在せず本番にも出荷されていないことを確認した(本番配信中の/sw.jsは PWA モジュール生成の workbox 版)。よって本PRでの削除対象はない。参拝画面の途中状態は #198(マージ済み)のローカル復元が担うため、本プラグインは「起動画面をトップに揃える」ことに専念している。
検証
yarn generate(node:18)成功、yarn.lock差分なし/omikujiを表示したままアプリを完全終了 → 再起動でトップが表示されること。通常のブラウザタブではリロード・戻る操作で従来どおり現在URLが維持されること(standalone 以外では何もしないため)🤖 Generated with Claude Code
https://claude.ai/code/session_015NjEjZtmCpVdJtCeFumYzG