Skip to content

Conversation

hongkongkiwi
Copy link

@hongkongkiwi hongkongkiwi commented Sep 23, 2025

Summary

Fixes an issue where the CLI --profile option was displaying the wrong profile name in command output.

Fixes #2542

Problem

When using --profile myprofile, the CLI would still display "profile: personal" or "profile: default" in the command output instead of showing the actual profile being used. This created confusion as users couldn't tell if their specified profile was actually being used.

Solution

  • Added profileToUse variable that correctly resolves the profile name at the start of the whoAmI function
  • Uses readAuthConfigCurrentProfileName() for proper default profile resolution when no --profile is specified
  • Ensures all messages (intro, error, and output) display the same profile consistently throughout execution

Changes

Modified packages/cli-v3/src/commands/whoami.ts:

  • Added import for readAuthConfigCurrentProfileName from configFiles.js
  • Introduced profileToUse variable that resolves to either the specified profile or the current default
  • Updated all profile references throughout the function to use profileToUse consistently

Testing

The fix ensures correct profile display in all scenarios:

  • trigger.dev whoami - correctly shows the current profile from config
  • trigger.dev whoami --profile myprofile - correctly shows "myprofile"
  • Error messages now accurately reference the profile being used

Related Issues

Fixes #2542 - CLI displays incorrect profile name when using --profile option

The CLI was displaying "default" or the first profile instead of the actual
profile being used when the --profile option was specified. This fix ensures
consistent profile resolution and display throughout the whoami command.

- Added profileToUse variable that correctly resolves the profile name
- Use readAuthConfigCurrentProfileName() for default profile resolution
- Ensure all messages display the same profile name consistently

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

changeset-bot bot commented Sep 23, 2025

⚠️ No Changeset found

Latest commit: 5173721

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Sep 23, 2025

Walkthrough

Multiple CLI command files were updated to pass an optional profile argument to printInitialBanner and printStandloneInitialBanner. The initialBanner utility API was changed to accept an optional profileOption and forwards it to getProfileInfo, which now accepts profileOption. Most call sites only add the profile parameter without other behavioral changes. Separately, the deploy command's failDeploy handling added INSTALLING to the set of serverDeployment.status values treated like PENDING/DEPLOYING/BUILDING. No other public exports were added or removed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (4 warnings)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning Based on the provided summaries, the code updates add an optional profile parameter to banner utilities and adjust calls to printInitialBanner but do not reflect the introduction of a profileToUse variable or explicit use of readAuthConfigCurrentProfileName within the whoami command; the objectives from issue #2542 require resolving the profile at command start and consistently using that value across all whoami messages, which is not clearly implemented. Introduce explicit profile resolution at the top of the whoami function by importing and calling readAuthConfigCurrentProfileName, assign the result or the --profile input to a profileToUse variable, and update all banner and output calls to reference this resolved value so that the displayed profile matches the user’s intent as specified in issue #2542.
Out of Scope Changes Check ⚠️ Warning The raw summary indicates changes across multiple commands and the initialBanner utilities—such as analyze, deploy, dev, env, and others—that are unrelated to the objectives of issue #2542, which focus solely on correcting the profile display in the whoami command, so these additional updates fall outside the linked issue’s scope. Restrict the pull request to only the whoami command and its immediate dependencies for resolving and displaying the profile name, and move any modifications to other commands or broad initialBanner API signature changes into a separate PR if needed for wider profile support.
Description Check ⚠️ Warning The description clearly articulates the summary, problem, solution, and testing steps but omits the repository’s required checklist, changelog, and screenshots sections and uses “Fixes #2542” instead of the template’s “Closes #2542” heading, so it does not follow the specified template. Please add the “✅ Checklist” section with the contributing guide, title convention, and testing confirmations, include a “Changelog” section with a brief change summary, provide a “Screenshots” placeholder or images if applicable, and update the issue reference to use “Closes #2542” as specified by the template.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly summarizes the main change—fixing the CLI’s --profile display behavior—and follows the conventional commit style, making it clear to reviewers what the pull request addresses.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d89ac4f and 5173721.

📒 Files selected for processing (1)
  • packages/cli-v3/src/commands/deploy.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Always prefer using isomorphic code like fetch, ReadableStream, etc. instead of Node.js specific code
For TypeScript, we usually use types over interfaces
Avoid enums
No default exports, use function declarations

Files:

  • packages/cli-v3/src/commands/deploy.ts
🧬 Code graph analysis (1)
packages/cli-v3/src/commands/deploy.ts (1)
packages/cli-v3/src/utilities/initialBanner.ts (1)
  • printStandloneInitialBanner (65-84)
🔇 Additional comments (2)
packages/cli-v3/src/commands/deploy.ts (2)

148-149: Profile forwarded to banner

Nice touch routing options.profile through to printStandloneInitialBanner—this keeps the deploy intro consistent with the other profile-aware messaging you added.


