Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,7 @@ jobs:
CmuxNotifications
CmuxSettings
CmuxSettingsUI
CmuxSidebar
CmuxTerminal
CmuxTerminalCore
CmuxUpdater
Expand Down
11 changes: 5 additions & 6 deletions CLI/cmux.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25271,12 +25271,11 @@ struct CMUXCLI {
}
}

// An idle reminder while background work is still pending is not a
// real "waiting for input" state: the pane is still running (the Stop
// hook set it to Running) and the app suppresses this banner. Skip the
// "Needs input" pill/lifecycle so the idle nag can't undo the Running
// status; the app still gates the (tagged) notification itself.
let suppressNeedsInputState = (notifyCategory == .idleReminder && notifyPending)
// Claude's timed idle_prompt is a reminder, not evidence that Claude
// asked a question. Keep the notification, but never turn it into a
// "Needs input" pill/lifecycle. Pending work remains Running too.
let suppressNeedsInputState = notificationType == "idle_prompt"
|| (notifyCategory == .idleReminder && notifyPending)

// `.other` means "ungated, always deliver" — identical to an untagged
// payload, so don't put it on the wire: the app parser accepts only
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/// Aggregates immutable agent-activity values for sidebar presentation.
public struct SidebarAgentActivityAggregator: Sendable {
/// Creates an agent-activity aggregator.
public init() {}

/// Counts the highest-priority activity state already selected for each panel.
///
/// - Parameter panelActivities: One activity value per panel.
/// - Returns: The number of running and needs-input panels.
public func counts<S: Sequence>(panelActivities: S) -> SidebarAgentActivityCounts
where S.Element == SidebarAgentPanelActivity {
panelActivities.reduce(into: SidebarAgentActivityCounts()) { counts, activity in
switch activity {
case .running:
counts.running += 1
case .needsInput:
counts.needsInput += 1
case .inactive:
break
}
}
}

/// Combines workspace counts into a larger sidebar scope.
///
/// - Parameter counts: Counts from the workspaces in the scope.
/// - Returns: The combined counts.
public func total<S: Sequence>(counts: S) -> SidebarAgentActivityCounts
where S.Element == SidebarAgentActivityCounts {
counts.reduce(SidebarAgentActivityCounts(), +)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/// Counts active agents by the state shown in the sidebar.
public struct SidebarAgentActivityCounts: Equatable, Hashable, Sendable {
/// The number of agents currently running.
public var running: Int

/// The number of agents waiting for user input.
public var needsInput: Int

/// Creates sidebar agent counts.
///
/// - Parameters:
/// - running: The number of running agents.
/// - needsInput: The number of agents waiting for input.
public init(running: Int = 0, needsInput: Int = 0) {
self.running = running
self.needsInput = needsInput
}

/// Adds counts from two sidebar scopes.
///
/// - Parameters:
/// - lhs: Counts from the first scope.
/// - rhs: Counts from the second scope.
/// - Returns: The combined counts.
public static func + (lhs: Self, rhs: Self) -> Self {
Self(
running: lhs.running + rhs.running,
needsInput: lhs.needsInput + rhs.needsInput
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// The highest-priority active-agent state for one sidebar panel.
public enum SidebarAgentPanelActivity: Sendable {
/// At least one agent in the panel is running.
case running

/// At least one agent in the panel is waiting for user input.
case needsInput

/// The panel has no active agent state to count.
case inactive
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Testing

@testable import CmuxSidebar

@Suite("Sidebar agent activity aggregator")
struct SidebarAgentActivityAggregatorTests {
@Test func countsOneStatePerPanel() {
let counts = SidebarAgentActivityAggregator().counts(panelActivities: [
.running,
.needsInput,
.inactive,
])

#expect(counts == .init(running: 1, needsInput: 1))
}

@Test func combinesWorkspaceCounts() {
let counts = SidebarAgentActivityAggregator().total(counts: [
SidebarAgentActivityCounts(running: 2),
SidebarAgentActivityCounts(running: 1, needsInput: 3),
])

#expect(counts == .init(running: 3, needsInput: 3))
}
}
51 changes: 51 additions & 0 deletions Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -257164,6 +257164,57 @@
}
}
},
"workspaceGroup.agentActivity.a11y": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Running agents: %1$lld. Need input: %2$lld."
}
},
"ja": {
"stringUnit": {
"state": "translated",
"value": "実行中のエージェント: %1$lld。入力待ち: %2$lld。"
}
}
}
},
"workspaceGroup.agentActivity.needsInput": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "! %lld"
}
},
"ja": {
"stringUnit": {
"state": "translated",
"value": "! %lld"
}
}
}
},
"workspaceGroup.agentActivity.running": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "▶ %lld"
}
},
"ja": {
"stringUnit": {
"state": "translated",
"value": "▶ %lld"
}
}
}
},
"workspaceGroup.autoName.numbered": {
"extractionState": "manual",
"localizations": {
Expand Down
18 changes: 14 additions & 4 deletions Sources/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11924,6 +11924,7 @@ struct VerticalTabsSidebar: View, Equatable {
sidebarWorkspaceGroupRowSnapshot(
group: group,
memberWorkspaceIds: renderContext.memberWorkspaceIdsByGroupId[group.id] ?? [],
workspaceRowsById: workspaceRowInputsById,
renderContext: renderContext,
unreadSnapshot: unreadSnapshot,
notificationIndex: notificationIndex,
Expand All @@ -11947,6 +11948,7 @@ struct VerticalTabsSidebar: View, Equatable {
return sidebarWorkspaceGroupTableConfiguration(
group: group,
memberWorkspaceIds: renderContext.memberWorkspaceIdsByGroupId[groupId] ?? [],
workspaceRowsById: workspaceRowInputsById,
renderContext: renderContext
)
case .workspace(let workspaceId):
Expand Down Expand Up @@ -13598,6 +13600,7 @@ struct VerticalTabsSidebar: View, Equatable {
sidebarWorkspaceGroupRowSnapshot(
group: group,
memberWorkspaceIds: renderContext.memberWorkspaceIdsByGroupId[group.id] ?? [],
workspaceRowsById: workspaceRowInputsById,
renderContext: renderContext,
unreadSnapshot: unreadSnapshot,
notificationIndex: notificationIndex,
Expand Down Expand Up @@ -15698,10 +15701,17 @@ struct TabItemView: View, Equatable {
let accessibilityHintText = String(localized: "sidebar.workspace.accessibilityHint", defaultValue: "Activate to focus this workspace. Drag to reorder, or use Move Up and Move Down actions.")
let moveUpActionText = String(localized: "sidebar.workspace.moveUpAction", defaultValue: "Move Up")
let moveDownActionText = String(localized: "sidebar.workspace.moveDownAction", defaultValue: "Move Down")
let latestNotificationSubtitle = latestNotificationText
let conversationMessageSubtitle = !settings.hidesAllDetails && settings.iMessageModeEnabled
? workspaceSnapshot.latestConversationMessage?.trimmingCharacters(in: .whitespacesAndNewlines).nilIfEmpty
: nil
let agentActivitySummary = SidebarAgentActivitySummary()
let latestNotificationSubtitle = agentActivitySummary.notificationSubtitle(
showsAgentActivity: showsAgentActivity,
message: latestNotificationText
)
let conversationMessageSubtitle = agentActivitySummary.conversationSubtitle(
showsAgentActivity: showsAgentActivity,
hidesAllDetails: settings.hidesAllDetails,
iMessageModeEnabled: settings.iMessageModeEnabled,
message: workspaceSnapshot.latestConversationMessage
)
let effectiveSubtitle = latestNotificationSubtitle ?? conversationMessageSubtitle
let subtitleLineLimit = latestNotificationSubtitle == nil ? 2 : settings.notificationMessageLineLimit
// Bound notification payloads before shaping so pathological text stays cheap in lazy, Equatable rows.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ struct SidebarGroupHeaderRowModel: Equatable, Hashable {
let isMultiSelected: Bool
let multiSelectionBackgroundStyle: SidebarWorkspaceRowBackgroundStyle
let memberCount: Int
let showsAgentActivity: Bool
let runningAgentCount: Int
let needsInputAgentCount: Int
var anchorUnreadCount: Int
var canMarkRead: Bool
var canMarkUnread: Bool
Expand Down
62 changes: 59 additions & 3 deletions Sources/Sidebar/AppKitList/Cells/SidebarGroupHeaderRowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ final class SidebarGroupHeaderTableCellView: NSTableCellView {
private let chevronButton = SidebarHeaderGlyphButton()
private let iconImageView = NSImageView()
private let nameField = NSTextField(labelWithString: "")
private let agentActivityField = NSTextField(labelWithString: "")
// Direct-draw badge (shared with workspace rows): NSTextField's
// intrinsic insets shift single digits off the circle's optical center.
private let unreadBadgeView = SidebarRowUnreadBadgeView()
Expand Down Expand Up @@ -72,6 +73,8 @@ final class SidebarGroupHeaderTableCellView: NSTableCellView {
nameField.cell?.truncatesLastVisibleLine = true
addSubview(nameField)

addSubview(agentActivityField)

addSubview(unreadBadgeView)

plusButton.onClick = { [weak self] in self?.actions?.onTapPlus() }
Expand Down Expand Up @@ -180,6 +183,44 @@ final class SidebarGroupHeaderTableCellView: NSTableCellView {
)
nameField.textColor = model.isAnchorActive ? .labelColor : NSColor.labelColor.withAlphaComponent(0.9)

agentActivityField.isHidden = !model.showsAgentActivity
if model.showsAgentActivity {
let summary = SidebarAgentActivitySummary()
let font = NSFont.systemFont(
ofSize: GlobalFontMagnification.scaledSize(metrics.nameFontSize, percent: percent),
weight: .semibold
)
let running = summary.runningText(count: model.runningAgentCount)
let needsInput = summary.needsInputText(count: model.needsInputAgentCount)
let text = "\(running) \(needsInput)"
let attributed = NSMutableAttributedString(
string: text,
attributes: [.font: font]
)
attributed.addAttribute(
.foregroundColor,
value: NSColor.systemBlue,
range: NSRange(location: 0, length: running.utf16.count)
)
attributed.addAttribute(
.foregroundColor,
value: NSColor.systemOrange,
range: NSRange(
location: text.utf16.count - needsInput.utf16.count,
length: needsInput.utf16.count
)
)
agentActivityField.attributedStringValue = attributed
let accessibilityText = summary.accessibilityText(
counts: .init(
running: model.runningAgentCount,
needsInput: model.needsInputAgentCount
)
)
agentActivityField.toolTip = accessibilityText
agentActivityField.setAccessibilityLabel(accessibilityText)
}

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
let showsBadge = model.anchorUnreadCount > 0
unreadBadgeView.isHidden = !showsBadge
if showsBadge {
Expand Down Expand Up @@ -393,8 +434,12 @@ final class SidebarGroupHeaderTableCellView: NSTableCellView {
)
}

let nameAvailable = max(0, (plusButton.frame.minX - 4) - x
- (badgeSize.width > 0 ? badgeSize.width + 6 : 0))
let activitySize = agentActivityField.isHidden
? .zero
: agentActivityField.attributedStringValue.size()
let trailingDetailsWidth = (activitySize.width > 0 ? ceil(activitySize.width) + 8 : 0)
+ (badgeSize.width > 0 ? badgeSize.width + 6 : 0)
let nameAvailable = max(0, (plusButton.frame.minX - 4) - x - trailingDetailsWidth)
let nameSize = nameField.attributedStringValue.size()
// The field owns ALL remaining width (truncation only when genuinely
// out of space); the badge tracks the measured text width instead.
Expand All @@ -404,8 +449,19 @@ final class SidebarGroupHeaderTableCellView: NSTableCellView {
width: nameAvailable,
height: ceil(nameSize.height)
)
var detailX = x + min(ceil(nameSize.width), nameAvailable)
if !agentActivityField.isHidden {
detailX += 8
agentActivityField.frame = NSRect(
x: detailX,
y: midY - ceil(activitySize.height) / 2,
width: ceil(activitySize.width),
height: ceil(activitySize.height)
)
detailX = agentActivityField.frame.maxX
}
if !unreadBadgeView.isHidden {
let badgeX = x + min(ceil(nameSize.width), nameAvailable) + 6
let badgeX = detailX + 6
unreadBadgeView.frame = NSRect(
x: badgeX,
y: midY - badgeSize.height / 2,
Expand Down
20 changes: 13 additions & 7 deletions Sources/Sidebar/AppKitList/Cells/SidebarWorkspaceRowCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -516,13 +516,19 @@ final class SidebarWorkspaceRowTableCellView: NSTableCellView {
}
}

let conversationSubtitle: String? = {
guard !settings.hidesAllDetails, settings.iMessageModeEnabled else { return nil }
let trimmed = snapshot.latestConversationMessage?.trimmingCharacters(in: .whitespacesAndNewlines)
return (trimmed?.isEmpty == false) ? trimmed : nil
}()
let effectiveSubtitle = model.latestNotificationText ?? conversationSubtitle
let subtitleLineLimit = model.latestNotificationText == nil ? 2 : settings.notificationMessageLineLimit
let agentActivitySummary = SidebarAgentActivitySummary()
let notificationSubtitle = agentActivitySummary.notificationSubtitle(
showsAgentActivity: model.showsAgentActivity,
message: model.latestNotificationText
)
let conversationSubtitle = agentActivitySummary.conversationSubtitle(
showsAgentActivity: model.showsAgentActivity,
hidesAllDetails: settings.hidesAllDetails,
iMessageModeEnabled: settings.iMessageModeEnabled,
message: snapshot.latestConversationMessage
)
let effectiveSubtitle = notificationSubtitle ?? conversationSubtitle
let subtitleLineLimit = notificationSubtitle == nil ? 2 : settings.notificationMessageLineLimit
subtitleView.isHidden = effectiveSubtitle == nil
if let effectiveSubtitle {
subtitleView.maximumNumberOfLines = subtitleLineLimit
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sidebar/SidebarWorkspaceDescriptionText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct SidebarWorkspaceDescriptionText: View {
)
#endif
}
.onChange(of: markdown) { newValue in
.onChange(of: markdown) { _, newValue in
#if DEBUG
let newlineCount = newValue.reduce(into: 0) { count, character in
if character == "\n" { count += 1 }
Expand Down
Loading