Skip to content

feat: Implement UI improvements and persistent configuration#59

Merged
talltechy merged 6 commits intomainfrom
feature/issue-58-ui-improvements
Oct 7, 2025
Merged

feat: Implement UI improvements and persistent configuration#59
talltechy merged 6 commits intomainfrom
feature/issue-58-ui-improvements

Conversation

@talltechy
Copy link
Copy Markdown
Owner

Summary

Implements comprehensive UI improvements with persistent configuration system for InsightVM-Python tools.

Closes #58

Changes

New Components

  1. Configuration System (src/rapid7/config.py)

    • Persistent storage in ~/.insightvm/config.json
    • Tool-specific defaults and last-used values
    • User preferences management
    • State management for resumable operations
  2. UI Framework (src/rapid7/ui.py)

    • Colored output (success/error/warning/info)
    • Progress bars for long operations
    • Interactive menus with navigation
    • Confirmation prompts
    • Formatted tables
    • Graceful fallback without rich library

Enhanced Tools

  1. create_sonar_queries.py
    • Interactive mode (runs when no arguments provided)
    • Remembers last CSV path and settings
    • Preview and confirmation before execution
    • Colored feedback during processing
    • Settings persist across runs
    • CLI mode compatibility maintained

Dependencies

  1. requirements.txt
    • Added pandas>=2.0.0 for CSV processing
    • Added rich>=13.0.0 for enhanced UI (optional)

Documentation

  1. docs/UI_IMPROVEMENTS.md
    • Complete usage guide
    • Code examples
    • Migration guide for developers
    • Troubleshooting section

Benefits

  • ✅ Reduced repetition (remembered settings)
  • ✅ Better user experience (colored output, confirmations)
  • ✅ Safer operations (preview and confirm)
  • ✅ Consistent patterns across tools
  • ✅ Extensible framework for future tools

Testing

  • Interactive mode tested manually
  • CLI mode compatibility verified
  • Fallback tested without rich library
  • Configuration persistence verified
  • All commits follow conventional format

Commits

  1. feat(config): add persistent configuration system - Core config management
  2. feat(ui): add interactive UI framework with colored output - UI utilities
  3. feat(tools): add interactive mode to create_sonar_queries - Enhanced tool
  4. chore(deps): add pandas and rich dependencies - Dependencies
  5. docs: add comprehensive UI improvements documentation - Documentation

Related

  • Follows v2.0 architecture patterns
  • Integrates with existing client system
  • Ready for other tools to adopt same patterns

Screenshots

Interactive mode provides colored output and confirmation prompts

Next Steps

After merge:

  • Update Memory Bank with completed work
  • Consider enhancing install_insight_agent.py
  • Consider enhancing install_scan_assistant.py
  • Future: SQLite history tracking

Implements comprehensive configuration management with:
- Persistent storage in ~/.insightvm/config.json
- Tool-specific defaults and last-used values
- User preferences (colors, confirmations, progress)
- State management for resumable operations
- Dot-notation access pattern

Relates to #58
Implements rich UI utilities with graceful fallback:
- Colored output (success/error/warning/info)
- Progress bars for long operations
- Interactive menus with navigation
- Confirmation prompts with defaults
- Formatted tables
- Headers and separators
- Fallback support when rich library unavailable

Relates to #58
Enhances sonar query tool with interactive mode:
- Runs interactive when no arguments provided
- Remembers last CSV path and settings
- Preview and confirmation before execution
- Colored feedback during processing
- Persistent configuration storage
- Maintains backward compatibility with CLI mode

Relates to #58
Updates requirements.txt with:
- pandas>=2.0.0 for CSV data processing
- rich>=13.0.0 for enhanced UI (optional)

Rich library provides colored output, progress bars, and
interactive menus with graceful fallback when unavailable.

Relates to #58
Adds detailed documentation covering:
- Configuration system usage and structure
- UI framework features and examples
- Enhanced tool capabilities
- Migration guide for developers
- Troubleshooting section
- Future enhancement roadmap

Complete with code examples, usage patterns, and
integration instructions for extending to other tools.

Relates to #58
Copilot AI review requested due to automatic review settings October 7, 2025 20:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Introduces a persistent configuration system and a reusable UI utility layer to enhance interactivity, statefulness, and user experience across InsightVM tools, with an updated create_sonar_queries tool gaining an interactive mode.

  • Added persistent JSON-backed configuration (user preferences, last-used values, tool settings)
  • Added UI framework (colored output, prompts, menus, progress, tables) with graceful fallback
  • Enhanced create_sonar_queries.py with interactive mode and config/UI integration

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.

