Skip to content

Commit 4f7c8da

Browse files
committed
fix: route media files to image attachments
1 parent dec1878 commit 4f7c8da

3 files changed

Lines changed: 50 additions & 23 deletions

File tree

assets/scripts/InputBubbleTemplate.js

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@
521521

522522
const imageInput = document.createElement("input");
523523
imageInput.type = "file";
524-
imageInput.accept = "image/*";
524+
imageInput.accept = "image/*"; /**/
525525
imageInput.multiple = true;
526526
imageInput.style.display = "none";
527527

@@ -1902,6 +1902,8 @@
19021902
list = host.__knowledgeFiles;
19031903
} else if (target === "speech") {
19041904
list = host.__speechToTextFiles;
1905+
} else if (isMediaFile(name)) {
1906+
list = host.__images;
19051907
} else {
19061908
list = host.__files;
19071909
}
@@ -3415,6 +3417,33 @@
34153417
sendBtn.style.gridColumn = "3";
34163418
}
34173419

3420+
const MEDIA_EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp"];
3421+
3422+
function hasMediaExtension(name) {
3423+
if (typeof name !== "string") return false;
3424+
3425+
const lower = name.toLowerCase();
3426+
const dot = lower.lastIndexOf(".");
3427+
if (dot < 0) return false;
3428+
3429+
return MEDIA_EXTENSIONS.indexOf(lower.slice(dot + 1)) !== -1;
3430+
}
3431+
3432+
function isMediaFile(file) {
3433+
if (!file) return false;
3434+
3435+
if (typeof file === "string") return hasMediaExtension(file);
3436+
3437+
const type = (file.type || "").toLowerCase();
3438+
3439+
if (type.startsWith("image/")) {
3440+
const subtype = type.slice("image/".length);
3441+
if (MEDIA_EXTENSIONS.indexOf(subtype) !== -1) return true;
3442+
}
3443+
3444+
return hasMediaExtension(file.name);
3445+
}
3446+
34183447
fileInput.addEventListener("change", function () {
34193448
const files = Array.from(fileInput.files);
34203449

@@ -3426,8 +3455,14 @@
34263455
a.lastModified === b.lastModified;
34273456

34283457
files.forEach(f => {
3429-
if (!host.__files.some(existing => isSame(existing, f))) {
3430-
host.__files.push(f);
3458+
if (isMediaFile(f)) {
3459+
if (!host.__images.some(existing => isSame(existing, f))) {
3460+
host.__images.push(f);
3461+
}
3462+
} else {
3463+
if (!host.__files.some(existing => isSame(existing, f))) {
3464+
host.__files.push(f);
3465+
}
34313466
}
34323467
});
34333468

docs/changelog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
#### 2026 May 12 - version 0.9.3
2+
3+
- Route dropped media files to the image list
4+
5+
Updated the input bubble file handling so image files received through drag-and-drop or file selection are detected by MIME type and extension, then routed to the image attachment list instead of the generic file list. The UI now keeps documents and image media separated correctly.
6+
7+
- Fix Anthropic web search tool result replay (VCL_Anthropic demo)
8+
9+
Added support for replaying `web_search_tool_result` blocks in the Anthropic context builder. This preserves the required pairing between previous `web_search` tool calls and their results, preventing 400 errors when continuing conversations that used web search earlier.
10+
11+
112
#### 2026 May 11 - version 0.9.2
213

314
- Fix code block parsing with KaTeX protection

docs/pythia-documentation.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,7 +2094,6 @@ Instantiate the vendor after the form is shown and the browser has had time to i
20942094

20952095
```pascal
20962096
uses
2097-
System.Threading,
20982097
VCL.WVPythia.Chat,
20992098
WVPythia.Types,
21002099
VCL.WVPythia.Services,
@@ -2105,28 +2104,10 @@ begin
21052104
Pythia := TVCLPythia.Create(Panel2);
21062105
Pythia.ServiceAdapter := TVCLChatManagedItemDialogService.Create;
21072106
Pythia.OnApiKeyChanged := UpdateApiKey;
2107+
Pythia.OnInitialized := DoOnInitialized;
21082108
Pythia.Update;
21092109
end;
21102110
2111-
procedure TForm1.FormShow(Sender: TObject);
2112-
begin
2113-
DelayedFormshow;
2114-
end;
2115-
2116-
procedure TForm1.DelayedFormshow;
2117-
begin
2118-
TTask.Run(
2119-
procedure()
2120-
begin
2121-
Sleep(1200);
2122-
TThread.Queue(nil,
2123-
procedure
2124-
begin
2125-
DoInitialize;
2126-
end);
2127-
end);
2128-
end;
2129-
21302111
procedure TForm1.DoInitialize;
21312112
begin
21322113
AlphaBlend := False;

0 commit comments

Comments
 (0)