Skip to content

Upgrade staging#219

Merged
elliotBraem merged 4 commits intomainfrom
staging
Jul 15, 2025
Merged

Upgrade staging#219
elliotBraem merged 4 commits intomainfrom
staging

Conversation

@elliotBraem
Copy link
Collaborator

@elliotBraem elliotBraem commented Jul 15, 2025

Summary by CodeRabbit

  • New Features

    • Processing jobs and steps now automatically refresh every 5 seconds while in progress, ensuring up-to-date status.
    • Success and error notifications are displayed for processing actions such as retrying or reprocessing jobs and steps.
    • Job IDs in processing history are now truncated for readability, with full IDs shown on hover via tooltip.
    • Processing steps support branching, enabling parallel execution of different branches for more complex workflows.
  • Improvements

    • The "Reprocess" button has updated icons and tooltips for clearer user guidance.
    • The processing tab UI is streamlined with modular submission rows and enhanced status badges.
    • The "View Details" button styling is now consistent across the interface.
  • Bug Fixes

    • Improved handling of retries and tweaks for processing steps within branches, ensuring correct partial plan execution.

@vercel
Copy link

vercel bot commented Jul 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
curatedotfun-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 15, 2025 2:40pm

@coderabbitai
Copy link

coderabbitai bot commented Jul 15, 2025

Walkthrough

The changes introduce explicit support for branching in processing plans, updating both backend and frontend logic. The backend now annotates processing steps with branch IDs, executes global and branch-specific steps, and improves retry/tweak logic for branches. The frontend modularizes submission rows, enhances job status display, adds polling for job/step updates, and improves user feedback with toasts and tooltips.

Changes

File(s) Change Summary
apps/app/src/components/processing/ProcessingActions.tsx Removed tweak-and-reprocess logic and button; simplified reprocess button; updated tooltips and icons.
apps/app/src/components/processing/ProcessingHistory.tsx Added tooltip for truncated job IDs; set "View Details" button variant to "outline".
apps/app/src/lib/api/processing.ts Added polling to job/step hooks; mutations now invalidate queries and show success/error toasts.
apps/app/src/routes/_layout/feed/$feedId/_tabs/processing.tsx Refactored submission row rendering into SubmissionRow component; improved job status badge display.
packages/core-services/src/services/processing.service.ts Refactored processing to support branching; updated retry/tweak logic for branches; assigned branch IDs in plans.
packages/shared-db/src/schema/processing.ts Added optional branchId field to ProcessingPlanStepSchema.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Frontend
    participant Backend

    User->>Frontend: Clicks "Reprocess" or "Retry" button
    Frontend->>Backend: Calls reprocess/retry API
    Backend->>Backend: Processes job with branching logic
    Backend-->>Frontend: Returns updated job/step data
    Frontend->>Frontend: Shows toast (success or error)
    Frontend->>Backend: Polls for job/step updates if processing
    Backend-->>Frontend: Returns fresh data
    Frontend->>User: Updates UI with latest status
Loading

Possibly related PRs

  • Adds branching #216: The main PR and the retrieved PR both modify the same methods (process, retryStep, tweakAndReprocessStep, and _buildPlan) in ProcessingService to introduce and support branching in processing plans, making their changes directly related at the code level.

Poem

In the garden where data flows and bends,
Branches now blossom—each with their own ends.
Polling keeps watch as jobs process anew,
Tooltips and toasts bring clarity through.
With every new branch, the system grows bright—
Rabbits rejoice, for the plan works just right!
🐇🌿✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 2

🔭 Outside diff range comments (1)
apps/app/src/lib/api/processing.ts (1)

19-44: Performance issue: Duplicate API calls for polling detection

The implementation creates two identical queries - one to check processing state (lines 19-29) and another for the actual data (lines 33-44). This doubles the API calls and is inefficient.

Consider refactoring to use a single query with a custom hook or state management:

