Skip to content

feat: support multiple jobName filter in HTTP handler and React hooks#74

Merged
coji merged 4 commits into
mainfrom
feat/http-handler-job-names-filter
Mar 5, 2026
Merged

feat: support multiple jobName filter in HTTP handler and React hooks#74
coji merged 4 commits into
mainfrom
feat/http-handler-job-names-filter

Conversation

@coji
Copy link
Copy Markdown
Owner

@coji coji commented Mar 5, 2026

Summary

  • Update HTTP handler (server.ts) to support multiple jobName query params via getAll('jobName') for both /runs and /runs/subscribe endpoints
  • Update React useRuns hooks (browser + client mode) to accept jobName: string | string[]
  • Stabilize jobName array reference with useMemo to prevent infinite re-renders
  • Extract appendJobNameToParams helper to deduplicate URL param serialization
  • Update docs: browser.md, client.md, http-handler.md

Closes #70

Test plan

  • Added test for multi-jobName HTTP filter in server.shared.ts
  • All 141 tests pass (pnpm validate)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Filter runs by one or multiple job names (submit multiple jobName values in a single query).
    • Realtime updates: optional SSE-based realtime updates for runs listing.
  • Documentation

    • Updated client and API docs to show jobName accepts string or string[] and examples for multi-name filtering.
    • Documented the new realtime option for runs.
  • Tests

    • Added tests covering multi-job name filtering.

coji and others added 2 commits March 6, 2026 07:39
- 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>
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 5, 2026

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

Project Deployment Actions Updated (UTC)
durably-demo Ready Ready Preview Mar 5, 2026 11:09pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 5, 2026

Warning

Rate limit exceeded

@coji has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 24 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.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 219e16df-7980-47c4-a47e-f98d7b5c3d3a

📥 Commits

Reviewing files that changed from the base of the PR and between 4034912 and 7972046.

📒 Files selected for processing (2)
  • packages/durably-react/src/hooks/use-runs.ts
  • packages/durably/tests/shared/server.shared.ts
📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
React client implementation
packages/durably-react/src/client/use-runs.ts
Accepts `jobName: string
React hook types
packages/durably-react/src/hooks/use-runs.ts
UseRunsOptions.jobName type changed from string → `string
Server handlers
packages/durably/src/server.ts
RunsRequest.jobName type changed to `string
Tests
packages/durably/tests/shared/server.shared.ts
Added test "filters by multiple jobName params" validating GET /api/durably/runs with repeated jobName query params returns only matching runs.
Documentation
website/api/durably-react/browser.md, website/api/durably-react/client.md, website/api/http-handler.md
Docs updated to reflect `jobName: string

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)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 I nudged params from one to many,

jobName lists now hop like a penny;
SSE sings once for each matched race,
Stable keys keep the renders in place,
Hooray — fewer streams, more carrot-y pace! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% 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 title clearly summarizes the main change: adding support for multiple jobName filters in both HTTP handlers and React hooks.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from issue #70: multiple jobName query params in HTTP endpoints, jobName array support in React hooks, stabilization logic, helper extraction, and comprehensive documentation and test coverage.
Out of Scope Changes check ✅ Passed All changes are directly aligned with the objectives to support multiple jobName filters. Documentation updates, test additions, and code refactoring are all within scope and necessary for the feature.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/http-handler-job-names-filter

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

🧹 Nitpick comments (1)
packages/durably/tests/shared/server.shared.ts (1)

339-374: Add a companion multi-jobName test for runsSubscribe SSE filtering.

This new test covers /runs well, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 07ceffe and b2d9b13.

📒 Files selected for processing (7)
  • packages/durably-react/src/client/use-runs.ts
  • packages/durably-react/src/hooks/use-runs.ts
  • packages/durably/src/server.ts
  • packages/durably/tests/shared/server.shared.ts
  • website/api/durably-react/browser.md
  • website/api/durably-react/client.md
  • website/api/http-handler.md

Comment thread packages/durably-react/src/hooks/use-runs.ts
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>
@coji coji merged commit bd30667 into main Mar 5, 2026
1 check passed
@coji coji deleted the feat/http-handler-job-names-filter branch March 5, 2026 23:10
@coji coji mentioned this pull request Mar 6, 2026
5 tasks
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: Support jobNames[] filter in HTTP handler /runs endpoint

1 participant