Skip to content

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

Merged
Brendonovich merged 4 commits into
anomalyco:devfrom
OpeOginni:fix/desktop-terminal-auth
Mar 12, 2026
Merged

fix(desktop): set default WebSocket username and prevent repeated calling of terminal spawn properly closing the terminal#17061
Brendonovich merged 4 commits into
anomalyco:devfrom
OpeOginni:fix/desktop-terminal-auth

Conversation

@OpeOginni

@OpeOginniOpeOginni commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

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

OpeOginni commented Mar 11, 2026

Copy link
Copy Markdown
ContributorAuthor

@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
Copy Markdown
ContributorAuthor

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.

@Brendonovich
Brendonovich merged commit c9c0318 into anomalyco:devMar 12, 2026
8 checks passed
@OpeOginni
OpeOginni deleted the fix/desktop-terminal-auth branch March 12, 2026 06:55
ChicK00o pushed a commit to ChicK00o/opencode that referenced this pull request Mar 12, 2026
demostanis pushed a commit to demostanis/opencode that referenced this pull request Mar 19, 2026
demostanis pushed a commit to demostanis/opencode that referenced this pull request Mar 20, 2026
balcsida pushed a commit to balcsida/opencode that referenced this pull request Mar 24, 2026
balcsida pushed a commit to balcsida/opencode that referenced this pull request Apr 8, 2026
RobertWsp pushed a commit to RobertWsp/opencode that referenced this pull request Apr 16, 2026
xywsxp pushed a commit to xywsxp/opencode that referenced this pull request Apr 24, 2026
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request May 5, 2026
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
avion23 pushed a commit to avion23/opencode that referenced this pull request Jun 10, 2026
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request Jun 14, 2026
MarsQiu007 referenced this pull request in MarsQiu007/openNovel Jul 31, 2026
…ling of terminal spawn properly closing the terminal (#17061)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop Terminal Fails when Authed Server username is not passed

2 participants

@OpeOginni@Brendonovich