fix(open-webui): drop MCP exposure and address remaining review comments
Per ajnart's review (and CodeRabbit withdrawing its own MCP comment on the
predecessor PR), the Open WebUI chat isn't a meaningful MCP surface:
- remove the .meta({ mcp }) metadata from every openWebUi procedure
Remaining CodeRabbit comments from the predecessor PR that weren't carried over:
- processWeb: constrain the URL to http(s) and reject loopback/metadata hosts
(private LAN ranges stay allowed for self-hosters); it is also creator-gated
- uploadFile/transcribe: bound the base64 payload and validate filename/type
- docs: align the example URL with the integration default port (8080)
- new chat: clear the composer draft so it doesn't leak into the fresh chat
- web ingestion: keep the typed URL when ingestion fails
- persistence: fall back to the default title for image-only opening turns, and
don't persist a partial reply from a failed turn as finished history
- multimodal round-trip: make the native chat/history contracts accept the same
text-or-parts content union as completions, and flatten (not drop) non-text
nodes when rebuilding transcripts so attachment-backed chats aren't lost.
Image data URLs are still kept out of persisted history by design.
This commit is contained in:
7 files changed
+107
-78
No files matched your search
@@ -77,7 +77,12 @@ export function useChatStream({
|
||||
const runPersist = async (finalMessages: ChatMessage[], session: number) => {
|
||||
if (!integrationId || !model) return;
|
||||
// Native history stores plain text; image data URLs are dropped on persist.
|
||||
const title = finalMessages.find((message) => message.role === "user")?.content.slice(0, 80) ?? newChatTitle;
|
||||
// Derive the title from the first user message that actually has text so an
|
||||
// image-only opening turn still gets the fallback title instead of a blank.
|
||||
const firstUserText = finalMessages
|
||||
.find((message) => message.role === "user" && message.content.trim() !== "")
|
||||
?.content.trim();
|
||||
const title = firstUserText ? firstUserText.slice(0, 80) : newChatTitle;
|
||||
const payload = {
|
||||
title,
|
||||
models: [model],
|
||||
@@ -131,15 +136,15 @@ export function useChatStream({
|
||||
setPendingContextTexts([]);
|
||||
};
|
||||
|
||||
const finalizeAssistantMessage = (stopped = false) => {
|
||||
const finalizeAssistantMessage = (skipPersist = false) => {
|
||||
const finalText = streamingTextRef.current;
|
||||
if (finalText.length > 0) {
|
||||
const finalMessages = [...messagesRef.current, { role: "assistant" as const, content: finalText }];
|
||||
setMessages(finalMessages);
|
||||
messagesRef.current = finalMessages;
|
||||
// A user-stopped reply is kept on screen but not written to history as a
|
||||
// finished turn; a later real turn will persist the whole conversation.
|
||||
if (!stopped) void persistChat(finalMessages);
|
||||
// A stopped or failed reply is kept on screen but not written to history as
|
||||
// a finished turn; a later real turn will persist the whole conversation.
|
||||
if (!skipPersist) void persistChat(finalMessages);
|
||||
}
|
||||
streamingTextRef.current = "";
|
||||
setStreamingText("");
|
||||
@@ -165,12 +170,14 @@ export function useChatStream({
|
||||
finalizeAssistantMessage();
|
||||
} else if (event.type === "error") {
|
||||
setError(event.message);
|
||||
finalizeAssistantMessage();
|
||||
// Don't persist a partial reply from a failed turn as finished history.
|
||||
finalizeAssistantMessage(true);
|
||||
}
|
||||
},
|
||||
onError: (err) => {
|
||||
setError(err.message);
|
||||
finalizeAssistantMessage();
|
||||
// Don't persist a partial reply from a failed turn as finished history.
|
||||
finalizeAssistantMessage(true);
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user