File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
packages/opencode/src/cli/cmd/tui/component Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ import { useTheme } from "../context/theme"
1010import { TextAttributes } from "@opentui/core"
1111import type { ProviderAuthAuthorization } from "@opencode-ai/sdk/v2"
1212import { DialogModel } from "./dialog-model"
13+ import { useKeyboard } from "@opentui/solid"
14+ import { Clipboard } from "@tui/util/clipboard"
15+ import { useToast } from "../ui/toast"
1316
1417const PROVIDER_PRIORITY : Record < string , number > = {
1518 opencode : 0 ,
@@ -104,6 +107,17 @@ function AutoMethod(props: AutoMethodProps) {
104107 const sdk = useSDK ( )
105108 const dialog = useDialog ( )
106109 const sync = useSync ( )
110+ const toast = useToast ( )
111+
112+ useKeyboard ( ( evt ) => {
113+ if ( evt . name === "c" && ! evt . ctrl && ! evt . meta ) {
114+ const code =
115+ props . authorization . instructions . match ( / [ A - Z 0 - 9 ] { 4 } - [ A - Z 0 - 9 ] { 4 } / ) ?. [ 0 ] ?? props . authorization . instructions
116+ Clipboard . copy ( code )
117+ . then ( ( ) => toast . show ( { message : "Copied to clipboard" , variant : "info" } ) )
118+ . catch ( toast . error )
119+ }
120+ } )
107121
108122 onMount ( async ( ) => {
109123 const result = await sdk . client . provider . oauth . callback ( {
@@ -132,6 +146,9 @@ function AutoMethod(props: AutoMethodProps) {
132146 < text fg = { theme . textMuted } > { props . authorization . instructions } </ text >
133147 </ box >
134148 < text fg = { theme . textMuted } > Waiting for authorization...</ text >
149+ < text fg = { theme . text } >
150+ c < span style = { { fg : theme . textMuted } } > copy</ span >
151+ </ text >
135152 </ box >
136153 )
137154}
You can’t perform that action at this time.
0 commit comments