szn

Bug 300 — getForegroundProcessName called every render for automatic_rename windows

300. getForegroundProcessName called every render for automatic_rename windows

File: src/server/server.zig:2646–2665 Severity: MEDIUM Status: ✅ FIXED

Every renderToDisplayClient() call (once per loop iteration, up to ~10/sec when idle, more when dirty) walks all windows and calls getForegroundProcessName() for any window with automatic_rename set.

On macOS this is a proc_pidinfo() syscall. On Linux it reads /proc/{pgid}/comm. Both are relatively expensive for a hot path.

The result is compared against win.name, but the syscall happens regardless. If the name hasn’t changed, the syscall is wasted.

Fix: Add a dirty flag on the window or a separate name_needs_refresh flag. Only call getForegroundProcessName when the name has actually changed or on a timer (e.g. every 500ms). The name rarely changes more than once per foreground process switch, so checking every render is wasteful.

Suggested approach: