Skip to content

Conversation

fioan89
Copy link
Collaborator

@fioan89 fioan89 commented Sep 5, 2025

The default behavior for coder login --token <token> is to:

  • use the provided token temporarily to authenticate the login process
  • generate a new session token and stores that for future CLI use
  • the original token provided is not stored or reused

The Coder Recent projects view polls every 5 seconds for workspaces from multiple Coder deployment. The polling process also involves a call to the cli.login. The cli is later used to start workspaces if users click on a project for which the workspace is stopped. Instead of generating a new token each time we login we can use the coder login --use-token-as-session --token <token> which:

  • uses the provided token directly as the session token
  • stores the original token for future CLI commands
  • no new token is generated

Additionally the login can be called on demand, only when a "recent" project is stopped and the user wants to start it. This PR reduces a lot of overhead associated with spawning cli commands every 5 seconds.

The default behavior for `coder login --token <token>` is to:
- use the provided token temporarily to authenticate the login process
- generate a new session token and stores that for future CLI use
- the original token provided is not stored or reused

The Coder `Recent projects` view polls every 5 seconds for workspaces from
multiple Coder deployment. The polling process also involves a call
to the `cli.login`. The cli is later used start workspaces if user clicks on
a project for which the workspace is stopped. Instead of generating a new token
each time we login we can use the `coder login --use-token-as-session --token <token>` which:
- uses the provided token directly as the session token
- stores the original token for future CLI commands
- no new token is generated
The Coder `Recent projects` view polls every 5 seconds for workspaces from
multiple Coder deployment. The polling process also involves a call
to the `cli.login`. The cli is later used to start workspaces if a user clicks on
a project for which the workspace is stopped. The login can be called on demand, only
when a "recent" project is stopped and the user wants to start it. This commit
reduces a lot of overhead associated with spawning cli commands every 5 seconds.
Copy link
Contributor

github-actions bot commented Sep 5, 2025

Qodana Community for JVM

33 new problems were found

Inspection name Severity Problems
Usage of API marked for removal 🔴 Failure 13
Local 'var' is never modified and can be declared as 'val' 🔶 Warning 1
Incorrect string capitalization 🔶 Warning 1
Constant conditions 🔶 Warning 1
Usage of redundant or deprecated syntax or deprecated symbols 🔶 Warning 1
Throwable not thrown 🔶 Warning 1
Redundant nullable return type 🔶 Warning 1
Unused symbol 🔶 Warning 1
Convert 'object' to 'data object' ◽️ Notice 5
Class member can have 'private' visibility ◽️ Notice 3
String concatenation that can be converted to string template ◽️ Notice 2
Argument could be converted to 'Set' to improve performance ◽️ Notice 1
Return or assignment can be lifted out ◽️ Notice 1
Redundant lambda arrow ◽️ Notice 1

💡 Qodana analysis was run in the pull request mode: only the changed files were checked

View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

  1. Register at Qodana Cloud and configure the action
  2. Use GitHub Code Scanning with Qodana
  3. Host Qodana report at GitHub Pages
  4. Inspect and use qodana.sarif.json (see the Qodana SARIF format for details)

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/qodana-action@v2023.3.2
        with:
          upload-result: true
Contact Qodana team

Contact us at qodana-support@jetbrains.com

@fioan89 fioan89 requested a review from matifali September 5, 2025 21:10
Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

Fantastic!

@fioan89 fioan89 merged commit 66e470f into main Sep 8, 2025
6 checks passed
@fioan89 fioan89 deleted the fix-dont-create-new-api-keys-for-each-polling branch September 8, 2025 16:13
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.

JetBrains Gateway requests new API key every ~5 seconds
2 participants