Skip to content

fix(desktop): set default WebSocket username and prevent repeated calling of terminal spawn properly closing the terminal#17061

Open
OpeOginni wants to merge 4 commits intoanomalyco:devfrom
OpeOginni:fix/desktop-terminal-auth
Open

fix(desktop): set default WebSocket username and prevent repeated calling of terminal spawn properly closing the terminal#17061
OpeOginni wants to merge 4 commits intoanomalyco:devfrom
OpeOginni:fix/desktop-terminal-auth

Conversation

@OpeOginni
Copy link
Contributor

@OpeOginni OpeOginni commented Mar 11, 2026

Issue for this PR

Closes #17058

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Currently if you dont pass in a username when adding an authenticated opencode server, the desktop tries to spawn and connect to the terminal ws without a username and causes a 401 error. Also when this happens rather than the terminal closing it just keeps trying to connect to the terminal ws causing the desktop to attack the server till it crashes.

This PR does the following

  • Adds a fallback "opencode" username when the setup server username was not added in.
  • Username is pre-filled with "opencode" by default when user is adding in a new server.

How did you verify your code works?

Tested on my local machine, with a remote opencode server running on railway and connecting to it on my local dev desktop build with the changes.

Screenshots / recordings

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…ling of terminal spawn properly closing the terminal
@OpeOginni
Copy link
Contributor Author

OpeOginni commented Mar 11, 2026

@adamdotdevin I might need your input in here.

  1. The PR removed the terminal.clone and made it a terminal.close when we receive an error because it kept on retrying when it was an authentication error which wont be resolved until the user passes in the right credentials. Should I change it to only close on 401 (auth error), but clone on others as it was before?

  2. Rather than hardcode the fallback like we have right now, would it be better to have username compulsory in the add server dialog, making the value "opencode" the default there, making sure that if a user passes in a password a username must be passed in as well?

Im thinking if we can solve number 2 and make sure that a username is passed, the initial server health check can cover everything including the terminal spawning, meaning it might never have a 401 error and not need to close, and that way we keep the terminal.clone logic

@OpeOginni
Copy link
Contributor Author

I decided to go ahead and implement 2, so the "opencode" username is set be default, but the fallback on the websocket connection side is still there.

I reverted back to the terminal.clone logic, since an auth error should not be possible now, BUT I feel like it might still be needed having a close operation used when there is an auth error preventing cloning over and over and over when the issue is is authentication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop Terminal Fails when Authed Server username is not passed

1 participant