mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
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:
1 parent
11a2661cc6
commit
8747cfece9
4 files changed
+57
-5
No files matched your search
@@ -71,6 +71,19 @@ export function getPermissionLabel(permission: string): string {
|
||||
return PERMISSION_LABELS[permission] ?? permission.charAt(0).toUpperCase() + permission.slice(1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a permission action as a lowercase mid-sentence phrase, preserving acronyms.
|
||||
*
|
||||
* Use inside sentences such as `Allow ${getPermissionPhrase(action)}?` so the human
|
||||
* label reads naturally instead of lowercasing the whole label.
|
||||
*/
|
||||
export function getPermissionPhrase(action: string): string {
|
||||
return getPermissionLabel(action)
|
||||
.split(' ')
|
||||
.map((word) => (word === word.toUpperCase() ? word : word.toLowerCase()))
|
||||
.join(' ')
|
||||
}
|
||||
|
||||
interface PermissionLike {
|
||||
action?: unknown
|
||||
metadata?: unknown
|
||||
@@ -141,7 +154,7 @@ export function getPermissionAlwaysScope(input: PermissionLike): PermissionAlway
|
||||
const save = Array.isArray(input.save) ? input.save.filter((item): item is string => typeof item === 'string') : []
|
||||
if (save.length === 0) return null
|
||||
if (save.length === 1 && save[0] === '*') {
|
||||
return { summary: `This will always allow ${action} for this project.`, patterns: [] }
|
||||
return { summary: `This will always allow ${getPermissionPhrase(action)} for this project.`, patterns: [] }
|
||||
}
|
||||
return { summary: 'This will always allow the following patterns for this project.', patterns: save }
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user