refactor: action 戻り値型統一・toast 通知・エラーハンドリング整備#230
Conversation
Closes #229 - 全 multi-intent action の戻り値を { ok, lastResult } に統一 - 成功パスに dataWithSuccess で toast 追加(8箇所) - エラーパスに dataWithError で toast 追加(settings 系4箇所) - danger route に try/catch 追加 - ConfirmDialogData 型を統一型に対応 - コンポーネントの型ガード簡素化 - 'lastResult' in data → data?.lastResult - 'ok' in data → data?.ok === true - repositories.add の console.error 除去 - data-table-floating-bar の型キャスト除去 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough複数の設定ページのアクションハンドラを更新し、 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (2)
app/routes/$orgSlug/settings/_index/index.tsx (1)
36-41: 統一されたレスポンス形式との整合性バリデーション失敗時のレスポンスに
ok: falseが含まれていません。他のルート(repositories._index/index.tsxの Line 86、members/index.tsxの Line 92)では{ ok: false, lastResult: submission.reply() }を返しています。一貫性のため、このパスも同じ形式に更新することを検討してください。
♻️ 提案する修正
if (submission.status !== 'success') { - return { + return data({ + ok: false, intent: 'organization-settings' as const, lastResult: submission.reply(), - } + }, { status: 400 }) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/routes/`$orgSlug/settings/_index/index.tsx around lines 36 - 41, The branch that handles non-success submission in the settings route returns an object missing the unified ok flag; update the block that checks submission.status !== 'success' so it returns { ok: false, intent: 'organization-settings' as const, lastResult: submission.reply() } (i.e., add ok: false) to match the response shape used by repositories._index and members/index handlers.app/routes/$orgSlug/settings/members/index.tsx (1)
121-128: removeMember エラー時のトースト通知がありません
removeMemberのエラーパスではdata()を使用しているため、トースト通知が表示されません。changeRoleのエラーパスではdataWithErrorを使用してトーストを表示しています。
shouldConfirm: trueを維持しつつトースト通知も行う場合、dataWithErrorにshouldConfirmを含める方法を検討してください。ただし、ダイアログ内にエラーが表示される設計であれば、現状のままでも問題ありません。♻️ トースト通知を追加する場合の修正案
} catch (e) { + const message = getErrorMessage(e) - return data( + return dataWithError( { ok: false, - lastResult: submission.reply({ formErrors: [getErrorMessage(e)] }), + lastResult: submission.reply({ formErrors: [message] }), shouldConfirm: true, }, - { status: 400 }, + { message }, ) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/routes/`$orgSlug/settings/members/index.tsx around lines 121 - 128, The removeMember error branch currently returns data(...) so no toast is shown; change that return to use dataWithError(...) (the same helper used by changeRole) and include shouldConfirm: true plus the existing lastResult payload (submission.reply({ formErrors: [getErrorMessage(e)] })) so the toast/error UI is triggered while preserving the confirmation dialog state; locate the error return inside the removeMember handler and replace the data(...) call with dataWithError(...) carrying the same object and status.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@app/routes/`$orgSlug/settings/_index/index.tsx:
- Around line 36-41: The branch that handles non-success submission in the
settings route returns an object missing the unified ok flag; update the block
that checks submission.status !== 'success' so it returns { ok: false, intent:
'organization-settings' as const, lastResult: submission.reply() } (i.e., add
ok: false) to match the response shape used by repositories._index and
members/index handlers.
In `@app/routes/`$orgSlug/settings/members/index.tsx:
- Around line 121-128: The removeMember error branch currently returns data(...)
so no toast is shown; change that return to use dataWithError(...) (the same
helper used by changeRole) and include shouldConfirm: true plus the existing
lastResult payload (submission.reply({ formErrors: [getErrorMessage(e)] })) so
the toast/error UI is triggered while preserving the confirmation dialog state;
locate the error return inside the removeMember handler and replace the
data(...) call with dataWithError(...) carrying the same object and status.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 757a2059-3d9e-44a1-a482-2f9ab436d044
📒 Files selected for processing (13)
app/components/confirm-dialog.tsxapp/routes/$orgSlug/settings/_index/index.tsxapp/routes/$orgSlug/settings/danger/index.tsxapp/routes/$orgSlug/settings/export/index.tsxapp/routes/$orgSlug/settings/github-users._index/index.tsxapp/routes/$orgSlug/settings/integration/index.tsxapp/routes/$orgSlug/settings/members/+components/member-row-actions.tsxapp/routes/$orgSlug/settings/members/index.tsxapp/routes/$orgSlug/settings/repositories._index/+components/data-table-floating-bar.tsxapp/routes/$orgSlug/settings/repositories._index/index.tsxapp/routes/$orgSlug/settings/repositories.add/index.tsxapp/routes/$orgSlug/settings/repositories/$repository/settings/index.tsxapp/routes/$orgSlug/settings/teams._index/index.tsx
Summary
{ ok: boolean, lastResult: SubmissionResult | null }に統一変更内容
戻り値型の統一(5ルート)
teams._index,github-users._index,repositories._index,members,repositories/$repository/settingsの全分岐でok+lastResultを返すように統一。toast 追加(成功 8箇所・エラー 4箇所)
エラーハンドリング改善
danger/index.tsx:deleteOrganization()に try/catch 追加repositories.add/index.tsx:console.error除去、実際のエラーメッセージ使用getErrorMessage(e)に置換コンポーネント簡素化
member-row-actions.tsx:'lastResult' in data→data?.lastResult、'ok' in data→data?.ok === truerepositories/$repository/settings: 同上data-table-floating-bar.tsx:useFetcher<{ ok: boolean }>ジェネリックで型キャスト除去Closes #229
Test plan
pnpm validate通過🤖 Generated with Claude Code
Summary by CodeRabbit
リリースノート
バグ修正
ユーザー体験