Repository navigation
feat(webui): show generated images and audio inline in chat - #6384
Conversation
Images from generate_image and tracks from generate_music /
generate_sound_effect now appear in the answer instead of as a bare path:
the image (click for full size) and an audio player with the file name and
length. They come back when the chat is reopened.
- The Agent UI host builds the `image` / `audio` card from the tool
result's saved path, for in-process and relayed turns alike, so no
sidecar contract version changes; `audio_path` joins the result keys a
relayed turn carries.
- GET /api/media/{kind}/{name} serves only a plain file name sitting
directly in GAIA's own image or audio generation folder: traversal,
absolute paths, symlinks, subfolders and other suffixes are 404s.
- `audio` is a new generic render primitive (additive); the TUI draws it,
and a generated image, as caption + saved path (+ length).
- A reloaded answer rebuilds its cards from the tool steps that persisted
them.
Microphone input is out of scope; voice input is tracked in #702.
Fixes #540
|
Verdict: Approve with suggestions Generated images and music/sound effects now show up inline in the Agent UI chat and come back when you reopen the conversation; the TUI shows a text card instead of "Unsupported". The new file route is tightly locked down: it serves only plain file names sitting directly in GAIA's own generation folders, and the live evidence below shows it refusing traversal, symlinks, subfolders and SVG. I found no blocking issues. Two small UI polish items:
Real-world evidenceThe CI evidence stage started the real backend and called the new media route over HTTP. The rendered chat screenshot is pending strix-halo lane, and the TUI cards were N/A on that lane, so the visual result rests on static review and the component tests until those land. Spot regression: the sibling 🔍 Technical details🟢 Minor
Strengths
|
…ngth The image card's full-size toggle label now goes through the locale files, and the audio length is wrapped left-to-right so it reads correctly in the Arabic layout. Notes why a relayed result's data gives way to the card.
|
Fixed all three in the latest commit. The full-size toggle label now comes from the locale files (English and Arabic), the audio length is wrapped left-to-right, and a one-line comment explains why a relayed result's data is replaced by the card. |
Skill audit
✅ All audited skills cleared the tier they claim. Per-finding detail is withheld here on purpose. Read it in the Security > Code scanning tab, or download the |
A tool-reported image or audio path like a UNC share path (//host/share/x.png) made the server resolve it, which opens an SMB connection and can leak the user's NTLM credentials, before the generated-folder check ran. The card builder now refuses UNC, device and NT-namespace spellings, and any path whose folder is not spelled as the media folder, from the string alone; only then does it resolve the file.
|
A generated-image result that named a network share (for example 🔍 Technical details
|
Main now plays generated audio inline (#6384), so this keeps only the save folder, the Outputs list and the narration lines. A track saved with save_to is written to GAIA's audio folder first, so the chat still plays it, and then copied to the user's folder; the copy is what Outputs lists. Drops the second audio card, the /api/files/audio route, the generated_audio payload, the TUI result row the card now covers, and the skill and live-test changes.
… in Outputs (#6118) Generated music and sound effects already play in the chat (#6384), but they could only be saved in GAIA's own cache, the session panel's Outputs never listed them, and a long generation showed a generic step line. Now "save it in my game's audio folder" writes a copy there, never replacing an existing file, while the chat keeps playing GAIA's own copy; each track is listed under Outputs (the user's copy when there is one); and both apps' step lines read "Composing 30 s of music: …" or "Generating a 3 s sound effect". **Evals to watch:** `generate_music` and `generate_sound_effect` gain a `save_to` argument, so the next RC eval should compare `gaia_media` and `gaia_skills_tasks` (the music-gen tasks) against the flagship baseline. <details> <summary>🔍 Technical details</summary> - `save_to` takes an absolute folder or a new `.wav` path. It is checked against the host's write policy before anything about the path is reported, refused before generation when relative, missing, existing or not allowed, and written with exclusive create after generation. A failed copy leaves no partial file and the error names where the original is. - The `music-gen` skill (now 1.1.0) tells the model to pass the user's folder as `save_to` instead of copying the file by hand. - The result keeps `audio_path` (GAIA's copy, which the inline player serves) and adds `saved_to`. The turn summary lists `saved_to` as the output and records GAIA's copy as `copy_of`, so the Outputs list shows the track once. - Cut from the earlier version of this PR because main covers it or it is a separate change: the second audio card and `/api/files/audio` route (main's player from #6384), the `generated_audio` result payload and TUI result row (main's audio card shows path and length), the WAV chunk parser and missing-model download hint, the rest of the `music-gen` skill rewrite, and the live-test and lane-allowlist follow-ups. </details> ## Test plan - [x] `python -m pytest tests/unit/test_audio_generation_tools.py tests/unit/chat/ui/test_session_outputs.py tests/unit/test_sse_narration.py tests/unit/chat/ui/test_generated_media.py` - [x] `go test ./internal/ui/chat/...` in `tui/`; `npx tsc --noEmit` and vitest on the session panel and locales - [ ] With ACE-Step downloaded: "make 20 seconds of calm piano and save it in <an existing folder>". The track plays in the chat, the WAV lands in the folder, Outputs lists it once, and asking again with the same file name is refused.
When GAIA generated an image, a song or a sound effect, the Agent UI chat showed only a file path, so you had to go find the file to see or hear it. Now the image appears in the answer (click it for full size) and music and sound effects get a player with the file name and length. Both come back when you reopen the chat. Only files GAIA saved in its own generation folders are shown or served.
Scope, as decided for this PR: this covers rendering what the agent already makes. Microphone input from the original issue is left out; voice input is tracked in #702. Text-to-speech output is not included either. No agent prompts or tool schemas change, so no eval run is needed.
One visible change: a turn that only generates an image or audio, with no text, now ends as done with the card as its answer instead of "GAIA ran its tools but didn't write an answer".
🔍 Technical details
image/audiocard from the tool result'simage_path/audio_pathin the chat stream loop (media_cardingaia/ui/generated_media.py). That one place covers in-process and relayed turns. No sidecar emits the card, so no sidecarapiVersionbump:audio_pathjust joinsRESULT_PATH_KEYS/SUMMARY_VIEW_KEYS, and an older sidecar gets no audio card.GET /api/media/{kind}/{name}only accepts a plain name with an allowed raster/WAV suffix that is a regular non-symlink file directly in~/.gaia/cache/sd/imagesor~/.gaia/cache/audio/generations. The response carriesnosniffandCSP: sandbox. Everything else returns 404.audioprimitive, andimage.srcnow also accepts/api/media/image/<name>. The TUI draws both as caption + saved path (+ length) instead of "Unsupported".fromApiMessagesrebuildsmessage.cardsfrom persisted tool steps (the hydration feat(ui): route email chat through the sidecar /v1/email/query loop (V2-10) #2109 left as a TODO). The post-turn refetch no longer drops those cards.Test plan
python -m pytest tests/unit/chat/ui/test_generated_media.pycovers traversal, encoded traversal, absolute paths, symlinks out and in, subfolders, suffixes, the cold state, the relay stream, persistence and the tools' folders matching the served ones. The 3 symlink cases skip on Windows without the privilege and run on Linux CI.python -m pytest tests/unit/chat/ui+ relay/SSE/audio/SD suites: 3245 passednpx vitest run(2321 passed, incl.render-media.test.tsx),npx tsc --noEmitcd tui && go test ./...enable_sd_tools/enable_audio_generation_toolson, generate an image and a sound effect ingaia chat --ui, then reload the chat. Both cards should still be there.Fixes #540