From e8570829e7392c8fcbc55f4e3f63c0afe11a461a Mon Sep 17 00:00:00 2001 From: Aziz Albahar Date: Mon, 29 Jun 2026 12:10:29 -0700 Subject: [PATCH 1/3] Fix mobile chat shortcut scroll edge blur --- .../Composer/ChatAccessoryChipRow.swift | 56 ++++++++++++++----- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/Packages/iOS/CmuxAgentChatUI/Sources/CmuxAgentChatUI/Composer/ChatAccessoryChipRow.swift b/Packages/iOS/CmuxAgentChatUI/Sources/CmuxAgentChatUI/Composer/ChatAccessoryChipRow.swift index acc2f01c8367..77928f8ee3b4 100644 --- a/Packages/iOS/CmuxAgentChatUI/Sources/CmuxAgentChatUI/Composer/ChatAccessoryChipRow.swift +++ b/Packages/iOS/CmuxAgentChatUI/Sources/CmuxAgentChatUI/Composer/ChatAccessoryChipRow.swift @@ -4,12 +4,17 @@ import SwiftUI /// The horizontal shortcut row above the composer field. public struct ChatAccessoryChipRow: View { + private static let scrollEdgeBlurWidth: CGFloat = 34 + private let agentState: ChatAgentState private let leadingShortcuts: [ChatAccessoryShortcut] private let shortcuts: [ChatAccessoryShortcut] private let onInterrupt: (Bool) -> Void private let onOpenTerminal: () -> Void + @State private var scrollContentWidth: CGFloat = 0 + @State private var scrollViewportWidth: CGFloat = 0 + /// Creates the chip row. /// /// - Parameters: @@ -53,23 +58,24 @@ public struct ChatAccessoryChipRow: View { // chips rather than cropping the very first/last chip flush // at the edge. .padding(.horizontal, 2) + .onGeometryChange(for: CGFloat.self, of: { $0.size.width }) { width in + scrollContentWidth = width + } } .frame(height: 32) .layoutPriority(1) - // Soft horizontal scroll-edge fade so chips dissolve at the - // margins instead of being hard-clipped by the scroll view's - // straight edge. - .mask { - LinearGradient( - stops: [ - .init(color: .clear, location: 0), - .init(color: .black, location: 0.035), - .init(color: .black, location: 0.965), - .init(color: .clear, location: 1), - ], - startPoint: .leading, - endPoint: .trailing - ) + .onGeometryChange(for: CGFloat.self, of: { $0.size.width }) { width in + scrollViewportWidth = width + } + .overlay(alignment: .leading) { + if scrollNeedsEdgeBlur { + scrollEdgeBlur(isLeading: true) + } + } + .overlay(alignment: .trailing) { + if scrollNeedsEdgeBlur { + scrollEdgeBlur(isLeading: false) + } } } } @@ -100,6 +106,10 @@ public struct ChatAccessoryChipRow: View { !leadingShortcuts.isEmpty || !shortcuts.isEmpty } + private var scrollNeedsEdgeBlur: Bool { + scrollContentWidth > scrollViewportWidth + 1 + } + private var stopShortcut: ChatAccessoryShortcut { ChatAccessoryShortcut( id: "chat.chip.stop", @@ -169,4 +179,22 @@ public struct ChatAccessoryChipRow: View { Text(shortcut.title) } } + + private func scrollEdgeBlur(isLeading: Bool) -> some View { + Rectangle() + .fill(.regularMaterial) + .frame(width: Self.scrollEdgeBlurWidth) + .mask { + LinearGradient( + stops: [ + .init(color: isLeading ? .black : .clear, location: 0), + .init(color: isLeading ? .black : .clear, location: 0.18), + .init(color: isLeading ? .clear : .black, location: 1), + ], + startPoint: .leading, + endPoint: .trailing + ) + } + .allowsHitTesting(false) + } } From 07aa5f44b97eff70609f25fe8b1f377b6b371591 Mon Sep 17 00:00:00 2001 From: Aziz Albahar Date: Mon, 29 Jun 2026 21:58:05 -0700 Subject: [PATCH 2/3] Fix chat shortcut scroll edge fade --- .../Composer/ChatAccessoryChipRow.swift | 46 +++++------ .../AgentChatDemoScreen.swift | 76 +++++++++++++++++-- 2 files changed, 95 insertions(+), 27 deletions(-) diff --git a/Packages/iOS/CmuxAgentChatUI/Sources/CmuxAgentChatUI/Composer/ChatAccessoryChipRow.swift b/Packages/iOS/CmuxAgentChatUI/Sources/CmuxAgentChatUI/Composer/ChatAccessoryChipRow.swift index 77928f8ee3b4..24d3deb1bafe 100644 --- a/Packages/iOS/CmuxAgentChatUI/Sources/CmuxAgentChatUI/Composer/ChatAccessoryChipRow.swift +++ b/Packages/iOS/CmuxAgentChatUI/Sources/CmuxAgentChatUI/Composer/ChatAccessoryChipRow.swift @@ -4,7 +4,7 @@ import SwiftUI /// The horizontal shortcut row above the composer field. public struct ChatAccessoryChipRow: View { - private static let scrollEdgeBlurWidth: CGFloat = 34 + private static let scrollEdgeFadeWidth: CGFloat = 34 private let agentState: ChatAgentState private let leadingShortcuts: [ChatAccessoryShortcut] @@ -67,15 +67,8 @@ public struct ChatAccessoryChipRow: View { .onGeometryChange(for: CGFloat.self, of: { $0.size.width }) { width in scrollViewportWidth = width } - .overlay(alignment: .leading) { - if scrollNeedsEdgeBlur { - scrollEdgeBlur(isLeading: true) - } - } - .overlay(alignment: .trailing) { - if scrollNeedsEdgeBlur { - scrollEdgeBlur(isLeading: false) - } + .mask { + scrollEdgeFadeMask } } } @@ -106,7 +99,7 @@ public struct ChatAccessoryChipRow: View { !leadingShortcuts.isEmpty || !shortcuts.isEmpty } - private var scrollNeedsEdgeBlur: Bool { + private var scrollNeedsEdgeFade: Bool { scrollContentWidth > scrollViewportWidth + 1 } @@ -180,21 +173,30 @@ public struct ChatAccessoryChipRow: View { } } - private func scrollEdgeBlur(isLeading: Bool) -> some View { - Rectangle() - .fill(.regularMaterial) - .frame(width: Self.scrollEdgeBlurWidth) - .mask { + @ViewBuilder + private var scrollEdgeFadeMask: some View { + if scrollNeedsEdgeFade { + HStack(spacing: 0) { + LinearGradient( + colors: [.clear, .black], + startPoint: .leading, + endPoint: .trailing + ) + .frame(width: Self.scrollEdgeFadeWidth) + + Rectangle() + .fill(.black) + LinearGradient( - stops: [ - .init(color: isLeading ? .black : .clear, location: 0), - .init(color: isLeading ? .black : .clear, location: 0.18), - .init(color: isLeading ? .clear : .black, location: 1), - ], + colors: [.black, .clear], startPoint: .leading, endPoint: .trailing ) + .frame(width: Self.scrollEdgeFadeWidth) } - .allowsHitTesting(false) + } else { + Rectangle() + .fill(.black) + } } } diff --git a/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/AgentChatDemoScreen.swift b/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/AgentChatDemoScreen.swift index 8ab6ea982084..4ac8346d197d 100644 --- a/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/AgentChatDemoScreen.swift +++ b/Packages/iOS/CmuxMobileShellUI/Sources/CmuxMobileShellUI/AgentChatDemoScreen.swift @@ -2,6 +2,7 @@ import CmuxAgentChat import CmuxAgentChatUI import CmuxMobileSupport +import CmuxMobileTerminal import SwiftUI /// Debug-only host for the agent chat surface fed by the fixture @@ -86,11 +87,22 @@ struct AgentChatDemoScreen: View { } private func baseChatScreen(for stack: DemoStack) -> some View { - ChatScreen( - store: stack.store, - providesOwnChrome: false, - onOpenTerminal: {} - ) + switch style { + case .standalone: + ChatScreen( + store: stack.store, + providesOwnChrome: false, + onOpenTerminal: {} + ) + case .inlineWorkspace: + ChatScreen( + store: stack.store, + accessoryLeadingShortcuts: previewLeadingShortcuts, + accessoryShortcuts: previewScrollableShortcuts(for: stack), + providesOwnChrome: false, + onOpenTerminal: {} + ) + } } private func header(for stack: DemoStack) -> some View { @@ -101,6 +113,60 @@ struct AgentChatDemoScreen: View { ) } + private var previewLeadingShortcuts: [ChatAccessoryShortcut] { + [ + ChatAccessoryShortcut( + id: "terminal.inputAccessory.hideKeyboard", + title: "", + systemImage: "keyboard.chevron.compact.down", + accessibilityLabel: L10n.string( + "terminal.input_accessory.hideKeyboard", + defaultValue: "Hide Keyboard" + ), + tint: .secondary, + semanticAction: .dismissKeyboard + ) {}, + ChatAccessoryShortcut( + id: "terminal.inputAccessory.composer", + title: "", + systemImage: "terminal", + accessibilityLabel: L10n.string( + "mobile.terminal.select", + defaultValue: "Terminal" + ) + ) {}, + ] + } + + private func previewScrollableShortcuts(for stack: DemoStack) -> [ChatAccessoryShortcut] { + TerminalInputAccessoryAction.defaultConfigurableOrder.compactMap { action in + guard action.isSupportedInAgentChat else { return nil } + return ChatAccessoryShortcut( + id: action.accessibilityIdentifier, + title: action.title(isMacRemote: true), + systemImage: action.symbolName, + accessibilityLabel: action.accessibilityLabel ?? action.settingsDisplayName, + semanticAction: action == .paste ? .paste : nil + ) { + performPreviewShortcut(action, store: stack.store) + } + } + } + + private func performPreviewShortcut( + _ action: TerminalInputAccessoryAction, + store: ChatConversationStore + ) { + switch action { + case .escape: + Task { await store.interrupt(hard: false) } + case .ctrlC: + Task { await store.interrupt(hard: true) } + default: + break + } + } + /// Holds the demo's store so its identity is stable across re-renders. private struct DemoStack { let store: ChatConversationStore From f474e4a4bbebef9be3d92fe56f131cf47f4a6a0c Mon Sep 17 00:00:00 2001 From: Aziz Albahar Date: Mon, 29 Jun 2026 22:36:28 -0700 Subject: [PATCH 3/3] Keep shortcut chips outside edge fade --- .../CmuxAgentChatUI/Composer/ChatAccessoryChipRow.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Packages/iOS/CmuxAgentChatUI/Sources/CmuxAgentChatUI/Composer/ChatAccessoryChipRow.swift b/Packages/iOS/CmuxAgentChatUI/Sources/CmuxAgentChatUI/Composer/ChatAccessoryChipRow.swift index 24d3deb1bafe..e5602e87351d 100644 --- a/Packages/iOS/CmuxAgentChatUI/Sources/CmuxAgentChatUI/Composer/ChatAccessoryChipRow.swift +++ b/Packages/iOS/CmuxAgentChatUI/Sources/CmuxAgentChatUI/Composer/ChatAccessoryChipRow.swift @@ -54,13 +54,10 @@ public struct ChatAccessoryChipRow: View { chip(shortcut) } } - // Inset the row content slightly so the fade reveals/clips - // chips rather than cropping the very first/last chip flush - // at the edge. - .padding(.horizontal, 2) .onGeometryChange(for: CGFloat.self, of: { $0.size.width }) { width in scrollContentWidth = width } + .padding(.horizontal, scrollNeedsEdgeFade ? Self.scrollEdgeFadeWidth : 2) } .frame(height: 32) .layoutPriority(1)