File tree Expand file tree Collapse file tree
mobile/src/features/threads
provider-opencode/src/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { RequestActionButton } from "./RequestActionButton" ;
2+ import { approvalRequestLabel } from "@t3tools/client-runtime/state/thread-requests" ;
23import { approvalCommandDisplayText } from "@t3tools/client-runtime/work-log/command-label" ;
34import type {
45 ProviderApprovalDecision ,
@@ -38,7 +39,7 @@ export function PendingApprovalCard(props: PendingApprovalCardProps) {
3839 Approval needed
3940 </ Text >
4041 < Text className = "font-t3-bold text-lg text-foreground" >
41- { props . approval . appName ?? props . approval . requestKind }
42+ { props . approval . appName ?? approvalRequestLabel ( props . approval . requestKind ) }
4243 </ Text >
4344 { props . approval . title && ! props . approval . appName ? (
4445 < Text className = "font-sans text-sm leading-normal text-foreground-secondary" >
Original file line number Diff line number Diff line change 1+ import { approvalRequestLabel } from "@t3tools/client-runtime/state/thread-requests" ;
12import { approvalCommandDisplayText } from "@t3tools/client-runtime/work-log/command-label" ;
23import { memo } from "react" ;
34import { type PendingApproval } from "../../session-logic" ;
@@ -15,16 +16,7 @@ export const ComposerPendingApprovalPanel = memo(function ComposerPendingApprova
1516 className,
1617} : ComposerPendingApprovalPanelProps ) {
1718 const Detail = approval . requestKind === "mcp-elicitation" ? "span" : "code" ;
18- const fallbackLabel =
19- approval . requestKind === "mcp-elicitation"
20- ? "App access approval"
21- : approval . requestKind === "command"
22- ? "Command approval"
23- : approval . requestKind === "file-read"
24- ? "File read approval"
25- : approval . requestKind === "permission"
26- ? "App permission approval"
27- : "File change approval" ;
19+ const fallbackLabel = approvalRequestLabel ( approval . requestKind ) ;
2820 const detailAriaLabel =
2921 approval . requestKind === "mcp-elicitation"
3022 ? "App access request"
Original file line number Diff line number Diff line change @@ -8,6 +8,19 @@ import type {
88} from "@t3tools/contracts" ;
99import * as DateTime from "effect/DateTime" ;
1010
11+ const APPROVAL_REQUEST_LABELS : Record < ProviderRequestKind , string > = {
12+ command : "Command approval" ,
13+ "file-read" : "File read approval" ,
14+ "file-change" : "File change approval" ,
15+ "mcp-elicitation" : "App access approval" ,
16+ permission : "App permission approval" ,
17+ } ;
18+
19+ /** Names an approval card by what it asks for; web and mobile show the same words. */
20+ export function approvalRequestLabel ( requestKind : ProviderRequestKind ) : string {
21+ return APPROVAL_REQUEST_LABELS [ requestKind ] ;
22+ }
23+
1124export interface ThreadPendingApproval {
1225 readonly requestId : RuntimeRequestId ;
1326 readonly requestKind : ProviderRequestKind ;
Original file line number Diff line number Diff line change @@ -1783,19 +1783,23 @@ export const makeOpenCodeAdapterV2 = Effect.fn("makeOpenCodeAdapterV2")(function
17831783 throw protocolError ( `OpenCode request ${ pending . requestId } has no native payload` ) ;
17841784 }
17851785 // Patterns split a pipeline into its commands; the command keeps it whole.
1786- const command = permission . metadata . command ;
1786+ const command =
1787+ typeof permission . metadata . command === "string" &&
1788+ permission . metadata . command . trim ( ) . length > 0
1789+ ? permission . metadata . command
1790+ : undefined ;
17871791 return {
17881792 ...base ,
1789- title : permission . permission ,
1793+ // A title explains a request; "bash" beside its own command explains nothing.
1794+ title : command === undefined ? permission . permission : null ,
17901795 type : "approval_request" ,
17911796 requestId : pending . requestId ,
17921797 requestKind : pending . requestKind === "user_input" ? "command" : pending . requestKind ,
17931798 prompt :
1794- typeof command === "string" && command . trim ( ) . length > 0
1795- ? command
1796- : permission . patterns . length === 0
1797- ? permission . permission
1798- : permission . patterns . join ( "\n" ) ,
1799+ command ??
1800+ ( permission . patterns . length === 0
1801+ ? permission . permission
1802+ : permission . patterns . join ( "\n" ) ) ,
17991803 } ;
18001804 } ;
18011805
Original file line number Diff line number Diff line change @@ -398,8 +398,10 @@ interface PendingPiPrompt {
398398 readonly turnItem : OrchestrationV2TurnItem ;
399399}
400400
401+ const PI_TOOL_GATE_TITLE = / ^ A l l o w ( \S + ) \? $ / ;
402+
401403function piApprovalRequestKind ( title : string ) : "command" | "file-change" {
402- const toolName = / ^ A l l o w ( \S + ) \? $ / . exec ( title ) ?. [ 1 ] ;
404+ const toolName = PI_TOOL_GATE_TITLE . exec ( title ) ?. [ 1 ] ;
403405 return toolName !== undefined &&
404406 ( PI_FILE_CHANGE_TOOLS as ReadonlyArray < string > ) . includes ( toolName )
405407 ? "file-change"
@@ -1324,6 +1326,8 @@ export const makePiAdapterV2 = Effect.fn("makePiAdapterV2")(function* (
13241326 method === "confirm"
13251327 ? {
13261328 ...itemBase ,
1329+ // The tool gate's "Allow bash?" restates the card; other confirms keep their question.
1330+ title : PI_TOOL_GATE_TITLE . test ( title ) ? null : title ,
13271331 type : "approval_request" ,
13281332 requestId,
13291333 requestKind : piApprovalRequestKind ( title ) ,
You can’t perform that action at this time.
0 commit comments