Add context ID validation before fetching chat files path in file browser

Guard chat_files_path_get API call with context ID check to prevent unnecessary requests when no context is active. Extract ctxid to variable for clarity.

frdel committed Mar 26, 2026 at 11:35 UTC ec4de765618acdb22933a3f14895b9aeab5dad55
1 file changed +11 -7
webui/components/chat/input/input-store.js
+11 -7
@@ -193,13 +193,17 @@ const model = {
193
194 async browseFiles(path) {
195 if (!path) {
196 - try {
197 - const resp = await shortcuts.callJsonApi("/chat_files_path_get", {
198 - ctxid: shortcuts.getCurrentContextId(),
199 - });
200 - if (resp.ok) path = resp.path;
201 - } catch (_e) {
202 - console.error("Error getting chat files path", _e);
196 + const ctxid = shortcuts.getCurrentContextId();
197 +
198 + if (ctxid) {
199 + try {
200 + const resp = await shortcuts.callJsonApi("/chat_files_path_get", {
201 + ctxid,
202 + });
203 + if (resp.ok) path = resp.path;
204 + } catch (_e) {
205 + console.error("Error getting chat files path", _e);
206 + }
207 }
208 }
209 await fileBrowserStore.open(path);