Skip to content

Adds a "dev connected" banner to the top of the Run and Runs list pages #1855

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 1, 2025

Conversation

samejr
Copy link
Member

@samejr samejr commented Mar 31, 2025

Adds a "Your local dev server is not connected to Trigger.dev" banner message to the top of the Run and Runs list pages

Also moves the functionality to the DevPresence.tsx file and makes the DevConnection component reusable.

CleanShot 2025-03-31 at 14 07 02

Summary by CodeRabbit

  • New Features

    • Introduced new components to visually represent the development server’s connection status, including icons and banners.
    • Added prompts that guide users on reconnecting to the server when disconnected.
  • Refactor

    • Streamlined the connection status display by integrating it directly into the navigation and application pages, enhancing user experience.
    • Removed the old connection management component in favor of a more integrated inline solution.

Copy link

changeset-bot bot commented Mar 31, 2025

⚠️ No Changeset found

Latest commit: 934cd7f

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 bot commented Mar 31, 2025

Walkthrough

This pull request introduces new components and refactors existing ones to improve how the development server's connection status is displayed. New components (ConnectionIcon, DevPresencePanel, and DevDisconnectedBanner) are created in the DevPresence module to handle different connection states. The SideMenu component has been updated to remove the previous DevConnection implementation, replacing it with inline logic for dynamic connection feedback using tooltips. Additionally, route components now conditionally render the DevDisconnectedBanner based on the development environment.

Changes

Files Change Summary
apps/webapp/app/components/DevPresence.tsx Added new functions: useCrossEngineIsConnected (manages connection status), ConnectionIcon (renders icons based on connection state), DevPresencePanel (displays connection status message), and DevDisconnectedBanner (conditionally shows a banner when disconnected).
apps/webapp/app/components/navigation/SideMenu.tsx Removed the old DevConnection component and related imports. Integrated inline connection status logic using TooltipProvider and ConnectionIcon, simplifying connection status handling.
apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx
apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs._index/route.tsx
Updated to include the DevDisconnectedBanner based on the connection status and development environment, utilizing useDevPresence and useCrossEngineIsConnected hooks.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SideMenu
    participant ConnectionIcon
    participant DevDisconnectedBanner
    User->>SideMenu: Interacts with SideMenu
    SideMenu->>ConnectionIcon: Request connection status
    ConnectionIcon-->>SideMenu: Render appropriate icon
    SideMenu->>DevDisconnectedBanner: Check connection status
    DevDisconnectedBanner-->>SideMenu: Display banner if disconnected
Loading
sequenceDiagram
    participant User
    participant PageComponent
    participant useDevPresence
    participant DevDisconnectedBanner
    User->>PageComponent: Loads page
    PageComponent->>useDevPresence: Retrieve connection status
    useDevPresence-->>PageComponent: Return isConnected flag
    PageComponent->>DevDisconnectedBanner: Conditional render check (env = DEVELOPMENT)
    DevDisconnectedBanner-->>PageComponent: Display connection status banner
Loading

Possibly related PRs

  • Side menu and Org dropdown improvements #1801: The changes in the main PR are related to the introduction and usage of the DevDisconnectedBanner component and the useCrossEngineIsConnected hook, indicating a shared focus on managing and displaying connection status.
  • Remove v2 event list #1680: The changes in the main PR are related to modifications to the DevDisconnectedBanner component and the useCrossEngineIsConnected hook, indicating a shared focus on connection status management.
  • "Dev connecting" icon update + text color fix for the purple login buttons #1835: The changes in the main PR are related to the introduction of the ConnectionIcon component, which visually represents connection status, while the retrieved PR modifies the CheckingConnectionIcon, enhancing its visual representation.

Poem

I’m a rabbit tapping keys in glee,
Hoping the connections now dance free.
Icons shimmer, statuses unveiled,
Banners that softly fade and hailed.
In dev realms where code takes flight,
I burrow deep with joy tonight!
🐇✨

✨ 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 (1)
apps/webapp/app/components/DevPresence.tsx (1)

107-158: Centralized connection dialog logic.
Using the Dialog for a visual alert on server connectivity is user-friendly and well-organized. The fallback text is clear (“Checking connection...”). You may want to add a small test case for undefined vs. true vs. false states to ensure the dialog content is correct.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 394f1de and a2b66ab.

