forked from devartifex/copilot-unleashed
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.ts
More file actions
33 lines (28 loc) · 993 Bytes
/
Copy pathinit.ts
File metadata and controls
33 lines (28 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { startSessionWatcher, stopSessionWatcher } from './session-watcher.js';
import { broadcastToAll } from './ws/session-pool.js';
import { config } from './config.js';
import { resolve } from 'node:path';
import { homedir } from 'node:os';
let initialized = false;
export function initServerSideEffects(): void {
if (initialized) return;
initialized = true;
// Start session filesystem watcher for CLI ↔ Browser autosync (best-effort)
try {
const copilotDir = config.copilotConfigDir || resolve(homedir(), '.copilot');
const sessionStatePath = resolve(copilotDir, 'session-state');
startSessionWatcher(sessionStatePath, () => {
broadcastToAll({ type: 'sessions_changed' });
});
} catch (err) {
console.warn(
'[INIT] Session watcher failed to start:',
err instanceof Error ? err.message : err,
);
}
const shutdown = () => {
stopSessionWatcher();
};
process.on('SIGTERM', shutdown);
process.on('SIGINT', shutdown);
}