From 71cd69cfbf34f445fe20962c29bc9bcd3e8d1cb8 Mon Sep 17 00:00:00 2001 From: Rod Boev Date: Sun, 28 Jun 2026 09:55:19 -0400 Subject: [PATCH] fix(#4961): honor send query prefill flag --- static/boot.js | 7 ++++++- static/sessions.js | 6 ++++-- tests/test_4961_url_query_prefill.py | 7 +++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/static/boot.js b/static/boot.js index 6792af0c..adc34a67 100644 --- a/static/boot.js +++ b/static/boot.js @@ -109,9 +109,14 @@ async function _applyComposerPrefillOnBoot(prefillIntent){ if(!msg) return; const text=String(prefillIntent.text||''); msg.value=text; - // Boot prefill is composer-only; URL params never submit on the user's behalf. if(typeof autoResize==='function') autoResize(); else if(typeof updateSendBtn==='function') updateSendBtn(); + if(!prefillIntent.autoSend) return; + if(typeof handleComposerPrimaryAction==='function'){ + await handleComposerPrimaryAction(); + return; + } + if(typeof send==='function') await send(); } // Mobile navigation. diff --git a/static/sessions.js b/static/sessions.js index ab37e975..0e47c45a 100644 --- a/static/sessions.js +++ b/static/sessions.js @@ -3221,7 +3221,7 @@ function _sessionIdFromLocation(){ }catch(_e){return null;} } function _composerPrefillIntentFromLocation(){ - const empty={hasParams:false,hasText:false,text:''}; + const empty={hasParams:false,hasText:false,text:'',autoSend:false}; if(typeof window==='undefined'||!window.location) return empty; try{ const qs=new URLSearchParams(window.location.search||''); @@ -3230,10 +3230,12 @@ function _composerPrefillIntentFromLocation(){ const hasSend=qs.has('send'); if(!hasQ&&!hasPrompt&&!hasSend) return empty; const text=hasQ?(qs.get('q')||''):(hasPrompt?(qs.get('prompt')||''):''); + const autoSend=hasSend&&/^(1|true|yes|on)$/i.test(String(qs.get('send')||'').trim()); return { hasParams:true, hasText:!!String(text).trim(), - text + text, + autoSend }; }catch(_e){return empty;} } diff --git a/tests/test_4961_url_query_prefill.py b/tests/test_4961_url_query_prefill.py index 1079b7d7..08e06b81 100644 --- a/tests/test_4961_url_query_prefill.py +++ b/tests/test_4961_url_query_prefill.py @@ -73,16 +73,19 @@ console.log(JSON.stringify({ first, second, third })); "hasParams": True, "hasText": True, "text": "hello world", + "autoSend": True, } assert payload["second"] == { "hasParams": True, "hasText": True, "text": "from prompt", + "autoSend": False, } assert payload["third"] == { "hasParams": True, "hasText": False, "text": " ", + "autoSend": True, } @@ -152,7 +155,7 @@ console.log(JSON.stringify(result)); assert load_pos > prefill_guard -def test_apply_prefill_updates_composer_without_autosend(): +def test_apply_prefill_updates_composer_and_optionally_autosends(): source = _node_prelude() + """ (async () => { evalBoot('_applyComposerPrefillOnBoot'); @@ -178,7 +181,7 @@ def test_apply_prefill_updates_composer_without_autosend(): }); """ payload = json.loads(_run_node(source)) - assert payload["counts"] == {"autoResize": 1, "updateSendBtn": 1, "send": 0} + assert payload["counts"] == {"autoResize": 1, "updateSendBtn": 1, "send": 1} assert payload["value"] == "second pass"