-
Notifications
You must be signed in to change notification settings - Fork 891
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
feat: update discover summary UX #8700
base: main
Are you sure you want to change the base?
feat: update discover summary UX #8700
Conversation
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8700 +/- ##
==========================================
+ Coverage 60.71% 60.75% +0.03%
==========================================
Files 3798 3798
Lines 90662 90668 +6
Branches 14260 14263 +3
==========================================
+ Hits 55047 55081 +34
+ Misses 32163 32093 -70
- Partials 3452 3494 +42
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
const manualTriggerVisible = | ||
!shouldAutoTrigger && | ||
canGenerateSummary && | ||
lastUsedQueryStateRef.current?.answer !== queryState.answer; |
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.
should we compare result 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.
Maybe unnecessary and too much to have a deep equality check on the results? The "Generate summary" button will be available to for a manual trigger if needed when results updated.
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.
Thanks for making this change, there are some minor UX changes which might not
be covered:
- The title "Response" needs update?
- Summary panel should be under PPL edit panel?
- "Generate Summary" with a sparkling icon next to it?
- From UX mock in the video, it looks like, even the summary is generated, the "Generate summary" is also clickable?
@@ -88,6 +87,7 @@ export const QueryAssistBar: React.FC<QueryAssistInputProps> = (props) => { | |||
language: params.language, | |||
dataset: selectedDataset, | |||
}); | |||
updateQueryState({ question: previousQuestionRef.current, answer: response.query }); |
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 much better implementation. 👍
question: string; | ||
question$: BehaviorSubject<string>; | ||
updateQuestion: (question: string) => void; | ||
answer: string; |
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.
answer
is quite vague, can we use generatedQuery
or xxxQuery
to make it more specific?
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.
Good point, I will update
queryState.answer && queryState.answer !== props.data.query.queryString.getQuery().query; | ||
// It can generate summary when | ||
// 1. it has the current generated query(answer) | ||
// 2. the generated query didn't been changed by user |
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.
query didn't been changed by user
The definition of it means user doesn't click "run" button after changing query, right?
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.
Yes, let me update the comment so it's more precise.
// 1. it has the current generated query(answer) | ||
// 2. the generated query didn't been changed by user | ||
// 3. there are search results | ||
const canGenerateSummary = Boolean(results.length) && Boolean(queryState.answer) && !queryChanged; |
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 could be a case that when question changes and answer remains the same, but we can't generate summary, is that expected?
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 think it can generated summary in such case. canGenerateSummary
should be true
canGenerateSummary && | ||
lastUsedQueryStateRef.current?.answer !== queryState.answer; | ||
// The visibility of panel action buttons: thumbs up/down and copy to clipboard buttons | ||
const actionButtonVisible = summary && !loading && !queryChanged && !manualTriggerVisible; |
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.
shall we also check if text to ppl is loading?
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.
Sounds reasonable to me, but seems no good way to read the PPL loading state, I think I'll keep it simple for now
const getPanelMessage = useCallback(() => { | ||
if (loading) { | ||
return ( | ||
<EuiText size="s" data-test-subj="queryAssist_summary_loading"> |
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: (refactor suggestion):(non-blocking)
Looks like some duplicate code could be saved:
if (xxx) {
return (
<EuiText xxxx>
)
}
What about
const renderConditionalText = (shouldRender, dataTestSubj, i18nKey, default) {
if (!shouldRender) return null;
return (
<EuiText size="s" data-test-subj={dataTestSubj}>....
)
}
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 not sure if I fully understood, but to my understanding, renderConditionalText
is pretty much doing what EuiText
does, I don't see much value to move the conditional logic into the function.
src/plugins/query_enhancements/public/query_assist/components/query_assist_summary.tsx
Outdated
Show resolved
Hide resolved
src/plugins/query_enhancements/public/query_assist/components/query_assist_summary.tsx
Outdated
Show resolved
Hide resolved
}, | ||
[props.usageCollection, METRIC_APP] | ||
); | ||
const queryChanged = |
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.
Will this be recalculated whenever there's state change?
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.
Yes, the change of queryState
will make the component rerender.
Thank you very much for the detailed review
|
It will only auto-trigger the summary generating the first time a ppl query was generated. The following summary generation requires user to click a "Generate summary" button. Signed-off-by: Yulong Ruan <[email protected]>
Signed-off-by: Yulong Ruan <[email protected]>
Signed-off-by: Yulong Ruan <[email protected]>
+ change variable `answer` -> `generatedQuery` to be more specific Signed-off-by: Yulong Ruan <[email protected]>
eae71a9
to
63f292f
Compare
Description
Trigger summary generation on initial query, add manual trigger for subsequent queries.
This PR updates the summary generation logic to improve user experience. Previously, summaries were auto-triggered on every ppl query. Now, summaries will only be auto-generated on the first query execution. For any subsequent queries, users will need to click the "Generate Summary" button to trigger the summary generation manually.
Screen.Recording.2024-10-24.at.18.42.46.mov
Issues Resolved
Screenshot
Testing the changes
Changelog
Check List
yarn test:jest
yarn test:jest_integration