Skip to content

Commit 99e00d8

Browse files
authored
Merge pull request #96 from grimmerk/fix/codev-terminal-detection
fix: detect CodeV embedded terminal sessions correctly
2 parents f750fcc + 68e85cc commit 99e00d8

4 files changed

Lines changed: 48 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 1.0.63
4+
5+
- Fix: Terminal tab sessions correctly detected as CODEV (not parent terminal)
6+
- Click Terminal tab session → switches to Term tab instead of external terminal
7+
38
## 1.0.62
49

510
- Feat: session status hooks — colored dots for working (pulse) / idle / needs-attention (blink)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "CodeV",
33
"productName": "CodeV",
4-
"version": "1.0.62",
4+
"version": "1.0.63",
55
"description": "Quick switcher for VS Code, Cursor, and Claude Code sessions",
66
"repository": {
77
"type": "git",

src/claude-session-utility.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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+
771802
export const openSessionInITerm2 = (
772803
sessionId: string,
773804
projectPath: string,

src/main.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
invalidateSessionCache,
2626
loadSessionEnrichment,
2727
loadLastAssistantResponses,
28+
setCodevTerminalCallback,
2829
} from './claude-session-utility';
2930
import {
3031
installHooks,
@@ -1059,6 +1060,15 @@ const trayToggleEvtHandler = async () => {
10591060
console.log('when ready');
10601061
}
10611062

1063+
// Set callback for CodeV embedded terminal sessions
1064+
setCodevTerminalCallback((_sessionId: string) => {
1065+
showSwitcherWindow();
1066+
// Send after show to ensure window exists and is ready
1067+
setTimeout(() => {
1068+
switcherWindow?.webContents.send('switch-to-terminal');
1069+
}, 50);
1070+
});
1071+
10621072
// Pre-initialize aiAssistantWindow for faster first open
10631073
// This is done after mainWindow is created, but before showing it
10641074
// so that initial startup isn't slowed down

0 commit comments

Comments
 (0)