Skip to content

[VW-128] Api Key Connector Table Views#97

Open
trummelhadron wants to merge 5 commits intomainfrom
connector-tables
Open

[VW-128] Api Key Connector Table Views#97
trummelhadron wants to merge 5 commits intomainfrom
connector-tables

Conversation

@trummelhadron
Copy link
Contributor

@trummelhadron trummelhadron commented Mar 20, 2026

New table views for each of the 4 connector types (asset, device artifact, remediation, vulnerability)

image

Summary by CodeRabbit

  • New Features
    • Unified "API key connectors" lists on Assets, Remediations, Vulnerabilities, and Device Artifacts with resource-type filtering.
    • Table improvements: sortable name, username column, "Last Used" tooltip, status badges (Active/Expired), and type badges (API Key/Integration).
    • Built-in search, pagination, refined loading/error/empty states, and server-side prefetching for faster initial loads.
    • Minor breadcrumb link update on the Asset detail header.

@trummelhadron trummelhadron requested review from 0xcad and timrcm March 20, 2026 18:44
@vercel
Copy link

vercel bot commented Mar 20, 2026

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

Project Deployment Actions Updated (UTC)
viper Ready Ready Preview, Comment Mar 23, 2026 6:36pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
viper-demo Ignored Ignored Mar 23, 2026 6:36pm

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 670c11a8-ac28-4d25-ae32-b53428b97cc7

📥 Commits

Reviewing files that changed from the base of the PR and between f1e605c and 015cc29.

📒 Files selected for processing (1)
  • src/features/api-key-connectors/types.ts
✅ Files skipped from review due to trivial changes (1)
  • src/features/api-key-connectors/types.ts

📝 Walkthrough

Walkthrough

Rewires four dashboard connector list pages to use a new centralized api-key-connectors feature and adds types, params, hooks, server loaders/prefetchers, TRPC procedures, and UI components to support connector listing by resource type.

Changes

Cohort / File(s) Summary
Dashboard Page Rewiring
src/app/(dashboard)/(rest)/connectors/assets/page.tsx, src/app/(dashboard)/(rest)/connectors/deviceArtifacts/page.tsx, src/app/(dashboard)/(rest)/connectors/remediations/page.tsx, src/app/(dashboard)/(rest)/connectors/vulnerabilities/page.tsx
Swapped feature-specific containers/lists/loading/error components and server wiring to use api-key-connectors equivalents; replaced paramsLoader and prefetch with connector-specific variants.
API Key Connectors Types & Config
src/features/api-key-connectors/types.ts, src/features/api-key-connectors/params.ts
Adds Zod schemas/types for connector responses, paginated input/output, resource-type counts, connectorInclude, and exported connectorsParams pagination config.
API Key Connectors Components
src/features/api-key-connectors/components/columns.tsx, src/features/api-key-connectors/components/connectors.tsx
New table column defs and reusable UI components (loading/error/empty, header/container/search, per-resource connector containers and lists).
API Key Connectors Hooks
src/features/api-key-connectors/hooks/use-connectors.ts
Adds useConnectorParams() and useSuspenseConnectorsByResourceType() to read params and fetch connectors by resource type via TRPC suspense queries.
API Key Connectors Server
src/features/api-key-connectors/server/params-loader.ts, src/features/api-key-connectors/server/prefetch.ts, src/features/api-key-connectors/server/routers.ts
Adds server-side params loader, resource-type-specific prefetch helpers, and getManyByTypeInternal TRPC procedure returning paginated connector results using shared schemas and include selection.
TRPC Route Error Logging
src/app/api/trpc/[trpc]/route.ts
Adds an onError callback to the tRPC fetch handler to log request path and error via console.error.
Minor UI Fix
src/features/assets/components/asset.tsx
Adjusted AssetDetailPage breadcrumb link from /connectors/assets to /assets and updated label formatting.

Sequence Diagram(s)

