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

Function CodeMethod

packages/tui/src/component/dialog-provider.tsx:314–350  ·  view source on GitHub ↗
(props: CodeMethodProps)

Source from the content-addressed store, hash-verified

312 authorization: ProviderAuthAuthorization
313}
314function CodeMethod(props: CodeMethodProps) {
315 const { theme } = useTheme()
316 const sdk = useSDK()
317 const sync = useSync()
318 const dialog = useDialog()
319 const [error, setError] = createSignal(false)
320
321 return (
322 <DialogPrompt
323 title={props.title}
324 placeholder="Authorization code"
325 onConfirm={async (value) => {
326 const { error } = await sdk.client.provider.oauth.callback({
327 providerID: props.providerID,
328 method: props.index,
329 code: value,
330 })
331 if (!error) {
332 await sdk.client.instance.dispose()
333 await sync.bootstrap()
334 dialog.replace(() => <DialogModel providerID={props.providerID} />)
335 return
336 }
337 setError(true)
338 }}
339 description={() => (
340 <box gap={1}>
341 <text fg={theme.textMuted}>{props.authorization.instructions}</text>
342 <Link href={props.authorization.url} fg={theme.primary} />
343 <Show when={error()}>
344 <text fg={theme.error}>Invalid code</text>
345 </Show>
346 </box>
347 )}
348 />
349 )
350}
351
352interface ApiMethodProps {
353 providerID: string

Callers

nothing calls this directly

Calls 5

useSyncFunction · 0.90
useDialogFunction · 0.90
errorFunction · 0.50
callbackMethod · 0.45
disposeMethod · 0.45

Tested by

no test coverage detected