Skip to content

Commit 88cb2bb

Browse files
committed
fix(tui): enable copy-on-select in permission prompt
The permission prompt's expanded (ctrl+f) view renders via Portal, which sits outside the root box's onMouseUp handler. Add an onMouseUp copy-on-select handler directly on the prompt's content box so clipboard copy works in both inline and fullscreen views.
1 parent d010485 commit 88cb2bb

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎packages/tui/src/routes/session/permission.tsx‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ import { useTuiConfig } from "../../config"
1717
import{OPENCODE_BASE_MODE,useBindings,useCommandShortcut}from"../../keymap"
1818
import{usePathFormatter}from"../../context/path-format"
1919
import{useDialog}from"../../ui/dialog"
20+
import{useClipboard}from"../../context/clipboard"
21+
import{useToast}from"../../ui/toast"
22+
import{Selection}from"../../util/selection"
23+
import{Flag}from"@opencode-ai/core/flag/flag"
2024

2125
typePermissionStage="permission"|"always"|"reject"
2226

@@ -601,6 +605,8 @@ function Prompt<const T extends Record<string, string>>(props: {
601605
})
602606
constnarrow=createMemo(()=>dimensions().width<80)
603607
constfullscreenHint=useCommandShortcut("permission.prompt.fullscreen")
608+
constclipboard=useClipboard()
609+
consttoast=useToast()
604610

605611
useBindings(()=>({
606612
mode: OPENCODE_BASE_MODE,
@@ -687,14 +693,19 @@ function Prompt<const T extends Record<string, string>>(props: {
687693
}))
688694

689695
consthint=createMemo(()=>(store.expanded ? "minimize" : "fullscreen"))
690-
useRenderer()
696+
constrenderer=useRenderer()
691697

692698
constcontent=()=>(
693699
<box
694700
backgroundColor={theme.backgroundPanel}
695701
border={["left"]}
696702
borderColor={theme.warning}
697703
customBorderChars={SplitBorder.customBorderChars}
704+
onMouseUp={
705+
!Flag.OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT
706+
? ()=>Selection.copy(renderer,toast,clipboard)
707+
: undefined
708+
}
698709
{...(store.expanded
699710
? {top: dimensions().height*-1+1,bottom: 1,left: 2,right: 2,position: "absolute"}
700711
: {

0 commit comments

Comments
 (0)