Say on the Profile page that drafting from the website needs an AI provider
The Draft button is disabled, with a link to Settings → AI provider, until one is set up; the Overview lists the AI provider first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ type profileData struct {
|
||||
Websites []profile.Website // existing plus one blank row
|
||||
Drafted bool
|
||||
DraftURL string
|
||||
NoAI bool // no AI provider yet: drafting from the website can't work
|
||||
}
|
||||
|
||||
func withBlankRows(p *profile.Profile) profileData {
|
||||
@@ -34,6 +35,7 @@ func (s *Server) profilePage(w http.ResponseWriter, r *http.Request) {
|
||||
if len(p.Websites) > 0 {
|
||||
d.DraftURL = p.Websites[0].URL
|
||||
}
|
||||
d.NoAI = !s.aiReady()
|
||||
s.render(w, r, "profile", page{Title: "Company profile", Nav: "profile", Data: d})
|
||||
}
|
||||
|
||||
@@ -129,6 +131,7 @@ func (s *Server) profileDraft(w http.ResponseWriter, r *http.Request) {
|
||||
d := withBlankRows(p)
|
||||
d.Drafted = drafted
|
||||
d.DraftURL = siteURL
|
||||
d.NoAI = !s.aiReady()
|
||||
s.render(w, r, "profile", page{Title: "Company profile", Nav: "profile", Error: errMsg, Data: d})
|
||||
}
|
||||
|
||||
@@ -190,3 +193,13 @@ func merge(cur, draft *profile.Profile) *profile.Profile {
|
||||
out.Accounts.LinkedIn = pick(cur.Accounts.LinkedIn, draft.Accounts.LinkedIn)
|
||||
return &out
|
||||
}
|
||||
|
||||
// aiReady reports whether an AI provider is set up.
|
||||
func (s *Server) aiReady() bool {
|
||||
cfg, err := ai.LoadConfig(s.DB)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
_, err = ai.New(cfg, s.Secrets)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user