This commit is contained in:
Timothy Jaeryang Baek committed 2026-11-30 21:27:41 +04:00
1 parent f20f00056f
commit affe67b7df
6 files changed
+161 -125

No files matched your search

+10 -3
View File
@@ -641,13 +641,20 @@ class AutomationRunTable:
skip: int = 0,
limit: int = 50,
direction: str = 'desc',
query: Optional[str] = None,
status: Optional[str] = None,
db: Optional[AsyncSession] = None,
) -> list[AutomationRunModel]:
order = AutomationRun.created_at.asc() if direction == 'asc' else AutomationRun.created_at.desc()
async with get_async_db_context(db) as db:
result = await db.execute(
select(AutomationRun).filter_by(automation_id=automation_id).order_by(order).offset(skip).limit(limit)
)
stmt = select(AutomationRun).filter_by(automation_id=automation_id)
if status:
stmt = stmt.filter(AutomationRun.status == status)
if query:
stmt = stmt.filter(
or_(AutomationRun.error.icontains(query, autoescape=True), AutomationRun.output.icontains(query, autoescape=True))
)
result = await db.execute(stmt.order_by(order).offset(skip).limit(limit))
rows = result.scalars().all()
return [AutomationRunModel.model_validate(r) for r in rows]
+5 -1
View File
@@ -666,12 +666,16 @@ async def get_automation_runs(
skip: int = 0,
limit: int = 50,
direction: Literal['asc', 'desc'] = 'desc',
query: Optional[str] = None,
status: Optional[Literal['success', 'error']] = None,
user=Depends(get_verified_user),
db: AsyncSession = Depends(get_async_session),
):
await check_automations_permission(request, user)
await get_accessible_automation(id, user, 'read', db)
return await AutomationRuns.get_by_automation(id, skip=skip, limit=limit, direction=direction, db=db)
return await AutomationRuns.get_by_automation(
id, skip=skip, limit=limit, direction=direction, query=query, status=status, db=db
)
@router.get('/{id}/runs/{run_id}', response_model=AutomationRunModel)
+7 -2
View File
@@ -440,12 +440,17 @@ export const getAutomationRuns = async (
id: string,
skip: number = 0,
limit: number = 50,
direction: 'asc' | 'desc' = 'desc'
direction: 'asc' | 'desc' = 'desc',
query: string = '',
status: '' | 'success' | 'error' = ''
) => {
let error = null;
const params = new URLSearchParams({ skip: `${skip}`, limit: `${limit}`, direction });
if (query) params.set('query', query);
if (status) params.set('status', status);
const res = await fetch(
`${WEBUI_API_BASE_URL}/automations/${id}/runs?skip=${skip}&limit=${limit}&direction=${direction}`,
`${WEBUI_API_BASE_URL}/automations/${id}/runs?${params}`,
{
method: 'GET',
headers: {
@@ -73,6 +73,7 @@
const updateModelsHandler = async () => {
updateCancelled = false;
let failed = false;
toast.info('Checking for model updates...');
for (const model of ollamaModels) {
@@ -80,66 +81,39 @@
break;
}
console.debug(model);
updateModelId = model.id;
const [res, controller] = await pullModel(localStorage.token, model.id, urlIdx).catch(
(error) => {
if (error.name !== 'AbortError') {
toast.error(`${error}`);
}
return [null, null];
}
);
try {
const [res, controller] = await pullModel(localStorage.token, model.id, urlIdx);
updateModelsControllers = { ...updateModelsControllers, [model.id]: controller };
updateModelsControllers = {
...updateModelsControllers,
[model.id]: controller
};
if (res) {
const reader = res.body
.pipeThrough(new TextDecoderStream())
.pipeThrough(splitStream('\n'))
.getReader();
while (true) {
try {
const { value, done } = await reader.read();
if (done) break;
const { value, done } = await reader.read();
if (done) break;
let lines = value.split('\n');
for (const line of value.split('\n')) {
if (line === '') continue;
for (const line of lines) {
if (line !== '') {
let data = JSON.parse(line);
console.log(data);
if (data.error) {
throw data.error;
}
if (data.detail) {
throw data.detail;
}
if (data.status) {
if (data.digest) {
updateProgress = 0;
if (data.completed) {
updateProgress = Math.round((data.completed / data.total) * 1000) / 10;
} else {
updateProgress = 100;
}
}
}
}
const data = JSON.parse(line);
if (data.error || data.detail) {
throw data.error ?? data.detail;
}
} catch (err) {
if (err.name !== 'AbortError') {
console.error(err);
if (data.status && data.digest) {
updateProgress = data.completed
? Math.round((data.completed / data.total) * 1000) / 10
: 100;
}
break;
}
}
} catch (err) {
if (err.name !== 'AbortError') {
failed = true;
toast.error(`${model.id}: ${err}`);
}
}
delete updateModelsControllers[model.id];
@@ -148,7 +122,7 @@
if (updateCancelled) {
toast.info('Model update cancelled');
} else {
} else if (!failed) {
toast.success('All models are up to date');
}
updateModelId = null;
@@ -77,6 +77,7 @@
import LinkIcon from '$lib/components/icons/Link.svelte';
import WebhookDropdown from '$lib/components/automations/WebhookDropdown.svelte';
import InputVariablesModal from '$lib/components/chat/MessageInput/InputVariablesModal.svelte';
import CodeEditor from '$lib/components/common/CodeEditor.svelte';
import CodeEditorModal from '$lib/components/common/CodeEditorModal.svelte';
import Cube from '$lib/components/icons/Cube.svelte';
import CodeBracket from '$lib/components/icons/CodeBracket.svelte';
@@ -128,6 +129,10 @@
void prompt;
tick().then(measurePrompt);
}
// Code shows in a small editor; a long program starts collapsed like a long prompt.
let showCode = false;
$: codeClamped = code.split('\n').length > 8;
onMount(() => {
const observer = new ResizeObserver(measurePrompt);
if (promptMeasureEl) observer.observe(promptMeasureEl);
@@ -734,80 +739,10 @@
</div>
{#if selectedTab === 'overview'}
<div class="mx-1 py-1">
{#if action_type !== 'code'}
<div class="relative">
<div
bind:this={promptMeasureEl}
aria-hidden="true"
class="pointer-events-none invisible absolute inset-x-0 top-0 line-clamp-5 whitespace-pre-wrap break-words text-xs font-normal leading-relaxed"
>
{prompt}
</div>
</div>
{#if showPrompt || !promptClamped}
<Textarea
className="mt-1 w-full resize-none overflow-hidden bg-transparent text-xs font-normal leading-relaxed text-base-500 outline-hidden placeholder:text-base-400 dark:text-base-400 dark:placeholder:text-base-500"
bind:value={prompt}
readonly={!canEdit}
rows={1}
ariaLabel={$i18n.t('Instructions')}
placeholder={$i18n.t('Enter prompt here.')}
/>
{:else}
<button
type="button"
aria-label={$i18n.t('Instructions')}
aria-expanded={false}
on:click={() => {
showPrompt = true;
}}
class="mt-1 w-full cursor-text text-start line-clamp-5 whitespace-pre-wrap break-words text-xs font-normal leading-relaxed text-base-500 dark:text-base-400"
>
{prompt}
</button>
{/if}
{#if promptClamped}
<button
class="mt-1 block text-xs text-base-500 transition hover:text-base-700 dark:hover:text-base-300"
type="button"
aria-expanded={showPrompt}
on:click={() => {
showPrompt = !showPrompt;
}}
>
{showPrompt ? $i18n.t('Show less') : $i18n.t('Show more')}
</button>
{/if}
{/if}
<div
class="{action_type !== 'code'
? 'mt-6'
: ''} mb-1 text-[0.6875rem] text-base-400 dark:text-base-500"
>
{$i18n.t('Properties')}
<div class="mb-1 text-[0.6875rem] text-base-400 dark:text-base-500">
{$i18n.t('Action')}
</div>
<div class="-mx-2">
<div class={rowClass}>
<span class={labelClass}>
<svg class="size-3 shrink-0" viewBox="0 0 16 16" fill="none" aria-hidden="true"
><circle cx="8" cy="8" r="5.75" stroke="currentColor" stroke-width="1.5" /><path
d="M8 2.25a5.75 5.75 0 0 1 0 11.5z"
fill="currentColor"
/></svg
>{$i18n.t('Status')}
</span>
<span class="min-w-0 truncate {valueClass}"
>{is_active ? $i18n.t('Active') : $i18n.t('Paused')}</span
>
<Switch
state={is_active}
disabled={!canManage}
on:change={toggleHandler}
ariaLabel={is_active ? $i18n.t('Active') : $i18n.t('Paused')}
/>
</div>
<div class={rowClass}>
<span class={labelClass}
><CodeBracket className="size-3 shrink-0" />{$i18n.t('Action')}</span
@@ -856,7 +791,92 @@
{/if}
</div>
</div>
</div>
{#if action_type === 'code'}
<div class="relative mt-1 {showCode || !codeClamped ? '' : 'max-h-40 overflow-hidden'}">
<CodeEditor
value={code}
lang="python"
readOnly={!canEdit}
ariaLabel={$i18n.t('Code')}
className="text-xs"
onChange={(value) => {
code = value;
}}
/>
{#if codeClamped && !showCode}
<div
class="pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-white to-transparent dark:from-base-900"
></div>
<button
type="button"
class="absolute bottom-0 left-1/2 -translate-x-1/2 text-xs text-base-500 transition hover:text-base-700 dark:hover:text-base-300"
on:click={() => (showCode = true)}>{$i18n.t('Expand')}</button
>
{/if}
</div>
{#if codeClamped && showCode}
<button
class="mt-1 block text-xs text-base-500 transition hover:text-base-700 dark:hover:text-base-300"
type="button"
on:click={() => (showCode = false)}>{$i18n.t('Collapse')}</button
>
{/if}
{:else}
<div class="relative">
<div
bind:this={promptMeasureEl}
aria-hidden="true"
class="pointer-events-none invisible absolute inset-x-0 top-0 line-clamp-5 whitespace-pre-wrap break-words text-xs font-normal leading-relaxed"
>
{prompt}
</div>
</div>
{#if showPrompt || !promptClamped}
<Textarea
className="mt-1 w-full resize-none overflow-hidden bg-transparent text-xs font-normal leading-relaxed text-base-500 outline-hidden placeholder:text-base-400 dark:text-base-400 dark:placeholder:text-base-500"
bind:value={prompt}
readonly={!canEdit}
rows={1}
ariaLabel={$i18n.t('Instructions')}
placeholder={$i18n.t('Enter prompt here.')}
/>
{:else}
<div class="relative">
<button
type="button"
aria-label={$i18n.t('Instructions')}
aria-expanded={false}
on:click={() => {
showPrompt = true;
}}
class="mt-1 w-full cursor-text text-start line-clamp-5 whitespace-pre-wrap break-words text-xs font-normal leading-relaxed text-base-500 dark:text-base-400"
>
{prompt}
</button>
<div
class="pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-white to-transparent dark:from-base-900"
></div>
<button
type="button"
class="absolute bottom-0 left-1/2 -translate-x-1/2 text-xs text-base-500 transition hover:text-base-700 dark:hover:text-base-300"
on:click={() => (showPrompt = true)}>{$i18n.t('Expand')}</button
>
</div>
{/if}
{#if promptClamped && showPrompt}
<button
class="mt-1 block text-xs text-base-500 transition hover:text-base-700 dark:hover:text-base-300"
type="button"
on:click={() => (showPrompt = false)}>{$i18n.t('Collapse')}</button
>
{/if}
{/if}
<div class="mt-6 mb-1 text-[0.6875rem] text-base-400 dark:text-base-500">
{$i18n.t('Triggers')}
</div>
<div class="-mx-2">
{#each scheduleRows as row, i (row)}
<div class={rowClass}>
<span class={labelClass}
@@ -925,6 +945,31 @@
</div>
</div>
{/if}
</div>
<div class="mt-6 mb-1 text-[0.6875rem] text-base-400 dark:text-base-500">
{$i18n.t('Properties')}
</div>
<div class="-mx-2">
<div class={rowClass}>
<span class={labelClass}>
<svg class="size-3 shrink-0" viewBox="0 0 16 16" fill="none" aria-hidden="true"
><circle cx="8" cy="8" r="5.75" stroke="currentColor" stroke-width="1.5" /><path
d="M8 2.25a5.75 5.75 0 0 1 0 11.5z"
fill="currentColor"
/></svg
>{$i18n.t('Status')}
</span>
<span class="min-w-0 truncate {valueClass}"
>{is_active ? $i18n.t('Active') : $i18n.t('Paused')}</span
>
<Switch
state={is_active}
disabled={!canManage}
on:change={toggleHandler}
ariaLabel={is_active ? $i18n.t('Active') : $i18n.t('Paused')}
/>
</div>
<div class={rowClass}>
<span class={labelClass}
@@ -4870,6 +4870,7 @@
"Translation key": "",
"Translations": "",
"Trial License": "",
"Triggers": "",
"Trust and install": "",
"Try a different search or remove a filter.": "",
"Try adjusting your search or filter to find what you are looking for.": "",