export function useProcessingJobs(
  submissionId: string | null,
  feedId: string | null,
  options?: { enabled?: boolean },
) {
-  const query = useApiQuery<ProcessingJobsResponse, Error, ProcessingJob[]>(
-    ["processingJobs", submissionId, feedId],
-    `/processing/jobs/${submissionId}?feedId=${feedId}`,
-    {
-      enabled:
-        options?.enabled !== undefined
-          ? options.enabled && !!submissionId && !!feedId
-          : !!submissionId && !!feedId,
-      select: (data) => data.data.jobs,
-    },
-  );
-
-  const isProcessing = query.data?.some((job) => job.status === "processing");
-
-  return useApiQuery<ProcessingJobsResponse, Error, ProcessingJob[]>(
+  const query = useApiQuery<ProcessingJobsResponse, Error, ProcessingJob[]>(
     ["processingJobs", submissionId, feedId],
     `/processing/jobs/${submissionId}?feedId=${feedId}`,
     {
       enabled:
         options?.enabled !== undefined
           ? options.enabled && !!submissionId && !!feedId
           : !!submissionId && !!feedId,
       select: (data) => data.data.jobs,
-      refetchInterval: isProcessing ? 5000 : false,
+      refetchInterval: (data) => 
+        data?.data.jobs?.some((job) => job.status === "processing") ? 5000 : false,
     },
   );
+
+  return query;
 }
🧹 Nitpick comments (1)
apps/app/src/routes/_layout/feed/$feedId/_tabs/processing.tsx (1)

36-40: Consider optimizing the latest job calculation.

The current implementation sorts the entire array to find the latest job. For better performance with large job lists, consider using reduce:

-  const latestJob = jobs?.sort((a, b) => {
-    const dateA = a.startedAt ? new Date(a.startedAt).getTime() : 0;
-    const dateB = b.startedAt ? new Date(b.startedAt).getTime() : 0;
-    return dateB - dateA;
-  })[0];
+  const latestJob = jobs?.reduce((latest, job) => {
+    const jobTime = job.startedAt ? new Date(job.startedAt).getTime() : 0;
+    const latestTime = latest?.startedAt ? new Date(latest.startedAt).getTime() : 0;
+    return jobTime > latestTime ? job : latest;
+  }, undefined);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6640cd5 and 1d2a65b.

📒 Files selected for processing (6)
  • apps/app/src/components/processing/ProcessingActions.tsx (2 hunks)
  • apps/app/src/components/processing/ProcessingHistory.tsx (3 hunks)
  • apps/app/src/lib/api/processing.ts (12 hunks)
  • apps/app/src/routes/_layout/feed/$feedId/_tabs/processing.tsx (3 hunks)
  • packages/core-services/src/services/processing.service.ts (4 hunks)
  • packages/shared-db/src/schema/processing.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/app/src/lib/api/processing.ts (3)
apps/app/src/hooks/api-client.ts (1)
  • useApiQuery (17-44)
packages/types/src/api/processing.ts (4)
  • ProcessingJobsResponse (152-154)
  • ProcessingJob (90-90)
  • ProcessingStepsResponse (164-166)
  • ProcessingStep (141-141)
apps/app/src/hooks/use-toast.ts (1)
  • toast (211-211)
🔇 Additional comments (13)
packages/shared-db/src/schema/processing.ts (1)

60-62: LGTM! Well-structured schema extension.

The addition of the optional branchId field is clean and properly documented. This provides a solid foundation for the branching logic implemented in the processing service.

apps/app/src/components/processing/ProcessingHistory.tsx (2)

65-79: Good UX improvement with the tooltip.

Truncating job IDs to 8 characters with a tooltip for the full ID is a nice balance between UI cleanliness and information accessibility.


197-197: Consistent button styling.

Setting the variant to "outline" aligns with the UI patterns used elsewhere.

apps/app/src/components/processing/ProcessingActions.tsx (1)

41-65: Consider the implications of removing tweak functionality.

The UI no longer exposes the tweak-and-reprocess functionality, but the backend still implements tweakAndReprocessStep. This creates dead code in the backend if the feature is being deprecated.

If the tweak functionality is being intentionally removed, consider also removing the tweakAndReprocessStep method from the backend processing service to avoid maintaining unused code.

apps/app/src/routes/_layout/feed/$feedId/_tabs/processing.tsx (1)

24-101: Excellent refactoring into a separate component.

The SubmissionRow component improves modularity and makes the code more maintainable. The latest job status display with appropriate badge variants enhances the user experience.

packages/core-services/src/services/processing.service.ts (3)

85-144: Well-implemented branching logic.

The separation of global steps and branch-specific steps with concurrent branch execution is a solid architectural improvement. The use of branchId to group steps is clean and maintainable.


456-461: Good defensive programming with bounds checking.

The bounds checking for step indices prevents potential out-of-bounds errors. This is consistent between both retryStep and tweakAndReprocessStep methods.


117-143: Verify error handling in concurrent branch processing

Currently, you kick off all branch executions in parallel and await them with Promise.all. If one branch throws, Promise.all rejects but doesn’t cancel the other running branches, which may lead to partial side-effects (e.g. some transformations/distributions applied, others not).

Please confirm whether this behavior is intentional. If not, consider one of the following:

• Wrap each branch promise in its own try/catch so you can handle or aggregate errors per branch.
• Use Promise.allSettled if you need to collect both successes and failures without short-circuiting.
• Add or update tests to cover failure scenarios in one branch while others are still executing.

Locations to review:

  • packages/core-services/src/services/processing.service.ts (lines 117–143)
apps/app/src/lib/api/processing.ts (5)

8-9: LGTM: Proper imports for enhanced functionality

The new imports for useQueryClient and toast are correctly added to support query invalidation and user notifications in the mutation hooks.


82-82: Well-implemented mutation with proper error handling

The mutation hook correctly:

  • Uses useQueryClient for cache invalidation
  • Provides user feedback with toast notifications
  • Handles both success and error cases
  • Invalidates the appropriate queries to refresh the UI

Also applies to: 94-112


121-121: Proper query invalidation for step retry

The implementation correctly invalidates both processing steps and jobs queries since a step retry affects both the individual step status and the overall job status.

Also applies to: 133-153


163-163: LGTM: Clean reprocess implementation

The reprocess mutation is well-implemented with proper error handling and query invalidation.

Also applies to: 175-192


202-202: Comprehensive query invalidation for tweak and reprocess

The mutation correctly invalidates both steps and jobs queries, which is appropriate since tweaking a step affects both the step data and the overall job status.

Also applies to: 214-234

@elliotBraem elliotBraem merged commit bf2fff4 into main Jul 15, 2025
8 checks passed
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.

1 participant