mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-18 06:14:07 +00:00
fix(cliproxy): register session on dashboard start and add port-based stop fallback
Dashboard Stop/Update buttons failed with contradictory errors: - Stop: "No active CLIProxy session found" - Update: "CLIProxy was already running" Root cause: service-manager spawned proxy but never called registerSession(), so stopProxy() couldn't find the lock file. Changes: - service-manager.ts: Add registerSession() after spawn - session-tracker.ts: Make stopProxy() async with port-based fallback - routes.ts: Update proxy-stop endpoint to async - cliproxy-command.ts: Update handleStop() to await async stopProxy() - port-utils.ts: Fix double-escaped regex for Windows port detection - session-tracker.test.js: Update tests for async stopProxy()
This commit is contained in:
1 parent
f1dfd69a4a
commit
a3b172cc43
6 files changed
+47
-12
No files matched your search
@@ -299,13 +299,13 @@ describe('Session Tracker', function () {
|
||||
});
|
||||
|
||||
describe('stopProxy', function () {
|
||||
it('should return error when no lock exists', function () {
|
||||
const result = stopProxy();
|
||||
it('should return error when no lock exists', async function () {
|
||||
const result = await stopProxy();
|
||||
assert.strictEqual(result.stopped, false);
|
||||
assert.strictEqual(result.error, 'No active CLIProxy session found');
|
||||
});
|
||||
|
||||
it('should cleanup stale lock when proxy is not running', function () {
|
||||
it('should cleanup stale lock when proxy is not running', async function () {
|
||||
// Create lock with dead PID
|
||||
const lock = {
|
||||
port: testPort,
|
||||
@@ -315,7 +315,7 @@ describe('Session Tracker', function () {
|
||||
};
|
||||
fs.writeFileSync(sessionLockPath, JSON.stringify(lock));
|
||||
|
||||
const result = stopProxy();
|
||||
const result = await stopProxy();
|
||||
assert.strictEqual(result.stopped, false);
|
||||
assert.ok(result.error.includes('not running'));
|
||||
assert.strictEqual(fs.existsSync(sessionLockPath), false);
|
||||
|
||||
Reference in new issue
Block a user