Skip to content

fix(dx-4439): Show human-readable prompts in interactive mode after command correction v2-dev#2444

Closed
harshithad0703 wants to merge 5 commits intov2-devfrom
fix/dx-4439-beta-interactive-mode-messages
Closed

fix(dx-4439): Show human-readable prompts in interactive mode after command correction v2-dev#2444
harshithad0703 wants to merge 5 commits intov2-devfrom
fix/dx-4439-beta-interactive-mode-messages

Conversation

@harshithad0703
Copy link
Contributor

@harshithad0703 harshithad0703 commented Mar 3, 2026

Problem

  1. Interactive prompts after command correction: When an invalid command is corrected (e.g. csdx loginasda → "Did you mean login?" → Yes), the CLI shows i18n keys (e.g. CLI_AUTH_LOGIN_ENTER_EMAIL_ADDRESS) instead of user-friendly text (e.g. "Enter your email address").

  2. Logout confirmation message: When the user answers No to "Are you sure you want to log out?", the CLI still shows "SUCCESS: You're already logged out", which is incorrect—the user chose not to log out and remains logged in.

Solution

1. Human-readable prompts after command correction

  • New prerun hook init-context-for-command: When context.messageFilePath is missing and the current command id is available (e.g. after correction), re-build CsdxContext for that command and re-initialize messageHandler, cliux, and SDK initiators so the correct plugin message file is loaded.
  • Hook is registered as the first prerun hook.

2. Correct message when user cancels logout

  • Added message key CLI_AUTH_LOGOUT_CANCELLED: "Log out cancelled".
  • In auth:logout, when the user answers No to the confirmation and is still authenticated, show "Log out cancelled" instead of "You're already logged out". "You're already logged out" is now only shown when the user is actually not authenticated.

Testing

Interactive prompts (command correction):

  1. Run csdx loginasda (or node bin/run.js loginasda from packages/contentstack).
  2. At "Did you mean login?", answer Yes.
  3. Expected: Prompt shows "Enter your email address" (not the key).

Logout cancel:

  1. Run csdx auth:login and log in.
  2. Run csdx auth:logout, answer No to the confirmation.
  3. Expected: Message shows "Log out cancelled" (not "You're already logged out").
  4. Run csdx whoami to confirm you are still logged in.

cs-raj and others added 3 commits March 2, 2026 19:30
When an invalid command is corrected (e.g. loginasda → login), init had run
with the invalid command so context.messageFilePath was never set. Interactive
prompts then showed i18n keys instead of messages (e.g. Enter your email address).

- Add prerun hook init-context-for-command that re-builds context and
  re-initializes messageHandler/cliux/SDKs when messageFilePath is missing
  and the actual command id is available (e.g. auth:login).
- Register the hook as the first prerun hook.

Made-with: Cursor
@harshithad0703 harshithad0703 requested review from a team as code owners March 3, 2026 12:42
@gitguardian
Copy link

gitguardian bot commented Mar 3, 2026

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@harshithad0703 harshithad0703 changed the base branch from development to v2-beta-dev March 3, 2026 12:47
@harshithad0703 harshithad0703 changed the title fix(dx-4439): Show human-readable prompts in interactive mode after command correction (beta) fix(dx-4439): Show human-readable prompts in interactive mode after command correction v2-dev Mar 4, 2026
@harshithad0703 harshithad0703 changed the base branch from v2-beta-dev to v2-dev March 4, 2026 06:12
@harshithad0703
Copy link
Contributor Author

closing this PR, will create new branch and raise PR

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.

3 participants