Improve interactive mode autocompletion - #658
Conversation
WalkthroughThe changes add two new completer classes to provide context-sensitive command-line completions in the interactive prompt, merge them with existing completers, switch input history to persistent file-based storage, and isolate certain prompts from polluting the main history. Imports are updated to support these features. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant PromptSession
participant Completers
participant FileHistory
User->>PromptSession: Start interactive prompt
PromptSession->>Completers: Request completions (context-sensitive)
Completers->>PromptSession: Return merged completions
User->>PromptSession: Enter command
PromptSession->>FileHistory: Save command to ~/.holmes/history
User->>PromptSession: Trigger special prompt (e.g., Y/N)
PromptSession->>PromptSession: Use temporary session with in-memory history
Estimated code review effort2 (~20 minutes) Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
✨ 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
holmes/interactive.py (1)
727-739: Excellent enhancement to completion and history persistence.The merged completer design properly combines all three completion types, and the switch to
FileHistoryprovides valuable persistence. The directory creation logic is correct.Consider adding error handling around the
FileHistorycreation in case of permission issues:- history_file = os.path.expanduser("~/.holmes/history") - os.makedirs(os.path.dirname(history_file), exist_ok=True) - history = FileHistory(history_file) + try: + history_file = os.path.expanduser("~/.holmes/history") + os.makedirs(os.path.dirname(history_file), exist_ok=True) + history = FileHistory(history_file) + except (OSError, PermissionError) as e: + console.print(f"[bold {ERROR_COLOR}]Warning: Could not create persistent history: {e}[/bold {ERROR_COLOR}]") + history = InMemoryHistory()
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
holmes/interactive.py(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Pre-commit checks
- GitHub Check: llm_evals
- GitHub Check: Pre-commit checks
🔇 Additional comments (4)
holmes/interactive.py (4)
5-5: LGTM! Import changes support new completion features.The import additions and reorganization are necessary for the new completion functionality and follow Python best practices.
Also applies to: 9-9, 14-17
77-104: Well-implemented path completer for relative paths.The
SmartPathCompletercorrectly handles relative path completion by delegating toPathCompleterand properly adjusting the start position. The logic for detecting relative paths is sound.
106-140: Excellent implementation of conditional executable completion.The
ConditionalExecutableCompletercorrectly restricts executable completion to/runcommands and only for the first word. The duplicate filtering and position calculations are well-implemented.
484-485: Good improvement to isolate prompts from main history.Using a temporary
PromptSessionwithInMemoryHistoryfor Y/N and comment prompts prevents these interactions from polluting the main command history, improving the user experience.Also applies to: 487-487, 492-492
No description provided.