@@ -31,23 +31,11 @@ const pendingLoginKeySuffix = "#device-code"
3131// that cannot be completed.
3232const startNewLoginHint = "Run the same command without --user-code and --confirmation-code to start a new login"
3333
34- // deviceCodeAgentNote tells an AI agent to pass the login on to the user, who
35- // approves it in the browser. The notes of the two flows end with how the
36- // agent completes the login.
34+ // deviceCodeAgentNote starts the note that tells an AI agent to pass the login
35+ // on to the user.
3736const deviceCodeAgentNote = "give the URL and the code above to the user.\n " +
3837 "Do not open the URL or approve the login yourself: the user must approve it.\n "
3938
40- // nonInteractiveAgentNote is followed by how to complete the login with a
41- // rerun of the command.
42- const nonInteractiveAgentNote = deviceCodeAgentNote +
43- "Ask the user for the confirmation code their browser shows."
44-
45- // interactiveAgentNote tells an agent that runs the login in a terminal to
46- // enter the confirmation code into the running command.
47- const interactiveAgentNote = deviceCodeAgentNote +
48- "Ask the user for the confirmation code their browser shows, and enter it\n " +
49- `at the "Confirmation code" prompt of this command.`
50-
5139// deviceCodeIncompatibleFlags lists flags that device code login cannot honor.
5240var deviceCodeIncompatibleFlags = []string {
5341 // Resource indicators are sent on the browser authorization request,
@@ -201,7 +189,8 @@ func (l nonInteractiveDeviceCodeLogin) start(ctx context.Context) error {
201189 if err != nil {
202190 return fmt .Errorf ("store pending login: %w" , err )
203191 }
204- cmdio .LogString (ctx , strings .Join (append (approvalInstructions (* da , nonInteractiveAgentNote ),
192+ agentNote := deviceCodeAgentNote + "Ask the user for the confirmation code their browser shows."
193+ cmdio .LogString (ctx , strings .Join (append (approvalInstructions (* da , agentNote ),
205194 "Once finished, complete the login by running the same command with" ,
206195 "--user-code " + formatCode (da .UserCode )+ " and --confirmation-code set to the confirmation code" ,
207196 "provided in your browser." ,
@@ -285,7 +274,9 @@ func sameCode(a, b string) bool {
285274// and asks again.
286275func promptForConfirmationCode (ctx context.Context , da u2m.DeviceAuthorization , lastErr error , attemptsLeft int ) (string , error ) {
287276 if lastErr == nil {
288- cmdio .LogString (ctx , strings .Join (append (approvalInstructions (da , interactiveAgentNote ),
277+ agentNote := deviceCodeAgentNote + "Ask the user for the confirmation code their browser shows, and enter it\n " +
278+ `at the "Confirmation code" prompt of this command.`
279+ cmdio .LogString (ctx , strings .Join (append (approvalInstructions (da , agentNote ),
289280 "Once finished, enter the confirmation code provided in your browser." ,
290281 ), "\n " ))
291282 } else {
0 commit comments