ccmanager 0.0.4 → 0.0.5
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.
|
@@ -55,6 +55,21 @@ export class SessionManager extends EventEmitter {
|
|
|
55
55
|
this.busyTimers.delete(sessionId);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
else if (currentState === 'waiting_input' &&
|
|
59
|
+
hasBottomBorder &&
|
|
60
|
+
!hasWaitingPrompt &&
|
|
61
|
+
wasWaitingWithBottomBorder) {
|
|
62
|
+
// We've already seen the bottom border for this waiting prompt,
|
|
63
|
+
// so transition to idle
|
|
64
|
+
newState = 'idle';
|
|
65
|
+
this.waitingWithBottomBorder.set(sessionId, false);
|
|
66
|
+
// Clear any pending busy timer
|
|
67
|
+
const existingTimer = this.busyTimers.get(sessionId);
|
|
68
|
+
if (existingTimer) {
|
|
69
|
+
clearTimeout(existingTimer);
|
|
70
|
+
this.busyTimers.delete(sessionId);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
58
73
|
else if (hasEscToInterrupt) {
|
|
59
74
|
// If "esc to interrupt" is present, set state to busy
|
|
60
75
|
newState = 'busy';
|
|
@@ -84,6 +99,18 @@ export class SessionManager extends EventEmitter {
|
|
|
84
99
|
// Keep current busy state for now
|
|
85
100
|
newState = 'busy';
|
|
86
101
|
}
|
|
102
|
+
else if (currentState === 'waiting_input') {
|
|
103
|
+
// If we're in waiting_input but no special patterns detected,
|
|
104
|
+
// transition to idle and clear the flag
|
|
105
|
+
newState = 'idle';
|
|
106
|
+
this.waitingWithBottomBorder.set(sessionId, false);
|
|
107
|
+
// Clear any pending busy timer
|
|
108
|
+
const existingTimer = this.busyTimers.get(sessionId);
|
|
109
|
+
if (existingTimer) {
|
|
110
|
+
clearTimeout(existingTimer);
|
|
111
|
+
this.busyTimers.delete(sessionId);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
87
114
|
return newState;
|
|
88
115
|
}
|
|
89
116
|
constructor() {
|
|
@@ -62,27 +62,16 @@ describe('SessionManager', () => {
|
|
|
62
62
|
const newState = sessionManager.detectSessionState(cleanData, currentState, mockSessionId);
|
|
63
63
|
expect(newState).toBe('busy');
|
|
64
64
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
// );
|
|
76
|
-
//
|
|
77
|
-
// // Now another bottom border appears
|
|
78
|
-
// const newState = sessionManager.detectSessionState(
|
|
79
|
-
// cleanData,
|
|
80
|
-
// currentState,
|
|
81
|
-
// mockSessionId,
|
|
82
|
-
// );
|
|
83
|
-
//
|
|
84
|
-
// expect(newState).toBe('idle'); // Should change to idle since we already saw the bottom border
|
|
85
|
-
// });
|
|
65
|
+
it('should not change from waiting_input when bottom border was already seen', () => {
|
|
66
|
+
const cleanData = '└───────────────────────┘';
|
|
67
|
+
const currentState = 'waiting_input';
|
|
68
|
+
vi.mocked(includesPromptBoxBottomBorder).mockReturnValue(true);
|
|
69
|
+
// First, simulate seeing waiting prompt with bottom border
|
|
70
|
+
sessionManager.detectSessionState('│ Do you want to continue?\n└───────────────────────┘', 'idle', mockSessionId);
|
|
71
|
+
// Now another bottom border appears
|
|
72
|
+
const newState = sessionManager.detectSessionState(cleanData, currentState, mockSessionId);
|
|
73
|
+
expect(newState).toBe('idle'); // Should change to idle since we already saw the bottom border
|
|
74
|
+
});
|
|
86
75
|
it('should clear waitingWithBottomBorder flag when transitioning to busy', () => {
|
|
87
76
|
const cleanData = 'Processing... Press ESC to interrupt';
|
|
88
77
|
const currentState = 'waiting_input';
|
|
@@ -95,29 +84,18 @@ describe('SessionManager', () => {
|
|
|
95
84
|
const newState = sessionManager.detectSessionState(cleanData, currentState, mockSessionId);
|
|
96
85
|
expect(newState).toBe('busy');
|
|
97
86
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
//
|
|
111
|
-
// // Now transition to idle
|
|
112
|
-
// vi.mocked(includesPromptBoxBottomBorder).mockReturnValue(false);
|
|
113
|
-
// const newState = sessionManager.detectSessionState(
|
|
114
|
-
// cleanData,
|
|
115
|
-
// currentState,
|
|
116
|
-
// mockSessionId,
|
|
117
|
-
// );
|
|
118
|
-
//
|
|
119
|
-
// expect(newState).toBe('idle');
|
|
120
|
-
// });
|
|
87
|
+
it('should clear waitingWithBottomBorder flag when transitioning to idle', () => {
|
|
88
|
+
const cleanData = 'Task completed successfully';
|
|
89
|
+
const currentState = 'waiting_input';
|
|
90
|
+
vi.mocked(includesPromptBoxBottomBorder).mockReturnValue(false);
|
|
91
|
+
// First set up waiting state with bottom border
|
|
92
|
+
vi.mocked(includesPromptBoxBottomBorder).mockReturnValue(true);
|
|
93
|
+
sessionManager.detectSessionState('│ Do you want to continue?\n└───────────────────────┘', 'idle', mockSessionId);
|
|
94
|
+
// Now transition to idle
|
|
95
|
+
vi.mocked(includesPromptBoxBottomBorder).mockReturnValue(false);
|
|
96
|
+
const newState = sessionManager.detectSessionState(cleanData, currentState, mockSessionId);
|
|
97
|
+
expect(newState).toBe('idle');
|
|
98
|
+
});
|
|
121
99
|
it('should transition from busy to idle after 500ms timer when no "esc to interrupt"', async () => {
|
|
122
100
|
// Create a mock session for the timer test
|
|
123
101
|
const mockWorktreePath = '/test/worktree';
|