📒 Files selected for processing (4)
  • apps/webapp/app/components/DevPresence.tsx (2 hunks)
  • apps/webapp/app/components/navigation/SideMenu.tsx (3 hunks)
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx (2 hunks)
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs._index/route.tsx (2 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx (1)
apps/webapp/app/components/DevPresence.tsx (1)
  • DevPresenceBanner (160-191)
apps/webapp/app/components/DevPresence.tsx (2)
apps/webapp/app/assets/icons/ConnectionIcons.tsx (3)
  • CheckingConnectionIcon (50-73)
  • ConnectedIcon (1-28)
  • DisconnectedIcon (30-48)
apps/webapp/app/utils/pathBuilder.ts (1)
  • docsPath (417-419)
⏰ 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 (13)
apps/webapp/app/components/DevPresence.tsx (4)

1-7: Imports look consistent and well-structured.
No issues with adding AnimatePresence and motion from framer-motion, as well as the icon imports.


12-19: Proper imports for path building and images.
These references are used correctly, and having separate images for connected vs. disconnected states is a clear design.


95-105: Straightforward and readable connection icon logic.
The component handles the undefined vs. boolean states cleanly. Consider logging, or gracefully handling unexpected values if isConnected ever falls out of expected states.


160-190: Banner component integrated with framer-motion.
The fade-in/out transition, specifically for DEVELOPMENT environment, is well-structured. It’s concise and keeps the UI elements separated from logic.

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

11-11: Newly added imports for DevPresence.
This import ensures availability of the dev-connected banner. Everything appears correct.


165-166: Accessing isConnected via useDevPresence.
Good usage of the hook for retrieving the server connection status. No issues spotted.


172-184: Conditional dev banner with fade animation.
This fade effect is straightforward, improving the user experience with minimal overhead. Nicely done.

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

24-24: Expanded framer-motion import.
Allowing usage of AnimatePresence for transitions is consistent with other code sections.


30-30: Importing DevPresence functionality.
Clean separation of dev presence logic in its own module. This keeps route code focused on displaying relevant banners.


198-210: Extended fade animation for the runs detail page.
Matching the existing pattern from other pages, providing a unified user experience. Looks good.

apps/webapp/app/components/navigation/SideMenu.tsx (3)

23-25: New icon imports for runs and waitpoints.
These icons are used consistently with the rest of the menu. No concerns here.


60-63: DevPresence imports in SideMenu.
The approach of having the inline connectivity check is simplified and removes duplication from older code. Great structure.


156-183: Inline DevConnection usage under DEVELOPMENT.
This is a neat way to show or hide connectivity status within the environment selector. The tooltip logic is handled properly, and the messaging is intuitive. Consider a fallback scenario for unexpected states of isConnected, though it should be fine as typed.

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/components/DevPresence.tsx (1)

96-126: Unnecessary dependency in useEffect

The environment.type is included in the dependency array but isn't used inside the effect function.

- }, [environment.type, project.engine, logCount, isConnected]);
+ }, [project.engine, logCount, isConnected]);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a2b66ab and 9c4f9e6.

📒 Files selected for processing (4)
  • apps/webapp/app/components/DevPresence.tsx (2 hunks)
  • apps/webapp/app/components/navigation/SideMenu.tsx (5 hunks)
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx (3 hunks)
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs._index/route.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs._index/route.tsx
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx
🧰 Additional context used
🧬 Code Definitions (1)
apps/webapp/app/components/DevPresence.tsx (2)
apps/webapp/app/assets/icons/ConnectionIcons.tsx (3)
  • CheckingConnectionIcon (50-73)
  • ConnectedIcon (1-28)
  • DisconnectedIcon (30-48)
apps/webapp/app/utils/pathBuilder.ts (1)
  • docsPath (417-419)
⏰ 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: units / 🧪 Unit Tests
  • GitHub Check: typecheck / typecheck
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (7)
apps/webapp/app/components/navigation/SideMenu.tsx (4)

58-59: Good integration of the DevPresence components

The import of the new components from the DevPresence module looks good and aligns with the PR objective of refactoring the connection functionality into a dedicated module.


83-83: Appropriate type extension

Adding the engine property to the SideMenuProject type is necessary to support the new connection status logic that differentiates between V1 and V2 engines.


107-107: Clean hook usage

Good use of the new useDevPresence hook to access the connection state.


156-182: Well-implemented conditional connection status display

This implementation correctly:

  1. Only shows the connection status for development environments with V2 engines
  2. Uses the ConnectionIcon component to visually represent the connection state
  3. Provides helpful tooltips that change based on connection status
  4. Integrates the DevPresencePanel for detailed information
apps/webapp/app/components/DevPresence.tsx (3)

128-137: Well-implemented connection icon component

The ConnectionIcon component properly handles all three possible states (checking, connected, disconnected) and renders the appropriate icon with consistent sizing.


139-181: Comprehensive connection status panel

The DevPresencePanel effectively:

  1. Shows the appropriate header based on connection state
  2. Displays relevant imagery for the connection status
  3. Provides clear instructions when disconnected
  4. Links to documentation for additional help

This is a good user experience enhancement for developers trying to understand connection issues.


183-210: Good implementation of the banner component

The DevDisconnectedBanner effectively implements the PR's main objective of adding a banner when disconnected. The animation provides a smooth user experience, and the conditional rendering ensures it only appears when needed. Good integration with the DevPresencePanel component for providing more detailed information.

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/DevPresence.tsx (3)

96-137: Consider removing unused dependency from useEffect.

The useCrossEngineIsConnected hook correctly implements different connection detection logic based on the project engine type. However, there's an unnecessary dependency in the useEffect.

