Repository navigation
fix(server): resolve the configured shell for session terminals - #51052
Tsuki-hash wants to merge 2 commits into
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: |
|
Correcting what I wrote earlier, because I had the cause wrong twice and the accurate version is more useful to whoever triages this: |
|
Friendly nudge — checked against the current |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Fixes #51051 (#51051)
Type of change
What does this PR do?
shellis documented as the shell used for the interactive terminal, and both the shell tool(
shell.ts:263) andpty.ts:166resolve it throughShellSelect.Service. Session terminals did not:persistent-pty/index.ts:160falls back to the freeShellSelect.environment(), which reads onlyprocess.env.SHELLand passesundefinedin the slot where the configured options belong.process.env.SHELLis normally unset on Windows and the Windows branch ofselect()putspwsh/powershell first, so a Windows session terminal started PowerShell whatever
shellsaid, while theagent's own commands ran in the configured shell.
persistentPty.createnow resolves the configured shell and passes it down ascommand. It is resolvedin the handler rather than inside
PersistentPtydeliberately: PersistentPty is a process-global nodeand
ShellSelect.Serviceis Location-scoped, so the service cannot be yielded there —handlers/config.ts:21is the existing precedent for reaching it from a handler. Tell me if you wouldrather have it as a resolver option on the PersistentPty layer and I will move it.
An explicit
commandin the request payload still wins, and non-HTTP callers keep the old fallback.How did you verify your code works?
I did not run the repo checks: no Bun on this machine, so
bun typecheckandbun run checknever ran,and no session terminal was actually opened. What I traced, at
v2tip318a8c1:persistent-pty/index.ts:160is the only consumer ofShellSelect.environment(), and the TUI's New Terminal action (tui/src/context/session-terminals.tsx:78-86) sends nocommand, so the fallback is the live path.handlers.tsbuildsConfigHandlerandPersistentPtyHandlerin one list, androutes.ts:130replacesShellSelect.nodewith the configured variant, so the service a handler yields is the configured one.createcaller is the legacyhandlers/pty.ts:47, which already resolves config viapty.ts:166.packages/serveralready imports@opencode/core/shell/select(handlers/config.ts:2), so no new dependency direction.To confirm for real: set
"shell"to a Git Bash path on Windows, open a session terminal, and see that$PSVersionTableno longer answers.Screenshots / recordings
No UI change.
Checklist
"Tested locally" covers the source trace above and nothing more — the handler itself was not executed.