Skip to content
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

fix(quantic): CRGA component not showing collapsed when answer appears without streaming #4840

Merged
merged 19 commits into from
Jan 20, 2025

Conversation

SimonMilord
Copy link
Contributor

@SimonMilord SimonMilord commented Jan 8, 2025

SFINT-5914

ISSUE:

This is following a maintenance case where some cases of customers would trigger a CRGA answer directly without the stream. This would cause the answer to show fully rather than collapsed.

The culprit is caused by the following code:

image

The generatedAnswerElementHeight, when isStreaming is false ( case where the answer is generated in one shot rather than being streamed), is essentially 0. Therefore, the this._exceedsMaximumHeight = 0 > 250px which is false and therefore does not result in the answer being collapsed. This is happening since the component does not re-render and therefore does not re-calculates the height and CSS variables.

SOLUTION:

Adding quantic__answergenerated event.

We are proposing dispatching an event from the quanticGeneratedAnswerContent component when the answer's HTML is updated. We then listen for this event in the quanticGeneratedAnswer component and recalculate the CSS variables.

When the event is triggered, it calls this function:

image

E2E:

image

Copy link

github-actions bot commented Jan 8, 2025

Pull Request Report

PR Title

❌ Title should follow the conventional commit spec:
<type>(optional scope): <description>

Example: feat(headless): add result-list controller

Live demo links

Bundle Size

File Old (kb) New (kb) Change (%)
case-assist 243.9 243.9 0
commerce 355.1 355.1 0
search 415 415 0
insight 406.3 406.3 0
recommendation 256.2 256.2 0
ssr 408.9 408.9 0
ssr-commerce 372.9 372.9 0

SSR Progress

Use case SSR (#) CSR (#) Progress (%)
search 39 44 89
recommendation 0 4 0
case-assist 0 6 0
insight 0 27 0
commerce 0 15 0
Detailed logs search : buildInteractiveResult
search : buildInteractiveInstantResult
search : buildInteractiveRecentResult
search : buildInteractiveCitation
search : buildGeneratedAnswer
recommendation : missing SSR support
case-assist : missing SSR support
insight : missing SSR support
commerce : missing SSR support

@SimonMilord SimonMilord marked this pull request as ready for review January 16, 2025 15:54
@SimonMilord SimonMilord requested a review from a team as a code owner January 16, 2025 15:54
Copy link
Collaborator

@erocheleau erocheleau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question of renaming the event so it better describes what it is.

And don't forget to move the two lines of comments that go with the code.

This is a very good example why the code should be "self-explanatory" in this case I chose to add those comments, may not have been the best idea, because now we need to remember to move those comments along with the code. FYI

Copy link
Collaborator

@erocheleau erocheleau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice

@SimonMilord SimonMilord added this pull request to the merge queue Jan 20, 2025
Merged via the queue into master with commit 0cfeec7 Jan 20, 2025
101 checks passed
@SimonMilord SimonMilord deleted the SFINT-5914 branch January 20, 2025 18:43
github-merge-queue bot pushed a commit that referenced this pull request Jan 30, 2025
…tedAnswer component (#4871)

[SFINT-5855](https://coveord.atlassian.net/browse/SFINT-5855)

## IN THIS PR:

- Added new property to the `quanticGeneratedAnswer` component called
`maxCollapsedHeight` (same name as in Atomic). This property dictates
what is the desired height of the generated answer before we collapse
it.
- Default value is still 250px
- We now also have an accepted range from 150px to 500px, otherwise the
default value is applied.

Note: We want to merge this
[PR](#4840) first since there will
be conflicts.

## DEMO:

#### Example when `maxCollapsedHeight` is within the acceptable range
(here 151px is within 150 and 500px)
<img width="760" alt="image"
src="https://github.com/user-attachments/assets/6f281318-c9c9-4f64-87e0-4cc28bbef36e"
/>

OUTCOME: it caps the height to 151px since 151px is between 150 and
500px.

#### Example when `maxCollapsedHeight` is outside the acceptable range
(here 100px is NOT within 150 and 500px)
<img width="1482" alt="image"
src="https://github.com/user-attachments/assets/c3aaa141-995d-4254-979a-7356ad64c83d"
/>

OUTCOME: it displays the entire answer since the stated
`maxCollapsedHeight` of 100px is NOT within 150 and 500px. Therefore,
the answer height of 156px being smaller than 250px (Default height) is
fully displayed. It also logs a warning in the console about this value
of maxCollapsedHeight being outside the acceptable range.

#### Example when `maxCollapsedHeight` is outside the acceptable range
(here 600px is NOT within 150 and 500px)
<img width="1596" alt="image"
src="https://github.com/user-attachments/assets/83e62fd4-b395-4aab-be9f-25a71efd93a3"
/>

OUTCOME: it displays the entire answer since the stated
`maxCollapsedHeight` of 600px is NOT within 150 and 500px. Therefore,
the answer height of 195px being smaller than 250px (Default height) is
fully displayed. It also logs a warning in the console about this value
of maxCollapsedHeight being outside the acceptable range.

## UNIT TESTS:

<img width="1024" alt="image"
src="https://github.com/user-attachments/assets/e8c0a748-f0a2-44e2-bbf5-8a560ceec63a"
/>


[SFINT-5855]:
https://coveord.atlassian.net/browse/SFINT-5855?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants