refactor: group assistant runtime controls
This commit is contained in:
1 parent
e6981a7f44
commit
1d15b614f3
3 files changed
+192
-64
No files matched your search
@@ -95,11 +95,11 @@ as part of the prompt.
|
|||||||
|
|
||||||
Type `@` in the composer to add permission-checked context. The nested menu contains apps, integrations,
|
Type `@` in the composer to add permission-checked context. The nested menu contains apps, integrations,
|
||||||
boards, widgets, and tools available to the current user. Homarr validates every referenced ID again on
|
boards, widgets, and tools available to the current user. Homarr validates every referenced ID again on
|
||||||
the server before adding it to the model context. Type `/` for common prompt shortcuts. The compact
|
the server before adding it to the model context. Type `/` for common prompt shortcuts. The joined
|
||||||
controls below the composer can switch between models discovered from the configured endpoint. Model
|
controls below the composer open a searchable model picker and the thinking-level menu. Model selection
|
||||||
selection is stored on the conversation after a completed request. Thinking mode can be left on
|
is stored on the conversation after a completed request. Thinking mode can be left on **Auto**, disabled,
|
||||||
**Auto**, disabled, or set from minimal through high; explicit levels are sent using the AI SDK's
|
or set from minimal through high; explicit levels are sent using the AI SDK's provider-neutral reasoning
|
||||||
provider-neutral reasoning setting and still depend on support from the chosen model and endpoint.
|
setting and still depend on support from the chosen model and endpoint.
|
||||||
|
|
||||||
Each completed response includes a circular context-window meter. Select it to open request details when
|
Each completed response includes a circular context-window meter. Select it to open request details when
|
||||||
the provider reports them: input, output, cached-input and reasoning tokens, used and remaining context,
|
the provider reports them: input, output, cached-input and reasoning tokens, used and remaining context,
|
||||||
|
|||||||
@@ -740,30 +740,70 @@
|
|||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modelSelect {
|
.runtimeButtonGroup {
|
||||||
width: min(15rem, 52%);
|
min-width: 0;
|
||||||
min-width: 8rem;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.reasoningSelect {
|
.runtimeButton {
|
||||||
width: 8.75rem;
|
min-width: 0;
|
||||||
flex: 0 0 auto;
|
border-color: var(--mantine-color-default-border);
|
||||||
}
|
color: var(--mantine-color-text);
|
||||||
|
|
||||||
.runtimeSelectInput {
|
|
||||||
border-color: transparent;
|
|
||||||
border-radius: var(--mantine-radius-md);
|
|
||||||
background: var(--mantine-color-body);
|
background: var(--mantine-color-body);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.runtimeSelectInput:hover {
|
.runtimeButton:hover {
|
||||||
background: var(--mantine-color-default-hover);
|
background: var(--mantine-color-default-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
.runtimeSelectInput:focus,
|
.runtimeButtonLabel {
|
||||||
.runtimeSelectInput:focus-within {
|
min-width: 0;
|
||||||
border-color: var(--mantine-primary-color-filled);
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modelButton {
|
||||||
|
min-width: 8rem;
|
||||||
|
max-width: 15rem;
|
||||||
|
flex: 1 1 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reasoningButton {
|
||||||
|
min-width: 7.5rem;
|
||||||
|
max-width: 10.5rem;
|
||||||
|
flex: 0 1 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modelDropdown {
|
||||||
|
max-width: calc(100vw - 2rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modelOptions {
|
||||||
|
max-height: min(18rem, 42dvh);
|
||||||
|
overflow-y: auto;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modelOption {
|
||||||
|
padding-block: 0.45rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modelOptionText {
|
||||||
|
min-width: 0;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.runtimeOptionCheck {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
color: var(--mantine-primary-color-filled);
|
||||||
|
}
|
||||||
|
|
||||||
|
.runtimeMenuItem[data-selected] {
|
||||||
|
color: var(--mantine-primary-color-filled);
|
||||||
|
background: var(--mantine-primary-color-light);
|
||||||
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.triggerPopover {
|
.triggerPopover {
|
||||||
@@ -918,10 +958,17 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modelSelect {
|
.runtimeButtonGroup {
|
||||||
width: auto;
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modelButton {
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
flex: 1 1 auto;
|
max-width: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reasoningButton {
|
||||||
|
max-width: 9rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.suggestions {
|
.suggestions {
|
||||||
@@ -970,8 +1017,9 @@
|
|||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
}
|
}
|
||||||
|
|
||||||
.reasoningSelect {
|
.reasoningButton {
|
||||||
width: 7.75rem;
|
min-width: 2.5rem;
|
||||||
|
max-width: 7.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.approvalActions {
|
.approvalActions {
|
||||||
|
|||||||
@@ -36,19 +36,21 @@ import {
|
|||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
Collapse,
|
Collapse,
|
||||||
|
Combobox,
|
||||||
Divider,
|
Divider,
|
||||||
FocusTrap,
|
FocusTrap,
|
||||||
Group,
|
Group,
|
||||||
Loader,
|
Loader,
|
||||||
|
Menu,
|
||||||
Popover,
|
Popover,
|
||||||
RingProgress,
|
RingProgress,
|
||||||
ScrollArea,
|
ScrollArea,
|
||||||
Select,
|
|
||||||
Stack,
|
Stack,
|
||||||
Text,
|
Text,
|
||||||
ThemeIcon,
|
ThemeIcon,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
UnstyledButton,
|
UnstyledButton,
|
||||||
|
useCombobox,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useWindowEvent } from "@mantine/hooks";
|
import { useWindowEvent } from "@mantine/hooks";
|
||||||
import {
|
import {
|
||||||
@@ -1212,45 +1214,123 @@ const RuntimeControls = ({
|
|||||||
onReasoningChange,
|
onReasoningChange,
|
||||||
}: ComposerProps) => {
|
}: ComposerProps) => {
|
||||||
const t = useScopedI18n("common.assistant");
|
const t = useScopedI18n("common.assistant");
|
||||||
|
const [modelSearch, setModelSearch] = useState("");
|
||||||
|
const selectedModel = models.find((model) => model.id === modelId);
|
||||||
|
const normalizedModelSearch = modelSearch.trim().toLocaleLowerCase();
|
||||||
|
const visibleModels =
|
||||||
|
normalizedModelSearch.length === 0
|
||||||
|
? models
|
||||||
|
: models.filter(
|
||||||
|
(model) =>
|
||||||
|
model.name.toLocaleLowerCase().includes(normalizedModelSearch) ||
|
||||||
|
model.id.toLocaleLowerCase().includes(normalizedModelSearch),
|
||||||
|
);
|
||||||
|
const modelCombobox = useCombobox({
|
||||||
|
onDropdownOpen: () => {
|
||||||
|
modelCombobox.selectActiveOption();
|
||||||
|
requestAnimationFrame(() => modelCombobox.focusSearchInput());
|
||||||
|
},
|
||||||
|
onDropdownClose: () => {
|
||||||
|
modelCombobox.resetSelectedOption();
|
||||||
|
setModelSearch("");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const selectModel = (value: string) => {
|
||||||
|
if (!models.some((model) => model.id === value)) return;
|
||||||
|
onModelChange(value);
|
||||||
|
modelCombobox.closeDropdown();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group className={classes.runtimeControls} gap={6} wrap="nowrap">
|
<Group className={classes.runtimeControls} gap={0} wrap="nowrap">
|
||||||
<Select
|
<Button.Group
|
||||||
className={classes.modelSelect}
|
className={classes.runtimeButtonGroup}
|
||||||
classNames={{ input: classes.runtimeSelectInput }}
|
aria-label={`${t("runtime.model")}, ${t("runtime.thinking")}`}
|
||||||
size="xs"
|
>
|
||||||
value={modelId}
|
<Combobox store={modelCombobox} onOptionSubmit={selectModel} withinPortal position="top-start" width={320}>
|
||||||
onChange={(value) => {
|
<Combobox.Target>
|
||||||
if (value) onModelChange(value);
|
<Button
|
||||||
}}
|
className={classes.modelButton}
|
||||||
data={models.map((model) => ({ value: model.id, label: model.name }))}
|
classNames={{ root: classes.runtimeButton, label: classes.runtimeButtonLabel }}
|
||||||
searchable
|
variant="default"
|
||||||
allowDeselect={false}
|
size="compact-sm"
|
||||||
disabled={modelOptionsLoading || models.length === 0}
|
disabled={modelOptionsLoading || models.length === 0}
|
||||||
leftSection={modelOptionsLoading ? <Loader size={13} /> : <IconSparkles size={14} />}
|
leftSection={modelOptionsLoading ? <Loader size={13} /> : <IconSparkles size={14} />}
|
||||||
aria-label={t("runtime.model")}
|
rightSection={<Combobox.Chevron size="xs" />}
|
||||||
placeholder={t("runtime.model")}
|
onClick={() => modelCombobox.toggleDropdown()}
|
||||||
nothingFoundMessage={t("runtime.noModels")}
|
aria-label={`${t("runtime.model")}: ${selectedModel?.name ?? t("runtime.noModels")}`}
|
||||||
comboboxProps={{ withinPortal: true, position: "top-start" }}
|
title={selectedModel?.name}
|
||||||
/>
|
>
|
||||||
<Select
|
{selectedModel?.name ?? t("runtime.model")}
|
||||||
className={classes.reasoningSelect}
|
</Button>
|
||||||
classNames={{ input: classes.runtimeSelectInput }}
|
</Combobox.Target>
|
||||||
size="xs"
|
<Combobox.Dropdown className={classes.modelDropdown}>
|
||||||
value={reasoning}
|
<Combobox.Search
|
||||||
onChange={(value) => {
|
value={modelSearch}
|
||||||
if (value && assistantReasoningModes.includes(value as AssistantReasoningMode)) {
|
onChange={(event) => {
|
||||||
onReasoningChange(value as AssistantReasoningMode);
|
setModelSearch(event.currentTarget.value);
|
||||||
}
|
modelCombobox.updateSelectedOptionIndex();
|
||||||
}}
|
}}
|
||||||
data={assistantReasoningModes.map((mode) => ({
|
placeholder={t("runtime.model")}
|
||||||
value: mode,
|
aria-label={t("runtime.model")}
|
||||||
label: t(`runtime.reasoning.${mode}`),
|
/>
|
||||||
}))}
|
<Combobox.Options className={classes.modelOptions}>
|
||||||
allowDeselect={false}
|
{visibleModels.map((model) => (
|
||||||
leftSection={<IconBrain size={14} />}
|
<Combobox.Option
|
||||||
aria-label={t("runtime.thinking")}
|
className={classes.modelOption}
|
||||||
comboboxProps={{ withinPortal: true, position: "top-end" }}
|
key={model.id}
|
||||||
/>
|
value={model.id}
|
||||||
|
active={model.id === modelId}
|
||||||
|
>
|
||||||
|
<Group gap="xs" wrap="nowrap">
|
||||||
|
<Stack gap={0} className={classes.modelOptionText}>
|
||||||
|
<Text size="sm" fw={model.id === modelId ? 650 : 500} lineClamp={1}>
|
||||||
|
{model.name}
|
||||||
|
</Text>
|
||||||
|
<Text size="xs" c="dimmed" lineClamp={1}>
|
||||||
|
{model.id}
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
{model.id === modelId && <IconCheck size={15} className={classes.runtimeOptionCheck} />}
|
||||||
|
</Group>
|
||||||
|
</Combobox.Option>
|
||||||
|
))}
|
||||||
|
{visibleModels.length === 0 && <Combobox.Empty>{t("runtime.noModels")}</Combobox.Empty>}
|
||||||
|
</Combobox.Options>
|
||||||
|
</Combobox.Dropdown>
|
||||||
|
</Combobox>
|
||||||
|
<Menu position="top-end" width={210} withinPortal>
|
||||||
|
<Menu.Target>
|
||||||
|
<Button
|
||||||
|
className={classes.reasoningButton}
|
||||||
|
classNames={{ root: classes.runtimeButton, label: classes.runtimeButtonLabel }}
|
||||||
|
variant="default"
|
||||||
|
size="compact-sm"
|
||||||
|
leftSection={<IconBrain size={14} />}
|
||||||
|
rightSection={<IconChevronUp size={14} />}
|
||||||
|
aria-label={`${t("runtime.thinking")}: ${t(`runtime.reasoning.${reasoning}`)}`}
|
||||||
|
title={t(`runtime.reasoning.${reasoning}`)}
|
||||||
|
>
|
||||||
|
{t(`runtime.reasoning.${reasoning}`)}
|
||||||
|
</Button>
|
||||||
|
</Menu.Target>
|
||||||
|
<Menu.Dropdown>
|
||||||
|
<Menu.Label>{t("runtime.thinking")}</Menu.Label>
|
||||||
|
{assistantReasoningModes.map((mode) => (
|
||||||
|
<Menu.Item
|
||||||
|
key={mode}
|
||||||
|
className={classes.runtimeMenuItem}
|
||||||
|
data-selected={mode === reasoning || undefined}
|
||||||
|
rightSection={mode === reasoning ? <IconCheck size={15} /> : null}
|
||||||
|
onClick={() => onReasoningChange(mode)}
|
||||||
|
>
|
||||||
|
{t(`runtime.reasoning.${mode}`)}
|
||||||
|
</Menu.Item>
|
||||||
|
))}
|
||||||
|
</Menu.Dropdown>
|
||||||
|
</Menu>
|
||||||
|
</Button.Group>
|
||||||
</Group>
|
</Group>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user