Skip to content

fix: focus window on single-instance activation#209

Merged
ErikBjare merged 1 commit intoActivityWatch:masterfrom
TimeToBuildBob:fix/single-instance-focus
Feb 23, 2026
Merged

fix: focus window on single-instance activation#209
ErikBjare merged 1 commit intoActivityWatch:masterfrom
TimeToBuildBob:fix/single-instance-focus

Conversation

@TimeToBuildBob
Copy link
Copy Markdown
Contributor

@TimeToBuildBob TimeToBuildBob commented Feb 23, 2026

Summary

  • Add window.set_focus() after window.show() in the single-instance file watcher handler, matching the existing tray "Open Dashboard" handler pattern
  • Without this, launching a second instance shows the existing window but leaves it behind other windows

Fixes #208


Important

Add window.set_focus() in listen_for_lockfile() to focus the main window on second instance launch.

  • Behavior:
    • Add window.set_focus() after window.show() in listen_for_lockfile() in lib.rs to focus the main window when a second instance is launched.
    • Matches the existing behavior in the tray "Open Dashboard" handler.
  • Fixes:

This description was created by Ellipsis for 6afc5b1. You can customize this summary. It will automatically update as commits are pushed.

The single-instance file watcher handler called window.show() but not
window.set_focus(), causing the window to appear but stay behind other
windows. This matches the tray "Open Dashboard" handler which correctly
does both.

Fixes ActivityWatch#208
Copy link
Copy Markdown

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to 6afc5b1 in 16 seconds. Click for details.
  • Reviewed 12 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.

Workflow ID: wflow_aLfZrU0h25ZvgBQR

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Feb 23, 2026

Greptile Summary

Adds window.set_focus() after window.show() in listen_for_lockfile() so that when a second instance is launched, the existing window is both shown and brought to the foreground. This matches the existing pattern used in the tray "Open Dashboard" menu handler.

  • Adds window.set_focus().expect("Failed to focus main window") at line 215 in listen_for_lockfile()
  • Fixes bug: single-instance handler shows window but doesn't focus it #208 where the main window would appear behind other windows on second instance activation
  • No issues found; the change is minimal, correct, and consistent with the codebase

Confidence Score: 5/5

  • This PR is safe to merge with no risk — it adds a single well-understood Tauri API call that matches an existing pattern in the same file.
  • The change is a single line addition calling set_focus() after show(), directly mirroring the existing tray handler pattern at line 607-608. The Tauri set_focus() API is well-established. No logic changes, no new dependencies, no edge cases.
  • No files require special attention.

Important Files Changed

Filename Overview
src-tauri/src/lib.rs Adds window.set_focus() after window.show() in listen_for_lockfile(), matching the existing tray "Open Dashboard" handler pattern. Minimal, correct change.

Sequence Diagram

sequenceDiagram
    participant User as User (2nd Instance)
    participant Plugin as single_instance plugin
    participant Lockfile as single_instance.lock
    participant Watcher as listen_for_lockfile()
    participant Window as Main Window

    User->>Plugin: Launch 2nd instance
    Plugin->>Lockfile: Create/truncate lock file
    Plugin->>Plugin: Log & quit 2nd instance
    Lockfile-->>Watcher: File change detected
    Watcher->>Lockfile: Remove lock file
    Watcher->>Window: window.show()
    Watcher->>Window: window.set_focus() ✨ NEW
Loading

Last reviewed commit: 6afc5b1

Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@TimeToBuildBob
Copy link
Copy Markdown
Contributor Author

@greptileai review

Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@ErikBjare ErikBjare merged commit f10e26e into ActivityWatch:master Feb 23, 2026
7 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: single-instance handler shows window but doesn't focus it

2 participants