-
Notifications
You must be signed in to change notification settings - Fork 159
fix: move citation urls to buttons in embed #8443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for the fix! The core issue makes sense - The implementation works, but I wanted to share some thoughts on the approach and potential alternatives. Current approach concerns: The button +
Short-term alternative - Svelte Action: Instead of branching in the renderer, we could keep // citation-link-action.ts
export function enhanceCitationLinks(node: HTMLElement) {
const isEmbedded = EmbedStore.isEmbedded();
function handleClick(e: MouseEvent) {
const link = (e.target as HTMLElement)?.closest("a[data-citation]");
if (!link || !isEmbedded) return;
e.preventDefault();
const href = link.getAttribute("href");
if (href) goto(href);
}
node.addEventListener("click", handleClick);
return {
destroy() { node.removeEventListener("click", handleClick); },
};
}This keeps semantic Medium-term idea - Structured Citations: The deeper issue is that citations are embedded in markdown strings, forcing us to parse/rewrite HTML. One option would be to have the backend return citations as structured data separate from the markdown content, letting the frontend render them as proper Svelte components. I've drafted a proposal for this approach here: https://www.notion.so/rilldata/Citation-URLs-tech-clean-up-2c5ba33c8f578030813df6ab43bbb64d Would love feedback on whether this direction makes sense or if there are concerns I'm not seeing. If we need to ship quickly, the current PR works. Happy to discuss either alternative further. Developed in collaboration with Claude Code |
ericpgreen2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to the approach in the PR as-is, but it doesn't feel like the most maintainable, ideal design. Thoughts on the two ideas (one a quicker idea that might help code co-location; one a larger-scale refactor) mentioned above?
051db96 to
aab26c8
Compare
|
Even in non-embed it would do a full page refresh. So I opted to always use As for the long term fix,
|
aab26c8 to
80517df
Compare
ericpgreen2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll approve the PR, and we can pick up the long-term architecture another time. For this PR though– thoughts on the Svelte Action approach, or otherwise encapsulating the complexity & moving it out of the TextMessage.svelte (AssistantMessage.svelte, on main) component? Perhaps we should have one file /chat/core/messages/text/citation-urls.ts that holds all the logic.
|
Here's where we can continue the discussion of the longer-term refactor: #8502 |
* fix: move citation urls to buttons in embed * Remove checks for embedded context * Move action out of svelte
* fix: move citation urls to buttons in embed * Remove checks for embedded context * Move action out of svelte
A link in embed can cause issues on
cmd/ctrl+click. The link opened will be the iframe url which will not open. So we need to convert it to a button to avoid such issues.Checklist: