fix(webui): upload TUI and WebUI attachments over binary HTTP (#5980)

* feat(webui): add bounded binary attachment staging

* feat(webui): bridge binary HTTP bodies alongside websocket listener

* fix(webui): deliver attachments over authenticated binary HTTP

* fix(webui): bound incomplete upload headers and preserve staging markers

* test: reflect aiohttp runtime dependency for binary uploads

* fix(webui): relay binary uploads and retain rejected drafts

* refactor(webui): remove obsolete attachment transport errors

* refactor(websocket): own binary attachment transport

* fix(websocket): allow bounded uploads over slow connections

* test(webui): restore upload timeout before retry

* docs(websocket): focus attachment guide on client usage
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-08 11:55:13 +08:00
1 parent 5be1e589f2
commit 6646f5fbee
53 files changed
+1972 -847

No files matched your search

+18 -2
View File
@@ -176,6 +176,7 @@ export class NanobotTui {
private ready = false
private shimmerFrame = 0
private shimmerTimer: ReturnType<typeof setInterval> | null = null
private attachmentSendPending = false
private submitPending = false
private submitGeneration = 0
private unsentSubmit = false
@@ -584,10 +585,25 @@ export class NanobotTui {
this.sendPrompt(prompt)
}
private sendPrompt(prompt: QueuedPrompt, steering = false): boolean {
private sendPrompt(prompt: QueuedPrompt, steering = false, acceptedTurnId?: string): boolean {
if (!acceptedTurnId && prompt.options.media?.length) {
if (this.attachmentSendPending) return false
this.attachmentSendPending = true
const originalText = this.composer.plainText
const chatId = this.client.activeChatId
this.status.content = "Uploading attachments…"
void this.client.sendAttachments(prompt.content, prompt.options).then((turnId) => {
if (this.client.activeChatId !== chatId || this.composer.plainText !== originalText) return
this.sendPrompt(prompt, steering, turnId)
}).catch((error: unknown) => {
this.unsentSubmit = true
this.status.content = error instanceof Error ? error.message : "Attachment send failed · draft retained"
}).finally(() => { this.attachmentSendPending = false })
return true
}
let turnId: string
try {
turnId = this.client.send(prompt.content, prompt.options)
turnId = acceptedTurnId ?? this.client.send(prompt.content, prompt.options)
} catch {
this.markSubmitUnsent(true)
return false