Skip to content

fix(ui): change shuffle hotkey to "ctrl+t"#99

Closed
mdhowle wants to merge 1 commit intoshinokada:mainfrom
mdhowle:fix-lucky-t-key
Closed

fix(ui): change shuffle hotkey to "ctrl+t"#99
mdhowle wants to merge 1 commit intoshinokada:mainfrom
mdhowle:fix-lucky-t-key

Conversation

@mdhowle
Copy link
Contributor

@mdhowle mdhowle commented Feb 25, 2026

Closes #97

📑 Description

This change modifies the Shuffle mode toggle hot key in the I Feel Lucky menu from t to ctrl+t. This allows the user to type any value in the Genre/keyword field without triggering the Shuffle mode toggle when it begins with a t.

The alternative is to make Shuffle mode a selectable text input that toggles the off and on when the user presses space/enter/etc. This would require more changes to allow navigating up and down the two input fields and through the list of Recent Searches. Currently, up and down is exclusively for the Recent Searches.

However, this change is the fast and minimal amount of changes. The hotkey can be changed, preferably a ctrl, meta, or alt key combination to avoid erroneously toggling.

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

ℹ Additional Information

Summary by CodeRabbit

  • Documentation

    • Updated keyboard shortcut documentation for shuffle mode throughout README files, changing the referenced shortcut from 't' to 'ctrl+t'
  • Updates

    • Modified shuffle mode toggle keyboard shortcut from 't' to 'ctrl+t' with corresponding input handling updated to support the new keybinding

@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2026

📝 Walkthrough

Walkthrough

The keyboard shortcut for toggling shuffle mode in the "I Feel Lucky" menu is changed from 't' to 'ctrl+t' across documentation, UI logic, and tests. This addresses a bug preventing users from typing text starting with 't' in the genre/keyword field.

Changes

Cohort / File(s) Summary
Documentation Updates
README.md, docs/README.md
Updated keyboard shortcut references from "Press t" to "Press ctrl+t" for toggling shuffle mode in two locations.
UI Logic
internal/ui/lucky.go
Rebind shuffle toggle from single 't' key to 'ctrl+t' key; removes previous dependency on empty text input. UI hint text updated to reflect new keybinding.
Test Updates
internal/ui/lucky_test.go
Updated shuffle toggle test cases to use 'ctrl+t' instead of 't'. Added assertion to verify text input is cleared when enabling shuffle.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A rabbit hops with glee,
No more 't' blocks the way,
Ctrl+t sets shuffle free,
Type your tags without delay! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(ui): change shuffle hotkey to "ctrl+t"' directly and clearly describes the main change - rebinding the shuffle toggle from 't' to 'ctrl+t' in the UI.
Linked Issues check ✅ Passed The PR successfully addresses issue #97 by rebinding the shuffle toggle hotkey from 't' to 'ctrl+t', allowing users to type words beginning with 't' in the Genre/keyword field without triggering the toggle.
Out of Scope Changes check ✅ Passed All changes are scoped to the shuffle hotkey rebinding: updates to README/docs, UI code changes in lucky.go, and corresponding test updates in lucky_test.go. No unrelated modifications were introduced.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
docs/README.md (1)

536-570: ⚠️ Potential issue | 🟡 Minor

Shuffle shortcut table still lists t instead of ctrl+t.

The updated steps now say ctrl+t, but the shortcut table row remains outdated, which is confusing.

Suggested patch
-| `t`   | Toggle shuffle mode (in input screen) |
+| `ctrl+t` | Toggle shuffle mode (in input screen) |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/README.md` around lines 536 - 570, The "Shuffle Keyboard Shortcuts"
table is inconsistent with the usage instructions: update the Key cell for the
shuffle toggle from `t` to `ctrl+t` so it matches the steps that say "Press
`ctrl+t` to toggle shuffle mode"; ensure the Action cell still reads "Toggle
shuffle mode (in input screen)" and verify any other references to the `t`
shortcut in the README (e.g., the "Shuffle Keyboard Shortcuts" heading or nearby
descriptions) are changed to `ctrl+t` for consistency.
README.md (1)

536-570: ⚠️ Potential issue | 🟡 Minor

Shortcut reference is inconsistent: table still shows t for shuffle toggle.

Please update the Shuffle Keyboard Shortcuts table to match the new ctrl+t binding.

Suggested patch
-| `t`   | Toggle shuffle mode (in input screen) |
+| `ctrl+t` | Toggle shuffle mode (in input screen) |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` around lines 536 - 570, Update the "Shuffle Keyboard Shortcuts"
table in README.md so the shuffle toggle row reflects the new binding: replace
the `t` entry with `ctrl+t` (keep the Action text "Toggle shuffle mode (in input
screen)" unchanged) and ensure any other mentions of `t` for toggling shuffle in
that section are updated to `ctrl+t`.
internal/ui/lucky.go (1)

