diff --git a/mac/VibeTunnel/Core/Services/SessionMonitor.swift b/mac/VibeTunnel/Core/Services/SessionMonitor.swift index 2b601b39..cb3a9503 100644 --- a/mac/VibeTunnel/Core/Services/SessionMonitor.swift +++ b/mac/VibeTunnel/Core/Services/SessionMonitor.swift @@ -36,6 +36,7 @@ struct ServerSessionInfo: Codable { let remoteId: String? let remoteName: String? let remoteUrl: String? + let attachedViaVT: Bool? var isRunning: Bool { status == "running" diff --git a/web/src/server/pty/pty-manager.ts b/web/src/server/pty/pty-manager.ts index 69186946..2b3f3119 100644 --- a/web/src/server/pty/pty-manager.ts +++ b/web/src/server/pty/pty-manager.ts @@ -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 diff --git a/web/src/shared/types.ts b/web/src/shared/types.ts index 65ba67eb..088724ef 100644 --- a/web/src/shared/types.ts +++ b/web/src/shared/types.ts @@ -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; } /**