Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • updated copilot keys to have names, full parity with API keys page, route and copilot already supported names

Type of Change

  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Dec 9, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Dec 9, 2025 2:32am

@waleedlatif1 waleedlatif1 requested a review from Sg312 December 9, 2025 02:32
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 9, 2025

Greptile Overview

Greptile Summary

Added name field support for Copilot API keys, bringing the feature to parity with the workspace API keys page. The implementation follows the same patterns and UX as the existing API keys feature.

  • Added Zod validation for required name field (1-255 characters) in the generate endpoint
  • Extended API response types to include name, createdAt, and lastUsed fields
  • Implemented create dialog with name input and duplicate name validation
  • Enhanced key display to show key name, last used timestamp, and key preview
  • Updated hooks to pass name parameter during key generation

Confidence Score: 5/5

  • This PR is safe to merge with no issues
  • Implementation closely follows existing patterns from the API keys page, includes proper validation and duplicate checking, handles errors gracefully, and maintains type safety throughout. All changes are additive with no breaking changes.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/app/api/copilot/api-keys/generate/route.ts 5/5 Added name field validation and passed to backend API for key generation
apps/sim/app/api/copilot/api-keys/route.ts 5/5 Extended type definitions to include name, createdAt, and lastUsed fields from backend response
apps/sim/hooks/queries/copilot-keys.ts 5/5 Updated CopilotKey interface and mutation to support name parameter
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components-new/settings-modal/components/copilot/copilot.tsx 5/5 Added create dialog, name input with validation, duplicate checking, and enhanced display with timestamps

Sequence Diagram

sequenceDiagram
    participant User
    participant CopilotUI as Copilot Component
    participant Hook as useGenerateCopilotKey
    participant API as /api/copilot/api-keys/generate
    participant Backend as Sim Agent API

    User->>CopilotUI: Click "Create" button
    CopilotUI->>CopilotUI: Open create dialog
    User->>CopilotUI: Enter key name
    User->>CopilotUI: Click "Create" in dialog
    CopilotUI->>CopilotUI: Validate name (check duplicates)
    alt Duplicate name found
        CopilotUI-->>User: Show error message
    else Name is unique
        CopilotUI->>Hook: mutateAsync({ name })
        Hook->>API: POST { name }
        API->>API: Validate with Zod schema
        alt Validation fails
            API-->>Hook: 400 error
            Hook-->>CopilotUI: Error
            CopilotUI-->>User: Show error
        else Validation passes
            API->>Backend: POST /api/validate-key/generate<br/>{ userId, name }
            Backend-->>API: { apiKey, id }
            API-->>Hook: { success: true, key }
            Hook->>Hook: Refetch keys query
            Hook-->>CopilotUI: Return key data
            CopilotUI->>CopilotUI: Show new key dialog
            CopilotUI-->>User: Display full API key (one-time)
        end
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@Sg312 Sg312 merged commit 17a084c into staging Dec 9, 2025
9 checks passed
@waleedlatif1 waleedlatif1 deleted the copilot-key branch December 10, 2025 04:03
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