feat: accept status array in useRuns filter (#140)#154
Conversation
Allow `status` option to accept `RunStatus | RunStatus[]` across the entire stack: storage (WHERE IN), HTTP handler (getAll + validation), React hooks (both client and browser modes with reference stabilization). Empty array is treated as no filter. Invalid/empty status values return 400. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
|
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 (7)
📝 WalkthroughWalkthroughuseRuns の Changes
Sequence Diagram(s)sequenceDiagram
participant Client as React Client
participant Server as Durably API Server
participant Storage as Storage Layer
Client->>Client: useStableValue(status: RunStatus|RunStatus[])
Client->>Server: GET /api/durably/runs?status=pending&status=leased
Server->>Server: parseRunFilter() -> statuses = getAll('status')
Server->>Server: validate each status (no empty, in VALID_STATUSES)
Server->>Storage: getRuns(filter with status: single|array)
Storage->>Storage: build query (status = X OR status IN (...))
Storage-->>Server: runs[]
Server-->>Client: 200 JSON runs[]
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 |
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 `@packages/durably-react/src/client/use-runs.ts`:
- Line 416: 現在の「if (!status)
return」は空文字列を誤って未指定扱いにして送信を止めているので、空文字列を許容して未指定(null/undefined)のみ早期リターンする判定に変更してください;具体的には該当の
status チェック(use-runs.ts 内の status 変数をチェックしている箇所)を「if (status == null)
return」または「if (status === undefined || status === null) return」に置き換え、空文字列 ('')
がそのまま送信されるようにしてください。
🪄 Autofix (Beta)
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: 61d10478-8e8f-478f-964a-621fed165d7b
📒 Files selected for processing (10)
packages/durably-react/src/client/use-runs.tspackages/durably-react/src/hooks/use-runs.tspackages/durably-react/tests/browser/use-runs.test.tsxpackages/durably-react/tests/client/use-runs.test.tsxpackages/durably-react/tests/types.test.tspackages/durably/src/server.tspackages/durably/src/storage.tspackages/durably/tests/node/types.test.tspackages/durably/tests/shared/run-api.shared.tspackages/durably/tests/shared/server.shared.ts
Deduplicate JSON.stringify/parse stabilization pattern across hooks (6 instances → shared useStableValue hook). Unify appendJobNameToParams and appendStatusToParams into generic appendArrayParam. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prevent empty string from being silently dropped as falsy. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update RunFilter.status type and useRuns options across llms.md, website API reference (create-durably, spa, fullstack), and regenerate llms.txt. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
RunFilter.statusnow acceptsRunStatus | RunStatus[]— enablesgetRuns({ status: ['pending', 'leased'] })?status=pending&status=leasedviagetAll()with per-value validationTest plan
getRuns({ status: ['pending', 'leased'] })returns only matching runsgetRuns({ status: [] })returns all runs (no filter)?status=pending&status=leasedparsed correctly?status=runningreturns 400?status=(empty value) returns 400useRuns({ status: ['pending', 'leased'] })builds correct URL (client mode)useRuns({ status: ['pending', 'leased'] })works in browser modeRunFilter.status,UseRunsOptions.status,UseRunsClientOptions.statuspnpm validatepasses (206 tests)Closes #140
🤖 Generated with Claude Code
Summary by CodeRabbit
新機能
useRunsのstatusフィルタが複数ステータスを受け取れるようになりました(配列指定で OR 検索)。status配列はフィルタ未指定として扱われ、全件が返ります。テスト