Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

refactor(webv2): move Video sliders to ScrubberField

Josh Corbett06843a22aa82
diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx
index 4252b82d8d..ab7295a771 100644
--- a/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx
+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx
@@ -34,10 +34,10 @@ import {
import { Button, IconButton } from '@platform/ui/Button';
import { DropTargetOverlay } from '@platform/ui/DropTargetOverlay';
import { DropZone } from '@platform/ui/DropZone';
-import { Field, FieldLabel } from '@platform/ui/Field';
+import { Field } from '@platform/ui/Field';
import { MiddleTruncate } from '@platform/ui/MiddleTruncate';
+import { ScrubberField } from '@platform/ui/ScrubberField';
import { Select } from '@platform/ui/Select';
-import { SliderNumberField } from '@platform/ui/SliderNumberField';
import { ArrowDownIcon, ArrowUpIcon, ChevronDownIcon, ImagePlusIcon, UploadIcon, XIcon } from 'lucide-react';
import { memo, useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -362,19 +362,15 @@ const ReferenceCard = memo(function ReferenceCard({
label={t('widgets.video.trimStartShort')}
src={galleryVideoUrls.full(name)}
/>
- <Stack flex="1" gap="0.5" minW="0">
- <FieldLabel>{t('widgets.video.trimStart')}</FieldLabel>
- <SliderNumberField
- ariaLabel={t('widgets.video.trimStart')}
- disabled={disabled}
- max={Math.max(0, reference.clip.numFrames - 1)}
- min={0}
- showStepper
- step={1}
- value={reference.clip.startFrame}
- onChange={handleStartFrame}
- />
- </Stack>
+ <ScrubberField
+ disabled={disabled}
+ label={t('widgets.video.trimStart')}
+ max={Math.max(0, reference.clip.numFrames - 1)}
+ min={0}
+ step={1}
+ value={reference.clip.startFrame}
+ onChange={handleStartFrame}
+ />
</HStack>
<HStack gap="2">
<TrimBoundThumb
@@ -383,25 +379,21 @@ const ReferenceCard = memo(function ReferenceCard({
label={`${t('widgets.video.trimEndShort')} · ${reference.clip.endFrame}`}
src={galleryVideoUrls.full(name)}
/>
- <Stack flex="1" gap="0.5" minW="0">
- <FieldLabel>
- {sampleSeconds === null
+ <ScrubberField
+ disabled={disabled}
+ label={
+ sampleSeconds === null
? t('widgets.video.sampleLength')
- : t('widgets.video.sampleLengthWithSeconds', { seconds: sampleSeconds })}
- </FieldLabel>
- <SliderNumberField
- ariaLabel={t('widgets.video.sampleLength')}
- disabled={disabled}
- // The window grows forward from its start, so the ceiling is what the
- // clip has left from there — it falls as the start frame climbs.
- max={Math.max(1, reference.clip.numFrames - reference.clip.startFrame)}
- min={1}
- showStepper
- step={1}
- value={sampleFrames}
- onChange={handleSampleFrames}
- />
- </Stack>
+ : t('widgets.video.sampleLengthWithSeconds', { seconds: sampleSeconds })
+ }
+ // The window grows forward from its start, so the ceiling is what the
+ // clip has left from there — it falls as the start frame climbs.
+ max={Math.max(1, reference.clip.numFrames - reference.clip.startFrame)}
+ min={1}
+ step={1}
+ value={sampleFrames}
+ onChange={handleSampleFrames}
+ />
</HStack>
</Stack>
) : null}
diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoSourceClipField.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoSourceClipField.tsx
index bfb13836cb..cf60e2fe9e 100644
--- a/invokeai/frontend/webv2/src/features/video/ui/VideoSourceClipField.tsx
+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoSourceClipField.tsx
@@ -2,7 +2,7 @@ import type { DragEndEvent } from '@dnd-kit/core';
import type { VideoSourceClip } from '@features/video/core/types';
import type { ChangeEvent } from 'react';
-import { Box, HStack, Icon, Input, Spinner, Stack, Text } from '@chakra-ui/react';
+import { HStack, Icon, Input, Spinner, Stack, Text } from '@chakra-ui/react';
import { useDndContext, useDndMonitor, useDroppable } from '@dnd-kit/core';
import { galleryItems, galleryTransfers, type GalleryItem } from '@features/gallery';
import { GalleryPickerPopover } from '@features/gallery/picker';
@@ -18,7 +18,7 @@ import { Button } from '@platform/ui/Button';
import { DropTargetOverlay } from '@platform/ui/DropTargetOverlay';
import { DropZone } from '@platform/ui/DropZone';
import { MiddleTruncate } from '@platform/ui/MiddleTruncate';
-import { SliderNumberField } from '@platform/ui/SliderNumberField';
+import { ScrubberField } from '@platform/ui/ScrubberField';
import { ChevronDownIcon, FilmIcon, UploadIcon, XIcon } from 'lucide-react';
import { memo, useCallback, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -323,18 +323,15 @@ export const VideoSourceClipField = memo(
label={t('widgets.video.trimStartShort')}
src={previewSrc}
/>
- <Box flex="1" minW="0">
- <SliderNumberField
- ariaLabel={t('widgets.video.trimStart')}
- disabled={disabled}
- max={maxFrameIndex}
- min={0}
- showStepper
- step={1}
- value={sourceVideo.startFrame}
- onChange={setStartFrame}
- />
- </Box>
+ <ScrubberField
+ disabled={disabled}
+ label={t('widgets.video.trimStart')}
+ max={maxFrameIndex}
+ min={0}
+ step={1}
+ value={sourceVideo.startFrame}
+ onChange={setStartFrame}
+ />
</HStack>
<HStack gap="2">
<TrimBoundThumb
@@ -343,18 +340,15 @@ export const VideoSourceClipField = memo(
label={t('widgets.video.trimEndShort')}
src={previewSrc}
/>
- <Box flex="1" minW="0">
- <SliderNumberField
- ariaLabel={t('widgets.video.trimEnd')}
- disabled={disabled}
- max={maxFrameIndex}
- min={0}
- showStepper
- step={1}
- value={sourceVideo.endFrame}
- onChange={setEndFrame}
- />
- </Box>
+ <ScrubberField
+ disabled={disabled}
+ label={t('widgets.video.trimEnd')}
+ max={maxFrameIndex}
+ min={0}
+ step={1}
+ value={sourceVideo.endFrame}
+ onChange={setEndFrame}
+ />
</HStack>
</Stack>
</HStack>
diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
index b6e401814c..772088cf49 100644
--- a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
@@ -29,7 +29,7 @@ import { createDefaultVideoWidgetValues, syncVideoWidgetValuesWithModels } from
import { useMountEffect } from '@platform/react/useMountEffect';
import { Field, IconButton, Select } from '@platform/ui';
import { Button } from '@platform/ui/Button';
-import { SliderNumberField } from '@platform/ui/SliderNumberField';
+import { ScrubberField } from '@platform/ui/ScrubberField';
import { toaster } from '@platform/ui/toaster';
import { ArrowLeftRightIcon, DicesIcon } from 'lucide-react';
import { useCallback, useEffect, useId, useMemo, useRef } from 'react';
@@ -647,32 +647,27 @@ export const VideoWidgetView = () => {
onValueChange={set.targetResolution}
/>
</Field>
- <Field helpText={durationText} label={t('widgets.video.frames')}>
- <SliderNumberField
- ariaLabel={t('widgets.video.frames')}
- max={framesSlider.max}
- min={framesSlider.min}
- step={framesSlider.step}
- value={values.numFrames}
- onChange={setNumFrames}
- />
- </Field>
+ <ScrubberField
+ helpText={durationText}
+ label={t('widgets.video.frames')}
+ max={framesSlider.max}
+ min={framesSlider.min}
+ step={framesSlider.step}
+ value={values.numFrames}
+ onChange={setNumFrames}
+ />
{policy.ui.fpsVisible ? (
- <Field
+ <ScrubberField
+ disabled={fpsLockedForExtend}
helpText={fpsLockedForExtend ? t('widgets.video.fpsExtendLocked') : undefined}
+ inputMax={policy.fps.max}
label={t('widgets.video.fps')}
- >
- <SliderNumberField
- ariaLabel={t('widgets.video.fps')}
- disabled={fpsLockedForExtend}
- max={60}
- min={policy.fps.min}
- numberInputMax={policy.fps.max}
- step={1}
- value={values.fps}
- onChange={set.fps}
- />
- </Field>
+ max={60}
+ min={policy.fps.min}
+ step={1}
+ value={values.fps}
+ onChange={set.fps}
+ />
) : (
<Text color="fg.muted" fontSize="2xs">
{t('widgets.video.fixedFps', { fps: policy.fps.defaultValue })}
@@ -700,42 +695,39 @@ export const VideoWidgetView = () => {
</Switch.Root>
</Field>
) : null}
- <Field hint="steps" label={t('widgets.video.steps')}>
- <SliderNumberField
- ariaLabel={t('widgets.video.steps')}
- max={100}
- min={policy.minSteps}
- numberInputMax={500}
- step={1}
- value={values.steps}
- onChange={set.steps}
- />
- </Field>
+ <ScrubberField
+ hint="steps"
+ inputMax={500}
+ label={t('widgets.video.steps')}
+ max={100}
+ min={policy.minSteps}
+ step={1}
+ value={values.steps}
+ onChange={set.steps}
+ />
{policy.ui.cfgVisible ? (
- <Field hint="cfgScale" label={t('widgets.video.cfg')}>
- <SliderNumberField
- ariaLabel={t('widgets.video.cfg')}
- max={15}
- min={1}
- numberInputMax={100}
- step={0.1}
- value={values.cfgScale}
- onChange={set.cfgScale}
- />
- </Field>
+ <ScrubberField
+ hint="cfgScale"
+ inputMax={100}
+ label={t('widgets.video.cfg')}
+ max={15}
+ min={1}
+ step={0.1}
+ value={values.cfgScale}
+ onChange={set.cfgScale}
+ />
) : null}
{policy.ui.cfgLowNoiseVisible ? (
- <Field helpText={t('widgets.video.cfgLowNoiseHelp')} label={t('widgets.video.cfgLowNoise')}>
- <SliderNumberField
- ariaLabel={t('widgets.video.cfgLowNoise')}
- max={15}
- min={0}
- numberInputMax={100}
- step={0.1}
- value={values.cfgScaleLowNoise ?? values.cfgScale}
- onChange={set.cfgScaleLowNoise}
- />
- </Field>
+ <ScrubberField
+ helpText={t('widgets.video.cfgLowNoiseHelp')}
+ inputMax={100}
+ label={t('widgets.video.cfgLowNoise')}
+ max={15}
+ min={0}
+ step={0.1}
+ value={values.cfgScaleLowNoise ?? values.cfgScale}
+ onChange={set.cfgScaleLowNoise}
+ />
) : null}
<Field hint="seed" label={t('widgets.video.seed')}>
<HStack gap="2">