Prevent recursive VibeTunnel sessions (GitHub #95) (#104)

* Prevent recursive VibeTunnel sessions (GitHub #95)

Added detection and prevention of nested VibeTunnel sessions to avoid
recursive 'vt' command execution.

Changes:
- Set INSIDE_VIBETUNNEL and VIBETUNNEL_SESSION environment variables when creating PTY sessions
- Added check in vt script to detect if already inside a VibeTunnel session
- Shows helpful error message when recursive session is attempted

This prevents the confusing behavior where users could run 'vt' inside a
VibeTunnel session, creating nested terminal instances. Now users get a
clear error message explaining they're already in a VibeTunnel session.

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

Co-Authored-By: Claude <noreply@anthropic.com>

* Improve recursive session prevention based on PR feedback

- Consolidate to single environment variable VIBETUNNEL_SESSION_ID
- Add session ID for debugging purposes as requested
- Show session ID in error message for better user feedback
- Remove redundant environment variables (INSIDE_VIBETUNNEL, VIBETUNNEL_SESSION)

This addresses feedback from PR #104 to use a single, more informative
environment variable that serves both purposes: preventing recursion
and providing debugging information.

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Helmut Januschka 2025-06-27 21:05:36 +02:00 committed by GitHub
parent 9aaac17150
commit fc162ad55c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View file

@ -1,6 +1,13 @@
#!/bin/bash
# VibeTunnel CLI wrapper
# Check if we're already inside a VibeTunnel session
if [ -n "$VIBETUNNEL_SESSION_ID" ]; then
echo "Error: Already inside a VibeTunnel session (ID: $VIBETUNNEL_SESSION_ID). Recursive VibeTunnel sessions are not supported." >&2
echo "If you need to run commands, use them directly without the 'vt' prefix." >&2
exit 1
fi
# Try standard locations first, but verify the binary exists
APP_PATH=""
for TRY_PATH in "/Applications/VibeTunnel.app" "$HOME/Applications/VibeTunnel.app"; do

View file

@ -237,6 +237,8 @@ export class PtyManager extends EventEmitter {
const ptyEnv = {
...process.env,
TERM: term,
// Set session ID to prevent recursive vt calls and for debugging
VIBETUNNEL_SESSION_ID: sessionId,
};
// Debug log the spawn parameters