Skip to content

fix(gui): prevent background apps from stealing focus#1491

Merged
jelveh merged 2 commits intoHeyPuter:mainfrom
rajanarahul93:fix/terminal-focus-loss-clean
Sep 7, 2025
Merged

fix(gui): prevent background apps from stealing focus#1491
jelveh merged 2 commits intoHeyPuter:mainfrom
rajanarahul93:fix/terminal-focus-loss-clean

Conversation

@rajanarahul93
Copy link
Copy Markdown
Contributor

fix(gui): prevent background apps from stealing focus

Summary

This pull request fixes an issue where launching a background application from the terminal would incorrectly steal keyboard focus. The change introduces a condition to the window creation logic, ensuring that only foreground applications receive focus upon launch, thereby preserving the user's context in the terminal.

Root Cause

The UIWindow component was designed to unconditionally grant focus to any newly created window that was marked as visible. This behavior did not differentiate between interactive foreground applications and non-interactive background processes, causing the latter to incorrectly steal focus from the active window.

Changes

  • Added a new options.background property to the UIWindow component, which defaults to false.
  • Modified the initial window creation logic in UIWindow.js to only call focusWindow() if the options.background property is false.
  • Updated two additional event handlers (drop and dragster:enter) to also respect the options.background flag, ensuring focus is not stolen during drag-and-drop operations.

Closes #453

@jelveh jelveh merged commit cddfa0c into HeyPuter:main Sep 7, 2025
1 check passed
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.

Terminal loses focus when running a background app

2 participants