common-fate / granted

The easiest way to access your cloud.
https://granted.dev
MIT License
1.09k stars 95 forks source link

[bug] Granted opens a new instance of Chrome and still tries to make it frontmost (macOS) #439

Closed jaklan closed 1 year ago

jaklan commented 1 year ago

When I open AWS Console with granted (assume -c <ROLE-NAME>), the new, independent instance of Chrome appears:

image

Of course it would be much convenient to have it opened in a new tab, or at least - a new window, of the already running instance, but the biggest problem with the current behaviour is the fact that... each ~minute the new Chrome becomes the frontmost application (!!!).

That's very, very frustrating behaviour: imagine you use terminal / VSCode - and you are switched back to the granted-related instance of Chrome each minute. You answer an e-mail in "normal" Chrome - you are switched back. You do WHATEVER on your laptop - you are switched back. The only way to stop that behaviour is to kill completely that new instance, which means you can't keep AWS Console open in the background and you have to re-open it each time you want to use it.

granted settings (the default ones actually):

DefaultBrowser                  CHROME
CustomBrowserPath               /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
CustomSSOBrowserPath            /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
shwethaumashanker commented 1 year ago

Hey @jaklan! Sorry, you're facing this frustrating issue. I tried replicating it but couldn't reproduce the part where you get switched back to the granted-related Chrome instance every minute. To help me further, could you let me know the versions of Granted and Chrome you're using?

As a temporary fix, while we investigate, you can change your default browser from Chrome to another browser using the command: granted browser set. Hopefully, this will prevent the switching back issue.

jaklan commented 1 year ago

Hello @shwethaumashanker:

Tbh I have no idea what's the reason of that behaviour - the command which is triggered by granted:

  PID TTY           TIME CMD
25171 ??         0:04.56 /Applications/Google Chrome.app/Contents/MacOS/Google Chrome --user-data-dir=/Users/lanskij/.granted/chromium-profiles/1 --profile-directory=2280159318 --no-first-run --no-default-browser-check https://eu-central-1.signin.aws.amazon.com/federation?<parameters>

rather doesn't look suspicious... But I haven't verified the content of granted Chrome profile nor haven't done any A/B tests by removing the flags one by one.

Anyway - if granted allows to run the command in already opened window (which should be the case after removing the additional flags like --user-data-dir / --profile-directory / --no-first-run / --no-default-browser-check), I believe the issue would be solved. Correct me if I'm wrong, but it's not possible to achieve at the moment?

jaklan commented 1 year ago

Just made a quick test - I modified the above command to run it without --user-data-dir and --profile-directory flags and the AWS Console was opened in the current window. The issue seems to be related to the granted-specific Chrome profile then.

shwethaumashanker commented 1 year ago

@jaklan Thank you for investigating the issue and testing the different flags. Yes, you are right that currently, we are unable to modify the flags which are used to open the Chrome application. A potential quick fix to the problem could be changing your default browser in ~/.granted/config to:

DefaultBrowser = "OPEN"

This should open the AWS Console in your current window. Please let me know if that works for you!

jaklan commented 1 year ago

@shwethaumashanker thanks, it worked! I believe that option is not documented? Definitely worth to add it to docs then.

I would also keep the issue open to verify what could be the problem with granted-specific Chrome profile.