Skip to content

feat: add search functionality to help menu#334

Merged
idursun merged 14 commits intoidursun:mainfrom
baggiiiie:help-search
Oct 17, 2025
Merged

feat: add search functionality to help menu#334
idursun merged 14 commits intoidursun:mainfrom
baggiiiie:help-search

Conversation

@baggiiiie
Copy link
Copy Markdown
Collaborator

@baggiiiie baggiiiie commented Oct 11, 2025

summary

Add search/filter support for help page

see issue #329

feature

  • added search and filtering logic to the help page

    • if a h.keyMap.*.Mode matches the user’s search, the whole group of help menu entries under that mode is displayed
    • if an individual entry matches, that entry and its associated h.keyMap.*.Mode are shown
    • basically: you can now search by mode or by any specific entry keyword
  • implemented search bar input with charmbracelet/bubbles/textinput

  • introduced new struct types to organize help content

    • helpItem: represents an individual help entry
      • has display (what’s shown to user) and searchTerm (used internally for filtering)
      • searchTerm combines keybind, name, and description so you can match across multiple fields
    • itemGroup: groups related helpItems under the same mode
      • e.g. everything under Rebase mode goes into the itemGroup for rebase
      • first entry of the group is treated as the header
  • extended the main tea Model with:

    • defaultMenu – the full help menu
    • filteredMenu – current filtered state based on search
    • searchQuery – user’s input string

fixes

  • fixed wrong description for the revert key (was marked as “rebase”) — this was messing up search results. now correctly labeled as revert.

refactors

  • moved help menu rendering logic into a separate file for better structure and readability

others / notes

  • tried using charmbracelet/bubbles/list for the menu layout; didn’t work out since the menu uses 3 columns
  • current search logic is exact match only; no fuzzy find yet; plan to add fuzzy matching later
  • possible future UI polish: dimming + highlighting for search feedback
    • unmatched itemGroups could be dimmed
    • matched ones stay normal color
    • matched characters within items could be highlighted, similar to fzf

preview of help menu with search

image image image image

@idursun
Copy link
Copy Markdown
Owner

idursun commented Oct 11, 2025

Hey @baggiiiie thanks for working on this.

I have a couple of suggestions:

  • Feel free to refactor the help page.
  • I'd recommend it to be in search mode from the get go. User opens help and starts typing to filter it down, or presses esc to close it. I don't think there's need to press / to filter it down as the initial view is not scrollable anyway.
  • I'd also like to see the mode names next to the bindings if I filter it down, because as you can see in the screenshot, I see a bunch of diff bindings but have no way to tell in which mode they can be used.
image

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?

@baggiiiie
Copy link
Copy Markdown
Collaborator Author

hey @idursun , thanks for the feedback, im working on a newer version of help menu with search, will push my changes soon for review!

@baggiiiie
Copy link
Copy Markdown
Collaborator Author

hey @idursun i have pushed some changes and updated PR description.
sorry for the big PR, i've documented as clearly and concisely as possible, together with git commit history. lemme know if there's anything else i could help to make this review easier!

return h, nil
}

func (h *Model) printKeyBinding(k key.Binding) string {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

moved to internal/ui/helppage/help_item_groups.go

func (h *Model) View() string {
var left []string
left = append(left,
h.printTitle("UI"),
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

moved to internal/ui/helppage/help_item_groups.go

}
}

func (h *Model) renderColumn(width int, height int, lines ...string) string {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

rendering logic moved to internal/ui/helppage/help_menu_render.go

Copy link
Copy Markdown
Owner

@idursun idursun left a comment

Choose a reason for hiding this comment

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

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")),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks!

Comment on lines 75 to 77
func (h *Model) Init() tea.Cmd {
return nil
return textinput.Blink
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

oh shoot, thanks for catching this!

@idursun idursun merged commit 087dd7c into idursun:main Oct 17, 2025
3 checks passed
@baggiiiie baggiiiie deleted the help-search branch October 18, 2025 17:31
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Oct 22, 2025
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. [#&#8203;334](idursun/jjui#334)
- changed **preview** to run in the background while getting the diff contents to improve UI responsiveness. [#&#8203;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.  [#&#8203;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. [#&#8203;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. [#&#8203;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` [#&#8203;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 [@&#8203;baggiiiie](https://github.com/baggiiiie) in [#&#8203;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=-->
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