From 5f722d9183da4790ba2d52f62546c0d82b55c356 Mon Sep 17 00:00:00 2001 From: Luis de Dios Date: Tue, 24 Mar 2026 12:27:09 +0100 Subject: [PATCH] :bug: Fix show red bullet in workspace menu if mcp key is expired (#8727) --- backend/src/app/rpc/commands/profile.clj | 2 +- frontend/src/app/main/data/workspace.cljs | 5 +++- .../src/app/main/ui/workspace/main_menu.cljs | 24 +++++++++++++++---- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/backend/src/app/rpc/commands/profile.clj b/backend/src/app/rpc/commands/profile.clj index 4383ab794f..efe99c4a70 100644 --- a/backend/src/app/rpc/commands/profile.clj +++ b/backend/src/app/rpc/commands/profile.clj @@ -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] diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index f1c54caf48..64221eecb8 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -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 diff --git a/frontend/src/app/main/ui/workspace/main_menu.cljs b/frontend/src/app/main/ui/workspace/main_menu.cljs index bdaf205ddd..135ed716e4 100644 --- a/frontend/src/app/main/ui/workspace/main_menu.cljs +++ b/frontend/src/app/main/ui/workspace/main_menu.cljs @@ -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)}]]))