Skip to content

refactor: openapi selection#4048

Merged
chronark merged 1 commit intomainfrom
diffing-improvements
Oct 1, 2025
Merged

refactor: openapi selection#4048
chronark merged 1 commit intomainfrom
diffing-improvements

Conversation

@ogzhanolguncu
Copy link
Contributor

What does this PR do?

This PR;

  • Disables deployment selection if doesn't have any spec
  • Improves explanations of disabled states through TooltipInfo
  • Uses deploymentId and timestamp for diffing selecting items.
    Fixes # (issue)

If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

  • Go to diffing page
  • Try to select deployment without a spec. You should not be able to select it
  • Check out tooltip messages

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Unkey Docs if changes were necessary

@changeset-bot
Copy link

changeset-bot bot commented Oct 1, 2025

⚠️ No Changeset found

Latest commit: d46cbbb

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

@vercel
Copy link

vercel bot commented Oct 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
dashboard Ready Ready Preview Comment Oct 1, 2025 2:19pm
engineering Ready Ready Preview Comment Oct 1, 2025 2:19pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 1, 2025

📝 Walkthrough

Walkthrough

Extracts a reusable PulseIndicator from status-indicator. Introduces a new DeploymentSelect component under openapi-diff/components, removes the old one, and updates page import. Adds hasOpenApiSpec to deployment schema and computes it in TRPC by deriving from openapiSpec, which is now selected but stripped from the response.

Changes

Cohort / File(s) Summary
Status signal refactor
apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/details/active-deployment-card/status-indicator.tsx
Replaced inline pulsing dots with new exported PulseIndicator component and props; StatusIndicator delegates to PulseIndicator when withSignal is true.
DeploymentSelect relocation and enhancement
apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/openapi-diff/components/deployment-select.tsx, apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/openapi-diff/deployment-select.tsx (removed), apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/openapi-diff/page.tsx
Added new DeploymentSelect with loading/empty states, disabled reasons, live-deployment indicator using PulseIndicator; removed legacy file; updated page import to new components path.
Data model and API mapping
apps/dashboard/lib/collections/deploy/deployments.ts, apps/dashboard/lib/trpc/routers/deploy/deployment/list.ts
Added hasOpenApiSpec to Deployment schema; TRPC now selects openapiSpec, maps it to hasOpenApiSpec, and omits openapiSpec from the returned objects.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant DS as DeploymentSelect (UI)
  participant TRPC as deployments.list (TRPC)
  participant DB as DB

  U->>DS: Open OpenAPI diff page
  DS->>TRPC: Fetch deployments
  TRPC->>DB: SELECT ..., openapiSpec
  DB-->>TRPC: Rows (incl. openapiSpec)
  TRPC-->>DS: Deployments with hasOpenApiSpec (openapiSpec removed)
  note over DS: Disable items lacking spec or matching disabledDeploymentId<br/>Highlight liveDeploymentId with PulseIndicator
  U->>DS: Choose deployment
  DS-->>U: Update selection
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

UI, 🕹️ oss.gg, :joystick: 150 points

Suggested reviewers

  • mcstepp
  • chronark
  • perkinsjr

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description omits a filled-in issue reference and lacks contextual motivation or dependency information in the “What does this PR do?” section, incorrectly marks every change type rather than only the relevant ones, and leaves the checklist mostly untouched despite the template’s requirements. Please specify the actual issue number or link, add motivation, context, and any dependencies in the summary section, select only the applicable change types instead of checking all boxes, and complete the required checklist items such as confirming build/format success and documentation updates.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title “refactor: openapi selection” succinctly follows conventional commit style and accurately describes the main change of refactoring the deployment selection UX for OpenAPI specs. It clearly signals the primary focus without unnecessary detail or noise, making it easy to understand at a glance.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch diffing-improvements

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2025

Thank you for following the naming conventions for pull request titles! 🙏

@vercel vercel bot temporarily deployed to Preview – dashboard October 1, 2025 14:19 Inactive
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/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/openapi-diff/components/deployment-select.tsx (1)

58-58: Standardize date formatting across the dashboard
Observed multiple format() patterns in the dashboard code:

  • apps/.../openapi-diff/components/deployment-select.tsx: format(deployment.createdAt, "MMM d, h:mm a")
  • apps/.../_components/create-key/expiration-setup.tsx: format(date, "MMM d, yyyy 'at' h:mm a")
  • apps/.../logs/queries/utils.ts: format(Number(value), "MMM d HH:mm:ss")
  • apps/.../chart/utils/format-timestamp.ts: format(localDate, "MMM d, HH:mm"), "HH:mm:ss", etc.

Pick one canonical pattern (for example, "MMM d, h:mm a") and centralize it via a shared date-format helper for consistency.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d9c585 and d46cbbb.

