Commit b957102
committed
fix(opencode): isHealthy() must reject 401 to prevent stale-orphan adoption
The previous semantic 'response.statusCode === 401 || isHealthResponse(body)' allowed isHealthy() to return true even when the server rejected the manager's password. On IDE restart, this caused the new manager (with a fresh password Y2) to falsely adopt an orphan opencode-serve from the previous IDE session that was still running with the old password Y1. The SPA proxy then forwarded requests with Y2; opencode rejected with 401; the user saw 'Error: Unauthorized' loading the chat UI.
Fix: only treat the server as healthy when it returns a parseable health body (200 OK with {healthy:true, version:...}). 401 now returns false so doStart() falls through to killStaleServer(), which SIGKILLs the orphan and spawns a fresh opencode-serve with the current password.
If a future test or user genuinely needs 'adopt an external server with unknown password' semantic, the right path is to read the password from that external server's data dir / env, not to ignore auth failures.1 parent 5594814 commit b957102
2 files changed
Lines changed: 3 additions & 3 deletions
File tree
- src/vs/workbench/contrib/opencode
- electron-main
- test/electron-main
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
397 | | - | |
| 397 | + | |
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
424 | | - | |
| 424 | + | |
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
428 | | - | |
| 428 | + | |
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
| |||
0 commit comments