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

feat: implement related-prompts multi-query #1685

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

lauramargar
Copy link
Contributor

@lauramargar lauramargar commented Jan 8, 2025

Pull request template

The idea is to display related prompts from different queries in the same view. For that reason, we have changed the related-prompt structure, now, we are setting the prompts in the state as a dictionary of the queries requested with their corresponding prompts.
We also have to manage the selected prompt view in different locations. For that, we obtain the location of the related prompts from the metadata of the event UserSelectedARelatedPrompt, which also provides the related prompt query.

Motivation and context

Display related-prompts in the toolbar (under the searchbox), and embbed into the results grid.

  • Dependencies. If any, specify:
  • Open issue. If applicable, link:

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that causes existing functionality to not work as expected)
  • Change requires a documentation update

What is the destination branch of this PR?

  • Main
  • Other. Specify:

How has this been tested?

Try with query trousers in the X demo

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review on my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

@lauramargar lauramargar marked this pull request as ready for review January 9, 2025 10:09
@lauramargar lauramargar requested a review from a team as a code owner January 9, 2025 10:09
Comment on lines +15 to +17
endpoint:
'https://api.empathy.co/relatedprompts/mymotivemarketplace?store=Labstore+London&lang=en',
requestMapper: ({ query }) => ({ query }),
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess those changes are not intended, are they?

@@ -66,23 +69,48 @@
showOnlyAfterOffset: {
type: Boolean,
default: false
}
},
customQuery: String
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to avoid custom prefix everything. I think we could just use query for the prop

() => props.customQuery,
() => {
if (props.customQuery || props.customQuery !== '') {
x.emit('RelatedPromptsCustomQueryProvider', props.customQuery);
Copy link
Contributor

Choose a reason for hiding this comment

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

Following the comment above, I'd like to skip the custom prefix. Besides, we should stick to our convention of using past tense. What about RelatedPromptsQueryProvided?

Comment on lines 77 to 85
const { query, status } = useState('relatedPrompts', ['query', 'status']);

/**
* The state related prompts.
*/
const relatedPrompts: ComputedRef<RelatedPrompt[]> = useState('relatedPrompts', [
'relatedPrompts'
]).relatedPrompts;
const relatedPrompts: ComputedRef<Dictionary<RelatedPromptsItems>> = useState(
'relatedPrompts',
['relatedPrompts']
).relatedPrompts;
Copy link
Contributor

Choose a reason for hiding this comment

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

We could call just once to useState here, right?

* The current location of the related prompts.
* Payload: The query to request prompts and the location of the related-prompts.
*/
RelatedPromptsLocation: { location: FeatureLocation | undefined; query: string };
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't need this event at all. We could just use UserSelectedARelatedPrompt and rely on the metada. We always provide the location as metadata for the events:

image

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.

2 participants