Skip to content

Commit 43efbd6

Browse files
committed
feat(provider): notify user via toast when AWS SSO re-authentication triggers
1 parent 7c0b699 commit 43efbd6

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

@@ -297,10 +299,24 @@ function custom(dep: CustomDep): Record<string, CustomLoader> {
297299
return await rawProvider()
298300
} catch (e) {
299301
if (e instanceof Error && e.name === "CredentialsProviderError") {
302+
void Bus.publish(TuiEvent.ToastShow, {
303+
variant: "warning",
304+
message: "AWS SSO session expired — re-authenticating...",
305+
})
300306
await new Promise<void>((resolve, reject) => {
301307
const args = ["sso", "login", ...(profile ? ["--profile", profile] : [])]
302308
const child = spawn("aws", args, { stdio: "pipe" })
303-
child.on("exit", (code) => (code === 0 ? resolve() : reject(e)))
309+
child.on("exit", (code) => {
310+
if (code === 0) {
311+
void Bus.publish(TuiEvent.ToastShow, {
312+
variant: "success",
313+
message: "AWS SSO re-authentication successful",
314+
})
315+
resolve()
316+
} else {
317+
reject(e)
318+
}
319+
})
304320
child.on("error", () => reject(e))
305321
})
306322
return await rawProvider()

0 commit comments

Comments
 (0)