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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Clarify Assistant gateway fallback and command copy
rcourtman5c4b54251de9
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex d44ae3c2e0..e2e5858519 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -158,9 +158,9 @@ runtime cost control, and shared AI transport surfaces.active stream becomes idle. Queued follow-ups must snapshot the effectivemodel route at enqueue time so a later model/provider switch cannot silentlyreroute an already-queued user turn; explicit failed-turn recovery actions- such as `Retry via OpenRouter` must pass their selected route as an override- instead of relying on ambient selector state. The referenced OpenCode source- at fetched `origin/dev` commit+ labelled from a configured provider route must pass that selected route as an+ override instead of relying on ambient selector state. The referenced+ OpenCode source at fetched `origin/dev` commit`1399323b78a04229d9bfe00c7436d7f41770fda8` keeps current, recent, andselected models as structured `{ providerID, modelID }` values in`packages/opencode/src/cli/cmd/tui/component/dialog-model.tsx` and@@ -447,14 +447,16 @@ runtime cost control, and shared AI transport surfaces.chat route or a stable provider default without calling provider modelcatalogs before the selected stream starts. Catalog-backed recommendationbelongs to settings/model-list flows, not `/api/ai/chat` first-response- startup. When the selected direct-provider route fails before visible output- and OpenRouter is configured, fallback planning should first try the same- vendor/model through the OpenRouter route where a deterministic gateway id- can be formed, such as `deepseek:deepseek-v4-pro` to- `openrouter:deepseek/deepseek-v4-pro`, before falling back to unrelated- provider defaults. That same-model gateway planning must remain catalog-free- and may continue to the next configured provider if the gateway attempt also- fails before visible output. Once visible output has streamed, Pulse must+ startup. When the selected direct-provider route fails before visible output,+ fallback planning may first try configured gateway-equivalent candidates+ returned by `internal/ai/modelresolution` when they preserve the same+ provider/model family through a deterministic route string, before falling+ back to unrelated configured provider defaults. That same-model gateway+ planning must remain catalog-free, capability-driven, and may continue to the+ next configured provider if a gateway attempt also fails before visible+ output; chat execution and frontend UI must never encode user-specific+ network assumptions or named-provider failover rules. Once visible output has+ streamed, Pulse mustnot silently switch providers for that turn; the error belongs to the visibleattempt and is surfaced through normal failed-turn recovery. Assistantstartup retry behavior must be route-aware: when another provider/model@@ -1038,7 +1040,8 @@ runtime cost control, and shared AI transport surfaces.operator action label as the primary row and adding a sanitized `$ ...`command preview below it when the tool input carries a shell command; rawprovider envelopes such as `pulse_read(...)`, raw JSON, and full command- output remain Details-only.+ output remain Details-only. Any visible command-copy affordance must copy+ that same sanitized command preview rather than the raw provider/tool input.The referenced OpenCode source atcommit`9ed17da55ab1f7360cc0e01075f763e27fa899e9` also renders pending tool rowsdiff --git a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsxindex 2d4070af78..b5577131c1 100644--- a/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx+++ b/frontend-modern/src/components/AI/Chat/ToolExecutionBlock.tsx@@ -172,15 +172,60 @@ const ToolInputSummary: Component<ToolInputSummaryProps> = (props) => {};const ToolCommandPreview: Component<ToolCommandPreviewProps> = (props) => (- <code- data-testid="tool-command-preview"- aria-label="Tool command"- class="mt-1 block whitespace-pre-wrap break-words font-mono text-[11px] leading-5 text-muted"- >- {props.preview}- </code>+ <VisibleToolCommandPreview preview={props.preview} />);+const VisibleToolCommandPreview: Component<ToolCommandPreviewProps> = (props) => {+ const [copied, setCopied] = createSignal(false);+ let copiedResetTimer: number | undefined;+ const copyLabel = () => (copied() ? 'Copied tool command' : 'Copy tool command');+ const commandText = () => props.preview.replace(/^\$\s*/, '').trim() || props.preview.trim();++ const copyCommand = async (event: MouseEvent) => {+ event.stopPropagation();+ const text = commandText();+ if (!text) return;+ const ok = await copyToClipboard(text);+ if (!ok) return;+ setCopied(true);+ if (copiedResetTimer) window.clearTimeout(copiedResetTimer);+ copiedResetTimer = window.setTimeout(() => setCopied(false), 1500);+ };++ const handleKeyDown = (event: KeyboardEvent) => {+ event.stopPropagation();+ };++ onCleanup(() => {+ if (copiedResetTimer) window.clearTimeout(copiedResetTimer);+ });++ return (+ <div class="mt-1 flex min-w-0 items-start gap-1.5">+ <code+ data-testid="tool-command-preview"+ aria-label="Tool command"+ class="min-w-0 flex-1 whitespace-pre-wrap break-words font-mono text-[11px] leading-5 text-muted"+ >+ {props.preview}+ </code>+ <button+ type="button"+ class="mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded border border-border-subtle bg-surface text-muted transition-colors hover:bg-surface-hover hover:text-base-content focus:outline-none focus:ring-2 focus:ring-blue-500/30"+ onClick={(event) => void copyCommand(event)}+ onMouseDown={(event) => event.stopPropagation()}+ onKeyDown={handleKeyDown}+ title={copyLabel()}+ aria-label={copyLabel()}+ >+ <Show when={copied()} fallback={<CopyIcon class="h-3 w-3" aria-hidden="true" />}>+ <CheckIcon class="h-3 w-3 text-emerald-600" aria-hidden="true" />+ </Show>+ </button>+ </div>+ );+};+const normalizeDetailText = (value?: string) => value?.trim() ?? '';const toolDetailInputText = (input: string, rawInput?: string) => {@@ -301,7 +346,9 @@ export const ToolExecutionBlock: Component<ToolExecutionBlockProps> = (props) =>const hiddenOutputSummary = createMemo(() =>outputPreview() ? '' : formatHiddenOutputSummary(outputText()),);- const hiddenOutputBadgeLabel = createMemo(() => (hiddenOutputSummary() ? 'output available' : ''));+ const hiddenOutputBadgeLabel = createMemo(() =>+ hiddenOutputSummary() ? 'output available' : '',+ );const hasInput = createMemo(() => detailInputText().trim().length > 0);const hasOutput = createMemo(() => hasReadableToolOutput(outputText()));const hasDetails = createMemo(() => hasInput() || hasOutput());diff --git a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsxindex f01032d2d3..9c8891eb0a 100644--- a/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx+++ b/frontend-modern/src/components/AI/Chat/__tests__/ToolExecutionBlock.test.tsx@@ -290,6 +290,36 @@ describe('ToolExecutionBlock', () => {expect(screen.queryByText(/"target_host"/)).not.toBeInTheDocument();});+ it('copies the sanitized visible command preview without opening raw details', async () => {+ const writeText = vi.fn().mockResolvedValue(undefined);+ Object.defineProperty(navigator, 'clipboard', {+ value: { writeText },+ configurable: true,+ });++ render(() => (+ <ToolExecutionBlock+ tool={makeTool({+ name: 'pulse_read',+ input: '{"action":"exec","target_host":"current_resource","command":"ls /dev | wc -l"}',+ output: '42',+ })}+ />+ ));++ const trigger = getToolDetailsTrigger();+ fireEvent.click(screen.getByRole('button', { name: 'Copy tool command' }));++ await waitFor(() => {+ expect(writeText).toHaveBeenCalledWith('ls /dev | wc -l');+ });+ await waitFor(() => {+ expect(screen.getByRole('button', { name: 'Copied tool command' })).toBeInTheDocument();+ });+ expect(trigger).toHaveAttribute('aria-expanded', 'false');+ expect(screen.queryByText(/"target_host"/)).not.toBeInTheDocument();+ });+it('wraps completed command summaries instead of truncating the visible action row', () => {render(() => (<ToolExecutionBlock@@ -346,6 +376,35 @@ describe('ToolExecutionBlock', () => {expect(preview).not.toHaveTextContent('hunter2');});+ it('copies the redacted visible command preview rather than the raw command', async () => {+ const writeText = vi.fn().mockResolvedValue(undefined);+ Object.defineProperty(navigator, 'clipboard', {+ value: { writeText },+ configurable: true,+ });++ render(() => (+ <ToolExecutionBlock+ tool={makeTool({+ name: 'pulse_read',+ input:+ '{"action":"exec","command":"curl -H \\"Authorization: Bearer secret-token\\" --password hunter2 https://example.local"}',+ output: '200',+ })}+ />+ ));++ fireEvent.click(screen.getByRole('button', { name: 'Copy tool command' }));++ await waitFor(() => {+ expect(writeText).toHaveBeenCalledWith(+ 'curl -H "Authorization: Bearer [redacted-secret]" --password [redacted-secret] https://example.local',+ );+ });+ expect(writeText).not.toHaveBeenCalledWith(expect.stringContaining('secret-token'));+ expect(writeText).not.toHaveBeenCalledWith(expect.stringContaining('hunter2'));+ });+it('renders Pulse read log input as a readable log action', () => {render(() => (<ToolExecutionBlock@@ -753,6 +812,36 @@ describe('PendingToolBlock', () => {expect(screen.queryByText(/"command"/)).not.toBeInTheDocument();});+ it('copies a pending visible command preview without opening raw details', async () => {+ const writeText = vi.fn().mockResolvedValue(undefined);+ Object.defineProperty(navigator, 'clipboard', {+ value: { writeText },+ configurable: true,+ });++ render(() => (+ <PendingToolBlock+ tool={makePending({+ name: 'pulse_read',+ input:+ '{"action":"exec","target_host":"current_resource","command":"lsblk -o NAME,SIZE"}',+ })}+ />+ ));++ const trigger = getToolDetailsTrigger();+ fireEvent.click(screen.getByRole('button', { name: 'Copy tool command' }));++ await waitFor(() => {+ expect(writeText).toHaveBeenCalledWith('lsblk -o NAME,SIZE');+ });+ await waitFor(() => {+ expect(screen.getByRole('button', { name: 'Copied tool command' })).toBeInTheDocument();+ });+ expect(trigger).toHaveAttribute('aria-expanded', 'false');+ expect(screen.queryByText(/"command"/)).not.toBeInTheDocument();+ });+it('wraps pending command summaries so live tool activity stays readable', () => {render(() => (<PendingToolBlockdiff --git a/internal/ai/chat/service_execute_additional_test.go b/internal/ai/chat/service_execute_additional_test.goindex 02a8b503f3..ea3ba814a1 100644--- a/internal/ai/chat/service_execute_additional_test.go+++ b/internal/ai/chat/service_execute_additional_test.go@@ -924,7 +924,7 @@ func TestService_ExecuteStream_FallsBackWhenPrimaryProviderFailsBeforeVisibleOut}}-func TestService_ExecuteStream_FallsBackToSameModelOpenRouterGatewayBeforeDefaults(t *testing.T) {+func TestService_ExecuteStream_FallsBackToSameModelGatewayRouteBeforeDefaults(t *testing.T) {tmpDir := t.TempDir()store, err := NewSessionStore(tmpDir)if err != nil {@@ -942,7 +942,7 @@ func TestService_ExecuteStream_FallsBackToSameModelOpenRouterGatewayBeforeDefaulstreamFn: func(ctx context.Context, req providers.ChatRequest, callback providers.StreamCallback) error {callback(providers.StreamEvent{Type: "content",- Data: providers.ContentEvent{Text: "OPENROUTER_OK"},+ Data: providers.ContentEvent{Text: "GATEWAY_OK"},})callback(providers.StreamEvent{Type: "done",@@ -974,7 +974,7 @@ func TestService_ExecuteStream_FallsBackToSameModelOpenRouterGatewayBeforeDefaulvar fallbackNextModel stringvar doneModel stringerr = service.ExecuteStream(context.Background(), ExecuteRequest{- SessionID: "fallback-to-openrouter-same-model",+ SessionID: "fallback-to-same-model-gateway",Prompt: "reply",}, func(event StreamEvent) {switch event.Type {@@ -1003,14 +1003,14 @@ func TestService_ExecuteStream_FallsBackToSameModelOpenRouterGatewayBeforeDefaulif err != nil {t.Fatalf("ExecuteStream failed: %v", err)}- if got := content.String(); got != "OPENROUTER_OK" {- t.Fatalf("content = %q, want OpenRouter fallback response", got)+ if got := content.String(); got != "GATEWAY_OK" {+ t.Fatalf("content = %q, want gateway fallback response", got)}if fallbackNextModel != "openrouter:deepseek/deepseek-v4-pro" {- t.Fatalf("fallback next model = %q, want same-model OpenRouter route", fallbackNextModel)+ t.Fatalf("fallback next model = %q, want same-model gateway route", fallbackNextModel)}if doneModel != "openrouter:deepseek/deepseek-v4-pro" {- t.Fatalf("done model = %q, want same-model OpenRouter route", doneModel)+ t.Fatalf("done model = %q, want same-model gateway route", doneModel)}if got := primaryCalls.Load(); got != 1 {t.Fatalf("primary provider calls = %d, want one fast-fail call before fallback", got)diff --git a/internal/ai/modelresolution/model_resolution.go b/internal/ai/modelresolution/model_resolution.goindex 6bc6db736b..2680e27b47 100644--- a/internal/ai/modelresolution/model_resolution.go+++ b/internal/ai/modelresolution/model_resolution.go@@ -112,17 +112,21 @@ func ResolveConfiguredChatProviderModelOffline(cfg *config.AIConfig, provider st}type gatewayEquivalentResolver struct {- resolve func(cfg *config.AIConfig, model string) (string, bool)+ gatewayProvider string+ ownerForProvider func(provider string) string}var gatewayEquivalentResolvers = []gatewayEquivalentResolver{- {resolve: openRouterEquivalentChatModel},+ {+ gatewayProvider: config.AIProviderOpenRouter,+ ownerForProvider: openRouterOwnerForProvider,+ },}// GatewayEquivalentChatModels maps a configured direct-provider chat model to-// equivalent routes through configured gateway providers. Provider-specific-// route syntax belongs in this model-resolution registry; chat execution should-// consume the returned candidates without hardcoding a gateway.+// equivalent routes through configured gateway providers. Gateway route syntax+// belongs in this model-resolution registry; chat execution consumes candidates+// without encoding provider-specific fallback policy.func GatewayEquivalentChatModels(cfg *config.AIConfig, model string) []string {if cfg == nil {return nil@@ -147,16 +151,9 @@ func GatewayEquivalentChatModels(cfg *config.AIConfig, model string) []string {return routes}-// OpenRouterEquivalentChatModel maps a configured direct-provider chat model to-// the same vendor/model route through OpenRouter when that gateway is configured.-// It never calls a live model catalog; unsupported gateway routes simply fail as-// normal provider attempts and the chat fallback planner can continue.-func OpenRouterEquivalentChatModel(cfg *config.AIConfig, model string) (string, bool) {- return openRouterEquivalentChatModel(cfg, model)-}--func openRouterEquivalentChatModel(cfg *config.AIConfig, model string) (string, bool) {- if cfg == nil || !cfg.HasProvider(config.AIProviderOpenRouter) {+func (r gatewayEquivalentResolver) resolve(cfg *config.AIConfig, model string) (string, bool) {+ gatewayProvider := strings.TrimSpace(r.gatewayProvider)+ if cfg == nil || gatewayProvider == "" || r.ownerForProvider == nil || !cfg.HasProvider(gatewayProvider) {return "", false}provider, modelName := config.ParseModelString(strings.TrimSpace(model))@@ -164,16 +161,16 @@ func openRouterEquivalentChatModel(cfg *config.AIConfig, model string) (string,if provider == "" || modelName == "" {return "", false}- if provider == config.AIProviderOpenRouter ||+ if provider == gatewayProvider ||provider == config.AIProviderOllama ||provider == config.AIProviderQuickstart {return "", false}- openRouterOwner := openRouterOwnerForProvider(provider)- if openRouterOwner == "" {+ gatewayOwner := strings.TrimSpace(r.ownerForProvider(provider))+ if gatewayOwner == "" {return "", false}- candidate := config.FormatModelString(config.AIProviderOpenRouter, openRouterOwner+"/"+strings.TrimPrefix(modelName, openRouterOwner+"/"))+ candidate := config.FormatModelString(gatewayProvider, gatewayOwner+"/"+strings.TrimPrefix(modelName, gatewayOwner+"/"))if !IsModelUsableForChatWithConfig(cfg, candidate) {return "", false}diff --git a/internal/ai/modelresolution/model_resolution_offline_test.go b/internal/ai/modelresolution/model_resolution_offline_test.goindex ed423ff524..fd73ddc5e5 100644--- a/internal/ai/modelresolution/model_resolution_offline_test.go+++ b/internal/ai/modelresolution/model_resolution_offline_test.go@@ -56,7 +56,7 @@ func TestResolveConfiguredChatModelOffline_ReplacesSpecializedChatModelWithStabl}}-func TestOpenRouterEquivalentChatModel_MapsDirectProviderRoutes(t *testing.T) {+func TestGatewayEquivalentChatModels_MapsConfiguredGatewayEquivalentRoutes(t *testing.T) {t.Parallel()cfg := &config.AIConfig{@@ -96,23 +96,23 @@ func TestOpenRouterEquivalentChatModel_MapsDirectProviderRoutes(t *testing.T) {for _, tt := range tests {t.Run(tt.name, func(t *testing.T) {- got, ok := OpenRouterEquivalentChatModel(cfg, tt.model)- if !ok {- t.Fatalf("OpenRouterEquivalentChatModel(%q) ok = false, want true", tt.model)+ got := GatewayEquivalentChatModels(cfg, tt.model)+ if len(got) != 1 {+ t.Fatalf("GatewayEquivalentChatModels(%q) length = %d, want 1: %#v", tt.model, len(got), got)}- if got != tt.want {- t.Fatalf("OpenRouterEquivalentChatModel(%q) = %q, want %q", tt.model, got, tt.want)+ if got[0] != tt.want {+ t.Fatalf("GatewayEquivalentChatModels(%q)[0] = %q, want %q", tt.model, got[0], tt.want)}})}}-func TestOpenRouterEquivalentChatModel_RejectsUnavailableOrNonGatewayRoutes(t *testing.T) {+func TestGatewayEquivalentChatModels_RejectsUnavailableOrNonEquivalentRoutes(t *testing.T) {t.Parallel()cfg := &config.AIConfig{DeepSeekAPIKey: "deepseek-test"}- if got, ok := OpenRouterEquivalentChatModel(cfg, "deepseek:deepseek-v4-pro"); ok || got != "" {- t.Fatalf("OpenRouterEquivalentChatModel without OpenRouter = %q, %v; want empty false", got, ok)+ if got := GatewayEquivalentChatModels(cfg, "deepseek:deepseek-v4-pro"); len(got) != 0 {+ t.Fatalf("GatewayEquivalentChatModels without gateway = %#v, want empty", got)}cfg.OpenRouterAPIKey = "sk-or-test"@@ -122,28 +122,8 @@ func TestOpenRouterEquivalentChatModel_RejectsUnavailableOrNonGatewayRoutes(t *t"quickstart:minimax-2.5m","deepseek:deepseek-embed",} {- if got, ok := OpenRouterEquivalentChatModel(cfg, model); ok || got != "" {- t.Fatalf("OpenRouterEquivalentChatModel(%q) = %q, %v; want empty false", model, got, ok)- }- }-}--func TestGatewayEquivalentChatModels_ReturnsConfiguredGatewayRoutes(t *testing.T) {- t.Parallel()-- cfg := &config.AIConfig{- OpenRouterAPIKey: "sk-or-test",- DeepSeekAPIKey: "deepseek-test",- }-- got := GatewayEquivalentChatModels(cfg, "deepseek:deepseek-v4-pro")- want := []string{"openrouter:deepseek/deepseek-v4-pro"}- if len(got) != len(want) {- t.Fatalf("GatewayEquivalentChatModels length = %d, want %d: %#v", len(got), len(want), got)- }- for i := range want {- if got[i] != want[i] {- t.Fatalf("GatewayEquivalentChatModels[%d] = %q, want %q", i, got[i], want[i])+ if got := GatewayEquivalentChatModels(cfg, model); len(got) != 0 {+ t.Fatalf("GatewayEquivalentChatModels(%q) = %#v, want empty", model, got)}}}