Files
windmill/frontend/src/lib/components/copilot/chat/DeployDiffButton.svelte
T
GuilhemandClaude Opus 5.5 c8d047905e feat: give the chat's deploy confirmation a card of its own (#12571)
* feat: give the chat's deploy confirmation a card with editable fields and a diff

* fix: refuse a picked deploy path that is already taken

* fix: show the folder default user a first deploy will run as

* fix: close the run-as picker once a user is chosen

* fix: let Escape stop a turn in a drawer and seed the card from the staged path

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: read a raw app's staged path before canonicalizing its unsaved draft

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: drop the deploy card dev page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 16:50:42 +01:00

68 lines
1.8 KiB
Svelte

<script lang="ts" module>
import { lazyModule } from '$lib/lazyModule.svelte'
import type { UserDraftItemKind } from '$lib/gen'
// It reaches the AI clients, which the transcript must not load to render a card.
const diffDrawerModule = lazyModule(() => import('$lib/components/DiffDrawer.svelte'))
export type DeployDiffSides = { kind: UserDraftItemKind; deployed: unknown; draft: unknown }
</script>
<script lang="ts">
import { tick } from 'svelte'
import { GitCompareArrows } from 'lucide-svelte'
import { Button } from '$lib/components/common'
import type DiffDrawer from '$lib/components/DiffDrawer.svelte'
import { sendUserToast } from '$lib/toast'
import type { Value } from '$lib/utils'
interface Props {
/** Undefined disables the button. */
load: (() => Promise<DeployDiffSides>) | undefined
}
let { load }: Props = $props()
let diffDrawer: DiffDrawer | undefined = $state(undefined)
let isFlow = $state(false)
let loading = $state(false)
async function showDiff() {
if (!load || loading) return
loading = true
try {
const [diff] = await Promise.all([load(), diffDrawerModule.load()])
isFlow = diff.kind === 'flow'
await tick()
diffDrawer?.openDrawer()
diffDrawer?.setDiff({
mode: 'simple',
title: 'Deployed → Draft',
original: diff.deployed as Value,
current: diff.draft as Value
})
} catch (e: any) {
sendUserToast(`Could not load the diff: ${e?.body ?? e?.message ?? e}`, true)
} finally {
loading = false
}
}
</script>
<Button
variant="subtle"
unifiedSize="sm"
startIcon={{ icon: GitCompareArrows }}
{loading}
disabled={!load}
title="Compare the draft with what is deployed"
onClick={showDiff}
>
Diff
</Button>
{#if diffDrawerModule.current}
{@const LoadedDiffDrawer = diffDrawerModule.current.default}
<LoadedDiffDrawer bind:this={diffDrawer} {isFlow} />
{/if}