Remember cursor position in prompts #462
No reviewers
Labels
No labels
breaking change
duplicate
good first issue
help wanted
invalid
question
scope: card
scope: docs
scope: game
scope: registry
scope: script
scope: tool
scope: universe
tracker
type: bug
type: card request
type: documentation
type: enhancement
type: improvement
type: parity
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
LunarTides/Hearthstone.js!462
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "cursor"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Not implemented for the class creator / packager
Closes #461
Summary by CodeRabbit
New Features
Improvements
Chores
✏️ Tip: You can customize this high-level summary in your review settings.
📝 Walkthrough
Walkthrough
Migrates interactive menus from inquirer
selecttogame.prompt.customSelectacross hub and tooling, adds persistent cursor state (selectValues) to retain selections, updates developer-mode options, and bumps@inquirer/promptsto ^8.2.0.Changes
src/functions/interact.tsselectValuesstate to persist cursor positions; extendedgame.prompt.customSelectoptions withresetCursor?: booleananddefault?: unknown; updated default/reset and post-selection storage logic.hub.tsselectusage withgame.prompt.customSelect; mapped option handling to label-based results; expanded developer mode with “Start Packager”, “Test Cards”, “Crash Test”, “Generate Vanilla Cards”; removed old select import.tools/cardcreator/class.tsselecttocustomSelect; removed explicitSeparatorusage and reworked choice handling to label/default mapping.tools/deckcreator.tssearchPromptandlastPickedOptionto preserve prior search/selection across prompts; wired defaults into selection flow.tools/packager.tscustomSelect; renamed some prompts ("Choose a Pack" → “Import a Pack” / “Export a Pack”); added menu states (Refresh/New/Done) and updated license handling with default/other flow.package.json@inquirer/promptsfrom^8.0.2to^8.2.0.Sequence Diagram(s)
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
game.prompt.customSelectand toucheshub.ts,interact.ts, and related prompt flows.Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
#461.✅ Passed checks (3 passed)
#461by introducing cursor position tracking via the selectValues mechanism in interact.ts and applying it throughout the modified prompts.✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
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 helpto get the list of available commands and usage tips.Actionable comments posted: 2
🤖 Fix all issues with AI agents
⚠️ Potential issue | 🟡 Minor
🧩 Analysis chain
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 968
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 1655
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 369
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 1330
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 326
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 225
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 271
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 286
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 656
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 833
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 1733
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 380
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 256
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 1600
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 294
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 435
Store choice values, not choice objects, for cursor restoration.
When Back/Done/Cancel is selected,
selectValues[message]is set tochoices[0]which may be aSeparatorobject with novalueproperty. That stored value is later passed asdefaulttoselect(), butselect()expects a string value matching one of the choice values. A Separator won't match and cursor restoration fails. Extract and store only the first selectable choice's value, and validate defaults against available choice values.🛠️ Proposed fix
🤖 Prompt for AI Agents
@ -501,46 +502,56 @@ async function configureMetadata(metadata: Metadata) {⚠️ Potential issue | 🟡 Minor
🧩 Analysis chain
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 124
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 1757
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 90
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 1943
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 1193
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 244
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 378
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 253
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 709
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 1627
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 696
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 126
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 106
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 1600
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 96
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 1430
Map custom license values to "other" option when reopening packs.
When a user selects "other" and enters a custom license, that value is stored in
metadata.license. If the pack is reopened and the license menu is accessed again, the custom string is passed asdefaulttocustomSelect. Since it won't match any predefined option, this creates an invalid default selection. Map unknown values to"other"before callingcustomSelectso custom licenses default to the appropriate choice.🛠️ Proposed fix
🤖 Prompt for AI Agents
✅ Addressed in commit
caae3b4