chore: refactor handle_configure to reduce line count#6276
Merged
Conversation
Split the 203-line handle_configure function into smaller, focused helpers: - handle_first_time_setup: Handles welcome flow and setup method selection - handle_manual_provider_setup: Handles manual provider configuration result - print_manual_config_error: Handles ConfigError display with platform-specific keyring messages - print_keyring_error: Platform-specific keyring error messages (cfg-gated) - handle_existing_config: Handles configuration updates for existing setups The main handle_configure function is now 9 lines, delegating to appropriate helpers based on whether config exists. All helper functions are under 60 lines.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the monolithic handle_configure function by extracting its logic into focused helper functions, reducing it from 203 lines to 9 lines without changing functionality.
Key changes:
- Main function now delegates to
handle_first_time_setuporhandle_existing_configbased on config existence - Error handling extracted into
print_manual_config_errorand platform-specificprint_keyring_errorfunctions - Manual provider setup flow extracted into
handle_manual_provider_setup
DOsinga
approved these changes
Jan 5, 2026
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors the
handle_configurefunction incrates/goose-cli/src/commands/configure.rsfrom 203 lines down to 9 lines by extracting logical sections into focused helper functions.Changes
Split the monolithic
handle_configurefunction into smaller, focused helpers:handle_first_time_setup(58 lines): Handles welcome flow and setup method selection (openrouter/tetrate/manual)handle_manual_provider_setup(28 lines): Handles manual provider configuration result and error handlingprint_manual_config_error(48 lines): Handles ConfigError display with platform-specific keyring messagesprint_keyring_error(platform-specific, cfg-gated): Platform-specific keyring error messages for macOS/Windows/Linuxhandle_existing_config(53 lines): Handles configuration updates for existing setupsThe main
handle_configurefunction is now just 9 lines, delegating to appropriate helpers based on whether config exists.Testing
cargo build -p goose-cli✅cargo test -p goose-cli✅ (112 tests pass)cargo fmt✅cargo clippy -p goose-cli✅ (no errors or warnings in configure.rs)Related
Part of TSK-696: Simplify clippy baseline system