Repository navigation
経路プリセットをクイックアクションから呼び出せるようにする - #5563
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
📝 WalkthroughWalkthroughネイティブのクイックアクションを追加。 Changes
Sequence Diagram(s)sequenceDiagram
participant OS as OS (iOS/Android)
participant QA as QuickActions\n(useQuickActions)
participant Nav as NavigationAtom\n(pendingQuickActionRouteId)
participant SLS as SelectLineScreen
participant DB as Routes Data
OS->>QA: ユーザーがクイックアクションを選択
QA->>QA: action.params から routeId を抽出
QA->>Nav: pendingQuickActionRouteId を設定
Note right of SLS: 起動済みでもコールドスタートでも処理
SLS->>DB: usePresetCarouselData で routes を取得
SLS->>Nav: pendingQuickActionRouteId を監視
alt pendingQuickActionRouteId が設定されている
SLS->>SLS: routes から一致を検索
SLS->>SLS: handlePresetPress を呼び出す(選択処理)
SLS->>Nav: pendingQuickActionRouteId を null にリセット
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/screens/SelectLineScreen.render.test.tsx (1)
19-20: 新しい quick action 導線のテストがまだ通っていません。
useAtomは常にpendingQuickActionRouteId: nullを返し、useQuickActionsも丸ごと no-op なので、今回追加した「pending ID に一致する preset を自動で開いてからクリアする」経路が壊れてもこのファイルでは検知できません。少なくとも 1 ケース、pendingQuickActionRouteIdをセットしてhandlePresetPressと setter の両方を確認したいです。 As per coding guidelines "Test agents in isolation and with integration tests to ensure correctness and compatibility".Also applies to: 73-73
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/screens/SelectLineScreen.render.test.tsx` around lines 19 - 20, The test currently always mocks useAtom to return { pendingQuickActionRouteId: null } and leaves useQuickActions as a no-op, so the new flow that auto-opens a preset when pendingQuickActionRouteId is set isn't exercised; update the test to include at least one case where useAtom returns a state with pendingQuickActionRouteId set (e.g., a non-null ID) and a mock setter function, then assert that the component calls handlePresetPress (or the internal opener) and that the atom setter is called to clear the pendingQuickActionRouteId; also adjust the useQuickActions mock to simulate the real behavior needed for auto-opening so the integration path is tested.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/screens/SelectLineScreen.tsx`:
- Around line 88-90: quick action handling is currently scoped to
SelectLineScreen (useQuickActions and consumption of pendingQuickActionRouteId),
so shortcuts are ignored when the app resumes on other screens; move the
quick-action listener to a global/root level (e.g., AppRoot or
NavigationContainer host) or surface a global handler via Context that consumes
pendingQuickActionRouteId and navigates to SelectLineScreen; specifically,
register useQuickActions (or its logic) at the app root, ensure it reads and
clears pendingQuickActionRouteId centrally, and invoke
navigation.navigate('SelectLineScreen', { routeId }) from that root handler so
pending shortcuts are consumed regardless of which screen is visible.
---
Nitpick comments:
In `@src/screens/SelectLineScreen.render.test.tsx`:
- Around line 19-20: The test currently always mocks useAtom to return {
pendingQuickActionRouteId: null } and leaves useQuickActions as a no-op, so the
new flow that auto-opens a preset when pendingQuickActionRouteId is set isn't
exercised; update the test to include at least one case where useAtom returns a
state with pendingQuickActionRouteId set (e.g., a non-null ID) and a mock setter
function, then assert that the component calls handlePresetPress (or the
internal opener) and that the atom setter is called to clear the
pendingQuickActionRouteId; also adjust the useQuickActions mock to simulate the
real behavior needed for auto-opening so the integration path is tested.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 43d4a43a-437b-4dc6-88bf-a51b42d8dbfc
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (8)
app.config.tspackage.jsonsrc/hooks/useDeepLink.test.tsxsrc/hooks/useLineSelection.test.tsxsrc/hooks/useQuickActions.tssrc/screens/SelectLineScreen.render.test.tsxsrc/screens/SelectLineScreen.tsxsrc/store/atoms/navigation.ts
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/hooks/useSavedRoutes.ts`:
- Around line 124-128: The current ensureDbInitialized stores a rejected Promise
in initPromise so failures become permanent; change the assignment so
initPromise = initDb().catch(err => { initPromise = null; throw err; }) (i.e.,
in ensureDbInitialized wrap the initDb() call with a catch that resets
initPromise to null and rethrows the error) so subsequent calls can retry;
reference ensureDbInitialized, initDb, and initPromise when making this change.
- Around line 137-140: The useEffect calling ensureDbInitialized lacks error
handling and can leave presetsFetched false on rejection; wrap the promise with
a .catch (or use try/catch in an async IIFE) to capture migration/PRAGMA
failures, log the error, and update navigation atom to avoid infinite waiting —
e.g., in the catch call setNavigationAtom(prev => ({ ...prev, presetsFetched:
true, presetsInitError: true })) and include the error detail in your log (use
your app logger or console) so ensureDbInitialized, setNavigationAtom, and the
presetsFetched state are updated even on failure.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7211d215-caad-440c-8122-d641e7a77a28
⛔ Files ignored due to path filters (1)
ios/Podfile.lockis excluded by!**/*.lock
📒 Files selected for processing (1)
src/hooks/useSavedRoutes.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/hooks/useQuickActions.ts (1)
54-57: コールドスタート時のアクション処理が再マウント時に重複実行される可能性
QuickActions.initialは静的な値で、アプリが完全に再起動されるまで残り続けます。コンポーネントが再マウントされた場合、同じinitialアクションが再度処理される可能性があります。処理済みフラグを追加するか、処理後に
initialを参照しないようにすることを検討してください。♻️ 重複処理を防ぐ修正案
+let initialHandled = false; + export const useQuickActions = () => { // ... useEffect(() => { // ... // コールドスタート時 - if (QuickActions.initial) { + if (QuickActions.initial && !initialHandled) { + initialHandled = true; handleAction(QuickActions.initial); } // ... }, [setNavigationState]); };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/hooks/useQuickActions.ts` around lines 54 - 57, The cold-start action QuickActions.initial can be processed multiple times on remount; in useQuickActions ensure the initial action is handled only once by adding a processed flag or clearing the static after first use: inside the initialization logic (where QuickActions.initial is checked and handleAction(QuickActions.initial) is called) guard it with a boolean (e.g., handledInitialRef or handledInitial state) or set QuickActions.initial = null/undefined after calling handleAction, so subsequent mounts skip re-processing; update the check and post-call behavior in useQuickActions to use that flag/clear to prevent duplicate handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/hooks/useQuickActions.ts`:
- Around line 43-51: The current navigation dispatch in useQuickActions.ts only
runs when navigationRef.isReady() is true, leaving pendingQuickActionRouteId
orphaned; change this by adopting the waitForNavReady pattern (like in
useDeepLink.ts) or by queuing/retrying the navigation when navigationRef becomes
ready: in useQuickActions.ts, wrap the dispatch logic that navigates to
'MainStack' -> 'SelectLine' (the block that checks navigationRef.isReady()) with
a waitForNavReady() helper or subscribe to navigationRef readiness, then perform
the CommonActions.navigate call and clear pendingQuickActionRouteId once
navigation succeeds; ensure the retry mechanism is idempotent so it won’t
double-navigate when already handled.
---
Nitpick comments:
In `@src/hooks/useQuickActions.ts`:
- Around line 54-57: The cold-start action QuickActions.initial can be processed
multiple times on remount; in useQuickActions ensure the initial action is
handled only once by adding a processed flag or clearing the static after first
use: inside the initialization logic (where QuickActions.initial is checked and
handleAction(QuickActions.initial) is called) guard it with a boolean (e.g.,
handledInitialRef or handledInitial state) or set QuickActions.initial =
null/undefined after calling handleAction, so subsequent mounts skip
re-processing; update the check and post-call behavior in useQuickActions to use
that flag/clear to prevent duplicate handling.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c53baace-bb88-45ca-b1d1-833f146271b2
📒 Files selected for processing (5)
src/hooks/useQuickActions.tssrc/index.tsxsrc/providers/QuickActionsProvider.tsxsrc/screens/SelectLineScreen.render.test.tsxsrc/screens/SelectLineScreen.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
- src/screens/SelectLineScreen.render.test.tsx
- src/screens/SelectLineScreen.tsx
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/hooks/useQuickActions.ts`:
- Around line 55-64: useEffect 内で直接 QuickActions.setItems(...) を呼んで未処理の Promise
を放置しているため、QuickActions.isSupported() を使ってサポート判定を行い、setItems の呼び出しを
await/then/catch でハンドルして例外を吸収するように修正してください。具体的には useEffect のコールバックを非同期関数(または即時実行
async 関数)にして QuickActions.isSupported() を await し、true の場合のみ
QuickActions.setItems(presetRoutes.slice(0, MAX_QUICK_ACTIONS).map(...))
を呼び出し、その Promise に対して catch を追加して失敗時は無視またはログだけ残すようにしてください(参照箇所: useEffect,
QuickActions.setItems, QuickActions.isSupported, presetRoutes,
MAX_QUICK_ACTIONS, Platform.OS)。
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 05511fbc-61d8-43c3-b0c1-0bd7e33a1baa
📒 Files selected for processing (2)
src/hooks/useQuickActions.tssrc/hooks/useSavedRoutes.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/hooks/useSavedRoutes.ts
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/hooks/useQuickActions.ts`:
- Around line 55-69: The current useEffect's async syncItems can run
out-of-order and overwrite newer quick-action state; modify the useQuickActions
hook to add a generation/token guard (e.g., a useRef counter or epoch) checked
by syncItems before calling QuickActions.setItems so only the latest invocation
writes to native. Increment the generation at each effect run (inside useEffect)
and capture it in syncItems; before and/or after any await, verify the captured
generation still matches the current ref and abort if not. Ensure symbols
referenced are useEffect, syncItems, QuickActions.setItems, presetRoutes, and
MAX_QUICK_ACTIONS so the fix is applied to the existing logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 95fec6f5-a74d-4f72-918d-b1129b62718e
📒 Files selected for processing (1)
src/hooks/useQuickActions.ts
|
@coderabbitai resume |
✅ Actions performedReviews resumed. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/hooks/useQuickActions.ts`:
- Around line 15-42: The waitForNavReady() polling can give up (resolve false)
and leave pendingQuickActionRouteId set, causing stale quick actions to fire
later; update navigateToSelectLine (and the analogous block around
pendingQuickActionRouteId handling) to explicitly handle the failure case
instead of silently returning: either replace the fixed-retry polling with an
event-driven wait that subscribes to the navigation ready event (use the
navigationRef's ready/onReady listener and resolve when it fires) so it waits
until ready, or if you keep a retry limit then clear or reset
pendingQuickActionRouteId and log/handle the failure path when waitForNavReady()
returns false so no stale pending action remains. Reference:
navigateToSelectLine, waitForNavReady, navigationRef.isReady(), and
pendingQuickActionRouteId.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7dddd452-8e93-4891-9900-462de282c2c1
📒 Files selected for processing (1)
src/hooks/useQuickActions.ts
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Summary
close #4490
expo-quick-actionsを導入し、SQLiteに保存された経路プリセット(最大4件)をiOS/Androidのクイックアクション(ホーム画面長押しショートカット)として表示tram.fillSFSymbol アイコンを表示主な変更
src/hooks/useQuickActions.ts: プリセット同期・アクション選択ハンドリングフック(新規)src/store/atoms/navigation.ts:pendingQuickActionRouteIdステート追加src/screens/SelectLineScreen.tsx: クイックアクション統合(同期 + 自動発火)app.config.ts:expo-quick-actionsプラグイン追加動作フロー
Test plan
npm run typecheckパスnpm test全1261テストパス🤖 Generated with Claude Code
Summary by CodeRabbit