Fix shutdown handling, error management, and process lifecycle issues

🤖 Generated with [OpenCode](https://opencode.ai)

Co-Authored-By: OpenCode <noreply@opencode.ai>
This commit is contained in:
Dax Raad
2025-06-10 18:58:47 -04:00
parent ca3c22dc12
commit 28f5cbbfe9
7 changed files with 89 additions and 66 deletions

View File

@@ -6,6 +6,7 @@ import * as prompts from "@clack/prompts"
import open from "open"
import { VERSION } from "../version"
import { Provider } from "../../provider/provider"
import { UI } from "../ui"
export const ProviderCommand = cmd({
command: "provider",
@@ -62,7 +63,7 @@ export const ProviderAddCommand = cmd({
},
],
})
if (prompts.isCancel(provider)) return
if (prompts.isCancel(provider)) throw new UI.CancelledError({})
if (provider === "anthropic") {
const method = await prompts.select({
@@ -78,7 +79,7 @@ export const ProviderAddCommand = cmd({
},
],
})
if (prompts.isCancel(method)) return
if (prompts.isCancel(method)) throw new UI.CancelledError({})
if (method === "oauth") {
// some weird bug where program exits without this
@@ -92,7 +93,8 @@ export const ProviderAddCommand = cmd({
message: "Paste the authorization code here: ",
validate: (x) => (x.length > 0 ? undefined : "Required"),
})
if (prompts.isCancel(code)) return
if (prompts.isCancel(code)) throw new UI.CancelledError({})
await AuthAnthropic.exchange(code, verifier)
.then(() => {
prompts.log.success("Login successful")
@@ -109,7 +111,7 @@ export const ProviderAddCommand = cmd({
message: "Enter your API key",
validate: (x) => (x.length > 0 ? undefined : "Required"),
})
if (prompts.isCancel(key)) return
if (prompts.isCancel(key)) throw new UI.CancelledError({})
await AuthKeys.set(provider, key)
prompts.outro("Done")