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

search-suggestions: Remove is:dm suggestion from get_operator_suggestions #30330

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

joyhchen
Copy link
Collaborator

@joyhchen joyhchen commented Jun 6, 2024

Fixes: #30320

Currently, there are 2 lists of filterers

  • one for non-spectators (here)
  • one for spectators (here)

When you type is: in the search bar as a spectator, it currently suggests "Direct messages" (Issue 30320) because get_operator_suggestions is adding the suggestion.

This PR

  • Removes the is:dm suggestion from get_operator_suggestions
    • And since get_is_operator_suggestions doesn't apply to spectators, we no longer suggest "Direct messages" when the user searches "is:" (see screenshot)
    • For non-spectators, the is:dm suggestion will be populated from get_is_filter_suggestions

Alternatives considered

  • You can add something like visible_to_spectators on the Suggestion object. This would fix the core problem that suggestions that spectators can't access still appear to them.
    • Why I didn't implement this: In some cases, you might want the suggestion to appear still, I wasn't sure. In any case, when the user clicks the suggestion, they'll see the modal prompting them to login to access more features.

Screenshots and screen captures:

Screenshot 2024-06-06 at 12 50 46 AM
Self-review checklist
  • Self-reviewed the changes for clarity and maintainability
    (variable names, code reuse, readability, etc.).

Communicate decisions, questions, and potential concerns.

  • Explains differences from previous plans (e.g., issue description).
  • Highlights technical choices and bugs encountered.
  • Calls out remaining decisions and concerns.
  • Automated tests verify logic where appropriate.

Individual commits are ready for review (see commit discipline).

  • Each commit is a coherent idea.
  • Commit message(s) explain reasoning and motivation for changes.

Completed manual review and testing of the following:

  • Visual appearance of the changes.
  • Responsiveness and internationalization.
  • Strings and tooltips.
  • End-to-end functionality of buttons, interactions and flows.
  • Corner cases, error conditions, and easily imagined bugs.

@joyhchen joyhchen changed the title [wip] web-search-suggestions: Move is:dm suggestion to new filterer [wip] search-suggestions: Move is:dm suggestion to new filterer Jun 6, 2024
@@ -23,6 +23,7 @@ run_test("phrase_match", () => {
assert.ok(common.phrase_match("Tes", "test"));
assert.ok(common.phrase_match("Tes", "Test"));
assert.ok(common.phrase_match("tes", "Stream Test"));
assert.ok(common.phrase_match("", "test"));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would you prefer I move this change to a separate commit? I can do that if so. I added this to make it clear phrase_match matches on empty string.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

I'm not going to ask you to split this so late in review for how much benefit it'll have, but yeah probably it'd have been better to do this in its own commit, with the commit explaining this change.

@joyhchen joyhchen changed the title [wip] search-suggestions: Move is:dm suggestion to new filterer search-suggestions: Move is:dm suggestion to new filterer Jun 6, 2024
@joyhchen joyhchen marked this pull request as ready for review June 6, 2024 19:27
@timabbott
Copy link
Sponsor Member

Thanks for the PR @joyhchen! @pratik-pc would you be up for reviewing this? I think you've been working in that code path recently.

@zulipbot zulipbot added size: S and removed size: M labels Jun 12, 2024
@joyhchen joyhchen changed the title search-suggestions: Move is:dm suggestion to new filterer search-suggestions: Remove is:dm suggestion from get_operator_suggestions Jun 12, 2024
@zulipbot zulipbot added size: M and removed size: S labels Jun 12, 2024
…ions

Previously, is: searches as a spectator would suggest Direct messages even though DMs aren't accessible for spectators. This commit removes the is:dm suggestion from operator suggestions and adds the is:dm suggestion to get_is_filter_suggestions, which only runs for non-spectators
@joyhchen
Copy link
Collaborator Author

@pratik-pc moved the code to get_is_filter_suggestions

@pratik-pc
Copy link
Collaborator

This looks good to me now

@timabbott I think this is ready now

@alya alya added the integration review Added by maintainers when a PR may be ready for integration. label Jun 17, 2024
@alya
Copy link
Contributor

alya commented Jun 17, 2024

@pratik-pc Have you manually tested this PR?

@timabbott
Copy link
Sponsor Member

The commit message isn't properly formatted. Check out our GitHub guide and commit guidelines for more details.

image

@timabbott timabbott merged commit 8a1a41e into zulip:main Jun 17, 2024
7 checks passed
@timabbott
Copy link
Sponsor Member

Merged, thanks @joyhchen and @pratik-pc, after testing manually and rewriting the commit message.

I think this may not be the best possible implementation, though; it feels like the ideal setup would be for us to be able to declare private as an alias in this declaration, and have the search system take care of it from there.

    const suggestions = [                                                                               
        {                                                                                               
            search_string: "is:dm",                                                                     
            description_html: "direct messages",                                                        
            incompatible_patterns: [                                                                    
                {operator: "is", operand: "dm"},                                                        
                {operator: "is", operand: "resolved"},                                                  
                {operator: "channel"},                                                                  
                {operator: "dm"},                                                                       
                {operator: "in"},                                                                       
            ],                                                                                          
        },                                                                                              

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration review Added by maintainers when a PR may be ready for integration. size: M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove is:dm search suggestion for spectators
5 participants