📒 Files selected for processing (6)
  • apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/details/active-deployment-card/status-indicator.tsx (1 hunks)
  • apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/openapi-diff/components/deployment-select.tsx (1 hunks)
  • apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/openapi-diff/deployment-select.tsx (0 hunks)
  • apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/openapi-diff/page.tsx (1 hunks)
  • apps/dashboard/lib/collections/deploy/deployments.ts (1 hunks)
  • apps/dashboard/lib/trpc/routers/deploy/deployment/list.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/openapi-diff/deployment-select.tsx
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-07-25T19:09:43.284Z
Learnt from: mcstepp
PR: unkeyed/unkey#3662
File: apps/dashboard/lib/trpc/routers/deployment/list.ts:11-11
Timestamp: 2025-07-25T19:09:43.284Z
Learning: In apps/dashboard/lib/trpc/routers/deployment/list.ts, the listDeployments procedure intentionally queries the versions table rather than a deployments table. The user mcstepp indicated that renaming the table would require a database migration, which was deferred for the current PR focused on UI features.

Applied to files:

  • apps/dashboard/lib/trpc/routers/deploy/deployment/list.ts
📚 Learning: 2025-07-25T19:11:00.208Z
Learnt from: mcstepp
PR: unkeyed/unkey#3662
File: apps/dashboard/lib/trpc/routers/deployment/getOpenApiDiff.ts:110-147
Timestamp: 2025-07-25T19:11:00.208Z
Learning: In apps/dashboard/lib/trpc/routers/deployment/getOpenApiDiff.ts, the user mcstepp prefers to keep mock data fallbacks in POC/demonstration code for simplicity, even if it wouldn't be production-ready. This aligns with the PR being work-in-progress for demonstration purposes.

Applied to files:

  • apps/dashboard/lib/trpc/routers/deploy/deployment/list.ts
📚 Learning: 2025-07-28T20:38:53.244Z
Learnt from: mcstepp
PR: unkeyed/unkey#3662
File: apps/dashboard/app/(app)/projects/[projectId]/diff/[...compare]/components/client.tsx:322-341
Timestamp: 2025-07-28T20:38:53.244Z
Learning: In apps/dashboard/app/(app)/projects/[projectId]/diff/[...compare]/components/client.tsx, mcstepp prefers to keep hardcoded endpoint logic in the getDiffType function during POC phases for demonstrating diff functionality, rather than implementing a generic diff algorithm. This follows the pattern of keeping simplified implementations for demonstration purposes.

Applied to files:

  • apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/openapi-diff/page.tsx
🧬 Code graph analysis (2)
apps/dashboard/lib/trpc/routers/deploy/deployment/list.ts (1)
internal/db/src/schema/deployments.ts (1)
  • deployments (9-54)
apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/openapi-diff/components/deployment-select.tsx (4)
apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/layout-provider.tsx (1)
  • useProjectLayout (16-22)
internal/db/src/schema/deployments.ts (1)
  • deployments (9-54)
apps/dashboard/lib/shorten-id.ts (1)
  • shortenId (5-54)
apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/details/active-deployment-card/status-indicator.tsx (1)
  • PulseIndicator (77-105)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Test Go API Local / Test
  • GitHub Check: Build / Build
  • GitHub Check: Test API / API Test Local
🔇 Additional comments (7)
apps/dashboard/lib/collections/deploy/deployments.ts (1)

17-18: LGTM! Schema addition aligns with backend data.

The hasOpenApiSpec field correctly extends the Deployment schema to support the new deployment selection UX. This flag is computed by the TRPC endpoint in list.ts (line 38) from the presence of openapiSpec.

apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/details/active-deployment-card/status-indicator.tsx (1)

71-105: LGTM! Clean extraction of reusable component.

The PulseIndicator component properly encapsulates the pulsing animation logic with sensible defaults and flexible props for different status colors. The original animation timing and visual behavior are preserved.

apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/openapi-diff/page.tsx (1)

13-13: LGTM! Import path correctly updated.

The import path properly reflects the component relocation to the components subdirectory.

apps/dashboard/lib/trpc/routers/deploy/deployment/list.ts (2)

27-27: LGTM! Efficient data retrieval.

Adding openapiSpec to the query columns enables computing the hasOpenApiSpec flag while keeping the actual spec content out of the response payload.


33-38: LGTM! Clean computed field pattern.

The destructuring and mapping correctly computes hasOpenApiSpec from the presence of openapiSpec while excluding the potentially large spec text from the response. This keeps the API response lean while providing the UI with the information it needs.

apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/openapi-diff/components/deployment-select.tsx (2)

29-107: LGTM! Well-structured component with clear UX patterns.

The DeploymentSelect component correctly implements the PR objectives:

  • Disables deployments without OpenAPI specs using hasOpenApiSpec
  • Prevents selecting the same deployment twice via disabledDeploymentId
  • Provides contextual tooltips for disabled states
  • Indicates live deployments with PulseIndicator
  • Handles loading and empty states appropriately

The component logic is sound and the data flow from backend through TRPC to this UI component is correct.


62-78: Consider potential DOM nesting issue with InfoTooltip + SelectItem.

The InfoTooltip component with asChild prop is wrapping a SelectItem. This pattern relies on proper slot composition in Radix UI primitives. Verify that this doesn't cause DOM nesting issues or accessibility warnings, especially since SelectItem itself may render as a complex interactive element.

If you encounter any console warnings or accessibility issues during testing, consider restructuring the tooltip to wrap only the content div (lines 79-84) rather than the entire SelectItem.

@chronark chronark merged commit 027ce45 into main Oct 1, 2025
18 checks passed
@chronark chronark deleted the diffing-improvements branch October 1, 2025 14:42
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