Skip to content

fix(tray): stop the Windows tray launching the CLI instead of the GUI - #460

Merged
davidbudnick merged 2 commits into
AprilNEA:masterfrom
Stanley5249:fix/tray-launches-cli
Aug 1, 2026
Merged

fix(tray): stop the Windows tray launching the CLI instead of the GUI#460
davidbudnick merged 2 commits into
AprilNEA:masterfrom
Stanley5249:fix/tray-launches-cli

Conversation

@Stanley5249

@Stanley5249 Stanley5249 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

On Windows the tray's "Show Main Window" launched the CLI instead of the GUI, and
Show/Quit could report GUI process is running but no window was found to focus.

Root cause: tray_windows.rs identifies the GUI by filename — OpenLogi.exe
(installed) or openlogi-gui.exe (dev). The CLI binary is openlogi.exe, and two
independent things went wrong in a cargo target dir:

  • gui_pids() compared process image names with eq_ignore_ascii_case, so a transient
    openlogi.exe CLI run counted as the GUI — hence the "no window to focus" report.
    This is the comparison's own doing, not the filesystem's.
  • spawn_gui() probed dir.join("OpenLogi.exe").exists(). Win32 path lookup is
    case-insensitive, so that name resolved to the CLI's openlogi.exe and the tray
    launched it.

The installed layout ships only OpenLogi.exe + openlogi-agent.exe (no CLI), so this
only bites dev/portable layouts — but it's a real filename-collision bug.

Changes

  • agent (tray): extract is_gui_process_name() and match the product GUI
    OpenLogi.exe case-sensitively — Windows reports image names with their on-disk
    case, so the lowercase CLI openlogi.exe no longer counts as the GUI.
  • agent (tray): probe the unambiguous openlogi-gui.exe first in spawn_gui(), so
    .exists() can't resolve OpenLogi.exe to the CLI on the case-insensitive filesystem.
  • agent (tray): add a unit test pinning all three binary names.

Testing

cargo clippy -p openlogi-agent --all-targets -- -D warnings — clean.

Note the new is_gui_process_name test sits in a Windows-only module, so it runs only on
a Windows host — CI's test jobs are macOS/Linux, so they skip it. clippy (windows) is
the only CI job that compiles this file.

Windows-only tray behaviour, not runtime-tested on hardware: verify by rebuilding the
agent and clicking the tray — it should open the GUI window, not print a device list.

Fixes the wrong-binary launch reported on Windows dev builds.

@greptile-apps

greptile-apps Bot commented Jul 24, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a binary name collision in the Windows tray on dev/cargo-target-dir builds: eq_ignore_ascii_case("OpenLogi.exe") matched the CLI binary openlogi.exe because the Windows filesystem is case-insensitive, causing the tray to track and launch the CLI instead of the GUI.

  • is_gui_process_name now matches OpenLogi.exe with a case-sensitive equality check (relying on NTFS preserving on-disk casing in process image names), while keeping openlogi-gui.exe case-insensitive since there is no ambiguous sibling for it.
  • spawn_gui probes openlogi-gui.exe before OpenLogi.exe so that on a case-insensitive filesystem dir.join("OpenLogi.exe").exists() no longer resolves to the CLI; the installed layout, which only ships OpenLogi.exe, still works via the fallthrough.
  • A unit test is added covering the GUI (both names) and CLI cases.

Confidence Score: 5/5

Safe to merge — the change is a targeted, well-reasoned fix for a real binary-name collision on Windows dev builds, with no regressions in the installed layout.

Both changes are narrow and correctly address the root cause. The case-sensitive process-name match relies on NTFS preserving on-disk casing in process image names (documented in the new comment), which is the correct assumption for this Windows API surface. The spawn probe reorder eliminates the case-insensitive exists() false-positive without breaking the installed layout. The added unit test explicitly exercises the CLI-rejection path. No logic regressions were found.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
crates/openlogi-agent/src/tray_windows.rs Fixes GUI/CLI binary confusion on Windows dev layouts: case-sensitive match for OpenLogi.exe, probe openlogi-gui.exe first in spawn_gui, and adds a unit test covering all three key cases.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Tray: Show Main Window clicked] --> B[gui_pids]
    B --> C{is_gui_process_name?}
    C -->|name == 'OpenLogi.exe' case-SENSITIVE| D[GUI PID collected]
    C -->|name eq_ignore_ascii_case 'openlogi-gui.exe'| D
    C -->|'openlogi.exe' CLI - NO MATCH fixed| E[Rejected]
    D --> F{pids empty?}
    F -->|No| G[focus_window_of pids]
    F -->|Yes| H[spawn_gui]
    H --> I{Probe order}
    I -->|1. openlogi-gui.exe unambiguous dev binary| J{exists?}
    J -->|Yes| K[Spawn openlogi-gui.exe]
    J -->|No - installed layout| L{OpenLogi.exe exists?}
    L -->|Yes| M[Spawn OpenLogi.exe]
    L -->|No| N[Warn: no GUI binary found]
Loading

Reviews (3): Last reviewed commit: "test(tray): pin that the Windows CLI bin..." | Re-trigger Greptile

The CLI binary `openlogi.exe` case-insensitively equals the GUI's
`OpenLogi.exe`, so in a cargo target dir — the only layout holding both — the
tray's Show/Quit mistook a transient CLI run for the GUI, and `spawn_gui`
launched the CLI (`dir.join("OpenLogi.exe").exists()` resolves to it on the
case-insensitive filesystem) instead of the window.

Match `OpenLogi.exe` case-sensitively so the lowercase CLI no longer counts as
the GUI, and probe the unambiguous `openlogi-gui.exe` first when spawning.
The GUI/CLI discrimination is one string comparison, and its failure mode
is silent: Show would spawn a duplicate GUI that immediately exits on the
singleton lock, so nothing visible happens. Extract the predicate out of
`gui_pids`'s filter and assert all three names, so a regression fails a
local `cargo test` on Windows instead of only showing up as a dead tray
menu. CI does not run it: the module is cfg'd to Windows and the only
Windows job is clippy, which compiles the test but never executes it.

Also record why the two names are matched differently — `OpenLogi.exe`
exactly (the CLI `openlogi.exe` collides with it case-insensitively) and
`openlogi-gui.exe` case-insensitively (nothing else shares that name).
@Stanley5249
Stanley5249 force-pushed the fix/tray-launches-cli branch from 0a202a1 to 85e67e6 Compare August 1, 2026 03:07
@Stanley5249

Copy link
Copy Markdown
Contributor Author

@davidbudnick mind taking a look at this one? Thanks.

@davidbudnick davidbudnick added the platform: windows Windows-specific issue label Aug 1, 2026
@davidbudnick

Copy link
Copy Markdown
Collaborator

@davidbudnick mind taking a look at this one? Thanks.

Yup, looks good to me!

@davidbudnick
davidbudnick merged commit 323b6e4 into AprilNEA:master Aug 1, 2026
24 checks passed
@Stanley5249
Stanley5249 deleted the fix/tray-launches-cli branch August 3, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: windows Windows-specific issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants