Skip to content

fix: Avoid re-login when set mode to interactive - #86

Merged
aviatco merged 12 commits into
mainfrom
dev/aviatcohen/avoidReLoginWhenSwitchingToInteractiveMode
Dec 24, 2025
Merged

fix: Avoid re-login when set mode to interactive#86
aviatco merged 12 commits into
mainfrom
dev/aviatcohen/avoidReLoginWhenSwitchingToInteractiveMode

Conversation

@aviatco

@aviatco aviatco commented Dec 3, 2025

Copy link
Copy Markdown
Collaborator

📥 Pull Request

✨ Description of new changes

🎯 Overview
This PR enhances the user experience by eliminating the need to re-authenticate when switching from command-line mode to interactive mode using fab config set mode interactive. Previously, users had to manually run fab auth login after setting the mode, creating friction in the workflow.

🔧 Changes Made

Enhanced parser reusability: Extracted _create_parser_and_subparsers() function to enable parser reuse across different contexts
Improved auth flow: Streamlined the authentication and mode transition logic in the main entry point
Smart authentication check: Added _is_user_authenticated() function that validates existing tokens without requiring interactive renewal
Seamless mode transition: Enhanced mode switching logic in _set_config() to automatically launch interactive mode when:
Switching from command-line to interactive mode
User has valid authentication tokens
Automatic interactive launch: Added _start_interactive_mode() function that reuses existing parser context to launch interactive mode
Graceful fallback: If user is not authenticated, provides clear guidance to login first

🚀 User Experience Improvements

$ fab config set mode interactive
Configuration 'mode' set to 'interactive'
Switching to interactive mode...
Welcome to the Fabric CLI ⚡
fab:/$

🔐 Security Considerations

Token validation is performed without triggering interactive authentication flows
Existing authentication patterns and security boundaries are preserved
Falls back to requiring explicit login if tokens are invalid or expired

🧪 Technical Details

Authentication validation: Uses FabAuth.get_access_token() with interactive_renew=False to check token validity
Parser reuse: Leverages the extracted parser creation function to maintain consistency between command-line and interactive contexts
Error handling: Graceful handling of authentication errors and interactive mode failures
Context management: Proper cleanup of context files during mode transitions
✅ Impact
Improved UX: Eliminates unnecessary authentication steps
Workflow efficiency: Reduces friction when switching between modes
Backward compatibility: Maintains existing behavior for unauthenticated users
Code reusability: Extracted parser creation logic for better maintainability

@aviatco
aviatco requested a review from a team as a code owner December 3, 2025 15:51
Comment thread src/fabric_cli/commands/config/fab_config_set.py Outdated
Comment thread src/fabric_cli/commands/config/fab_config_set.py Outdated
Comment thread src/fabric_cli/main.py Outdated
Comment thread src/fabric_cli/commands/config/fab_config_set.py Outdated
Comment thread src/fabric_cli/utils/fab_cmd_config_utils.py Outdated
Comment thread src/fabric_cli/core/fab_parser_setup.py
Comment thread src/fabric_cli/core/fab_parser_setup.py
Comment thread src/fabric_cli/commands/config/fab_config_set.py
Comment thread src/fabric_cli/core/fab_interactive.py
Comment thread src/fabric_cli/core/fab_interactive.py
Comment thread src/fabric_cli/core/fab_interactive.py Outdated
Comment thread src/fabric_cli/core/fab_interactive.py
@aviatco
aviatco merged commit 882a67f into main Dec 24, 2025
12 checks passed
@aviatco
aviatco deleted the dev/aviatcohen/avoidReLoginWhenSwitchingToInteractiveMode branch December 24, 2025 07:41
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.

2 participants