{#if automationId} {#if detailLoading}
{:else if detail}
{#if !$sidebarOpen}
sidebarOpen.set(true)} title={$t('automations.toggleSidebar')} >
{/if}
goto('/automations')} >
{$t('automations.title')}
/
{detail.name}
handleToggle(detail!)} />
handleRunNow(detail!)} title={$t('automations.runNow')} >
{ editingAutomation = detail; showModal = true; }} title={$t('automationModal.save')} >
handleDelete(detail!)} title={$t('admin.delete')} >
{$t('automations.status')}
{detail.is_active ? $t('automations.active') : $t('automations.paused')}
{$t('automations.schedule')}
{parseFrequency(detail.rrule)}
{$t('automations.model')}
{detail.model_id}
{$t('automations.nextRun')}
{formatTime(detail.next_run_at)}
{$t('automations.lastRun')}
{formatTime(detail.last_run_at)}
{$t('automations.webhook')}
{#if detail.webhook_url}
...?token={detail.webhook_url.split('token=')[1]?.slice(0, 12)}...
{webhookCopied ? $t('automations.copied') : $t('automations.copy')}
{:else if detail.has_webhook}
{$t('automations.enabled')}
·
{$t('automations.regenerate')}
·
{$t('automations.disable')}
{:else}
{$t('automations.enable')}
{/if}
{$t('automations.prompt')}
{detail.prompt}
{$t('automations.runs')}
{#if runs.length === 0}
{$t('automations.noRuns')}
{:else} {#each runs as run}
{formatTime(run.created_at)}
{#if run.chat_id}
{ const ws = detail?.workspace; if (ws) { goto(`/?workspace=${encodeURIComponent(ws)}`); } setTimeout(() => openChatTab(run.chat_id!), 300); }} > {$t('automations.viewChat')}
{/if} {#if run.error}
{run.error}
{/if}
{/each} {/if}
{/if} {:else}
{#if !$sidebarOpen}
sidebarOpen.set(true)} title={$t('automations.toggleSidebar')} >
{/if}
{$t('automations.title')}
{#if total > 0}
{total}
{/if}
{$t('automations.all')}
{$t('automations.active')}
{$t('automations.paused')}
{ editingAutomation = null; showModal = true; }} title={$t('automations.newAutomation')} >
{#if searchQuery}
{ searchQuery = ''; loadList(); }}>
{/if}
{#if loading}
{:else if items.length === 0}
{searchQuery ? $t('automations.noMatches') : $t('automations.noAutomations')}
{#if !searchQuery}
{ editingAutomation = null; showModal = true; }} > {$t('automations.create')}
{/if}
{:else} {#each items as a (a.id)}
goto(`/automations/${a.id}`)} > {a.name}
{a.workspace.split('/').pop()}
·
{parseFrequency(a.rrule)}
e.stopPropagation()}>
handleRunNow(a)} title={$t('automations.runNow')} >
e.stopPropagation()}>
handleToggle(a)} />
{/each} {/if}
{/if}
{#if showModal}
{ showModal = false; editingAutomation = null; }} onsave={handleSave} /> {/if}