Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
528dfe01a1 | ||
|
|
fb6c8e3fc0 | ||
|
|
76d6fc2749 | ||
|
|
2f013b4751 | ||
|
|
66dce4415a | ||
|
|
6460349fc7 |
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "cheating-daddy",
|
"name": "cheating-daddy",
|
||||||
"productName": "cheating-daddy",
|
"productName": "cheating-daddy",
|
||||||
"version": "0.5.6",
|
"version": "0.5.11",
|
||||||
"description": "cheating daddy",
|
"description": "cheating daddy",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -19,8 +19,8 @@
|
|||||||
"cheating daddy ai assistant for interviews"
|
"cheating daddy ai assistant for interviews"
|
||||||
],
|
],
|
||||||
"author": {
|
"author": {
|
||||||
"name": "sohzm",
|
"name": "ShiftyX1",
|
||||||
"email": "sohambharambe9@gmail.com"
|
"email": "lead@pyserve.org"
|
||||||
},
|
},
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { HelpView } from '../views/HelpView.js';
|
|||||||
import { HistoryView } from '../views/HistoryView.js';
|
import { HistoryView } from '../views/HistoryView.js';
|
||||||
import { AssistantView } from '../views/AssistantView.js';
|
import { AssistantView } from '../views/AssistantView.js';
|
||||||
import { OnboardingView } from '../views/OnboardingView.js';
|
import { OnboardingView } from '../views/OnboardingView.js';
|
||||||
|
import { ScreenPickerDialog } from '../views/ScreenPickerDialog.js';
|
||||||
|
|
||||||
export class CheatingDaddyApp extends LitElement {
|
export class CheatingDaddyApp extends LitElement {
|
||||||
static styles = css`
|
static styles = css`
|
||||||
@@ -112,6 +113,8 @@ export class CheatingDaddyApp extends LitElement {
|
|||||||
_storageLoaded: { state: true },
|
_storageLoaded: { state: true },
|
||||||
aiProvider: { type: String },
|
aiProvider: { type: String },
|
||||||
modelInfo: { type: Object },
|
modelInfo: { type: Object },
|
||||||
|
showScreenPicker: { type: Boolean },
|
||||||
|
screenSources: { type: Array },
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -137,6 +140,8 @@ export class CheatingDaddyApp extends LitElement {
|
|||||||
this._storageLoaded = false;
|
this._storageLoaded = false;
|
||||||
this.aiProvider = 'gemini';
|
this.aiProvider = 'gemini';
|
||||||
this.modelInfo = { model: '', visionModel: '', whisperModel: '' };
|
this.modelInfo = { model: '', visionModel: '', whisperModel: '' };
|
||||||
|
this.showScreenPicker = false;
|
||||||
|
this.screenSources = [];
|
||||||
|
|
||||||
// Load from storage
|
// Load from storage
|
||||||
this._loadFromStorage();
|
this._loadFromStorage();
|
||||||
@@ -549,6 +554,16 @@ export class CheatingDaddyApp extends LitElement {
|
|||||||
<div class="view-container">${this.renderCurrentView()}</div>
|
<div class="view-container">${this.renderCurrentView()}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
${this.showScreenPicker
|
||||||
|
? html`
|
||||||
|
<screen-picker-dialog
|
||||||
|
?visible=${this.showScreenPicker}
|
||||||
|
.sources=${this.screenSources}
|
||||||
|
@source-selected=${this.handleSourceSelected}
|
||||||
|
@cancelled=${this.handlePickerCancelled}
|
||||||
|
></screen-picker-dialog>
|
||||||
|
`
|
||||||
|
: ''}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -579,6 +594,44 @@ export class CheatingDaddyApp extends LitElement {
|
|||||||
|
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async showScreenPickerDialog() {
|
||||||
|
const { ipcRenderer } = window.require('electron');
|
||||||
|
const result = await ipcRenderer.invoke('get-screen-sources');
|
||||||
|
|
||||||
|
if (result.success) {
|
||||||
|
this.screenSources = result.sources;
|
||||||
|
this.showScreenPicker = true;
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
this._screenPickerResolve = resolve;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.error('Failed to get screen sources:', result.error);
|
||||||
|
return { cancelled: true };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async handleSourceSelected(event) {
|
||||||
|
const { source } = event.detail;
|
||||||
|
const { ipcRenderer } = window.require('electron');
|
||||||
|
|
||||||
|
// Tell main process which source was selected
|
||||||
|
await ipcRenderer.invoke('set-selected-source', source.id);
|
||||||
|
|
||||||
|
this.showScreenPicker = false;
|
||||||
|
if (this._screenPickerResolve) {
|
||||||
|
this._screenPickerResolve({ source });
|
||||||
|
this._screenPickerResolve = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handlePickerCancelled() {
|
||||||
|
this.showScreenPicker = false;
|
||||||
|
if (this._screenPickerResolve) {
|
||||||
|
this._screenPickerResolve({ cancelled: true });
|
||||||
|
this._screenPickerResolve = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define('cheating-daddy-app', CheatingDaddyApp);
|
customElements.define('cheating-daddy-app', CheatingDaddyApp);
|
||||||
|
|||||||
@@ -0,0 +1,175 @@
|
|||||||
|
import { html, css, LitElement } from '../../assets/lit-core-2.7.4.min.js';
|
||||||
|
|
||||||
|
export class ScreenPickerDialog extends LitElement {
|
||||||
|
static properties = {
|
||||||
|
sources: { type: Array },
|
||||||
|
visible: { type: Boolean },
|
||||||
|
};
|
||||||
|
|
||||||
|
static styles = css`
|
||||||
|
:host {
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.8);
|
||||||
|
z-index: 10000;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
:host([visible]) {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog {
|
||||||
|
background: var(--background-color);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 24px;
|
||||||
|
max-width: 800px;
|
||||||
|
max-height: 80vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
margin: 0 0 16px 0;
|
||||||
|
color: var(--text-color);
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sources-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-item {
|
||||||
|
background: var(--input-background);
|
||||||
|
border: 2px solid transparent;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-item:hover {
|
||||||
|
border-color: var(--border-default);
|
||||||
|
background: var(--button-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-item.selected {
|
||||||
|
border-color: var(--accent-color);
|
||||||
|
background: var(--button-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-thumbnail {
|
||||||
|
width: 100%;
|
||||||
|
height: 120px;
|
||||||
|
object-fit: contain;
|
||||||
|
background: #1a1a1a;
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-name {
|
||||||
|
color: var(--text-color);
|
||||||
|
font-size: 13px;
|
||||||
|
text-align: center;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.buttons {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
background: var(--button-background);
|
||||||
|
color: var(--text-color);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 3px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 13px;
|
||||||
|
transition: background-color 0.1s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
background: var(--button-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
button.primary {
|
||||||
|
background: var(--accent-color);
|
||||||
|
color: white;
|
||||||
|
border-color: var(--accent-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
button.primary:hover {
|
||||||
|
background: var(--accent-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
button:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.sources = [];
|
||||||
|
this.visible = false;
|
||||||
|
this.selectedSource = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectSource(source) {
|
||||||
|
this.selectedSource = source;
|
||||||
|
this.requestUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
confirm() {
|
||||||
|
if (this.selectedSource) {
|
||||||
|
this.dispatchEvent(
|
||||||
|
new CustomEvent('source-selected', {
|
||||||
|
detail: { source: this.selectedSource },
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cancel() {
|
||||||
|
this.dispatchEvent(new CustomEvent('cancelled'));
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return html`
|
||||||
|
<div class="dialog">
|
||||||
|
<h2>Choose screen or window to share</h2>
|
||||||
|
<div class="sources-grid">
|
||||||
|
${this.sources.map(
|
||||||
|
source => html`
|
||||||
|
<div
|
||||||
|
class="source-item ${this.selectedSource?.id === source.id ? 'selected' : ''}"
|
||||||
|
@click=${() => this.selectSource(source)}
|
||||||
|
>
|
||||||
|
<img class="source-thumbnail" src="${source.thumbnail}" alt="${source.name}" />
|
||||||
|
<div class="source-name">${source.name}</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div class="buttons">
|
||||||
|
<button @click=${this.cancel}>Cancel</button>
|
||||||
|
<button class="primary" @click=${this.confirm} ?disabled=${!this.selectedSource}>Share</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
customElements.define('screen-picker-dialog', ScreenPickerDialog);
|
||||||
+74
-3
@@ -277,10 +277,14 @@ async function sendImageMessage(base64Image, prompt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process audio chunk and get response
|
// Process audio chunk and get response
|
||||||
// This accumulates audio and transcribes when silence is detected
|
// This accumulates audio and transcribes when silence is detected or timer expires
|
||||||
let audioChunks = [];
|
let audioChunks = [];
|
||||||
let lastAudioTime = 0;
|
let lastAudioTime = 0;
|
||||||
|
let firstChunkTime = 0;
|
||||||
const SILENCE_THRESHOLD_MS = 1500; // 1.5 seconds of silence
|
const SILENCE_THRESHOLD_MS = 1500; // 1.5 seconds of silence
|
||||||
|
const MAX_BUFFER_DURATION_MS = 5000; // 5 seconds max buffering before forced transcription
|
||||||
|
let silenceCheckTimer = null;
|
||||||
|
let windowsTranscriptionTimer = null;
|
||||||
|
|
||||||
async function processAudioChunk(base64Audio, mimeType) {
|
async function processAudioChunk(base64Audio, mimeType) {
|
||||||
if (!openaiClient) {
|
if (!openaiClient) {
|
||||||
@@ -290,12 +294,43 @@ async function processAudioChunk(base64Audio, mimeType) {
|
|||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const buffer = Buffer.from(base64Audio, 'base64');
|
const buffer = Buffer.from(base64Audio, 'base64');
|
||||||
|
|
||||||
|
// Track first chunk time for duration-based flushing
|
||||||
|
if (audioChunks.length === 0) {
|
||||||
|
firstChunkTime = now;
|
||||||
|
|
||||||
|
// Start periodic transcription timer (Windows needs this)
|
||||||
|
if (!windowsTranscriptionTimer && process.platform === 'win32') {
|
||||||
|
console.log('Starting Windows periodic transcription timer...');
|
||||||
|
windowsTranscriptionTimer = setInterval(async () => {
|
||||||
|
if (audioChunks.length > 0) {
|
||||||
|
const bufferDuration = Date.now() - firstChunkTime;
|
||||||
|
if (bufferDuration >= MAX_BUFFER_DURATION_MS) {
|
||||||
|
console.log(`Periodic flush: ${bufferDuration}ms of audio buffered`);
|
||||||
|
await flushAudioAndTranscribe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 2000); // Check every 2 seconds
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add to audio buffer
|
// Add to audio buffer
|
||||||
audioChunks.push(buffer);
|
audioChunks.push(buffer);
|
||||||
lastAudioTime = now;
|
lastAudioTime = now;
|
||||||
|
|
||||||
// Check for silence (no new audio for SILENCE_THRESHOLD_MS)
|
// Clear existing timer
|
||||||
// This is a simple approach - in production you'd want proper VAD
|
if (silenceCheckTimer) {
|
||||||
|
clearTimeout(silenceCheckTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set timer to check for silence
|
||||||
|
silenceCheckTimer = setTimeout(async () => {
|
||||||
|
const silenceDuration = Date.now() - lastAudioTime;
|
||||||
|
if (silenceDuration >= SILENCE_THRESHOLD_MS && audioChunks.length > 0) {
|
||||||
|
console.log('Silence detected, flushing audio for transcription...');
|
||||||
|
await flushAudioAndTranscribe();
|
||||||
|
}
|
||||||
|
}, SILENCE_THRESHOLD_MS);
|
||||||
|
|
||||||
return { success: true, buffering: true };
|
return { success: true, buffering: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,15 +339,30 @@ async function flushAudioAndTranscribe() {
|
|||||||
return { success: true, text: '' };
|
return { success: true, text: '' };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear Windows transcription timer
|
||||||
|
if (windowsTranscriptionTimer) {
|
||||||
|
clearInterval(windowsTranscriptionTimer);
|
||||||
|
windowsTranscriptionTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Combine all audio chunks
|
// Combine all audio chunks
|
||||||
const combinedBuffer = Buffer.concat(audioChunks);
|
const combinedBuffer = Buffer.concat(audioChunks);
|
||||||
|
const chunkCount = audioChunks.length;
|
||||||
audioChunks = [];
|
audioChunks = [];
|
||||||
|
firstChunkTime = 0;
|
||||||
|
|
||||||
|
// Calculate audio duration
|
||||||
|
const bytesPerSample = 2;
|
||||||
|
const audioDurationMs = (combinedBuffer.length / bytesPerSample / SAMPLE_RATE) * 1000;
|
||||||
|
|
||||||
|
console.log(`Transcribing ${chunkCount} chunks (${audioDurationMs.toFixed(0)}ms of audio)...`);
|
||||||
|
|
||||||
// Transcribe
|
// Transcribe
|
||||||
const transcription = await transcribeAudio(combinedBuffer);
|
const transcription = await transcribeAudio(combinedBuffer);
|
||||||
|
|
||||||
if (transcription && transcription.trim()) {
|
if (transcription && transcription.trim()) {
|
||||||
|
console.log('Transcription result:', transcription);
|
||||||
// Send to chat
|
// Send to chat
|
||||||
const response = await sendTextMessage(transcription);
|
const response = await sendTextMessage(transcription);
|
||||||
|
|
||||||
@@ -334,6 +384,16 @@ function clearConversation() {
|
|||||||
const systemMessage = conversationMessages.find(m => m.role === 'system');
|
const systemMessage = conversationMessages.find(m => m.role === 'system');
|
||||||
conversationMessages = systemMessage ? [systemMessage] : [];
|
conversationMessages = systemMessage ? [systemMessage] : [];
|
||||||
audioChunks = [];
|
audioChunks = [];
|
||||||
|
|
||||||
|
// Clear timers
|
||||||
|
if (silenceCheckTimer) {
|
||||||
|
clearTimeout(silenceCheckTimer);
|
||||||
|
silenceCheckTimer = null;
|
||||||
|
}
|
||||||
|
if (windowsTranscriptionTimer) {
|
||||||
|
clearInterval(windowsTranscriptionTimer);
|
||||||
|
windowsTranscriptionTimer = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeOpenAISDK() {
|
function closeOpenAISDK() {
|
||||||
@@ -343,6 +403,17 @@ function closeOpenAISDK() {
|
|||||||
conversationMessages = [];
|
conversationMessages = [];
|
||||||
audioChunks = [];
|
audioChunks = [];
|
||||||
isProcessing = false;
|
isProcessing = false;
|
||||||
|
|
||||||
|
// Clear timers
|
||||||
|
if (silenceCheckTimer) {
|
||||||
|
clearTimeout(silenceCheckTimer);
|
||||||
|
silenceCheckTimer = null;
|
||||||
|
}
|
||||||
|
if (windowsTranscriptionTimer) {
|
||||||
|
clearInterval(windowsTranscriptionTimer);
|
||||||
|
windowsTranscriptionTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
sendToRenderer('update-status', 'Disconnected');
|
sendToRenderer('update-status', 'Disconnected');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-2
@@ -294,9 +294,20 @@ async function startCapture(screenshotIntervalSeconds = 5, imageQuality = 'mediu
|
|||||||
|
|
||||||
console.log('Linux capture started - system audio:', mediaStream.getAudioTracks().length > 0, 'microphone mode:', audioMode);
|
console.log('Linux capture started - system audio:', mediaStream.getAudioTracks().length > 0, 'microphone mode:', audioMode);
|
||||||
} else {
|
} else {
|
||||||
// Windows - use display media with loopback for system audio
|
// Windows - show custom screen picker first
|
||||||
logToMain('info', '=== Starting Windows audio capture ===');
|
logToMain('info', '=== Starting Windows audio capture ===');
|
||||||
cheatingDaddy.setStatus('Requesting screen & audio...');
|
cheatingDaddy.setStatus('Choose screen to share...');
|
||||||
|
|
||||||
|
// Show screen picker dialog
|
||||||
|
const appElement = document.querySelector('cheating-daddy-app');
|
||||||
|
const pickerResult = await appElement.showScreenPickerDialog();
|
||||||
|
|
||||||
|
if (pickerResult.cancelled) {
|
||||||
|
cheatingDaddy.setStatus('Cancelled');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cheatingDaddy.setStatus('Starting capture...');
|
||||||
|
|
||||||
mediaStream = await navigator.mediaDevices.getDisplayMedia({
|
mediaStream = await navigator.mediaDevices.getDisplayMedia({
|
||||||
video: {
|
video: {
|
||||||
|
|||||||
+65
-5
@@ -34,16 +34,53 @@ function createWindow(sendToRenderer, geminiSessionRef) {
|
|||||||
|
|
||||||
const { session, desktopCapturer } = require('electron');
|
const { session, desktopCapturer } = require('electron');
|
||||||
|
|
||||||
// Setup display media request handler for screen capture
|
// Store selected source for Windows custom picker
|
||||||
// Use system picker on all platforms to let user choose screen/window and audio
|
let selectedSourceId = null;
|
||||||
|
|
||||||
|
// Setup display media handler based on platform
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
// macOS: Use native system picker
|
||||||
session.defaultSession.setDisplayMediaRequestHandler(
|
session.defaultSession.setDisplayMediaRequestHandler(
|
||||||
(request, callback) => {
|
(request, callback) => {
|
||||||
// Don't call callback - let system picker handle the selection
|
desktopCapturer.getSources({ types: ['screen'] }).then(sources => {
|
||||||
// The system will call callback with user's choice
|
callback({ video: sources[0], audio: 'loopback' });
|
||||||
console.log('Showing system screen picker dialog...');
|
});
|
||||||
},
|
},
|
||||||
{ useSystemPicker: true }
|
{ useSystemPicker: true }
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
// Windows/Linux: Use selected source from custom picker
|
||||||
|
session.defaultSession.setDisplayMediaRequestHandler(async (request, callback) => {
|
||||||
|
try {
|
||||||
|
const sources = await desktopCapturer.getSources({
|
||||||
|
types: ['screen', 'window'],
|
||||||
|
thumbnailSize: { width: 0, height: 0 },
|
||||||
|
});
|
||||||
|
|
||||||
|
// Find the selected source or use first screen
|
||||||
|
let source = sources[0];
|
||||||
|
if (selectedSourceId) {
|
||||||
|
const found = sources.find(s => s.id === selectedSourceId);
|
||||||
|
if (found) source = found;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source) {
|
||||||
|
callback({ video: source, audio: 'loopback' });
|
||||||
|
} else {
|
||||||
|
callback({});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error in display media handler:', error);
|
||||||
|
callback({});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPC handler to set selected source
|
||||||
|
ipcMain.handle('set-selected-source', async (event, sourceId) => {
|
||||||
|
selectedSourceId = sourceId;
|
||||||
|
return { success: true };
|
||||||
|
});
|
||||||
|
|
||||||
mainWindow.setResizable(false);
|
mainWindow.setResizable(false);
|
||||||
mainWindow.setContentProtection(true);
|
mainWindow.setContentProtection(true);
|
||||||
@@ -718,6 +755,29 @@ function setupWindowIpcHandlers(mainWindow, sendToRenderer, geminiSessionRef) {
|
|||||||
return { success: false, error: error.message };
|
return { success: false, error: error.message };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Get available screen sources for picker
|
||||||
|
ipcMain.handle('get-screen-sources', async () => {
|
||||||
|
try {
|
||||||
|
const { desktopCapturer } = require('electron');
|
||||||
|
const sources = await desktopCapturer.getSources({
|
||||||
|
types: ['screen', 'window'],
|
||||||
|
thumbnailSize: { width: 150, height: 150 },
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
sources: sources.map(source => ({
|
||||||
|
id: source.id,
|
||||||
|
name: source.name,
|
||||||
|
thumbnail: source.thumbnail.toDataURL(),
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error getting screen sources:', error);
|
||||||
|
return { success: false, error: error.message };
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
Reference in New Issue
Block a user