Skip to content

Conversation

@hemanth-1321
Copy link

@hemanth-1321 hemanth-1321 commented Jul 25, 2025

Fix: Launched project still shows "Launch" button (#158)

Summary

This fixes the UI not reflecting the launched state immediately.

Fix Details

  • Added local state (hasLaunched) that updates immediately on successful mutation.
  • UI now conditionally renders the "View Project" button after launch without requiring a reload.

🔗 Related Issue

Closes #158

Screencast.from.2025-07-25.19-44-57.webm

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added launch state tracking to the project description and launch dialog, enabling the UI to indicate when a project has already been launched.
    • The launch dialog now conditionally displays a "View Project" button if the project is already launched.
  • Improvements

    • Removed forced page reload after repository status changes from private to public.

@coderabbitai
Copy link

coderabbitai bot commented Jul 25, 2025

Walkthrough

The changes introduce an isAlreadyLaunched prop, which is derived from launch data fetched using React Query in the project description component. This prop is threaded through to the launch dialog, which now tracks and displays the launch state, conditionally rendering a "View Project" button if the project is already launched. Minor validation and UI logic adjustments accompany these changes.

Changes

File(s) Change Summary
apps/web/app/(public)/(projects)/projects/[id]/project-description.tsx Added data fetching for launch state; introduced and passed isAlreadyLaunched prop to child components.
apps/web/components/project/launch-project-dialog.tsx Added isAlreadyLaunched prop, internal launch state, conditional UI for launched state, validation cleanup.
packages/api/src/routers/launches.ts Reformatted code for readability; no functional or logical changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ProjectDescription
    participant ActionButtons
    participant LaunchProjectDialog
    participant API

    User->>ProjectDescription: Visit project page
    ProjectDescription->>API: Fetch launch data for project
    API-->>ProjectDescription: Return launch status
    ProjectDescription->>ActionButtons: Pass isAlreadyLaunched prop
    ActionButtons->>LaunchProjectDialog: Pass isAlreadyLaunched prop
    User->>LaunchProjectDialog: Open dialog
    alt Project already launched
        LaunchProjectDialog->>User: Show "View Project" button
    else Not launched
        LaunchProjectDialog->>User: Show launch form/button
        User->>LaunchProjectDialog: Submit launch
        LaunchProjectDialog->>API: Launch project mutation
        API-->>LaunchProjectDialog: Confirm launch
        LaunchProjectDialog->>User: Show "View Project" button
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • Feat/project page #51: Adds launch state awareness and related props to ProjectDescription and nested components, building on the initial ProjectDescription component and page layout restructuring.

Poem

A bunny hopped through code anew,
With launch states tracked and buttons too,
No more confusion—just one click,
To view your project, oh so slick!
With every hop, the UI’s clear,
The launch is done—let’s all cheer!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 f9077d7 and acd2c73.

📒 Files selected for processing (1)
  • apps/web/components/project/launch-project-dialog.tsx (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/components/project/launch-project-dialog.tsx
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 generate unit tests to generate unit tests for 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.

@vercel
Copy link

vercel bot commented Jul 25, 2025

@hemanth-1321 is attempting to deploy a commit to the ossdotnow Team on Vercel.

A member of the Team first needs to authorize it.

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: 0

🧹 Nitpick comments (1)
apps/web/app/(public)/(projects)/projects/[id]/project-description.tsx (1)

23-27: Add error handling for the launch data query.

The launch data fetching logic is well-implemented, but consider adding error handling and potentially optimizing the query execution.

  const trpc = useTRPC();
- const { data: launchData, isLoading: launchLoading } = useQuery(
-   trpc.launches.getLaunchByProjectId.queryOptions({ projectId: project.id })
- );
+ const { data: launchData, isLoading: launchLoading, error } = useQuery({
+   ...trpc.launches.getLaunchByProjectId.queryOptions({ projectId: project.id }),
+   enabled: isOwner, // Only fetch for owners to optimize performance
+ });
  const isAlreadyLaunched = !!launchData;

This optimization prevents unnecessary API calls for non-owners and adds error state for better debugging.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fe6463f and 5e6e960.

📒 Files selected for processing (3)
  • apps/web/app/(public)/(projects)/projects/[id]/project-description.tsx (5 hunks)
  • apps/web/components/project/launch-project-dialog.tsx (6 hunks)
  • packages/api/src/routers/launches.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
packages/api/src/routers/launches.ts (3)
packages/api/src/trpc.ts (1)
  • protectedProcedure (40-52)
packages/db/src/schema/projects.ts (1)
  • project (16-64)
packages/db/src/schema/project-launches.ts (1)
  • projectLaunch (5-29)
apps/web/app/(public)/(projects)/projects/[id]/project-description.tsx (2)
packages/db/src/schema/projects.ts (1)
  • project (16-64)
packages/api/src/driver/types.ts (2)
  • ProjectWithRelations (26-72)
  • ProjectData (5-25)
apps/web/components/project/launch-project-dialog.tsx (2)
packages/db/src/seed/create-fixture.ts (1)
  • data (13-27)
packages/ui/src/components/button.tsx (1)
  • Button (56-56)
🔇 Additional comments (8)
packages/api/src/routers/launches.ts (1)

573-628: LGTM: Formatting improvements without functional changes.

The launchProject mutation logic remains unchanged - all validation checks, error handling, and business rules are preserved. The reformatting improves readability while maintaining API compatibility for the frontend launch state tracking changes.

apps/web/app/(public)/(projects)/projects/[id]/project-description.tsx (3)

11-12: LGTM: Proper imports for React Query integration.

The imports are correctly added to support the launch state fetching functionality.


73-73: LGTM: Proper prop threading.

The isAlreadyLaunched prop is correctly passed to the ActionButtons component to enable launch state awareness.


230-230: LGTM: Clean prop interface updates.

The prop signatures are properly updated to include the optional isAlreadyLaunched boolean, maintaining backward compatibility while enabling the new functionality.

Also applies to: 236-236, 257-257

apps/web/components/project/launch-project-dialog.tsx (4)

34-34: LGTM: Simplified validation schema.

Removing the explicit error messages while keeping the validation constraints is a clean simplification. The form will still show appropriate validation feedback.


44-44: LGTM: Proper launch state integration.

The new isAlreadyLaunched prop and hasLaunched state are correctly implemented. Initializing the state from the prop ensures the component reflects the current launch status on mount.

Also applies to: 55-55, 59-59


104-104: LGTM: Key fix for immediate UI update.

Setting hasLaunched to true on successful launch is the core fix that eliminates the need for manual page refresh. This directly addresses the issue described in the PR objectives.


242-262: LGTM: Clean conditional rendering logic.

The conditional rendering properly handles all three states:

  1. Already launched → Show "View Project" button
  2. Private repository → Show private repo dialog
  3. Public repository → Show launch dialog

The implementation correctly fixes the original UI issue.

Consider whether opening the project view in a new tab is the desired UX behavior, or if it should navigate in the same tab.

Copy link
Collaborator

@ahmetskilinc ahmetskilinc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one comment

@ahmetskilinc
Copy link
Collaborator

@cursor run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bugbot free trial expires on July 29, 2025
Learn more in the Cursor dashboard.

}: LaunchProjectDialogProps) {
const [open, setOpen] = useState(false);
const [privateRepoDialogOpen, setPrivateRepoDialogOpen] = useState(false);
const [hasLaunched, setHasLaunched] = useState(isAlreadyLaunched ?? false);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: State Initialization Fails to Sync with Prop

The hasLaunched state is initialized once from the isAlreadyLaunched prop using useState. Because useState's initializer only runs on the initial render, hasLaunched will not update if the isAlreadyLaunched prop changes later (e.g., when project data loads). This prevents the "View Project" button from appearing for already-launched projects until a new launch or a page refresh. The hasLaunched state should be kept in sync with the isAlreadyLaunched prop, for example, by using useEffect.

Locations (1)

Fix in CursorFix in Web

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.

Launched project still shows to launch

2 participants