ccmanager 0.0.2 → 0.0.3
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.
|
@@ -43,17 +43,11 @@ export class SessionManager extends EventEmitter {
|
|
|
43
43
|
}
|
|
44
44
|
else if (currentState === 'waiting_input' &&
|
|
45
45
|
hasBottomBorder &&
|
|
46
|
-
!hasWaitingPrompt
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
// First time seeing bottom border, keep waiting state
|
|
54
|
-
newState = 'waiting_input';
|
|
55
|
-
this.waitingWithBottomBorder.set(sessionId, true);
|
|
56
|
-
}
|
|
46
|
+
!hasWaitingPrompt &&
|
|
47
|
+
!wasWaitingWithBottomBorder) {
|
|
48
|
+
// Keep the waiting state and mark that we've seen the bottom border
|
|
49
|
+
newState = 'waiting_input';
|
|
50
|
+
this.waitingWithBottomBorder.set(sessionId, true);
|
|
57
51
|
// Clear any pending busy timer
|
|
58
52
|
const existingTimer = this.busyTimers.get(sessionId);
|
|
59
53
|
if (existingTimer) {
|
|
@@ -90,14 +84,6 @@ export class SessionManager extends EventEmitter {
|
|
|
90
84
|
// Keep current busy state for now
|
|
91
85
|
newState = 'busy';
|
|
92
86
|
}
|
|
93
|
-
else if (!hasWaitingPrompt && !hasEscToInterrupt && !hasBottomBorder) {
|
|
94
|
-
// No special prompts or indicators, transition to idle
|
|
95
|
-
newState = 'idle';
|
|
96
|
-
// Clear the waiting flag when transitioning to idle
|
|
97
|
-
if (currentState === 'waiting_input') {
|
|
98
|
-
this.waitingWithBottomBorder.set(sessionId, false);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
87
|
return newState;
|
|
102
88
|
}
|
|
103
89
|
constructor() {
|
|
@@ -62,16 +62,27 @@ describe('SessionManager', () => {
|
|
|
62
62
|
const newState = sessionManager.detectSessionState(cleanData, currentState, mockSessionId);
|
|
63
63
|
expect(newState).toBe('busy');
|
|
64
64
|
});
|
|
65
|
-
it('should not change from waiting_input when bottom border was already seen', () => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
// it('should not change from waiting_input when bottom border was already seen', () => {
|
|
66
|
+
// const cleanData = '└───────────────────────┘';
|
|
67
|
+
// const currentState: SessionState = 'waiting_input';
|
|
68
|
+
// vi.mocked(includesPromptBoxBottomBorder).mockReturnValue(true);
|
|
69
|
+
//
|
|
70
|
+
// // First, simulate seeing waiting prompt with bottom border
|
|
71
|
+
// sessionManager.detectSessionState(
|
|
72
|
+
// '│ Do you want to continue?\n└───────────────────────┘',
|
|
73
|
+
// 'idle',
|
|
74
|
+
// mockSessionId,
|
|
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
|
+
// });
|
|
75
86
|
it('should clear waitingWithBottomBorder flag when transitioning to busy', () => {
|
|
76
87
|
const cleanData = 'Processing... Press ESC to interrupt';
|
|
77
88
|
const currentState = 'waiting_input';
|
|
@@ -84,18 +95,29 @@ describe('SessionManager', () => {
|
|
|
84
95
|
const newState = sessionManager.detectSessionState(cleanData, currentState, mockSessionId);
|
|
85
96
|
expect(newState).toBe('busy');
|
|
86
97
|
});
|
|
87
|
-
it('should clear waitingWithBottomBorder flag when transitioning to idle', () => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
// it('should clear waitingWithBottomBorder flag when transitioning to idle', () => {
|
|
99
|
+
// const cleanData = 'Task completed successfully';
|
|
100
|
+
// const currentState: SessionState = 'waiting_input';
|
|
101
|
+
// vi.mocked(includesPromptBoxBottomBorder).mockReturnValue(false);
|
|
102
|
+
//
|
|
103
|
+
// // First set up waiting state with bottom border
|
|
104
|
+
// vi.mocked(includesPromptBoxBottomBorder).mockReturnValue(true);
|
|
105
|
+
// sessionManager.detectSessionState(
|
|
106
|
+
// '│ Do you want to continue?\n└───────────────────────┘',
|
|
107
|
+
// 'idle',
|
|
108
|
+
// mockSessionId,
|
|
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
|
+
// });
|
|
99
121
|
it('should transition from busy to idle after 500ms timer when no "esc to interrupt"', async () => {
|
|
100
122
|
// Create a mock session for the timer test
|
|
101
123
|
const mockWorktreePath = '/test/worktree';
|
|
@@ -103,6 +125,7 @@ describe('SessionManager', () => {
|
|
|
103
125
|
id: mockSessionId,
|
|
104
126
|
worktreePath: mockWorktreePath,
|
|
105
127
|
state: 'busy',
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
106
129
|
process: {},
|
|
107
130
|
output: [],
|
|
108
131
|
outputHistory: [],
|
|
@@ -131,6 +154,7 @@ describe('SessionManager', () => {
|
|
|
131
154
|
id: mockSessionId,
|
|
132
155
|
worktreePath: mockWorktreePath,
|
|
133
156
|
state: 'busy',
|
|
157
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
134
158
|
process: {},
|
|
135
159
|
output: [],
|
|
136
160
|
outputHistory: [],
|