diff --git a/src/cmdforge/ui_urwid/__init__.py b/src/cmdforge/ui_urwid/__init__.py index ac8d193..605039d 100644 --- a/src/cmdforge/ui_urwid/__init__.py +++ b/src/cmdforge/ui_urwid/__init__.py @@ -489,8 +489,9 @@ class CmdForgeUI: # Show waiting dialog status_text = urwid.Text(('label', f"Connecting as @{username}...\nDevice: {hostname}\n\nWaiting for approval...")) instructions = urwid.Text( - "\nGo to cmdforge.brrd.tech/dashboard/connected-apps\n" - "and click 'Connect New App' to approve." + "\nIn your browser, go to:\n" + " https://cmdforge.brrd.tech/dashboard/connected-apps\n" + "and click 'Connect New App', then 'I've Run the Command'." ) countdown_text = urwid.Text(('label', "Expires in 5:00")) @@ -510,7 +511,7 @@ class CmdForgeUI: self.close_overlay() dialog = Dialog("Connecting...", body, [("Cancel", on_cancel)]) - self.show_overlay(dialog, width=55, height=16) + self.show_overlay(dialog, width=60, height=18) def poll_for_connection(): """Background thread to poll for connection.""" @@ -524,14 +525,14 @@ class CmdForgeUI: self.loop.set_alarm_in(0, lambda l, d: self._on_connect_timeout()) return - # Update countdown + # Update countdown - capture values to avoid closure issues remaining = int(max_time - elapsed) mins = remaining // 60 secs = remaining % 60 - def update_countdown(l, d, m=mins, s=secs): + def update_countdown(loop, data, m=mins, s=secs): countdown_text.set_text(('label', f"Expires in {m}:{s:02d}")) - self.refresh() + loop.draw_screen() if self.loop: self.loop.set_alarm_in(0, update_countdown) @@ -550,8 +551,10 @@ class CmdForgeUI: token = data.get("data", {}).get("token") if token: set_registry_token(token) + def on_success(loop, data): + self._on_connect_success(tool, version, username, hostname) if self.loop: - self.loop.set_alarm_in(0, lambda l, d: self._on_connect_success(tool, version, username, hostname)) + self.loop.set_alarm_in(0, on_success) return except Exception: @@ -564,8 +567,8 @@ class CmdForgeUI: thread.start() self.input_dialog( - "Connect Account", - "Enter your CmdForge username", + "Connect to your CmdForge Account", + "Username (create account at cmdforge.brrd.tech)", "", on_username ) diff --git a/src/cmdforge/web/templates/dashboard/base.html b/src/cmdforge/web/templates/dashboard/base.html index 896d76a..af7cd47 100644 --- a/src/cmdforge/web/templates/dashboard/base.html +++ b/src/cmdforge/web/templates/dashboard/base.html @@ -47,7 +47,7 @@ - API Tokens + Connections diff --git a/src/cmdforge/web/templates/dashboard/index.html b/src/cmdforge/web/templates/dashboard/index.html index 294e408..a8987df 100644 --- a/src/cmdforge/web/templates/dashboard/index.html +++ b/src/cmdforge/web/templates/dashboard/index.html @@ -42,7 +42,7 @@
-

API Tokens

+

Connections

{{ stats.tokens_count }}

diff --git a/src/cmdforge/web/templates/dashboard/tokens.html b/src/cmdforge/web/templates/dashboard/tokens.html index 1647ed7..56f6876 100644 --- a/src/cmdforge/web/templates/dashboard/tokens.html +++ b/src/cmdforge/web/templates/dashboard/tokens.html @@ -31,7 +31,8 @@

About Connected Apps

Connected apps can publish tools and sync your work across devices. - Run cmdforge config connect <username> in your terminal, + You can connect via the TUI (cmdforge ui → Connect button) + or run cmdforge config connect {{ user.slug }} in your terminal, then click "Connect New App" here to complete the connection.

@@ -106,7 +107,7 @@ {% endif %} @@ -128,8 +129,12 @@

- To connect a new app, run this command in your terminal: + To connect a new app, use either method:

+

Option 1: TUI

+
cmdforge ui
+

Then click the "Connect" button in the UI.

+

Option 2: Command Line

cmdforge config connect {{ user.slug }}

Then click the button below to complete the connection.