MCPcopy
hub / github.com/anomalyco/opencode / AutoMethod

Function AutoMethod

packages/tui/src/component/dialog-provider.tsx:239–306  ·  view source on GitHub ↗
(props: AutoMethodProps)

Source from the content-addressed store, hash-verified

237 authorization: ProviderAuthAuthorization
238}
239function AutoMethod(props: AutoMethodProps) {
240 const { theme } = useTheme()
241 const sdk = useSDK()
242 const dialog = useDialog()
243 const sync = useSync()
244 const toast = useToast()
245 const clipboard = useClipboard()
246
247 useBindings(() => ({
248 bindings: [
249 {
250 key: "c",
251 desc: "Copy provider code",
252 group: "Dialog",
253 cmd: () => {
254 const code =
255 props.authorization.instructions.match(/[A-Z0-9]{4}-[A-Z0-9]{4,5}/)?.[0] ?? props.authorization.url
256 clipboard
257 .write?.(code)
258 .then(() => toast.show({ message: "Copied to clipboard", variant: "info" }))
259 .catch(toast.error)
260 },
261 },
262 ],
263 }))
264
265 onMount(async () => {
266 const result = await sdk.client.provider.oauth.callback({
267 providerID: props.providerID,
268 method: props.index,
269 })
270 if (result.error) {
271 toast.show({
272 variant: "error",
273 message:
274 "name" in result.error && result.error.name === "ProviderAuthOauthCallbackFailed"
275 ? "OAuth authorization failed. Try /connect again."
276 : JSON.stringify(result.error),
277 })
278 dialog.clear()
279 return
280 }
281 await sdk.client.instance.dispose()
282 await sync.bootstrap()
283 dialog.replace(() => <DialogModel providerID={props.providerID} />)
284 })
285
286 return (
287 <box paddingLeft={2} paddingRight={2} gap={1} paddingBottom={1}>
288 <box flexDirection="row" justifyContent="space-between">
289 <text attributes={TextAttributes.BOLD} fg={theme.text}>
290 {props.title}
291 </text>
292 <text fg={theme.textMuted} onMouseUp={() => dialog.clear()}>
293 esc
294 </text>
295 </box>
296 <box gap={1}>

Callers

nothing calls this directly

Calls 8

useDialogFunction · 0.90
useSyncFunction · 0.90
useToastFunction · 0.90
useClipboardFunction · 0.90
writeMethod · 0.80
callbackMethod · 0.45
clearMethod · 0.45
disposeMethod · 0.45

Tested by

no test coverage detected