mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-25 11:48:39 +00:00
refactor(macos): dedupe UI, pairing, and runtime helpers
This commit is contained in:
16
apps/macos/Sources/OpenClaw/TextSummarySupport.swift
Normal file
16
apps/macos/Sources/OpenClaw/TextSummarySupport.swift
Normal file
@@ -0,0 +1,16 @@
|
||||
import Foundation
|
||||
|
||||
enum TextSummarySupport {
|
||||
static func summarizeLastLine(_ text: String, maxLength: Int = 200) -> String? {
|
||||
let lines = text
|
||||
.split(whereSeparator: \.isNewline)
|
||||
.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
|
||||
.filter { !$0.isEmpty }
|
||||
guard let last = lines.last else { return nil }
|
||||
let normalized = last.replacingOccurrences(of: "\\s+", with: " ", options: .regularExpression)
|
||||
if normalized.count > maxLength {
|
||||
return String(normalized.prefix(maxLength - 1)) + "…"
|
||||
}
|
||||
return normalized
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user