sequenceDiagram
  participant Page as Client Page
  participant Loader as Server Loader (connectorsParamsLoader)
  participant Prefetch as Server Prefetch
  participant TRPC as TRPC Router (getManyByTypeInternal)
  participant DB as Prisma DB

  Page->>Loader: read pagination/search params
  Page->>Prefetch: request prefetch for ResourceType
  Prefetch->>TRPC: call getManyByTypeInternal(params + resourceType)
  TRPC->>DB: fetch paginated connectors (where resourceType, include user)
  DB-->>TRPC: return rows + counts
  TRPC-->>Prefetch: return data (cached)
  Prefetch-->>Page: hydrate prefetched data
  Page->>Page: render ConnectorsList (columns, search, pagination)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • timrcm
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'VW-128 Api Key Connector Table Views' clearly and specifically describes the main change: implementing new table views for API key connectors across 4 resource types (asset, device artifact, remediation, vulnerability).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch connector-tables

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.

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

🧹 Nitpick comments (3)
src/features/api-key-connectors/types.ts (1)

32-34: Consider using PascalCase for the exported type name.

The type paginatedConnectorsByTypeInput uses camelCase, while other types in this file (ConnectorResponse) and TypeScript convention typically use PascalCase for type aliases.

✏️ Suggested fix
-export type paginatedConnectorsByTypeInput = z.infer<
+export type PaginatedConnectorsByTypeInput = z.infer<
   typeof paginatedConnectorInputSchema
 >;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/features/api-key-connectors/types.ts` around lines 32 - 34, The exported
type name paginatedConnectorsByTypeInput should use PascalCase: rename it to
PaginatedConnectorsByTypeInput and update its declaration to export type
PaginatedConnectorsByTypeInput = z.infer<typeof paginatedConnectorInputSchema>;
then search and update all usages/imports of paginatedConnectorsByTypeInput
across the codebase (tests, consumers, and index exports) to the new
PaginatedConnectorsByTypeInput identifier so imports and references remain
consistent with ConnectorResponse and TS naming conventions.
src/features/api-key-connectors/server/prefetch.ts (1)

1-3: Add 'server-only' directive to prevent client-side imports.

This is a server-side prefetch utility that should not be imported on the client. Adding the directive ensures bundler errors if accidentally imported client-side.

🛡️ Suggested fix
+import "server-only";
+
 import type { inferInput } from "@trpc/tanstack-react-query";
 import { ResourceType } from "@/generated/prisma";
 import { prefetch, trpc } from "@/trpc/server";

As per coding guidelines: "Mark server-side files with 'server-only' directive".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/features/api-key-connectors/server/prefetch.ts` around lines 1 - 3, Add
the top-of-file "server-only" directive (a single line containing 'server-only')
as the very first line to prevent client-side imports; update src features
referenced symbols such as inferInput, ResourceType, prefetch, and trpc remain
unchanged — just insert the directive before the existing imports so the bundler
will error if this server-side prefetch utility is imported on the client.
src/features/api-key-connectors/components/connectors.tsx (1)

107-117: Inconsistent use of hardcoded string vs enum for resourceType.

DeviceArtifactConnectorsContainer uses the string "Device Artifact" for display, while other containers use ResourceType.* enum values directly. This works because ConnectorsContainer accepts ResourceType | string, but it's inconsistent.

Consider creating a display-name mapping to keep the prop type strict while still showing user-friendly names:

💡 Suggested approach
// At top of file or in a shared utility
const resourceTypeDisplayNames: Record<ResourceType, string> = {
  [ResourceType.Asset]: "Asset",
  [ResourceType.DeviceArtifact]: "Device Artifact",
  [ResourceType.Remediation]: "Remediation",
  [ResourceType.Vulnerability]: "Vulnerability",
};

// Then in ConnectorsHeader, use:
// title={`${resourceTypeDisplayNames[resourceType as ResourceType] ?? resourceType} Connectors`}

This would allow ConnectorsContainer to always receive ResourceType while still displaying "Device Artifact" with a space.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/features/api-key-connectors/components/connectors.tsx` around lines 107 -
117, DeviceArtifactConnectorsContainer currently passes the literal string
"Device Artifact" into ConnectorsContainer which accepts ResourceType | string;
change this to pass the ResourceType enum (ResourceType.DeviceArtifact) and add
a display-name mapping (e.g., resourceTypeDisplayNames:
Record<ResourceType,string>) used by ConnectorsHeader (or whatever renders the
title) to convert ResourceType.DeviceArtifact into the user-friendly "Device
Artifact"; update ConnectorsContainer prop typing to require ResourceType and
ensure ConnectorsHeader uses resourceTypeDisplayNames[resourceType] ??
resourceType for its title.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/features/api-key-connectors/components/columns.tsx`:
- Around line 53-58: The status logic in the columns renderer (where text and
color are set based on row.original.apiKeyId) mislabels connectors that have a
valid integrationId as expired; update the condition in that component (the
block that sets text and color for status) to treat a row as Active when either
row.original.apiKeyId or row.original.integrationId is present, and mark Expired
only when both are missing, keeping the same color mapping (e.g., bg-green-300
for Active, bg-red-400 for Expired).

