Skip to content

ロック画面コントロールを長押ししてもアプリが開かない問題を修正 - #6572

Merged
TinyKitten merged 2 commits into
devfrom
fix/lock-screen-control-open-app
Aug 6, 2026
Merged

TinyKitten merged 2 commits into
devfrom
fix/lock-screen-control-open-app

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Aug 6, 2026 •

Copy link
Copy Markdown
Member

概要

#6568 で追加したロック画面コントロールを長押ししても TrainLCD が起動しない不具合を修正する。

ロック画面下部のコントロールは懐中電灯・カメラと同様に「触れたまま押し込む → 拡大したら離す」で発動するため、長押しが正しい起動操作である。つまり操作方法の問題ではなく、コントロールに紐づけた AppIntent が実行されていなかった。

原因: OpenTrainLCDIntent を RideSessionActivity Extension のターゲットにしか含めていなかった。openAppWhenRun = true の AppIntent は Extension プロセスでは実行されず、システムがアプリを起動してアプリ側の定義で perform() を走らせる。アプリ本体に定義が無いと実行先が見つからず無反応になる。

変更の種類

  • バグ修正
  • 新機能
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • ios/RideSessionActivity/OpenTrainLCDIntent.swift(新規)
    • OpenTrainLCDIntent を LockScreenControl.swift から切り出し、アプリ本体と共有できるようにした
    • openAppWhenRun = true による起動に一本化。OpenURLIntent によるディープリンク併用は行わない(後述)
  • ios/TrainLCD.xcodeproj/project.pbxproj
    • 上記ファイルを CanaryTrainLCD / ProdTrainLCD(アプリ本体)と CanaryRideSessionActivityExtension / ProdRideSessionActivityExtension(Extension)の 4 ターゲット全てに登録。これが不具合の直接の修正にあたる
  • ios/RideSessionActivity/LockScreenControl.swift
    • インテント定義の移設に伴い import AppIntents を削除(コントロール定義自体は変更なし)
  • ios/RideSessionActivity/Schemes/{Dev,Prod}/Info.plist
    • CURRENT_SCHEME_NAME を追加。既存の Canary 版ロック画面ウィジェットが widgetURL で Prod スキーム(trainlcd://)を開いてしまう潜在バグの修正(RideSessionActivity.swift は Bundle.main からこのキーを読むが、Extension の Info.plist に存在しなかったため常に Prod 側へフォールバックしていた)

レビュー反映(000386a)

初回実装では openAppWhenRun に加えて OpenURLIntent でカスタムスキーム(trainlcd:// / trainlcd-canary://)も返していたが、OpenURLIntent は Universal Link 前提の API であり、カスタムスキームでは確実な起動経路にならない。本アプリの entitlements を確認したところ、アプリ本体には com.apple.developer.associated-domains が未設定(applinks: を持つのは App Clip のみ、しかも appclips: プレフィックス)で Universal Link を用意できないため、機能しないコードとして OpenURLIntent の併用を削除した。

Universal Link 経路が必要になるのは openAppWhenRun 単独での起動が実機で失敗した場合に限られ、その際は associated-domains + AASA の整備を含む別 PR で対応する。

回帰リスクと緩和策

  • アプリ本体への AppIntents 追加: OpenTrainLCDIntent は @available(iOS 18.0, *) で全体をガードしているため、アプリのデプロイターゲット(15.1)を下回る環境では参照されない。AppIntents.framework は可用性情報に基づき自動で weak link される。
  • openAppWhenRun の非推奨化: 後継の supportedModes / IntentModes は iOS 26.0 以降の API のため、iOS 18 を対象とする本コントロールでは採用できない(適合型より新しい可用性のメンバーでプロトコル要件を満たせない)。supportedModes を宣言しない場合の既定実装が openAppWhenRun を引き継ぐ後方互換設計に依存する。iOS 18 が最低対応から外れた時点で .foreground(.immediate) へ移行する。
  • Canary の URL スキーム変更: これまで Canary 拡張のウィジェットは誤って trainlcd:// を開いていたため、本 PR で trainlcd-canary:// に変わる。Canary ビルドで意図した側のアプリが開くことの確認が必要。

テスト

ローカルで以下を実行し、すべて成功することを確認した。

  • npm run lint: 615 ファイル検査、指摘なし

  • npm test: 208 suites / 2195 tests すべて成功

  • npm run typecheck: エラーなし

  • npm run lint が通ること

  • npm test が通ること

  • npm run typecheck が通ること

未検証事項(レビュー時にご確認ください)

  • 変更は Swift / pbxproj / Info.plist のみで、JS 側のテスト対象コードは変更していない(上記 3 コマンドは回帰確認のために実行)。
  • 作業環境が Linux コンテナのため Xcode でのビルド確認は未実施。実機での以下の確認をお願いしたい。
    • ロック画面下部のコントロールを長押しして TrainLCD が起動すること
    • Canary ビルドで Canary アプリが(Prod ではなく)起動すること
    • コントロールセンターに配置したコントロールからも起動すること
    • Canary 版ロック画面ウィジェットのタップで Canary アプリが開くこと(CURRENT_SCHEME_NAME 追加による副次的な修正)

関連Issue

スクリーンショット(任意)

macOS / シミュレータのない環境での作業のため未添付。動作確認時のロック画面からの起動フローの記録をいただけると助かります(例: iPhone 15 Pro / iOS 18 以降)。

@TinyKitten TinyKitten self-assigned this Aug 6, 2026
@github-actions github-actions Bot added the ios label Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

OpenTrainLCDIntentを独立ファイルへ移動しました。openAppWhenRunを有効にし、Canaryと本番の設定および4つの関連ターゲットを更新しました。

Changes

OpenTrainLCDIntent の共有化

Layer / File(s) Summary
起動Intentの分離
ios/RideSessionActivity/OpenTrainLCDIntent.swift, ios/RideSessionActivity/LockScreenControl.swift
OpenTrainLCDIntentを独立ファイルへ追加しました。openAppWhenRunを有効にし、perform()は空のIntentResultを返します。ロック画面側の定義とAppIntentsのインポートを削除しました。
環境設定とターゲット登録
ios/RideSessionActivity/Schemes/*/Info.plist, ios/TrainLCD.xcodeproj/project.pbxproj
DevにCanaryTrainLCD、ProdにProdTrainLCDを設定しました。Intentを4つのソースビルドフェーズへ登録しました。

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant LockScreenControl
  participant OpenTrainLCDIntent
  participant iOS
  LockScreenControl->>OpenTrainLCDIntent: Intentを参照
  iOS->>OpenTrainLCDIntent: perform()を実行
  OpenTrainLCDIntent-->>iOS: 空のIntentResultを返す
  iOS->>iOS: openAppWhenRunによりアプリを開く
Loading

Possibly related PRs

Poem

Intentが独立、うさぎは跳ねる。
CanaryとProdを正しく分ける。
空の結果でも、起動は進む。
四つのターゲットで列車を待つ。
TrainLCDへ、ぴょんと出発。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed タイトルは、ロック画面コントロールからアプリが起動しない不具合の修正という主な変更を明確に示しています。
Description check ✅ Passed 概要、変更内容、変更種別、テスト結果、未検証事項、関連Issue、スクリーンショットの各項目を記載しています。
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/lock-screen-control-open-app

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ios/RideSessionActivity/OpenTrainLCDIntent.swift`:
- Around line 18-20: Update the deep-link handling in OpenTrainLCDIntent so
OpenURLIntent receives an https Universal Link instead of the trainlcd:// or
trainlcd-canary:// custom schemes. Preserve distinct Canary and production
routing, using the configured Associated Domains/AASA Universal Links or another
supported launch path that reliably starts both variants from LockScreenControl.
- Line 27: OpenTrainLCDIntent の共有定義から openAppWhenRun = true を削除し、代わりに
supportedModes で必要なフォアグラウンド遷移を指定してください。アプリ本体と RideSessionActivity
拡張の双方で利用できる設定にし、iOS 18 実機でロック画面および Control Center 操作時の動作を確認してください。
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e1fa1b31-0b63-4e4e-ad8b-44f7619a89d7

📥 Commits

Reviewing files that changed from the base of the PR and between 8688771 and ed3507a.

📒 Files selected for processing (5)
  • ios/RideSessionActivity/LockScreenControl.swift
  • ios/RideSessionActivity/OpenTrainLCDIntent.swift
  • ios/RideSessionActivity/Schemes/Dev/Info.plist
  • ios/RideSessionActivity/Schemes/Prod/Info.plist
  • ios/TrainLCD.xcodeproj/project.pbxproj

@TinyKitten
TinyKitten merged commit cb3367e into dev Aug 6, 2026
3 checks passed
@TinyKitten
TinyKitten deleted the fix/lock-screen-control-open-app branch August 6, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants