Files
windmill/frontend/src/lib/components/ContextualVariableEditor.svelte
T
d6c2b2c683 feat: add a use/plan/build mode picker and read-only prod sessions (#11940)
* feat: read-only ai sessions on protected workspaces with a use, plan and build picker

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: address local review findings on the use, plan and build picker

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: address CI review findings on use mode and protected sessions

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: hold test-run forms and pending protection lookups to use mode

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* refactor: fetch rules once per send and dedupe helpers and prompt text

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: send role-locked operators to an admin and cover it with an eval

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* feat: count the work mode each session message runs in

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* chore: regenerate the mcp session definitions after merging main

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* feat: rename build to use & build and let the chat ask to switch modes

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: word a declined mode switch by the switch, not the mode

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* chore: update ee-repo-ref to 55445977dd05c25791388070182c77f4dbc20c0e

This commit updates the EE repository reference after PR #915 was merged in windmill-ee-private.

Previous ee-repo-ref: 7f7bf7003e356346ce74395af02c5bdf14f38781

New ee-repo-ref: 55445977dd05c25791388070182c77f4dbc20c0e

Automated by sync-ee-ref workflow.

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
2026-10-23 15:53:04 +02:00

98 lines
2.5 KiB
Svelte

<script lang="ts">
import { WorkspaceService } from '$lib/gen'
import { createEventDispatcher } from 'svelte'
import { Button } from './common'
import Drawer from './common/drawer/Drawer.svelte'
import DrawerContent from './common/drawer/DrawerContent.svelte'
import { sendUserToast } from '$lib/toast'
import { Save } from 'lucide-svelte'
import autosize from '$lib/autosize'
import Label from './Label.svelte'
import TextInput from './text_input/TextInput.svelte'
import {
useOperatingWorkspace,
useReadOnlyWorkspace
} from '$lib/components/operatingWorkspace.svelte'
const operatingWorkspace = useOperatingWorkspace()
// An editor opened in Build stays open when the session switches to Use.
const readOnly = useReadOnlyWorkspace()
const dispatch = createEventDispatcher()
let edit: boolean = $state(false)
let name: string = $state('')
let value: string = $state('')
export function initNew(): void {
edit = false
name = ''
value = ''
drawer?.openDrawer()
}
export function editVariable(editName: string, editValue: string): void {
edit = true
name = editName
value = editValue
drawer?.openDrawer()
}
let drawer: Drawer | undefined = $state()
async function updateVariable(): Promise<void> {
if (readOnly($operatingWorkspace)) return
await WorkspaceService.setEnvironmentVariable({
workspace: $operatingWorkspace!,
requestBody: {
value: value,
name: name
}
})
sendUserToast(
`${
edit ? 'Updated' : 'Created'
} contextual variable ${name}. It may take up to a few minutes to update.`
)
dispatch('update')
drawer?.closeDrawer()
setTimeout(() => {
dispatch('update')
}, 5000)
}
</script>
<Drawer bind:this={drawer} size="900px">
<DrawerContent
title={edit ? `Update contextual variable ${name}` : 'Create a contextual variable'}
on:close={drawer?.closeDrawer}
>
<div class="flex flex-col gap-8">
{#if !edit}
<Label for="name" label="Name">
<TextInput
inputProps={{ type: 'text', placeholder: 'Variable name', id: 'name' }}
bind:value={name}
/>
</Label>
{/if}
<Label for="value" label="Value">
<textarea rows="4" use:autosize bind:value placeholder="Variable value" id="value"
></textarea>
</Label>
</div>
{#snippet actions()}
<Button
on:click={() => updateVariable()}
disabled={value === '' || name === '' || readOnly($operatingWorkspace)}
startIcon={{ icon: Save }}
variant="accent"
unifiedSize="md"
>
{edit ? 'Update' : 'Save'}
</Button>
{/snippet}
</DrawerContent>
</Drawer>