From 175db9d94c7f4566154ca8c6c9e7aa81071da2d6 Mon Sep 17 00:00:00 2001 From: Charlie Tonneslan Date: Tue, 17 Mar 2026 13:46:20 -0400 Subject: [PATCH] fix: resource refresh button now bypasses cache to re-read content The refresh button in the Resources tab was not working because readResource() early-returns when the URI already exists in resourceContentMap. Since the content was cached from the first read, clicking refresh had no effect. Added a force parameter to readResource() that bypasses the cache check. The refresh button passes force=true while initial reads still use the cache for performance. Also fixes the issue where switching between resource template URIs (e.g. user://1 then user://2 then back to user://1) would show stale cached content without re-reading from the server. Fixes #1120 --- client/src/App.tsx | 11 +++++++---- client/src/components/ResourcesTab.tsx | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/client/src/App.tsx b/client/src/App.tsx index 12e9a7bd0..9c32f7ac4 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -893,8 +893,11 @@ const App = () => { setPromptContent(JSON.stringify(response, null, 2)); }; - const readResource = async (uri: string) => { - if (fetchingResources.has(uri) || resourceContentMap[uri]) { + const readResource = async (uri: string, force: boolean = false) => { + if (fetchingResources.has(uri)) { + return; + } + if (!force && resourceContentMap[uri]) { return; } @@ -1471,9 +1474,9 @@ const App = () => { setResourceTemplates([]); setNextResourceTemplateCursor(undefined); }} - readResource={(uri) => { + readResource={(uri, force) => { clearError("resources"); - readResource(uri); + readResource(uri, force); }} selectedResource={selectedResource} setSelectedResource={(resource) => { diff --git a/client/src/components/ResourcesTab.tsx b/client/src/components/ResourcesTab.tsx index 36e5cec8f..9f2774217 100644 --- a/client/src/components/ResourcesTab.tsx +++ b/client/src/components/ResourcesTab.tsx @@ -46,7 +46,7 @@ const ResourcesTab = ({ clearResources: () => void; listResourceTemplates: () => void; clearResourceTemplates: () => void; - readResource: (uri: string) => void; + readResource: (uri: string, force?: boolean) => void; selectedResource: Resource | null; setSelectedResource: (resource: Resource | null) => void; handleCompletion: ( @@ -229,7 +229,7 @@ const ResourcesTab = ({