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:
last_foreground_name: []const u8 to Window (owned, freed on deinit)getForegroundProcessName when last_foreground_name is null or differs from current win.name