Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

misc improvement suggestions in init flow UX#545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Saga4 wants to merge2 commits intomain
base:main
Choose a base branch
Loading
fromsaga4/misc_init_flow_improv

Conversation

@Saga4
Copy link
Contributor

@Saga4Saga4 commentedJul 14, 2025
edited
Loading

When user already have a CF configuration:
image

Giving option to select nested directory on test file:
image

PR Type

Enhancement


Description

  • Add interactive directory browser functionality

  • Implement display_current_config for existing settings

  • Update reconfiguration prompt UX in init flow

  • Use browser for tests directory selection


Changes diagram

flowchart LR  A["should_modify_pyproject_toml"] -- "not reconfigure" --> B["display_current_config"]  A -- "reconfigure" --> E["collect_setup_info"]  E -- "browse for tests" --> C["browse_and_select_directory"]  C -- "returns path" --> D["tests_root"]
Loading

Changes walkthrough 📝

Relevant files
Enhancement
cmd_init.py
Add directory browser and config display                                 

codeflash/cli_cmds/cmd_init.py

  • Add browse_and_select_directory function
  • Add display_current_config function
  • Update should_modify_pyproject_toml UX
  • Replace tests path prompt with browser
  • +178/-11

    Need help?
  • Type/help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out thedocumentation for more information.
  • @github-actions
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Undefined Variable

    config_file_path is not defined inshould_modify_pyproject_toml, causing a NameError whendisplay_current_config is called.

    display_current_config(config,config_file_path)returnshould_reconfigure
    Incompatible Type Annotation

    The signaturePath | None requires Python 3.10+. If older versions are supported, useOptional[Path] fromtyping.

    defbrowse_and_select_directory(start_dir:Path,message:str,title:str)->Path|None:
    Unbounded Loop

    browse_and_select_directory uses an unboundedwhile True. Invalid inputs (e.g., bad custom paths) could trap the user in the loop; consider retry limits or a clear exit option.

    defbrowse_and_select_directory(start_dir:Path,message:str,title:str)->Path|None:"""Interactive directory browser with tab-completion-like functionality."""current_dir=start_dirwhileTrue:# Get all subdirectories in current directorytry:subdirs= []foritemincurrent_dir.iterdir():ifitem.is_dir()andnotitem.name.startswith('.'):subdirs.append(item.name)subdirs.sort()exceptPermissionError:console.print(f"❌ Permission denied accessing{current_dir}")returnNone# Build choices listchoices= []# Add parent directory option if not at start_dirifcurrent_dir!=start_dirandcurrent_dir.parent!=current_dir:choices.append(("📁 .. (parent directory)",".."))# Add current directory selection optionchoices.append(("✅ Select this directory","SELECT"))# Add subdirectoriesforsubdirinsubdirs:choices.append((f"📂{subdir}/",subdir))# Add option to type custom pathchoices.append(("⌨️  Type custom path","CUSTOM"))choices.append(("❌ Cancel","CANCEL"))# Show current directory in panelbrowse_panel=Panel(Text(f"📍 Current directory:{current_dir}\n\n{message}",style="cyan"),title=title,border_style="bright_blue",        )console.print(browse_panel)console.print()# Prompt for selectionquestions= [inquirer.List("selection",message="Navigate or select directory:",choices=choices,carousel=True,            )        ]answers=inquirer.prompt(questions,theme=CodeflashTheme())ifnotanswers:returnNoneselection=answers["selection"]ifselection=="SELECT":returncurrent_direlifselection=="CANCEL":returnNoneelifselection=="..":current_dir=current_dir.parentelifselection=="CUSTOM":# Allow custom path inputcustom_panel=Panel(Text("Enter a directory path (relative to current directory or absolute):",style="yellow"),title="🔧 Custom Path",border_style="bright_yellow",            )console.print(custom_panel)console.print()custom_path=click.prompt("Directory path",type=str).strip()ifcustom_path:try:ifPath(custom_path).is_absolute():new_dir=Path(custom_path)else:new_dir=current_dir/custom_pathnew_dir=new_dir.resolve()ifnew_dir.exists()andnew_dir.is_dir():current_dir=new_direlse:console.print(f"❌ Directory does not exist:{new_dir}")click.pause()exceptExceptionase:console.print(f"❌ Invalid path:{e}")click.pause()else:# Navigate to subdirectorytry:new_dir=current_dir/selectionifnew_dir.exists()andnew_dir.is_dir():current_dir=new_direlse:console.print(f"❌ Directory not accessible:{new_dir}")click.pause()exceptExceptionase:console.print(f"❌ Error accessing directory:{e}")click.pause()

    @github-actions
    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                   Impact
    Possible issue
    Catch generic filesystem errors

    Broaden the exception handling to include other filesystem errors likeOSError and
    show the error message. This prevents uncaught exceptions ifiterdir fails for
    reasons other than permissions.

    codeflash/cli_cmds/cmd_init.py [192-200]

     try:     subdirs = []     for item in current_dir.iterdir():         if item.is_dir() and not item.name.startswith('.'):             subdirs.append(item.name)     subdirs.sort()-except PermissionError:-    console.print(f"❌ Permission denied accessing {current_dir}")+except (PermissionError, OSError) as e:+    console.print(f"❌ Error accessing directory {current_dir}: {e}")     return None
    Suggestion importance[1-10]: 6

    __

    Why: Expanding to catchOSError prevents uncaught filesystem errors during directory iteration and surfaces the actual error message.

    Low
    Prevent KeyError on selection

    Guard against a missing"selection" key in the answers dict to avoid a potential
    KeyError. Usedict.get and explicitly handle theNone case before proceeding.

    codeflash/cli_cmds/cmd_init.py [239-243]

     answers = inquirer.prompt(questions, theme=CodeflashTheme()) if not answers:     return None--selection = answers["selection"]+selection = answers.get("selection")+if selection is None:+    return None+
    Suggestion importance[1-10]: 5

    __

    Why: Usinganswers.get("selection") guards against a missing key and avoids a potentialKeyError, improving robustness.

    Low
    General
    Use explicit Choice objects

    Wrap each choice in an explicitinquirer.Choice to ensure the display name and value
    map correctly and avoid ambiguous tuple handling. This makes the list of choices
    more robust and clear for the prompt engine.

    codeflash/cli_cmds/cmd_init.py [204-218]

     choices = [] if current_dir != start_dir and current_dir.parent != current_dir:-    choices.append(("📁 .. (parent directory)", ".."))-choices.append(("✅ Select this directory", "SELECT"))+    choices.append(inquirer.Choice("📁 .. (parent directory)", ".."))+choices.append(inquirer.Choice("✅ Select this directory", "SELECT")) for subdir in subdirs:-    choices.append((f"📂 {subdir}/", subdir))-choices.append(("⌨️  Type custom path", "CUSTOM"))-choices.append(("❌ Cancel", "CANCEL"))+    choices.append(inquirer.Choice(f"📂 {subdir}/", subdir))+choices.append(inquirer.Choice("⌨️  Type custom path", "CUSTOM"))+choices.append(inquirer.Choice("❌ Cancel", "CANCEL"))
    Suggestion importance[1-10]: 4

    __

    Why: Wrapping tuples ininquirer.Choice can improve clarity but is optional since tuple choices already work and requires an extra import.

    Low

    Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

    Reviewers

    No reviews

    Assignees

    No one assigned

    Projects

    None yet

    Milestone

    No milestone

    Development

    Successfully merging this pull request may close these issues.

    2 participants

    @Saga4

    [8]ページ先頭

    ©2009-2025 Movatter.jp