Skip to content

Refactor download history popup to support multiple windows#553

Merged
timche merged 6 commits intomainfrom
claude/add-download-popup-googleapp-5Lnke
Apr 24, 2026
Merged

Refactor download history popup to support multiple windows#553
timche merged 6 commits intomainfrom
claude/add-download-popup-googleapp-5Lnke

Conversation

@timche
Copy link
Copy Markdown
Collaborator

@timche timche commented Apr 24, 2026

Summary

Refactored the download history popup system to be window-agnostic, allowing the popup to be opened from any window rather than being tied to the main window. This enables better support for multi-window scenarios and improves code maintainability.

Key Changes

  • Removed main window dependency: Eliminated the import of main from downloads.ts and replaced hardcoded references to main.window with a parentWindow parameter passed at runtime
  • Added parent window tracking: Introduced recentDownloadHistoryParentWindow field to track which window owns the current popup, enabling proper cleanup and bounds calculations
  • Renamed for clarity: Changed recentDownloadHistoryPopup to recentDownloadHistoryView to better reflect that it's a view, not a window
  • Updated toggle logic: Modified toggleRecentDownloadHistoryPopup() to accept a BrowserWindow parameter and intelligently handle toggling (closes if same window, opens in new window if different)
  • Fixed IPC integration: Updated the IPC handler to extract the parent window from the event sender, ensuring the popup opens in the correct window context
  • Unified button styling: Refactored both main and Google app titlebar download buttons to use consistent TitlebarIconButton component and naming (RecentDownloadHistoryButton)
  • Updated documentation: Added example to CLAUDE.md coding guidelines showing parentWindowBounds as a better alternative to generic names

Implementation Details

  • The popup now calculates bounds relative to the parent window's dimensions, with platform-specific handling for Windows (using getContentBounds()) vs other platforms (using getBounds())
  • Popup state is properly cleaned up when switching between windows or closing
  • All event listeners are attached to the correct parent window instance

https://claude.ai/code/session_01FCKbXY2185E7Jk4QxxVuQA

@timche timche merged commit e711096 into main Apr 24, 2026
7 checks passed
@timche timche deleted the claude/add-download-popup-googleapp-5Lnke branch April 24, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants