Restore attachedViaVT property to distinguish VibeTunnel sessions

- Add attachedViaVT to SessionInfo interface to identify nested sessions
- Set attachedViaVT=true when VIBETUNNEL_SESSION_ID env var is present
- Add property to Swift ServerSessionInfo for API compatibility
- Allows distinguishing between direct terminal sessions and those spawned from within VibeTunnel
This commit is contained in:
Peter Steinberger 2025-07-27 15:13:23 +02:00
parent 03c5638f21
commit d75e2ffd76
3 changed files with 11 additions and 0 deletions

View file

@ -36,6 +36,7 @@ struct ServerSessionInfo: Codable {
let remoteId: String?
let remoteName: String?
let remoteUrl: String?
let attachedViaVT: Bool?
var isRunning: Bool {
status == "running"

View file

@ -335,6 +335,9 @@ export class PtyManager extends EventEmitter {
logger.debug(chalk.blue(`Creating PTY session with command: ${resolvedCommand.join(' ')}`));
logger.debug(`Working directory: ${workingDir}`);
// Check if this session is being spawned from within VibeTunnel
const attachedViaVT = !!process.env.VIBETUNNEL_SESSION_ID;
// Create initial session info with resolved command
const sessionInfo: SessionInfo = {
id: sessionId,
@ -354,6 +357,7 @@ export class PtyManager extends EventEmitter {
gitHasChanges: options.gitHasChanges,
gitIsWorktree: options.gitIsWorktree,
gitMainRepoPath: options.gitMainRepoPath,
attachedViaVT,
};
// Save initial session info

View file

@ -84,6 +84,12 @@ export interface SessionInfo {
gitStagedCount?: number; // Number of staged files
gitAddedCount?: number; // Number of added files
gitDeletedCount?: number; // Number of deleted files
/**
* Whether this session was spawned from within VibeTunnel itself.
* Used to distinguish between direct terminal sessions and nested VibeTunnel sessions.
* Sessions with attachedViaVT=true are spawned from within an existing VibeTunnel session.
*/
attachedViaVT?: boolean;
}
/**