Commit graph

112 commits

Author SHA1 Message Date
Peter Steinberger
d56d358090 linting 2025-06-20 18:16:42 +02:00
Mario Zechner
0b97181a04 Fix Ctrl+C signal handling and cross-server session compatibility
- Added proper PTY slave terminal configuration for signal interpretation
- Enabled ISIG flag so Ctrl+C generates SIGINT instead of being treated as text
- Configured ICANON and ECHO flags for proper terminal behavior
- Applied configuration in both child process code paths (manual dup2 and login_tty)

- Implemented hybrid proxy fallback system for cross-server session input
- Rust server now proxies input to Node.js server when pipe write fails
- Added reqwest HTTP client for seamless communication between servers
- Reduced pipe timeout to 1 second for faster fallback detection
- Added key translation for special keys when proxying to Node.js

This fixes both:
1. Ctrl+C not interrupting processes in Rust-created sessions
2. "Device not configured" errors when accessing Node.js sessions from Rust server

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-19 23:06:39 +02:00
Mario Zechner
47ccd26416 Fix server working directory corruption and remove duplicate PTY code
- Fixed sessionId calculation bug in asciinema stream-out events
- Removed ~400 lines of duplicate PTY code from term_socket.rs
- Created reusable spawn_with_pty_fallback function in tty_spawn.rs
- Fixed working directory isolation in session spawning threads
- Ensured static file serving works correctly after session creation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-19 21:25:49 +02:00
Peter Steinberger
978205da76 Add resize feature to Rust server 2025-06-19 14:32:14 +02:00
Peter Steinberger
83a4bf0f75
fix: apply formatters to pass CI checks (#19) 2025-06-19 01:39:27 +02:00
Mario Zechner
8553de6ae3 Fix exit event format in terminal sessions
- Change exit event from nested JSON to direct array format: ["exit", exit_code, session_id]
- Add StreamEvent::Exit variant to handle exit events properly in parsing
- Add write_raw_json method to StreamWriter for direct JSON output

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 22:04:13 +02:00
Peter Steinberger
d99ef041f7 feat: add integration tests and fix compatibility issues
- Add comprehensive integration test suite for Node.js server
  - API endpoint tests for session lifecycle, I/O operations, file system
  - WebSocket connection tests for hot reload functionality
  - Server lifecycle tests for initialization and shutdown
  - Basic binary availability tests for tty-fwd

- Fix Rust code for nix 0.30 API changes
  - Update dup2 calls to use OwnedFd instead of raw file descriptors
  - Fix read calls to pass file descriptors directly instead of raw fd
  - Remove deprecated as_raw_fd() calls where not needed

- Reorganize test structure
  - Split tests into unit/ and integration/ directories
  - Add separate Vitest configuration for integration tests
  - Create test utilities and setup files for both test types
  - Add custom test matchers for session validation

- Update test coverage configuration
  - Configure separate coverage for unit and integration tests
  - Add proper test timeouts for long-running integration tests
  - Use fork pool for integration tests to avoid port conflicts
2025-06-18 19:39:42 +02:00
Peter Steinberger
940ea236ba fix: update Rust code for nix 0.30 compatibility
- Update term_socket.rs and tty_spawn.rs to use new nix 0.30 API
- dup2() now requires OwnedFd references instead of raw file descriptors
- Add proper OwnedFd handling with std::mem::forget to prevent premature closing
- Ensure compatibility with updated nix crate API changes
2025-06-18 19:35:30 +02:00
Peter Steinberger
1ece7b2fd5 feat: add comprehensive unit tests for Rust server and update dependencies
- Add unit tests for protocol.rs (24 tests)
  - SessionInfo serialization/deserialization
  - AsciinemaHeader and event handling
  - StreamWriter UTF-8 and escape sequence processing

- Add unit tests for sessions.rs (23 tests)
  - Session listing and management
  - PID tracking and process lifecycle
  - Signal handling and cleanup operations
  - Named pipe operations with timeout protection

- Add unit tests for api_server.rs (12 tests)
  - API response serialization
  - MIME type detection
  - File operations and path resolution

- Add unit tests for http_server.rs (12 tests)
  - HTTP request parsing and response generation
  - Server-Sent Events (SSE) handling
  - Edge cases for malformed requests

- Update Rust dependencies
  - jiff: 0.1 -> 0.2
  - nix: 0.29.0 -> 0.30.1
  - Update term_socket.rs for nix 0.30 API changes

- Update npm dependencies
  - Express: ^4.18.2 -> ^5.1.0
  - Various dev dependencies updated

Test coverage: 24.22% overall (489/2019 lines)
- http_server.rs: 82.65% coverage
- sessions.rs: 76.88% coverage
- api_server.rs: 26.55% coverage
- protocol.rs: 5.48% coverage
2025-06-18 19:32:39 +02:00
Peter Steinberger
6a8f472832 feat: adopt Blacksmith CI runners and comprehensive updates
- Migrate GitHub Actions to Blacksmith runners for faster CI
  - Update ubuntu-latest to blacksmith-4vcpu-ubuntu-2404
  - Update actions/setup-node@v4 to useblacksmith/setup-node@v5
  - Update Swatinem/rust-cache@v2 to useblacksmith/rust-cache@v3

- Fix all linting warnings across all platforms
  - TypeScript: Fix any type warnings with proper type annotations
  - Rust: All clippy warnings resolved
  - Swift: Fix SwiftLint violations and format code

- Update all dependencies to latest versions
  - npm: Major updates including Express 5 compatibility fixes
  - Rust: Update 7 crates to latest compatible versions
  - Swift: Dependencies already up-to-date

- Add comprehensive test suite using Vitest
  - API endpoint tests for session CRUD operations
  - WebSocket connection and streaming tests
  - Session management lifecycle tests
  - Frontend component tests (terminal, session-list)
  - Critical functionality tests covering core features
  - Test infrastructure with proper mocking and utilities

- All tests passing, ready for production use
2025-06-18 19:10:03 +02:00
Peter Steinberger
915d3e3eb1 Fix remaining formatting issue in term_socket.rs 2025-06-18 15:26:10 +02:00
Peter Steinberger
4a0121eabe Fix Rust formatting and clippy warnings
- Fix cargo fmt formatting issues
- Fix unused variable warnings by prefixing with underscore
- Fix if_not_else clippy warning
- Fix uninlined_format_args warnings
- Fix redundant closure warning
2025-06-18 15:24:17 +02:00
Mario Zechner
e3e92c646d Remove debug logging from PTY child process
Removed eprintln\! statements that were cluttering stdout during PTY session creation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 14:43:38 +02:00
Mario Zechner
3fdad988ff Fix zombie process detection and add PTY-specific cleanup
- Update is_pid_alive to detect zombie processes (status 'Z') as dead
- Add spawn_type field to distinguish PTY vs socket sessions
- Add reap_zombies function to clean up zombie children
- Only attempt zombie reaping for PTY sessions to avoid interfering with osascript processes
- Fix session cleanup to work properly with zombie processes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 14:29:48 +02:00
Peter Steinberger
ef19211451 Fix clippy uninlined_format_args warnings
- Update format strings to use inline variable syntax
- Fix Linux CI clippy warnings for newer clippy version
2025-06-18 14:27:24 +02:00
Peter Steinberger
4cbbdf29fc Fix TIOCSCTTY usage for cross-platform compatibility
- Use proper type casting for ioctl on both Linux and non-Linux platforms
- Separate platform-specific code blocks for clarity
- Fix potential clippy warnings on Linux CI
2025-06-18 14:25:18 +02:00
Peter Steinberger
5f067c7a80 Fix clippy warnings and format code
- Fix redundant closure warning in api_server.rs
- Add backticks to login_tty in documentation comments
- All clippy warnings resolved
2025-06-18 14:16:43 +02:00
Peter Steinberger
f0658bccd0 improve bits for linux 2025-06-18 14:14:57 +02:00
Mario Zechner
2ceff6955c Make session kill endpoint wait for process death
- DELETE endpoint now waits up to 3 seconds for process to actually die
- Polls every 100ms to confirm process termination after SIGKILL
- Returns different messages based on whether process confirmed dead
- Makes is_pid_alive function public for reuse
- Provides more reliable session killing with proper status updates

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 14:01:43 +02:00
Peter Steinberger
db4b60e5f7 Fix CI: Apply cargo fmt to latest changes 2025-06-18 13:54:22 +02:00
Mario Zechner
779f8f3360 Fix session kill and add PTY PID tracking
- Update session.json status to "exited" when killing sessions via DELETE endpoint
- Set exit_code to 9 (SIGKILL) when process is killed
- Handle already-dead sessions by ensuring they're marked as "exited"
- Add PID tracking to PTY sessions so they can be properly killed
- Add reconnection detection in session-view: mark sessions as exited after 3 failed reconnects within 5 seconds

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 13:52:40 +02:00
Mario Zechner
c8931d1e40 Fix PTY streaming race condition and add exit events
- Add 5-second timeout when waiting for PTY stream-out file creation
- This prevents indefinite hanging when PTY background thread fails
- Send proper exit events to streaming clients when PTY process terminates
- Exit event format matches web frontend expectations: ["exit", exitCode, sessionId]
- Ensures web UI can properly handle session termination for PTY fallback

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 13:31:09 +02:00
Peter Steinberger
ec0bbcfdf4 Fix CI: Resolve all Clippy warnings and improve code quality
- Fixed redundant continue statements in loops
- Replaced manual string prefix stripping with strip_prefix method
- Fixed wildcard pattern that covered other patterns
- Removed redundant clone and unnecessary return value
- Used format string interpolation for cleaner code
- Removed unused imports and variables
- All Clippy checks now pass with -D warnings
2025-06-18 13:13:12 +02:00
Mario Zechner
68dd22e183 Fix session-view navigation for PTY fallback sessions
Change API response message from 'Terminal spawned successfully' to
'Session created successfully' for PTY fallback sessions. This allows
the web frontend to properly navigate to session-view instead of
treating it as a terminal window spawn.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 13:08:37 +02:00
Peter Steinberger
9b3839e361 Fix CI: Apply final Rust formatting 2025-06-18 13:07:37 +02:00
Peter Steinberger
6f20d395f5 Fix CI: Apply Clippy fixes and remove redundant continue statements
- Applied automatic Clippy fixes for better code quality
- Removed redundant continue statements at the end of match arms
- Fixed unused variable warnings by prefixing with underscore
- Applied cargo fmt to ensure consistent formatting
2025-06-18 13:06:06 +02:00
Mario Zechner
dd31dfb9f4 Fix compiler warnings in term_socket.rs
- Remove unused FromRawFd import
- Prefix unused parameters with underscore

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 13:05:46 +02:00
Mario Zechner
45f627fddf Add signal handling to update session statuses on server shutdown
- Add setup_shutdown_handler() to catch SIGTERM and SIGINT signals
- Create update_all_sessions_to_exited() to mark running sessions as exited
- Update handle_pty_session() to mark sessions as exited when PTY closes naturally
- Integrate signal handling into main server startup for both scenarios
- Ensures session.json files accurately reflect process state after server shutdown
- Fixes issue where sessions remain "running" after server restart or normal exit

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 13:04:52 +02:00
Peter Steinberger
2f4ca27b03 Fix CI: Format Swift and Rust code
- Fixed Swift formatting issues in AppConstants.swift and VibeTunnelApp.swift
- Fixed Rust formatting in tty-fwd source files
- CI should now pass formatting checks
2025-06-18 13:02:31 +02:00
Mario Zechner
1cef390ed6 Add PTY fallback to term_socket.rs with race condition fix
- Implements spawn_via_pty() function with complete bidirectional I/O
- Creates PTY master/slave, forks child process, handles stdin/stdout
- Fixes race condition by creating session.json synchronously before returning
- Background thread handles I/O operations while session metadata is immediate
- Enables cross-platform terminal functionality without requiring VibeTunnel.app

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 12:46:25 +02:00
Mario Zechner
18bb33c2ce Fix escape sequence corruption in asciinema cast output
Replace blind UTF-8 conversion with escape-sequence-aware processing:
- Add proper ANSI escape sequence parser (CSI, OSC, simple sequences)
- Buffer at escape sequence boundaries instead of arbitrary UTF-8 boundaries
- Preserve complete escape sequences as atomic units during conversion
- Only apply UTF-8 validation to text content between escape sequences
- Eliminates rendering artifacts in complex terminal applications like Claude

This maintains full JSON/asciinema compatibility while fixing the
fundamental issue where escape sequences were being corrupted by
UTF-8 validation during cast file generation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-18 08:23:09 +02:00
Peter Steinberger
e7480c3f59 Spawn new Terminal 2025-06-18 04:52:11 +02:00
Armin Ronacher
4fa8229b6f Add multiplex streaming 2025-06-17 21:18:15 +02:00
Armin Ronacher
f52001d831 Refactored into SSE helper 2025-06-17 20:31:34 +02:00
Armin Ronacher
e8b22949c8 Clean up parser 2025-06-17 20:16:28 +02:00
Armin Ronacher
78a5d1a77e Refactor thread spawning 2025-06-17 19:47:04 +02:00
Armin Ronacher
1b41fac4cf Cleanup reading of existing content 2025-06-17 18:43:22 +02:00
Armin Ronacher
19b545d8ba Simplify startup handling for the stream 2025-06-17 18:41:50 +02:00
Armin Ronacher
58932a535b Initial work for streaming refactor 2025-06-17 18:30:25 +02:00
Peter Steinberger
9642c7ed85 Add app-calling logic 2025-06-17 13:52:58 +02:00
Armin Ronacher
9e564fef00 Fixed unicode slicing 2025-06-17 13:28:58 +02:00
Armin Ronacher
11cc34d003 Refactor output writing 2025-06-17 13:02:17 +02:00
Armin Ronacher
f23dc80a38 spawn now works via the terminal once peter finishes that 2025-06-17 11:41:52 +02:00
Armin Ronacher
7ef07e61c5 Removed mod term 2025-06-17 11:28:13 +02:00
Armin Ronacher
34a2bcce49 Removed --spawn-terminal for now 2025-06-17 11:27:30 +02:00
Armin Ronacher
df13c82c64 Added --spawn-terminal experiment 2025-06-17 11:08:28 +02:00
Armin Ronacher
eee8a65450 Improved vt command to allow finding the current session 2025-06-17 09:56:21 +02:00
Peter Steinberger
e8f65b9121 Fix CI failures: platform-specific Rust code and Swift formatting 2025-06-17 01:36:12 +02:00
Peter Steinberger
12cef6f5c8 lint Rust 2025-06-17 01:03:29 +02:00
Armin Ronacher
4f29fd899e Remove unused heuristics for now 2025-06-17 00:33:45 +02:00