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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(canvas): compact select object controls
joshistoastc78911f89707
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex e406adffc0..b40ebfe0ea 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -1346,8 +1346,7 @@"includeCount": "Include · {{count}}","invert": "Invert","isolatedPreview": "Isolated Preview",- "model": "Segment Anything model",- "modelAndRefinement": "Model and refinement",+ "model": "Model","modelHuge": "SAM Huge","modelSam2Large": "SAM 2 Large","mode": "Selection mode",@@ -1356,14 +1355,13 @@"promptMode": "Prompt","pointType": "Point type","process": "Process",- "refine": "Refine mask edges",+ "refine": "Refine","reset": "Reset","saveAs": "Save As","saveAs_control": "Control layer","saveAs_inpaint_mask": "Inpaint mask","saveAs_raster": "Raster layer","saveAs_regional_guidance": "Regional guidance",- "sourceSummary": "{{width}} × {{height}} generation area","statusCommitting": "Applying object result…","statusError": "Select Object needs attention.","statusPreparingComposite": "Preparing canvas composite…",diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/CanvasOperationPanel.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/CanvasOperationPanel.test.tsxindex fe64974d08..7c8cddfa52 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/CanvasOperationPanel.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/CanvasOperationPanel.test.tsx@@ -8,6 +8,8 @@ import {CANVAS_OPERATION_FIXED_SECTION_LAYOUT,CANVAS_OPERATION_FOOTER_LAYOUT,CANVAS_OPERATION_PANEL_LAYOUT,+ CANVAS_SELECT_OBJECT_PANEL_LAYOUT,+ CANVAS_SELECT_OBJECT_SLOT_LAYOUT,CanvasOperationPanel,} from './CanvasOperationPanel';@@ -55,6 +57,20 @@ describe('CanvasOperationPanel', () => {expect(CANVAS_OPERATION_FOOTER_LAYOUT).toMatchObject({ flexWrap: 'wrap', minW: '0' });});+ it('gives Select Object a compact 26.25rem variant without changing Filter', () => {+ expect(CANVAS_SELECT_OBJECT_PANEL_LAYOUT).toEqual({+ flex: '0 1 26.25rem',+ maxH: 'full',+ maxW: 'full',+ minH: '0',+ minW: '0',+ overflow: 'hidden',+ w: '26.25rem',+ });+ expect(CANVAS_OPERATION_PANEL_LAYOUT.w).toBe('30rem');+ expect(CANVAS_SELECT_OBJECT_SLOT_LAYOUT).toMatchObject({ px: '4', py: '3' });+ });+it('keeps vertical overflow on the body while fixed sections retain their order', () => {expect(CANVAS_OPERATION_BODY_LAYOUT).toEqual({flex: '1',diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/CanvasOperationPanel.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/CanvasOperationPanel.tsxindex 7a54e15b9d..d52f611401 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/CanvasOperationPanel.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/CanvasOperationPanel.tsx@@ -2,6 +2,7 @@ import type { BoxProps, FlexProps } from '@chakra-ui/react';import { Box, Flex } from '@chakra-ui/react';import { Panel } from '@workbench/components/ui';+import { createContext, useContext } from 'react';type Operation = 'filter' | 'select-object';@@ -15,6 +16,21 @@ export const CANVAS_OPERATION_PANEL_LAYOUT = {w: '30rem',} satisfies BoxProps;+export const CANVAS_SELECT_OBJECT_PANEL_LAYOUT = {+ flex: '0 1 26.25rem',+ maxH: 'full',+ maxW: 'full',+ minH: '0',+ minW: '0',+ overflow: 'hidden',+ w: '26.25rem',+} satisfies BoxProps;++export const CANVAS_SELECT_OBJECT_SLOT_LAYOUT = {+ px: '4',+ py: '3',+} satisfies BoxProps;+export const CANVAS_OPERATION_FOOTER_LAYOUT = {flexWrap: 'wrap',minW: '0',@@ -29,51 +45,73 @@ export const CANVAS_OPERATION_BODY_LAYOUT = {export const CANVAS_OPERATION_FIXED_SECTION_LAYOUT = { flexShrink: '0' } satisfies BoxProps;-const Root = ({ children, operation, ...rest }: BoxProps & { operation: Operation }) => (- <Panel- data-operation={operation}- density="none"- display="flex"- flexDirection="column"- pointerEvents="auto"- role="region"- rounded="xl"- shadow="lg"- tone="raised"- {...CANVAS_OPERATION_PANEL_LAYOUT}- {...rest}- >- {children}- </Panel>-);+const OperationContext = createContext<Operation>('filter');-const Header = (props: BoxProps) => (- <Box- as="header"- borderBottomWidth="1px"- data-slot="header"- px="4"- py="3"- {...CANVAS_OPERATION_FIXED_SECTION_LAYOUT}- {...props}- />-);+const Root = ({ children, operation, ...rest }: BoxProps & { operation: Operation }) => {+ const layout = operation === 'select-object' ? CANVAS_SELECT_OBJECT_PANEL_LAYOUT : CANVAS_OPERATION_PANEL_LAYOUT;+ return (+ <OperationContext value={operation}>+ <Panel+ data-operation={operation}+ density="none"+ display="flex"+ flexDirection="column"+ pointerEvents="auto"+ role="region"+ rounded="xl"+ shadow="lg"+ tone="raised"+ {...layout}+ {...rest}+ >+ {children}+ </Panel>+ </OperationContext>+ );+};-const Body = (props: BoxProps) => (- <Box data-scroll-container="body" data-slot="body" px="4" py="3" {...CANVAS_OPERATION_BODY_LAYOUT} {...props} />-);+const Header = (props: BoxProps) => {+ const operation = useContext(OperationContext);+ return (+ <Box+ as="header"+ borderBottomWidth={operation === 'select-object' ? undefined : '1px'}+ data-slot="header"+ {...CANVAS_SELECT_OBJECT_SLOT_LAYOUT}+ {...CANVAS_OPERATION_FIXED_SECTION_LAYOUT}+ {...props}+ />+ );+};-const Feedback = (props: BoxProps) => (- <Box- borderTopWidth="1px"- data-slot="feedback"- minH="16"- px="4"- py="2"- {...CANVAS_OPERATION_FIXED_SECTION_LAYOUT}- {...props}- />-);+const Body = (props: BoxProps) => {+ const operation = useContext(OperationContext);+ return (+ <Box+ data-scroll-container="body"+ data-slot="body"+ {...CANVAS_SELECT_OBJECT_SLOT_LAYOUT}+ {...CANVAS_OPERATION_BODY_LAYOUT}+ flex={operation === 'select-object' ? '0 1 auto' : CANVAS_OPERATION_BODY_LAYOUT.flex}+ {...props}+ />+ );+};++const Feedback = (props: BoxProps) => {+ const operation = useContext(OperationContext);+ return (+ <Box+ borderTopWidth={operation === 'select-object' ? undefined : '1px'}+ data-slot="feedback"+ minH={operation === 'select-object' ? undefined : '16'}+ px="4"+ py="2"+ {...CANVAS_OPERATION_FIXED_SECTION_LAYOUT}+ {...props}+ />+ );+};const Footer = (props: FlexProps) => (<Flex@@ -81,8 +119,7 @@ const Footer = (props: FlexProps) => (borderTopWidth="1px"data-slot="footer"gap="2"- px="4"- py="3"+ {...CANVAS_SELECT_OBJECT_SLOT_LAYOUT}{...CANVAS_OPERATION_FOOTER_LAYOUT}{...CANVAS_OPERATION_FIXED_SECTION_LAYOUT}{...props}diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SamOptions.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SamOptions.test.tsindex 129c7f74b2..4631124ce8 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SamOptions.test.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SamOptions.test.ts@@ -12,9 +12,13 @@ import {getSamActionEligibility,getSamErrorTranslationKey,getSamStatusTranslationKey,- SAM_AUTO_FIT_COLUMNS,+ SAM_COMPACT_CONTROL_LAYOUT,+ SAM_COMPACT_FOOTER_LAYOUT,+ SAM_MODEL_SELECT_LAYOUT,+ SamPromptBody,SamModeToggle,SamProcessFeedback,+ SamVisualBody,} from './SamOptions';const englishCatalogModules = import.meta.glob('../../../../../public/locales/en.json', {@@ -149,8 +153,10 @@ describe('getSamPanelViewModel', () => {});describe('SamModeToggle', () => {- it('uses available inline width instead of viewport breakpoints', () => {- expect(SAM_AUTO_FIT_COLUMNS).toBe('repeat(auto-fit, minmax(min(100%, 11rem), 1fr))');+ it('uses compact controls and wraps only when the card runs out of inline space', () => {+ expect(SAM_COMPACT_CONTROL_LAYOUT).toEqual({ h: '8', minH: '8', size: 'sm' });+ expect(SAM_COMPACT_FOOTER_LAYOUT).toMatchObject({ flexWrap: 'wrap', gap: '2' });+ expect(SAM_MODEL_SELECT_LAYOUT).toEqual({ flex: '0 1 11rem', maxW: 'full', minW: '0', w: '11rem' });});it('uses ordinary pressed buttons without incomplete tab relationships', () => {@@ -215,11 +221,16 @@ describe('SamProcessFeedback', () => {it('server-renders a localized phase with polite status semantics', () => {const markup = renderToStaticMarkup(- createElement(SamProcessFeedback, {- error: null,- errorText: null,- statusText: 'Rendering object preview…',- })+ createElement(+ ChakraProvider,+ { value: system } as ComponentProps<typeof ChakraProvider>,+ createElement(SamProcessFeedback, {+ error: null,+ errorText: null,+ isBusy: true,+ statusText: 'Rendering object preview…',+ })+ ));expect(markup).toContain('role="status"');@@ -228,11 +239,25 @@ describe('SamProcessFeedback', () => {expect(markup).not.toContain('role="alert"');});+ it('renders nothing when ready without an error', () => {+ const markup = renderToStaticMarkup(+ createElement(SamProcessFeedback, {+ error: null,+ errorText: null,+ isBusy: false,+ statusText: 'Ready',+ })+ );++ expect(markup).toBe('');+ });+it('server-renders a known localized error as the assertive primary message', () => {const markup = renderToStaticMarkup(createElement(SamProcessFeedback, {error: { code: 'decode' },errorText: 'The object preview could not be decoded.',+ isBusy: false,statusText: 'Select Object needs attention.',}));@@ -247,11 +272,13 @@ describe('SamProcessFeedback', () => {createElement(SamProcessFeedback, {error: { code: 'unknown', detail: 'GPU worker disconnected' },errorText: 'Select Object could not finish.',+ isBusy: false,statusText: 'Select Object needs attention.',}));- expect(markup.indexOf('Select Object could not finish.')).toBeLessThan(markup.indexOf('GPU worker disconnected'));+ expect(markup).toContain('title="GPU worker disconnected"');+ expect(markup).not.toContain('>GPU worker disconnected<');expect(markup).toContain('role="alert"');});@@ -261,11 +288,69 @@ describe('SamProcessFeedback', () => {createElement(SamProcessFeedback, {error: { code: 'queue', detail: 'AttributeError' },errorText,+ isBusy: false,statusText: 'Select Object needs attention.',}));- expect(markup.indexOf(errorText)).toBeLessThan(markup.indexOf('AttributeError'));+ expect(markup).toContain('title="AttributeError"');+ expect(markup).not.toContain('>AttributeError<');expect(markup).toContain('role="alert"');});});++describe('compact SAM inputs', () => {+ it('uses compact model-row copy without the removed stacked section heading', () => {+ expect(en.widgets.layers.selectObject.model).toBe('Model');+ expect(en.widgets.layers.selectObject.refine).toBe('Refine');+ expect(en.widgets.layers.selectObject).not.toHaveProperty('modelAndRefinement');+ expect(en.widgets.layers.selectObject).not.toHaveProperty('sourceSummary');+ });++ it('server-renders Prompt as a one-line accessible input', () => {+ const markup = renderToStaticMarkup(+ createElement(+ ChakraProvider,+ { value: system } as ComponentProps<typeof ChakraProvider>,+ createElement(SamPromptBody, { disabled: false, prompt: 'cat', onChange: () => undefined })+ )+ );++ expect(markup).toContain('<input');+ expect(markup).toContain('aria-label=');+ expect(markup).toContain('placeholder=');+ expect(markup).not.toContain('<textarea');+ });++ it('server-renders the visual controls as one labeled row without permanent guidance', () => {+ const session = snapshot({+ input: {+ bbox: { height: 8, width: 12, x: 1, y: 2 },+ excludePoints: [{ x: 3, y: 4 }],+ includePoints: [{ x: 1, y: 2 }],+ type: 'visual',+ },+ });+ const markup = renderToStaticMarkup(+ createElement(+ ChakraProvider,+ { value: system } as ComponentProps<typeof ChakraProvider>,+ createElement(SamVisualBody, {+ disabled: false,+ onExclude: () => undefined,+ onInclude: () => undefined,+ session: session as SamSessionSnapshot & {+ input: Extract<SamSessionSnapshot['input'], { type: 'visual' }>;+ },+ viewModel: getSamPanelViewModel(session, (width, height) => `${width} × ${height}`),+ })+ )+ );++ expect(markup).toContain('role="group"');+ expect(markup).toContain('aria-pressed="true"');+ expect(markup).toContain('title=');+ expect(markup).not.toContain('>widgets.layers.selectObject.pointType<');+ expect(markup).not.toContain('widgets.layers.selectObject.visualGuidance</');+ });+});diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SamOptions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SamOptions.tsxindex 7c1a073881..cd0ffb27aa 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SamOptions.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SamOptions.tsx@@ -1,11 +1,24 @@+import type { FlexProps } from '@chakra-ui/react';/* oxlint-disable react-perf/jsx-no-jsx-as-prop, react-perf/jsx-no-new-function-as-prop, react-perf/jsx-no-new-object-as-prop */import type { SelectObjectSaveTarget } from '@workbench/canvas-engine/engine';import type { SamSessionError, SamSessionErrorCode, SamSessionSnapshot } from '@workbench/canvas-engine/engineStores';import type { SamModel } from '@workbench/generation/canvas/samGraph';import type { ChangeEvent } from 'react';-import { Box, Flex, Grid, Heading, Menu, NativeSelect, Portal, Stack, Switch, Text, Textarea } from '@chakra-ui/react';-import { Button, Field, MenuContent } from '@workbench/components/ui';+import {+ Flex,+ Group,+ Heading,+ Input,+ Menu,+ NativeSelect,+ Portal,+ Spinner,+ Stack,+ Switch,+ Text,+} from '@chakra-ui/react';+import { Button, MenuContent } from '@workbench/components/ui';import { makeImageDurable } from '@workbench/gallery/api';import { isSamDocumentInputValid } from '@workbench/generation/canvas/samGraph';import { useSamSession } from '@workbench/widgets/canvas/engineStoreHooks';@@ -32,7 +45,9 @@ export interface SamPanelViewModel {sourceSummary: string;}-export const SAM_AUTO_FIT_COLUMNS = 'repeat(auto-fit, minmax(min(100%, 11rem), 1fr))';+export const SAM_COMPACT_CONTROL_LAYOUT = { h: '8', minH: '8', size: 'sm' } as const;+export const SAM_COMPACT_FOOTER_LAYOUT = { flexWrap: 'wrap', gap: '2' } satisfies FlexProps;+export const SAM_MODEL_SELECT_LAYOUT = { flex: '0 1 11rem', maxW: 'full', minW: '0', w: '11rem' } as const;const SAM_STATUS_TRANSLATION_KEYS: Record<SamSessionSnapshot['status'], string> = {committing: 'widgets.layers.selectObject.statusCommitting',@@ -79,27 +94,36 @@ export const getSamPanelViewModel = (export const SamProcessFeedback = ({error,errorText,+ isBusy,statusText,}: {error: SamSessionError | null;errorText: string | null;+ isBusy: boolean;statusText: string;}) => {const detail = error?.detail?.trim();- const showDetail = Boolean(detail && detail !== errorText);- return (- <span>- <span aria-live="polite" role="status">- {statusText}+ if (error && errorText) {+ return (+ <span+ aria-live="assertive"+ role="alert"+ style={{ WebkitBoxOrient: 'vertical', WebkitLineClamp: 2, display: '-webkit-box', overflow: 'hidden' }}+ title={detail && detail !== errorText ? detail : undefined}+ >+ {errorText}</span>- {error && errorText ? (- <span aria-live="assertive" role="alert">- <span>{errorText}</span>- {showDetail ? <span>{detail}</span> : null}- </span>- ) : null}- </span>- );+ );+ }+ if (isBusy) {+ return (+ <Flex align="center" aria-live="polite" gap="2" role="status">+ <Spinner boxSize="5" flexShrink="0" />+ <span>{statusText}</span>+ </Flex>+ );+ }+ return null;};export const getSamActionEligibility = (@@ -137,8 +161,7 @@ const SamSwitch = ({<Switch.Rootchecked={checked}disabled={disabled}- minH="10"- size="sm"+ {...SAM_COMPACT_CONTROL_LAYOUT}onCheckedChange={({ checked: next }) => onChange(next)}><Switch.HiddenInput />@@ -166,12 +189,11 @@ export const SamModeToggle = ({promptLabel: string;visualLabel: string;}) => (- <Flex aria-label={groupLabel} flexWrap="wrap" gap="1" role="group">+ <Group aria-label={groupLabel} attached role="group"><Buttonaria-pressed={mode === 'visual'}disabled={disabled}- flex="1 1 8rem"- minH="10"+ {...SAM_COMPACT_CONTROL_LAYOUT}variant={mode === 'visual' ? 'solid' : 'ghost'}onClick={onVisual}>@@ -180,17 +202,16 @@ export const SamModeToggle = ({<Buttonaria-pressed={mode === 'prompt'}disabled={disabled}- flex="1 1 8rem"- minH="10"+ {...SAM_COMPACT_CONTROL_LAYOUT}variant={mode === 'prompt' ? 'solid' : 'ghost'}onClick={onPrompt}>{promptLabel}</Button>- </Flex>+ </Group>);-const SamVisualBody = ({+export const SamVisualBody = ({disabled,session,viewModel,@@ -205,75 +226,67 @@ const SamVisualBody = ({}) => {const { t } = useTranslation();return (- <Stack gap="3">- <Box>- <Text fontSize="xs" fontWeight="semibold" mb="2">- {t('widgets.layers.selectObject.pointType')}- </Text>- <Grid gap="2" templateColumns={SAM_AUTO_FIT_COLUMNS}>- <Button- aria-pressed={session.pointLabel === 'include'}- disabled={disabled}- minH="10"- variant={session.pointLabel === 'include' ? 'solid' : 'outline'}- onClick={onInclude}- >- <Text as="span" fontVariantNumeric="tabular-nums">- {t('widgets.layers.selectObject.includeCount', { count: viewModel.includeCount })}- </Text>- </Button>- <Button- aria-pressed={session.pointLabel === 'exclude'}- disabled={disabled}- minH="10"- variant={session.pointLabel === 'exclude' ? 'solid' : 'outline'}- onClick={onExclude}- >- <Text as="span" fontVariantNumeric="tabular-nums">- {t('widgets.layers.selectObject.excludeCount', { count: viewModel.excludeCount })}- </Text>- </Button>- </Grid>- </Box>+ <Flex+ align="center"+ aria-label={t('widgets.layers.selectObject.pointType')}+ flexWrap="wrap"+ gap="2"+ role="group"+ title={t('widgets.layers.selectObject.visualGuidance')}+ >+ <Group attached>+ <Button+ aria-pressed={session.pointLabel === 'include'}+ disabled={disabled}+ {...SAM_COMPACT_CONTROL_LAYOUT}+ variant={session.pointLabel === 'include' ? 'solid' : 'outline'}+ onClick={onInclude}+ >+ <Text as="span" fontVariantNumeric="tabular-nums">+ {t('widgets.layers.selectObject.includeCount', { count: viewModel.includeCount })}+ </Text>+ </Button>+ <Button+ aria-pressed={session.pointLabel === 'exclude'}+ disabled={disabled}+ {...SAM_COMPACT_CONTROL_LAYOUT}+ variant={session.pointLabel === 'exclude' ? 'solid' : 'outline'}+ onClick={onExclude}+ >+ <Text as="span" fontVariantNumeric="tabular-nums">+ {t('widgets.layers.selectObject.excludeCount', { count: viewModel.excludeCount })}+ </Text>+ </Button>+ </Group><Text color={viewModel.bboxActive ? 'fg' : 'fg.muted'} fontSize="xs" fontWeight="medium">{viewModel.bboxActive? t('widgets.layers.selectObject.bboxActive'): t('widgets.layers.selectObject.bboxInactive')}</Text>- <Text color="fg.muted" fontSize="xs">- {t('widgets.layers.selectObject.visualGuidance')}- </Text>- </Stack>+ </Flex>);};-const SamPromptBody = ({+export const SamPromptBody = ({disabled,prompt,onChange,}: {disabled: boolean;prompt: string;- onChange(event: ChangeEvent<HTMLTextAreaElement>): void;+ onChange(event: ChangeEvent<HTMLInputElement>): void;}) => {const { t } = useTranslation();return (- <Stack gap="2">- <Field label={t('widgets.layers.selectObject.prompt')}>- <Textarea- aria-label={t('widgets.layers.selectObject.prompt')}- autoComplete="off"- disabled={disabled}- minH="24"- resize="vertical"- value={prompt}- onChange={onChange}- />- </Field>- <Text color="fg.muted" fontSize="xs">- {t('widgets.layers.selectObject.promptGuidance')}- </Text>- </Stack>+ <Input+ aria-label={t('widgets.layers.selectObject.prompt')}+ autoComplete="off"+ disabled={disabled}+ placeholder={t('widgets.layers.selectObject.promptGuidance')}+ value={prompt}+ {...SAM_COMPACT_CONTROL_LAYOUT}+ onChange={onChange}+ />);};@@ -305,9 +318,7 @@ export const SamOptions = ({}const eligibility = getSamActionEligibility(session, isExternalInteractionLocked);- const viewModel = getSamPanelViewModel(session, (width, height) =>- t('widgets.layers.selectObject.sourceSummary', { height, width })- );+ const viewModel = getSamPanelViewModel(session, (width, height) => `${width} × ${height}`);const isProcessing =session.status === 'preparing-composite' ||session.status === 'uploading' ||@@ -319,16 +330,16 @@ export const SamOptions = ({return (<CanvasOperationPanel.Root aria-labelledby="sam-operation-title" operation="select-object"><CanvasOperationPanel.Header>- <Stack gap="3">- <Box>+ <Flex align="center" flexWrap="wrap" gap="3" justify="space-between">+ <Flex align="baseline" gap="2" minW="0"><Heading fontSize="md" id="sam-operation-title">{t('widgets.layers.selectObject.title')}</Heading>- <Text color="fg.muted" fontSize="xs" fontVariantNumeric="tabular-nums">+ <Text color="fg.muted" fontSize="xs" fontVariantNumeric="tabular-nums" whiteSpace="nowrap">{viewModel.sourceSummary}</Text>- </Box>- <Grid gap="2" templateColumns={SAM_AUTO_FIT_COLUMNS}>+ </Flex>+ <Flex align="center" flexWrap="wrap" gap="3"><SamSwitchchecked={session.autoProcess}disabled={!eligibility.canEditInputs}@@ -341,12 +352,12 @@ export const SamOptions = ({label={t('widgets.layers.selectObject.isolatedPreview')}onChange={(value) => setBoolean('isolatedPreview', value)}/>- </Grid>- </Stack>+ </Flex>+ </Flex></CanvasOperationPanel.Header><CanvasOperationPanel.Body>- <Stack gap="4">- <Stack gap="2">+ <Stack gap="3">+ <Flex align="center" gap="2" justify="space-between"><SamModeToggledisabled={!eligibility.canEditInputs}groupLabel={t('widgets.layers.selectObject.mode')}@@ -366,7 +377,7 @@ export const SamOptions = ({label={t('widgets.layers.selectObject.invert')}onChange={(value) => setBoolean('invert', value)}/>- </Stack>+ </Flex>{session.input.type === 'visual' ? (<SamVisualBodydisabled={!eligibility.canEditInputs}@@ -384,62 +395,73 @@ export const SamOptions = ({}/>)}- <Stack borderTopWidth="1px" gap="3" pt="4">- <Heading fontSize="sm">{t('widgets.layers.selectObject.modelAndRefinement')}</Heading>- <Field label={t('widgets.layers.selectObject.model')}>- <NativeSelect.Root disabled={isProcessing || !eligibility.canEditInputs} minH="10" size="sm">- <NativeSelect.Field- aria-label={t('widgets.layers.selectObject.model')}- value={session.model}- onChange={(event) =>- engine.updateSelectObjectSession({ model: event.currentTarget.value as SamModel })- }- >- <option value="segment-anything-2-large">{t('widgets.layers.selectObject.modelSam2Large')}</option>- <option value="segment-anything-huge">{t('widgets.layers.selectObject.modelHuge')}</option>- </NativeSelect.Field>- <NativeSelect.Indicator />- </NativeSelect.Root>- </Field>+ <Flex align="center" flexWrap="wrap" gap="2">+ <Text asChild fontSize="xs" fontWeight="semibold">+ <label htmlFor="sam-model">{t('widgets.layers.selectObject.model')}</label>+ </Text>+ <NativeSelect.Root+ disabled={isProcessing || !eligibility.canEditInputs}+ {...SAM_COMPACT_CONTROL_LAYOUT}+ {...SAM_MODEL_SELECT_LAYOUT}+ >+ <NativeSelect.Field+ aria-label={t('widgets.layers.selectObject.model')}+ id="sam-model"+ value={session.model}+ onChange={(event) => engine.updateSelectObjectSession({ model: event.currentTarget.value as SamModel })}+ >+ <option value="segment-anything-2-large">{t('widgets.layers.selectObject.modelSam2Large')}</option>+ <option value="segment-anything-huge">{t('widgets.layers.selectObject.modelHuge')}</option>+ </NativeSelect.Field>+ <NativeSelect.Indicator />+ </NativeSelect.Root><SamSwitchchecked={session.applyPolygonRefinement}disabled={isProcessing || !eligibility.canEditInputs}label={t('widgets.layers.selectObject.refine')}onChange={(value) => setBoolean('applyPolygonRefinement', value)}/>- </Stack>+ </Flex></Stack></CanvasOperationPanel.Body>- <CanvasOperationPanel.Feedback color={session.error ? 'fg.error' : 'fg.muted'} fontSize="xs">- <SamProcessFeedback- error={session.error}- errorText={session.error ? t(getSamErrorTranslationKey(session.error.code)) : null}- statusText={t(getSamStatusTranslationKey(session.status))}- />- </CanvasOperationPanel.Feedback>- <CanvasOperationPanel.Footer>+ {session.error || isProcessing || session.status === 'scheduled' || session.status === 'committing' ? (+ <CanvasOperationPanel.Feedback color={session.error ? 'fg.error' : 'fg.muted'} fontSize="xs">+ <SamProcessFeedback+ error={session.error}+ errorText={session.error ? t(getSamErrorTranslationKey(session.error.code)) : null}+ isBusy={!session.error}+ statusText={t(getSamStatusTranslationKey(session.status))}+ />+ </CanvasOperationPanel.Feedback>+ ) : null}+ <CanvasOperationPanel.Footer {...SAM_COMPACT_FOOTER_LAYOUT}><Buttondisabled={!eligibility.canProcess}loading={isProcessing}- minH="10"+ {...SAM_COMPACT_CONTROL_LAYOUT}onClick={() => void engine.processSelectObjectSession()}>{t('widgets.layers.selectObject.process')}</Button>+ <Button+ colorPalette="accent"+ disabled={!eligibility.canApply}+ {...SAM_COMPACT_CONTROL_LAYOUT}+ onClick={() => void engine.applySelectObjectSession()}+ >+ {t('common.apply')}+ </Button><Buttondisabled={!eligibility.canReset}- minH="10"- variant="outline"+ variant="ghost"+ {...SAM_COMPACT_CONTROL_LAYOUT}onClick={() => engine.resetSelectObjectSession()}>{t('widgets.layers.selectObject.reset')}</Button>- <Button disabled={!eligibility.canApply} minH="10" onClick={() => void engine.applySelectObjectSession()}>- {t('common.apply')}- </Button><Menu.Root><Menu.Trigger asChild>- <Button disabled={!eligibility.canSave} minH="10" variant="outline">+ <Button disabled={!eligibility.canSave} variant="outline" {...SAM_COMPACT_CONTROL_LAYOUT}>{t('widgets.layers.selectObject.saveAs')} <ChevronDownIcon size={14} /></Button></Menu.Trigger>@@ -455,8 +477,8 @@ export const SamOptions = ({</Menu.Root><Buttondisabled={!eligibility.canCancel}- minH="10"variant="ghost"+ {...SAM_COMPACT_CONTROL_LAYOUT}onClick={() => engine.cancelSelectObjectSession()}>{t('common.cancel')}