Add HasLLM flag to control LLM-specific UI sectionsUnverified
9755234 parent: 01468b3 modified
internal/server/server.go +5 -0 | @@ -587,6 +587,8 @@ func (s *Server) render(w http.ResponseWriter, r *http.Request, name string, dat | ||
| 587 | 587 | data = map[string]any{} |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | + data["HasLLM"] = s.llm != nil | |
| 591 | + | |
| 590 | 592 | if cookie, err := r.Cookie("glean_csrf"); err == nil { |
| 591 | 593 | data["CSRFToken"] = cookie.Value |
| 592 | 594 | } |
| @@ -621,6 +623,9 @@ func (s *Server) render(w http.ResponseWriter, r *http.Request, name string, dat | ||
| 621 | 623 | if csrf, ok := data["CSRFToken"]; ok { |
| 622 | 624 | baseData["CSRFToken"] = csrf |
| 623 | 625 | } |
| 626 | + if hasLLM, ok := data["HasLLM"]; ok { | |
| 627 | + baseData["HasLLM"] = hasLLM | |
| 628 | + } | |
| 624 | 629 | } |
| 625 | 630 | |
| 626 | 631 | if err := s.templates.ExecuteTemplate(w, "base.html", baseData); err != nil { |
| @@ -587,6 +587,8 @@ func (s *Server) render(w http.ResponseWriter, r *http.Request, name string, dat | |||
| 587 | data = map[string]any{} | 587 | data = map[string]any{} |
| 588 | } | 588 | } |
| 589 | 589 | ||
| 590 | + data["HasLLM"] = s.llm != nil | ||
| 591 | + | ||
| 590 | if cookie, err := r.Cookie("glean_csrf"); err == nil { | 592 | if cookie, err := r.Cookie("glean_csrf"); err == nil { |
| 591 | data["CSRFToken"] = cookie.Value | 593 | data["CSRFToken"] = cookie.Value |
| 592 | } | 594 | } |
| @@ -621,6 +623,9 @@ func (s *Server) render(w http.ResponseWriter, r *http.Request, name string, dat | |||
| 621 | if csrf, ok := data["CSRFToken"]; ok { | 623 | if csrf, ok := data["CSRFToken"]; ok { |
| 622 | baseData["CSRFToken"] = csrf | 624 | baseData["CSRFToken"] = csrf |
| 623 | } | 625 | } |
| 626 | + if hasLLM, ok := data["HasLLM"]; ok { | ||
| 627 | + baseData["HasLLM"] = hasLLM | ||
| 628 | + } | ||
| 624 | } | 629 | } |
| 625 | 630 | ||
| 626 | if err := s.templates.ExecuteTemplate(w, "base.html", baseData); err != nil { | 631 | if err := s.templates.ExecuteTemplate(w, "base.html", baseData); err != nil { |
modified
internal/tmpl/dashboard.html +1 -19 | @@ -38,7 +38,7 @@ | ||
| 38 | 38 | </div> |
| 39 | 39 | {{end}} |
| 40 | 40 | |
| 41 | -{{if .DigestEnabled}} | |
| 41 | +{{if and .DigestEnabled .HasLLM}} | |
| 42 | 42 | <div id="digest" hx-get="/digest" hx-trigger="load" hx-swap="innerHTML" hx-indicator="#digest"> |
| 43 | 43 | <div class="mb-6"> |
| 44 | 44 | <h2 class="text-lg font-semibold text-spot-text mb-4">Daily digest</h2> |
| @@ -82,24 +82,6 @@ | ||
| 82 | 82 | </div> |
| 83 | 83 | {{end}} |
| 84 | 84 | |
| 85 | -{{if and .DigestEnabled (gt .UnreadCount 0)}} | |
| 86 | -<div id="digest" hx-get="/digest" hx-trigger="load" hx-swap="innerHTML" hx-indicator="#digest"> | |
| 87 | - <div class="mb-6"> | |
| 88 | - <h2 class="text-lg font-semibold text-spot-text mb-4">Daily digest</h2> | |
| 89 | - <div class="animate-pulse bg-spot-surface rounded-xl px-5 py-4"> | |
| 90 | - <div class="flex items-start gap-2.5"> | |
| 91 | - <div class="w-4 h-4 bg-spot-hover rounded shrink-0 mt-0.5"></div> | |
| 92 | - <div class="flex-1 space-y-2"> | |
| 93 | - <div class="h-4 bg-spot-hover rounded w-2/3"></div> | |
| 94 | - <div class="h-3 bg-spot-hover rounded w-full"></div> | |
| 95 | - <div class="h-3 bg-spot-hover rounded w-4/5"></div> | |
| 96 | - </div> | |
| 97 | - </div> | |
| 98 | - </div> | |
| 99 | - </div> | |
| 100 | -</div> | |
| 101 | -{{end}} | |
| 102 | - | |
| 103 | 85 | <div class="mb-8"> |
| 104 | 86 | <h2 class="text-lg font-semibold text-spot-text mb-4">Unread articles</h2> |
| 105 | 87 | <div class="bg-spot-surface rounded-2xl py-14 px-6 text-center"> |
| @@ -38,7 +38,7 @@ | |||
| 38 | </div> | 38 | </div> |
| 39 | {{end}} | 39 | {{end}} |
| 40 | 40 | ||
| 41 | -{{if .DigestEnabled}} | 41 | +{{if and .DigestEnabled .HasLLM}} |
| 42 | <div id="digest" hx-get="/digest" hx-trigger="load" hx-swap="innerHTML" hx-indicator="#digest"> | 42 | <div id="digest" hx-get="/digest" hx-trigger="load" hx-swap="innerHTML" hx-indicator="#digest"> |
| 43 | <div class="mb-6"> | 43 | <div class="mb-6"> |
| 44 | <h2 class="text-lg font-semibold text-spot-text mb-4">Daily digest</h2> | 44 | <h2 class="text-lg font-semibold text-spot-text mb-4">Daily digest</h2> |
| @@ -82,24 +82,6 @@ | |||
| 82 | </div> | 82 | </div> |
| 83 | {{end}} | 83 | {{end}} |
| 84 | 84 | ||
| 85 | -{{if and .DigestEnabled (gt .UnreadCount 0)}} | ||
| 86 | -<div id="digest" hx-get="/digest" hx-trigger="load" hx-swap="innerHTML" hx-indicator="#digest"> | ||
| 87 | - <div class="mb-6"> | ||
| 88 | - <h2 class="text-lg font-semibold text-spot-text mb-4">Daily digest</h2> | ||
| 89 | - <div class="animate-pulse bg-spot-surface rounded-xl px-5 py-4"> | ||
| 90 | - <div class="flex items-start gap-2.5"> | ||
| 91 | - <div class="w-4 h-4 bg-spot-hover rounded shrink-0 mt-0.5"></div> | ||
| 92 | - <div class="flex-1 space-y-2"> | ||
| 93 | - <div class="h-4 bg-spot-hover rounded w-2/3"></div> | ||
| 94 | - <div class="h-3 bg-spot-hover rounded w-full"></div> | ||
| 95 | - <div class="h-3 bg-spot-hover rounded w-4/5"></div> | ||
| 96 | - </div> | ||
| 97 | - </div> | ||
| 98 | - </div> | ||
| 99 | - </div> | ||
| 100 | -</div> | ||
| 101 | -{{end}} | ||
| 102 | - | ||
| 103 | <div class="mb-8"> | 85 | <div class="mb-8"> |
| 104 | <h2 class="text-lg font-semibold text-spot-text mb-4">Unread articles</h2> | 86 | <h2 class="text-lg font-semibold text-spot-text mb-4">Unread articles</h2> |
| 105 | <div class="bg-spot-surface rounded-2xl py-14 px-6 text-center"> | 87 | <div class="bg-spot-surface rounded-2xl py-14 px-6 text-center"> |
modified
internal/tmpl/profile.html +2 -0 | @@ -23,6 +23,7 @@ | ||
| 23 | 23 | </div> |
| 24 | 24 | |
| 25 | 25 | {{if eq .ProfileUser.DID .CurrentUserDID}} |
| 26 | + {{if .HasLLM}} | |
| 26 | 27 | <h2 class="text-sm font-bold text-spot-text uppercase tracking-wide mb-3">Settings</h2> |
| 27 | 28 | <div class="bg-spot-surface rounded-xl p-5 mb-6 space-y-5"> |
| 28 | 29 | <form hx-post="/settings/digest-enabled" hx-swap="none" hx-on::after-request="location.reload()"> |
| @@ -64,6 +65,7 @@ | ||
| 64 | 65 | </div> |
| 65 | 66 | </div> |
| 66 | 67 | {{end}} |
| 68 | + {{end}} | |
| 67 | 69 | |
| 68 | 70 | <h2 class="text-sm font-bold text-spot-text uppercase tracking-wide mb-3">Feeds</h2> |
| 69 | 71 | <div class="bg-spot-surface rounded-xl divide-y divide-spot-divider mb-6 overflow-hidden"> |
| @@ -23,6 +23,7 @@ | |||
| 23 | </div> | 23 | </div> |
| 24 | 24 | ||
| 25 | {{if eq .ProfileUser.DID .CurrentUserDID}} | 25 | {{if eq .ProfileUser.DID .CurrentUserDID}} |
| 26 | + {{if .HasLLM}} | ||
| 26 | <h2 class="text-sm font-bold text-spot-text uppercase tracking-wide mb-3">Settings</h2> | 27 | <h2 class="text-sm font-bold text-spot-text uppercase tracking-wide mb-3">Settings</h2> |
| 27 | <div class="bg-spot-surface rounded-xl p-5 mb-6 space-y-5"> | 28 | <div class="bg-spot-surface rounded-xl p-5 mb-6 space-y-5"> |
| 28 | <form hx-post="/settings/digest-enabled" hx-swap="none" hx-on::after-request="location.reload()"> | 29 | <form hx-post="/settings/digest-enabled" hx-swap="none" hx-on::after-request="location.reload()"> |
| @@ -64,6 +65,7 @@ | |||
| 64 | </div> | 65 | </div> |
| 65 | </div> | 66 | </div> |
| 66 | {{end}} | 67 | {{end}} |
| 68 | + {{end}} | ||
| 67 | 69 | ||
| 68 | <h2 class="text-sm font-bold text-spot-text uppercase tracking-wide mb-3">Feeds</h2> | 70 | <h2 class="text-sm font-bold text-spot-text uppercase tracking-wide mb-3">Feeds</h2> |
| 69 | <div class="bg-spot-surface rounded-xl divide-y divide-spot-divider mb-6 overflow-hidden"> | 71 | <div class="bg-spot-surface rounded-xl divide-y divide-spot-divider mb-6 overflow-hidden"> |