Skip to content

Don't show queue time in the run timeline by default #1909

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

Merged
merged 7 commits into from
Apr 10, 2025
Merged

Conversation

matt-aitken
Copy link
Member

@matt-aitken matt-aitken commented Apr 10, 2025

If you have concurrency limits set you can end up with queue times greater than a few seconds if you add many items to your queue.

This makes the run timeline really annoying because the queue time dominates the horizontal space, making it hard to tell what happened when your code started executing.

This PR makes it so this queue time is hidden by default, and can be turned back on using a toggle (or pressing "Q" on the keyboard).

Fixes

  • The v4 retry attempt spans getting placed in the wrong order in the tree.
  • The duration numbers expanded/squished while the timeline was animating, this is now fixed.

Copy link

changeset-bot bot commented Apr 10, 2025

⚠️ No Changeset found

Latest commit: f309c6f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Apr 10, 2025

Walkthrough

This pull request updates the run lifecycle data across several components. In the presenter, a new startedAt property and a computed queuedDuration are introduced to provide enhanced timing details in the run data. The route components are updated to propagate and apply queuedDuration in timeline calculations and UI elements. Additionally, the run engine event handler now records a new startTime (in nanoseconds) for retry events, replacing the previous spanIdSeed.

Changes

File(s) Change Summary
apps/webapp/app/presenters/v3/RunPresenter.server.ts Added startedAt to the run selection and return type; computed and returned queuedDuration in the call method.
apps/webapp/app/routes/_app.orgs.$organizationSlug...$runParam/route.tsx Introduced queuedDuration in the trace object; added queueAdjustedNs function; updated TimelineView, TasksTreeView, and CurrentTimeIndicator to incorporate queued duration and included a UI toggle for queue time visibility.
apps/webapp/app/v3/runEngineHandlers.server.ts Updated the runRetryScheduled event handler by removing spanIdSeed and adding a new startTime property (in nanoseconds) when recording events.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant RunPresenter
    participant Database
    Client->>RunPresenter: call()
    RunPresenter->>Database: Query run (including `startedAt`)
    Database-->>RunPresenter: Return run data
    RunPresenter->>Client: Return runData (with `startedAt` & `queuedDuration`)
Loading
sequenceDiagram
    participant TraceView 
    participant TimelineView
    participant TasksTreeView
    participant CurrentTimeIndicator
    TraceView->>TimelineView: Pass `trace` (includes `queuedDuration`)
    TimelineView->>TimelineView: Compute duration using `queueAdjustedNs(totalDuration, queuedDuration)`
    TimelineView->>CurrentTimeIndicator: Update current time display with `queuedDuration`
    TimelineView->>TasksTreeView: Pass down `queuedDuration` and `showQueueTime` flag
Loading
sequenceDiagram
    participant Handler as runEngineHandlers
    participant EventRepo
    Handler->>EventRepo: recordEvent({ startTime, ... })
Loading

Possibly related PRs

Suggested reviewers

  • nicktrn

Poem

Oh, hopping through the code I go,
With startedAt now in tow,
Duration queued with careful art,
Displayed in timelines, set apart,
A rabbit’s cheer—onward we grow! 🐇✨

✨ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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
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: 0

🧹 Nitpick comments (1)
apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx (1)

516-516: Variable naming could be more descriptive

The variable queuedTime might be confusing since it represents whether to use or ignore the queue duration rather than the actual queue time value.

- const queuedTime = showQueueTime ? undefined : queuedDuration;
+ const effectiveQueuedDuration = showQueueTime ? undefined : queuedDuration;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 61232ab and f309c6f.

📒 Files selected for processing (3)
  • apps/webapp/app/presenters/v3/RunPresenter.server.ts (3 hunks)
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx (21 hunks)
  • apps/webapp/app/v3/runEngineHandlers.server.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx (4)
apps/webapp/app/components/primitives/Switch.tsx (1)
  • Switch (44-95)
packages/core/src/v3/index.ts (3)
  • millisecondsToNanoseconds (35-35)
  • nanosecondsToMilliseconds (36-36)
  • formatDurationMilliseconds (33-33)
apps/webapp/app/v3/taskEventStore.server.ts (1)
  • TraceEvent (7-24)
apps/webapp/app/components/runs/v3/SpanTitle.tsx (1)
  • eventBackgroundClassName (120-148)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: units / 🧪 Unit Tests
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (10)
apps/webapp/app/v3/runEngineHandlers.server.ts (1)

336-336: Replace spanIdSeed with startTime for retry spans

The change replaces the previous spanIdSeed property with a precise startTime in nanoseconds. This timestamp will ensure that retry attempt spans are properly ordered in the timeline tree, addressing the issue mentioned in the PR objectives.

apps/webapp/app/presenters/v3/RunPresenter.server.ts (3)

53-53: Include startedAt in the run data selection

Adding the startedAt property to the database selection is necessary to support the new queue duration functionality.


108-108: Expose startedAt in the returned run data

This change makes the startedAt timestamp available to the UI components.


206-209: Add queue duration calculation to trace data

This change calculates the time a task spent in the queue before execution started, converting from milliseconds to nanoseconds for consistent time precision. This is essential for implementing the "hide queue time" feature in the timeline visualization.

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx (6)

509-509: Default to hiding queue time

Setting showQueueTime to false by default implements the main objective of the PR - hiding queue times in the run timeline by default to improve readability for users.


565-571: Add UI toggle for queue time with keyboard shortcut

This switch implementation with the "Q" keyboard shortcut gives users control to toggle queue time visibility as needed, which matches the PR objective.


1075-1081: Well-implemented queue time adjustment utility function

The queueAdjustedNs utility function cleanly handles the adjustment of timeline points and spans based on whether queue time should be displayed. This centralized approach ensures consistency across all time calculations in the timeline.


1243-1246: Add gradient effect to indicate hidden queue time

When queue time is hidden, this visual indicator (gradient from dark to transparent) helps users understand that some time has been omitted at the beginning of the span, providing good UI feedback.


1299-1303: Update time indicator to account for queue time

The current time indicator now correctly adds the queue duration when displaying the absolute timestamp. This ensures the displayed timestamp is accurate regardless of whether queue time is visible.


1368-1368: Document keyboard shortcut for queue time toggle

This change adds the "Q" shortcut to the keyboard shortcuts guide, making the feature discoverable for users.

@nicktrn nicktrn merged commit 030c8ae into main Apr 10, 2025
11 of 12 checks passed
@nicktrn nicktrn deleted the run-timeline-queued branch April 10, 2025 15:37
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.

2 participants