Skip to content

fix: unminimize Ghostty window before raising on focus#340

Merged
Wirasm merged 3 commits into
mainfrom
kild/289-ghostty-focus-hide
Feb 11, 2026
Merged

fix: unminimize Ghostty window before raising on focus#340
Wirasm merged 3 commits into
mainfrom
kild/289-ghostty-focus-hide

Conversation

@Wirasm

@Wirasm Wirasm commented Feb 11, 2026

Copy link
Copy Markdown
Owner

Summary

After the Core Graphics migration (#286), kild focus could not restore a window previously minimized via kild hide. The AX API focus path only raised the window without unsetting kAXMinimizedAttribute, so hidden windows stayed in the Dock.

Root Cause

focus_window() in macos.rs called ax_perform_raise() which only sets AXRaised/AXMain attributes — neither undoes minimize. The is_minimized field was tracked in NativeWindowInfo but never checked or acted upon in the focus path.

Changes

File Change
crates/kild-core/src/terminal/native/macos.rs Add UnminimizeAndRaise variant to WindowAction enum
crates/kild-core/src/terminal/native/macos.rs Add ax_unminimize_and_raise_window() function
crates/kild-core/src/terminal/native/macos.rs Check is_minimized in focus_window() and unminimize before raising
crates/kild-core/src/terminal/native/macos.rs Add test for new WindowAction variant

Testing

  • cargo fmt --check passes
  • cargo clippy --all -- -D warnings passes
  • cargo test --all passes
  • Manual: kild hide branchkild focus branch restores window from Dock

Validation

cargo fmt --check && cargo clippy --all -- -D warnings && cargo test --all

Issue

Fixes #289

Implementation Details

Implementation followed artifact:

.claude/PRPs/issues/issue-289.md

Deviations from plan:

None

Root cause: focus_window doesn't unminimize — AXRaised + activate_app
don't undo kAXMinimizedAttribute set by kild hide. Need to add
UnminimizeAndRaise action that sets kAXMinimized=false before raising.
After the Core Graphics migration (#286), `kild focus` could not restore
a window previously minimized via `kild hide` because the AX API focus
path only raised the window without unsetting kAXMinimizedAttribute.

Changes:
- Add UnminimizeAndRaise variant to WindowAction enum
- Add ax_unminimize_and_raise_window function mirroring existing pattern
- Check is_minimized in focus_window and unminimize before raising
- Add test for new WindowAction variant

Fixes #289
@Wirasm

Wirasm commented Feb 11, 2026

Copy link
Copy Markdown
Owner Author

Automated Code Review

Summary

The fix correctly implements the unminimize-before-raise sequence for Ghostty windows. Code follows established codebase patterns with proper AX API memory management.

Strengths

  • Root cause directly addressed: focus_window() now checks is_minimized and calls ax_unminimize_and_raise_window() before raising
  • ax_unminimize_and_raise_window() follows exact same structure as ax_raise_window() and ax_minimize_window()
  • Memory management correct: AXUIElement Create Rule ownership, proper CFRelease
  • Structured logging added for the new unminimize code path
  • Existing fallback to activate_app() preserved when AX fails

Suggestions (non-blocking)

  • Test could use exhaustive match pattern instead of array length check for stronger compile-time verification
  • Optional: Add specific log event when unminimize fails vs general AX failure (currently uses same fallback warning)

Security

  • No security concerns — reuses existing AX API patterns, no new input handling or external operations

Checklist

  • Fix addresses root cause from investigation
  • Code follows codebase patterns
  • Tests cover the change (compile-time variant check; integration tests require running Ghostty)
  • No obvious bugs introduced

Self-reviewed

Add dedicated focus_unminimize_failed log event to distinguish unminimize
failures from general AX raise failures — helps debug Ghostty AX quirks.

Replace array length test with exhaustive match test for WindowAction
variants, providing stronger compile-time guarantees.
@Wirasm Wirasm merged commit 36106b0 into main Feb 11, 2026
6 checks 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.

bug: investigate kild hide and kild focus issues with Ghostty after Core Graphics migration

1 participant