Commit Graph
1 Commits
Author SHA1 Message Date
yetone ffc18a850d agent: an app folder is listed and an Info.plist read again only when it changed
The Agents page asks every desktop app whether it is installed, and its
version, on each poll. Each ask listed /Applications and ~/Applications
whole (os.ReadDir, for the one-level-down folders of #2325) and read
every candidate bundle's Info.plist. With real accounts, 40 window polls
spent 38.6 MB of allocations in Agent.Detected, 14.5 MB of it ReadDir.

folderSubs keeps a folder's non-bundle subfolders while its
modification time stays (adding, removing or renaming an entry changes
it), and bundleInfo keeps what an Info.plist said while its size and
modification time stay. A time under 2s old is never trusted, as git
treats a racily clean index. macBundle and desktopApp.version read
through bundleInfo; what each reports is unchanged.

Run on mote (macOS), at this tree:
- gofmt clean; go vet ./internal/agent for darwin, windows and linux ok.
- TestAppFoldersReadAgainOnlyWhenChanged alone 3/3 ok.
- Broken by hand: never trusting the kept list and plist -> "an
  unchanged app folder and Info.plist cost 1268 allocations a look";
  trusting them whatever changed -> "Moved.app in a folder added since
  isn't found" and "Kept.app's Info.plist says another id now".
- go test ./internal/agent ./internal/tui ./internal/cli: ok.
- go test ./internal/gui (with the next commit's providers.go too): red
  only on TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestMainWindowCorners (#3949), as before.
- Real-account sandbox, 40 window polls against v0.1.2504's tree:
  total allocations 509.9 -> 427.6 MB, Agent.Detected 38.6 -> 21.5 MB,
  os.ReadDir 14.5 -> 4.0 MB; /api/state and drift output byte-identical.
  phys_footprint_peak 139 MB (136 before; within run noise).
Not run: the whole ./... suite; the Linux and Windows app paths (they
don't reach these readers).
2026-11-01 08:12:34 +08:00