In `@src/features/api-key-connectors/server/params-loader.ts`:
- Around line 1-2: Add the "server-only" directive as the very first line of the
file and update the local import to use the project alias: keep the createLoader
import from "nuqs/server" but replace the relative connectors import
(connectorsParams from "../params") with the aliased path connectorsParams from
"@/features/api-key-connectors/params"; ensure the "server-only" string literal
appears before any imports so the file is explicitly marked server-side.

---

Nitpick comments:
In `@src/features/api-key-connectors/components/connectors.tsx`:
- Around line 107-117: DeviceArtifactConnectorsContainer currently passes the
literal string "Device Artifact" into ConnectorsContainer which accepts
ResourceType | string; change this to pass the ResourceType enum
(ResourceType.DeviceArtifact) and add a display-name mapping (e.g.,
resourceTypeDisplayNames: Record<ResourceType,string>) used by ConnectorsHeader
(or whatever renders the title) to convert ResourceType.DeviceArtifact into the
user-friendly "Device Artifact"; update ConnectorsContainer prop typing to
require ResourceType and ensure ConnectorsHeader uses
resourceTypeDisplayNames[resourceType] ?? resourceType for its title.

In `@src/features/api-key-connectors/server/prefetch.ts`:
- Around line 1-3: Add the top-of-file "server-only" directive (a single line
containing 'server-only') as the very first line to prevent client-side imports;
update src features referenced symbols such as inferInput, ResourceType,
prefetch, and trpc remain unchanged — just insert the directive before the
existing imports so the bundler will error if this server-side prefetch utility
is imported on the client.

In `@src/features/api-key-connectors/types.ts`:
- Around line 32-34: The exported type name paginatedConnectorsByTypeInput
should use PascalCase: rename it to PaginatedConnectorsByTypeInput and update
its declaration to export type PaginatedConnectorsByTypeInput = z.infer<typeof
paginatedConnectorInputSchema>; then search and update all usages/imports of
paginatedConnectorsByTypeInput across the codebase (tests, consumers, and index
exports) to the new PaginatedConnectorsByTypeInput identifier so imports and
references remain consistent with ConnectorResponse and TS naming conventions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 41069a9f-826c-4444-bf02-64fff5d01bec

📥 Commits

Reviewing files that changed from the base of the PR and between b8ac874 and 3d6278b.

📒 Files selected for processing (13)
  • src/app/(dashboard)/(rest)/connectors/assets/page.tsx
  • src/app/(dashboard)/(rest)/connectors/deviceArtifacts/page.tsx
  • src/app/(dashboard)/(rest)/connectors/remediations/page.tsx
  • src/app/(dashboard)/(rest)/connectors/vulnerabilities/page.tsx
  • src/features/api-key-connectors/components/columns.tsx
  • src/features/api-key-connectors/components/connectors.tsx
  • src/features/api-key-connectors/hooks/use-connectors.ts
  • src/features/api-key-connectors/params.ts
  • src/features/api-key-connectors/server/params-loader.ts
  • src/features/api-key-connectors/server/prefetch.ts
  • src/features/api-key-connectors/server/routers.ts
  • src/features/api-key-connectors/types.ts
  • src/features/assets/components/asset.tsx

Copy link
Contributor

@timrcm timrcm left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Copy link
Contributor

@timrcm timrcm left a comment

Choose a reason for hiding this comment

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

Note Cassidy's feedback in Slack -- it looks like there might still be some issues with this after all.

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

🧹 Nitpick comments (2)
src/app/api/trpc/[trpc]/route.ts (1)

12-14: Consider structured logging and environment-aware verbosity.

