on main help sign in
fix(agent): move reauth notification from agent to coordinator
23157b6Kieran Klukas
internal/agent/agent.go−8
@@ -641,14 +641,6 @@ func (a *sessionAgent) Run(ctx context.Context, call SessionAgentCall) (result *
641 currentAssistant.AddFinish(message.FinishReasonCanceled, "User canceled request", "")
641 currentAssistant.AddFinish(message.FinishReasonCanceled, "User canceled request", "")
642 } else if isHyper && errors.As(err, &providerErr) && providerErr.StatusCode == http.StatusUnauthorized {
642 } else if isHyper && errors.As(err, &providerErr) && providerErr.StatusCode == http.StatusUnauthorized {
643 currentAssistant.AddFinish(message.FinishReasonError, "Unauthorized", `Please re-authenticate with Hyper. You can also run "crush auth" to re-authenticate.`)
643 currentAssistant.AddFinish(message.FinishReasonError, "Unauthorized", `Please re-authenticate with Hyper. You can also run "crush auth" to re-authenticate.`)
644− if a.notify != nil {
645− a.notify.Publish(pubsub.CreatedEvent, notify.Notification{
646− SessionID: call.SessionID,
647− SessionTitle: currentSession.Title,
648− Type: notify.TypeReAuthenticate,
649− ProviderID: largeModel.ModelCfg.Provider,
650− })
651− }
652 } else if isHyper && errors.As(err, &providerErr) && providerErr.StatusCode == http.StatusPaymentRequired {
644 } else if isHyper && errors.As(err, &providerErr) && providerErr.StatusCode == http.StatusPaymentRequired {
653 url := hyper.BaseURL()
645 url := hyper.BaseURL()
654 link := linkStyle.Hyperlink(url, "id=hyper").Render(url)
646 link := linkStyle.Hyperlink(url, "id=hyper").Render(url)
internal/agent/coordinator.go+6
@@ -266,6 +266,12 @@ func (c *coordinator) Run(ctx context.Context, sessionID string, prompt string,
266 if err := c.retryAfterUnauthorized(ctx, providerCfg); err == nil {
266 if err := c.retryAfterUnauthorized(ctx, providerCfg); err == nil {
267 result, originalErr = run()
267 result, originalErr = run()
268 }
268 }
269+ if c.notify != nil && model.ModelCfg.Provider == hyper.Name {
270+ c.notify.Publish(pubsub.CreatedEvent, notify.Notification{
271+ Type: notify.TypeReAuthenticate,
272+ ProviderID: model.ModelCfg.Provider,
273+ })
274+ }
269 }
275 }
270
276
271 if hasLatest && c.runComplete != nil {
277 if hasLatest && c.runComplete != nil {