Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Mark current Assistant model rows

rcourtman32482a547206
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 8b6c77a024..f5d7d6cd99 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -370,7 +370,16 @@ runtime cost control, and shared AI transport surfaces.
`provider:model` routes that the backend chat stream can execute. Unknown
recent or custom Pulse routes may survive catalog hydration only when they
still have a valid provider/model shape; malformed route strings must not
- become selectable chat routes.
+ become selectable chat routes. The referenced OpenCode source at commit
+ `9ed17da55ab1f7360cc0e01075f763e27fa899e9`
+ `packages/opencode/src/cli/cmd/tui/component/dialog-model.tsx` passes the
+ current structured model route into `DialogSelect` at lines 146-171, and
+ `packages/opencode/src/cli/cmd/run/footer.command.tsx` marks the current
+ direct-mode model row with a `current` footer at lines 796-804. Pulse adapts
+ that by making the shared model picker mark the selected catalog, recent,
+ override, custom, or inherited-default route as a visible `Current`
+ `role="option"` row with `aria-selected`, instead of relying on background
+ color alone.
The referenced OpenCode source at fetched `origin/dev` commit
`147169e9b78bdd8430800f883af6b6485e5156e4` runs ordinary follow-up
prompts through a serial local queue in
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index cd724cdb6b..53154f3505 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -1017,7 +1017,10 @@ not a replacement status card, CTA band, or page-local nested card.
they have a valid non-empty provider and model segment; malformed route
strings such as empty provider/model values, URL-shaped text, whitespace,
or path-only payloads must be dropped instead of becoming selectable model
- routes.
+ routes. The shared picker must also mark the selected catalog, recent,
+ override, custom, or inherited-default route as the current row with
+ visible `Current` metadata and `aria-selected`; selected model state must
+ not be communicated by background color alone.
Gateway-routed model choices must not look like direct-provider choices:
the shared picker, System AI settings status strip, and per-surface
inherited-default descriptions must render OpenRouter-hosted provider
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/ModelSelector.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/ModelSelector.test.tsx
index 8346f18dc8..e4a52f9ee0 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/ModelSelector.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/ModelSelector.test.tsx
@@ -302,13 +302,10 @@ describe('ModelSelector', () => {
fireEvent.click(screen.getByTitle('Select model for this chat'));
- // Click the Default option (the one with "Use configured default model" text)
- const defaultButtons = screen.getAllByRole('button');
- const defaultOption = defaultButtons.find((btn) =>
- btn.textContent?.includes('Use configured default model'),
- );
- expect(defaultOption).toBeDefined();
- fireEvent.click(defaultOption!);
+ const defaultOption = screen.getByRole('option', {
+ name: /Default.*Use configured default model/,
+ });
+ fireEvent.click(defaultOption);
expect(onModelSelect).toHaveBeenCalledWith('');
});
diff --git a/frontend-modern/src/components/shared/AIModelPicker.tsx b/frontend-modern/src/components/shared/AIModelPicker.tsx
index 018fe472cd..94a4eeefe1 100644
--- a/frontend-modern/src/components/shared/AIModelPicker.tsx
+++ b/frontend-modern/src/components/shared/AIModelPicker.tsx
@@ -77,6 +77,7 @@ const SEARCH_HEADER_HEIGHT = 52;
const ERROR_ROW_HEIGHT = 36;
const CUSTOM_RECENT_MODEL_DESCRIPTION = 'Recent custom model route';
const MODEL_ROUTE_PROVIDER_RE = /^[a-z][a-z0-9_-]*$/i;
+const CURRENT_SELECTION_LABEL = 'Current';
type ResolvedModelRoute = {
id: string;
@@ -109,6 +110,24 @@ const modelRouteSecondaryId = (entry: ResolvedModelRoute) => {
return model.id;
};
+const CurrentSelectionBadge: Component = () => (
+ <span class="shrink-0 rounded border border-blue-200 bg-blue-100 px-1.5 py-0.5 text-[10px] font-semibold uppercase text-blue-700 dark:border-blue-800 dark:bg-blue-950/60 dark:text-blue-200">
+ {' '}
+ {CURRENT_SELECTION_LABEL}
+ {' '}
+ </span>
+);
+
+const optionAriaLabel = (
+ label: string,
+ isSelected: boolean,
+ details: Array<string | undefined> = [],
+) =>
+ [
+ isSelected ? `${label}, ${CURRENT_SELECTION_LABEL}` : label,
+ ...details.filter((detail): detail is string => Boolean(detail?.trim())),
+ ].join('. ');
+
function groupModelsByProvider(models: ModelInfo[]): Map<string, ModelInfo[]> {
const grouped = new Map<string, ModelInfo[]>();
@@ -328,6 +347,11 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {
props.onModelSelect(modelId);
closePicker();
};
+ const isSelectedRoute = (modelId: string) => selectedModel() === modelId;
+ const optionClass = (isSelected: boolean) =>
+ `w-full px-3 py-2 text-left text-sm hover:bg-surface-hover ${
+ isSelected ? 'bg-blue-50 dark:bg-blue-900' : ''
+ }`;
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key !== 'Enter') {
@@ -453,9 +477,23 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {
<button
type="button"
onClick={() => handleSelect('')}
- class={`w-full px-3 py-2 text-left text-sm hover:bg-surface-hover ${!selectedModel() ? 'bg-blue-50 dark:bg-blue-900' : ''}`}
+ role="option"
+ aria-selected={!selectedModel()}
+ aria-label={optionAriaLabel(
+ props.defaultOption!.label,
+ !selectedModel(),
+ [props.defaultOption!.description],
+ )}
+ class={optionClass(!selectedModel())}
>
- <div class="font-medium text-base-content">{props.defaultOption!.label}</div>
+ <div class="flex min-w-0 items-center gap-2">
+ <span class="min-w-0 flex-1 truncate font-medium text-base-content">
+ {props.defaultOption!.label}
+ </span>
+ <Show when={!selectedModel()}>
+ <CurrentSelectionBadge />
+ </Show>
+ </div>
<Show when={props.defaultOption!.description}>
<div class="text-[11px] text-muted">{props.defaultOption!.description}</div>
</Show>
@@ -467,9 +505,21 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {
<button
type="button"
onClick={() => handleSelect(option.id)}
- class={`w-full px-3 py-2 text-left text-sm hover:bg-surface-hover ${selectedModel() === option.id ? 'bg-blue-50 dark:bg-blue-900' : ''}`}
+ role="option"
+ aria-selected={isSelectedRoute(option.id)}
+ aria-label={optionAriaLabel(option.label, isSelectedRoute(option.id), [
+ option.description,
+ ])}
+ class={optionClass(isSelectedRoute(option.id))}
>
- <div class="font-medium text-base-content">{option.label}</div>
+ <div class="flex min-w-0 items-center gap-2">
+ <span class="min-w-0 flex-1 truncate font-medium text-base-content">
+ {option.label}
+ </span>
+ <Show when={isSelectedRoute(option.id)}>
+ <CurrentSelectionBadge />
+ </Show>
+ </div>
<Show when={option.description}>
<div class="text-[11px] text-muted">{option.description}</div>
</Show>
@@ -481,9 +531,23 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {
<button
type="button"
onClick={() => handleSelect(customModelCandidate())}
- class="w-full px-3 py-2 text-left text-sm hover:bg-surface-hover"
+ role="option"
+ aria-selected={isSelectedRoute(customModelCandidate())}
+ aria-label={optionAriaLabel(
+ `Use "${customModelCandidate()}"`,
+ isSelectedRoute(customModelCandidate()),
+ [props.customModelDescription || 'Custom model ID'],
+ )}
+ class={optionClass(isSelectedRoute(customModelCandidate()))}
>
- <div class="font-medium text-base-content">Use "{customModelCandidate()}"</div>
+ <div class="flex min-w-0 items-center gap-2">
+ <span class="min-w-0 flex-1 truncate font-medium text-base-content">
+ Use "{customModelCandidate()}"
+ </span>
+ <Show when={isSelectedRoute(customModelCandidate())}>
+ <CurrentSelectionBadge />
+ </Show>
+ </div>
<div class="text-[11px] text-muted">
{props.customModelDescription || 'Custom model ID'}
</div>
@@ -514,9 +578,23 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {
<button
type="button"
onClick={() => handleSelect(entry.id)}
- class={`w-full px-3 py-2 text-left text-sm hover:bg-surface-hover ${selectedModel() === entry.id ? 'bg-blue-50 dark:bg-blue-900' : ''}`}
+ role="option"
+ aria-selected={isSelectedRoute(entry.id)}
+ aria-label={optionAriaLabel(
+ modelRouteLabel(entry),
+ isSelectedRoute(entry.id),
+ [modelRouteDescription(entry), modelRouteSecondaryId(entry)],
+ )}
+ class={optionClass(isSelectedRoute(entry.id))}
>
- <div class="font-medium text-base-content">{modelRouteLabel(entry)}</div>
+ <div class="flex min-w-0 items-center gap-2">
+ <span class="min-w-0 flex-1 truncate font-medium text-base-content">
+ {modelRouteLabel(entry)}
+ </span>
+ <Show when={isSelectedRoute(entry.id)}>
+ <CurrentSelectionBadge />
+ </Show>
+ </div>
<Show when={modelRouteDescription(entry)}>
<div class="line-clamp-2 text-[11px] text-muted">
{modelRouteDescription(entry)}
@@ -544,10 +622,25 @@ export const AIModelPicker: Component<AIModelPickerProps> = (props) => {
<button
type="button"
onClick={() => handleSelect(model.id)}
- class={`w-full px-3 py-2 text-left text-sm hover:bg-surface-hover ${selectedModel() === model.id ? 'bg-blue-50 dark:bg-blue-900' : ''}`}
+ role="option"
+ aria-selected={isSelectedRoute(model.id)}
+ aria-label={optionAriaLabel(
+ formatAIModelRouteLabel(model),
+ isSelectedRoute(model.id),
+ [
+ model.description,
+ model.name && model.name !== model.id ? model.id : undefined,
+ ],
+ )}
+ class={optionClass(isSelectedRoute(model.id))}
>
- <div class="font-medium text-base-content">
- {formatAIModelRouteLabel(model)}
+ <div class="flex min-w-0 items-center gap-2">
+ <span class="min-w-0 flex-1 truncate font-medium text-base-content">
+ {formatAIModelRouteLabel(model)}
+ </span>
+ <Show when={isSelectedRoute(model.id)}>
+ <CurrentSelectionBadge />
+ </Show>
</div>
<Show when={model.description}>
<div class="line-clamp-2 text-[11px] text-muted">{model.description}</div>
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index fd834b3ae8..6deefe80df 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -255,6 +255,12 @@ describe('shared primitive guardrails', () => {
expect(aiModelPickerSource).toContain('const selectedButtonLabel = createMemo');
expect(aiModelPickerSource).toContain('aria-label={selectedButtonLabel()}');
expect(aiModelPickerSource).toContain("·{' '}");
+ expect(aiModelPickerSource).toContain("const CURRENT_SELECTION_LABEL = 'Current'");
+ expect(aiModelPickerSource).toContain('const CurrentSelectionBadge');
+ expect(aiModelPickerSource).toContain('const optionAriaLabel');
+ expect(aiModelPickerSource).toContain('aria-selected={isSelectedRoute(model.id)}');
+ expect(aiModelPickerSource).toContain('aria-label={optionAriaLabel(');
+ expect(aiModelPickerSource).toContain('role="option"');
expect(aiModelPickerSource).toContain("candidate.includes('://')");
expect(aiModelPickerSource).toContain('separator <= 0 || separator === candidate.length - 1');
expect(aiModelPickerSource).toContain('MOBILE_BOTTOM_CLEARANCE');
diff --git a/frontend-modern/src/components/shared/__tests__/AIModelPicker.test.tsx b/frontend-modern/src/components/shared/__tests__/AIModelPicker.test.tsx
index 2e73943ee2..50250fb77a 100644
--- a/frontend-modern/src/components/shared/__tests__/AIModelPicker.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/AIModelPicker.test.tsx
@@ -104,6 +104,54 @@ describe('AIModelPicker', () => {
).toBe(button);
});
+ it('marks the selected catalog row as current in the model list', () => {
+ render(() => (
+ <AIModelPicker
+ models={models}
+ selectedModel="openrouter:minimax/minimax-m2.5"
+ onModelSelect={vi.fn()}
+ title="Select shared default model"
+ />
+ ));
+
+ fireEvent.click(screen.getByTitle('Select shared default model'));
+
+ const currentOption = screen.getByRole('option', {
+ name: /MiniMax: MiniMax M2\.5 via OpenRouter.*Current/,
+ });
+ expect(currentOption).toHaveAttribute('aria-selected', 'true');
+ expect(currentOption).toHaveAttribute(
+ 'aria-label',
+ 'MiniMax: MiniMax M2.5 via OpenRouter, Current. Current OpenRouter model. openrouter:minimax/minimax-m2.5',
+ );
+ expect(currentOption).toHaveTextContent('Current');
+ });
+
+ it('marks the inherited default option as current when no chat route is selected', () => {
+ render(() => (
+ <AIModelPicker
+ models={models}
+ selectedModel=""
+ onModelSelect={vi.fn()}
+ defaultOption={{
+ label: 'Default',
+ description: 'Use configured default model',
+ }}
+ title="Select shared default model"
+ />
+ ));
+
+ fireEvent.click(screen.getByTitle('Select shared default model'));
+
+ const currentOption = screen.getByRole('option', { name: /Default.*Current/ });
+ expect(currentOption).toHaveAttribute('aria-selected', 'true');
+ expect(currentOption).toHaveAttribute(
+ 'aria-label',
+ 'Default, Current. Use configured default model',
+ );
+ expect(currentOption).toHaveTextContent('Use configured default model');
+ });
+
it('constrains the dropdown to the available mobile viewport height', () => {
vi.spyOn(window, 'innerWidth', 'get').mockReturnValue(760);
vi.spyOn(window, 'innerHeight', 'get').mockReturnValue(850);