mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-17 16:12:21 -06:00
5143d909b9
* feat(macos): stream Quick Chat conversations * docs(macos): explain Quick Chat recents * fix(macos): bind the Quick Chat reply consumer before dispatching the send * fix(macos): pre-bind reply consumer for all send paths; gate rebind on visible route * fix(macos): revalidate recents eligibility after the async fetch * fix(macos): invalidate in-flight recents fetches on competing interactions * fix(macos): single-owner recents invalidation; fresh presentations clear prepared replies * docs(macos): name the accepted scheduler-scale pre-bind tradeoff * chore(i18n): refresh native locale artifacts for new Quick Chat strings * fix(macos): keep Quick Chat placeholder and recents titles localizable
36 lines
1.3 KiB
Swift
36 lines
1.3 KiB
Swift
import Foundation
|
|
|
|
struct QuickChatRecentMenuItem: Equatable, Identifiable {
|
|
let id: String
|
|
let title: String
|
|
let target: QuickChatSessionTargetOverride?
|
|
let isSelected: Bool
|
|
}
|
|
|
|
enum QuickChatRecentMenuLogic {
|
|
static func items(
|
|
rows: [SessionRow],
|
|
agentName: String,
|
|
selectedTarget: QuickChatSessionTargetOverride?,
|
|
now: Date = Date()) -> [QuickChatRecentMenuItem]
|
|
{
|
|
let newMessage = QuickChatRecentMenuItem(
|
|
id: "new-message",
|
|
// String(localized:) keeps the NSMenuItem title translatable; the relative
|
|
// age below uses the shared app-wide relativeAge helper, unlocalized here as
|
|
// everywhere else it is used (a separate app-wide follow-up).
|
|
title: String(localized: "New message to \(agentName)"),
|
|
target: nil,
|
|
isSelected: selectedTarget == nil)
|
|
let recents = rows.prefix(5).map { row in
|
|
let target = QuickChatSessionTargetOverride(key: row.key, displayName: row.label)
|
|
return QuickChatRecentMenuItem(
|
|
id: row.key,
|
|
title: "\(row.label) — \(relativeAge(from: row.updatedAt, now: now))",
|
|
target: target,
|
|
isSelected: selectedTarget?.key == row.key)
|
|
}
|
|
return [newMessage] + recents
|
|
}
|
|
}
|