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

Add initial Command Pallette addon #449

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

ericholscher
Copy link
Member

@ericholscher ericholscher commented Nov 23, 2024

This is one I'm pretty excited about.
It takes the Command Pallette pattern from Slack, GitHub, etc.,
and adds it to any documentation page.

I think this could be an interesting UX for our future UX,
and enable a lot of really interesting power user features.

The really nice thing is that it's totally based on a keyboard shortcut,
so doesn't require any UX, and generally folks won't want to disable it.

Demo

Screen.Recording.2024-11-23.at.3.12.46.PM.mov

Requires readthedocs/readthedocs.org#11791

This is one I'm pretty excited about.
It takes the Command Pallette pattern from Slack, GitHub, etc.,
and adds it to any documentation page.

I think this could be an interesting UX for our future UX,
and enable a lot of really interesting power user features.

The really nice thing is that it's totally based on a keyboard shortcut,
so doesn't require any UX, and generally folks won't want to disable it.
@humitos
Copy link
Member

humitos commented Nov 25, 2024

I think this is an interesting idea to explore more 👍🏼 . It seems we don't need to create a different addon and UI for this and it can probably be integrated with the search addon -- like a feature of the search addon: you type anything and you see the results for the "commands" and for the "search" in the same UI.

@ericholscher
Copy link
Member Author

@humitos Yea, I think the main issue I have with search is just the UX. The really nice thing about the filtering UI is that it's instant, whereas search has a pretty long lag. It's going to be tricky to figure out how to build that UX, but I was wondering if page titles and section titles are in-memory matched, but then page results are queried against ES. I think we could build a reasonable UX there, but it's gonna take a little thought and discussion.

I think there's a huge win of the instant feel of the UX of the filtering UI though, and I really want to make sure we keep that working.

A lot of programs have a similar concept where search and filtering are different UX, for example GitHub and VS Code. So I don't think it's obviously wrong to have 2 different UIs. We could ship a default "Command" that is Search $query that shows at the bottom, for example.

@ericholscher
Copy link
Member Author

@humitos any additional thoughts here ^^

I still think the Command Pallette is a powerful UX for exposing a bunch more functionality to users, and would love to get at least a internal-only test going at some point soonish.

Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

I did a code review and I left a few comments and suggestions.

I think this is an interesting concept. However, I'd say we should work on other pieces before moving forward with this (eg. backend API for .json file, add required AddonsConfig fields, etc).

This implementation copies a lot of the search code/UI which, unfortunately, is the least polished one. I mentioned in another comment that I'd like to see the Command Palette and Search UI combined, making these command items inside the same UI.

I don't think this is ready to be exposed to users yet, but we can merge it for internal-only testing once we have done the backend work if you want.

this.commands = [];
this.inputIcon = icon(faMagnifyingGlass, { title: "Search commands" });
this.currentQueryRequest = null;
this.triggerKeycode = 191;
Copy link
Member

Choose a reason for hiding this comment

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

This will collide with the hotkey for search.

Comment on lines +85 to +88
* sections: {
* id: string, // The unique identifier of the section
* title: string, // The title of the section
* }
Copy link
Member

Choose a reason for hiding this comment

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

What a "section" means in the context of a command?

},
];

if (config.projects && config.projects.current) {
Copy link
Member

Choose a reason for hiding this comment

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

There is no need to check for all of these fields. These are always coming in the API response. You just need to add them to the data validation as required fields. The same happens with config.builds below.

Comment on lines +184 to +185
config.addons.filesections &&
config.addons.filesections.pages
Copy link
Member

Choose a reason for hiding this comment

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

This should a URL with the manifest instead and the client should retrieve and parse this data. I mentioned this in the backend PR: readthedocs/readthedocs.org#11791 (comment)

renderCommandPalette() {
console.log("Rendering command palette modal");
return html`
<div ?hidden=${!this.show} role="search">
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be search role.

Copy link
Member

Choose a reason for hiding this comment

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

Note there are more references to search in other places as well.

properties: {
addons: {
type: "object",
required: ["filesections"],
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be required since projects without filesections won't have access to the commands palette.

$id: "http://v1.schemas.readthedocs.org/addons.commands.json",
type: "object",
required: ["addons"],
properties: {
Copy link
Member

Choose a reason for hiding this comment

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

Here you want to have projects, versions and builds required as well.

Comment on lines +277 to +278
// Validator for FileSections Addon
const addons_filesections = {
Copy link
Member

Choose a reason for hiding this comment

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

This should make reference to commands, instead of filesections.

@@ -43,6 +44,7 @@ export class HotKeysElement extends LitElement {
this.docDiffShowed = false;

this.searchHotKeyEnabled = this.config.addons.hotkeys.search.enabled;
this.commandPaletteHotKeyEnabled = true;
Copy link
Member

Choose a reason for hiding this comment

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

We should decide for one name and stick with it everywhere in the code; variables, functions and event names: Command or CommandPalette.

Comment on lines +90 to +91
(e.metaKey || e.ctrlKey) &&
e.key === "k" &&
Copy link
Member

Choose a reason for hiding this comment

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

This hotkey combination should come from the API.

@ericholscher
Copy link
Member Author

This implementation copies a lot of the search code/UI which, unfortunately, is the least polished one. I mentioned in another comment that I'd like to see the Command Palette and Search UI combined, making these command items inside the same UI.

This is what I was asking for feedback on, was my discussion about this above: #449 (comment)

In particular, how does it make sense to combine things that are realtime lookups with search lookups that are delayed. I think that's going to be a much harder UX challenge.

I do think the Command Palette concept could be a pretty powerful thing to expose, and give us a bunch more functionality that we can add outside of the Flyout, but mostly for advanced users. I think if we shipped it, I would use it on our docs everyday tho, which I think is a pretty powerful vote for it being something powerful.

@humitos
Copy link
Member

humitos commented Dec 4, 2024

In particular, how does it make sense to combine things that are realtime lookups with search lookups that are delayed. I think that's going to be a much harder UX challenge.

We can show the results from commands immediately at the top, and below them in another section, the results that comes from the search API. Long search queries won't have any result from commands so that section won't be shown in those cases. We can distinct these sections/results visually somehow.

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