mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 06:03:26 -05:00
[PR #24864] [CLOSED] feat(chat): citation modal as global singleton via store #115205
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/24864
Author: @julenlurnova
Created: 5/18/2026
Status: ❌ Closed
Base:
main← Head:feat/citation-modal-store📝 Commits (3)
86932affeat(chat): add citation modal store1956616feat(chat): mount global citation modal in layoutc486904refactor(chat): dispatch citation modal via store📊 Changes
3 files changed (+48 additions, -20 deletions)
View changed files
📝
src/lib/components/chat/Messages/Citations.svelte(+4 -20)➕
src/lib/stores/citations.ts(+31 -0)📝
src/routes/(app)/+layout.svelte(+13 -0)📄 Description
Citations.svelte mounts per instance. A chat with N RAG responses has N modal state machines in the DOM, idle until clicked.
Same shape as the embed/showEmbeds pattern already in $lib/stores. Applied to citations:
bind:thisref hacks into the right instance.Changes
src/lib/stores/citations.ts— writable + openCitation/closeCitationsrc/routes/(app)/+layout.svelte— mount once, subscribed to storesrc/lib/components/chat/Messages/Citations.svelte— dispatch via store instead of local mount;showSourceModalexport kept as thin wrapper for back-compatBridge note
The +layout bridge is one-way sync (store→local) + close-back handler. The naive
if ($store.show !== local) { sync }form races itself: the X click writes false to local viabind:show, the reactive immediately re-syncs from store (still true), undoes the close. The split form (one$:writes local from store, a separate$:writes store-close when local goes false) avoids the loop.Tested
Follow-ups (separate PRs if this lands)
Same pattern fits ImagePreview (Image.svelte mounts one per image — 7+ call sites in the chat tree) and CodeExecutionModal. Happy to open those as small PRs after this is reviewed.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.