feat: add PTY_WEB_AUTOSTART environment variable support for V1 and V2 (#60) - #62
Open
kumar-shivang wants to merge 1 commit into
Open
kumar-shivang wants to merge 1 commit into
kumar-shivang wants to merge 1 commit into
Conversation
…hekohex#60) - Add `PTYServer.isAutostartEnabled()` supporting `PTY_WEB_AUTOSTART` and alias `PTY_AUTOSTART` - Autostart Web UI server on OpenCode V1 plugin initialization when enabled - Fallback to `PTY_WEB_AUTOSTART` in OpenCode V2 when `options.autostart` is not explicitly configured - Share and coordinate `PTYServer` singleton instance between V1 and V2 adapters - Document `PTY_WEB_AUTOSTART` in README Environment Variables and V2 options tables - Add unit tests for V1 and V2 autostart lifecycle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #60
Motivation
As reported in #60, users running OpenCode (especially in V1 or via scripts configuring
PTY_WEB_PORT) want to keep the Web UI open in a browser tab and view or interact with running PTY sessions without needing to wait or manually trigger/pty-open-background-spyor/pty-show-server-url.In V1, the server was previously only instantiated on-demand when executing those slash commands. In V2,
autostartwas only configurable viactx.options.autostartinopencode.jsonand did not inspect environment variables.Summary of Changes
PTY_WEB_AUTOSTARTEnvironment Variable:PTYServer.isAutostartEnabled()helper supportingPTY_WEB_AUTOSTARTand aliasPTY_AUTOSTART(true,1,yes,on).src/plugin.ts):PTYServerduring plugin setup if autostart is enabled.src/v2/index.ts):PTYServer.isAutostartEnabled()whenoptions.autostartis not explicitly provided inctx.options.options.autostart: falsein config continues to take precedence over the environment variable.PTYServer, delegating cleanly between V1 and V2.PTY_WEB_AUTOSTARTinREADME.mdunder### Environment Variablesand updated the V2 options table.test/v1.test.tsverifying V1 autostart lifecycle and server reuse.test/v2.test.tscovering environment variable autostart and explicit config overrides.