Skip to content

The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.

fix(console): clarify API key access preset permissions (#3141)

Mandab2fb9944bf63
diff --git a/apps/dashboard/README.md b/apps/dashboard/README.md
index 30916945a..e666dd21f 100644
--- a/apps/dashboard/README.md
+++ b/apps/dashboard/README.md
@@ -625,13 +625,20 @@ duplicates, updates with fixed scope, write permissions, and refusals named by b
## Console API key permissions and expiration
**New API key** defaults to **Operate boxes** (`write:boxes`) and **30 days**.
-The Access selector offers Operate boxes, Manage box lifecycle (adds Box deletion),
+The Access preset selector offers Operate boxes, Manage box lifecycle (adds Box deletion),
and Use boxes with volumes (adds Volume read and write). A preset requires every
scope in its bundle; unavailable presets explain the missing capabilities.
+Each named option shows its permission count. Selecting a valid preset displays
+**This preset includes N permissions** and its constituent permission labels without
+opening advanced settings. For example, **Use boxes with volumes · 3 permissions**
+includes Operate boxes, View volumes, and Manage volumes. Switching presets replaces
+the selected bundle; it does not accumulate permissions from earlier choices.
+Preset previews: [desktop](../../docs/contributing/investigations/assets/api-key-access-presets/desktop.png)
+and [390px viewport](../../docs/contributing/investigations/assets/api-key-access-presets/narrow.png).
**All available permissions** explicitly selects every supported permission the
current member can grant in this organization; it does not change the default.
-The overall summary and resource groups show selected/available counts, such as
+Custom access and All available permissions summaries, plus resource groups, show selected/available counts, such as
**13/13 permissions selected** and **3/3 selected**. Implicit Box reading is excluded.
Manual complete selections also show **All available permissions selected**.
diff --git a/apps/dashboard/src/components/CreateApiKeyDialog.permissions.spec.tsx b/apps/dashboard/src/components/CreateApiKeyDialog.permissions.spec.tsx
index 0f1f296f0..bb2b5eead 100644
--- a/apps/dashboard/src/components/CreateApiKeyDialog.permissions.spec.tsx
+++ b/apps/dashboard/src/components/CreateApiKeyDialog.permissions.spec.tsx
@@ -159,11 +159,11 @@ describe('API key permission contract', () => {
async function chooseAccess(label: string) {
await act(async () =>
document
- .querySelector('[aria-label="Access"]')!
+ .querySelector('[aria-label="Access preset"]')!
.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })),
)
const option = [...document.querySelectorAll<HTMLElement>('[role="option"]')].find(
- (item) => item.textContent?.trim() === label,
+ (item) => item.textContent?.trim() === label || item.textContent?.trim().startsWith(`${label} · `),
)!
expect(option).toBeTruthy()
await act(async () => option.click())
@@ -178,7 +178,7 @@ describe('API key selection completeness', () => {
it('shows selected/available counts globally and in resource groups', async () => {
await render()
await open()
- expect(summary()).toContain('1/3 permissions selected')
+ expect(summary()).toContain('This preset includes 1 permission')
await act(async () => button('Adjust permissions').click())
expect([...document.querySelectorAll('summary')].map((item) => item.textContent)).toEqual(
expect.arrayContaining(['Boxes1/2 selected', 'Members0/1 selected']),
@@ -210,7 +210,7 @@ describe('API key selection completeness', () => {
await chooseAccess('Custom access')
await toggle('Delete boxes')
expect(summary()).toContain('All available permissions selected')
- expect(document.querySelector('[aria-label="Access"]')!.textContent).toBe('Custom access')
+ expect(document.querySelector('[aria-label="Access preset"]')!.textContent).toBe('Custom access')
await toggle('Operate boxes')
expect(summary()).toContain('1/2 permissions selected')
expect(summary()).not.toContain('All available permissions selected')
@@ -225,7 +225,7 @@ describe('API key selection completeness', () => {
await chooseAccess('All available permissions')
await render([P.WRITE_BOXES, P.DELETE_BOXES])
expect(summary()).toContain('1/2 permissions selected')
- expect(document.querySelector('[aria-label="Access"]')!.textContent).toBe('Custom access')
+ expect(document.querySelector('[aria-label="Access preset"]')!.textContent).toBe('Custom access')
await submit()
expect(mocks.create.mock.calls[0][0].permissions).toEqual([P.WRITE_BOXES])
})
@@ -236,7 +236,7 @@ describe('API key selection completeness', () => {
await render([P.WRITE_BOXES])
expect(summary()).toContain('1/1 permissions selected')
expect(summary()).not.toContain('All available permissions selected')
- expect(document.querySelector('[aria-label="Access"]')!.textContent).toBe('Custom access')
+ expect(document.querySelector('[aria-label="Access preset"]')!.textContent).toBe('Custom access')
expect(document.querySelector('summary')!.textContent).toBe('Boxes1/1 selected')
await submit()
expect(mocks.create).not.toHaveBeenCalled()
@@ -255,7 +255,7 @@ describe('API key selection completeness', () => {
),
)
expect(summary()).not.toContain('permissions selected')
- expect(document.querySelector('[aria-label="Access"]')!.textContent).toBe('Custom access')
+ expect(document.querySelector('[aria-label="Access preset"]')!.textContent).toBe('Custom access')
await submit()
expect(mocks.create).not.toHaveBeenCalled()
})
@@ -266,7 +266,7 @@ describe('API key selection completeness', () => {
expect(summary()).not.toContain('All available permissions selected')
await act(async () =>
document
- .querySelector('[aria-label="Access"]')!
+ .querySelector('[aria-label="Access preset"]')!
.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })),
)
const option = [...document.querySelectorAll('[role="option"]')].find(
@@ -279,14 +279,31 @@ describe('API key selection completeness', () => {
await open()
await chooseAccess('All available permissions')
await chooseAccess('Operate boxes')
- expect(summary()).toContain('1/13 permissions selected')
+ expect(summary()).toContain('This preset includes 1 permission')
await chooseAccess('All available permissions')
await render(supported, 'org-2')
- expect(summary()).toContain('1/13 permissions selected')
- expect(document.querySelector('[aria-label="Access"]')!.textContent).toBe('Operate boxes')
+ expect(summary()).toContain('This preset includes 1 permission')
+ expect(document.querySelector('[aria-label="Access preset"]')!.textContent).toBe('Operate boxes · 1 permission')
})
})
describe('API key access presets', () => {
+ it('explains the preset bundle without opening advanced settings', async () => {
+ await render([...all, P.READ_VOLUMES, P.WRITE_VOLUMES])
+ await open()
+ await chooseAccess('Operate boxes')
+ await chooseAccess('Manage box lifecycle')
+ await chooseAccess('Use boxes with volumes')
+ expect(document.body.textContent).toContain('This preset includes 3 permissions')
+ const included = document.querySelector('[aria-label="Included permissions"]')!
+ expect([...included.querySelectorAll('li')].map((item) => item.textContent)).toEqual([
+ 'Operate boxes',
+ 'View volumes',
+ 'Manage volumes',
+ ])
+ expect(button('Adjust permissions').getAttribute('aria-expanded')).toBe('false')
+ await submit()
+ expect(mocks.create.mock.calls[0][0].permissions).toEqual([P.WRITE_BOXES, P.READ_VOLUMES, P.WRITE_VOLUMES])
+ })
it.each([
['Manage box lifecycle', [P.WRITE_BOXES, P.DELETE_BOXES]],
['Use boxes with volumes', [P.WRITE_BOXES, P.READ_VOLUMES, P.WRITE_VOLUMES]],
@@ -302,7 +319,7 @@ describe('API key access presets', () => {
await open()
await act(async () =>
document
- .querySelector('[aria-label="Access"]')!
+ .querySelector('[aria-label="Access preset"]')!
.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })),
)
const option = [...document.querySelectorAll('[role="option"]')].find((item) =>
@@ -320,7 +337,7 @@ describe('API key access presets', () => {
await act(async () => button('Adjust permissions').click())
const label = [...document.querySelectorAll('label')].find((item) => item.textContent?.startsWith('Delete boxes'))!
await act(async () => document.getElementById(label.htmlFor)!.click())
- expect(document.querySelector('[aria-label="Access"]')!.textContent).toBe('Custom access')
+ expect(document.querySelector('[aria-label="Access preset"]')!.textContent).toBe('Custom access')
await chooseAccess('Operate boxes')
await submit()
expect(mocks.create.mock.calls[0][0].permissions).toEqual([P.WRITE_BOXES])
diff --git a/apps/dashboard/src/components/CreateApiKeyDialog.tsx b/apps/dashboard/src/components/CreateApiKeyDialog.tsx
index 6f41206c6..8f184a302 100644
--- a/apps/dashboard/src/components/CreateApiKeyDialog.tsx
+++ b/apps/dashboard/src/components/CreateApiKeyDialog.tsx
@@ -93,6 +93,14 @@ function ApiKeyForm({
invalid.length === 0
const effectivePresetId = presetId === 'all' && !allSelected ? 'custom' : presetId
const preset = API_KEY_ACCESS_PRESETS.find((item) => item.id === effectivePresetId)
+ const matchingPreset =
+ permissionsStatus === 'ready' &&
+ invalid.length === 0 &&
+ preset &&
+ selected.length === preset.permissions.length &&
+ preset.permissions.every((permission) => selected.includes(permission))
+ ? preset
+ : undefined
const canSubmit = Boolean(
organizationId &&
name.trim() &&
@@ -246,7 +254,10 @@ function ApiKeyForm({
/>
</div>
<fieldset className="space-y-2" disabled={submitting} aria-describedby={`${id}-permission-help`}>
- <legend className="form-field-label mb-2">Access</legend>
+ <legend className="form-field-label mb-2">Access preset</legend>
+ <p id={id + '-preset-help'} className="text-body text-muted-foreground">
+ Choose a preset or customize individual permissions.
+ </p>
<Select
value={effectivePresetId}
disabled={submitting || permissionsStatus !== 'ready'}
@@ -275,7 +286,7 @@ function ApiKeyForm({
setCustomize(false)
}}
>
- <SelectTrigger aria-label="Access" aria-describedby={id + '-permission-help'}>
+ <SelectTrigger aria-label="Access preset" aria-describedby={`${id}-preset-help ${id}-permission-help`}>
<SelectValue />
</SelectTrigger>
<SelectContent>
@@ -283,7 +294,7 @@ function ApiKeyForm({
const missing = item.permissions.filter((permission) => !availablePermissions.includes(permission))
return (
<SelectItem key={item.id} value={item.id} disabled={missing.length > 0}>
- {item.label}
+ {item.label} · {item.permissions.length} permission{item.permissions.length === 1 ? '' : 's'}
{missing.length > 0 && (
<span className="block text-meta text-muted-foreground">
Requires: {missing.map((p) => API_KEY_PERMISSION_LABELS[p]).join(', ')}
@@ -304,14 +315,30 @@ function ApiKeyForm({
: (preset?.description ?? 'Choose specific operations for this key.')}
</p>
<div className="flex items-center justify-between gap-3">
- <span className="text-meta text-muted-foreground" aria-live="polite">
+ <div className="text-meta text-muted-foreground" aria-live="polite">
{permissionsStatus === 'ready' && (
<>
- {selectedAvailable.length}/{availablePermissions.length} permissions selected
+ {matchingPreset ? (
+ <>
+ <p>
+ This preset includes {matchingPreset.permissions.length} permission
+ {matchingPreset.permissions.length === 1 ? '' : 's'}
+ </p>
+ <ul aria-label="Included permissions" className="mt-1 list-inside list-disc text-body">
+ {matchingPreset.permissions.map((permission) => (
+ <li key={permission}>{API_KEY_PERMISSION_LABELS[permission]}</li>
+ ))}
+ </ul>
+ </>
+ ) : (
+ <>
+ {selectedAvailable.length}/{availablePermissions.length} permissions selected
+ </>
+ )}
{allSelected && <span className="block">All available permissions selected</span>}
</>
)}
- </span>
+ </div>
<AsciiButton
type="button"
variant="quiet"
diff --git a/docs/contributing/investigations/assets/api-key-access-presets/desktop.png b/docs/contributing/investigations/assets/api-key-access-presets/desktop.png
new file mode 100644
index 000000000..f811240b4
Binary files /dev/null and b/docs/contributing/investigations/assets/api-key-access-presets/desktop.png differ
diff --git a/docs/contributing/investigations/assets/api-key-access-presets/narrow.png b/docs/contributing/investigations/assets/api-key-access-presets/narrow.png
new file mode 100644
index 000000000..b0034b96d
Binary files /dev/null and b/docs/contributing/investigations/assets/api-key-access-presets/narrow.png differ