- }, [environment.type, project.engine, logCount, isConnected, isCompleted]);
+ }, [project.engine, logCount, isConnected, isCompleted]);

The environment.type variable is included in the dependency array but isn't used within the effect body, potentially causing unnecessary effect executions.


125-133: Consider adding debounce to prevent connection status flicker.

The current implementation uses a timeout to determine connection status for V1 engines with low log counts. This approach could lead to UI flicker if the log count hovers around the threshold.

Consider implementing a debounce mechanism to make the connection status more stable:

+ const [debouncedLogCount, setDebouncedLogCount] = useState(logCount);
+ 
+ useEffect(() => {
+   const timer = setTimeout(() => {
+     setDebouncedLogCount(logCount);
+   }, 1000);
+   return () => clearTimeout(timer);
+ }, [logCount]);

  if (project.engine === "V1") {
    if (isCompleted) {
      setCrossEngineIsConnected(true);
      return;
    }

-   if (logCount <= 1) {
+   if (debouncedLogCount <= 1) {
      const timer = setTimeout(() => {
        setCrossEngineIsConnected(false);
      }, 5000);
      return () => clearTimeout(timer);
    } else {
      setCrossEngineIsConnected(true);
    }
  }

150-192: Extract repeated text to constants.

The DevPresencePanel component contains duplicated text strings that could be extracted to constants for better maintainability.

export function DevPresencePanel({ isConnected }: { isConnected: boolean | undefined }) {
+  const getHeaderText = () => {
+    if (isConnected === undefined) return "Checking connection...";
+    return isConnected ? "Your dev server is connected" : "Your dev server is not connected";
+  };
+  
+  const getStatusText = () => {
+    if (isConnected === undefined) return "Checking connection...";
+    return isConnected 
+      ? "Your local dev server is connected to Trigger.dev" 
+      : "Your local dev server is not connected to Trigger.dev";
+  };

  return (
    <DialogContent>
      <DialogHeader>
-        {isConnected === undefined
-          ? "Checking connection..."
-          : isConnected
-          ? "Your dev server is connected"
-          : "Your dev server is not connected"}
+        {getHeaderText()}
      </DialogHeader>
      <div className="mt-2 flex flex-col gap-3 px-2">
        <div className="flex flex-col items-center justify-center gap-6 px-6 py-10">
          <img
            src={isConnected === true ? connectedImage : disconnectedImage}
            alt={isConnected === true ? "Connected" : "Disconnected"}
            width={282}
            height={45}
          />
          <Paragraph variant="small" className={isConnected ? "text-success" : "text-error"}>
-            {isConnected === undefined
-              ? "Checking connection..."
-              : isConnected
-              ? "Your local dev server is connected to Trigger.dev"
-              : "Your local dev server is not connected to Trigger.dev"}
+            {getStatusText()}
          </Paragraph>
        </div>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fea49cb and 934cd7f.

📒 Files selected for processing (2)
  • apps/webapp/app/components/DevPresence.tsx (2 hunks)
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx (3 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
apps/webapp/app/components/DevPresence.tsx (2)
apps/webapp/app/assets/icons/ConnectionIcons.tsx (3)
  • CheckingConnectionIcon (50-73)
  • ConnectedIcon (1-28)
  • DisconnectedIcon (30-48)
apps/webapp/app/utils/pathBuilder.ts (1)
  • docsPath (417-419)
⏰ 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 (7)
apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam/route.tsx (4)

24-24: Import update looks good.

The import has been expanded to include AnimatePresence along with motion from framer-motion, which is needed for the animation effects in the new components.


30-34: Good addition of required components.

These imports bring in the necessary components and hooks for handling the development server connection status. The organization of imports follows the project's conventions.


191-194: Well-structured connection detection logic.

The implementation correctly uses the useCrossEngineIsConnected hook to determine if the development server is connected, providing relevant context from the current run (log count and completion status).


206-206: Good conditional rendering of the banner.

The banner is appropriately shown only in development environments, ensuring production users don't see irrelevant connection warnings. The implementation correctly passes the connection status to the banner component.

apps/webapp/app/components/DevPresence.tsx (3)

1-21: Good organization of imports.

The imports are well-structured and properly grouped. The code imports necessary components from framer-motion, React core, and internal application components that will be needed for the connection status UI.


139-148: Clean implementation of ConnectionIcon component.

The component properly handles all three possible states (undefined, true, false) and renders the appropriate icon for each case. The use of conditional rendering is clean and effective.


194-222: Well-implemented banner with proper animation.

The DevDisconnectedBanner component is well-structured with appropriate use of AnimatePresence for smooth transitions. It correctly appears only when isConnected is false, and the dialog is properly implemented with a clear trigger mechanism.

@matt-aitken matt-aitken merged commit a5b9151 into main Apr 1, 2025
12 checks passed
@matt-aitken matt-aitken deleted the adds-dev-connected-banner branch April 1, 2025 13:34
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.

3 participants