feat: support multiple jobName filter in HTTP handler and React hooks#74
Conversation
- HTTP /runs endpoint: use getAll('jobName') for array support
e.g. /runs?jobName=job-a&jobName=job-b
- SSE /runs/subscribe: matchesFilter supports multiple jobName params
- React useRuns (client mode): jobName accepts string | string[],
appends multiple params for array values
- React useRuns (browser mode): jobName type updated to string | string[]
Closes #70
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Extract appendJobNameToParams helper to deduplicate URL param logic - Stabilize jobName array reference with useMemo to prevent infinite re-renders and SSE reconnections - Update RunsRequest.jobName type to string | string[] - Simplify server runs() normalization (storage handles arrays) - Update docs: browser.md, client.md, http-handler.md jobName type Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
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. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR extends jobName filtering from a single string to string | string[] across client hooks, server handlers, and docs; adds stabilization and multi-value URL param handling in the client; and updates server parsing and SSE filtering to accept multiple jobName query parameters. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Server
participant DB
participant SSE
Client->>Server: GET /runs?jobName=A&jobName=B
Server->>DB: query runs WHERE jobName IN [A,B]
DB-->>Server: return matching runs
Server-->>Client: 200 OK with runs
Client->>Server: GET /runs/subscribe?jobName=A&jobName=B (SSE)
Server->>SSE: subscribe to run events
SSE->>Server: event(run with jobName)
Server->>Server: if jobName in [A,B] -> forward
Server-->>Client: SSE event (filtered)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 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
🧹 Nitpick comments (1)
packages/durably/tests/shared/server.shared.ts (1)
339-374: Add a companion multi-jobNametest forrunsSubscribeSSE filtering.This new test covers
/runswell, but multi-value behavior was also added to/runs/subscribe. A matching SSE test (?jobName=a&jobName=b) would close the regression gap.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/durably/tests/shared/server.shared.ts` around lines 339 - 374, Add a companion test that mirrors the existing multi-jobName `/runs` test but targets the SSE subscribe endpoint: call handler.runsSubscribe with a Request to '/api/durably/runs/subscribe?jobName=multi-filter-1&jobName=multi-filter-3', register the same three jobs (multi-filter-1/2/3) and trigger them, then read the SSE stream returned by runsSubscribe and assert only events for jobName multi-filter-1 and multi-filter-3 are received (use the same job registration symbols and event assertions as the existing test to validate filtering).
🤖 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/hooks/use-runs.ts`:
- Line 13: The hook useRuns accepts jobName?: string | string[] but the refresh
function and effect depend on the raw jobName, causing render/fetch loops when
callers pass inline array literals; fix by normalizing/stabilizing jobName
inside useRuns (e.g., create a stableJobName string via useMemo or
joining/JSON.stringify the array when Array.isArray(jobName)) and then update
references so refresh, any useEffect deps, and any cache key use stableJobName
instead of the raw jobName; locate the normalization near the top of useRuns and
replace dependencies in the refresh function and the effect that currently
reference jobName (the refresh function and the effect around lines where
refresh is declared/used) to use stableJobName.
---
Nitpick comments:
In `@packages/durably/tests/shared/server.shared.ts`:
- Around line 339-374: Add a companion test that mirrors the existing
multi-jobName `/runs` test but targets the SSE subscribe endpoint: call
handler.runsSubscribe with a Request to
'/api/durably/runs/subscribe?jobName=multi-filter-1&jobName=multi-filter-3',
register the same three jobs (multi-filter-1/2/3) and trigger them, then read
the SSE stream returned by runsSubscribe and assert only events for jobName
multi-filter-1 and multi-filter-3 are received (use the same job registration
symbols and event assertions as the existing test to validate filtering).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: be9a6109-a89f-4450-af5d-ff2a56500b5d
📒 Files selected for processing (7)
packages/durably-react/src/client/use-runs.tspackages/durably-react/src/hooks/use-runs.tspackages/durably/src/server.tspackages/durably/tests/shared/server.shared.tswebsite/api/durably-react/browser.mdwebsite/api/durably-react/client.mdwebsite/api/http-handler.md
Replace '\0' join/split with JSON.stringify/parse pattern to match stableLabels and avoid edge cases with special chars. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add stableJobName useMemo in browser-mode useRuns to prevent re-fetch loops when callers pass inline array literals - Add runsSubscribe test for multi-jobName SSE filtering Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
server.ts) to support multiplejobNamequery params viagetAll('jobName')for both/runsand/runs/subscribeendpointsuseRunshooks (browser + client mode) to acceptjobName: string | string[]jobNamearray reference withuseMemoto prevent infinite re-rendersappendJobNameToParamshelper to deduplicate URL param serializationCloses #70
Test plan
server.shared.tspnpm validate)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Tests