-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add one liner for trying library #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
+674
−0
Conversation
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
- Add bin/ghostty-web.js with inline HTML, WebSocket server, and PTY support - Implement minimal WebSocket server using only Node.js built-ins (no deps) - Single file implementation (~624 lines, 16KB) - Auto-opens browser to http://localhost:8080 - Usage: npx ghostty-web All functionality inlined: - HTML template with styling - Minimal WebSocket protocol implementation - PTY session handler using child_process.spawn - HTTP file server for library and WASM - Graceful shutdown handling Size impact: +16KB bin script only (package stays dependency-free)
- Pass -i flag to bash/zsh for interactive mode - Shell now displays prompt and responds to commands - Fixes issue where terminal loaded but no shell appeared
- Send \n when WebSocket connects to trigger prompt display - Add console logging for debugging data flow - Shell now displays prompt immediately on connection
- Hardcode port 8080 in client-side WebSocket URL - Fixes syntax error: Invalid or unexpected token - Template literal was incorrectly interpolating server-side variable
- Change \\n to \\\\n in source (4 backslashes) - Outputs \\n in HTML (valid JS string with newline char) - Fixes: Uncaught SyntaxError: Invalid or unexpected token
- Add route for __vite-browser-external-2447137e.js - Log actual received data for debugging - Fixes 404 error for vite internal file
- Move newline trigger from client to server-side - Send to ptyProcess.stdin.write() after 100ms - Should properly trigger shell prompt display
- Use 'script -qfc' to create proper PTY instead of plain spawn - Filter OSC sequences (window title) that were causing artifacts - Pass COLUMNS and LINES env vars for terminal size - Matches working implementation in demo/server/pty-server.ts
- Send stty cols/rows command after spawn to set initial size - Handle resize messages with stty command instead of no-op - Clear screen after initial stty to hide command echo - Matches demo/server/pty-server.ts implementation
- Log client-side input being sent - Log server-side input being received - Helps debug vim keyboard issues (0, 15gg not working)
- Copy HTML/CSS/JS verbatim from working demo - Remove debug logging from client-side - Use exact same Terminal initialization - Use exact same WebSocket handling - Should fix vim keyboard issues (0, 15gg, etc)
- Wrap stderr in red escape codes like demo - Remove debug logging that might interfere - Server code now matches demo/server/pty-server.ts output handling
- Known issue: vim commands like 0, 15gg don't work - Suspected cause: MinimalWebSocket implementation bug - Working demo with Bun WebSocket works fine - Document workaround and potential fixes
- Log raw WebSocket data received (hex) - Log parsed frame details (opcode, payload) - Log data written to PTY stdin - Log data sent from PTY stdout to client - Will help identify where vim '0' command is lost
BUG: Characters like '0' are valid JSON and would parse successfully, then be ignored because they're not resize messages. FIX: Check if parsed JSON is an object with type='resize' first. Always fall through to treating data as terminal input unless it's explicitly a control message. This fixes vim commands like 0, gg, etc that were being dropped.
Bug is fixed, remove verbose logging to keep output clean
Complete working implementation of npx ghostty-web demo launcher
Fixes lint errors: - Use for...of instead of forEach in emit() - Use for...of instead of forEach in cleanup()
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.
No description provided.