Skip to content

Commit 78690eb

Browse files
committed
feat(provider): notify user via toast when AWS SSO re-authentication triggers
1 parent 8cbdba6 commit 78690eb

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

packages/opencode/src/provider/provider.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import { withStatics } from "@/util/schema"
2929

3030
import * as ProviderTransform from "./transform"
3131
import { ModelID, ProviderID } from "./schema"
32+
import { Bus } from "@/bus"
33+
import { TuiEvent } from "@/cli/cmd/tui/event"
3234

3335
const log = Log.create({ service: "provider" })
3436

@@ -316,10 +318,24 @@ function custom(dep: CustomDep): Record<string, CustomLoader> {
316318
return await rawProvider()
317319
} catch (e) {
318320
if (e instanceof Error && e.name === "CredentialsProviderError") {
321+
void Bus.publish(TuiEvent.ToastShow, {
322+
variant: "warning",
323+
message: "AWS SSO session expired — re-authenticating...",
324+
})
319325
await new Promise<void>((resolve, reject) => {
320326
const args = ["sso", "login", ...(profile ? ["--profile", profile] : [])]
321327
const child = spawn("aws", args, { stdio: "pipe" })
322-
child.on("exit", (code) => (code === 0 ? resolve() : reject(e)))
328+
child.on("exit", (code) => {
329+
if (code === 0) {
330+
void Bus.publish(TuiEvent.ToastShow, {
331+
variant: "success",
332+
message: "AWS SSO re-authentication successful",
333+
})
334+
resolve()
335+
} else {
336+
reject(e)
337+
}
338+
})
323339
child.on("error", () => reject(e))
324340
})
325341
return await rawProvider()

0 commit comments

Comments
 (0)