Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ let updateInfo: { version: string; progress: number } | null = null
let lastAutoExportDate: string | null = null
let lastImportedExportDate: string | null = null

/** Ignore blur-to-hide briefly after showing (shortcut keyup race). */
let ignoreBlurUntil = 0

const POPUP_WIDTH = 360
const POPUP_HEIGHT = 680
const DEFAULT_SHORTCUT = 'CommandOrControl+Shift+M'
Expand Down Expand Up @@ -98,8 +101,9 @@ function createPopupWindow(): void {
}
})

// Hide when clicking outside
// Hide when clicking outside (skip briefly after show — shortcut keyup can blur)
popupWindow.on('blur', () => {
if (Date.now() < ignoreBlurUntil) return
popupWindow?.hide()
})

Expand Down Expand Up @@ -144,11 +148,17 @@ function togglePopup(): void {
popupWindow.hide()
} else {
const { x, y } = getPopupPosition()
popupWindow.setPosition(x, y, false)
// Re-assert bounds every open — size/position can drift after Space/display changes.
popupWindow.setBounds({ x, y, width: POPUP_WIDTH, height: POPUP_HEIGHT }, false)
popupWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true })
popupWindow.setAlwaysOnTop(true, 'pop-up-menu')
// Shortcut keyup often blurs the newly focused window; ignore hide briefly.
ignoreBlurUntil = Date.now() + 400
popupWindow.show()
popupWindow.focus()
// Force a repaint after hide→show (transparent/vibrancy can leave a blank band).
popupWindow.webContents.invalidate()
popupWindow.webContents.send('popup-shown')
}
}

Expand Down
1 change: 1 addition & 0 deletions src/preload/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export interface API {
// Interview Mode
getInterviewMode: () => Promise<boolean>
setInterviewMode: (enabled: boolean) => Promise<{ success: boolean; enabled: boolean }>
onPopupShown: (callback: () => void) => () => void
}

declare global {
Expand Down
10 changes: 9 additions & 1 deletion src/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ const api = {

// Interview Mode
getInterviewMode: () => ipcRenderer.invoke('get-interview-mode'),
setInterviewMode: (enabled: boolean) => ipcRenderer.invoke('set-interview-mode', enabled)
setInterviewMode: (enabled: boolean) => ipcRenderer.invoke('set-interview-mode', enabled),

onPopupShown: (callback: () => void) => {
const listener = (): void => callback()
ipcRenderer.on('popup-shown', listener)
return () => {
ipcRenderer.removeListener('popup-shown', listener)
}
}
}

// Expose APIs
Expand Down
24 changes: 24 additions & 0 deletions src/renderer/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@
// Interview mode state
let interviewModeEnabled = $state(false)

function resetPopupLayout(): void {
// Transparent/vibrancy popups can open with a blank band until layout is nudged.
window.scrollTo(0, 0)
document.documentElement.scrollTop = 0
document.body.scrollTop = 0
const list = document.querySelector('.flex-1.overflow-y-auto')
if (list instanceof HTMLElement) list.scrollTop = 0
// Force a style recalc / paint on the root shell.
const root = document.getElementById('app')
if (root) {
root.style.transform = 'translateZ(0)'
requestAnimationFrame(() => {
root.style.transform = ''
})
}
}

onMount(() => {
// Initialize async operations
const init = async (): Promise<void> => {
Expand All @@ -72,15 +89,22 @@
// Refresh data when window becomes visible (e.g., popup shown after new day)
const handleVisibilityChange = async (): Promise<void> => {
if (document.visibilityState === 'visible') {
resetPopupLayout()
const set = $currentProblemSet
await Promise.all([loadTodayReviews(), loadProblems(), loadStats(set), loadActivity()])
}
}
document.addEventListener('visibilitychange', handleVisibilityChange)

// Main process notifies after shortcut/tray show — reset scroll/layout in case of a blank band.
const unsubscribePopupShown = window.api.onPopupShown(() => {
resetPopupLayout()
})

return () => {
if (updateCheckInterval) clearInterval(updateCheckInterval)
document.removeEventListener('visibilitychange', handleVisibilityChange)
unsubscribePopupShown()
}
})

Expand Down
4 changes: 2 additions & 2 deletions src/renderer/src/components/HomeView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
</div>
{:else if $completedInSession >= sessionQuota && $completedInSession > 0}
<!-- Quota completed -->
<div class="flex flex-col items-center justify-center h-full">
<div class="flex flex-col items-center justify-center min-h-[76px]">
<div class="text-sm text-gray-500 dark:text-gray-400 mb-1">✨ Session completed</div>
{#if $todayReviewsCount > 0}
<div class="text-xs text-gray-400 dark:text-gray-500 mb-2">
Expand All @@ -301,7 +301,7 @@
</div>
{:else}
<!-- No reviews due but some completed -->
<div class="flex flex-col items-center justify-center h-full">
<div class="flex flex-col items-center justify-center min-h-[76px]">
<div class="text-sm text-gray-500 dark:text-gray-400">
✨ All caught up! ({$completedInSession} reviewed today)
</div>
Expand Down
Loading