🐛 Fix show red bullet in workspace menu if mcp key is expired (#8727)

This commit is contained in:
Luis de Dios 2026-03-24 12:27:09 +01:00 committed by GitHub
parent 5a73003c7f
commit 5f722d9183
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 6 deletions

View File

@ -48,7 +48,7 @@
(def schema:props
[:map {:title "ProfileProps"}
[:plugins {:optional true} schema:plugin-registry]
[:mcp-status {:optional true} ::sm/boolean]
[:mcp-enabled {:optional true} ::sm/boolean]
[:newsletter-updates {:optional true} ::sm/boolean]
[:newsletter-news {:optional true} ::sm/boolean]
[:onboarding-team-id {:optional true} ::sm/uuid]

View File

@ -340,7 +340,10 @@
(rx/of (ntf/hide)
(dcmt/retrieve-comment-threads file-id)
(dcmt/fetch-profiles)
(df/fetch-fonts team-id)))
(df/fetch-fonts team-id))
(when (contains? cf/flags :mcp)
(rx/of (du/fetch-access-tokens))))
;; Once the essential data is fetched, lets proceed to
;; fetch teh file bunldle

View File

@ -10,6 +10,7 @@
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cfh]
[app.common.time :as ct]
[app.common.uuid :as uuid]
[app.config :as cf]
[app.main.data.common :as dcm]
@ -42,9 +43,13 @@
[app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd]
[beicon.v2.core :as rx]
[okulary.core :as l]
[potok.v2.core :as ptk]
[rumext.v2 :as mf]))
(def tokens-ref
(l/derived :access-tokens st/state))
(mf/defc shortcuts*
{::mf/private true}
[{:keys [id]}]
@ -978,10 +983,21 @@
:class (stl/css :item-arrow)}]])
(when (contains? cf/flags :mcp)
(let [mcp-enabled? (true? (-> profile :props :mcp-enabled))
(let [tokens (mf/deref tokens-ref)
expired? (some->> tokens
(some #(when (= (:type %) "mcp") %))
:expires-at
(> (ct/now)))
mcp-enabled? (true? (-> profile :props :mcp-enabled))
mcp-connection (-> workspace-local :mcp :connection)
mcp-connected? (= mcp-connection "connected")
mcp-error? (= mcp-connection "error")]
mcp-error? (= mcp-connection "error")
active? (and mcp-enabled? mcp-connected?)
failed? (or (and mcp-enabled? mcp-error?)
(true? expired?))]
[:> dropdown-menu-item* {:class (stl/css :base-menu-item :menu-item)
:on-click on-menu-click
:on-key-down (fn [event]
@ -993,8 +1009,8 @@
[:span {:class (stl/css :item-name)}
(tr "workspace.header.menu.option.mcp")]
[:span {:class (stl/css-case :item-indicator true
:active (and mcp-enabled? mcp-connected?)
:failed (and mcp-enabled? mcp-error?))}]
:active active?
:failed failed?)}]
[:> icon* {:icon-id i/arrow-right
:class (stl/css :item-arrow)}]]))