Escaping at a prompt should go up one level instead of exiting CLI #4
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ckreidl/katana#4
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@coderabbitai plan
Coding Plan
Summary
index.tswith a navigation loop that continuously presents mode selection until the user explicitly cancels at that levelDesign Choices
Design Choice 1: Should successful completion of a mode also return to menu?
Options Considered:
Chosen Option: 1
Rationale: Provides a more consistent user experience where the CLI acts as an interactive session rather than a one-shot tool, and aligns with the spirit of improved navigation.
💡 User Tips
Regenerate the plan with different choices with
@coderabbitai <feedback>.Implementation Steps
Phase 1: Establish Main Navigation Loop
This phase restructures the main execution flow to support returning to mode selection after any mode completes or is cancelled.
Task 1: Wrap Mode Execution in Navigation Loop
Restructure the main command handler to continuously loop through mode selection and execution until the user explicitly cancels at the mode selection prompt.
src/index.tsto wrap the mode execution logic (lines ~140-356) in awhile (true)loopresolveSettingsWithPrompts()call inside the loop so mode selection is re-presented after each mode completesresolveSettingsWithPrompts()returnsnull(user cancelled at mode selection), break the loop and exit cleanlyTask 2: Adjust Settings Flow Integration
Ensure the settings flow integrates cleanly with the new navigation loop.
src/ui/settingsFlow.tsto confirm its existing settings loop continues to work correctly within the outer navigation loopwhile (mode === "settings")loop should function as before, with the outer loop handling production modes🤖 Prompt for AI agents
Phase 2: Update Cancellation Handling in Mode Flows
This phase changes how cancellation is handled within each mode so that it returns control to the navigation loop rather than exiting the program.
Task 1: Update Purchase Orders Flow Cancellation
Modify the PO creation flow to gracefully return on cancellation instead of exiting.
src/index.ts, update the PO flow section (lines ~157-272) to handle cancellation by returning/continuing instead of exitingoutro("Cancelled.")calls within the PO flow since the navigation loop will handle the return to menupromptForSupplier()returningnulltriggers a return to the navigation loop, not program exitTask 2: Update Manufacturing Orders Flow Cancellation
Modify the MO creation flows (sales_orders and general modes) to return on cancellation.
src/index.ts, update the MO flow section (lines ~276-356) to handle cancellation by returning/continuingpromptForSalesOrders()returning empty/null triggers return to navigation looppromptForShortageVariants()cancellation returns to navigation looppromptForMoCreation()behavior so its early returns propagate back to the navigation loopTask 3: Clean Up Redundant Exit Messages
Remove cancellation messages that would now be redundant or confusing given the new navigation behavior.
src/ui/prompts.tsforoutro("Cancelled.")calls that occur at non-root levelslog.info("Returning to menu..."))outro("Cancelled.")message only for the mode selection cancellation inselectMode()(line 163)outro("Aborted.")messages (lines 637, 223) to indicate return to menu rather than program exit🤖 Prompt for AI agents
Phase 3: Preserve Critical Exit Points and Handle Edge Cases
This phase ensures that certain critical paths still exit appropriately and handles edge cases in the navigation flow.
Task 1: Preserve API Key Authentication Exit Behavior
Maintain the current exit behavior for API key resolution since this occurs before any navigation context exists.
process.exit(1)call inresolveApiKey()(line 132 in prompts.ts) unchangedsrc/index.ts(line 120)Task 2: Verify Pagination Behavior
Ensure the existing pagination logic in
pagedMultiSelect()works correctly within the new navigation structure.pagedMultiSelect()insrc/ui/prompts.ts(lines 25-87)Task 3: Update Completion Messaging
Add appropriate messaging when returning to mode selection after a completed or cancelled operation.
@clack/promptslog utilities for consistent stylingTask 4: Handle Non-Interactive Mode
Ensure non-interactive mode (when CLI args specify mode directly) still behaves correctly.
🤖 Prompt for AI agents
Research
The katana-mo-cli is a Manufacturing Order/Purchase Order creation tool built with
gunshifor CLI argument parsing and@clack/promptsfor interactive prompts. The current navigation is linear and forward-only: mode selection → data fetching → mode-specific prompts → exit. Cancellation (viaisCancel()) is handled at 21 locations acrossprompts.tsandindex.ts, with most returningnullwhich propagates up and causes program exit. There is no navigation stack or state machine—the settings menu is the only flow that loops back to mode selection via awhileloop insettingsFlow.ts. Data fetching happens after mode selection and is not cached.🚀 Next Steps
🤖 All AI agent prompts combined
💡 Iterate on the plan with:
@coderabbitai <feedback>💬 Have feedback or questions? Drop into our discord!