Skip to content

Conversation

@baxen
Copy link
Collaborator

@baxen baxen commented Dec 25, 2025

Summary

Refactors the configure_extensions_dialog function from 353 lines down to 36 lines by extracting common functionality into focused helper functions.

Changes

Split the monolithic function into smaller, reusable helpers:

  • prompt_extension_timeout(): Prompts for extension timeout
  • prompt_extension_description(): Prompts for extension description
  • prompt_extension_name(): Prompts for extension name with validation
  • collect_env_vars(): Collects environment variables interactively
  • collect_headers(): Collects custom headers interactively
  • configure_builtin_extension(): Handles built-in extension setup
  • configure_stdio_extension(): Handles stdio extension setup
  • configure_sse_extension(): Handles SSE extension setup
  • configure_streamable_http_extension(): Handles streaming HTTP setup

Result

  • Before: 353 lines
  • After: 36 lines (main function)
  • Target: Under 200 lines ✅

The refactoring improves code readability and maintainability while preserving all existing functionality.

Testing

  • cargo build -p goose-cli
  • cargo fmt
  • cargo clippy -p goose-cli -- -D warnings
  • ./scripts/clippy-lint.sh

Copilot AI review requested due to automatic review settings December 25, 2025 03:14
Copy link
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

This PR successfully refactors the configure_extensions_dialog function from 353 lines to 36 lines by extracting common prompting and configuration logic into focused helper functions. The refactoring improves code maintainability and readability while preserving all existing functionality.

Key changes:

  • Extracted 9 helper functions for reusable prompting and configuration logic
  • Standardized description validation across all extension types (fixing a validation bug in the process)
  • Maintained identical behavior for all extension configuration flows

@baxen baxen marked this pull request as draft December 25, 2025 03:29
@baxen baxen marked this pull request as ready for review December 25, 2025 04:56
Copilot AI review requested due to automatic review settings December 25, 2025 04:56
Copy link
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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@baxen baxen changed the title TSK-702: Refactor configure_extensions_dialog to reduce line count chore: refactor configure_extensions_dialog to reduce line count Dec 25, 2025
@baxen baxen mentioned this pull request Dec 26, 2025
11 tasks
@baxen baxen merged commit ff4ebb0 into main Jan 6, 2026
20 checks passed
@baxen baxen deleted the baxen/TSK-702 branch January 6, 2026 05:08
zanesq added a commit that referenced this pull request Jan 6, 2026
* 'main' of github.com:block/goose:
  refactor:  when changing provider/model,load existing provider/model (#6334)
  chore: refactor configure_extensions_dialog to reduce line count (#6277)
  chore: refactor handle_configure to reduce line count (#6276)
  chore: refactor interactive session to reduce line count (#6274)
  chore: refactor docx_tool to reduce function size (#6273)
  chore: refactor cli() function to reduce line count (#6272)
  make sure the models are using streaming properly (#6331)
  feat: add a max tokens env var (#6264)
  docs: slash commands topic (#6333)
  fix(ci): prevent gh-pages branch bloat (#6340)
  chore(deps): bump qs and body-parser in /documentation (#6338)
  Skip the smoke tests for dependabot PRs (#6337)
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.

4 participants