Refactor window management and global shortcuts handling
This commit is contained in:
parent
494e692738
commit
4cf48ee0af
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
2159
src/utils/gemini.js
2159
src/utils/gemini.js
File diff suppressed because it is too large
Load Diff
@ -1,21 +1,45 @@
|
||||
const profilePrompts = {
|
||||
interview: {
|
||||
intro: `You are an AI-powered interview assistant, designed to act as a discreet on-screen teleprompter. Your mission is to help the user excel in their job interview by providing concise, impactful, and ready-to-speak answers or key talking points. Analyze the ongoing interview dialogue and, crucially, the 'User-provided context' below.`,
|
||||
|
||||
formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**
|
||||
const responseModeFormats = {
|
||||
brief: `**RESPONSE FORMAT REQUIREMENTS:**
|
||||
- Keep responses SHORT and CONCISE (1-3 sentences max)
|
||||
- Use **markdown formatting** for better readability
|
||||
- Use **bold** for key points and emphasis
|
||||
- Use bullet points (-) for lists when appropriate
|
||||
- Focus on the most essential information only`,
|
||||
- Focus on the most essential information only
|
||||
- EXCEPTION: If a coding/algorithm task is detected, ALWAYS provide the complete working code (see CODING TASKS below)`,
|
||||
|
||||
searchUsage: `**SEARCH TOOL USAGE:**
|
||||
detailed: `**RESPONSE FORMAT REQUIREMENTS:**
|
||||
- Provide a THOROUGH and COMPREHENSIVE response with full explanations
|
||||
- Use **markdown formatting** for better readability
|
||||
- Use **bold** for key points and emphasis
|
||||
- Use headers (##) to organize sections when appropriate
|
||||
- Use bullet points (-) for lists when appropriate
|
||||
- Include relevant context, edge cases, and reasoning
|
||||
- For technical topics, explain the "why" behind each point
|
||||
- No length restriction — be as detailed as needed to fully answer the question`,
|
||||
};
|
||||
|
||||
const codingAwareness = `**CODING TASKS — CRITICAL INSTRUCTION:**
|
||||
When the interviewer/questioner asks to solve a coding problem, implement an algorithm, debug code, do a live coding exercise, open an IDE and write code, or any task that requires a code solution:
|
||||
- You MUST provide the ACTUAL COMPLETE WORKING CODE SOLUTION
|
||||
- NEVER respond with meta-advice like "now you should write code" or "prepare to implement" or "think about the approach"
|
||||
- NEVER say "open your IDE" or "start coding" — instead, GIVE THE CODE
|
||||
- In brief mode: provide 2-3 bullet approach points, then the FULL working code with comments
|
||||
- In detailed mode: explain approach, time/space complexity, edge cases, then the FULL working code with comments
|
||||
- Include the programming language name in the code fence (e.g. \`\`\`python, \`\`\`javascript)
|
||||
- If the language is not specified, default to Python
|
||||
- The code must be complete, runnable, and correct`;
|
||||
|
||||
const profilePrompts = {
|
||||
interview: {
|
||||
intro: `You are an AI-powered interview assistant, designed to act as a discreet on-screen teleprompter. Your mission is to help the user excel in their job interview by providing concise, impactful, and ready-to-speak answers or key talking points. Analyze the ongoing interview dialogue and, crucially, the 'User-provided context' below.`,
|
||||
|
||||
searchUsage: `**SEARCH TOOL USAGE:**
|
||||
- If the interviewer mentions **recent events, news, or current trends** (anything from the last 6 months), **ALWAYS use Google search** to get up-to-date information
|
||||
- If they ask about **company-specific information, recent acquisitions, funding, or leadership changes**, use Google search first
|
||||
- If they mention **new technologies, frameworks, or industry developments**, search for the latest information
|
||||
- After searching, provide a **concise, informed response** based on the real-time data`,
|
||||
|
||||
content: `Focus on delivering the most essential information the user needs. Your suggestions should be direct and immediately usable.
|
||||
content: `Focus on delivering the most essential information the user needs. Your suggestions should be direct and immediately usable.
|
||||
|
||||
To help the user 'crack' the interview in their specific field:
|
||||
1. Heavily rely on the 'User-provided context' (e.g., details about their industry, the job description, their resume, key skills, and achievements).
|
||||
@ -32,27 +56,20 @@ You: "I've been working with React for 4 years, building everything from simple
|
||||
Interviewer: "Why do you want to work here?"
|
||||
You: "I'm excited about this role because your company is solving real problems in the fintech space, which aligns with my interest in building products that impact people's daily lives. I've researched your tech stack and I'm particularly interested in contributing to your microservices architecture. Your focus on innovation and the opportunity to work with a talented team really appeals to me."`,
|
||||
|
||||
outputInstructions: `**OUTPUT INSTRUCTIONS:**
|
||||
outputInstructions: `**OUTPUT INSTRUCTIONS:**
|
||||
Provide only the exact words to say in **markdown format**. No coaching, no "you should" statements, no explanations - just the direct response the candidate can speak immediately. Keep it **short and impactful**.`,
|
||||
},
|
||||
},
|
||||
|
||||
sales: {
|
||||
intro: `You are a sales call assistant. Your job is to provide the exact words the salesperson should say to prospects during sales calls. Give direct, ready-to-speak responses that are persuasive and professional.`,
|
||||
sales: {
|
||||
intro: `You are a sales call assistant. Your job is to provide the exact words the salesperson should say to prospects during sales calls. Give direct, ready-to-speak responses that are persuasive and professional.`,
|
||||
|
||||
formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**
|
||||
- Keep responses SHORT and CONCISE (1-3 sentences max)
|
||||
- Use **markdown formatting** for better readability
|
||||
- Use **bold** for key points and emphasis
|
||||
- Use bullet points (-) for lists when appropriate
|
||||
- Focus on the most essential information only`,
|
||||
|
||||
searchUsage: `**SEARCH TOOL USAGE:**
|
||||
searchUsage: `**SEARCH TOOL USAGE:**
|
||||
- If the prospect mentions **recent industry trends, market changes, or current events**, **ALWAYS use Google search** to get up-to-date information
|
||||
- If they reference **competitor information, recent funding news, or market data**, search for the latest information first
|
||||
- If they ask about **new regulations, industry reports, or recent developments**, use search to provide accurate data
|
||||
- After searching, provide a **concise, informed response** that demonstrates current market knowledge`,
|
||||
|
||||
content: `Examples:
|
||||
content: `Examples:
|
||||
|
||||
Prospect: "Tell me about your product"
|
||||
You: "Our platform helps companies like yours reduce operational costs by 30% while improving efficiency. We've worked with over 500 businesses in your industry, and they typically see ROI within the first 90 days. What specific operational challenges are you facing right now?"
|
||||
@ -63,27 +80,20 @@ You: "Three key differentiators set us apart: First, our implementation takes ju
|
||||
Prospect: "I need to think about it"
|
||||
You: "I completely understand this is an important decision. What specific concerns can I address for you today? Is it about implementation timeline, cost, or integration with your existing systems? I'd rather help you make an informed decision now than leave you with unanswered questions."`,
|
||||
|
||||
outputInstructions: `**OUTPUT INSTRUCTIONS:**
|
||||
outputInstructions: `**OUTPUT INSTRUCTIONS:**
|
||||
Provide only the exact words to say in **markdown format**. Be persuasive but not pushy. Focus on value and addressing objections directly. Keep responses **short and impactful**.`,
|
||||
},
|
||||
},
|
||||
|
||||
meeting: {
|
||||
intro: `You are a meeting assistant. Your job is to provide the exact words to say during professional meetings, presentations, and discussions. Give direct, ready-to-speak responses that are clear and professional.`,
|
||||
meeting: {
|
||||
intro: `You are a meeting assistant. Your job is to provide the exact words to say during professional meetings, presentations, and discussions. Give direct, ready-to-speak responses that are clear and professional.`,
|
||||
|
||||
formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**
|
||||
- Keep responses SHORT and CONCISE (1-3 sentences max)
|
||||
- Use **markdown formatting** for better readability
|
||||
- Use **bold** for key points and emphasis
|
||||
- Use bullet points (-) for lists when appropriate
|
||||
- Focus on the most essential information only`,
|
||||
|
||||
searchUsage: `**SEARCH TOOL USAGE:**
|
||||
searchUsage: `**SEARCH TOOL USAGE:**
|
||||
- If participants mention **recent industry news, regulatory changes, or market updates**, **ALWAYS use Google search** for current information
|
||||
- If they reference **competitor activities, recent reports, or current statistics**, search for the latest data first
|
||||
- If they discuss **new technologies, tools, or industry developments**, use search to provide accurate insights
|
||||
- After searching, provide a **concise, informed response** that adds value to the discussion`,
|
||||
|
||||
content: `Examples:
|
||||
content: `Examples:
|
||||
|
||||
Participant: "What's the status on the project?"
|
||||
You: "We're currently on track to meet our deadline. We've completed 75% of the deliverables, with the remaining items scheduled for completion by Friday. The main challenge we're facing is the integration testing, but we have a plan in place to address it."
|
||||
@ -94,27 +104,20 @@ You: "Absolutely. We're currently at 80% of our allocated budget with 20% of the
|
||||
Participant: "What are the next steps?"
|
||||
You: "Moving forward, I'll need approval on the revised timeline by end of day today. Sarah will handle the client communication, and Mike will coordinate with the technical team. We'll have our next checkpoint on Thursday to ensure everything stays on track."`,
|
||||
|
||||
outputInstructions: `**OUTPUT INSTRUCTIONS:**
|
||||
outputInstructions: `**OUTPUT INSTRUCTIONS:**
|
||||
Provide only the exact words to say in **markdown format**. Be clear, concise, and action-oriented in your responses. Keep it **short and impactful**.`,
|
||||
},
|
||||
},
|
||||
|
||||
presentation: {
|
||||
intro: `You are a presentation coach. Your job is to provide the exact words the presenter should say during presentations, pitches, and public speaking events. Give direct, ready-to-speak responses that are engaging and confident.`,
|
||||
presentation: {
|
||||
intro: `You are a presentation coach. Your job is to provide the exact words the presenter should say during presentations, pitches, and public speaking events. Give direct, ready-to-speak responses that are engaging and confident.`,
|
||||
|
||||
formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**
|
||||
- Keep responses SHORT and CONCISE (1-3 sentences max)
|
||||
- Use **markdown formatting** for better readability
|
||||
- Use **bold** for key points and emphasis
|
||||
- Use bullet points (-) for lists when appropriate
|
||||
- Focus on the most essential information only`,
|
||||
|
||||
searchUsage: `**SEARCH TOOL USAGE:**
|
||||
searchUsage: `**SEARCH TOOL USAGE:**
|
||||
- If the audience asks about **recent market trends, current statistics, or latest industry data**, **ALWAYS use Google search** for up-to-date information
|
||||
- If they reference **recent events, new competitors, or current market conditions**, search for the latest information first
|
||||
- If they inquire about **recent studies, reports, or breaking news** in your field, use search to provide accurate data
|
||||
- After searching, provide a **concise, credible response** with current facts and figures`,
|
||||
|
||||
content: `Examples:
|
||||
content: `Examples:
|
||||
|
||||
Audience: "Can you explain that slide again?"
|
||||
You: "Of course. This slide shows our three-year growth trajectory. The blue line represents revenue, which has grown 150% year over year. The orange bars show our customer acquisition, doubling each year. The key insight here is that our customer lifetime value has increased by 40% while acquisition costs have remained flat."
|
||||
@ -125,27 +128,20 @@ You: "Great question. Our competitive advantage comes down to three core strengt
|
||||
Audience: "How do you plan to scale?"
|
||||
You: "Our scaling strategy focuses on three pillars. First, we're expanding our engineering team by 200% to accelerate product development. Second, we're entering three new markets next quarter. Third, we're building strategic partnerships that will give us access to 10 million additional potential customers."`,
|
||||
|
||||
outputInstructions: `**OUTPUT INSTRUCTIONS:**
|
||||
outputInstructions: `**OUTPUT INSTRUCTIONS:**
|
||||
Provide only the exact words to say in **markdown format**. Be confident, engaging, and back up claims with specific numbers or facts when possible. Keep responses **short and impactful**.`,
|
||||
},
|
||||
},
|
||||
|
||||
negotiation: {
|
||||
intro: `You are a negotiation assistant. Your job is to provide the exact words to say during business negotiations, contract discussions, and deal-making conversations. Give direct, ready-to-speak responses that are strategic and professional.`,
|
||||
negotiation: {
|
||||
intro: `You are a negotiation assistant. Your job is to provide the exact words to say during business negotiations, contract discussions, and deal-making conversations. Give direct, ready-to-speak responses that are strategic and professional.`,
|
||||
|
||||
formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**
|
||||
- Keep responses SHORT and CONCISE (1-3 sentences max)
|
||||
- Use **markdown formatting** for better readability
|
||||
- Use **bold** for key points and emphasis
|
||||
- Use bullet points (-) for lists when appropriate
|
||||
- Focus on the most essential information only`,
|
||||
|
||||
searchUsage: `**SEARCH TOOL USAGE:**
|
||||
searchUsage: `**SEARCH TOOL USAGE:**
|
||||
- If they mention **recent market pricing, current industry standards, or competitor offers**, **ALWAYS use Google search** for current benchmarks
|
||||
- If they reference **recent legal changes, new regulations, or market conditions**, search for the latest information first
|
||||
- If they discuss **recent company news, financial performance, or industry developments**, use search to provide informed responses
|
||||
- After searching, provide a **strategic, well-informed response** that leverages current market intelligence`,
|
||||
|
||||
content: `Examples:
|
||||
content: `Examples:
|
||||
|
||||
Other party: "That price is too high"
|
||||
You: "I understand your concern about the investment. Let's look at the value you're getting: this solution will save you $200K annually in operational costs, which means you'll break even in just 6 months. Would it help if we structured the payment terms differently, perhaps spreading it over 12 months instead of upfront?"
|
||||
@ -156,27 +152,20 @@ You: "I appreciate your directness. We want this to work for both parties. Our c
|
||||
Other party: "We're considering other options"
|
||||
You: "That's smart business practice. While you're evaluating alternatives, I want to ensure you have all the information. Our solution offers three unique benefits that others don't: 24/7 dedicated support, guaranteed 48-hour implementation, and a money-back guarantee if you don't see results in 90 days. How important are these factors in your decision?"`,
|
||||
|
||||
outputInstructions: `**OUTPUT INSTRUCTIONS:**
|
||||
outputInstructions: `**OUTPUT INSTRUCTIONS:**
|
||||
Provide only the exact words to say in **markdown format**. Focus on finding win-win solutions and addressing underlying concerns. Keep responses **short and impactful**.`,
|
||||
},
|
||||
},
|
||||
|
||||
exam: {
|
||||
intro: `You are an exam assistant designed to help students pass tests efficiently. Your role is to provide direct, accurate answers to exam questions with minimal explanation - just enough to confirm the answer is correct.`,
|
||||
exam: {
|
||||
intro: `You are an exam assistant designed to help students pass tests efficiently. Your role is to provide direct, accurate answers to exam questions with minimal explanation - just enough to confirm the answer is correct.`,
|
||||
|
||||
formatRequirements: `**RESPONSE FORMAT REQUIREMENTS:**
|
||||
- Keep responses SHORT and CONCISE (1-2 sentences max)
|
||||
- Use **markdown formatting** for better readability
|
||||
- Use **bold** for the answer choice/result
|
||||
- Focus on the most essential information only
|
||||
- Provide only brief justification for correctness`,
|
||||
|
||||
searchUsage: `**SEARCH TOOL USAGE:**
|
||||
searchUsage: `**SEARCH TOOL USAGE:**
|
||||
- If the question involves **recent information, current events, or updated facts**, **ALWAYS use Google search** for the latest data
|
||||
- If they reference **specific dates, statistics, or factual information** that might be outdated, search for current information
|
||||
- If they ask about **recent research, new theories, or updated methodologies**, search for the latest information
|
||||
- After searching, provide **direct, accurate answers** with minimal explanation`,
|
||||
|
||||
content: `Focus on providing efficient exam assistance that helps students pass tests quickly.
|
||||
content: `Focus on providing efficient exam assistance that helps students pass tests quickly.
|
||||
|
||||
**Key Principles:**
|
||||
1. **Answer the question directly** - no unnecessary explanations
|
||||
@ -196,30 +185,62 @@ You: "**Question**: Which of the following is a primary color? A) Green B) Red C
|
||||
Question: "Solve for x: 2x + 5 = 13"
|
||||
You: "**Question**: Solve for x: 2x + 5 = 13 **Answer**: x = 4 **Why**: Subtract 5 from both sides: 2x = 8, then divide by 2: x = 4."`,
|
||||
|
||||
outputInstructions: `**OUTPUT INSTRUCTIONS:**
|
||||
outputInstructions: `**OUTPUT INSTRUCTIONS:**
|
||||
Provide direct exam answers in **markdown format**. Include the question text, the correct answer choice, and a brief justification. Focus on efficiency and accuracy. Keep responses **short and to the point**.`,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
function buildSystemPrompt(promptParts, customPrompt = '', googleSearchEnabled = true) {
|
||||
const sections = [promptParts.intro, '\n\n', promptParts.formatRequirements];
|
||||
function buildSystemPrompt(
|
||||
promptParts,
|
||||
customPrompt = "",
|
||||
googleSearchEnabled = true,
|
||||
responseMode = "brief",
|
||||
) {
|
||||
const formatReqs =
|
||||
responseModeFormats[responseMode] || responseModeFormats.brief;
|
||||
const sections = [
|
||||
promptParts.intro,
|
||||
"\n\n",
|
||||
formatReqs,
|
||||
"\n\n",
|
||||
codingAwareness,
|
||||
];
|
||||
|
||||
// Only add search usage section if Google Search is enabled
|
||||
if (googleSearchEnabled) {
|
||||
sections.push('\n\n', promptParts.searchUsage);
|
||||
}
|
||||
// Only add search usage section if Google Search is enabled
|
||||
if (googleSearchEnabled) {
|
||||
sections.push("\n\n", promptParts.searchUsage);
|
||||
}
|
||||
|
||||
sections.push('\n\n', promptParts.content, '\n\nUser-provided context\n-----\n', customPrompt, '\n-----\n\n', promptParts.outputInstructions);
|
||||
sections.push(
|
||||
"\n\n",
|
||||
promptParts.content,
|
||||
"\n\nUser-provided context\n-----\n",
|
||||
customPrompt,
|
||||
"\n-----\n\n",
|
||||
promptParts.outputInstructions,
|
||||
);
|
||||
|
||||
return sections.join('');
|
||||
return sections.join("");
|
||||
}
|
||||
|
||||
function getSystemPrompt(profile, customPrompt = '', googleSearchEnabled = true) {
|
||||
const promptParts = profilePrompts[profile] || profilePrompts.interview;
|
||||
return buildSystemPrompt(promptParts, customPrompt, googleSearchEnabled);
|
||||
function getSystemPrompt(
|
||||
profile,
|
||||
customPrompt = "",
|
||||
googleSearchEnabled = true,
|
||||
responseMode = "brief",
|
||||
) {
|
||||
const promptParts = profilePrompts[profile] || profilePrompts.interview;
|
||||
return buildSystemPrompt(
|
||||
promptParts,
|
||||
customPrompt,
|
||||
googleSearchEnabled,
|
||||
responseMode,
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
profilePrompts,
|
||||
getSystemPrompt,
|
||||
profilePrompts,
|
||||
responseModeFormats,
|
||||
codingAwareness,
|
||||
getSystemPrompt,
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,368 +1,429 @@
|
||||
const { BrowserWindow, globalShortcut, ipcMain, screen } = require('electron');
|
||||
const path = require('node:path');
|
||||
const storage = require('../storage');
|
||||
const { BrowserWindow, globalShortcut, ipcMain, screen } = require("electron");
|
||||
const path = require("node:path");
|
||||
const storage = require("../storage");
|
||||
|
||||
let mouseEventsIgnored = false;
|
||||
|
||||
function createWindow(sendToRenderer, geminiSessionRef) {
|
||||
// Get layout preference (default to 'normal')
|
||||
let windowWidth = 1100;
|
||||
let windowHeight = 800;
|
||||
// Get layout preference (default to 'normal')
|
||||
let windowWidth = 1100;
|
||||
let windowHeight = 800;
|
||||
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: windowWidth,
|
||||
height: windowHeight,
|
||||
frame: false,
|
||||
transparent: true,
|
||||
hasShadow: false,
|
||||
alwaysOnTop: true,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false, // TODO: change to true
|
||||
backgroundThrottling: false,
|
||||
enableBlinkFeatures: 'GetDisplayMedia',
|
||||
webSecurity: true,
|
||||
allowRunningInsecureContent: false,
|
||||
},
|
||||
backgroundColor: '#00000000',
|
||||
});
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: windowWidth,
|
||||
height: windowHeight,
|
||||
frame: false,
|
||||
transparent: true,
|
||||
hasShadow: false,
|
||||
alwaysOnTop: true,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false, // TODO: change to true
|
||||
backgroundThrottling: false,
|
||||
enableBlinkFeatures: "GetDisplayMedia",
|
||||
webSecurity: true,
|
||||
allowRunningInsecureContent: false,
|
||||
},
|
||||
backgroundColor: "#00000000",
|
||||
});
|
||||
|
||||
const { session, desktopCapturer } = require('electron');
|
||||
session.defaultSession.setDisplayMediaRequestHandler(
|
||||
(request, callback) => {
|
||||
desktopCapturer.getSources({ types: ['screen'] }).then(sources => {
|
||||
callback({ video: sources[0], audio: 'loopback' });
|
||||
});
|
||||
},
|
||||
{ useSystemPicker: true }
|
||||
);
|
||||
const { session, desktopCapturer } = require("electron");
|
||||
session.defaultSession.setDisplayMediaRequestHandler(
|
||||
(request, callback) => {
|
||||
desktopCapturer.getSources({ types: ["screen"] }).then((sources) => {
|
||||
callback({ video: sources[0], audio: "loopback" });
|
||||
});
|
||||
},
|
||||
{ useSystemPicker: true },
|
||||
);
|
||||
|
||||
mainWindow.setResizable(false);
|
||||
mainWindow.setContentProtection(true);
|
||||
mainWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
|
||||
mainWindow.setResizable(false);
|
||||
mainWindow.setContentProtection(true);
|
||||
mainWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
|
||||
|
||||
// Hide from Windows taskbar
|
||||
if (process.platform === 'win32') {
|
||||
try {
|
||||
mainWindow.setSkipTaskbar(true);
|
||||
} catch (error) {
|
||||
console.warn('Could not hide from taskbar:', error.message);
|
||||
}
|
||||
// Hide from Windows taskbar
|
||||
if (process.platform === "win32") {
|
||||
try {
|
||||
mainWindow.setSkipTaskbar(true);
|
||||
} catch (error) {
|
||||
console.warn("Could not hide from taskbar:", error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Hide from Mission Control on macOS
|
||||
if (process.platform === 'darwin') {
|
||||
try {
|
||||
mainWindow.setHiddenInMissionControl(true);
|
||||
} catch (error) {
|
||||
console.warn('Could not hide from Mission Control:', error.message);
|
||||
}
|
||||
// Hide from Mission Control on macOS
|
||||
if (process.platform === "darwin") {
|
||||
try {
|
||||
mainWindow.setHiddenInMissionControl(true);
|
||||
} catch (error) {
|
||||
console.warn("Could not hide from Mission Control:", error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Center window at the top of the screen
|
||||
const primaryDisplay = screen.getPrimaryDisplay();
|
||||
const { width: screenWidth } = primaryDisplay.workAreaSize;
|
||||
const x = Math.floor((screenWidth - windowWidth) / 2);
|
||||
const y = 0;
|
||||
mainWindow.setPosition(x, y);
|
||||
// Center window at the top of the screen
|
||||
const primaryDisplay = screen.getPrimaryDisplay();
|
||||
const { width: screenWidth } = primaryDisplay.workAreaSize;
|
||||
const x = Math.floor((screenWidth - windowWidth) / 2);
|
||||
const y = 0;
|
||||
mainWindow.setPosition(x, y);
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
mainWindow.setAlwaysOnTop(true, 'screen-saver', 1);
|
||||
}
|
||||
if (process.platform === "win32") {
|
||||
mainWindow.setAlwaysOnTop(true, "screen-saver", 1);
|
||||
}
|
||||
|
||||
mainWindow.loadFile(path.join(__dirname, '../index.html'));
|
||||
mainWindow.loadFile(path.join(__dirname, "../index.html"));
|
||||
|
||||
// After window is created, initialize keybinds
|
||||
mainWindow.webContents.once('dom-ready', () => {
|
||||
setTimeout(() => {
|
||||
const defaultKeybinds = getDefaultKeybinds();
|
||||
let keybinds = defaultKeybinds;
|
||||
// After window is created, initialize keybinds
|
||||
mainWindow.webContents.once("dom-ready", () => {
|
||||
setTimeout(() => {
|
||||
const defaultKeybinds = getDefaultKeybinds();
|
||||
let keybinds = defaultKeybinds;
|
||||
|
||||
// Load keybinds from storage
|
||||
const savedKeybinds = storage.getKeybinds();
|
||||
if (savedKeybinds) {
|
||||
keybinds = { ...defaultKeybinds, ...savedKeybinds };
|
||||
}
|
||||
// Load keybinds from storage
|
||||
const savedKeybinds = storage.getKeybinds();
|
||||
if (savedKeybinds) {
|
||||
keybinds = { ...defaultKeybinds, ...savedKeybinds };
|
||||
}
|
||||
|
||||
updateGlobalShortcuts(keybinds, mainWindow, sendToRenderer, geminiSessionRef);
|
||||
}, 150);
|
||||
});
|
||||
updateGlobalShortcuts(
|
||||
keybinds,
|
||||
mainWindow,
|
||||
sendToRenderer,
|
||||
geminiSessionRef,
|
||||
);
|
||||
}, 150);
|
||||
});
|
||||
|
||||
setupWindowIpcHandlers(mainWindow, sendToRenderer, geminiSessionRef);
|
||||
setupWindowIpcHandlers(mainWindow, sendToRenderer, geminiSessionRef);
|
||||
|
||||
return mainWindow;
|
||||
return mainWindow;
|
||||
}
|
||||
|
||||
function getDefaultKeybinds() {
|
||||
const isMac = process.platform === 'darwin';
|
||||
return {
|
||||
moveUp: isMac ? 'Alt+Up' : 'Ctrl+Up',
|
||||
moveDown: isMac ? 'Alt+Down' : 'Ctrl+Down',
|
||||
moveLeft: isMac ? 'Alt+Left' : 'Ctrl+Left',
|
||||
moveRight: isMac ? 'Alt+Right' : 'Ctrl+Right',
|
||||
toggleVisibility: isMac ? 'Cmd+\\' : 'Ctrl+\\',
|
||||
toggleClickThrough: isMac ? 'Cmd+M' : 'Ctrl+M',
|
||||
nextStep: isMac ? 'Cmd+Enter' : 'Ctrl+Enter',
|
||||
previousResponse: isMac ? 'Cmd+[' : 'Ctrl+[',
|
||||
nextResponse: isMac ? 'Cmd+]' : 'Ctrl+]',
|
||||
scrollUp: isMac ? 'Cmd+Shift+Up' : 'Ctrl+Shift+Up',
|
||||
scrollDown: isMac ? 'Cmd+Shift+Down' : 'Ctrl+Shift+Down',
|
||||
emergencyErase: isMac ? 'Cmd+Shift+E' : 'Ctrl+Shift+E',
|
||||
};
|
||||
const isMac = process.platform === "darwin";
|
||||
return {
|
||||
moveUp: isMac ? "Alt+Up" : "Ctrl+Up",
|
||||
moveDown: isMac ? "Alt+Down" : "Ctrl+Down",
|
||||
moveLeft: isMac ? "Alt+Left" : "Ctrl+Left",
|
||||
moveRight: isMac ? "Alt+Right" : "Ctrl+Right",
|
||||
toggleVisibility: isMac ? "Cmd+\\" : "Ctrl+\\",
|
||||
toggleClickThrough: isMac ? "Cmd+M" : "Ctrl+M",
|
||||
nextStep: isMac ? "Cmd+Enter" : "Ctrl+Enter",
|
||||
previousResponse: isMac ? "Cmd+[" : "Ctrl+[",
|
||||
nextResponse: isMac ? "Cmd+]" : "Ctrl+]",
|
||||
scrollUp: isMac ? "Cmd+Shift+Up" : "Ctrl+Shift+Up",
|
||||
scrollDown: isMac ? "Cmd+Shift+Down" : "Ctrl+Shift+Down",
|
||||
expandResponse: isMac ? "Cmd+E" : "Ctrl+E",
|
||||
emergencyErase: isMac ? "Cmd+Shift+E" : "Ctrl+Shift+E",
|
||||
};
|
||||
}
|
||||
|
||||
function updateGlobalShortcuts(keybinds, mainWindow, sendToRenderer, geminiSessionRef) {
|
||||
console.log('Updating global shortcuts with:', keybinds);
|
||||
function updateGlobalShortcuts(
|
||||
keybinds,
|
||||
mainWindow,
|
||||
sendToRenderer,
|
||||
geminiSessionRef,
|
||||
) {
|
||||
console.log("Updating global shortcuts with:", keybinds);
|
||||
|
||||
// Unregister all existing shortcuts
|
||||
globalShortcut.unregisterAll();
|
||||
// Unregister all existing shortcuts
|
||||
globalShortcut.unregisterAll();
|
||||
|
||||
const primaryDisplay = screen.getPrimaryDisplay();
|
||||
const { width, height } = primaryDisplay.workAreaSize;
|
||||
const moveIncrement = Math.floor(Math.min(width, height) * 0.1);
|
||||
const primaryDisplay = screen.getPrimaryDisplay();
|
||||
const { width, height } = primaryDisplay.workAreaSize;
|
||||
const moveIncrement = Math.floor(Math.min(width, height) * 0.1);
|
||||
|
||||
// Register window movement shortcuts
|
||||
const movementActions = {
|
||||
moveUp: () => {
|
||||
if (!mainWindow.isVisible()) return;
|
||||
const [currentX, currentY] = mainWindow.getPosition();
|
||||
mainWindow.setPosition(currentX, currentY - moveIncrement);
|
||||
},
|
||||
moveDown: () => {
|
||||
if (!mainWindow.isVisible()) return;
|
||||
const [currentX, currentY] = mainWindow.getPosition();
|
||||
mainWindow.setPosition(currentX, currentY + moveIncrement);
|
||||
},
|
||||
moveLeft: () => {
|
||||
if (!mainWindow.isVisible()) return;
|
||||
const [currentX, currentY] = mainWindow.getPosition();
|
||||
mainWindow.setPosition(currentX - moveIncrement, currentY);
|
||||
},
|
||||
moveRight: () => {
|
||||
if (!mainWindow.isVisible()) return;
|
||||
const [currentX, currentY] = mainWindow.getPosition();
|
||||
mainWindow.setPosition(currentX + moveIncrement, currentY);
|
||||
},
|
||||
};
|
||||
// Register window movement shortcuts
|
||||
const movementActions = {
|
||||
moveUp: () => {
|
||||
if (!mainWindow.isVisible()) return;
|
||||
const [currentX, currentY] = mainWindow.getPosition();
|
||||
mainWindow.setPosition(currentX, currentY - moveIncrement);
|
||||
},
|
||||
moveDown: () => {
|
||||
if (!mainWindow.isVisible()) return;
|
||||
const [currentX, currentY] = mainWindow.getPosition();
|
||||
mainWindow.setPosition(currentX, currentY + moveIncrement);
|
||||
},
|
||||
moveLeft: () => {
|
||||
if (!mainWindow.isVisible()) return;
|
||||
const [currentX, currentY] = mainWindow.getPosition();
|
||||
mainWindow.setPosition(currentX - moveIncrement, currentY);
|
||||
},
|
||||
moveRight: () => {
|
||||
if (!mainWindow.isVisible()) return;
|
||||
const [currentX, currentY] = mainWindow.getPosition();
|
||||
mainWindow.setPosition(currentX + moveIncrement, currentY);
|
||||
},
|
||||
};
|
||||
|
||||
// Register each movement shortcut
|
||||
Object.keys(movementActions).forEach(action => {
|
||||
const keybind = keybinds[action];
|
||||
if (keybind) {
|
||||
try {
|
||||
globalShortcut.register(keybind, movementActions[action]);
|
||||
console.log(`Registered ${action}: ${keybind}`);
|
||||
} catch (error) {
|
||||
console.error(`Failed to register ${action} (${keybind}):`, error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Register toggle visibility shortcut
|
||||
if (keybinds.toggleVisibility) {
|
||||
try {
|
||||
globalShortcut.register(keybinds.toggleVisibility, () => {
|
||||
if (mainWindow.isVisible()) {
|
||||
mainWindow.hide();
|
||||
} else {
|
||||
mainWindow.showInactive();
|
||||
}
|
||||
});
|
||||
console.log(`Registered toggleVisibility: ${keybinds.toggleVisibility}`);
|
||||
} catch (error) {
|
||||
console.error(`Failed to register toggleVisibility (${keybinds.toggleVisibility}):`, error);
|
||||
}
|
||||
// Register each movement shortcut
|
||||
Object.keys(movementActions).forEach((action) => {
|
||||
const keybind = keybinds[action];
|
||||
if (keybind) {
|
||||
try {
|
||||
globalShortcut.register(keybind, movementActions[action]);
|
||||
console.log(`Registered ${action}: ${keybind}`);
|
||||
} catch (error) {
|
||||
console.error(`Failed to register ${action} (${keybind}):`, error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Register toggle click-through shortcut
|
||||
if (keybinds.toggleClickThrough) {
|
||||
try {
|
||||
globalShortcut.register(keybinds.toggleClickThrough, () => {
|
||||
mouseEventsIgnored = !mouseEventsIgnored;
|
||||
if (mouseEventsIgnored) {
|
||||
mainWindow.setIgnoreMouseEvents(true, { forward: true });
|
||||
console.log('Mouse events ignored');
|
||||
} else {
|
||||
mainWindow.setIgnoreMouseEvents(false);
|
||||
console.log('Mouse events enabled');
|
||||
}
|
||||
mainWindow.webContents.send('click-through-toggled', mouseEventsIgnored);
|
||||
});
|
||||
console.log(`Registered toggleClickThrough: ${keybinds.toggleClickThrough}`);
|
||||
} catch (error) {
|
||||
console.error(`Failed to register toggleClickThrough (${keybinds.toggleClickThrough}):`, error);
|
||||
// Register toggle visibility shortcut
|
||||
if (keybinds.toggleVisibility) {
|
||||
try {
|
||||
globalShortcut.register(keybinds.toggleVisibility, () => {
|
||||
if (mainWindow.isVisible()) {
|
||||
mainWindow.hide();
|
||||
} else {
|
||||
mainWindow.showInactive();
|
||||
}
|
||||
});
|
||||
console.log(`Registered toggleVisibility: ${keybinds.toggleVisibility}`);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Failed to register toggleVisibility (${keybinds.toggleVisibility}):`,
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Register next step shortcut (either starts session or takes screenshot based on view)
|
||||
if (keybinds.nextStep) {
|
||||
// Register toggle click-through shortcut
|
||||
if (keybinds.toggleClickThrough) {
|
||||
try {
|
||||
globalShortcut.register(keybinds.toggleClickThrough, () => {
|
||||
mouseEventsIgnored = !mouseEventsIgnored;
|
||||
if (mouseEventsIgnored) {
|
||||
mainWindow.setIgnoreMouseEvents(true, { forward: true });
|
||||
console.log("Mouse events ignored");
|
||||
} else {
|
||||
mainWindow.setIgnoreMouseEvents(false);
|
||||
console.log("Mouse events enabled");
|
||||
}
|
||||
mainWindow.webContents.send(
|
||||
"click-through-toggled",
|
||||
mouseEventsIgnored,
|
||||
);
|
||||
});
|
||||
console.log(
|
||||
`Registered toggleClickThrough: ${keybinds.toggleClickThrough}`,
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Failed to register toggleClickThrough (${keybinds.toggleClickThrough}):`,
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Register next step shortcut (either starts session or takes screenshot based on view)
|
||||
if (keybinds.nextStep) {
|
||||
try {
|
||||
globalShortcut.register(keybinds.nextStep, async () => {
|
||||
console.log("Next step shortcut triggered");
|
||||
try {
|
||||
globalShortcut.register(keybinds.nextStep, async () => {
|
||||
console.log('Next step shortcut triggered');
|
||||
try {
|
||||
// Determine the shortcut key format
|
||||
const isMac = process.platform === 'darwin';
|
||||
const shortcutKey = isMac ? 'cmd+enter' : 'ctrl+enter';
|
||||
// Determine the shortcut key format
|
||||
const isMac = process.platform === "darwin";
|
||||
const shortcutKey = isMac ? "cmd+enter" : "ctrl+enter";
|
||||
|
||||
// Use the new handleShortcut function
|
||||
mainWindow.webContents.executeJavaScript(`
|
||||
// Use the new handleShortcut function
|
||||
mainWindow.webContents.executeJavaScript(`
|
||||
cheatingDaddy.handleShortcut('${shortcutKey}');
|
||||
`);
|
||||
} catch (error) {
|
||||
console.error('Error handling next step shortcut:', error);
|
||||
}
|
||||
});
|
||||
console.log(`Registered nextStep: ${keybinds.nextStep}`);
|
||||
} catch (error) {
|
||||
console.error(`Failed to register nextStep (${keybinds.nextStep}):`, error);
|
||||
console.error("Error handling next step shortcut:", error);
|
||||
}
|
||||
});
|
||||
console.log(`Registered nextStep: ${keybinds.nextStep}`);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Failed to register nextStep (${keybinds.nextStep}):`,
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Register previous response shortcut
|
||||
if (keybinds.previousResponse) {
|
||||
try {
|
||||
globalShortcut.register(keybinds.previousResponse, () => {
|
||||
console.log('Previous response shortcut triggered');
|
||||
sendToRenderer('navigate-previous-response');
|
||||
});
|
||||
console.log(`Registered previousResponse: ${keybinds.previousResponse}`);
|
||||
} catch (error) {
|
||||
console.error(`Failed to register previousResponse (${keybinds.previousResponse}):`, error);
|
||||
}
|
||||
}
|
||||
|
||||
// Register next response shortcut
|
||||
if (keybinds.nextResponse) {
|
||||
try {
|
||||
globalShortcut.register(keybinds.nextResponse, () => {
|
||||
console.log('Next response shortcut triggered');
|
||||
sendToRenderer('navigate-next-response');
|
||||
});
|
||||
console.log(`Registered nextResponse: ${keybinds.nextResponse}`);
|
||||
} catch (error) {
|
||||
console.error(`Failed to register nextResponse (${keybinds.nextResponse}):`, error);
|
||||
}
|
||||
}
|
||||
|
||||
// Register scroll up shortcut
|
||||
if (keybinds.scrollUp) {
|
||||
try {
|
||||
globalShortcut.register(keybinds.scrollUp, () => {
|
||||
console.log('Scroll up shortcut triggered');
|
||||
sendToRenderer('scroll-response-up');
|
||||
});
|
||||
console.log(`Registered scrollUp: ${keybinds.scrollUp}`);
|
||||
} catch (error) {
|
||||
console.error(`Failed to register scrollUp (${keybinds.scrollUp}):`, error);
|
||||
}
|
||||
}
|
||||
|
||||
// Register scroll down shortcut
|
||||
if (keybinds.scrollDown) {
|
||||
try {
|
||||
globalShortcut.register(keybinds.scrollDown, () => {
|
||||
console.log('Scroll down shortcut triggered');
|
||||
sendToRenderer('scroll-response-down');
|
||||
});
|
||||
console.log(`Registered scrollDown: ${keybinds.scrollDown}`);
|
||||
} catch (error) {
|
||||
console.error(`Failed to register scrollDown (${keybinds.scrollDown}):`, error);
|
||||
}
|
||||
}
|
||||
|
||||
// Register emergency erase shortcut
|
||||
if (keybinds.emergencyErase) {
|
||||
try {
|
||||
globalShortcut.register(keybinds.emergencyErase, () => {
|
||||
console.log('Emergency Erase triggered!');
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.hide();
|
||||
|
||||
if (geminiSessionRef.current) {
|
||||
geminiSessionRef.current.close();
|
||||
geminiSessionRef.current = null;
|
||||
}
|
||||
|
||||
sendToRenderer('clear-sensitive-data');
|
||||
|
||||
setTimeout(() => {
|
||||
const { app } = require('electron');
|
||||
app.quit();
|
||||
}, 300);
|
||||
}
|
||||
});
|
||||
console.log(`Registered emergencyErase: ${keybinds.emergencyErase}`);
|
||||
} catch (error) {
|
||||
console.error(`Failed to register emergencyErase (${keybinds.emergencyErase}):`, error);
|
||||
// Register previous response shortcut
|
||||
if (keybinds.previousResponse) {
|
||||
try {
|
||||
globalShortcut.register(keybinds.previousResponse, () => {
|
||||
console.log("Previous response shortcut triggered");
|
||||
sendToRenderer("navigate-previous-response");
|
||||
});
|
||||
console.log(`Registered previousResponse: ${keybinds.previousResponse}`);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Failed to register previousResponse (${keybinds.previousResponse}):`,
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Register next response shortcut
|
||||
if (keybinds.nextResponse) {
|
||||
try {
|
||||
globalShortcut.register(keybinds.nextResponse, () => {
|
||||
console.log("Next response shortcut triggered");
|
||||
sendToRenderer("navigate-next-response");
|
||||
});
|
||||
console.log(`Registered nextResponse: ${keybinds.nextResponse}`);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Failed to register nextResponse (${keybinds.nextResponse}):`,
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Register scroll up shortcut
|
||||
if (keybinds.scrollUp) {
|
||||
try {
|
||||
globalShortcut.register(keybinds.scrollUp, () => {
|
||||
console.log("Scroll up shortcut triggered");
|
||||
sendToRenderer("scroll-response-up");
|
||||
});
|
||||
console.log(`Registered scrollUp: ${keybinds.scrollUp}`);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Failed to register scrollUp (${keybinds.scrollUp}):`,
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Register scroll down shortcut
|
||||
if (keybinds.scrollDown) {
|
||||
try {
|
||||
globalShortcut.register(keybinds.scrollDown, () => {
|
||||
console.log("Scroll down shortcut triggered");
|
||||
sendToRenderer("scroll-response-down");
|
||||
});
|
||||
console.log(`Registered scrollDown: ${keybinds.scrollDown}`);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Failed to register scrollDown (${keybinds.scrollDown}):`,
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Register expand response shortcut
|
||||
if (keybinds.expandResponse) {
|
||||
try {
|
||||
globalShortcut.register(keybinds.expandResponse, () => {
|
||||
console.log("Expand response shortcut triggered");
|
||||
sendToRenderer("expand-response");
|
||||
});
|
||||
console.log(`Registered expandResponse: ${keybinds.expandResponse}`);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Failed to register expandResponse (${keybinds.expandResponse}):`,
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Register emergency erase shortcut
|
||||
if (keybinds.emergencyErase) {
|
||||
try {
|
||||
globalShortcut.register(keybinds.emergencyErase, () => {
|
||||
console.log("Emergency Erase triggered!");
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.hide();
|
||||
|
||||
if (geminiSessionRef.current) {
|
||||
geminiSessionRef.current.close();
|
||||
geminiSessionRef.current = null;
|
||||
}
|
||||
|
||||
sendToRenderer("clear-sensitive-data");
|
||||
|
||||
setTimeout(() => {
|
||||
const { app } = require("electron");
|
||||
app.quit();
|
||||
}, 300);
|
||||
}
|
||||
});
|
||||
console.log(`Registered emergencyErase: ${keybinds.emergencyErase}`);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Failed to register emergencyErase (${keybinds.emergencyErase}):`,
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setupWindowIpcHandlers(mainWindow, sendToRenderer, geminiSessionRef) {
|
||||
ipcMain.on('view-changed', (event, view) => {
|
||||
if (!mainWindow.isDestroyed()) {
|
||||
const primaryDisplay = screen.getPrimaryDisplay();
|
||||
const { width: screenWidth } = primaryDisplay.workAreaSize;
|
||||
ipcMain.on("view-changed", (event, view) => {
|
||||
if (!mainWindow.isDestroyed()) {
|
||||
const primaryDisplay = screen.getPrimaryDisplay();
|
||||
const { width: screenWidth } = primaryDisplay.workAreaSize;
|
||||
|
||||
if (view === 'assistant') {
|
||||
// Shrink window for live view
|
||||
const liveWidth = 850;
|
||||
const liveHeight = 400;
|
||||
const x = Math.floor((screenWidth - liveWidth) / 2);
|
||||
mainWindow.setSize(liveWidth, liveHeight);
|
||||
mainWindow.setPosition(x, 0);
|
||||
} else {
|
||||
// Restore full size
|
||||
const fullWidth = 1100;
|
||||
const fullHeight = 800;
|
||||
const x = Math.floor((screenWidth - fullWidth) / 2);
|
||||
mainWindow.setSize(fullWidth, fullHeight);
|
||||
mainWindow.setPosition(x, 0);
|
||||
mainWindow.setIgnoreMouseEvents(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (view === "assistant") {
|
||||
// Shrink window for live view
|
||||
const liveWidth = 850;
|
||||
const liveHeight = 400;
|
||||
const x = Math.floor((screenWidth - liveWidth) / 2);
|
||||
mainWindow.setSize(liveWidth, liveHeight);
|
||||
mainWindow.setPosition(x, 0);
|
||||
} else {
|
||||
// Restore full size
|
||||
const fullWidth = 1100;
|
||||
const fullHeight = 800;
|
||||
const x = Math.floor((screenWidth - fullWidth) / 2);
|
||||
mainWindow.setSize(fullWidth, fullHeight);
|
||||
mainWindow.setPosition(x, 0);
|
||||
mainWindow.setIgnoreMouseEvents(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('window-minimize', () => {
|
||||
if (!mainWindow.isDestroyed()) {
|
||||
mainWindow.minimize();
|
||||
}
|
||||
});
|
||||
ipcMain.handle("window-minimize", () => {
|
||||
if (!mainWindow.isDestroyed()) {
|
||||
mainWindow.minimize();
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('update-keybinds', (event, newKeybinds) => {
|
||||
if (!mainWindow.isDestroyed()) {
|
||||
updateGlobalShortcuts(newKeybinds, mainWindow, sendToRenderer, geminiSessionRef);
|
||||
}
|
||||
});
|
||||
ipcMain.on("update-keybinds", (event, newKeybinds) => {
|
||||
if (!mainWindow.isDestroyed()) {
|
||||
updateGlobalShortcuts(
|
||||
newKeybinds,
|
||||
mainWindow,
|
||||
sendToRenderer,
|
||||
geminiSessionRef,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('toggle-window-visibility', async event => {
|
||||
try {
|
||||
if (mainWindow.isDestroyed()) {
|
||||
return { success: false, error: 'Window has been destroyed' };
|
||||
}
|
||||
ipcMain.handle("toggle-window-visibility", async (event) => {
|
||||
try {
|
||||
if (mainWindow.isDestroyed()) {
|
||||
return { success: false, error: "Window has been destroyed" };
|
||||
}
|
||||
|
||||
if (mainWindow.isVisible()) {
|
||||
mainWindow.hide();
|
||||
} else {
|
||||
mainWindow.showInactive();
|
||||
}
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error('Error toggling window visibility:', error);
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
});
|
||||
if (mainWindow.isVisible()) {
|
||||
mainWindow.hide();
|
||||
} else {
|
||||
mainWindow.showInactive();
|
||||
}
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error("Error toggling window visibility:", error);
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('update-sizes', async event => {
|
||||
// With the sidebar layout, the window size is user-controlled.
|
||||
// This handler is kept for compatibility but is a no-op now.
|
||||
return { success: true };
|
||||
});
|
||||
ipcMain.handle("update-sizes", async (event) => {
|
||||
// With the sidebar layout, the window size is user-controlled.
|
||||
// This handler is kept for compatibility but is a no-op now.
|
||||
return { success: true };
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createWindow,
|
||||
getDefaultKeybinds,
|
||||
updateGlobalShortcuts,
|
||||
setupWindowIpcHandlers,
|
||||
createWindow,
|
||||
getDefaultKeybinds,
|
||||
updateGlobalShortcuts,
|
||||
setupWindowIpcHandlers,
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user