fix(notifications): phrase permission labels without losing acronyms

The always-allow summary interpolated the raw action id ("always allow
shell") while every other surface shows the label ("Run Command"), and
the permission dialog lowercased the whole label, turning "Fetch URL"
into "fetch url". getPermissionPhrase lowercases each word of the label
unless it is all caps, and both the scope summary and the dialog
question use it.
This commit is contained in:
Chris Scott committed 2026-10-25 11:20:21 -04:00
1 parent 11a2661cc6
commit 8747cfece9
4 files changed
+57 -5

No files matched your search

@@ -34,6 +34,23 @@ describe('PermissionRequestDialog', () => {
expect(screen.getByText('rm -rf node_modules')).toBeInTheDocument()
})
it('phrases the allow question in lowercase while preserving acronyms', () => {
const { unmount } = render(
<PermissionRequestDialog permission={permission} pendingCount={1} onRespond={vi.fn()} />,
)
expect(screen.getByText('Allow run command?')).toBeInTheDocument()
unmount()
render(
<PermissionRequestDialog
permission={{ ...permission, action: 'webfetch', resources: [], metadata: { url: 'https://example.com' } }}
pendingCount={1}
onRespond={vi.fn()}
/>,
)
expect(screen.getByText('Allow fetch URL?')).toBeInTheDocument()
})
it('labels multiple shell resources as commands', () => {
render(
<PermissionRequestDialog
@@ -69,7 +86,7 @@ describe('PermissionRequestDialog', () => {
/>,
)
expect(screen.getByText('This will always allow shell for this project.')).toBeInTheDocument()
expect(screen.getByText('This will always allow run command for this project.')).toBeInTheDocument()
})
it('lists the patterns an always decision approves', () => {
@@ -13,6 +13,7 @@ import type { PermissionResponse } from '@/api/types'
import type { PermissionRequest } from '@opencode-manager/shared/opencode'
import {
getPermissionLabel,
getPermissionPhrase,
getPermissionDetail,
getPermissionAlwaysScope,
} from '@opencode-manager/shared/notifications'
@@ -99,7 +100,7 @@ export function PermissionRequestDialog({
)}
</DialogTitle>
<DialogDescription className="break-all">
{`Allow ${typeLabel.toLowerCase()}?`}
{`Allow ${getPermissionPhrase(permission.action)}?`}
</DialogDescription>
</DialogHeader>