diff --git a/pyproject.toml b/pyproject.toml index cdb88b664..c987c3489 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,6 +70,7 @@ keywords = [ ] [project.scripts] codegen = "codegen.cli.cli:main" +cg = "codegen.cli.cli:main" [project.optional-dependencies] types = [] diff --git a/src/codegen/cli/auth/login.py b/src/codegen/cli/auth/login.py index 5df4bf252..6905330ed 100644 --- a/src/codegen/cli/auth/login.py +++ b/src/codegen/cli/auth/login.py @@ -23,6 +23,10 @@ def login_routine(token: str | None = None) -> str: typer.Exit: If login fails """ + # Display header like in the main TUI + print("\033[38;2;82;19;217m" + "/" * 20 + " Codegen\033[0m") + print() + # Try environment variable first token = token or global_env.CODEGEN_USER_ACCESS_TOKEN @@ -39,7 +43,7 @@ def login_routine(token: str | None = None) -> str: try: token_manager = TokenManager() token_manager.authenticate_token(token) - rich.print(f"[green]✓ Stored token and profile to:[/green] {token_manager.token_file}") + rich.print(f"[dim]✓ Stored token and profile to:[/dim] [#ffca85]{token_manager.token_file}[/#ffca85]") # Show organization selector if multiple organizations available organizations = get_cached_organizations() @@ -69,6 +73,12 @@ def login_routine(token: str | None = None) -> str: except Exception as e: rich.print(f"[yellow]Warning: Could not set default organization: {e}[/yellow]") + # After successful login, launch the TUI + print() # Add some space + from codegen.cli.tui.app import run_tui + + run_tui() + return token except AuthError as e: rich.print(f"[red]Error:[/red] {e!s}") diff --git a/src/codegen/cli/tui/app.py b/src/codegen/cli/tui/app.py index 919988f2d..96389cf9c 100644 --- a/src/codegen/cli/tui/app.py +++ b/src/codegen/cli/tui/app.py @@ -402,7 +402,7 @@ def _create_background_agent(self, prompt: str): input("Press Enter to continue...") return - print(f"\n🔄 Creating agent run with prompt: '{prompt[:50]}{'...' if len(prompt) > 50 else ''}'") + print(f"\n\033[90mCreating agent run with prompt: '{prompt[:50]}{'...' if len(prompt) > 50 else ''}'\033[0m") try: payload = {"prompt": prompt.strip()} @@ -420,10 +420,10 @@ def _create_background_agent(self, prompt: str): status = agent_run_data.get("status", "Unknown") web_url = self._generate_agent_url(run_id) - print("\n✅ Agent run created successfully!") - print(f" Run ID: {run_id}") - print(f" Status: {status}") - print(f" Web URL: {web_url}") + print("\n\033[90mAgent run created successfully!\033[0m") + print(f"\033[90m Run ID: {run_id}\033[0m") + print(f"\033[90m Status: {status}\033[0m") + print(f"\033[90m Web URL: \033[38;2;255;202;133m{web_url}\033[0m") # Clear the input self.prompt_input = "" @@ -441,8 +441,8 @@ def _show_post_creation_menu(self, web_url: str): """Show menu after successful agent creation.""" from codegen.cli.utils.inplace_print import inplace_print - print("\nWhat would you like to do next?") - options = ["open in web preview", "go to recent"] + print("\n\033[90mWhat would you like to do next?\033[0m") + options = ["Open Trace ↗", "Go to Recent"] selected = 0 prev_lines = 0 @@ -470,7 +470,7 @@ def build_lines(): selected = (selected + 1) % len(options) prev_lines = inplace_print(build_lines(), prev_lines) elif key == "\r" or key == "\n": # Enter - select option - if selected == 0: # open in web preview + if selected == 0: # Open Trace try: import webbrowser @@ -478,7 +478,7 @@ def build_lines(): except Exception as e: print(f"\n❌ Failed to open browser: {e}") input("Press Enter to continue...") - elif selected == 1: # go to recent + elif selected == 1: # Go to Recent self.current_tab = 0 # Switch to recent tab self.input_mode = False self._load_agent_runs() # Refresh the data @@ -884,8 +884,16 @@ def _clear_and_redraw(self): def run(self): """Run the minimal TUI.""" if not self.is_authenticated: - print("⚠️ Not authenticated. Please run 'codegen login' first.") - return + # Automatically start login flow for first-time users + from codegen.cli.auth.login import login_routine + + try: + login_routine() + # login_routine will launch TUI after successful authentication + return + except Exception: + # If login fails, just exit gracefully + return # Show UI immediately self._clear_and_redraw() diff --git a/src/codegen/cli/utils/simple_selector.py b/src/codegen/cli/utils/simple_selector.py index 7a15e71db..65ee04842 100644 --- a/src/codegen/cli/utils/simple_selector.py +++ b/src/codegen/cli/utils/simple_selector.py @@ -77,7 +77,7 @@ def signal_handler(signum, frame): for i, option in enumerate(options): display_text = str(option.get(display_key, f"Option {i + 1}")) if i == selected: - print(f" \033[34m→ {display_text}\033[0m") + print(f" \033[37m→ {display_text}\033[0m") # White for selected else: print(f" \033[90m {display_text}\033[0m") @@ -100,7 +100,7 @@ def signal_handler(signum, frame): for i, option in enumerate(options): display_text = str(option.get(display_key, f"Option {i + 1}")) if i == selected: - print(f" \033[34m→ {display_text}\033[0m\033[K") # Clear to end of line + print(f" \033[37m→ {display_text}\033[0m\033[K") # White for selected, clear to end of line else: print(f" \033[90m {display_text}\033[0m\033[K") # Clear to end of line if show_help: @@ -115,7 +115,7 @@ def signal_handler(signum, frame): for i, option in enumerate(options): display_text = str(option.get(display_key, f"Option {i + 1}")) if i == selected: - print(f" \033[34m→ {display_text}\033[0m\033[K") # Clear to end of line + print(f" \033[37m→ {display_text}\033[0m\033[K") # White for selected, clear to end of line else: print(f" \033[90m {display_text}\033[0m\033[K") # Clear to end of line if show_help: