From 19fc07faa95a8a2247e726f9d0a2adc3cfa42bd2 Mon Sep 17 00:00:00 2001 From: AlexRV12 <71396855+AlexRV12@users.noreply.github.com> Date: Fri, 16 Oct 2026 17:52:58 +0200 Subject: [PATCH] fix: use the session workspace's user in three AI session places (#11808) --- frontend/src/lib/components/FlowBuilder.svelte | 17 +++++++++++------ .../apps/editor/InWorkspaceAppViewer.svelte | 4 ++-- .../raw_apps/RawAppInlineScriptRunnable.svelte | 7 +++---- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/frontend/src/lib/components/FlowBuilder.svelte b/frontend/src/lib/components/FlowBuilder.svelte index f533fcc1f0..73ce91083d 100644 --- a/frontend/src/lib/components/FlowBuilder.svelte +++ b/frontend/src/lib/components/FlowBuilder.svelte @@ -18,7 +18,13 @@ linkedAgentToolsVersion, migrateLinkedAgentToolsScope } from '$lib/components/flows/linkedAgentToolsStore.svelte' - import { enterpriseLicense, userStore, userWorkspaces, usedTriggerKinds } from '$lib/stores' + import { + enterpriseLicense, + userStore, + userWorkspaces, + usedTriggerKinds, + workspaceStore + } from '$lib/stores' import { generateRandomString, orderedJsonStringify, @@ -552,15 +558,14 @@ // One lookup for the whole list: an agent lives in a folder, and the groups and admin // flag that answer for it are per workspace, so the nav user would answer for the wrong // membership when a session editor operates on another workspace. - const user = await getUserExt(opWorkspace ?? '').catch(() => undefined) + const user = + (await getUserExt(opWorkspace ?? '')) ?? + (opWorkspace === $workspaceStore ? $userStore : undefined) const operatorSettings = $userWorkspaces.find( (w) => w.id === opWorkspace )?.operator_settings agentCanWrite = Object.fromEntries( - draftAgents.map((a) => [ - a.path, - agentDraftCanWrite(a, user ?? $userStore ?? undefined, operatorSettings) - ]) + draftAgents.map((a) => [a.path, agentDraftCanWrite(a, user, operatorSettings)]) ) // The path is passed, so a draft that renames the agent is refused here too: a rename is // the agent editor's to deploy, and this dialog lists the agent under the path the flow diff --git a/frontend/src/lib/components/apps/editor/InWorkspaceAppViewer.svelte b/frontend/src/lib/components/apps/editor/InWorkspaceAppViewer.svelte index 2f94e086ad..0d4fb03704 100644 --- a/frontend/src/lib/components/apps/editor/InWorkspaceAppViewer.svelte +++ b/frontend/src/lib/components/apps/editor/InWorkspaceAppViewer.svelte @@ -18,7 +18,7 @@ import type { Item } from '$lib/utils' import { Button } from '$lib/components/common' import { AppService, OpenAPI } from '$lib/gen' - import { userStore, type UserExt } from '$lib/stores' + import { userStore, workspaceStore, type UserExt } from '$lib/stores' import { getUserExt } from '$lib/user' import { ExternalLink, Pen } from 'lucide-svelte' import { page } from '$app/state' @@ -254,7 +254,7 @@