Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const sectionState = reactive<Record<string, boolean>>({
auxiliaryImages: false,
lora: false,
vaeTiling: false,
preview: false,
cache: false,
});
const loadingCapabilities = ref(false);
Expand Down Expand Up @@ -91,6 +92,8 @@ const fullImageInputs = computed(() => currentImageInputs.value.filter((input) =
const queueLimit = computed(() => capabilities.value?.limits?.max_queue_size ?? "unknown");
const canCancelQueued = computed(() => Boolean(currentJobFeatures.value.cancel_queued));
const canCancelGenerating = computed(() => Boolean(currentJobFeatures.value.cancel_generating));
const supportsPreview = computed(() => Boolean(currentJobFeatures.value.preview));
const previewModes = computed(() => capabilities.value?.preview_modes || ["none", "latent", "decoded"]);

const currentStatus = computed(() => currentJob.value?.status || "idle");
const currentJobKind = computed(() => currentJob.value?.kind || null);
Expand Down Expand Up @@ -129,6 +132,14 @@ const animatedVideoImageSrc = computed(() => {
return `data:image/webp;base64,${currentJob.value.result.b64_json}`;
});
const previewImageSrc = computed(() => animatedVideoImageSrc.value || selectedImage.value);
const livePreviewSrc = computed(() => {
if (currentStatus.value !== "generating" || !currentJob.value?.preview?.b64_json) {
return null;
}
return `data:image/png;base64,${currentJob.value.preview.b64_json}`;
});
const livePreviewStep = computed(() => currentJob.value?.preview?.step ?? 0);
const livePreviewTotalSteps = computed(() => currentJob.value?.preview?.total_steps ?? 0);
const downloadableSrc = computed(() => {
const result = currentJob.value?.result;
if (currentJobKind.value === "vid_gen" && result?.b64_json && videoMimeType.value) {
Expand Down Expand Up @@ -829,6 +840,21 @@ onBeforeUnmount(() => {
</div>
</CollapsibleSection>

<CollapsibleSection v-if="supportsPreview" class="stack-top" eyebrow="Preview" :summary="form.preview_mode === 'none' ? 'Disabled' : form.preview_mode" :open="sectionState.preview" @toggle="toggleSection('preview')">
<div class="fields">
<div class="field">
<label>Preview Mode</label>
<select v-model="form.preview_mode">
<option v-for="mode in previewModes" :key="mode" :value="mode">{{ mode }}</option>
</select>
</div>
<div class="field">
<label>Interval (steps)</label>
<input v-model.number="form.preview_interval" type="number" min="1" step="1" />
</div>
</div>
</CollapsibleSection>

<CollapsibleSection class="stack-top" eyebrow="Cache" :summary="cacheSummary" :open="sectionState.cache" @toggle="toggleSection('cache')">
<div class="field">
<label>Mode</label>
Expand All @@ -849,6 +875,13 @@ onBeforeUnmount(() => {
</div>
</div>

<div v-if="livePreviewSrc" class="hero-frame hero-frame--media hero-frame--preview">
<img class="hero-frame__image" :src="livePreviewSrc" alt="Live preview" />
<div class="hero-frame__preview-overlay">
<span class="hero-frame__preview-label">Preview</span>
<span class="hero-frame__preview-step">{{ livePreviewStep }} / {{ livePreviewTotalSteps }} steps</span>
</div>
</div>
<div v-if="videoPreviewSrc" class="hero-frame hero-frame--media">
<video class="hero-frame__video" :src="videoPreviewSrc" controls autoplay loop muted playsinline />
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/lib/form-capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export function formFromCapabilities(capabilities: Capabilities): GenerationForm
form.vace_strength = finiteOrFallback(defaults.vace_strength, 1.0);
form.output_format = defaults.output_format || "png";
form.output_compression = finiteOrFallback(defaults.output_compression, 100);
form.preview_mode = defaults.preview_mode || "none";
form.preview_interval = finiteOrFallback(defaults.preview_interval, 1);

assignSampleParams(form.sample_params, sample, 20);
assignSampleParams(form.high_noise_sample_params, highNoiseSample, -1);
Expand Down
2 changes: 2 additions & 0 deletions src/lib/form-defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export function createBlankForm(): GenerationForm {
vace_strength: 1.0,
output_format: "png",
output_compression: 100,
preview_mode: "none",
preview_interval: 1,
sample_params: {
scheduler: "default",
sample_method: "default",
Expand Down
2 changes: 2 additions & 0 deletions src/lib/form-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ export function buildRequestBody(form: GenerationForm) {
scm_policy_dynamic: Boolean(form.cache.scm_policy_dynamic),
output_format: form.output_format,
output_compression: parseNumber(form.output_compression, 100),
preview: form.preview_mode || "none",
preview_interval: parseNumber(form.preview_interval, 1),
};

if (!request.prompt) {
Expand Down
9 changes: 9 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export interface GenerationForm {
vace_strength: number;
output_format: string;
output_compression: number;
preview_mode: string;
preview_interval: number;
sample_params: SampleParams;
high_noise_sample_params: SampleParams;
init_image: ImageEntry | null;
Expand Down Expand Up @@ -127,12 +129,14 @@ export interface Capabilities {
samplers?: string[];
schedulers?: string[];
loras?: AvailableLora[];
preview_modes?: string[];
limits?: {
max_queue_size?: number;
};
features?: {
cancel_queued?: boolean;
cancel_generating?: boolean;
preview?: boolean;
};
features_by_mode?: Partial<Record<"img_gen" | "vid_gen", Record<string, any>>>;
defaults?: Record<string, any>;
Expand Down Expand Up @@ -168,6 +172,11 @@ export interface Job {
started?: number;
completed?: number;
result?: JobResult | null;
preview?: {
step: number;
total_steps: number;
b64_json: string;
} | null;
error?: {
code?: string;
message?: string;
Expand Down
30 changes: 30 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,36 @@ button {
background: #000;
}

.hero-frame--preview {
position: relative;
}

.hero-frame__preview-overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 12px;
background: rgba(17, 24, 39, 0.72);
color: #fff;
font-size: 12px;
font-weight: 600;
letter-spacing: 0.02em;
}

.hero-frame__preview-label {
text-transform: uppercase;
letter-spacing: 0.08em;
}

.hero-frame__preview-step {
font-family: var(--font-mono);
font-size: 11px;
}

.hero-placeholder {
padding: 32px;
text-align: center;
Expand Down