Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function makeApiKey(overrides: Partial<ApiKey> = {}): ApiKey {
name: 'Test Key',
start: 'tale_abc',
prefix: 'tale_',
suffix: 'wxyz',
userId: 'user-1',
enabled: true,
expiresAt: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function makeApiKey(overrides: Partial<ApiKey> = {}): ApiKey {
name: 'Test Key',
start: 'tale_abc',
prefix: 'tale_',
suffix: 'wxyz',
userId: 'user-1',
enabled: true,
expiresAt: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function makeApiKey(overrides: Partial<ApiKey> = {}): ApiKey {
name: 'Test Key',
start: 'tale_abc',
prefix: 'tale_',
suffix: 'wxyz',
userId: 'user-1',
enabled: true,
expiresAt: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,22 @@ export function useApiKeysTableConfig(
{
id: 'key',
header: tSettings('apiKeys.columns.key'),
cell: ({ row }) => (
<Text as="span" variant="muted" className="font-mono text-sm">
{row.original.start || row.original.prefix || '-'}
</Text>
),
cell: ({ row }) => {
const head = row.original.start || row.original.prefix;
const tail = row.original.suffix;
const display = head
? tail
? `${head} … ${tail}`
: head
: tail
? `… ${tail}`
: '-';
return (
<Text as="span" variant="muted" className="font-mono text-sm">
{display}
</Text>
Comment on lines +42 to +54
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Handle suffix-only fallback in key rendering.

If start and prefix are missing but suffix exists, the current branch shows - and hides usable key identity data.

Proposed fix
-              {head ? (tail ? `${head} … ${tail}` : head) : '-'}
+              {head
+                ? tail
+                  ? `${head} … ${tail}`
+                  : head
+                : tail
+                  ? `… ${tail}`
+                  : '-'}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@services/platform/app/features/settings/api-keys/hooks/use-api-keys-table-config.tsx`
around lines 42 - 47, The rendering currently sets head = row.original.start ||
row.original.prefix and hides the suffix when both start and prefix are missing;
change the fallback so that if head is falsy but row.original.suffix exists we
still render the suffix (e.g., show just the tail or "… {tail}") instead of '-'
— update the component in use-api-keys-table-config.tsx where head and tail are
computed and the JSX return so the conditional becomes: if head show (head +
optional tail), else if tail show tail (or a prefixed ellipsis + tail), else
show '-'. This ensures row.original.suffix is used when start/prefix are absent.

);
},
},
{
id: 'created',
Expand Down
10 changes: 10 additions & 0 deletions services/platform/app/features/settings/api-keys/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ export interface ApiKey {
* Used as fallback when `start` is not available.
*/
prefix: string | null;
/**
* Trailing plaintext characters of the key, captured at creation time
* by an after-hook on `/api-key/create` (the upstream Better Auth
* plugin doesn't know about this column). Rendered alongside `start`
* as `start … suffix` so users can match a row against the key they
* hold. Optional because (a) Better Auth's SDK return type doesn't
* include it and (b) rows created before this feature shipped have no
* value — those render with the prefix only.
*/
suffix?: string | null;
userId?: string;
enabled: boolean | null;
expiresAt: Date | null;
Expand Down
Loading
Loading