-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathspawn-calls.js
More file actions
145 lines (126 loc) · 3.6 KB
/
Copy pathspawn-calls.js
File metadata and controls
145 lines (126 loc) · 3.6 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/**
* Spawn multiple simulated call windows
* This script opens 4 Electron BrowserWindows, each showing a different platform's call UI
*/
const { app, BrowserWindow, screen, ipcMain } = require('electron');
const path = require('path');
// Prevent multiple instances
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
app.quit();
process.exit(0);
}
const windows = [];
function createCallWindow(platform, htmlFile, x, y, callerName, callerContext, callType = 'video') {
const win = new BrowserWindow({
width: 380,
height: 420,
x,
y,
resizable: false,
frame: false,
alwaysOnTop: true,
skipTaskbar: false,
show: false,
transparent: false,
vibrancy: 'hud',
visualEffectState: 'active',
backgroundColor: platform === 'facetime' ? '#1c1c1e' :
platform === 'teams' ? '#292929' :
platform === 'slack' ? '#1a1d21' : '#0d1117',
hasShadow: true,
titleBarStyle: 'hidden',
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
preload: path.join(__dirname, 'src/main/preload-sim.js'),
},
});
const params = new URLSearchParams({
name: callerName,
context: callerContext,
type: callType,
});
win.loadFile(htmlFile, { query: Object.fromEntries(params) });
win.once('ready-to-show', () => {
win.show();
});
windows.push(win);
return win;
}
app.whenReady().then(() => {
const primaryDisplay = screen.getPrimaryDisplay();
const { width: screenWidth, height: screenHeight } = primaryDisplay.workAreaSize;
const winWidth = 380;
const winHeight = 420;
const padding = 40;
// Calculate positions for 4 windows
const positions = {
// Top-left: Teams
teams: { x: padding, y: padding },
// Top-right: Slack
slack: { x: screenWidth - winWidth - padding, y: padding },
// Bottom-left: FaceTime
facetime: { x: padding, y: screenHeight - winHeight - padding },
// Bottom-right: Agent
agent: { x: screenWidth - winWidth - padding, y: screenHeight - winHeight - padding },
};
// Spawn all windows
createCallWindow(
'teams',
path.join(__dirname, 'src/renderer/call-teams.html'),
positions.teams.x,
positions.teams.y,
'Sarah Chen',
'Engineering standup',
'video'
);
createCallWindow(
'slack',
path.join(__dirname, 'src/renderer/call-slack.html'),
positions.slack.x,
positions.slack.y,
'Mike Johnson',
'#product-launch'
);
createCallWindow(
'facetime',
path.join(__dirname, 'src/renderer/call-facetime.html'),
positions.facetime.x,
positions.facetime.y,
'Copilot',
'iPhone',
'video'
);
createCallWindow(
'agent',
path.join(__dirname, 'src/renderer/call-agent.html'),
positions.agent.x,
positions.agent.y,
'Copilot Agent',
'Ready to assist with your task'
);
console.log('✅ Spawned 4 call simulation windows');
});
// Handle accept/decline from renderer
ipcMain.handle('accept-simulated-call', (event, platform, callerName) => {
console.log(`✅ Accepted call from ${platform}: ${callerName}`);
// Close all windows
windows.forEach(win => {
if (!win.isDestroyed()) win.close();
});
app.quit();
});
ipcMain.handle('decline-simulated-call', (event, platform) => {
console.log(`❌ Declined call from ${platform}`);
// Just close that window
const win = BrowserWindow.fromWebContents(event.sender);
if (win && !win.isDestroyed()) win.close();
// If all windows closed, quit
if (windows.every(w => w.isDestroyed())) {
app.quit();
}
});
app.on('window-all-closed', () => {
app.quit();
});