fix: cap logBuffer at 100k chars to prevent unbounded growth

Every brew command appended its full output to logBuffer and nothing
ever trimmed it, so with the hourly refresh timer the buffer grew
forever. Memory aside, each log() call re-renders the entire buffer
into the log window's NSTextView, so logging got slower over time.

Keep only the most recent 100k characters, dropping the oldest content.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
maxsoch 2026-07-06 21:33:32 +02:00
parent d1f4c0cb79
commit 99c243a51c

View file

@ -344,9 +344,16 @@ class AppDelegate: NSObject, NSApplicationDelegate {
// MARK: - Logs
/// oldest content is dropped past this size, or the buffer grows forever
/// and every log() re-renders an ever-larger string into the text view
let maxLogLength = 100_000
func log(_ text: String) {
DispatchQueue.main.async {
self.logBuffer += text
if self.logBuffer.count > self.maxLogLength {
self.logBuffer = String(self.logBuffer.suffix(self.maxLogLength))
}
self.logWindow?.update(text: self.logBuffer)
}
}