From 6543739aac4d1523acc27aad19be0706229be10d Mon Sep 17 00:00:00 2001 From: NeilJo-GY <43027886+NeilJo-GY@users.noreply.github.com> Date: Tue, 1 Sep 2026 21:18:21 +0800 Subject: [PATCH] fix(settings): treat heartbeat as default and restore on no ack Owner Save waits for the agent runtime. Show the live preferred model, say when sync is in progress, and snap the draft back if Gateway returns agent_unreachable so listing never impersonates a failed apply. Co-authored-by: Cursor --- .../src/ranch-shell/AgentOwnerSettings.tsx | 18 +++++++++++------- .../src/ranch-shell/RanchChatShell.tsx | 6 ++++++ packages/agent-chat/src/ranch-shell/i18n.ts | 6 ++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/packages/agent-chat/src/ranch-shell/AgentOwnerSettings.tsx b/packages/agent-chat/src/ranch-shell/AgentOwnerSettings.tsx index 962af7f..10cfa71 100644 --- a/packages/agent-chat/src/ranch-shell/AgentOwnerSettings.tsx +++ b/packages/agent-chat/src/ranch-shell/AgentOwnerSettings.tsx @@ -162,11 +162,11 @@ function resolvePricingModelId( detail: MyAgentSummary, supported: string[] = [], ): string { - // Saved listing wins unless it is a leftover OpenRouter shelf id. - const listed = (detail.token_pricing?.model_id || "").trim(); + // Heartbeat default wins. Stale listing must not impersonate the machine. const runtime = (detail.runtime_model_id || "").trim(); - if (listed && !listingIsStaleOpenRouter(listed, runtime, supported)) return listed; if (runtime) return runtime; + const listed = (detail.token_pricing?.model_id || "").trim(); + if (listed && !listingIsStaleOpenRouter(listed, runtime, supported)) return listed; const preferred = (detail.preferred_model_id || "").trim(); if (preferred) return preferred; return FALLBACK_MODEL_ID; @@ -1554,11 +1554,15 @@ export function AgentOwnerSettings({ return row; }) .catch((err: unknown) => { + const code = err instanceof ChatGatewayError ? err.code : ""; const msg = - err instanceof ChatGatewayError && err.message.trim() - ? err.message.trim() - : t.myAgentsPricingFailed; + code === "agent_unreachable" + ? t.myAgentsPricingNoAck + : err instanceof ChatGatewayError && err.message.trim() + ? err.message.trim() + : t.myAgentsPricingFailed; setPricingError(msg); + setModelIdDraft(resolvePricingModelId(detail, supportedModels)); return null; }) .finally(() => setSavingPricing(false)); @@ -2677,7 +2681,7 @@ export function AgentOwnerSettings({ disabled={!canSaveAny} onClick={saveAll} > - {saving ? t.loading : t.save} + {savingPricing ? t.myAgentsPricingSyncing : saving ? t.loading : t.save} ) : null}