The error logging is functional, but for production use:

  1. Logging the full error object may expose sensitive data or stack traces in production logs.
  2. A more structured format would improve observability and log parsing.
♻️ Optional: Structured error logging
     onError: ({ path, error }) => {
-      console.error(path, error);
+      console.error(`[tRPC Error] ${path}:`, {
+        code: error.code,
+        message: error.message,
+        ...(process.env.NODE_ENV === "development" && { stack: error.stack }),
+      });
     },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/api/trpc/`[trpc]/route.ts around lines 12 - 14, The onError handler
currently logs the raw error object (onError: ({ path, error }) => {
console.error(path, error); }) which can leak sensitive info and is
unstructured; update the handler to emit structured logs (an object with path,
error.message, error.name, optional status/code) and gate stack traces behind an
environment check (e.g., include error.stack only when NODE_ENV !==
'production'), and redact any sensitive properties before logging or use an
existing structured logger instance if available; ensure the handler still
captures the path and a concise message for observability while avoiding full
error dumps in production.
src/features/api-key-connectors/components/connectors.tsx (1)

1-1: Rename this component file to PascalCase for consistency.

This component lives in src/features/.../components/ but the filename is connectors.tsx; please rename it to Connectors.tsx to match repo conventions.

As per coding guidelines, "Use PascalCase for component file names and kebab-case for utility/helper file names".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/features/api-key-connectors/components/connectors.tsx` at line 1, Rename
the component file from connectors.tsx to Connectors.tsx and update all imports
referencing it to the new filename; ensure the exported React component
(Connectors) and any default export usages still match after the rename so
imports like import Connectors from "…/components/Connectors" resolve correctly,
and run project/type-check to catch any missed import paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/features/api-key-connectors/components/connectors.tsx`:
- Line 85: Remove the debug console logging of connector payloads: delete the
console.log("useSuspenseConnectorsByResourceType:", connectors) statement in the
connectors.tsx implementation (the useSuspenseConnectorsByResourceType flow that
handles the connectors variable) so fetched connector data is not printed to the
browser console; ensure no equivalent debug logs remain in the same module or
helper functions that expose connector payloads.

---

Nitpick comments:
In `@src/app/api/trpc/`[trpc]/route.ts:
- Around line 12-14: The onError handler currently logs the raw error object
(onError: ({ path, error }) => { console.error(path, error); }) which can leak
sensitive info and is unstructured; update the handler to emit structured logs
(an object with path, error.message, error.name, optional status/code) and gate
stack traces behind an environment check (e.g., include error.stack only when
NODE_ENV !== 'production'), and redact any sensitive properties before logging
or use an existing structured logger instance if available; ensure the handler
still captures the path and a concise message for observability while avoiding
full error dumps in production.

In `@src/features/api-key-connectors/components/connectors.tsx`:
- Line 1: Rename the component file from connectors.tsx to Connectors.tsx and
update all imports referencing it to the new filename; ensure the exported React
component (Connectors) and any default export usages still match after the
rename so imports like import Connectors from "…/components/Connectors" resolve
correctly, and run project/type-check to catch any missed import paths.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 56631c87-204d-4f97-adf6-2e0ac36f1c78

📥 Commits

Reviewing files that changed from the base of the PR and between 9d58ad7 and f1e605c.

📒 Files selected for processing (2)
  • src/app/api/trpc/[trpc]/route.ts
  • src/features/api-key-connectors/components/connectors.tsx

resourceType,
});

console.log("useSuspenseConnectorsByResourceType:", connectors);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Remove connector payload debug logging before merge.

Line 85 logs fetched connector data in the browser console. This is a production data-exposure/noise risk and should be removed.

Suggested fix
-  console.log("useSuspenseConnectorsByResourceType:", connectors);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.log("useSuspenseConnectorsByResourceType:", connectors);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/features/api-key-connectors/components/connectors.tsx` at line 85, Remove
the debug console logging of connector payloads: delete the
console.log("useSuspenseConnectorsByResourceType:", connectors) statement in the
connectors.tsx implementation (the useSuspenseConnectorsByResourceType flow that
handles the connectors variable) so fetched connector data is not printed to the
browser console; ensure no equivalent debug logs remain in the same module or
helper functions that expose connector payloads.

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