File Description
src/rapid7/config.py New persistent configuration manager with preferences, tool sections, and state handling
src/rapid7/ui.py New UI abstraction (printing, menus, prompts, progress bars, tables)
src/rapid7/tools/create_sonar_queries.py Added interactive mode, config integration, optional UI output
docs/UI_IMPROVEMENTS.md Documentation of new UI/config systems and usage patterns

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/rapid7/ui.py
Comment on lines +296 to +329
def progress_bar(
self,
description: str,
total: Optional[int] = None
):
"""
Create a progress bar context manager.

Args:
description: Progress description
total: Total steps (None for indeterminate)

Returns:
Progress context manager

Example:
>>> ui = UI()
>>> with ui.progress_bar("Processing", 100) as progress:
... for i in range(100):
... progress.update(1)
... # do work
"""
if RICH_AVAILABLE and self.config.get_preference(
'show_progress_bars',
True
):
return Progress(
SpinnerColumn(),
TextColumn("[progress.description]{task.description}"),
transient=True,
)
else:
# Simple fallback progress indicator
return SimpleProgressBar(description, total, self)
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

When rich is available this returns a raw Progress instance without creating a task; the documented example calls progress.update(1) which will raise a TypeError because Progress.update() requires a task_id. The total and description arguments are also unused in the rich branch. Wrap the Progress in a lightweight adapter that creates a task and exposes an update(advance: int) method (to match SimpleProgressBar), or return a context manager that yields such an adapter.

Copilot uses AI. Check for mistakes.
Comment on lines +259 to +268
if last_output:
output_file = ui.prompt(
"Output CSV file path",
default=default_output
)
else:
output_file = ui.prompt(
"Output CSV file path",
default=default_output
)
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

The logic retrieves last_output but never uses it as the default; both branches are identical and always default to the derived path, so previously saved output path is ignored (contradicts documented persistence). Use last_output as the default when present, and remove the duplicated conditional.

Suggested change
if last_output:
output_file = ui.prompt(
"Output CSV file path",
default=default_output
)
else:
output_file = ui.prompt(
"Output CSV file path",
default=default_output
)
output_file = ui.prompt(
"Output CSV file path",
default=last_output if last_output else default_output
)

Copilot uses AI. Check for mistakes.
Comment on lines +156 to +159
if ui:
print(f"\nProcessing: {target}")
else:
print(f"\nProcessing: {target}")
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Duplicate branches with identical print; this can be simplified. Prefer using ui.print_info or a single unconditional print to reduce noise.

Suggested change
if ui:
print(f"\nProcessing: {target}")
else:
print(f"\nProcessing: {target}")
print(f"\nProcessing: {target}")

Copilot uses AI. Check for mistakes.
Comment thread src/rapid7/config.py
Comment on lines +86 to +89
'insight_agent': {
'last_installer_path': '',
'last_token': '' # Note: Should be encrypted in production
},
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Storing tokens in plaintext on disk introduces credential exposure risk. Use a secure storage mechanism (e.g. keyring, OS credential store, or encrypt with a master key) or omit sensitive secrets from the persisted config.

Copilot uses AI. Check for mistakes.
Comment thread docs/UI_IMPROVEMENTS.md
Comment on lines +124 to +127
with ui.progress_bar("Processing items", total=100) as progress:
for i in range(100):
# Do work
progress.update(1)
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Example implies progress.update(1) works with both rich and fallback implementations, but the current rich-based progress_bar returns a raw Progress object which requires a task_id when calling update. Update the example after fixing the implementation to avoid misleading users.

Suggested change
with ui.progress_bar("Processing items", total=100) as progress:
for i in range(100):
# Do work
progress.update(1)
with ui.progress_bar("Processing items", total=100) as (progress, task_id):
for i in range(100):
# Do work
progress.update(task_id, advance=1)

Copilot uses AI. Check for mistakes.
… with UI framework

Added interactive UI features to installation tools:
- install_insight_agent.py: Interactive installer discovery, token management,
  progress feedback, and configuration persistence
- install_scan_assistant.py: Interactive package download, checksum verification,
  certificate management, and configuration persistence

Both tools now support:
- CLI mode for automation
- Interactive mode with colored output
- Configuration persistence for repeated use
- Better error handling and user feedback
- Graceful fallback when rich library unavailable

Relates to #58
Copy link
Copy Markdown
Contributor

@github-advanced-security github-advanced-security AI left a comment

Choose a reason for hiding this comment

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

Bandit found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@talltechy talltechy merged commit cc0d527 into main Oct 7, 2025
9 of 13 checks passed
@talltechy talltechy deleted the feature/issue-58-ui-improvements branch October 7, 2025 20:44
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.

Implement UI improvements and persistent configuration

3 participants