ccmanager 2.9.0 → 2.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,11 @@ import { shortcutManager } from '../services/shortcutManager.js';
4
4
  const Session = ({ session, sessionManager, onReturnToMenu, }) => {
5
5
  const { stdout } = useStdout();
6
6
  const [isExiting, setIsExiting] = useState(false);
7
+ const stripOscColorSequences = (input) => {
8
+ // Remove default foreground/background color OSC sequences that Codex emits
9
+ // These sequences leak as literal text when replaying buffered output
10
+ return input.replace(/\x1B\](?:10|11);[^\x07\x1B]*(?:\x07|\x1B\\)/g, '');
11
+ };
7
12
  useEffect(() => {
8
13
  if (!stdout)
9
14
  return;
@@ -17,7 +22,7 @@ const Session = ({ session, sessionManager, onReturnToMenu, }) => {
17
22
  const buffer = restoredSession.outputHistory[i];
18
23
  if (!buffer)
19
24
  continue;
20
- const str = buffer.toString('utf8');
25
+ const str = stripOscColorSequences(buffer.toString('utf8'));
21
26
  // Skip clear screen sequences at the beginning
22
27
  if (i === 0 && (str.includes('\x1B[2J') || str.includes('\x1B[H'))) {
23
28
  // Skip this buffer or remove the clear sequence
@@ -25,11 +30,13 @@ const Session = ({ session, sessionManager, onReturnToMenu, }) => {
25
30
  .replace(/\x1B\[2J/g, '')
26
31
  .replace(/\x1B\[H/g, '');
27
32
  if (cleaned.length > 0) {
28
- stdout.write(Buffer.from(cleaned, 'utf8'));
33
+ stdout.write(cleaned);
29
34
  }
30
35
  }
31
36
  else {
32
- stdout.write(buffer);
37
+ if (str.length > 0) {
38
+ stdout.write(str);
39
+ }
33
40
  }
34
41
  }
35
42
  }
@@ -93,9 +100,7 @@ const Session = ({ session, sessionManager, onReturnToMenu, }) => {
93
100
  if (isExiting)
94
101
  return;
95
102
  // Check for return to menu shortcut
96
- const returnToMenuShortcut = shortcutManager.getShortcuts().returnToMenu;
97
- const shortcutCode = shortcutManager.getShortcutCode(returnToMenuShortcut);
98
- if (shortcutCode && data === shortcutCode) {
103
+ if (shortcutManager.matchesRawInput('returnToMenu', data)) {
99
104
  // Disable focus reporting mode before returning to menu
100
105
  if (stdout) {
101
106
  stdout.write('\x1b[?1004l');
@@ -7,8 +7,10 @@ export declare class ShortcutManager {
7
7
  private isReservedKey;
8
8
  saveShortcuts(shortcuts: ShortcutConfig): boolean;
9
9
  getShortcuts(): ShortcutConfig;
10
+ private getRawShortcutCodes;
10
11
  matchesShortcut(shortcutName: keyof ShortcutConfig, input: string, key: Key): boolean;
11
12
  getShortcutDisplay(shortcutName: keyof ShortcutConfig): string;
12
13
  getShortcutCode(shortcut: ShortcutKey): string | null;
14
+ matchesRawInput(shortcutName: keyof ShortcutConfig, input: string): boolean;
13
15
  }
14
16
  export declare const shortcutManager: ShortcutManager;
@@ -60,6 +60,51 @@ export class ShortcutManager {
60
60
  getShortcuts() {
61
61
  return configurationManager.getShortcuts();
62
62
  }
63
+ getRawShortcutCodes(shortcut) {
64
+ const codes = new Set();
65
+ // Direct control-code form (e.g. Ctrl+E -> \u0005)
66
+ const controlCode = this.getShortcutCode(shortcut);
67
+ if (controlCode) {
68
+ codes.add(controlCode);
69
+ }
70
+ // Escape key in raw mode
71
+ if (shortcut.key === 'escape' &&
72
+ !shortcut.ctrl &&
73
+ !shortcut.alt &&
74
+ !shortcut.shift) {
75
+ codes.add('\u001b');
76
+ }
77
+ // Kitty/xterm extended keyboard sequences (CSI <code>;<mod>u)
78
+ if (shortcut.ctrl &&
79
+ !shortcut.alt &&
80
+ !shortcut.shift &&
81
+ shortcut.key.length === 1) {
82
+ const lower = shortcut.key.toLowerCase();
83
+ const upperCode = lower.toUpperCase().charCodeAt(0);
84
+ const lowerCode = lower.charCodeAt(0);
85
+ // Include the CSI u format (ESC[<code>;5u) used by Kitty/WezTerm for Ctrl+letters.
86
+ if (upperCode >= 32 && upperCode <= 126) {
87
+ codes.add(`\u001b[${upperCode};5u`);
88
+ }
89
+ if (lowerCode !== upperCode && lowerCode >= 32 && lowerCode <= 126) {
90
+ codes.add(`\u001b[${lowerCode};5u`);
91
+ }
92
+ // Tmux/xterm with modifyOtherKeys emit ESC[27;5;<code>~ for the same shortcut.
93
+ if (upperCode >= 32 && upperCode <= 126) {
94
+ codes.add(`\u001b[27;5;${upperCode}~`);
95
+ }
96
+ if (lowerCode !== upperCode && lowerCode >= 32 && lowerCode <= 126) {
97
+ codes.add(`\u001b[27;5;${lowerCode}~`);
98
+ }
99
+ // Some setups (issue #82/#107 repros) send ESC[1;5<letter>; include both upper/lower.
100
+ const upperKey = lower.toUpperCase();
101
+ codes.add(`\u001b[1;5${upperKey}`);
102
+ if (upperKey !== lower) {
103
+ codes.add(`\u001b[1;5${lower}`);
104
+ }
105
+ }
106
+ return Array.from(codes);
107
+ }
63
108
  matchesShortcut(shortcutName, input, key) {
64
109
  const shortcuts = configurationManager.getShortcuts();
65
110
  const shortcut = shortcuts[shortcutName];
@@ -115,5 +160,13 @@ export class ShortcutManager {
115
160
  }
116
161
  return null;
117
162
  }
163
+ matchesRawInput(shortcutName, input) {
164
+ const shortcuts = configurationManager.getShortcuts();
165
+ const shortcut = shortcuts[shortcutName];
166
+ if (!shortcut)
167
+ return false;
168
+ const codes = this.getRawShortcutCodes(shortcut);
169
+ return codes.some(code => input === code || input.includes(code));
170
+ }
118
171
  }
119
172
  export const shortcutManager = new ShortcutManager();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ import { describe, expect, it, beforeEach, afterEach, vi } from 'vitest';
2
+ import { shortcutManager } from './shortcutManager.js';
3
+ import { configurationManager } from './configurationManager.js';
4
+ describe('shortcutManager.matchesRawInput', () => {
5
+ const shortcuts = {
6
+ returnToMenu: { ctrl: true, key: 'e', alt: false, shift: false },
7
+ cancel: { ctrl: true, key: 'c', alt: false, shift: false },
8
+ };
9
+ beforeEach(() => {
10
+ vi.spyOn(configurationManager, 'getShortcuts').mockReturnValue(shortcuts);
11
+ });
12
+ afterEach(() => {
13
+ vi.restoreAllMocks();
14
+ });
15
+ it('matches classic control code', () => {
16
+ expect(shortcutManager.matchesRawInput('returnToMenu', '\u0005')).toBe(true);
17
+ });
18
+ it('matches CSI u sequence', () => {
19
+ expect(shortcutManager.matchesRawInput('returnToMenu', '\u001b[69;5u')).toBe(true);
20
+ });
21
+ it('matches modifyOtherKeys sequence', () => {
22
+ expect(shortcutManager.matchesRawInput('returnToMenu', '\u001b[27;5;69~')).toBe(true);
23
+ });
24
+ it('matches CSI 1;5<key>', () => {
25
+ expect(shortcutManager.matchesRawInput('returnToMenu', '\u001b[1;5E')).toBe(true);
26
+ });
27
+ it('ignores unrelated input', () => {
28
+ expect(shortcutManager.matchesRawInput('returnToMenu', 'hello')).toBe(false);
29
+ });
30
+ });
@@ -48,6 +48,10 @@ export class ClaudeStateDetector extends BaseStateDetector {
48
48
  content.includes('│ Would you like')) {
49
49
  return 'waiting_input';
50
50
  }
51
+ // Check for "Do you want" pattern with options (e.g., "Do you want...\n...Yes")
52
+ if (/do you want.+\n.*yes/.test(lowerContent)) {
53
+ return 'waiting_input';
54
+ }
51
55
  // Check for busy state
52
56
  if (lowerContent.includes('esc to interrupt')) {
53
57
  return 'busy';
@@ -153,6 +153,46 @@ describe('ClaudeStateDetector', () => {
153
153
  expect(state).toBe('busy');
154
154
  }
155
155
  });
156
+ it('should detect waiting_input when "Do you want" with options prompt is present', () => {
157
+ // Arrange
158
+ terminal = createMockTerminal([
159
+ 'Some previous output',
160
+ 'Do you want to make this edit to test.txt?',
161
+ '❯ 1. Yes',
162
+ '2. Yes, allow all edits during this session (shift+tab)',
163
+ '3. No, and tell Claude what to do differently (esc)',
164
+ ]);
165
+ // Act
166
+ const state = detector.detectState(terminal, 'idle');
167
+ // Assert
168
+ expect(state).toBe('waiting_input');
169
+ });
170
+ it('should detect waiting_input when "Do you want" with options prompt is present (case insensitive)', () => {
171
+ // Arrange
172
+ terminal = createMockTerminal([
173
+ 'Some output',
174
+ 'DO YOU WANT to make this edit?',
175
+ '❯ 1. YES',
176
+ '2. NO',
177
+ ]);
178
+ // Act
179
+ const state = detector.detectState(terminal, 'idle');
180
+ // Assert
181
+ expect(state).toBe('waiting_input');
182
+ });
183
+ it('should prioritize "Do you want" with options over busy state', () => {
184
+ // Arrange
185
+ terminal = createMockTerminal([
186
+ 'Press ESC to interrupt',
187
+ 'Do you want to continue?',
188
+ '❯ 1. Yes',
189
+ '2. No',
190
+ ]);
191
+ // Act
192
+ const state = detector.detectState(terminal, 'idle');
193
+ // Assert
194
+ expect(state).toBe('waiting_input'); // waiting_input should take precedence
195
+ });
156
196
  });
157
197
  });
158
198
  describe('GeminiStateDetector', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccmanager",
3
- "version": "2.9.0",
3
+ "version": "2.9.2",
4
4
  "description": "TUI application for managing multiple Claude Code sessions across Git worktrees",
5
5
  "license": "MIT",
6
6
  "author": "Kodai Kabasawa",