-
Notifications
You must be signed in to change notification settings - Fork 151
feat: measure anomaly quick explanation #8077
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
b1d5a3d to
375deff
Compare
d04c949 to
804dc1d
Compare
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.
UXQA:
- It doesn't seem as if the "E" click handler has been registered. When I press "E" nothing happens.
- After injecting the prompt, we should focus the chat input element. Then it'll be easier for the user to simply press
enterto submit the message. - Let's say I focus one data point and see the "Explain" CTA. If I further interact with the chart, like highlighting a time range or panning to a new time range, then the focused data point should be cleared.
- The context pill for the below time range shows "Invalid interval"

- I've discovered that the "Explain" text is clickable. There should be a hover effect to explicitly signal to the user that it's clickable.
- Because the context provided to the AI is provided per-message, we should have UI that shows that a message was sent with context. We can look at Cursor for inspiration.

- Along the lines of 6, I think we should put the context pills within the chat input, not outside of it.

- We should be able to clear context pills individually, not just as a group.
- The context pills have a hover effect, but nothing happens when I click on them.
| // Parse messages and fill in context | ||
| $: currentConversation.context.parseMessages(messages); |
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.
This UI component should simply be focused on rendering. If the Context class needs to operate on messages, then the class should fetch the messages from the TanStack Query cache directly. (Alternatively, there's a world where the Context class could get the messages from the Conversation class, but, since we're leaning into TanStack Query cache as the source-of-truth, I don't think we're really set-up for this approach.)
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.
The problem is we need a svelte derived store with unsubscribe. So we would have that called somewhere in a component.
Lets keep it simple for now, we can revisit once we have better contexts.
| import Markdown from "../../../../components/markdown/Markdown.svelte"; | ||
| import type { V1Message } from "../../../../runtime-client"; | ||
|
|
||
| export let message: V1Message; | ||
| export let content: string; | ||
|
|
||
| $: cleanedContent = ConversationContext.cleanContext(content); |
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.
Rather than adding data processing logic to this UI component, can we put this processing in the Conversation class logic in conversation.ts?
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.
Note that this is displaying a V1Message and has nothing to do with the Conversation class directly. So this makes sense to clean it here itself. In future, context might not be part of the prompt, so easy to clean up as well.
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.
Nit: rather than "presets", can we call this directory "prompts" or similar?
| if ( | ||
| hoveredTime && | ||
| measure.name && | ||
| TIME_GRAIN[timeGrain] && | ||
| !hasSubrangeSelected | ||
| ) { |
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.
This is a complex conditional. What about an explanatory variable?
| } | ||
| function onMouseClick() { | ||
| function onMouseClick(e) { |
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.
This function is quite hard to follow now. Mind trying to find a way to clean it up?
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.
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.
Hmmm we need a greater scrub refactor to move interactions to a single class. We can use a state machine then. Added comments for now.
| setTimeout(() => { | ||
| autoResize(); | ||
| }, 5); |
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.
Why this timeout?
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.
Added a comment explaining it.
| import type { V1Message } from "@rilldata/web-common/runtime-client"; | ||
| import { get, type Writable, writable } from "svelte/store"; | ||
|
|
||
| const contextRegex = /\s*<context>([\s\S]*?)<\/context>/m; |
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 see your PR comment. I agree– let's build on the backend PR's approach to context.
|
Thanks @ericpgreen2 . Have addressed all except 8. Removing certain context without others can get complex. Lets do that in the comprehensive context PR. |
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.
UXQA:
- The highlighted point or time range on the measures line chart should stay selected after asking AI — don’t auto-clear it. Right now from the screenshot below I don't know which point I'm asking for explanation after the question sent to AI.
- Make “Explain” Button Look Clickable, I use link button from the ShadCN component, so it should has a hover effect like the screenshot below.
- When drag a time range on the chart, it should be an Explain(E) button display under the selected time range, right now I have to drag a time range, and click on it again to see the Explain(E) button. Follow the interaction guide:
- Issue for future fix:
When a point or especially a time range is selected, the visual isn't emphasized enough, reducing clarity about what’s being analyzed or referenced in the AI query. Might need a better visual highlight in the future.
d5b8c77 to
1259f14
Compare
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.
Listed UXQA issues addressed.
| y={plotBottom + 10 + bodyBuffer} | ||
| on:click={onExplain} | ||
| > | ||
| Explain(E) |
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.
Nit: add a space– "Explain (E)"
| y={plotBottom + 10 + bodyBuffer} | ||
| on:click={onExplain} | ||
| > | ||
| Explain(E) |
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.
Oh, here too
|
Closing in favour of #8172 |

Adds a quick way to get info about a particular timestamp.
Design: https://www.figma.com/design/JtG3sbaopjO0xQlyeCjmho/RILL-WIP?node-id=406-60840&t=MjQi7JW86b7DIXcN-0
Adds some very basic WIP context framework. This is subject to change based on the backend refactor PR.
Closes APP-439
Checklist: