feat: add AWS profile context chip
Closes #4461 (now labeled ready-to-implement — re-opening per the maintainer comment on the issue).
Replaces #9428, which was auto-closed by Oz before the issue was labeled. Code is unchanged from that PR's final state (commits
4c2e57e,e1b7eec,9e9342e).
Summary
Adds an AWS Profile prompt context chip, mirroring the existing Kubernetes / git-branch chip pattern.
When the user types an AWS-related command (aws, aws-vault, awslocal, sam, eksctl, terraform, tofu, cdk, serverless/sls, chalice, copilot, amplify), the chip appears showing the active profile. Clicking it opens a searchable picker of profiles parsed from ~/.aws/config and ~/.aws/credentials. Selecting one emits a shell-appropriate command to switch profile.
Behavior
- Active profile resolution (matches what AWS SDKs honor):
AWS_VAULT→AWS_PROFILE→AWS_DEFAULT_PROFILE→default. - Tracked through precmd hooks, same path used by
virtualenv/conda/node_version/kube_config. Updates automatically afterexport AWS_PROFILE=...runs in the user's interactive shell. - Switch command is shell-aware:
- bash / zsh:
unset AWS_VAULT AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN; export AWS_PROFILE='...' - fish:
set -e VAR…; set -gx AWS_PROFILE '...'(fish has no standardunset/export) - PowerShell:
Remove-Item Env:VAR,… -ErrorAction SilentlyContinue; $env:AWS_PROFILE = '...'
- bash / zsh:
- The switch clears
AWS_VAULTand the temporary credential triplet (AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_SESSION_TOKEN) so that inside anaws-vault execsession the chip's display matches what the AWS SDK actually uses. - Single-quote escaping for both POSIX and PowerShell so profile names with metacharacters can't break out of the quoted context.
- The PowerShell profile-list parses
~/.aws/configand~/.aws/credentialsseparately, matching POSIX/fish behavior: inconfigonly[profile X]and[default]are profiles; incredentialsevery[X]is. sedinvocations on env-controlled paths use the--option delimiter to prevent paths beginning with-from being parsed as a sed program.
Files changed
app/src/context_chips/— newAwsProfilechip kind, menu, click handler, render function.app/src/terminal/model/— addsaws_profilefield toPrecmdValue,Block, andEnvironment.app/assets/bundled/bootstrap/{bash,zsh,fish}_body.sh— emitaws_profilein precmd JSON.app/src/themes/theme.rs— addsinput_prompt_awscolor (defaults to terminal yellow).
Test plan
- [x]
cargo check -p warp - [x]
cargo fmt --check -p warp - [x]
cargo clippy -p warp --no-deps - [x]
cargo test -p warp --lib context_chips::(66/66 pass) - [x] 8 unit tests for
format_aws_profile_commandcovering POSIX / fish / PowerShell / unknown-shell paths, single-quote escaping, metacharacter injection, vault-credentials clearing, and a negative assertion that fish never emitsunset/export - [ ] Manual: run
./script/run, typeaws s3 ls, verify chip appears with current profile - [ ] Manual: click chip, select different profile, verify chip updates after
exportruns - [ ] Manual: test in zsh, bash, and fish sessions
@rafet
I'm starting a first review of this pull request.
You can view the conversation on Warp.
I reviewed this pull request and requested human review from: @moirahuang.
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
@vkodithala thanks for the careful pass! All three points addressed in b8828bd:
-
Empty picker before
AWS_PROFILEis set — root-caused this to the chip's fingerprint being stable across early-bootstrap precmd cycles. If the on-click shell command failed during the first fetch (session not fully ready yet), the empty cached result stuck around until env-driven fingerprint change. AddedExternalCommandsState(flips once at bootstrap completion) to force a re-fetch after bootstrap, plusInvalidatingCommandCountwithwith_invalidate_on_commands(["aws", "aws-vault", "aws-profile", "aws2"])so new profiles added viaaws configureshow up too. -
Re-running export on current profile — went with the "omit current from picklist" alternative you mentioned. Picker now shows only profiles the user can switch to; selecting feels intentional.
-
Search bar with single profile — hidden when the AWS picker has ≤1 items. (After omitting the current profile, "1 item" is exactly when search becomes useless.)
Also addressed both inline nits — comment on Environment::new explaining the test-only narrow signature, and collapsed the identical GitBranch | AwsProfile arms in try_focus_open_menu.
PTAL.
Friendly bump @vkodithala — rebased on master to resolve the conflict (test file rename + new git-branch refactor). All three review points and both nits are addressed in 10db707; tests still pass. Ready for another look when you have a moment 🙏
Hey @rafet, thanks for the bump here! Apologies for the late re-review, was out-of-office last week and missed this. Taking a look!
Thanks @vkodithala! Moved the ShellType import to the top of the file in 2115b49. Ready for re-review 🙏
Rebased on master to resolve the conflicts that built up while waiting (test file renames + new CreateGitBranch struct). The 5 commits are unchanged in content, just replayed on top of latest master. Tests still pass (8/8 for the AWS-specific suite).
@vkodithala — could you take another look + approve when you have a moment? 🙏
Hi @rafet — a reviewer requested changes on this PR and it hasn't had activity from you in 7 days. When you get a chance, please push updates or reply to the review so a reviewer can take another look. Without activity, this PR will be automatically closed after 30 days of inactivity.
Hi @rafet — final reminder: a reviewer requested changes on this PR and it has been inactive for 10 days. It will be automatically closed in about 4 day(s) unless you push updates or reply. Maintainers can apply the no-autoclose label to keep it open.
Thanks @vkodithala, addressed all 3 in 6c146567:
1. Fish regression (the error): root-caused this to fish's set -e VAR1 VAR2 … returning exit 4 when any of the listed variables aren't set. For users who aren't inside an aws-vault session, the AWS credential triplet isn't set on the first click, so set -e exits non-zero and the chained set -gx (which actually does the work) succeeded but the overall command status was 4. Warp rendered that as a failed command. Fix: chain ; or true; after the erase so the overall exit reflects the subsequent set -gx. Verified locally:
$ fish -c "set -e AWS_VAULT AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN; or true; set -gx AWS_PROFILE 'prod'; echo profile=\$AWS_PROFILE"
profile=prod
exit: 0
2. terraform / tofu / cdk / serverless etc.: Agree — trimmed AWS_COMMANDS to AWS-only CLIs (aws, aws-vault, awslocal, sam, eksctl, copilot). GCP/Azure users running terraform plan will no longer see the chip.
3. Wildcard in format_aws_profile_command: replaced _ => with explicit Some(ShellType::Bash | ShellType::Zsh) | None => so the POSIX-branch shells are declared, and future variants won't silently fall in.
On the "new pane doesn't reflect the set": This is the same architectural property as the existing node_version / virtualenv / kube_config chips — set -gx / export mutates the current shell's env, not Warp's parent process or new sessions. A new pane spawns a fresh shell that re-reads $AWS_PROFILE from system/user-shell-rc, not from the previous session. Making selections persist across panes would require Warp to track and inject the env at session-spawn time, which feels like a separate, larger change than this PR. Happy to file a follow-up issue for it if useful.
Screen recordings for fish/bash/zsh coming separately — wanted to push the fix first so you can see the regression is gone. Will reply with them shortly.
Hi @rafet — a reviewer requested changes on this PR and it hasn't had activity from you in 7 days. When you get a chance, please push updates or reply to the review so a reviewer can take another look. Without activity, this PR will be automatically closed after 14 days of inactivity.
Hi @rafet — final reminder: a reviewer requested changes on this PR and it has been inactive for 10 days. It will be automatically closed in about 4 day(s) unless you push updates or reply. Maintainers can apply the no-autoclose label to keep it open.
@vkodithala
Hey @rafet, thanks for the ping and sorry for the delay here. Reviewing your PR now.
/oz-review
@vkodithala
I'm re-reviewing this pull request in response to a review request.
You can view the conversation on Warp.
I completed the review and no human review was requested for this pull request.
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
Hi @rafet — a reviewer requested changes on this PR and it hasn't had activity from you in 7 days. When you get a chance, please push updates or reply to the review so a reviewer can take another look. Without activity, this PR will be automatically closed after 14 days of inactivity.
Hi @rafet — final reminder: a reviewer requested changes on this PR and it has been inactive for 10 days. It will be automatically closed in about 4 day(s) unless you push updates or reply. Maintainers can apply the no-autoclose label to keep it open.