Repository navigation
Fix Claude needs input status acknowledgement #4794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
a39089f
63be611
21d1d73
5e8cc39
eee40ab
b3f1b94
2491b42
5481f40
0c22400
ea845d0
9f1671d
8e71084
bf2d2a9
f39ceec
673d58f
d2a714a
00a29f9
46a65d9
7d5d01b
bfda23d
afca982
3bc1dfe
835f949
11c64b8
d8aa8b5
b523007
3f16c38
29f0030
7f783d2
3c97954
912d604
04bf222
d90e083
e2d5726
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1555,20 +1555,91 @@ final class TerminalNotificationStore: ObservableObject { | |
| } | ||
| } | ||
|
|
||
| private static let structuredAgentStatusKeyByNotificationTitle: [String: String] = { | ||
| let pairs = [ | ||
| ("Amp", "amp"), | ||
| ("Antigravity", "antigravity"), | ||
| ("Claude Code", "claude_code"), | ||
| ("CodeBuddy", "codebuddy"), | ||
| ("Codex", "codex"), | ||
| ("Copilot", "copilot"), | ||
| ("Cursor", "cursor"), | ||
| ("Factory", "factory"), | ||
| ("Gemini", "gemini"), | ||
| ("Grok", "grok"), | ||
| ("Hermes Agent", "hermes-agent"), | ||
| ("OpenCode", "opencode"), | ||
| ("Pi", "pi"), | ||
| ("Qoder", "qoder"), | ||
| ("Rovo Dev", "rovodev"), | ||
| ] | ||
| return Dictionary(uniqueKeysWithValues: pairs.map { title, statusKey in | ||
| (title.trimmingCharacters(in: .whitespacesAndNewlines).lowercased(), statusKey) | ||
| }) | ||
| }() | ||
|
|
||
| private static func normalizedStructuredAgentNotificationTitle(_ title: String) -> String { | ||
| title.trimmingCharacters(in: .whitespacesAndNewlines).lowercased() | ||
| } | ||
|
|
||
| private static func structuredAgentStatusKey(for notification: TerminalNotification) -> String? { | ||
| structuredAgentStatusKeyByNotificationTitle[ | ||
| normalizedStructuredAgentNotificationTitle(notification.title) | ||
| ] | ||
| } | ||
|
|
||
| private func acknowledgeStructuredAgentInputStatuses(for notificationsToAcknowledge: [TerminalNotification]) { | ||
| for notification in notificationsToAcknowledge { | ||
|
Comment on lines
+1711
to
+1716
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep pending policy-hook input panel-scoped when the request already has a
💡 Narrow the transient guard to the owning panel when possible- let transientWorkspaceInputs = transientWorkspaceStructuredAgentInputKeys()
+ let transientWorkspaceInputs = transientWorkspaceStructuredAgentInputKeys()
+ let transientPanelInputs = transientPanelStructuredAgentInputKeys()
...
- let workspaceHasTransientInput = transientWorkspaceInputs.contains(
- StructuredAgentInputNotificationKey(tabId: notification.tabId, statusKey: statusKey)
- )
- demotePanelLifecycle = !panelHasRemainingInput && !workspaceHasTransientInput
+ let panelHasTransientInput = transientPanelInputs.contains(
+ StructuredAgentInputPanelKey(
+ tabId: notification.tabId,
+ panelId: acknowledgementPanelId,
+ statusKey: statusKey
+ )
+ )
+ demotePanelLifecycle = !panelHasRemainingInput && !panelHasTransientInputYou can still keep a workspace-wide fallback for truly unscoped queued inputs, but the policy-hook path already has enough information to avoid cross-panel bleed-through. Also applies to: 1743-1746, 1776-1784 🤖 Prompt for AI Agents |
||
| guard let statusKey = Self.structuredAgentStatusKey(for: notification), | ||
| let workspace = workspaceForStructuredAgentInputAcknowledgement( | ||
| tabId: notification.tabId, | ||
| surfaceId: notification.surfaceId ?? notification.panelId | ||
| ) else { | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| continue | ||
| } | ||
| workspace.acknowledgeStructuredAgentInputStatus( | ||
| statusKeys: [statusKey], | ||
| panelId: notification.surfaceId ?? notification.panelId, | ||
| notificationCreatedAt: notification.createdAt | ||
| ) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
|
cursor[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
|
|
||
| private func workspaceForStructuredAgentInputAcknowledgement( | ||
| tabId: UUID, | ||
| surfaceId: UUID? | ||
| ) -> Workspace? { | ||
| guard let appDelegate = AppDelegate.shared else { return nil } | ||
| if let surfaceId, | ||
| let located = appDelegate.workspaceContainingPanel( | ||
| panelId: surfaceId, | ||
| preferredWorkspaceId: tabId | ||
| ) { | ||
| return located.workspace | ||
| } | ||
|
|
||
| let tabManager = appDelegate.tabManagerFor(tabId: tabId) ?? appDelegate.tabManager | ||
| return tabManager?.tabs.first(where: { $0.id == tabId }) | ||
| } | ||
|
|
||
| func markRead(id: UUID) { | ||
| var updated = notifications | ||
| guard let index = updated.firstIndex(where: { $0.id == id }) else { return } | ||
| guard !updated[index].isRead else { return } | ||
| let notification = updated[index] | ||
| updated[index].isRead = true | ||
| notifications = updated | ||
| acknowledgeStructuredAgentInputStatuses(for: [notification]) | ||
| center.removeDeliveredNotificationsOffMain(withIdentifiers: [id.uuidString]) | ||
| } | ||
|
|
||
| func markRead(forTabId tabId: UUID) { | ||
| var updated = notifications | ||
| var idsToClear: [String] = [] | ||
| var notificationsToAcknowledge: [TerminalNotification] = [] | ||
| for index in updated.indices { | ||
| if updated[index].tabId == tabId && !updated[index].isRead { | ||
| notificationsToAcknowledge.append(updated[index]) | ||
| updated[index].isRead = true | ||
| idsToClear.append(updated[index].id.uuidString) | ||
| } | ||
|
|
@@ -1580,6 +1651,7 @@ final class TerminalNotificationStore: ObservableObject { | |
| clearWorkspacePanelUnread(forTabId: tabId) | ||
| setPanelDerivedWorkspaceUnread(false, forTabId: tabId) | ||
| setWorkspaceRestoredUnread(false, forTabId: tabId) | ||
| acknowledgeStructuredAgentInputStatuses(for: notificationsToAcknowledge) | ||
| if !idsToClear.isEmpty { | ||
| center.removeDeliveredNotificationsOffMain(withIdentifiers: idsToClear) | ||
| } | ||
|
|
@@ -1588,9 +1660,11 @@ final class TerminalNotificationStore: ObservableObject { | |
| func markRead(forTabId tabId: UUID, surfaceId: UUID?) { | ||
| var updated = notifications | ||
| var idsToClear: [String] = [] | ||
| var notificationsToAcknowledge: [TerminalNotification] = [] | ||
| for index in updated.indices { | ||
| if updated[index].matches(tabId: tabId, surfaceId: surfaceId), | ||
| !updated[index].isRead { | ||
| notificationsToAcknowledge.append(updated[index]) | ||
| updated[index].isRead = true | ||
| idsToClear.append(updated[index].id.uuidString) | ||
| } | ||
|
|
@@ -1603,6 +1677,7 @@ final class TerminalNotificationStore: ObservableObject { | |
| setPanelDerivedWorkspaceUnread(false, forTabId: tabId) | ||
| setWorkspaceRestoredUnread(false, forTabId: tabId) | ||
| } | ||
| acknowledgeStructuredAgentInputStatuses(for: notificationsToAcknowledge) | ||
| if !idsToClear.isEmpty { | ||
| center.removeDeliveredNotificationsOffMain(withIdentifiers: idsToClear) | ||
| center.removePendingNotificationRequestsOffMain(withIdentifiers: idsToClear) | ||
|
|
@@ -1666,8 +1741,10 @@ final class TerminalNotificationStore: ObservableObject { | |
| var updated = notifications | ||
| var idsToClear: [String] = [] | ||
| var tabIdsToClearPanelUnread = panelDerivedUnreadWorkspaceIds | ||
| var notificationsToAcknowledge: [TerminalNotification] = [] | ||
| for index in updated.indices { | ||
| if !updated[index].isRead { | ||
| notificationsToAcknowledge.append(updated[index]) | ||
| tabIdsToClearPanelUnread.insert(updated[index].tabId) | ||
| updated[index].isRead = true | ||
| idsToClear.append(updated[index].id.uuidString) | ||
|
|
@@ -1680,6 +1757,7 @@ final class TerminalNotificationStore: ObservableObject { | |
| clearAllWorkspacePanelUnread(forTabIds: tabIdsToClearPanelUnread) | ||
| clearPanelDerivedWorkspaceUnread() | ||
| clearWorkspaceRestoredUnread() | ||
| acknowledgeStructuredAgentInputStatuses(for: notificationsToAcknowledge) | ||
|
cursor[bot] marked this conversation as resolved.
Resolved
|
||
| if !idsToClear.isEmpty { | ||
| center.removeDeliveredNotificationsOffMain(withIdentifiers: idsToClear) | ||
| center.removePendingNotificationRequestsOffMain(withIdentifiers: idsToClear) | ||
|
|
@@ -1727,6 +1805,7 @@ final class TerminalNotificationStore: ObservableObject { | |
|
|
||
| func clearAll(discardQueuedNotifications: Bool = true) { | ||
| if discardQueuedNotifications { TerminalMutationBus.shared.discardPendingNotifications() } | ||
| let notificationsToAcknowledge = notifications | ||
| guard !notifications.isEmpty || | ||
| !focusedReadIndicatorByTabId.isEmpty || | ||
| !manualUnreadWorkspaceIds.isEmpty || | ||
|
|
@@ -1740,6 +1819,7 @@ final class TerminalNotificationStore: ObservableObject { | |
| clearPanelDerivedWorkspaceUnread() | ||
| clearWorkspaceRestoredUnread() | ||
| focusedReadIndicatorByTabId.removeAll() | ||
| acknowledgeStructuredAgentInputStatuses(for: notificationsToAcknowledge) | ||
| CmuxEventBus.shared.publishNotificationCleared(ids: ids, workspaceId: nil, surfaceId: nil) | ||
| center.removeDeliveredNotificationsOffMain(withIdentifiers: ids) | ||
| center.removePendingNotificationRequestsOffMain(withIdentifiers: ids) | ||
|
|
@@ -1756,8 +1836,10 @@ final class TerminalNotificationStore: ObservableObject { | |
| var updated: [TerminalNotification] = [] | ||
| updated.reserveCapacity(notifications.count) | ||
| var idsToClear: [String] = [] | ||
| var notificationsToAcknowledge: [TerminalNotification] = [] | ||
| for notification in notifications { | ||
| if notification.matches(tabId: tabId, surfaceId: surfaceId) { | ||
| notificationsToAcknowledge.append(notification) | ||
| idsToClear.append(notification.id.uuidString) | ||
| } else { | ||
| updated.append(notification) | ||
|
|
@@ -1770,6 +1852,7 @@ final class TerminalNotificationStore: ObservableObject { | |
| if surfaceId == nil { | ||
| setWorkspaceRestoredUnread(false, forTabId: tabId) | ||
| } | ||
| acknowledgeStructuredAgentInputStatuses(for: notificationsToAcknowledge) | ||
| clearFocusedReadIndicator(forTabId: tabId, surfaceId: surfaceId) | ||
| if !idsToClear.isEmpty { | ||
| CmuxEventBus.shared.publishNotificationCleared(ids: idsToClear, workspaceId: tabId, surfaceId: surfaceId) | ||
|
|
@@ -1820,8 +1903,10 @@ final class TerminalNotificationStore: ObservableObject { | |
| var updated: [TerminalNotification] = [] | ||
| updated.reserveCapacity(notifications.count) | ||
| var idsToClear: [String] = [] | ||
| var notificationsToAcknowledge: [TerminalNotification] = [] | ||
| for notification in notifications { | ||
| if notification.tabId == tabId { | ||
| notificationsToAcknowledge.append(notification) | ||
| idsToClear.append(notification.id.uuidString) | ||
| } else { | ||
| updated.append(notification) | ||
|
|
@@ -1831,6 +1916,7 @@ final class TerminalNotificationStore: ObservableObject { | |
| clearWorkspacePanelUnread(forTabId: tabId) | ||
| setPanelDerivedWorkspaceUnread(false, forTabId: tabId) | ||
| setWorkspaceRestoredUnread(false, forTabId: tabId) | ||
| acknowledgeStructuredAgentInputStatuses(for: notificationsToAcknowledge) | ||
| guard !idsToClear.isEmpty || hadFocusedReadIndicator else { return } | ||
| if !idsToClear.isEmpty { | ||
| replaceNotificationsForClear(updated) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.