Skip to content

Warm start UI #1882

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 10 commits into from
Apr 4, 2025
Merged

Warm start UI #1882

merged 10 commits into from
Apr 4, 2025

Conversation

matt-aitken
Copy link
Member

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

We show whether it's a warm start or not on the Attempt, with a useful tooltip.

CleanShot 2025-04-04 at 13 59 47
CleanShot 2025-04-04 at 13 59 54

Summary by CodeRabbit

  • New Features

    • Introduced a new icon for trace tasks, refreshing the task view.
    • Rolled out revamped warm and cold start indicators with interactive tooltips, enhancing clarity in status displays.
    • Extended span detail views with support for attempt-type displays, providing detailed status insights.
    • Added new components for TraceIcon, WarmStartIcon, and ColdStartIcon for improved visual representation.
    • Enhanced the NodeStatusIcon logic to dynamically display warm and cold start indicators.
  • Refactor

    • Improved tooltip layering to ensure consistent visibility and smoother interactions.

Copy link
Contributor

coderabbitai bot commented Apr 4, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces several new React components and adjusts existing UI elements. A new TraceIcon has been added along with modifications to the WaitpointTokenIcon’s SVG path. Additional files, including WarmStartIcon.tsx and WarmStarts.tsx, provide components for handling warm and cold start displays. The tooltip component now uses a portal for its content. Updates in the RunIcon, SpanPresenter, and span route files add support for rendering and processing warm start data and "attempt" entities while exporting and refining a helper function in the event repository.

Changes

File(s) Change Summary
apps/webapp/app/assets/icons/TraceIcon.tsx,
apps/webapp/app/assets/icons/WaitpointTokenIcon.tsx,
apps/webapp/app/assets/icons/WarmStartIcon.tsx
Introduced a new TraceIcon component, updated the <path> data in WaitpointTokenIcon, and added WarmStartIcon with an accompanying ColdStartIcon for conditional SVG rendering.
apps/webapp/app/components/WarmStarts.tsx Added new components (WarmStartCombo, WarmStartIconWithTooltip) and a tooltip content function to display detailed warm/cold start information.
apps/webapp/app/components/primitives/Tooltip.tsx Modified the component structure by wrapping TooltipPrimitive.Content with a portal to adjust the rendering context.
apps/webapp/app/components/runs/v3/RunIcon.tsx Updated the switch-case logic to import and render TraceIcon for the “trace” task type.
apps/webapp/app/presenters/v3/SpanPresenter.server.ts Enhanced the #getSpan method by adding a new "attempt" case that uses rehydrateAttribute and a helper isWarmStart to process warm start attributes.
apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx Revised import statements and updated the NodeStatusIcon logic to render WarmStartIconWithTooltip based on the node’s style variant (“warm” or “cold”).
apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route.tsx Inserted a new "attempt" case into SpanEntity to render detailed span views with status, timeline, and a conditional warm start indicator, using assertNever for type safety.
apps/webapp/app/v3/eventRepository.server.ts Made rehydrateAttribute public and refined error handling by checking explicitly for undefined.

Possibly related PRs

  • Adds a python logo icon to the RunIcon.tsx component #1834: The changes in the main PR, which introduce the TraceIcon component, are related to the modifications in the retrieved PR that also involve updates to the RunIcon component, as both PRs alter the same RunIcon file to include new icon components.

Suggested reviewers

  • ericallam

Poem

Hopping through lines of code with glee,
I found fresh icons and tweaks, oh me!
Trace and WarmStart gleam with grace,
Tooltips and logic keep up the pace.
A rabbit’s cheer in every line—code’s a wonderland divine! 🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 066e166 and 71efd15.

