From 86141e13be88242735363e6697473c8f3bc5e987 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 3 Mar 2026 23:38:30 +0100 Subject: [PATCH] fix(desktop): reduce quick entry window height, add resize IPC, fix focus - Reduce initial window height from 500px to 120px so it only shows the input bar without excess space - Add quick-entry:resize IPC channel so the frontend can expand the window when the help modal opens and collapse it when closed - Wait for did-finish-load before showing/focusing the window so the input gets properly focused on each invocation --- desktop/main.js | 29 +++++++++++++++++++++-------- desktop/preload-quick-entry.js | 1 + frontend/src/types/quick-entry.d.ts | 1 + 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/desktop/main.js b/desktop/main.js index 9a0614905..3a750eb10 100644 --- a/desktop/main.js +++ b/desktop/main.js @@ -16,6 +16,9 @@ const portInUse = require('./portInUse.js') const frontendPath = 'frontend/' const SAFE_PROTOCOLS = new Set(['http:', 'https:', 'mailto:']) +const QUICK_ENTRY_WIDTH = 680 +const QUICK_ENTRY_COLLAPSED_HEIGHT = 120 + function safeOpenExternal(url) { try { const parsed = new URL(url) @@ -94,14 +97,12 @@ function createMainWindow() { function createQuickEntryWindow() { const display = screen.getPrimaryDisplay() const {width: screenWidth, height: screenHeight} = display.workAreaSize - const winWidth = 680 - const winHeight = 500 quickEntryWindow = new BrowserWindow({ - width: winWidth, - height: winHeight, - x: Math.round((screenWidth - winWidth) / 2), - y: Math.round(screenHeight / 3 - winHeight / 2), + width: QUICK_ENTRY_WIDTH, + height: QUICK_ENTRY_COLLAPSED_HEIGHT, + x: Math.round((screenWidth - QUICK_ENTRY_WIDTH) / 2), + y: Math.round(screenHeight / 3 - QUICK_ENTRY_COLLAPSED_HEIGHT / 2), frame: false, transparent: true, alwaysOnTop: true, @@ -150,10 +151,16 @@ function showQuickEntry() { return } + // Reset to collapsed height for each new invocation + quickEntryWindow.setSize(QUICK_ENTRY_WIDTH, QUICK_ENTRY_COLLAPSED_HEIGHT) + // Reload to reset Vue state (clear previous input) quickEntryWindow.loadURL(`http://127.0.0.1:${serverPort}/?mode=quick-add`) - quickEntryWindow.show() - quickEntryWindow.focus() + // Wait for page to finish loading before showing, so the input gets focused + quickEntryWindow.webContents.once('did-finish-load', () => { + quickEntryWindow.show() + quickEntryWindow.focus() + }) } function hideQuickEntry() { @@ -221,6 +228,12 @@ ipcMain.on('quick-entry:close', () => { hideQuickEntry() }) +ipcMain.on('quick-entry:resize', (_event, width, height) => { + if (quickEntryWindow) { + quickEntryWindow.setSize(width, height) + } +}) + // ─── App lifecycle ─────────────────────────────────────────────────── app.whenReady().then(() => { startServer((port) => { diff --git a/desktop/preload-quick-entry.js b/desktop/preload-quick-entry.js index 813793e4e..bad2de093 100644 --- a/desktop/preload-quick-entry.js +++ b/desktop/preload-quick-entry.js @@ -3,4 +3,5 @@ const { contextBridge, ipcRenderer } = require('electron') contextBridge.exposeInMainWorld('quickEntry', { close: () => ipcRenderer.send('quick-entry:close'), + resize: (width, height) => ipcRenderer.send('quick-entry:resize', width, height), }) diff --git a/frontend/src/types/quick-entry.d.ts b/frontend/src/types/quick-entry.d.ts index b3d7ad87e..553c3e145 100644 --- a/frontend/src/types/quick-entry.d.ts +++ b/frontend/src/types/quick-entry.d.ts @@ -1,5 +1,6 @@ interface Window { quickEntry?: { close: () => void + resize: (width: number, height: number) => void } }