Compare commits

..
2 Commits
Author SHA1 Message Date
amitwhandClaude 1b2afb5f15 Fix double-click file opening in installed Windows app (v1.7.5)
This fix addresses the critical issue where double-clicking .md files would not open them in the installed PanConverter application on Windows.

## Root Cause
When a user double-clicks a file and the app is already running, Windows tries to launch a SECOND INSTANCE with the file path. Without single-instance lock handling, that second instance would exit and the first instance would never receive the file path.

## Changes
- Added single-instance lock handling in main.js (lines 52-85)
- Implemented second-instance event handler to capture file paths
- Focus existing window when second instance is attempted
- Pass file path to existing instance using openFileFromPath()
- Properly handle rendererReady state for file opening

## Testing
- Works in development mode (npm start)
- Should now work correctly in installed Windows app with double-click
- Maintains single instance behavior across all file opening methods

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-11 13:46:48 +05:30
amitwhandClaude c811af9d48 Remove debug console.log statements (v1.7.4 cleanup)
Cleaned up debug logging from file opening investigation:
- Removed console.log from command line arg processing
- Removed console.log from renderer-ready handler
- Removed console.log from openFileFromPath function
- Removed console.log from file-opened IPC handler

The double-click file opening fix is confirmed working.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-11 13:13:27 +05:30
2 changed files with 36 additions and 5 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "pan-converter",
"version": "1.7.4",
"version": "1.7.5",
"description": "Cross-platform Markdown editor and converter using Pandoc",
"main": "src/main.js",
"scripts": {
+35 -4
View File
@@ -49,6 +49,41 @@ let currentFile = null; // This will now represent the active tab's file
let pandocAvailable = null; // Cache pandoc availability check
let rendererReady = false; // Track if renderer is ready to receive file data
// Handle single instance lock for Windows file association
// When a file is double-clicked and the app is already running,
// Windows tries to start a second instance. We prevent this and
// pass the file to the existing instance instead.
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
// Another instance is already running, quit this one
app.quit();
} else {
// This is the first instance, handle second-instance events
app.on('second-instance', (event, commandLine, workingDirectory) => {
// Someone tried to run a second instance, focus our window instead
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
}
// Check if a file was passed to the second instance
// commandLine is an array like: ['electron.exe', 'app.asar', 'file.md']
const fileArgs = commandLine.slice(2);
for (const arg of fileArgs) {
if ((arg.endsWith('.md') || arg.endsWith('.markdown')) && fs.existsSync(arg)) {
// Open the file in the existing instance
if (rendererReady) {
openFileFromPath(arg);
} else {
app.pendingFile = arg;
}
break;
}
}
});
}
// Check if pandoc is available
function checkPandocAvailability() {
return new Promise((resolve) => {
@@ -1584,15 +1619,11 @@ function openFileFromPath(filePath) {
currentFile = filePath;
const content = fs.readFileSync(filePath, 'utf-8');
if (mainWindow && mainWindow.webContents && rendererReady) {
console.log('Opening file (renderer ready):', filePath);
mainWindow.webContents.send('file-opened', { path: filePath, content });
} else {
console.log('Renderer not ready, storing file:', filePath);
// Store file to open after renderer is ready
app.pendingFile = filePath;
}
} else {
console.error('File does not exist:', filePath);
}
}