Skip to content

Conversation

@skyf0l
Copy link

@skyf0l skyf0l commented Dec 30, 2025

The output filename prompt required manual text entry every time, even for common patterns like using the same filename or saving to temp directories.

Changes

Replaced single text prompt with three-option TerminalMenu:

  • Same filename: Uses basename extracted from source file
  • Temp directory: OS-specific paths (C:\Windows\Temp\ for Windows, /tmp/ for Linux)
  • Custom: Shows prompt with default filename pre-filled

Menu behavior:

  • ESC raises StepBack() to return to previous step
  • Arrow keys navigate, Enter selects
  • Command-line --output argument bypasses menu (preserved)

Implementation:

# Extract basename and generate OS-specific temp path
default_filename = os.path.basename(selected_file)
temp_path = f"C:\\Windows\\Temp\\{default_filename}" if OS.lower() == "windows" else f"/tmp/{default_filename}"

# Present menu
menu_options = [
    f"Same filename ({default_filename})",
    f"Same filename in temp ({temp_path})",
    "Custom"
]
output_menu = TerminalMenu(menu_options, menu_cursor="=>  ", menu_highlight_style=style, 
                          title="Filename to write on the target machine? ")
menu_index = output_menu.show()

# Handle selection (0=same, 1=temp, 2=custom, None=ESC)

Refactored to use existing payload_requires_output() function instead of duplicating logic inline.

Original prompt

Updated Copilot Agent Prompt

Problem Statement

Replace the text input prompt for the output filename with a user-friendly menu that offers common default options.

Current Behavior

On line 348 of uploader.py, the code prompts for manual text entry:

Output = session.prompt("Enter the filename to write on the target machine: ", key_bindings=key_bindings)

This forces users to type the filename every time, even when they want to use common patterns like the same filename or saving to a temp directory.

Desired Behavior

Present users with a TerminalMenu offering three options:

  1. Same filename - Use file.txt (extracted from the source file)
  2. Same filename in temp - Use C:\Windows\Temp\file. txt (Windows) or /tmp/file.txt (Linux)
  3. Custom - Allow manual entry with the default filename pre-filled

Example menu:

Filename to write on the target machine? 
> Same filename (file.txt)
  Same filename in temp (C:\Windows\Temp\file. txt)
  Custom

Implementation Requirements

Location: Modify the section around lines 344-356 in uploader.py where requires_output() is checked.

Steps:

  1. Extract the basename from selected_file to get the default filename
  2. Create a TerminalMenu with three options:
    • Option 0: f"Same filename ({default_filename})"
    • Option 1: OS-specific temp path - C:\Windows\Temp\{default_filename} for Windows, /tmp/{default_filename} for Linux
    • Option 2: "Custom"
  3. Handle menu selection:
    • If index 0: Set Output = default_filename
    • If index 1: Set Output to the appropriate temp path based on OS
    • If index 2: Show the existing session.prompt() with default=default_filename parameter
    • If None (ESC pressed): Raise StepBack() to go back to step 3
  4. Maintain existing functionality:
    • Keep the Output_arg bypass for command-line arguments
    • Preserve StepBack exception handling
    • Keep keyboard interrupt handling
  5. Use consistent styling: Apply the same style variable used in other menus throughout the code

Technical Details

  • Use TerminalMenu class (already imported from simple_term_menu)
  • Use the existing style variable for consistent UI: ("bg_black", "fg_yellow", "bold")
  • Menu title: "Filename to write on the target machine? "
  • For the custom option, use session.prompt() with default=default_filename and check for "__stepback__" return value
  • Ensure the OS check uses .lower() for case-insensitive comparison

Testing Considerations

  • Test all three menu options (same filename, temp directory, custom)
  • Test on both Windows and Linux target OS selections (temp paths differ)
  • Verify ESC key navigation (stepback) works from both the menu and custom prompt
  • Test that --output command-line argument still bypasses the menu
  • Verify the custom option pre-fills with the default filename and allows editing

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 7 commits December 30, 2025 05:06
Co-authored-by: skyf0l <59019720+skyf0l@users.noreply.github.com>
Co-authored-by: skyf0l <59019720+skyf0l@users.noreply.github.com>
…duplicating logic

Co-authored-by: skyf0l <59019720+skyf0l@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ignore

Co-authored-by: skyf0l <59019720+skyf0l@users.noreply.github.com>
Co-authored-by: skyf0l <59019720+skyf0l@users.noreply.github.com>
@skyf0l skyf0l changed the title Copilot/update output filename prompt feat: multi-choice output filename prompt Dec 30, 2025
Copilot AI and others added 2 commits December 30, 2025 06:23
…r request

Co-authored-by: skyf0l <59019720+skyf0l@users.noreply.github.com>
Co-authored-by: skyf0l <59019720+skyf0l@users.noreply.github.com>
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.

1 participant