diff --git a/frontend/src/lib/components/flows/common/FlowCardHeader.svelte b/frontend/src/lib/components/flows/common/FlowCardHeader.svelte
index 6dcd288933..ce39c3a5ed 100644
--- a/frontend/src/lib/components/flows/common/FlowCardHeader.svelte
+++ b/frontend/src/lib/components/flows/common/FlowCardHeader.svelte
@@ -102,7 +102,9 @@
const scriptItems: Item[] = $derived.by(() => {
if (flowModuleValue?.type !== 'script') return []
const items: Item[] = []
- if (!isHub && customUi?.scriptEdit != false && !composeOnlyFlows) {
+ // Editing deploys a new version of the workspace script, which the server allows to any
+ // role with code, whatever its flows level.
+ if (!isHub && customUi?.scriptEdit != false && $roleCaps.code) {
items.push({
displayName: "Edit the script's code",
icon: Pen,
@@ -146,6 +148,7 @@
})
}
}
+ // Forking adds inline code to the flow, which a compose role cannot author.
if (customUi?.scriptFork != false && !composeOnlyFlows) {
items.push({
displayName: 'Fork into an inline script',
diff --git a/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte b/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte
index 0a726c43b3..7d22c1d1c3 100644
--- a/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte
+++ b/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte
@@ -83,7 +83,6 @@
const operatingWorkspace = useOperatingWorkspace()
const roleCaps = useRoleCapabilities()
- const composeOnlyFlows = $derived($roleCaps.flows === 'compose')
const {
selectionManager,
@@ -233,7 +232,6 @@
Boolean(flowStore.val.value?.chat_input_enabled) &&
flowModule.value.type === 'aiagent'
)
- let visibleSelected = $derived(selected === 'chat' && !canShowChatTab ? 'inputs' : selected)
let runSettings: FlowRunSettings | undefined = $state()
let agentLinked = $derived(flowModule.value.type === 'aiagent' && Boolean(flowModule.value.agent))
// A tool row drills in by selecting that tool's graph node, and the graph draws tool nodes only
@@ -261,20 +259,34 @@
() => (flowModule.value.type === 'script' ? flowModule.value.hash : undefined),
() => opWs
)
- // Hub scripts, hash-pinned steps, and embeddings that disable script editing
- // can't have their settings edited from here. The drawer must also be mounted:
- // local-dev editors (Dev.svelte / flows/dev) provide the context store but never
- // render the drawer, so editing there would be a no-op — keep values read-only.
+ // Not for hub scripts, hash-pinned steps, embeddings that disable script editing, or roles
+ // without code (why: FlowCardHeader's edit item). The drawer must also be mounted: local-dev
+ // editors (Dev.svelte / flows/dev) provide the context store but never render the drawer.
let canEditWorkspaceScriptSettings = $derived(
flowModule.value.type === 'script' &&
!flowModule.value.path?.startsWith('hub/') &&
flowModule.value.hash == undefined &&
customUi?.scriptEdit != false &&
- !composeOnlyFlows &&
+ $roleCaps.code &&
$workspaceScriptSettingsDrawer != undefined
)
// Same rule as the graph node's Run button (FlowModuleSchemaItem).
- let builderCannotTestStep = $derived(composeOnlyFlows && flowModule.value.type === 'script')
+ let builderCannotTestStep = $derived(
+ (flowModule.value.type === 'script' || flowModule.value.type === 'rawscript') &&
+ !($roleCaps.code && $roleCaps.run)
+ )
+ // Several paths ask for a tab that may be hidden (the editor's Ctrl+Enter, the forced test
+ // tab of an input edit or an agent tool); fall back to inputs here rather than guarding each
+ // of them. A preprocessor has no inputs tab, so it says why instead.
+ let visibleSelected = $derived(
+ selected === 'test' && builderCannotTestStep
+ ? preprocessorModule
+ ? 'cannot_test'
+ : 'inputs'
+ : selected === 'chat' && !canShowChatTab
+ ? 'inputs'
+ : selected
+ )
let workspaceScriptNoEditReason = $derived(
flowModule.value.type !== 'script' || canEditWorkspaceScriptSettings
? undefined
@@ -282,7 +294,9 @@
? 'Hub scripts cannot be edited from here.'
: flowModule.value.hash != undefined
? 'Steps pinned to a specific version cannot be edited from here.'
- : 'Editing script settings is not available in this editor.'
+ : !$roleCaps.code
+ ? 'Your role cannot edit scripts.'
+ : 'Editing script settings is not available in this editor.'
)
// Non-positive concurrent_limit / cache_ttl are treated as unset by the runtime (legacy rows).
let referencedConcurrentLimit = $derived(
@@ -470,7 +484,7 @@
flowStore.val && flowModule ? checkIfParentLoop(flowStore.val, flowModule.id) : undefined
)
$effect(() => {
- if (selected === 'test') {
+ if (visibleSelected === 'test') {
leftPanelSize = 50
} else {
leftPanelSize = 100
@@ -967,7 +981,7 @@
{#if assets?.length}
{/if}
- {#if isDebuggableScript && customUi?.editorBar?.debug != false}
+ {#if isDebuggableScript && customUi?.editorBar?.debug != false && !builderCannotTestStep}