ccmanager 3.1.3 → 3.1.4
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.
|
@@ -157,4 +157,25 @@ describe('SessionManager - Auto Approval Recovery', () => {
|
|
|
157
157
|
expect(handler).toHaveBeenCalledWith(session);
|
|
158
158
|
sessionManager.off('sessionStateChanged', handler);
|
|
159
159
|
});
|
|
160
|
+
it('forces state to busy after auto-approval to prevent endless loop', async () => {
|
|
161
|
+
const session = await Effect.runPromise(sessionManager.createSessionWithPresetEffect('/test/path'));
|
|
162
|
+
const mockPty = mockPtyInstances.get('/test/path');
|
|
163
|
+
expect(mockPty).toBeDefined();
|
|
164
|
+
const handler = vi.fn();
|
|
165
|
+
sessionManager.on('sessionStateChanged', handler);
|
|
166
|
+
// Advance to pending_auto_approval state
|
|
167
|
+
vi.advanceTimersByTime(STATE_CHECK_INTERVAL_MS * 3 + STATE_PERSISTENCE_DURATION_MS);
|
|
168
|
+
expect(session.state).toBe('pending_auto_approval');
|
|
169
|
+
// Wait for handleAutoApproval promise chain to fully resolve
|
|
170
|
+
await vi.waitFor(() => {
|
|
171
|
+
expect(session.state).toBe('busy');
|
|
172
|
+
});
|
|
173
|
+
expect(session.pendingState).toBeUndefined();
|
|
174
|
+
expect(session.pendingStateStart).toBeUndefined();
|
|
175
|
+
// Verify Enter key was sent to approve
|
|
176
|
+
expect(mockPty.write).toHaveBeenCalledWith('\r');
|
|
177
|
+
// Verify sessionStateChanged was emitted
|
|
178
|
+
expect(handler).toHaveBeenCalledWith(expect.objectContaining({ state: 'busy' }));
|
|
179
|
+
sessionManager.off('sessionStateChanged', handler);
|
|
180
|
+
});
|
|
160
181
|
});
|
|
@@ -91,6 +91,12 @@ export class SessionManager extends EventEmitter {
|
|
|
91
91
|
logger.info(`[${session.id}] Auto-approval granted, simulating user permission`);
|
|
92
92
|
session.autoApprovalReason = undefined;
|
|
93
93
|
session.process.write('\r');
|
|
94
|
+
// Force state to busy to prevent endless auto-approval
|
|
95
|
+
// when the state detection still sees pending_auto_approval
|
|
96
|
+
session.state = 'busy';
|
|
97
|
+
session.pendingState = undefined;
|
|
98
|
+
session.pendingStateStart = undefined;
|
|
99
|
+
this.emit('sessionStateChanged', session);
|
|
94
100
|
}
|
|
95
101
|
})
|
|
96
102
|
.catch((error) => {
|