679-682: INSTALLING state handled

Adding the INSTALLING branch alongside the other in-flight statuses ensures we fail deployments consistently while that server-side transition is in progress. Looks good.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/cli-v3/src/commands/whoami.ts (2)

77-79: Harden profile resolution with safe fallback and trim

readAuthConfigCurrentProfileName may throw if the config file is missing/corrupt (e.g., first‑run, not logged in). Also trim CLI input. Suggest a safe, explicit fallback to "default".

-  const profileToUse = options?.profile ?? readAuthConfigCurrentProfileName();
+  // Resolve the effective profile once. Fall back safely if config is missing.
+  let profileToUse: string = options?.profile?.trim() ?? "";
+  if (!profileToUse) {
+    try {
+      profileToUse = readAuthConfigCurrentProfileName();
+    } catch {
+      profileToUse = "default";
+    }
+  }

Please verify whether getConfig/readAuthConfigCurrentProfileName can throw on a fresh install or missing config and that "default" is an acceptable fallback for your UX.


150-151: Optional: prefer authenticated profile if available

Minor: after a successful auth, consider showing authentication.profile (canonicalized) if provided.

-      `Account details [${profileToUse}]`
+      `Account details [${(authentication as any).profile ?? profileToUse}]`

If LoginResult already narrows post early-return, you can type it without the cast.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 49728b5 and 0ca1598.

📒 Files selected for processing (1)
  • packages/cli-v3/src/commands/whoami.ts (5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Always prefer using isomorphic code like fetch, ReadableStream, etc. instead of Node.js specific code
For TypeScript, we usually use types over interfaces
Avoid enums
No default exports, use function declarations

Files:

  • packages/cli-v3/src/commands/whoami.ts
🧬 Code graph analysis (1)
packages/cli-v3/src/commands/whoami.ts (2)
packages/cli-v3/src/utilities/configFiles.ts (1)
  • readAuthConfigCurrentProfileName (79-82)
packages/cli-v3/src/utilities/session.ts (1)
  • isLoggedIn (32-73)
🔇 Additional comments (4)
packages/cli-v3/src/commands/whoami.ts (4)

19-19: LGTM: correct import

Importing readAuthConfigCurrentProfileName here is appropriate and aligns with the PR goal.


80-80: LGTM: consistent intro messaging

Intro now reflects the resolved profile consistently.


107-107: LGTM: auth check uses the resolved profile

Passing profileToUse to isLoggedIn aligns behavior and messaging.


116-121: LGTM: error hints reference the actual profile

Logout/login guidance now correctly includes the resolved profile.

hongkongkiwi and others added 3 commits September 23, 2025 17:17
Address CodeRabbit review feedback:
- Use logical OR (||) instead of nullish coalescing (??) to handle empty strings
- Trim profile input to handle accidental whitespace from CLI

This ensures more robust profile resolution when users provide input with
accidental leading/trailing spaces.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Explains how profile resolution works:
- No --profile: uses Zod default (readAuthConfigCurrentProfileName)
- With --profile: trims whitespace, falls back to current if empty
- Current profile defaults to 'default' when no config exists
- Rely on Zod schema default (readAuthConfigCurrentProfileName) for --profile fallback
- Use consistent 'default' fallback pattern like other commands
- Remove redundant readAuthConfigCurrentProfileName call
- Maintain whitespace trimming for user input robustness
Copy link
Collaborator

@nicktrn nicktrn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @hongkongkiwi - sadly this tries to "fix" the output of the whoami command which was working fine before with --profile <name>. What we need to do is fix the header instead that is used for all commands.

According to @nicktrn's review:
- Reverted unnecessary changes to whoami command (it was already working correctly)
- Fixed the actual issue: header display in printInitialBanner() and printStandloneInitialBanner()
- Now all commands pass their --profile option to the banner functions
- Banner functions now correctly display the profile specified via --profile option

This ensures the CLI header consistently shows the profile being used, whether it's the default or specified via --profile flag.
@hongkongkiwi hongkongkiwi force-pushed the fix/profile-display-consistency branch from cb1d4d8 to 74c8741 Compare September 25, 2025 11:36
Added profile parameter to printStandloneInitialBanner calls in:
- workers/build.ts
- workers/run.ts
- workers/list.ts
- workers/create.ts

This ensures worker commands also display the correct profile in their headers when using --profile option.
@hongkongkiwi
Copy link
Author

Thanks @nicktrn . Does this fix the actual issue now?


switch (serverDeployment.status) {
case "PENDING":
case "INSTALLING":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is interesting @myftija

@nicktrn
Copy link
Collaborator

nicktrn commented Sep 25, 2025

Does this fix the actual issue now?

Looks like it might, have you tested it? 😉

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's revert this file, no need for profile here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: CLI displays incorrect profile name when using --profile option
2 participants