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:
1 parent
5be1e589f2
commit
6646f5fbee
53 files changed
+1972
-847
No files matched your search
@@ -127,6 +127,38 @@ describe("NanobotTui composer", () => {
|
||||
expect(ui.composer.plainText).toBe("")
|
||||
})
|
||||
|
||||
test("retains the image and text until acceptance and after upload failure", async () => {
|
||||
setup = await createRenderer({ width: 72, height: 20, screenMode: "alternate-screen" })
|
||||
const transport = client()
|
||||
let rejectSend: (error: Error) => void = () => {}
|
||||
let resolveSend: (turnId: string) => void = () => {}
|
||||
let attempts = 0
|
||||
transport.sendAttachments = () => {
|
||||
attempts++
|
||||
return new Promise<string>((resolve, reject) => { resolveSend = resolve; rejectSend = reject })
|
||||
}
|
||||
const app = NanobotTui.mount(setup.renderer, options, transport,
|
||||
new MockTreeSitterClient({ autoResolveTimeout: 0 }), undefined,
|
||||
{ read: async () => ({ mimeType: "image/png", dataUrl: "data:image/png;base64,eA==" }), dispose: async () => {} })
|
||||
app.accept({ event: "attached", chat_id: "chat" })
|
||||
const ui = app as unknown as { ready: boolean; composer: TextareaRenderable; draft: { imageCount: number }; status: { plainText: string } }
|
||||
await waitUntil(() => ui.ready)
|
||||
setup.mockInput.pressKey("v", { ctrl: true })
|
||||
await waitUntil(() => ui.draft.imageCount === 1)
|
||||
ui.composer.submit()
|
||||
await waitUntil(() => attempts === 1)
|
||||
expect(ui.composer.plainText).toContain("[Image #1]")
|
||||
rejectSend(new Error("Upload failed (401)"))
|
||||
await waitUntil(() => ui.status.plainText.includes("401"))
|
||||
expect(ui.draft.imageCount).toBe(1)
|
||||
expect(ui.composer.plainText).toContain("[Image #1]")
|
||||
ui.composer.submit()
|
||||
await waitUntil(() => attempts === 2)
|
||||
resolveSend("accepted-image")
|
||||
await waitUntil(() => ui.composer.plainText === "")
|
||||
expect(ui.draft.imageCount).toBe(0)
|
||||
})
|
||||
|
||||
test("pastes clipboard images into removable placeholders and sends their data", async () => {
|
||||
const sent: string[] = []
|
||||
const sentOptions: MessageOptions[] = []
|
||||
|
||||
Reference in new issue
Block a user