🙌 OpenHands: AI-Driven Development
fix(chat): hold a message until the cloud runtime is reachable instead of failing it (OHE-3314) (#18443)
Hiep Leecc8735e7d16
diff --git a/.pr/17955/EVIDENCE.md b/.pr/17955/EVIDENCE.mddeleted file mode 100644index 5968c77d17..0000000000--- a/.pr/17955/EVIDENCE.md+++ /dev/null@@ -1,22 +0,0 @@-# Retained verification evidence--This evidence comes from the stopped `settings-17955-after-20261013` run at-fix revision `13da51daff35ae685f8fe13d3723b69c8464ab76`.--It covers only `F10.create-prefill`: the displayed inherited temperature `0.4`-survives creation and reopening of a new LLM profile, on desktop and phone,-two attempts each. The four attempts are recorded as **xpass**; each report-contains the asserted value before and after saving. These are fix-side results,-not a complete baseline/fix proof or verification of every profile option.--`evidence/` retains 22 files: eight screenshots, eight MP4/GIF recordings,-four assertion reports and two ledgers. Some captures repeat the same state;-the count is files, not independent checks. Raw stdout/stderr, embedded recipe-scripts and machine-local paths were removed from committed reports; original-private transcripts remain outside Git. Media received credential-pattern OCR-screening across the stills and sampled recording frames. No private runtime-state, credentials or traces are committed.--The feature-map update adds the reproducible desktop/phone known-bug recipes.-The design page describes the source proposal and does not substitute for live-proof. Issue #17955 remains open; this local fix has not been merged upstream.diff --git a/.pr/17955/bug-recipes.md b/.pr/17955/bug-recipes.mddeleted file mode 100644index f77326af91..0000000000--- a/.pr/17955/bug-recipes.md+++ /dev/null@@ -1,59 +0,0 @@-# Frozen baseline/fix recipes--I am an AI agent helping Engel Nyst (@enyst) with project maintenance.--These scripts preserve the exact recipe used for comparison. Run them only against an isolated control-openhands run with the appropriate backend pins and test credential environment. The maintained feature map converts the accepted behavior to a normal recipe after verification.-- ```sh known-bug F10.create-prefill desktop-inherited- control-openhands llm set --profile QA_Inherit --model deepseek/deepseek-flash --api-key-env DEEPSEEK_API_KEY --no-activate --no-validate- control-openhands api DELETE /api/profiles/QA_Inherit --write- control-openhands api PATCH /api/settings --write --data '{"agent_settings_diff":{"llm":{"temperature":0.4}}}'- control-openhands browser viewport desktop- control-openhands browser goto /settings/llm- control-openhands browser click 'testid=add-llm-profile'- control-openhands browser click 'testid=sdk-section-all-toggle'- control-openhands assert --field value --equals 0.4 -- browser value 'testid=sdk-settings-llm.temperature'- control-openhands browser fill 'testid=llm-custom-model-input' deepseek/deepseek-flash- control-openhands browser fill 'testid=profile-name-input' QA_Inherit- control-openhands browser fill 'testid=llm-api-key-input' --value-env DEEPSEEK_API_KEY- control-openhands browser record start --feature F10.create-prefill --name inherited-save- control-openhands browser scroll 'testid=sdk-settings-llm.temperature'- control-openhands browser screenshot --feature F10.create-prefill --name inherited-before-save- control-openhands browser click 'testid=save-profile-btn'- control-openhands browser wait-text 'created'- control-openhands browser click '[data-testid=profile-row]:has([title="QA_Inherit"]) >> testid=profile-menu-trigger'- control-openhands browser click 'testid=profile-actions-menu >> testid=profile-edit'- control-openhands browser click 'testid=sdk-section-all-toggle'- control-openhands browser scroll 'testid=sdk-settings-llm.temperature'- control-openhands browser screenshot --feature F10.create-prefill --name inherited-after-save- control-openhands browser record stop --gif- control-openhands api GET /api/profiles/QA_Inherit --pick config.temperature- control-openhands assert --field value --equals 0.4 --bug-shows '' -- browser value 'testid=sdk-settings-llm.temperature' # bug- ```-- ```sh known-bug F10.create-prefill phone-inherited- control-openhands llm set --profile QA_Inherit --model deepseek/deepseek-flash --api-key-env DEEPSEEK_API_KEY --no-activate --no-validate- control-openhands api DELETE /api/profiles/QA_Inherit --write- control-openhands api PATCH /api/settings --write --data '{"agent_settings_diff":{"llm":{"temperature":0.4}}}'- control-openhands browser viewport phone- control-openhands browser goto /settings/llm- control-openhands browser click 'testid=add-llm-profile'- control-openhands browser click 'testid=sdk-section-all-toggle'- control-openhands assert --field value --equals 0.4 -- browser value 'testid=sdk-settings-llm.temperature'- control-openhands browser fill 'testid=llm-custom-model-input' deepseek/deepseek-flash- control-openhands browser fill 'testid=profile-name-input' QA_Inherit- control-openhands browser fill 'testid=llm-api-key-input' --value-env DEEPSEEK_API_KEY- control-openhands browser record start --feature F10.create-prefill --name phone-inherited-save- control-openhands browser scroll 'testid=sdk-settings-llm.temperature'- control-openhands browser screenshot --feature F10.create-prefill --name phone-inherited-before-save- control-openhands browser click 'testid=save-profile-btn'- control-openhands browser wait-text 'created'- control-openhands browser click '[data-testid=profile-row]:has([title="QA_Inherit"]) >> testid=profile-menu-trigger'- control-openhands browser click 'testid=profile-actions-menu >> testid=profile-edit'- control-openhands browser click 'testid=sdk-section-all-toggle'- control-openhands browser scroll 'testid=sdk-settings-llm.temperature'- control-openhands browser screenshot --feature F10.create-prefill --name phone-inherited-after-save- control-openhands browser record stop --gif- control-openhands api GET /api/profiles/QA_Inherit --pick config.temperature- control-openhands assert --field value --equals 0.4 --bug-shows '' -- browser value 'testid=sdk-settings-llm.temperature' # bug- ```diff --git a/.pr/17955/design.html b/.pr/17955/design.htmldeleted file mode 100644index bc033c4db1..0000000000--- a/.pr/17955/design.html+++ /dev/null@@ -1,183 +0,0 @@-<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Preserve the new profile’s displayed options</title><style> :root{--fg:#1a1a1a;--muted:#5a5a5a;--subtle:#8a8a82;--bg:#fdfdfb;--card:#fff;--elevated:#f7f6f1;--accent:#2b4eaa;--accent-soft:#e6ecfa;--rule:#e2e2dc;--code-bg:#f3f1ec;--warn:#b25b0e;--mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--sans:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--fg);font:16px/1.6 var(--sans)}.wrap{display:grid;grid-template-columns:200px minmax(0,1fr);gap:40px;max-width:1220px;margin:auto;padding:36px 28px 90px}nav{position:sticky;top:24px;align-self:start;font-size:13px}nav a{display:block;margin:12px 0;overflow-wrap:anywhere}a{color:var(--accent)}header{border-bottom:1px solid var(--rule);padding-bottom:24px}h1{font-size:34px;line-height:1.2;margin:8px 0 16px}h2{margin:36px 0 12px;font-size:23px}h3{font-size:17px}.eyebrow{font-size:11px;letter-spacing:.12em;text-transform:uppercase;color:var(--accent)}.sub{color:var(--muted)}.callout{background:var(--accent-soft);border-left:3px solid var(--accent);padding:12px 16px;margin:18px 0}.ba{display:grid;grid-template-columns:1fr 1fr;gap:16px}figure{margin:0}svg{display:block;width:100%;height:auto;background:var(--card);border:1px solid var(--rule);border-radius:6px}figcaption{font-size:13px;color:var(--muted);margin:8px 0 16px}code,pre{font-family:var(--mono);background:var(--code-bg);font-size:13px}code{padding:2px 4px}pre{overflow:auto;padding:16px}.src{font-family:var(--mono);font-size:11px;overflow-wrap:anywhere}details{border:1px solid var(--rule);margin:12px 0;border-radius:6px}summary{padding:10px 14px;cursor:pointer;font-size:13px}table{border-collapse:collapse;width:100%;font-size:14px}th,td{padding:10px;border-bottom:1px solid var(--rule);text-align:left;vertical-align:top}th{background:var(--elevated)}footer{margin-top:44px;color:var(--muted);font-size:12px}@media(max-width:850px){.wrap{grid-template-columns:1fr;gap:12px}nav{position:static}.ba{grid-template-columns:1fr}h1{font-size:28px}}</style></head><body><div class="wrap"><nav><strong>Review index</strong><a href="#flow">1. Persistence flow</a><a href="#rules">2. Behavioral boundaries</a><a href="#tests">3. Contract and tests</a><a href="#diff">4. Focused source diff</a><details><summary>Changed files</summary><p>215 0 __tests__/components/settings/llm-profiles/llm-settings-local-view.integration.test.tsx</p><p>1 0 __tests__/components/settings/llm-profiles/llm-settings-local-view.test.tsx</p><p>15 0 specs/llm-profiles.md</p><p>86 15 src/components/features/settings/llm-profiles/llm-settings-local-view.tsx</p></details></nav><main><header><div class="eyebrow">OpenHands · proposal #17955 · 2026-10-13</div><h1>Preserve the new profile’s displayed options</h1><p class="sub">Creating a profile now saves the non-secret options already shown in its form, using the same schema coercion as explicit edits. Automatic booleans retain their raw meaning; credentials start blank and enter the payload only through explicit edits.</p><p class="callout">★ Untouched Temperature 0.4 must survive Save and reopen; an unchecked automatic boolean must remain automatic.</p><a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L114">src/components/features/settings/llm-profiles/llm-settings-local-view.tsx:114</a></header><section id="flow"><h2>The persistence flow changes before the write</h2><p>The API endpoint and profile configuration shape remain unchanged. This proposal changes which configuration values or name enter the existing save call. <a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L346">src/components/features/settings/llm-profiles/llm-settings-local-view.tsx:346</a></p><div class="ba"><figure><h3>Before</h3><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 410 380" role="img" aria-labelledby="before-t before-d"><title id="before-t">Before</title><desc id="before-d">saveControl.getDirtyPayload() → buildProfileLlmConfig() → saveProfile.mutateAsync()</desc><defs><marker id="before-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto"><path d="M0,0 L10,5 L0,10 Z" fill="var(--subtle)"/></marker><linearGradient id="before-wash" x2="0" y2="1"><stop stop-color="var(--accent)" stop-opacity=".10"/><stop offset="1" stop-color="var(--accent)" stop-opacity=".02"/></linearGradient></defs><style>.existing{fill:var(--code-bg);stroke:var(--subtle);stroke-dasharray:5 3;stroke-width:1.4}.new{fill:var(--accent-soft);stroke:var(--accent);stroke-width:2}.title{font:700 14px var(--sans);fill:var(--fg)}.detail{font:12px var(--sans);fill:var(--muted)}.loc{font:11px var(--mono);fill:var(--accent)}.edge{stroke:var(--subtle);stroke-width:1.8;stroke-dasharray:5 3;fill:none}</style><!-- saveControl.getDirtyPayload() --><g><rect class="existing" x="16" y="24" width="378" height="92" rx="6"/><text class="title" x="32" y="52">saveControl.getDirtyPayload()</text><text class="detail" x="32" y="75">Untouched displayed options are absent</text><a href="https://github.com/OpenHands/OpenHands/blob/bdb69754a113e3458d3645dfba0676ae73f4ebc3/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L256"><text class="loc" x="32" y="99">llm-settings-local-view.tsx:256</text></a></g><path class="edge" d="M205,118 L205,139" marker-end="url(#before-arrow)"/><!-- buildProfileLlmConfig() --><g><rect class="existing" x="16" y="142" width="378" height="92" rx="6"/><text class="title" x="32" y="170">buildProfileLlmConfig()</text><text class="detail" x="32" y="193">Create mode has no saved base config</text><a href="https://github.com/OpenHands/OpenHands/blob/bdb69754a113e3458d3645dfba0676ae73f4ebc3/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L267"><text class="loc" x="32" y="217">llm-settings-local-view.tsx:267</text></a></g><path class="edge" d="M205,236 L205,257" marker-end="url(#before-arrow)"/><!-- saveProfile.mutateAsync() --><g><rect class="existing" x="16" y="260" width="378" height="92" rx="6"/><text class="title" x="32" y="288">saveProfile.mutateAsync()</text><text class="detail" x="32" y="311">Missing options fall back to backend defaults</text><a href="https://github.com/OpenHands/OpenHands/blob/bdb69754a113e3458d3645dfba0676ae73f4ebc3/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L321"><text class="loc" x="32" y="335">llm-settings-local-view.tsx:321</text></a></g></svg><figcaption>Only dirty fields entered a new profile’s configuration; untouched temperature disappeared.</figcaption></figure><figure><h3>After</h3><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 410 380" role="img" aria-labelledby="after-t after-d"><title id="after-t">After</title><desc id="after-d">buildSdkSettingsPayload() → getDirtyPayload() + initialPayload → buildProfileLlmConfig()</desc><defs><marker id="after-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto"><path d="M0,0 L10,5 L0,10 Z" fill="var(--warn)"/></marker><linearGradient id="after-wash" x2="0" y2="1"><stop stop-color="var(--accent)" stop-opacity=".10"/><stop offset="1" stop-color="var(--accent)" stop-opacity=".02"/></linearGradient></defs><style>.existing{fill:var(--code-bg);stroke:var(--subtle);stroke-dasharray:5 3;stroke-width:1.4}.new{fill:var(--accent-soft);stroke:var(--accent);stroke-width:2}.title{font:700 14px var(--sans);fill:var(--fg)}.detail{font:12px var(--sans);fill:var(--muted)}.loc{font:11px var(--mono);fill:var(--accent)}.edge{stroke:var(--warn);stroke-width:1.8;stroke-dasharray:5 3;fill:none}</style><!-- buildSdkSettingsPayload() --><g><rect class="new" style="fill:url(#after-wash)" x="16" y="24" width="378" height="92" rx="6"/><text class="title" x="32" y="52">buildSdkSettingsPayload()</text><text class="detail" x="32" y="75">Coerce non-secret, non-automatic draft values</text><a href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L316"><text class="loc" x="32" y="99">llm-settings-local-view.tsx:316</text></a></g><path class="edge" d="M205,118 L205,139" marker-end="url(#after-arrow)"/><!-- getDirtyPayload() + initialPayload --><g><rect class="new" x="16" y="142" width="378" height="92" rx="6"/><text class="title" x="32" y="170">getDirtyPayload() + initialPayload</text><text class="detail" x="32" y="193">Explicit edits override preserved options</text><a href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L332"><text class="loc" x="32" y="217">llm-settings-local-view.tsx:332</text></a></g><path class="edge" d="M205,236 L205,257" marker-end="url(#after-arrow)"/><!-- buildProfileLlmConfig() --><g><rect class="new" x="16" y="260" width="378" height="92" rx="6"/><text class="title" x="32" y="288">buildProfileLlmConfig()</text><text class="detail" x="32" y="311">Existing auth normalization still owns credentials</text><a href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L346"><text class="loc" x="32" y="335">llm-settings-local-view.tsx:346</text></a></g></svg><figcaption>The create payload adds semantic draft values before the existing auth normalization.</figcaption></figure></div></section><section id="rules"><h2>The changed path preserves existing meaning</h2><details><summary>Source manifest</summary><p><a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L1">src/components/features/settings/llm-profiles/llm-settings-local-view.tsx:1</a></p><p><a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/utils/sdk-settings-schema.ts#L108">src/utils/sdk-settings-schema.ts:108</a></p><p><a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-profile-form.ts#L92">src/components/features/settings/llm-profiles/llm-profile-form.ts:92</a></p></details><h3>Blank every schema secret</h3><p>createProfileInitialValues initializes all secret fields to an empty string. The default model, Base URL, provider connection and authentication defaults remain explicit. <a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L114">src/components/features/settings/llm-profiles/llm-settings-local-view.tsx:114</a></p><h3>Preserve automatic booleans</h3><p>handleSaveControlChange captures null-default booleans from the raw draft origin once. getAgentSettingValue normalizes an omitted value to null. Later query refreshes cannot change this open draft’s origin. <a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L250">src/components/features/settings/llm-profiles/llm-settings-local-view.tsx:250</a></p><h3>Merge explicit edits last</h3><p>handleSave uses the existing schema serializer for initial options and overlays the real dirty payload. Existing edit mode continues to merge over the saved profile config. <a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx#L301">src/components/features/settings/llm-profiles/llm-settings-local-view.tsx:301</a></p><p>Unchanged serializer: <a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/utils/sdk-settings-schema.ts#L108">src/utils/sdk-settings-schema.ts:108</a></p><p>Unchanged auth boundary: <a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/src/components/features/settings/llm-profiles/llm-profile-form.ts#L92">src/components/features/settings/llm-profiles/llm-profile-form.ts:92</a></p></section><section id="tests"><h2>The contract is exercised through the form</h2><p>The real embedded form verifies Temperature 0.4, blank inherited credentials, null and omitted automatic booleans, explicit false, dirty true, and false retained through a real settings-query refresh. <a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/__tests__/components/settings/llm-profiles/llm-settings-local-view.integration.test.tsx#L92">__tests__/components/settings/llm-profiles/llm-settings-local-view.integration.test.tsx:92</a></p><p>Stable contract: <a class="src" href="https://github.com/OpenHands/OpenHands/blob/13da51daff35ae685f8fe13d3723b69c8464ab76/specs/llm-profiles.md#L3">specs/llm-profiles.md:3</a> <code>LLP-001</code>.</p><p>Live baseline/fix evidence is retained separately in the PR verification report. This design page describes source behavior; it does not substitute for runtime proof.</p></section><section id="diff"><h2>The source delta stays focused</h2><details><summary>Changed persistence logic</summary><pre>diff --git a/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx b/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx-index 1b3e12f6c4..01b5c571e9 100644---- a/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx-+++ b/src/components/features/settings/llm-profiles/llm-settings-local-view.tsx-@@ -47,7 +47,11 @@ import {- LLM_SUBSCRIPTION_VENDOR_KEY,- OPENAI_SUBSCRIPTION_VENDOR,- } from "#/constants/llm-subscription";--import { SettingsFormValues } from "#/utils/sdk-settings-schema";-+import {-+ buildSdkSettingsPayload,-+ getAgentSettingValue,-+ SettingsFormValues,-+} from "#/utils/sdk-settings-schema";- import { BackNavButton } from "#/components/shared/buttons/back-nav-button";- import { Typography } from "#/ui/typography";- import { useSettingsSectionHeader } from "#/contexts/settings-section-header-context";-@@ -109,6 +113,26 @@ export function LlmSettingsLocalView() {- // embedded form hydrates, so the eventual DB default never replaces it and- // the user can save the wrong model.- const isDefaultModelReady = useDefaultModelReady();-+ // @spec LLP-001 — A fresh profile never inherits schema-declared credentials.-+ const createProfileInitialValues = useMemo(-+ () => ({-+ // A fresh profile may inherit options, but no existing credentials.-+ ...Object.fromEntries(-+ (agentSchema?.sections ?? []).flatMap((section) =>-+ section.fields-+ .filter((field) => field.secret)-+ .map((field) => [field.key, ""]),-+ ),-+ ),-+ "llm.model": createProfileDefaultModel,-+ "llm.api_key": "",-+ "llm.base_url": "",-+ [LLM_PROVIDER_CONNECTION_KEY]: "",-+ [LLM_AUTH_TYPE_KEY]: LLM_AUTH_TYPE_API_KEY,-+ [LLM_SUBSCRIPTION_VENDOR_KEY]: OPENAI_SUBSCRIPTION_VENDOR,-+ }),-+ [agentSchema, createProfileDefaultModel],-+ );-- // Always hold the freshest schema. `handleEditProfile` awaits a network- // round-trip before seeding the form, so reading the schema from a ref-@@ -118,6 +142,8 @@ export function LlmSettingsLocalView() {- // and would otherwise seed only the three hard-coded keys.- const agentSchemaRef = useRef(agentSchema);- agentSchemaRef.current = agentSchema;-+ const settingsRef = useRef(settings);-+ settingsRef.current = settings;-- // Provider connections are available on the local agent-server and on cloud- // when an org is bound (the org-scoped CRUD routes). A cloud backend without-@@ -137,6 +163,7 @@ export function LlmSettingsLocalView() {- const [saveControl, setSaveControl] = useState<SdkSectionSaveControl | null>(- null,- );-+ const automaticCreateBooleanKeys = useRef<Set<string> | null>(null);- const [isSaving, setIsSaving] = useState(false);- const [isValidating, setIsValidating] = useState(false);--@@ -170,6 +197,7 @@ export function LlmSettingsLocalView() {- }, []);-- const handleAddProfile = useCallback(() => {-+ automaticCreateBooleanKeys.current = null;- setProfileName("");- setIsProfileNameUserEdited(false);- setEditingProfile(null);-@@ -212,6 +240,7 @@ export function LlmSettingsLocalView() {- );-- const handleBackToList = useCallback(() => {-+ automaticCreateBooleanKeys.current = null;- setViewMode("list");- setEditingProfile(null);- setProfileName("");-@@ -221,6 +250,31 @@ export function LlmSettingsLocalView() {- const handleSaveControlChange = useCallback(- (control: SdkSectionSaveControl) => {- setSaveControl(control);-+ const currentSettings = settingsRef.current;-+ const currentSchema = agentSchemaRef.current;-+ // Capture the draft's raw origin once it hydrates. Null-default booleans-+ // render unchecked, but null preserves provider auto-detection. A later-+ // settings refresh must not change that meaning for this open draft.-+ if (-+ viewMode === "create" &&-+ automaticCreateBooleanKeys.current === null &&-+ currentSettings &&-+ currentSchema &&-+ "llm.model" in control.values-+ ) {-+ automaticCreateBooleanKeys.current = new Set(-+ currentSchema.sections.flatMap((section) =>-+ section.fields-+ .filter(-+ (field) =>-+ field.value_type === "boolean" &&-+ field.default === null &&-+ getAgentSettingValue(currentSettings, field.key) === null,-+ )-+ .map((field) => field.key),-+ ),-+ );-+ }-- // Auto-derive profile name from model in create mode, and keep it- // following later model changes until the user types their own name.-@@ -243,6 +297,7 @@ export function LlmSettingsLocalView() {- [viewMode, isProfileNameUserEdited, existingNames],- );--+ // @spec LLP-001 — New profiles preserve options and credential boundaries.- const handleSave = useCallback(async () => {- if (!saveControl || !isNameValid) return;--@@ -253,10 +308,34 @@ export function LlmSettingsLocalView() {- // otherwise reset everything else to defaults.- let dirtyLlm: Record<string, unknown>;- try {-- dirtyLlm = (saveControl.getDirtyPayload().llm ?? {}) as Record<-- string,-- unknown-- >;-+ // A new profile has no saved config to merge over, so persist every-+ // non-secret value its form displays, using the same coercion as edits.-+ // Explicit credential edits are included by the dirty payload below.-+ const initialPayload =-+ viewMode === "create" && agentSchema-+ ? buildSdkSettingsPayload(-+ agentSchema,-+ saveControl.values,-+ Object.fromEntries(-+ agentSchema.sections.flatMap((section) =>-+ section.fields-+ .filter((field) => field.key in saveControl.values)-+ .map((field) => [-+ field.key,-+ !field.secret &&-+ !automaticCreateBooleanKeys.current?.has(field.key),-+ ]),-+ ),-+ ),-+ )-+ : {};-+ dirtyLlm = {-+ ...((initialPayload.llm ?? {}) as Record<string, unknown>),-+ ...((saveControl.getDirtyPayload().llm ?? {}) as Record<-+ string,-+ unknown-+ >),-+ };- } catch (error) {- displayErrorToast(- error instanceof Error ? error.message : t(I18nKey.ERROR$GENERIC),-@@ -348,6 +427,7 @@ export function LlmSettingsLocalView() {- }- }, [- saveControl,-+ agentSchema,- isNameValid,- supportsConnections,- profileName,-@@ -435,16 +515,7 @@ export function LlmSettingsLocalView() {- viewMode === "edit" && editingProfile?.initialValues- ? // Edit mode: use the existing profile values- editingProfile.initialValues-- : // Create mode: prefill with the backend-selected default model,-- // while keeping secret/base URL fields blank for a fresh profile.-- {-- "llm.model": createProfileDefaultModel,-- "llm.api_key": "",-- "llm.base_url": "",-- [LLM_PROVIDER_CONNECTION_KEY]: "",-- [LLM_AUTH_TYPE_KEY]: LLM_AUTH_TYPE_API_KEY,-- [LLM_SUBSCRIPTION_VENDOR_KEY]: OPENAI_SUBSCRIPTION_VENDOR,-- }-+ : createProfileInitialValues- }- showProviderConnection={supportsConnections}- onSaveControlChange={handleSaveControlChange}-</pre></details></section><footer>I am an AI agent helping Engel Nyst (@enyst) with project maintenance.<br>Before bdb69754a113e3458d3645dfba0676ae73f4ebc3 · after 13da51daff35ae685f8fe13d3723b69c8464ab76. Temporary .pr review artifact; source links are commit-pinned. Same-repository cleanup-on-approval workflow is present.</footer></main></div></body></html>\ No newline at end of filediff --git a/.pr/17955/evidence/F10.create-prefill/inherited-after-save-2.png b/.pr/17955/evidence/F10.create-prefill/inherited-after-save-2.pngdeleted file mode 100644index ac333095f7..0000000000Binary files a/.pr/17955/evidence/F10.create-prefill/inherited-after-save-2.png and /dev/null differdiff --git a/.pr/17955/evidence/F10.create-prefill/inherited-after-save.png b/.pr/17955/evidence/F10.create-prefill/inherited-after-save.pngdeleted file mode 100644index ac333095f7..0000000000Binary files a/.pr/17955/evidence/F10.create-prefill/inherited-after-save.png and /dev/null differdiff --git a/.pr/17955/evidence/F10.create-prefill/inherited-before-save-2.png b/.pr/17955/evidence/F10.create-prefill/inherited-before-save-2.pngdeleted file mode 100644index 7dc27e0b04..0000000000Binary files a/.pr/17955/evidence/F10.create-prefill/inherited-before-save-2.png and /dev/null differdiff --git a/.pr/17955/evidence/F10.create-prefill/inherited-before-save.png b/.pr/17955/evidence/F10.create-prefill/inherited-before-save.pngdeleted file mode 100644index 7dc27e0b04..0000000000Binary files a/.pr/17955/evidence/F10.create-prefill/inherited-before-save.png and /dev/null differdiff --git a/.pr/17955/evidence/F10.create-prefill/inherited-save-2.gif b/.pr/17955/evidence/F10.create-prefill/inherited-save-2.gifdeleted file mode 100644index 5c4252f517..0000000000Binary files a/.pr/17955/evidence/F10.create-prefill/inherited-save-2.gif and /dev/null differdiff --git a/.pr/17955/evidence/F10.create-prefill/inherited-save-2.mp4 b/.pr/17955/evidence/F10.create-prefill/inherited-save-2.mp4deleted file mode 100644index 960cb82a8b..0000000000Binary files a/.pr/17955/evidence/F10.create-prefill/inherited-save-2.mp4 and /dev/null differdiff --git a/.pr/17955/evidence/F10.create-prefill/inherited-save.gif b/.pr/17955/evidence/F10.create-prefill/inherited-save.gifdeleted file mode 100644index 1636f2faf5..0000000000Binary files a/.pr/17955/evidence/F10.create-prefill/inherited-save.gif and /dev/null differdiff --git a/.pr/17955/evidence/F10.create-prefill/inherited-save.mp4 b/.pr/17955/evidence/F10.create-prefill/inherited-save.mp4deleted file mode 100644index aa725a9e6b..0000000000Binary files a/.pr/17955/evidence/F10.create-prefill/inherited-save.mp4 and /dev/null differdiff --git a/.pr/17955/evidence/F10.create-prefill/phone-inherited-after-save-2.png b/.pr/17955/evidence/F10.create-prefill/phone-inherited-after-save-2.pngdeleted file mode 100644index b85338edf4..0000000000Binary files a/.pr/17955/evidence/F10.create-prefill/phone-inherited-after-save-2.png and /dev/null differdiff --git a/.pr/17955/evidence/F10.create-prefill/phone-inherited-after-save.png b/.pr/17955/evidence/F10.create-prefill/phone-inherited-after-save.pngdeleted file mode 100644index b85338edf4..0000000000Binary files a/.pr/17955/evidence/F10.create-prefill/phone-inherited-after-save.png and /dev/null differdiff --git a/.pr/17955/evidence/F10.create-prefill/phone-inherited-before-save-2.png b/.pr/17955/evidence/F10.create-prefill/phone-inherited-before-save-2.pngdeleted file mode 100644index 9a59a04f4f..0000000000Binary files a/.pr/17955/evidence/F10.create-prefill/phone-inherited-before-save-2.png and /dev/null differdiff --git a/.pr/17955/evidence/F10.create-prefill/phone-inherited-before-save.png b/.pr/17955/evidence/F10.create-prefill/phone-inherited-before-save.pngdeleted file mode 100644index 9a59a04f4f..0000000000Binary files a/.pr/17955/evidence/F10.create-prefill/phone-inherited-before-save.png and /dev/null differdiff --git a/.pr/17955/evidence/F10.create-prefill/phone-inherited-save-2.gif b/.pr/17955/evidence/F10.create-prefill/phone-inherited-save-2.gifdeleted file mode 100644index 88105d3870..0000000000Binary files a/.pr/17955/evidence/F10.create-prefill/phone-inherited-save-2.gif and /dev/null differdiff --git a/.pr/17955/evidence/F10.create-prefill/phone-inherited-save-2.mp4 b/.pr/17955/evidence/F10.create-prefill/phone-inherited-save-2.mp4deleted file mode 100644index 0e5e1b88fe..0000000000Binary files a/.pr/17955/evidence/F10.create-prefill/phone-inherited-save-2.mp4 and /dev/null differdiff --git a/.pr/17955/evidence/F10.create-prefill/phone-inherited-save.gif b/.pr/17955/evidence/F10.create-prefill/phone-inherited-save.gifdeleted file mode 100644index 9a198d5e3d..0000000000Binary files a/.pr/17955/evidence/F10.create-prefill/phone-inherited-save.gif and /dev/null differdiff --git a/.pr/17955/evidence/F10.create-prefill/phone-inherited-save.mp4 b/.pr/17955/evidence/F10.create-prefill/phone-inherited-save.mp4deleted file mode 100644index 7d20c9b7e0..0000000000Binary files a/.pr/17955/evidence/F10.create-prefill/phone-inherited-save.mp4 and /dev/null differdiff --git a/.pr/17955/evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874311564-1.json b/.pr/17955/evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874311564-1.jsondeleted file mode 100644index 60332801fb..0000000000--- a/.pr/17955/evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874311564-1.json+++ /dev/null@@ -1,29 +0,0 @@-{- "id": "F10.create-prefill",- "name": "desktop-inherited",- "exitCode": 0,- "timedOut": false,- "failedLine": null,- "elapsedMs": 7086,- "asserts": [- {- "ts": "2026-10-13T06:51:56.476Z",- "ok": true,- "kind": "hold",- "actual": "0.4",- "field": "value",- "expected": "0.4",- "command": "browser value testid=sdk-settings-llm.temperature"- },- {- "ts": "2026-10-13T06:52:01.349Z",- "ok": true,- "kind": "hold",- "actual": "0.4",- "field": "value",- "expected": "0.4",- "bugShows": "",- "command": "browser value testid=sdk-settings-llm.temperature"- }- ]-}diff --git a/.pr/17955/evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874321395-2.json b/.pr/17955/evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874321395-2.jsondeleted file mode 100644index fc1a78a93c..0000000000--- a/.pr/17955/evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874321395-2.json+++ /dev/null@@ -1,29 +0,0 @@-{- "id": "F10.create-prefill",- "name": "desktop-inherited",- "exitCode": 0,- "timedOut": false,- "failedLine": null,- "elapsedMs": 6276,- "asserts": [- {- "ts": "2026-10-13T06:52:06.252Z",- "ok": true,- "kind": "hold",- "actual": "0.4",- "field": "value",- "expected": "0.4",- "command": "browser value testid=sdk-settings-llm.temperature"- },- {- "ts": "2026-10-13T06:52:10.415Z",- "ok": true,- "kind": "hold",- "actual": "0.4",- "field": "value",- "expected": "0.4",- "bugShows": "",- "command": "browser value testid=sdk-settings-llm.temperature"- }- ]-}diff --git a/.pr/17955/evidence/known-bugs/F10.create-prefill-phone-inherited-1791874330422-1.json b/.pr/17955/evidence/known-bugs/F10.create-prefill-phone-inherited-1791874330422-1.jsondeleted file mode 100644index 250dcddb12..0000000000--- a/.pr/17955/evidence/known-bugs/F10.create-prefill-phone-inherited-1791874330422-1.json+++ /dev/null@@ -1,29 +0,0 @@-{- "id": "F10.create-prefill",- "name": "phone-inherited",- "exitCode": 0,- "timedOut": false,- "failedLine": null,- "elapsedMs": 5371,- "asserts": [- {- "ts": "2026-10-13T06:52:15.014Z",- "ok": true,- "kind": "hold",- "actual": "0.4",- "field": "value",- "expected": "0.4",- "command": "browser value testid=sdk-settings-llm.temperature"- },- {- "ts": "2026-10-13T06:52:18.464Z",- "ok": true,- "kind": "hold",- "actual": "0.4",- "field": "value",- "expected": "0.4",- "bugShows": "",- "command": "browser value testid=sdk-settings-llm.temperature"- }- ]-}diff --git a/.pr/17955/evidence/known-bugs/F10.create-prefill-phone-inherited-1791874338471-2.json b/.pr/17955/evidence/known-bugs/F10.create-prefill-phone-inherited-1791874338471-2.jsondeleted file mode 100644index 0d1ff02f71..0000000000--- a/.pr/17955/evidence/known-bugs/F10.create-prefill-phone-inherited-1791874338471-2.json+++ /dev/null@@ -1,29 +0,0 @@-{- "id": "F10.create-prefill",- "name": "phone-inherited",- "exitCode": 0,- "timedOut": false,- "failedLine": null,- "elapsedMs": 5728,- "asserts": [- {- "ts": "2026-10-13T06:52:23.235Z",- "ok": true,- "kind": "hold",- "actual": "0.4",- "field": "value",- "expected": "0.4",- "command": "browser value testid=sdk-settings-llm.temperature"- },- {- "ts": "2026-10-13T06:52:26.922Z",- "ok": true,- "kind": "hold",- "actual": "0.4",- "field": "value",- "expected": "0.4",- "bugShows": "",- "command": "browser value testid=sdk-settings-llm.temperature"- }- ]-}diff --git a/.pr/17955/evidence/known-bugs/attempts.jsonl b/.pr/17955/evidence/known-bugs/attempts.jsonldeleted file mode 100644index 12025ffdd8..0000000000--- a/.pr/17955/evidence/known-bugs/attempts.jsonl+++ /dev/null@@ -1,4 +0,0 @@-{"ts": "2026-10-13T06:52:01.394Z", "id": "F10.create-prefill", "name": "desktop-inherited", "label": "fix", "attempt": 1, "status": "xpass", "sha": "e54c2d729c903f2e", "exitCode": 0, "failedLine": null, "assertion": {"kind": "hold", "expected": "0.4", "actual": "0.4", "bugShows": ""}, "doctorBefore": true, "elapsedMs": 7086, "revision": "13da51daff35ae685f8fe13d3723b69c8464ab76", "backend": "local agent-server 1.54.0 automation 1.19.3", "viewport": "1440x1000", "transcript": "evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874311564-1.json"}-{"ts": "2026-10-13T06:52:10.422Z", "id": "F10.create-prefill", "name": "desktop-inherited", "label": "fix", "attempt": 2, "status": "xpass", "sha": "e54c2d729c903f2e", "exitCode": 0, "failedLine": null, "assertion": {"kind": "hold", "expected": "0.4", "actual": "0.4", "bugShows": ""}, "doctorBefore": true, "elapsedMs": 6276, "revision": "13da51daff35ae685f8fe13d3723b69c8464ab76", "backend": "local agent-server 1.54.0 automation 1.19.3", "viewport": "1440x1000", "transcript": "evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874321395-2.json"}-{"ts": "2026-10-13T06:52:18.471Z", "id": "F10.create-prefill", "name": "phone-inherited", "label": "fix", "attempt": 1, "status": "xpass", "sha": "ac0fc74c6cb76849", "exitCode": 0, "failedLine": null, "assertion": {"kind": "hold", "expected": "0.4", "actual": "0.4", "bugShows": ""}, "doctorBefore": true, "elapsedMs": 5371, "revision": "13da51daff35ae685f8fe13d3723b69c8464ab76", "backend": "local agent-server 1.54.0 automation 1.19.3", "viewport": "390x844", "transcript": "evidence/known-bugs/F10.create-prefill-phone-inherited-1791874330422-1.json"}-{"ts": "2026-10-13T06:52:26.928Z", "id": "F10.create-prefill", "name": "phone-inherited", "label": "fix", "attempt": 2, "status": "xpass", "sha": "ac0fc74c6cb76849", "exitCode": 0, "failedLine": null, "assertion": {"kind": "hold", "expected": "0.4", "actual": "0.4", "bugShows": ""}, "doctorBefore": true, "elapsedMs": 5728, "revision": "13da51daff35ae685f8fe13d3723b69c8464ab76", "backend": "local agent-server 1.54.0 automation 1.19.3", "viewport": "390x844", "transcript": "evidence/known-bugs/F10.create-prefill-phone-inherited-1791874338471-2.json"}diff --git a/.pr/17955/evidence/ledger.jsonl b/.pr/17955/evidence/ledger.jsonldeleted file mode 100644index c3a34fd581..0000000000--- a/.pr/17955/evidence/ledger.jsonl+++ /dev/null@@ -1,4 +0,0 @@-{"ts": "2026-10-13T06:52:01.394Z", "feature": "F10.create-prefill", "entry": "known bug: desktop-inherited", "result": "xpass", "expected": "0.4", "actual": "0.4", "artifacts": ["evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874311564-1.json"], "note": "known bug no longer reproduces: review the map note; fix attempt 1", "revision": "13da51daff35ae685f8fe13d3723b69c8464ab76", "backend": "local agent-server 1.54.0 automation 1.19.3", "viewport": "1440x1000"}-{"ts": "2026-10-13T06:52:10.422Z", "feature": "F10.create-prefill", "entry": "known bug: desktop-inherited", "result": "xpass", "expected": "0.4", "actual": "0.4", "artifacts": ["evidence/known-bugs/F10.create-prefill-desktop-inherited-1791874321395-2.json"], "note": "known bug no longer reproduces: review the map note; fix attempt 2", "revision": "13da51daff35ae685f8fe13d3723b69c8464ab76", "backend": "local agent-server 1.54.0 automation 1.19.3", "viewport": "1440x1000"}-{"ts": "2026-10-13T06:52:18.471Z", "feature": "F10.create-prefill", "entry": "known bug: phone-inherited", "result": "xpass", "expected": "0.4", "actual": "0.4", "artifacts": ["evidence/known-bugs/F10.create-prefill-phone-inherited-1791874330422-1.json"], "note": "known bug no longer reproduces: review the map note; fix attempt 1", "revision": "13da51daff35ae685f8fe13d3723b69c8464ab76", "backend": "local agent-server 1.54.0 automation 1.19.3", "viewport": "390x844"}-{"ts": "2026-10-13T06:52:26.928Z", "feature": "F10.create-prefill", "entry": "known bug: phone-inherited", "result": "xpass", "expected": "0.4", "actual": "0.4", "artifacts": ["evidence/known-bugs/F10.create-prefill-phone-inherited-1791874338471-2.json"], "note": "known bug no longer reproduces: review the map note; fix attempt 2", "revision": "13da51daff35ae685f8fe13d3723b69c8464ab76", "backend": "local agent-server 1.54.0 automation 1.19.3", "viewport": "390x844"}diff --git a/__tests__/contexts/conversation-websocket-provider.behavior.test.tsx b/__tests__/contexts/conversation-websocket-provider.behavior.test.tsxindex b4e5af7483..ae252ff32d 100644--- a/__tests__/contexts/conversation-websocket-provider.behavior.test.tsx+++ b/__tests__/contexts/conversation-websocket-provider.behavior.test.tsx@@ -21,6 +21,12 @@ import { useGoalStore } from "#/stores/goal-store";import { useModelStore } from "#/stores/model-store";import useMetricsStore from "#/stores/metrics-store";import { useFilesTabStore } from "#/stores/files-tab-store";+import {+ __resetActiveStoreForTests,+ setActiveSelection,+ setRegisteredBackends,+} from "#/api/backend-registry/active-store";+import type { Backend } from "#/api/backend-registry/types";import EventService from "#/api/event-service/event-service.api";import { SERVER_CONNECTION_ERROR_MESSAGE } from "#/constants/server-connection-error";import { getStoredConversationMetadata } from "#/api/conversation-metadata-store";@@ -47,6 +53,7 @@ const socketCapture = vi.hoisted(() => ({disconnectMain: vi.fn(),disconnectPlanning: vi.fn(),queueMessage: vi.fn(),+ clientOptions: vi.fn(),readConversationFile: vi.fn(),trackError: vi.fn(),launchChild: vi.fn(),@@ -108,7 +115,10 @@ vi.mock("#/utils/error-handler", () => ({}));vi.mock("#/api/agent-server-client-options", () => ({- getAgentServerClientOptions: () => ({ baseUrl: "http://agent-server.test" }),+ getAgentServerClientOptions: (...args: unknown[]) => {+ socketCapture.clientOptions(...args);+ return { baseUrl: "http://agent-server.test" };+ },}));vi.mock("@openhands/typescript-client/clients", () => ({@@ -342,6 +352,7 @@ describe("Conversation websocket behavior", () => {socketCapture.disconnectMain.mockReset();socketCapture.disconnectPlanning.mockReset();socketCapture.queueMessage.mockReset().mockResolvedValue(undefined);+ socketCapture.clientOptions.mockReset();socketCapture.readConversationFile.mockReset();socketCapture.trackError.mockReset();socketCapture.launchChild.mockReset().mockResolvedValue(undefined);@@ -2521,3 +2532,127 @@ describe("Conversation websocket — page visibility reconnect (#17894)", () =>expect(contextCapture.current?.hasConnectedOnce).toBe(true);});});++describe("Conversation websocket — cloud runtime without a URL (OHE-3314)", () => {+ const cloudBackend: Backend = {+ id: "cloud-test",+ name: "Cloud",+ host: "https://cloud.test",+ apiKey: "bearer-token",+ kind: "cloud",+ };+ const runtimeUrl = "https://runtime.test/api/conversations/conv-main";++ const rerenderProvider = (+ view: ReturnType<typeof renderProvider>,+ props: Partial<ProviderProps>,+ ) =>+ view.rerender(+ <QueryClientProvider client={view.queryClient}>+ <ConversationWebSocketProvider conversationId="conv-main" {...props}>+ <ContextProbe />+ </ConversationWebSocketProvider>+ </QueryClientProvider>,+ );++ beforeEach(() => {+ socketCapture.callIndex = 0;+ socketCapture.mainOptions = null;+ socketCapture.planningOptions = null;+ socketCapture.mainSocket = null;+ socketCapture.planningSocket = null;+ socketCapture.queueMessage.mockReset().mockResolvedValue(undefined);+ socketCapture.clientOptions.mockReset();+ contextCapture.current = null;+ historyCapture.result = {+ data: { events: [] },+ isPending: false,+ isFetching: false,+ isError: false,+ };+ useErrorMessageStore.getState().removeErrorMessage();+ useOptimisticUserMessageStore.getState().clearPendingMessages();+ useEventStore.setState({+ events: [],+ eventIds: new Set(),+ uiEvents: [],+ loadedConversationId: null,+ });+ useConversationStore.setState({ conversationMode: "code" });+ setRegisteredBackends([cloudBackend]);+ setActiveSelection({ backendId: cloudBackend.id });+ });++ afterEach(() => {+ __resetActiveStoreForTests();+ window.localStorage.clear();+ });++ it("holds a message while the runtime has no URL and sends it once the socket opens", async () => {+ const view = renderProvider({ conversationUrl: null });+ const request = makeSendRequest("hello");++ await expect(contextCapture.current?.sendMessage(request)).resolves.toEqual(+ { queued: true },+ );+ // A second submit of the same text while still held is coalesced.+ await contextCapture.current?.sendMessage(request);++ expect(socketCapture.queueMessage).not.toHaveBeenCalled();+ expect(useErrorMessageStore.getState().errorMessage).toBeNull();++ socketCapture.mainSocket = makeSocket();+ rerenderProvider(view, { conversationUrl: runtimeUrl, sessionApiKey: "k" });+ act(() => socketCapture.mainOptions?.onOpen?.(new Event("open")));++ await waitFor(() =>+ expect(socketCapture.mainSocket?.send).toHaveBeenCalledTimes(1),+ );+ expect(socketCapture.mainSocket?.send).toHaveBeenCalledWith(+ JSON.stringify({ ...request, run: true }),+ );+ expect(socketCapture.queueMessage).not.toHaveBeenCalled();+ });++ it("withdraws a held message whose pending bubble was stopped before the socket opened", async () => {+ const view = renderProvider({ conversationUrl: null });+ const pendingId = useOptimisticUserMessageStore+ .getState()+ .enqueuePendingMessage({ conversationId: "conv-main", text: "hello" });++ await expect(+ contextCapture.current?.sendMessage(makeSendRequest("hello")),+ ).resolves.toEqual({ queued: true });+ useOptimisticUserMessageStore.getState().removePendingMessage(pendingId);++ socketCapture.mainSocket = makeSocket();+ rerenderProvider(view, { conversationUrl: runtimeUrl });+ await act(async () => {+ socketCapture.mainOptions?.onOpen?.(new Event("open"));+ });++ expect(socketCapture.mainSocket?.send).not.toHaveBeenCalled();+ });++ it("posts to a reachable runtime with its coordinates while the socket is closed", async () => {+ renderProvider({+ conversationUrl: runtimeUrl,+ sessionApiKey: "session-key",+ });+ const request = makeSendRequest("now");++ await expect(contextCapture.current?.sendMessage(request)).resolves.toEqual(+ { queued: true },+ );++ expect(socketCapture.clientOptions).toHaveBeenCalledWith({+ conversationUrl: runtimeUrl,+ sessionApiKey: "session-key",+ });+ expect(socketCapture.queueMessage).toHaveBeenCalledWith(+ "conv-main",+ { role: "user", content: request.content },+ { run: true },+ );+ });+});diff --git a/src/contexts/conversation-websocket-context.tsx b/src/contexts/conversation-websocket-context.tsxindex 09a4ea62da..10684ca680 100644--- a/src/contexts/conversation-websocket-context.tsx+++ b/src/contexts/conversation-websocket-context.tsx@@ -70,8 +70,10 @@ import type {} from "#/api/conversation-service/agent-server-conversation-service.types";import EventService from "#/api/event-service/event-service.api";import { getAgentServerClientOptions } from "#/api/agent-server-client-options";+import { getActiveBackend } from "#/api/backend-registry/active-store";import { useConversationStore } from "#/stores/conversation-store";import { trackError } from "#/utils/error-handler";+import { matchesPendingConversationId } from "#/utils/pending-task-message-link";import { useReadConversationFile } from "#/hooks/mutation/use-read-conversation-file";import useMetricsStore, { type MetricsState } from "#/stores/metrics-store";import { useConversationHistory } from "#/hooks/query/use-conversation-history";@@ -93,6 +95,21 @@ export type WebSocketConnectionState =| "CLOSED"| "CLOSING";+/**+ * A message submitted while its cloud conversation had no runtime URL yet+ * (sandbox PAUSED/STARTING). Held until that conversation's socket opens.+ */+interface HeldMessage {+ message: SendMessageRequest;+ /** Whether an optimistic "sending" bubble existed when the message was held. */+ hadBubble: boolean;+}++const heldMessageText = (message: SendMessageRequest): string =>+ message.content+ .map((item) => (item.type === "text" ? item.text : ""))+ .join("");+interface SendMessageResult {queued: boolean; // true if message was queued for later delivery, false if sent immediately}@@ -1263,6 +1280,72 @@ export function ConversationWebSocketProvider({disconnect: disconnectPlanning,} = useWebSocket(planningAgentWsUrl || "", planningWebsocketOptions);+ // Messages submitted on a cloud backend while the target conversation has+ // no runtime URL (sandbox PAUSED/STARTING) have nowhere to go: the V1 agent+ // server only exists once the sandbox is RUNNING. Hold them per target+ // conversation and send them when that conversation's socket opens. The+ // caller's optimistic bubble stays in "sending" until the echo lands.+ const heldMessagesRef = useRef(new Map<string, HeldMessage[]>());++ const hasSendingBubble = useCallback(+ (targetConversationId: string, message: SendMessageRequest) => {+ const text = heldMessageText(message).trim();+ return useOptimisticUserMessageStore+ .getState()+ .pendingMessages.some(+ (pending) =>+ pending.status === "sending" &&+ matchesPendingConversationId(+ targetConversationId,+ pending.conversationId,+ ) &&+ pending.content.trim() === text,+ );+ },+ [],+ );++ const flushHeldMessages = useCallback(+ (targetConversationId: string, socket: WebSocket) => {+ if (socket.readyState !== WebSocket.OPEN) return;+ const held = heldMessagesRef.current.get(targetConversationId);+ if (!held?.length) return;+ heldMessagesRef.current.delete(targetConversationId);+ held.forEach(({ message, hadBubble }) => {+ // A bubble the user stopped (or that timed out into Retry) withdraws+ // its message; everything else goes out exactly as a live send would.+ if (hadBubble && !hasSendingBubble(targetConversationId, message)) {+ return;+ }+ socket.send(JSON.stringify({ ...message, run: true }));+ });+ },+ [hasSendingBubble],+ );++ useEffect(() => {+ if (mainConnectionState !== "OPEN" || !mainSocket || !conversationId) {+ return;+ }+ flushHeldMessages(conversationId, mainSocket);+ }, [mainConnectionState, mainSocket, conversationId, flushHeldMessages]);++ useEffect(() => {+ if (+ planningConnectionState !== "OPEN" ||+ !planningAgentSocket ||+ !planningConversationId+ ) {+ return;+ }+ flushHeldMessages(planningConversationId, planningAgentSocket);+ }, [+ planningConnectionState,+ planningAgentSocket,+ planningConversationId,+ flushHeldMessages,+ ]);+const reconnect = useCallback(() => {removeErrorMessage();const currentMode = useConversationStore.getState().conversationMode;@@ -1319,8 +1402,10 @@ export function ConversationWebSocketProvider({reconnectIfStale: reconnectStaleOnForeground,});- // V1 send message function via WebSocket- // Falls back to REST API queue when WebSocket is not connected+ // V1 send message function via WebSocket.+ // When the socket is not connected: on a cloud backend whose runtime has+ // no URL yet, hold the message until the socket opens; otherwise post it+ // straight to the runtime.const sendMessage = useCallback(async (message: SendMessageRequest): Promise<SendMessageResult> => {const currentMode = useConversationStore.getState().conversationMode;@@ -1330,8 +1415,7 @@ export function ConversationWebSocketProvider({currentMode === "plan" ? planningConversationId : conversationId;if (currentSocket?.readyState !== WebSocket.OPEN) {- // WebSocket not connected - queue message via REST API- // Message will be delivered automatically when conversation becomes ready+ // WebSocket not connected.if (!targetConversationId) {// Never fall back to the parent in plan mode: without a planner// target the message would run in the code agent, which is exactly@@ -1345,8 +1429,45 @@ export function ConversationWebSocketProvider({throw error;}+ // Runtime coordinates for the target. A cloud runtime only has a URL+ // (and session key) while its sandbox is RUNNING.+ const planningAgentConversation = subConversations?.[0];+ const runtimeUrl =+ currentMode === "plan"+ ? planningAgentConversation?.conversation_url+ : conversationUrl;+ const runtimeApiKey =+ currentMode === "plan"+ ? planningAgentConversation?.session_api_key+ : sessionApiKey;++ if (getActiveBackend().backend.kind === "cloud" && !runtimeUrl) {+ // Nothing to deliver to yet (sandbox PAUSED/STARTING). Hold the+ // message for `flushHeldMessages`; the caller's bubble stays in+ // "sending". Not an error, so no banner.+ const held = heldMessagesRef.current.get(targetConversationId) ?? [];+ const serialized = JSON.stringify(message);+ if (+ !held.some((entry) => JSON.stringify(entry.message) === serialized)+ ) {+ held.push({+ message,+ hadBubble: hasSendingBubble(targetConversationId, message),+ });+ heldMessagesRef.current.set(targetConversationId, held);+ }+ return { queued: true };+ }++ // The runtime is reachable: post the message to it directly. It is+ // delivered immediately and shows up in the socket's history replay.try {- await new ConversationClient(getAgentServerClientOptions()).sendEvent(+ await new ConversationClient(+ getAgentServerClientOptions({+ conversationUrl: runtimeUrl,+ sessionApiKey: runtimeApiKey,+ }),+ ).sendEvent(targetConversationId,{role: "user",@@ -1354,8 +1475,7 @@ export function ConversationWebSocketProvider({},{ run: true },);- // Message queued successfully - it will be delivered when ready- // Return queued: true so caller knows not to show optimistic UI+ // Return queued: true so the caller knows the socket did not carry itreturn { queued: true };} catch (error) {const errorMessage =@@ -1385,6 +1505,10 @@ export function ConversationWebSocketProvider({setErrorMessage,conversationId,planningConversationId,+ conversationUrl,+ sessionApiKey,+ subConversations,+ hasSendingBubble,],);