-
-
Notifications
You must be signed in to change notification settings - Fork 699
Renamed useBatch to useRealtimeBatch #1447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe changes involve renaming the function Changes
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (1)
packages/react-hooks/src/hooks/useRealtimeBatch.ts (1)
7-20
: Documentation improvements suggested.The JSDoc is well-structured, but could be enhanced with:
@throws
tag to document potential errors- A more comprehensive example showing error handling and actual usage of the runs
/** * hook to subscribe to realtime updates of a batch of task runs. * * @template TTask - The type of the task. * @param {string} batchId - The unique identifier of the batch to subscribe to. * @returns {{ runs: TaskRunShape<TTask>[], error: Error | null }} An object containing the current state of the runs and any error encountered. + * @throws {Error} When the subscription fails or encounters network issues * * @example * * ```ts * import type { myTask } from './path/to/task'; - * const { runs, error } = useRealtimeBatch<typeof myTask>('batch-id-123'); + * function BatchStatus() { + * const { runs, error } = useRealtimeBatch<typeof myTask>('batch-id-123'); + * + * if (error) { + * return <div>Error: {error.message}</div>; + * } + * + * return ( + * <div> + * {runs.map((run) => ( + * <div key={run.id}> + * Task {run.number}: {run.status} + * </div> + * ))} + * </div> + * ); + * } * ``` */
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
.changeset/honest-trains-burn.md
(1 hunks)packages/react-hooks/src/hooks/useRealtimeBatch.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- .changeset/honest-trains-burn.md
* const { runs, error } = useRealtimeBatch<typeof myTask>('batch-id-123'); | ||
* ``` | ||
*/ | ||
export function useRealtimeBatch<TTask extends AnyTask>(batchId: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Breaking change: useBatch
hook is still being used in the codebase
The renamed hook useRealtimeBatch
has breaking changes that need to be addressed:
references/nextjs-realtime/src/app/batches/[id]/ClientBatchRunDetails.tsx
: Still imports and usesuseBatch
from "@trigger.dev/react-hooks"references/v3-catalog/src/trigger/taskHierarchy.ts
: ContainsuseBatch
parameter in multiple task definitions, but this appears to be unrelated to the hook (it's a boolean parameter with different functionality)
🔗 Analysis chain
Function rename improves clarity.
The new name useRealtimeBatch
better describes the real-time nature of the hook's functionality.
Let's verify that all imports of the old name have been updated:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any remaining references to the old function name 'useBatch'
# Expect: No occurrences of the old name, except in test files or comments
echo "Checking for remaining references to 'useBatch'..."
rg --type ts --type tsx 'useBatch' \
--glob '!{**/*.test.*,**/*.spec.*}' \
--glob '!**/dist/**' \
--glob '!**/node_modules/**'
Length of output: 265
Script:
#!/bin/bash
# Let's try a different approach using ripgrep without file type filters
# and manually exclude test files and build directories
echo "Checking for remaining references to 'useBatch'..."
rg 'useBatch' \
--type-not test \
--glob '!{**/*.test.*,**/*.spec.*,**/__tests__/**}' \
--glob '!{**/dist/**,**/build/**,**/node_modules/**}' \
-C 2
Length of output: 286
Script:
#!/bin/bash
# Simplify the search using basic ripgrep command
# and pipe through grep to filter out test files
echo "Checking for remaining references to 'useBatch'..."
rg 'useBatch' -l | grep -v -E '(test|spec|__tests__|dist|build|node_modules)'
# Also search for export statements to verify the old name isn't exported elsewhere
echo -e "\nChecking for exports of 'useBatch'..."
rg 'export.*useBatch' -l | grep -v -E '(test|spec|__tests__|dist|build|node_modules)'
Length of output: 504
Script:
#!/bin/bash
# Let's check the actual content of the files that still reference 'useBatch'
echo "Checking content in taskHierarchy.ts:"
rg 'useBatch' -C 3 references/v3-catalog/src/trigger/taskHierarchy.ts
echo -e "\nChecking content in ClientBatchRunDetails.tsx:"
rg 'useBatch' -C 3 references/nextjs-realtime/src/app/batches/[id]/ClientBatchRunDetails.tsx
Length of output: 3023
@trigger.dev/react-hooks
@trigger.dev/sdk
@trigger.dev/build
trigger.dev
@trigger.dev/core
commit: |
e541ba2
to
f45382a
Compare
Summary by CodeRabbit
New Features
useBatch
touseRealtimeBatch
for clarity on its functionality.useRealtimeBatch
function, including usage examples.Bug Fixes