fix(#4961): honor send query prefill flag

This commit is contained in:
Rod Boev committed 2026-06-29 09:52:43 -04:00
1 parent 1bd9e52e5f
commit 71cd69cfbf
3 files changed
+15 -5

No files matched your search

+6 -1
View File
@@ -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.
+4 -2
View File
@@ -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;}
}
+5 -2
View File
@@ -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"