@@ -185,6 +185,13 @@ export const detectTerminalApp = async (pid: number): Promise<string> => {
185185 if ( ! comm ) break ;
186186
187187 const commLower = comm . toLowerCase ( ) ;
188+ // CodeV's embedded terminal (node-pty runs under Electron)
189+ if ( commLower . includes ( 'codev' ) ) return 'codev' ;
190+ // Check if this Electron process is CodeV by inspecting command line
191+ if ( commLower . includes ( 'electron' ) ) {
192+ const cmdline = ( await execPromise ( `ps -o command= -p ${ currentPid } 2>/dev/null` ) ) . trim ( ) ;
193+ if ( cmdline . toLowerCase ( ) . includes ( 'codev' ) ) return 'codev' ;
194+ }
188195 if ( commLower . includes ( 'iterm' ) || commLower . includes ( 'iterm2' ) ) return 'iterm2' ;
189196 if ( commLower . includes ( 'cmux' ) ) return 'cmux' ;
190197 if ( commLower . includes ( 'ghostty' ) ) return 'ghostty' ;
@@ -578,7 +585,7 @@ end tell`);
578585
579586 // Ghostty + unknown terminals: cwd fallback (no async work, runs after cross-ref)
580587 for ( const [ terminal , items ] of Object . entries ( byTerminal ) ) {
581- if ( terminal === 'iterm2' || terminal === 'cmux' || terminal === 'terminal' ) continue ;
588+ if ( terminal === 'iterm2' || terminal === 'cmux' || terminal === 'terminal' || terminal === 'codev' ) continue ;
582589 for ( const item of items ) {
583590 const fallback = item . candidates . find ( s => ! activeMap . has ( s . sessionId ) ) ;
584591 if ( fallback ) {
@@ -747,6 +754,10 @@ export const openSession = async (
747754 }
748755
749756 switch ( effectiveTerminal ) {
757+ case 'codev' :
758+ // Session is in CodeV's embedded terminal — notify renderer to switch to Term tab
759+ openSessionInCodeV ( sessionId ) ;
760+ break ;
750761 case 'cmux' :
751762 openSessionInCmux ( sessionId , projectPath , isActive , activePid , customTitle ) ;
752763 break ;
@@ -768,6 +779,26 @@ export const openSession = async (
768779 * If the session is already active, switch to its tab
769780 * Otherwise, open a new tab and run claude --resume
770781 */
782+ /**
783+ * Callback for opening sessions in CodeV's embedded terminal.
784+ * Set by main.ts to avoid circular dependency.
785+ */
786+ let codevTerminalCallback : ( ( sessionId : string ) => void ) | null = null ;
787+
788+ export const setCodevTerminalCallback = ( cb : ( sessionId : string ) => void ) => {
789+ codevTerminalCallback = cb ;
790+ } ;
791+
792+ /**
793+ * "Open" a session that's running in CodeV's embedded terminal.
794+ * Switches to the Terminal tab instead of opening an external terminal.
795+ */
796+ export const openSessionInCodeV = ( sessionId : string ) : void => {
797+ if ( codevTerminalCallback ) {
798+ codevTerminalCallback ( sessionId ) ;
799+ }
800+ } ;
801+
771802export const openSessionInITerm2 = (
772803 sessionId : string ,
773804 projectPath : string ,
0 commit comments