Skip to content

feat: accept status array in useRuns filter (#140)#154

Merged
coji merged 4 commits intomainfrom
feat/use-runs-status-array
Mar 26, 2026
Merged

feat: accept status array in useRuns filter (#140)#154
coji merged 4 commits intomainfrom
feat/use-runs-status-array

Conversation

@coji
Copy link
Copy Markdown
Owner

@coji coji commented Mar 26, 2026

Summary

  • RunFilter.status now accepts RunStatus | RunStatus[] — enables getRuns({ status: ['pending', 'leased'] })
  • HTTP handler supports ?status=pending&status=leased via getAll() with per-value validation
  • React hooks (client + browser) updated with reference stabilization to prevent re-fetch loops
  • Empty array treated as no filter; empty/invalid values return 400

Test plan

  • getRuns({ status: ['pending', 'leased'] }) returns only matching runs
  • getRuns({ status: [] }) returns all runs (no filter)
  • Single status still works (backward compatible)
  • HTTP ?status=pending&status=leased parsed correctly
  • HTTP ?status=running returns 400
  • HTTP ?status= (empty value) returns 400
  • useRuns({ status: ['pending', 'leased'] }) builds correct URL (client mode)
  • useRuns({ status: ['pending', 'leased'] }) works in browser mode
  • Reference stabilization: inline arrays don't cause re-fetch loops
  • Type tests for RunFilter.status, UseRunsOptions.status, UseRunsClientOptions.status
  • pnpm validate passes (206 tests)

Closes #140

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 新機能

    • useRunsstatus フィルタが複数ステータスを受け取れるようになりました(配列指定で OR 検索)。
    • 空の status 配列はフィルタ未指定として扱われ、全件が返ります。
    • フックは入力値の参照安定化を行い、不必要な再取得や再描画を抑制します。
  • テスト

    • 複数ステータス指定や空配列挙動を検証するテストを追加しました。

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>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
durably-demo Ready Ready Preview Mar 26, 2026 2:57pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
durably-demo-vercel-turso Ignored Ignored Mar 26, 2026 2:57pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 26, 2026

Warning

Rate limit exceeded

@coji has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 41 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a89d69fc-1424-42eb-adb6-12680fa84813

📥 Commits

Reviewing files that changed from the base of the PR and between f51b46b and adeaf84.

📒 Files selected for processing (7)
  • packages/durably-react/docs/llms.md
  • packages/durably-react/src/client/use-runs.ts
  • packages/durably/docs/llms.md
  • website/api/create-durably.md
  • website/api/durably-react/fullstack.md
  • website/api/durably-react/spa.md
  • website/public/llms.txt
📝 Walkthrough

Walkthrough

useRuns の status オプションが単一値から RunStatus | RunStatus[] に拡張され、クライアントは値を安定化してクエリに複数 status パラメータを付与。サーバーは複数 status クエリを受け取り個別検証し、ストレージ層は単一値は等号、複数値は IN 句でフィルタリングするよう変更された。

Changes

Cohort / File(s) Summary
React クライアント層
packages/durably-react/src/client/use-runs.ts, packages/durably-react/src/hooks/use-runs.ts, packages/durably-react/src/shared/use-stable-value.ts
status 型を RunStatus | RunStatus[] に拡張。useStableValue を導入して status/jobName/labels を安定化し、クエリパラメータ生成で単値/配列を適切に append するよう変更。
サーバーサイド解析
packages/durably/src/server.ts, packages/durably/tests/shared/server.shared.ts
GET /api/durably/runsstatusgetAll('status') で取得して個別検証。空文字列や不正値は 400 応答。複数値/単一値どちらにも対応するレスポンス検証テストを追加。
ストレージ層
packages/durably/src/storage.ts, packages/durably/tests/shared/run-api.shared.ts
RunFilter.statusRunStatus | RunStatus[] に変更。配列なら WHERE IN、単一値なら =、空配列ならフィルタ無効になるようクエリ構築を変更。API 統合テストを追加。
テスト(クライアント・ブラウザ)
packages/durably-react/tests/client/use-runs.test.tsx, packages/durably-react/tests/browser/use-runs.test.tsx
status に配列を渡すケースを追加。URL に複数 status が含まれること、同一配列で再レンダリング時に再フェッチしないことなどを検証。
型テスト
packages/durably-react/tests/types.test.ts, packages/durably/tests/node/types.test.ts
TypeScript の型テストを追加し、UseRunsOptions['status'] / UseRunsClientOptions['status'] / RunFilter['status']RunStatus | RunStatus[] | undefined になることを検証。

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[]
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 小さな耳で見渡せば、
ステータスが並んで踊るよ、
pending と leased を手を取り、
クエリは IN で歌う夜、
うさぎは跳ねてバグを見逃さない ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly describes the main feature: allowing useRuns to accept status arrays for filtering. It is concise and directly reflects the primary change.
Linked Issues check ✅ Passed All objectives from issue #140 are met: status accepts RunStatus | RunStatus[] [client, hook], server uses WHERE IN for arrays [server.ts, storage.ts], SSE supports arrays [client hook], empty arrays treated as unset [client, hook, server], and types updated across packages.
Out of Scope Changes check ✅ Passed All changes directly support the stated objective. Introduction of useStableValue and appendArrayParam helpers support stabilization and array param handling as part of the feature implementation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/use-runs-status-array

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.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 33b4fc3 and 426f3d5.

📒 Files selected for processing (10)
  • packages/durably-react/src/client/use-runs.ts
  • packages/durably-react/src/hooks/use-runs.ts
  • packages/durably-react/tests/browser/use-runs.test.tsx
  • packages/durably-react/tests/client/use-runs.test.tsx
  • packages/durably-react/tests/types.test.ts
  • packages/durably/src/server.ts
  • packages/durably/src/storage.ts
  • packages/durably/tests/node/types.test.ts
  • packages/durably/tests/shared/run-api.shared.ts
  • packages/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>
@coji coji merged commit 45a78af into main Mar 26, 2026
7 of 8 checks passed
@coji coji deleted the feat/use-runs-status-array branch March 26, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: useRuns の status フィルタで配列を受け付ける

1 participant