feat: add search functionality to help menu#334
Conversation
|
Hey @baggiiiie thanks for working on this. I have a couple of suggestions:
I'd probably try setting the entries to always belong to a mode/group by using something like this: h.modeEntry(h.keyMap.Rebase.Mode, "Rebase"),
h.keyMap.Rebase.Revision,
h.keyMap.Rebase.Source,
h.keyMap.Rebase.Branch,
h.keyMap.Rebase.Before,
h.keyMap.Rebase.After,
h.keyMap.Rebase.Onto,
h.keyMap.Rebase.Insert,
)so that the each group/mode would filter down their own children. What do you think? |
|
hey @idursun , thanks for the feedback, im working on a newer version of help menu with search, will push my changes soon for review! |
02a8cd5 to
d8d1ccf
Compare
|
hey @idursun i have pushed some changes and updated PR description. |
| return h, nil | ||
| } | ||
|
|
||
| func (h *Model) printKeyBinding(k key.Binding) string { |
There was a problem hiding this comment.
moved to internal/ui/helppage/help_item_groups.go
| func (h *Model) View() string { | ||
| var left []string | ||
| left = append(left, | ||
| h.printTitle("UI"), |
There was a problem hiding this comment.
moved to internal/ui/helppage/help_item_groups.go
| } | ||
| } | ||
|
|
||
| func (h *Model) renderColumn(width int, height int, lines ...string) string { |
There was a problem hiding this comment.
rendering logic moved to internal/ui/helppage/help_menu_render.go
idursun
left a comment
There was a problem hiding this comment.
Beautiful work! Thank you very much.
There's one comment about the use of the Blink command, which I will fix it myself after merging this.
| ExecShell: key.NewBinding(key.WithKeys(m.ExecShell...), key.WithHelp(JoinKeys(m.ExecShell), "interactive shell command")), | ||
| Revert: revertModeKeys[key.Binding]{ | ||
| Mode: key.NewBinding(key.WithKeys(m.Revert.Mode...), key.WithHelp(JoinKeys(m.Revert.Mode), "rebase")), | ||
| Mode: key.NewBinding(key.WithKeys(m.Revert.Mode...), key.WithHelp(JoinKeys(m.Revert.Mode), "revert")), |
| func (h *Model) Init() tea.Cmd { | ||
| return nil | ||
| return textinput.Blink | ||
| } |
There was a problem hiding this comment.
So, even though this makes sense, this is problematic because of how bubbletea simulates a visual cursor.
This will send a BlinkMsg at every blink interval, which is fine when help window is showing. However, it will keep sending it even when the help page is closed which will make jjui rerender unnecessarily. This only happens if the model is using a pointer receiver as it is the case here.
There's no way you would know this. I have sunk too many hours debugging similar issues in the past eventually gave up and don't use Blink anymore.
There was a problem hiding this comment.
oh shoot, thanks for catching this!
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [idursun/jjui](https://github.com/idursun/jjui) | patch | `v0.9.4` -> `v0.9.5` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>idursun/jjui (idursun/jjui)</summary> ### [`v0.9.5`](https://github.com/idursun/jjui/releases/tag/v0.9.5) [Compare Source](idursun/jjui@v0.9.4...v0.9.5) This release contains some minor improvements and bug fixes. - Help window is now searchable. [#​334](idursun/jjui#334) - changed **preview** to run in the background while getting the diff contents to improve UI responsiveness. [#​336](idursun/jjui#336) - fix: async command executor used to append `--color always` to the end of the command to get colourful output but this broke some commands that expect arguments. This change moves the `--color always` to the beginning of the command. [#​339](idursun/jjui#339) - Added `pgup` and `pgdown` bindings to the revisions view so that you can jump down/up without having to press `j`/`k` multiple times. [#​347](idursun/jjui#347) - improved handling of bookmarks that contain `--` characters in their name. `jj` returns these bookmarks with quotes which `jjui` didn't handle well. [#​346](idursun/jjui#346) - `JJUI_CONFIG_DIR` is changed to match the documentation where it will load the configuration from `$JJUI_CONFIG_DIR/config.toml` rather than `$JJUI_CONFIG_DIR/jjui/config.toml` [#​343](idursun/jjui#343) - **ace jump** didn't highlight change ids in some template configuration. It should highlight change ids and commit ids correctly now. #### What's Changed - feat: add search functionality to help menu by [@​baggiiiie](https://github.com/baggiiiie) in [#​334](idursun/jjui#334) **Full Changelog**: <idursun/jjui@v0.9.4...v0.9.5> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNTIuOSIsInVwZGF0ZWRJblZlciI6IjQxLjE1Mi45IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->

summary
Add search/filter support for help page
see issue #329
feature
added search and filtering logic to the help page
h.keyMap.*.Modematches the user’s search, the whole group of help menu entries under that mode is displayedh.keyMap.*.Modeare shownimplemented search bar input with
charmbracelet/bubbles/textinputintroduced new struct types to organize help content
helpItem: represents an individual help entrydisplay(what’s shown to user) andsearchTerm(used internally for filtering)searchTermcombines keybind, name, and description so you can match across multiple fieldsitemGroup: groups relatedhelpItems under the same modeitemGroupfor rebaseextended the main tea
Modelwith:defaultMenu– the full help menufilteredMenu– current filtered state based on searchsearchQuery– user’s input stringfixes
revertkey (was marked as “rebase”) — this was messing up search results. now correctly labeled asrevert.refactors
others / notes
charmbracelet/bubbles/listfor the menu layout; didn’t work out since the menu uses 3 columnsitemGroups could be dimmedfzfpreview of help menu with search