Merge pull request #2940
This commit is contained in:
commit
fdb0ccb392
2 changed files with 22 additions and 1 deletions
|
|
@ -433,7 +433,7 @@ async function send(){
|
|||
setComposerStatus('');
|
||||
|
||||
const uploadedNames=uploaded.map(u=>u.name||u);
|
||||
const uploadedPaths=uploaded.map(u=>u&&u.is_image?(u.name||u.filename||u):(u.path||u.name||u));
|
||||
const uploadedPaths=uploaded.map(u=>u&&u.path?u.path:(u&&u.name?u.name:(u&&u.filename?u.filename:u)));
|
||||
let msgText=text;
|
||||
if(uploaded.length&&!msgText)msgText=`I've uploaded ${uploaded.length} file(s): ${uploadedPaths.join(', ')}`;
|
||||
else if(uploaded.length)msgText=`${text}\n\n[Attached files: ${uploadedPaths.join(', ')}]`;
|
||||
|
|
|
|||
21
tests/test_chat_upload_attachment_paths.py
Normal file
21
tests/test_chat_upload_attachment_paths.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
"""Regression coverage for WebUI chat upload path handoff."""
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
MESSAGES_JS = ROOT / "static" / "messages.js"
|
||||
|
||||
|
||||
def test_image_uploads_use_server_path_in_attached_files_context():
|
||||
"""The agent text context must include real uploaded paths for images.
|
||||
|
||||
/api/upload returns an absolute attachment path. The browser also sends the
|
||||
structured attachment payload to /api/chat/start, but text/tool-mode agents
|
||||
still rely on the literal ``[Attached files: ...]`` suffix. Images must not
|
||||
be downgraded to bare filenames there, otherwise tools like vision_analyze
|
||||
cannot open the uploaded file immediately.
|
||||
"""
|
||||
src = MESSAGES_JS.read_text(encoding="utf-8")
|
||||
|
||||
assert "uploadedPaths=uploaded.map(u=>u&&u.is_image?" not in src
|
||||
assert "uploadedPaths=uploaded.map(u=>u&&u.path?u.path" in src
|
||||
Loading…
Reference in a new issue