mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 04:15:52 +00:00
feat(cliproxy): default session persistence for CLIProxy
CLIProxy now persists by default after terminal closes: - Spawn proxy with detached mode (survives terminal close) - Remove auto-kill on Claude exit (proxy keeps running) - Add `ccs cliproxy stop` to explicitly terminate proxy - Add `ccs cliproxy status` to show running proxy info Closes #129
This commit is contained in:
1 parent
7d03933f44
commit
a7450bdffe
3 files changed
+172
-50
No files matched your search
@@ -60,6 +60,7 @@ import {
|
||||
saveUnifiedConfig,
|
||||
} from '../config/unified-config-loader';
|
||||
import { isUnifiedConfigEnabled } from '../config/feature-flags';
|
||||
import { stopProxy, getProxyStatus } from '../cliproxy/session-tracker';
|
||||
|
||||
// ============================================================================
|
||||
// PROFILE MANAGEMENT
|
||||
@@ -804,6 +805,20 @@ async function showHelp(): Promise<void> {
|
||||
}
|
||||
console.log('');
|
||||
|
||||
// Proxy Lifecycle Commands
|
||||
console.log(subheader('Proxy Lifecycle:'));
|
||||
const lifecycleCmds: [string, string][] = [
|
||||
['status', 'Show running CLIProxy status'],
|
||||
['stop', 'Stop running CLIProxy instance'],
|
||||
];
|
||||
const maxLifecycleLen = Math.max(...lifecycleCmds.map(([cmd]) => cmd.length));
|
||||
for (const [cmd, desc] of lifecycleCmds) {
|
||||
console.log(` ${color(cmd.padEnd(maxLifecycleLen + 2), 'command')} ${desc}`);
|
||||
}
|
||||
console.log('');
|
||||
console.log(dim(' Note: CLIProxy now persists by default. Use "stop" to terminate.'));
|
||||
console.log('');
|
||||
|
||||
// Binary Commands
|
||||
console.log(subheader('Binary Commands:'));
|
||||
const binaryCmds: [string, string][] = [
|
||||
@@ -1041,6 +1056,62 @@ async function installLatest(verbose: boolean): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// PROXY LIFECYCLE COMMANDS
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Handle 'ccs cliproxy stop' - Stop running CLIProxy instance
|
||||
*/
|
||||
async function handleStop(): Promise<void> {
|
||||
await initUI();
|
||||
|
||||
console.log(header('Stop CLIProxy'));
|
||||
console.log('');
|
||||
|
||||
const result = stopProxy();
|
||||
|
||||
if (result.stopped) {
|
||||
console.log(ok(`CLIProxy stopped (PID ${result.pid})`));
|
||||
if (result.sessionCount && result.sessionCount > 0) {
|
||||
console.log(info(`${result.sessionCount} active session(s) were disconnected`));
|
||||
}
|
||||
} else {
|
||||
console.log(warn(result.error || 'Failed to stop CLIProxy'));
|
||||
}
|
||||
console.log('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle 'ccs cliproxy status' - Show running proxy status
|
||||
*/
|
||||
async function handleProxyStatus(): Promise<void> {
|
||||
await initUI();
|
||||
|
||||
console.log(header('CLIProxy Status'));
|
||||
console.log('');
|
||||
|
||||
const status = getProxyStatus();
|
||||
|
||||
if (status.running) {
|
||||
console.log(` Status: ${color('Running', 'success')}`);
|
||||
console.log(` PID: ${status.pid}`);
|
||||
console.log(` Port: ${status.port}`);
|
||||
console.log(` Sessions: ${status.sessionCount || 0} active`);
|
||||
if (status.startedAt) {
|
||||
const started = new Date(status.startedAt);
|
||||
console.log(` Started: ${started.toLocaleString()}`);
|
||||
}
|
||||
console.log('');
|
||||
console.log(dim('To stop: ccs cliproxy stop'));
|
||||
} else {
|
||||
console.log(` Status: ${color('Not running', 'warning')}`);
|
||||
console.log('');
|
||||
console.log(dim('CLIProxy starts automatically when you run ccs gemini, codex, etc.'));
|
||||
}
|
||||
console.log('');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// MAIN ROUTER
|
||||
// ============================================================================
|
||||
@@ -1074,6 +1145,17 @@ export async function handleCliproxyCommand(args: string[]): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle proxy lifecycle commands
|
||||
if (command === 'stop') {
|
||||
await handleStop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (command === 'status') {
|
||||
await handleProxyStatus();
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle --install <version>
|
||||
const installIdx = args.indexOf('--install');
|
||||
if (installIdx !== -1) {
|
||||
|
||||
Reference in new issue
Block a user