📒 Files selected for processing (1)
  • apps/webapp/app/presenters/v3/SpanPresenter.server.ts (3 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 (3)
apps/webapp/app/components/primitives/Tooltip.tsx (1)

40-51: Improved tooltip rendering with Portal.

Wrapping TooltipPrimitive.Content in TooltipPrimitive.Portal is an excellent improvement. This ensures that tooltips will:

  • Render at the root of the DOM tree instead of within their parent component
  • Avoid z-index conflicts and containment issues with parent elements
  • Display correctly even when parent elements have overflow: hidden

This follows React best practices for tooltip implementations, particularly when using Radix UI primitives.

Consider adding a comment explaining the purpose of using Portal for future maintainers, especially if this pattern isn't consistent across the codebase:

  <TooltipPrimitive.Portal>
+   {/* Portal ensures tooltip content renders at the root level to avoid z-index and overflow issues */}
    <TooltipPrimitive.Content
      ...
apps/webapp/app/components/WarmStarts.tsx (1)

24-38: Check z-index value for tooltip.

While the component correctly implements the tooltip functionality, the hardcoded z-index value of 9999 might be unnecessarily high and could potentially conflict with other UI elements.

Consider using a more moderate z-index value or, better yet, use a z-index variable from your design system to ensure consistency across the application:

-      className="relative z-[9999]"
+      className="relative z-[50]"
apps/webapp/app/presenters/v3/SpanPresenter.server.ts (1)

513-520: Unused helper function.

The isWarmStart function is defined but not used anywhere in the codebase. While it's a well-implemented utility function, it should either be used or removed to avoid dead code.

If this function is intended for future use, consider adding a TODO comment explaining its purpose. If not needed, you should remove it to keep the codebase clean:

-function isWarmStart(
-  attributes: string | number | boolean | Record<string, unknown> | null | undefined
-): boolean | undefined {
-  if (!attributes || typeof attributes !== "object") return undefined;
-  const attribute = attributes[SemanticInternalAttributes.WARM_START];
-  if (typeof attribute !== "boolean") return undefined;
-  return attribute;
-}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7644d92 and 036a414.

📒 Files selected for processing (10)
  • apps/webapp/app/assets/icons/TraceIcon.tsx (1 hunks)
  • apps/webapp/app/assets/icons/WaitpointTokenIcon.tsx (1 hunks)
  • apps/webapp/app/assets/icons/WarmStartIcon.tsx (1 hunks)
  • apps/webapp/app/components/WarmStarts.tsx (1 hunks)
  • apps/webapp/app/components/primitives/Tooltip.tsx (1 hunks)
  • apps/webapp/app/components/runs/v3/RunIcon.tsx (2 hunks)
  • apps/webapp/app/presenters/v3/SpanPresenter.server.ts (3 hunks)
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx (2 hunks)
  • apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route.tsx (5 hunks)
  • apps/webapp/app/v3/eventRepository.server.ts (2 hunks)
🧰 Additional context used
🧬 Code Definitions (4)
apps/webapp/app/components/runs/v3/RunIcon.tsx (1)
apps/webapp/app/assets/icons/TraceIcon.tsx (1)
  • TraceIcon (1-9)
apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route.tsx (2)
apps/webapp/app/components/run/RunTimeline.tsx (1)
  • SpanTimeline (582-677)
apps/webapp/app/utils/timelineSpanEvents.ts (1)
  • createTimelineSpanEventsFromSpanEvents (26-131)
apps/webapp/app/v3/eventRepository.server.ts (2)
apps/webapp/app/v3/marqs/fairDequeuingStrategy.server.ts (1)
  • T (296-313)
apps/webapp/app/v3/marqs/index.server.ts (1)
  • T (760-794)
apps/webapp/app/presenters/v3/SpanPresenter.server.ts (4)
packages/core/src/v3/taskContext/index.ts (2)
  • isWarmStart (34-36)
  • attributes (38-48)
apps/webapp/app/v3/eventRepository.server.ts (1)
  • rehydrateAttribute (1641-1664)
packages/core/src/v3/index.ts (1)
  • SemanticInternalAttributes (21-21)
packages/core/src/v3/semanticInternalAttributes.ts (1)
  • SemanticInternalAttributes (1-63)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: units / 🧪 Unit Tests
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (14)
apps/webapp/app/assets/icons/TraceIcon.tsx (1)

1-9: Clean implementation of the TraceIcon component.

The implementation follows React best practices with:

  • A properly exported function component
  • Typed props with optional className
  • Clean SVG structure with proper viewBox and namespace
  • Use of "currentColor" for fill to inherit colors from parent styling
apps/webapp/app/assets/icons/WaitpointTokenIcon.tsx (1)

7-7: SVG path updated successfully.

The SVG path data has been updated to change the visual appearance of the WaitpointTokenIcon. The new path definition maintains proper SVG formatting with appropriate rules and attributes.

apps/webapp/app/components/runs/v3/RunIcon.tsx (2)

21-21: Proper import of the new TraceIcon component.

The import statement is correctly formatted and uses the appropriate relative path.


69-69: Icon component update for "trace" case.

The code properly replaces Squares2X2Icon with the new TraceIcon component while maintaining the same styling approach.

apps/webapp/app/v3/eventRepository.server.ts (2)

1641-1644: Good change making the rehydrateAttribute function exportable.

This change appropriately exposes the rehydrateAttribute function so it can be used elsewhere in the codebase, specifically for extracting warm start information from event metadata.


1659-1661: Improved condition check for falsy values.

The condition has been refined from a general falsy check (!value) to a specific check for undefined. This is a good change as it allows other falsy values like 0, false, or empty strings to be valid return values rather than being treated the same as undefined.

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

1041-1047: Successfully implemented warm/cold start indicators in the UI.

The NodeStatusIcon component now properly handles warm and cold start variants, displaying the appropriate WarmStartIconWithTooltip component based on the variant. This implementation matches the PR objective of enhancing the UI to indicate whether an attempt is a warm start.

apps/webapp/app/assets/icons/WarmStartIcon.tsx (2)

4-13: Well-implemented Cold Start icon component.

The SVG implementation for the cold start icon uses clear, maintainable code with currentColor allowing for flexible colorization through CSS classes. The snowflake design choice clearly represents the cold start concept.


15-26: Clean conditional rendering based on warm start state.

The component correctly implements conditional rendering based on the isWarmStart prop, using appropriate icons and colors (orange for warm, blue for cold) to provide clear visual distinction. The use of the cn utility ensures proper class name handling.

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route.tsx (2)

934-967: Good implementation of attempt entity type handling.

The new case for handling spans of type "attempt" follows the existing pattern in the codebase. The conditional rendering of WarmStartCombo based on the presence of isWarmStart property provides users with valuable information about execution environment reuse.


990-991: Improved type safety with assertNever.

Using assertNever in the default case ensures that all entity types are properly handled, providing better compile-time type checking. This is a best practice for exhaustive switch statements in TypeScript.

apps/webapp/app/components/WarmStarts.tsx (2)

6-22: Clean implementation of WarmStartCombo component.

The component effectively combines the icon, text label, and optional tooltip to create a reusable UI element. The default parameter for showTooltip and consistent styling with dimmed text maintain UI consistency.


40-59: Clear and informative tooltip content.

The tooltip content provides excellent user education about the difference between warm and cold starts, with clear visual indicators and concise explanations of the performance implications.

apps/webapp/app/presenters/v3/SpanPresenter.server.ts (1)

491-506: Proper handling of warm start data in attempt entities.

The implementation correctly extracts the warm start information from span metadata using the rehydrateAttribute function, making this data available to the UI components.

Copy link

changeset-bot bot commented Apr 4, 2025

⚠️ No Changeset found

Latest commit: 71efd15

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.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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 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 (2)
references/hello-world/src/trigger/example.ts (1)

19-27: Consider distinguishing between trace messages

Both trace calls use the same message "my trace" and similar callback functions. Consider using more descriptive and unique messages to differentiate between these trace points for better debugging.

logger.trace(
-  "my trace",
+  "custom trace with icon",
  async (span) => {
    logger.debug("some log", { span });
  },
  {
    icon: "tabler-ad-circle",
  }
);
packages/core/src/v3/logger/taskLogger.ts (1)

102-102: Default icon now consistently applied to traces

This change ensures all traces have an associated icon by defaulting to "trace" when no specific icon is provided. This is consistent with the PR's objective to enhance UI indicators for warm starts.

Interestingly, the startSpan method at line 114 still uses the conditional spread approach without a default value. Consider using a similar approach there for consistency.

 startSpan(name: string, options?: TraceOptions): Span {
   const spanOptions = {
     ...options,
     attributes: {
       ...options?.attributes,
-      ...(options?.icon ? { [SemanticInternalAttributes.STYLE_ICON]: options.icon } : {}),
+      [SemanticInternalAttributes.STYLE_ICON]: options?.icon ?? "span",
     },
   };

   return this._config.tracer.startSpan(name, spanOptions);
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 036a414 and 066e166.

📒 Files selected for processing (2)
  • packages/core/src/v3/logger/taskLogger.ts (1 hunks)
  • references/hello-world/src/trigger/example.ts (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
packages/core/src/v3/logger/taskLogger.ts (1)
packages/core/src/v3/index.ts (1)
  • SemanticInternalAttributes (21-21)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: units / 🧪 Unit Tests
  • GitHub Check: typecheck / typecheck
🔇 Additional comments (2)
references/hello-world/src/trigger/example.ts (2)

15-17: Good addition of trace logging

Adding trace logging improves the observability of the task execution, which is helpful for debugging and monitoring.


24-26: Good usage of icon for visual representation

Using the icon property is aligned with the PR objective of enhancing the UI with warm start indicators.

@matt-aitken matt-aitken merged commit 36159be into main Apr 4, 2025
10 of 12 checks passed
@matt-aitken matt-aitken deleted the warm-start-ui branch April 4, 2025 13:20
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