1+ import { Option , Schema } from "effect"
12import { For , Show } from "solid-js"
23import type { PermissionRequest } from "@opencode/client/promise"
34import { Button } from "@opencode/ui/button"
45import { DockPrompt } from "@opencode/session-ui/dock-prompt"
56import { Icon } from "@opencode/ui/icon"
67import { useLanguage } from "@/runtime/i18n/language"
78
9+ const decodeToolInput = Schema . decodeUnknownOption ( Schema . Record ( Schema . String , Schema . Unknown ) )
10+
11+ const isString = Schema . is ( Schema . String )
12+
813export function SessionPermissionDock ( props : {
914 request : PermissionRequest
1015 responding : boolean
@@ -14,20 +19,20 @@ export function SessionPermissionDock(props: {
1419
1520 const toolDescription = ( ) => {
1621 const key = `settings.permissions.tool.${ props . request . action } .description`
22+ // SAFETY: an action without a curated description returns the key itself, which the check below detects.
1723 const value = language . t ( key as Parameters < typeof language . t > [ 0 ] )
1824
1925 if ( value === key ) return ""
2026
2127 return value
2228 }
2329
24- const input = ( ) => {
25- const value = props . request . metadata ?. input
26- if ( ! value || typeof value !== "object" ) return [ ]
27- return Object . entries ( value ) . map (
28- ( [ key , item ] ) => `${ key } : ${ typeof item === "string" ? item : JSON . stringify ( item ) } ` ,
29- )
30- }
30+ const input = ( ) =>
31+ Option . match ( decodeToolInput ( props . request . metadata ?. input ) , {
32+ onNone : ( ) => [ ] ,
33+ onSome : ( value ) =>
34+ Object . entries ( value ) . map ( ( [ key , item ] ) => `${ key } : ${ isString ( item ) ? item : JSON . stringify ( item ) } ` ) ,
35+ } )
3136
3237 return (
3338 < DockPrompt
@@ -64,7 +69,7 @@ export function SessionPermissionDock(props: {
6469 >
6570 < div data-slot = "permission-row" >
6671 < span data-slot = "permission-spacer" aria-hidden = "true" />
67- < Show when = { toolDescription ( ) } fallback = { < code data-slot = "permission-hint " > { props . request . action } </ code > } >
72+ < Show when = { toolDescription ( ) } fallback = { < code data-slot = "permission-action " > { props . request . action } </ code > } >
6873 < div data-slot = "permission-hint" > { toolDescription ( ) } </ div >
6974 </ Show >
7075 </ div >
0 commit comments