- 
                Notifications
    You must be signed in to change notification settings 
- Fork 7
AGENT-420 added an option to open login OTP with enter #393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||||||||||||||||||||||||||||||||||||
| package util | ||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||||||||||||||||
| "bufio" | ||||||||||||||||||||||||||||||||||||||||
| "context" | ||||||||||||||||||||||||||||||||||||||||
| "errors" | ||||||||||||||||||||||||||||||||||||||||
| "fmt" | ||||||||||||||||||||||||||||||||||||||||
|  | @@ -164,7 +165,7 @@ | |||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| if !skip { | ||||||||||||||||||||||||||||||||||||||||
| if berr := browser.OpenURL(u.String()); berr != nil { | ||||||||||||||||||||||||||||||||||||||||
| returnErr = fmt.Errorf("failed to open browser: %s", err) | ||||||||||||||||||||||||||||||||||||||||
| returnErr = fmt.Errorf("failed to open browser: %w", berr) | ||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|  | @@ -189,3 +190,42 @@ | |||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||
| return returnErr | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||
| // PromptBrowserOpen prompts the user to press Enter to open a browser to the given URL. | ||||||||||||||||||||||||||||||||||||||||
| // It handles display detection on Linux and provides appropriate user feedback. | ||||||||||||||||||||||||||||||||||||||||
| func PromptBrowserOpen(logger interface{ Error(string, ...interface{}) }, url string) { | ||||||||||||||||||||||||||||||||||||||||
| var skipOpen bool | ||||||||||||||||||||||||||||||||||||||||
| if runtime.GOOS == "linux" { | ||||||||||||||||||||||||||||||||||||||||
| // if we don't have a display, we can't open a browser most likely | ||||||||||||||||||||||||||||||||||||||||
| if _, ok := os.LookupEnv("DISPLAY"); !ok { | ||||||||||||||||||||||||||||||||||||||||
| skipOpen = true | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||
| fmt.Println() | ||||||||||||||||||||||||||||||||||||||||
| if skipOpen { | ||||||||||||||||||||||||||||||||||||||||
| fmt.Print(tui.Secondary("Press Enter to continue, or Ctrl+C to skip: ")) | ||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||
| fmt.Print(tui.Secondary("Press Enter to open browser, or Ctrl+C to skip: ")) | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||
| reader := bufio.NewReader(os.Stdin) | ||||||||||||||||||||||||||||||||||||||||
| reader.ReadLine() | ||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Ignored error from  
 Example quick fix: -	reader := bufio.NewReader(os.Stdin)
-	reader.ReadLine()
+	reader := bufio.NewReader(os.Stdin)
+	if _, _, err := reader.ReadLine(); err != nil && !errors.Is(err, io.EOF) {
+		logger.Error("Error reading stdin: %v", err)
+		return
+	}📝 Committable suggestion
 
        Suggested change
       
 🤖 Prompt for AI Agents | ||||||||||||||||||||||||||||||||||||||||
| if !skipOpen { | ||||||||||||||||||||||||||||||||||||||||
| if err := browser.OpenURL(url); err != nil { | ||||||||||||||||||||||||||||||||||||||||
| logger.Error("Failed to open browser: %v", err) | ||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||
| // Clear previous line and move cursor up to remove the "Press Enter..." prompt | ||||||||||||||||||||||||||||||||||||||||
| fmt.Print("\r\033[K\033[A\r\033[K") | ||||||||||||||||||||||||||||||||||||||||
| tui.ShowSuccess("Browser opened!") | ||||||||||||||||||||||||||||||||||||||||
| fmt.Println() | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||
| // Clear the prompt and show the URL for manual opening (and the loading spinner) | ||||||||||||||||||||||||||||||||||||||||
| fmt.Print("\r\033[K") | ||||||||||||||||||||||||||||||||||||||||
| fmt.Println(tui.Muted("Please visit the URL manually:")) | ||||||||||||||||||||||||||||||||||||||||
| fmt.Println(tui.Link(url)) | ||||||||||||||||||||||||||||||||||||||||
| fmt.Println() | ||||||||||||||||||||||||||||||||||||||||
| 
      Comment on lines
    
      +225
     to 
      +229
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
 
 -		fmt.Println(tui.Link(url))
+		fmt.Println(tui.Link("%s", url))📝 Committable suggestion
 
        Suggested change
       
 🧰 Tools🪛 GitHub Check: Build and Test (blacksmith-4vcpu-ubuntu-2204)[failure] 228-228: 🪛 golangci-lint (1.64.8)228-228: printf: non-constant format string in call to github.com/agentuity/go-common/tui.Link (govet) 🤖 Prompt for AI Agents | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same vet error – non-constant format string in
tui.Link.The authentication banner fails the build for the same reason:
Apply the change to unblock CI.
📝 Committable suggestion
🧰 Tools
🪛 GitHub Check: Build and Test (blacksmith-4vcpu-ubuntu-2204)
[failure] 81-81:
non-constant format string in call to github.com/agentuity/go-common/tui.Link
🪛 golangci-lint (1.64.8)
81-81: printf: non-constant format string in call to github.com/agentuity/go-common/tui.Link
(govet)
🪛 GitHub Actions: Go Build and Test
[error] 81-81: non-constant format string in call to github.com/agentuity/go-common/tui.Link
🤖 Prompt for AI Agents