Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ keywords = [
]
[project.scripts]
codegen = "codegen.cli.cli:main"
cg = "codegen.cli.cli:main"

[project.optional-dependencies]
types = []
Expand Down
12 changes: 11 additions & 1 deletion src/codegen/cli/auth/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -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}")
Expand Down
30 changes: 19 additions & 11 deletions src/codegen/cli/tui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
Expand All @@ -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 = ""
Expand All @@ -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

Expand Down Expand Up @@ -470,15 +470,15 @@ 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

webbrowser.open(web_url)
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
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions src/codegen/cli/utils/simple_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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:
Expand All @@ -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:
Expand Down
Loading