[PR #21294] [MERGED] feat: Enable Rich UI embed support for action functions #113323

Closed
opened 2026-05-18 13:40:20 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21294
Author: @Classic298
Created: 2/10/2026
Status: Merged
Merged: 2/11/2026
Merged by: @tjbck

Base: devHead: claude/verify-dynamic-ui-support-RDHW2


📝 Commits (1)

  • 0a08d88 Enable Rich UI embed support for action functions

📊 Changes

2 files changed (+25 additions, -1 deletions)

View changed files

📝 backend/open_webui/utils/chat.py (+24 -0)
📝 backend/open_webui/utils/middleware.py (+1 -1)

📄 Description

Action functions can now return HTMLResponse objects or (html, headers) tuples with Content-Disposition: inline to render rich UI iframes in chat, matching the existing tool behavior.

Why?

Actions and Tools are extremely similar - the only difference is who activates them

Tools get activated by LLMs
Actions get activated by Humans

Otherwise they behave the same. They get called on-demand and do something

So they should have the same capabilities and abilities for developers.

If you want to display beautiful graphs and charts with Actions, you have to inject a codeblock with the HTML content into the assistant's message by modifying the body - and even then it is only shown as an Artifact and not as a rich UI embed like the tools have available.


How action authors can now use Rich UI
Option A — HTMLResponse:

from fastapi.responses import HTMLResponse

async def action(self, body, __event_emitter__=None):
    html = "<html><body><h1>Dashboard</h1></body></html>"
    return HTMLResponse(content=html, headers={"Content-Disposition": "inline"})

Option B — Tuple with headers:

async def action(self, body, __event_emitter__=None):
    html = "<h1>Interactive Chart</h1><script>...</script>"
    return (html, {"Content-Disposition": "inline", "Content-Type": "text/html"})

No frontend changes were needed — the socket handler at Chat.svelte:416 already receives "embeds" events generically and renders them via FullHeightIframe.

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/21294 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 2/10/2026 **Status:** ✅ Merged **Merged:** 2/11/2026 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `claude/verify-dynamic-ui-support-RDHW2` --- ### 📝 Commits (1) - [`0a08d88`](https://github.com/open-webui/open-webui/commit/0a08d88d8af2c43c2268c49277d80878e8d20a88) Enable Rich UI embed support for action functions ### 📊 Changes **2 files changed** (+25 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/chat.py` (+24 -0) 📝 `backend/open_webui/utils/middleware.py` (+1 -1) </details> ### 📄 Description Action functions can now return HTMLResponse objects or (html, headers) tuples with Content-Disposition: inline to render rich UI iframes in chat, matching the existing tool behavior. # Why? <ins>**Actions and Tools are extremely similar - the only difference is who activates them**</ins> Tools get activated by LLMs Actions get activated by Humans Otherwise they behave the same. They get called on-demand and do something So they should have the same capabilities and abilities for developers. If you want to display beautiful graphs and charts with Actions, you have to inject a codeblock with the HTML content into the assistant's message by modifying the body - and even then it is only shown as an Artifact and not as a rich UI embed like the tools have available. --- How action authors can now use Rich UI Option A — HTMLResponse: ``` from fastapi.responses import HTMLResponse async def action(self, body, __event_emitter__=None): html = "<html><body><h1>Dashboard</h1></body></html>" return HTMLResponse(content=html, headers={"Content-Disposition": "inline"}) ``` Option B — Tuple with headers: ``` async def action(self, body, __event_emitter__=None): html = "<h1>Interactive Chart</h1><script>...</script>" return (html, {"Content-Disposition": "inline", "Content-Type": "text/html"}) ``` No frontend changes were needed — the socket handler at Chat.svelte:416 already receives "embeds" events generically and renders them via FullHeightIframe. ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-18 13:40:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#113323