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
This commit is contained in:
kolaente
2026-03-03 23:38:30 +01:00
parent 86e476ee72
commit 86141e13be
3 changed files with 23 additions and 8 deletions

View File

@@ -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) => {

View File

@@ -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),
})

View File

@@ -1,5 +1,6 @@
interface Window {
quickEntry?: {
close: () => void
resize: (width: number, height: number) => void
}
}