1021-1061: ⚠️ Potential issue | 🟡 Minor

Bottom help text is stale and still says t instead of ctrl+t.

Line 1060 currently advertises t: Toggle shuffle, which conflicts with Line 451 behavior and the updated inline hints.

Suggested patch
-	helpText := "↑↓/jk: Navigate • Enter: Search • t: Toggle shuffle"
+	helpText := "↑↓/jk: Navigate • Enter: Search • ctrl+t: Toggle shuffle"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/ui/lucky.go` around lines 1021 - 1061, The bottom helpText string
currently says "t: Toggle shuffle" but the UI uses ctrl+t to toggle shuffle (see
use of m.shuffleEnabled and inline hints showing "ctrl+t"); update the helpText
variable to advertise "ctrl+t: Toggle shuffle" (or "ctrl+t/ctrl+T" as desired)
so it matches the actual toggle behavior and the inline hints rendered for
m.shuffleEnabled and the shuffle toggle handler.
🧹 Nitpick comments (1)
internal/ui/lucky_test.go (1)

565-597: Add a regression test for the original bug path ("trance" should type normally).

Current test covers toggling, but it doesn’t assert that typing a leading t no longer toggles shuffle while entering text.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/ui/lucky_test.go` around lines 565 - 597, Update the
TestLuckyShuffleToggle to include a regression check that typing a leading "t"
(e.g., sending a tea.KeyMsg for rune 't') inserts the character into
model.textInput instead of toggling shuffle; after creating NewLuckyModel and
setting model.state = luckyStateInput, send a rune KeyMsg for 't', call
model.Update (or luckyModel.Update) and assert that shuffleEnabled remains
unchanged and textInput.Value() becomes "t" (and similarly verify typing
"trance" produces "trance"), referencing TestLuckyShuffleToggle, LuckyModel,
Update, shuffleEnabled, textInput and luckyStateInput to locate the logic to
test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/ui/lucky_test.go`:
- Line 577: Replace the synthetic rune-based key messages with proper control
key events: change constructions like tea.KeyMsg{Type: tea.KeyRunes, Runes:
[]rune("ctrl+t")} (and the other occurrence at the second spot) to use the
Bubble Tea control key constant tea.KeyCtrlT by creating tea.KeyMsg{Type:
tea.KeyCtrlT}; update both instances in the test (the variable msg assignments)
so the test sends a real Ctrl+T key event instead of rune characters.

---

Outside diff comments:
In `@docs/README.md`:
- Around line 536-570: The "Shuffle Keyboard Shortcuts" table is inconsistent
with the usage instructions: update the Key cell for the shuffle toggle from `t`
to `ctrl+t` so it matches the steps that say "Press `ctrl+t` to toggle shuffle
mode"; ensure the Action cell still reads "Toggle shuffle mode (in input
screen)" and verify any other references to the `t` shortcut in the README
(e.g., the "Shuffle Keyboard Shortcuts" heading or nearby descriptions) are
changed to `ctrl+t` for consistency.

In `@internal/ui/lucky.go`:
- Around line 1021-1061: The bottom helpText string currently says "t: Toggle
shuffle" but the UI uses ctrl+t to toggle shuffle (see use of m.shuffleEnabled
and inline hints showing "ctrl+t"); update the helpText variable to advertise
"ctrl+t: Toggle shuffle" (or "ctrl+t/ctrl+T" as desired) so it matches the
actual toggle behavior and the inline hints rendered for m.shuffleEnabled and
the shuffle toggle handler.

In `@README.md`:
- Around line 536-570: Update the "Shuffle Keyboard Shortcuts" table in
README.md so the shuffle toggle row reflects the new binding: replace the `t`
entry with `ctrl+t` (keep the Action text "Toggle shuffle mode (in input
screen)" unchanged) and ensure any other mentions of `t` for toggling shuffle in
that section are updated to `ctrl+t`.

---

Nitpick comments:
In `@internal/ui/lucky_test.go`:
- Around line 565-597: Update the TestLuckyShuffleToggle to include a regression
check that typing a leading "t" (e.g., sending a tea.KeyMsg for rune 't')
inserts the character into model.textInput instead of toggling shuffle; after
creating NewLuckyModel and setting model.state = luckyStateInput, send a rune
KeyMsg for 't', call model.Update (or luckyModel.Update) and assert that
shuffleEnabled remains unchanged and textInput.Value() becomes "t" (and
similarly verify typing "trance" produces "trance"), referencing
TestLuckyShuffleToggle, LuckyModel, Update, shuffleEnabled, textInput and
luckyStateInput to locate the logic to test.

ℹ️ Review info

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3bbce2 and d95a963.

📒 Files selected for processing (4)
  • README.md
  • docs/README.md
  • internal/ui/lucky.go
  • internal/ui/lucky_test.go


// Toggle shuffle on
msg := tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("t")}
msg := tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("ctrl+t")}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cat -n internal/ui/lucky_test.go | sed -n '570,600p'

Repository: shinokada/tera

Length of output: 1118


🏁 Script executed:

rg -n 'tea\.Key' internal/ui/lucky_test.go | head -20

Repository: shinokada/tera

Length of output: 977


🏁 Script executed:

rg -n 'tea\.KeyCtrlT|tea\.KeyRunes' internal/ -t go

Repository: shinokada/tera

Length of output: 3740


🏁 Script executed:

rg -i 'keyctrl' internal/ -t go

Repository: shinokada/tera

Length of output: 40


🌐 Web query:

Bubble Tea tea.Key control key types tea.KeyCtrlT API

💡 Result:

In Bubble Tea (tea), control keys are represented by tea.KeyType constants. tea.KeyCtrlT is the key type for Ctrl+T (it’s an alias of the control code keyDC4). [1]

To handle it, match on tea.KeyMsg in Update:

case tea.KeyMsg:
    switch {
    case msg.Type == tea.KeyCtrlT:
        // Ctrl+T pressed
    // or:
    case msg.String() == "ctrl+t":
        // Ctrl+T pressed
    }

msg.String() is "ctrl+t" for that key. [2]

Sources: [1] [2]


Replace tea.KeyRunes with tea.KeyCtrlT for control key events in tests.

tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("ctrl+t")} creates synthetic rune characters instead of a Ctrl+T key event. Use tea.KeyMsg{Type: tea.KeyCtrlT} to properly represent control key presses in Bubble Tea.

Suggested patch
-	msg := tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("ctrl+t")}
+	msg := tea.KeyMsg{Type: tea.KeyCtrlT}

Also applies to: 590-590

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/ui/lucky_test.go` at line 577, Replace the synthetic rune-based key
messages with proper control key events: change constructions like
tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("ctrl+t")} (and the other
occurrence at the second spot) to use the Bubble Tea control key constant
tea.KeyCtrlT by creating tea.KeyMsg{Type: tea.KeyCtrlT}; update both instances
in the test (the variable msg assignments) so the test sends a real Ctrl+T key
event instead of rune characters.

@mdhowle
Copy link
Contributor Author

mdhowle commented Feb 26, 2026

I just found another issue. Entering any number for the Genre/keyword, for example 90s, will be entered for the Choose an option field instead.

I'm not sure how to get around that without some redesigning.

shinokada added a commit that referenced this pull request Feb 26, 2026
@shinokada shinokada mentioned this pull request Feb 26, 2026
4 tasks
shinokada added a commit that referenced this pull request Feb 26, 2026
fix: #99

* **Documentation**
  * Updated shuffle shortcut from `t` to `Ctrl+T` across guides and help text.
* **User Interface**
  * In-app hints and messages now reference `Ctrl+T` for toggling shuffle.
* **Bug Fixes**
  * Number-key entry now only accumulates when not typing into the text input, improving input behavior.
* **Tests**
  * Updated and added tests to validate `Ctrl+T` behavior and non-toggle-while-typing cases.
* **Chores**
  * Build task now runs tests before compiling.
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.

[Bug]: Unable to enter a tag that begins with "t" while in "I Feel Lucky" menu

1 participant