Repository navigation
Conversation
unRekable
left a comment
There was a problem hiding this comment.
Code Review
🟡 5 findings (4 blocking).
Stage 1 of G3: a Windows tray icon behind an opt-in shell.prefs line, close-into-tray with a one-time balloon, and a Quit that reuses menubar::quit so chatd stops as on every other way out. The design holds: the hidden helper window rides GPUI's message pump, the quit ask crosses threads only as an atomic drained by the existing 500 ms loop, the prefs line is additive with junk-reads-off and old builds keep the line, and the platform cfg arms are complete. What fails is the windows-rs API layer: four 0.62 signature mismatches, verified against the published windows 0.62.2 the lockfile resolves, that cannot compile on the one platform this targets. One further gap: the icon is never re-added on the shell's TaskbarCreated broadcast, so after an explorer restart the close path hides the window with no way back in.
Residual risk
- main_window() returns the first top-level, unowned, titled window of the process in Z-order, and the Settings window (gui/settings/mod.rs:321) is titled too, so it is an equally qualified candidate; which window the tray click restores after a hide depends on where Windows keeps a hidden window in the Z-order. Remembering GPUI's own HWND instead of enumerating would remove the guess.
- The tray's Quit is delivered by the 500 ms loop through
let _ = cx.update(...); a Quit asked in the same tick as some other teardown is dropped silently. Harmless with today's loop body, but the swallow is worth remembering if the loop grows more work.
| }; | ||
| use windows::Win32::UI::WindowsAndMessaging::{ | ||
| AppendMenuW, CreatePopupMenu, CreateWindowExW, DefWindowProcW, DestroyMenu, DestroyWindow, EnumWindows, GetCursorPos, | ||
| GetModuleHandleW, GetWindow, GetWindowTextW, GetWindowThreadProcessId, HICON, IsIconic, LoadIconW, MF_STRING, PostMessageW, |
There was a problem hiding this comment.
🔴 Blocker: GetModuleHandleW is not in Win32::UI::WindowsAndMessaging: windows-rs 0.62.2 generates it only in Win32::System::LibraryLoader, so this import does not resolve and the Windows build cannot compile. No workspace crate enables the Win32_System_LibraryLoader feature on the windows 0.62 line (login and mediad list their features without it), so the fix needs both the import moved here and the feature added to crates/notifier/Cargo.toml.
| unsafe { | ||
| let _ = GetCursorPos(&mut at); | ||
| let _ = SetForegroundWindow(window); | ||
| let picked = TrackPopupMenu(items, TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, at.x, at.y, 0, window, None); |
There was a problem hiding this comment.
🔴 Blocker: windows-rs 0.62 declares TrackPopupMenu's fifth parameter as nreserved: Option, so the bare 0 is a type error and this cannot compile; pass Some(0).
| let picked = TrackPopupMenu(items, TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, at.x, at.y, 0, window, None); | |
| let picked = TrackPopupMenu(items, TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, at.x, at.y, Some(0), window, None); |
| let _ = GetCursorPos(&mut at); | ||
| let _ = SetForegroundWindow(window); | ||
| let picked = TrackPopupMenu(items, TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, at.x, at.y, 0, window, None); | ||
| let _ = PostMessageW(window, WM_NULL, WPARAM(0), LPARAM(0)); |
There was a problem hiding this comment.
🔴 Blocker: windows-rs 0.62 declares PostMessageW's hwnd as Option, so a bare HWND is a type error and this cannot compile.
| let _ = PostMessageW(window, WM_NULL, WPARAM(0), LPARAM(0)); | |
| let _ = PostMessageW(Some(window), WM_NULL, WPARAM(0), LPARAM(0)); |
| fn icon() -> Option<HICON> { | ||
| // SAFETY: reads our own module's resource table. | ||
| let module = unsafe { GetModuleHandleW(None) }.ok()?; | ||
| let icon = unsafe { LoadIconW(HINSTANCE(module.0), PCWSTR(1 as _)) }.ok()?; |
There was a problem hiding this comment.
🔴 Blocker: windows-rs 0.62 declares LoadIconW's first parameter as Option, so a bare HINSTANCE is a type error and this cannot compile.
| let icon = unsafe { LoadIconW(HINSTANCE(module.0), PCWSTR(1 as _)) }.ok()?; | |
| let icon = unsafe { LoadIconW(Some(HINSTANCE(module.0)), PCWSTR(1 as _)) }.ok()?; |
| } | ||
| } | ||
|
|
||
| unsafe extern "system" fn wnd_proc(window: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM) -> LRESULT { |
There was a problem hiding this comment.
Tiny Code Reviewthe AI provider rate-limited the request This is advice, not a gate. Re-run with the |
What changed and why
Windows gets a tray icon (issue #802, stage 1 of the plan). Turning on "Keep tinyclient in the
tray when I close the window" (Settings › General, G3 — off by default, so nothing changes
until it is on) makes closing the window hide it instead of quitting: chatd keeps receiving,
a one-time balloon says where the app went, and the icon's click brings the window back. The
icon's menu has Open tinyclient and Quit tinyclient, and Quit ends chatd exactly like ⌘Q does.
Type
Platforms
The tray is Windows only in this stage (
notifier::trayhas one backend). macOS, Linux,Android and iOS code paths are cfg-gated around, not changed: macOS and Linux still quit on
close as today, G3 is absent there, and the honest search line stays for their tray words.
Proof
Scenario: e2e/scenarios/tray-close-keeps-running
Lab run:
The driver closes the window with its X and proves the process stays and chatd still answers,
clicks the real tray icon and proves the window comes back, then chooses Quit in the icon's
menu and proves tinyclient and its chatd are gone. On the base build the first close quits the
process, so the base run fails.
Compatibility
No protocol change, no server involvement: the setting lives in the window's
shell.prefs,whose additive contract (unknown lines kept verbatim) means an older build never erases a
newer one's tray choice, and a missing line reads as off. Older clients and servers are
unaffected; nothing is removed or renamed. Off — the shipped default — is byte-for-byte
today's behavior, and the tray icon exists only while the choice is on.
Risk and rollback
The changed behavior is one branch in
close_window(menubar.rs) that only runs when thenew choice is on and the icon exists; with the choice off, closing quits as before. If it is
wrong, the setting is the rollback for users (turn it off), and
git revertof this PR is therollback for the code — no migration, no protocol, no server piece. Known residual risks are
listed in the plan (windows-rs signature check in CI; a hard process death leaves the icon
until hover, as every tray app's does).
Release note
Keep tinyclient running in the tray when you close its window (Windows): the icon in the
notification area brings the window back, and Quit there ends everything, like ⌘Q. Off by
default; find it in Settings › General.