Add shellshare serve command for combined local server + client#102
Open
vitorbaptista wants to merge 4 commits intomasterfrom
Open
Add shellshare serve command for combined local server + client#102vitorbaptista wants to merge 4 commits intomasterfrom
shellshare serve command for combined local server + client#102vitorbaptista wants to merge 4 commits intomasterfrom
Conversation
This adds a new `serve` subcommand that starts a local server and broadcasts the terminal to it in a single command, eliminating the need to run server and client separately for local sharing. Options: --host/-H: Bind address (default: 127.0.0.1) --port/-p: Listen port (default: 5000) --stdin: Read from stdin instead of spawning a shell The server automatically shuts down when the session ends. https://claude.ai/code/session_01HsviQhQjYdFSDSU7mpZmXw
When running `shellshare serve`, GET / now serves the room viewer page instead of the home page. This means visitors can go to http://localhost:5000 and see the terminal directly. Implementation: - Add `ServerConfig` struct with optional `serve_room` field - In serve mode, inject `window.SHELLSHARE_ROOM` into room.html so the JS knows which room to join regardless of URL path - Display clean base URL (http://localhost:5000) in output - Regular `shellshare server` is unaffected (serve_room: None) https://claude.ai/code/session_01HsviQhQjYdFSDSU7mpZmXw
- Fix XSS vulnerability: room name was injected unescaped into a <script> tag.
Replace with a JSON config block (<script type="application/json">) that is
safely parsed via JSON.parse, eliminating any injection vector.
- Replace brittle HTML string manipulation (replacen("<script>", ...)) with a
proper template placeholder ({{ROOM_CONFIG}}) and a shared render_room_page()
helper that serves both the index and room page handlers.
- Extract stream_and_cleanup() to eliminate duplicated stdin/script mode logic
between cli::run() and serve::run().
- Ensure tokio runtime shuts down on all code paths (error and success) by
moving shutdown_background() after the streaming result.
- Fix flaky test: replace port 1 (environment-dependent) with non-routable
192.0.2.1 (TEST-NET-1, RFC 5737) for reliable failure.
https://claude.ai/code/session_01B5yx7NLnwqDWtvjR5JdtJ8
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.
This adds a new
servesubcommand that starts a local server andbroadcasts the terminal to it in a single command, eliminating the
need to run server and client separately for local sharing.
Options:
--host/-H: Bind address (default: 127.0.0.1)
--port/-p: Listen port (default: 5000)
--stdin: Read from stdin instead of spawning a shell
The server automatically shuts down when the session ends.
https://claude.ai/code/session_01HsviQhQjYdFSDSU7mpZmXw