From 6f5c79f0ac69da05e524955095b2e0f77ca60246 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 28 Jul 2026 12:24:49 -0700 Subject: [PATCH 1/2] Enable toolbar items in Text Only mode. Fixes #3732. --- Mac/MainWindow/MainWindowController.swift | 25 ++++++++++++++++--- .../Sources/RSCore/AppKit/RSToolbarItem.swift | 8 +++--- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Mac/MainWindow/MainWindowController.swift b/Mac/MainWindow/MainWindowController.swift index 53ed0603d..b430cf891 100644 --- a/Mac/MainWindow/MainWindowController.swift +++ b/Mac/MainWindow/MainWindowController.swift @@ -539,8 +539,16 @@ final class MainWindowController: NSWindowController, NSUserInterfaceValidations assertionFailure("Expected toolbarShowShareMenu to be called only by the Share item in the toolbar.") return } - guard let view = shareToolbarItem.view else { - // TODO: handle menu form representation + // In the toolbar's Text Only mode or overflow menu the item's view isn't on-window, so anchor the picker to the window instead. + let anchorView: NSView + let anchorRect: NSRect + if let view = shareToolbarItem.view, view.window != nil { + anchorView = view + anchorRect = view.bounds + } else if let contentView = window?.contentView { + anchorView = contentView + anchorRect = NSRect(x: contentView.frame.width / 2.0, y: contentView.frame.height - 4, width: 1, height: 1) + } else { return } @@ -551,7 +559,7 @@ final class MainWindowController: NSWindowController, NSUserInterfaceValidations self.sharingServicePickerDelegate?.selectedHTML = selectedHTML let sharingServicePicker = NSSharingServicePicker(items: items) sharingServicePicker.delegate = self.sharingServicePickerDelegate - sharingServicePicker.show(relativeTo: view.bounds, of: view, preferredEdge: .minY) + sharingServicePicker.show(relativeTo: anchorRect, of: anchorView, preferredEdge: .minY) } } @@ -862,6 +870,7 @@ extension MainWindowController: NSToolbarDelegate { let button = ArticleExtractorButton() button.action = #selector(toggleArticleExtractor(_:)) toolbarItem.view = button + toolbarItem.menuFormRepresentation = NSMenuItem(title: description, action: #selector(toggleArticleExtractor(_:)), keyEquivalent: "") return toolbarItem case .share: @@ -1174,6 +1183,10 @@ private extension MainWindowController { if let toolbarItem = item as? NSToolbarItem { toolbarItem.toolTip = commandName + // Text Only toolbar mode shows the label and menu form representation, so they need to track state too. + let shortName = markingRead ? NSLocalizedString("Mark Read", comment: "command") : NSLocalizedString("Mark Unread", comment: "command") + toolbarItem.label = shortName + toolbarItem.menuFormRepresentation?.title = shortName } if let menuItem = item as? NSMenuItem { @@ -1258,6 +1271,10 @@ private extension MainWindowController { if let toolbarItem = item as? NSToolbarItem { toolbarItem.toolTip = commandName + // Text Only toolbar mode shows the label and menu form representation, so they need to track state too. + let shortName = starring ? NSLocalizedString("Star", comment: "Star") : NSLocalizedString("Unstar", comment: "Unstar") + toolbarItem.label = shortName + toolbarItem.menuFormRepresentation?.title = shortName } if let menuItem = item as? NSMenuItem { @@ -1452,6 +1469,8 @@ private extension MainWindowController { toolbarItem.view = button toolbarItem.toolTip = title toolbarItem.label = title + // A menu form representation keeps view-based items working in the toolbar's Text Only mode and overflow menu. + toolbarItem.menuFormRepresentation = NSMenuItem(title: title, action: Selector((selector)), keyEquivalent: "") return toolbarItem } diff --git a/Modules/RSCore/Sources/RSCore/AppKit/RSToolbarItem.swift b/Modules/RSCore/Sources/RSCore/AppKit/RSToolbarItem.swift index 556d76845..0ca9a6be8 100644 --- a/Modules/RSCore/Sources/RSCore/AppKit/RSToolbarItem.swift +++ b/Modules/RSCore/Sources/RSCore/AppKit/RSToolbarItem.swift @@ -12,10 +12,6 @@ import AppKit public class RSToolbarItem: NSToolbarItem { override public func validate() { - guard let view = view, view.window != nil else { - isEnabled = false - return - } isEnabled = isValidAsUserInterfaceItem() } } @@ -29,7 +25,9 @@ private extension RSToolbarItem { return validateWithResponder(target) ?? false } - var responder = view?.window?.firstResponder + // view.window is nil when the item is shown as its menu form representation (the toolbar's + // Text Only mode or overflow menu), so fall back to the main window's responder chain. + var responder = view?.window?.firstResponder ?? NSApp.mainWindow?.firstResponder if responder == nil { return false } From ef6dd0af4ab8fb3f8770ea8ca5e69776e27849b4 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 28 Jul 2026 21:24:20 -0700 Subject: [PATCH 2/2] Save and restore timeline width between runs. Fixes #4823. --- iOS/AppDefaults.swift | 15 +++++++++++++++ iOS/SceneCoordinator.swift | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/iOS/AppDefaults.swift b/iOS/AppDefaults.swift index 8249905b3..2715af5aa 100644 --- a/iOS/AppDefaults.swift +++ b/iOS/AppDefaults.swift @@ -78,6 +78,7 @@ final class AppDefaults: Sendable { static let selectedArticle = "selectedArticle" static let didMigrateLegacyStateRestorationInfo = "didMigrateLegacyStateRestorationInfo" static let splitViewPreferredDisplayMode = "splitViewPreferredDisplayMode" + static let timelineWidth = "timelineWidth" } let isDeveloperBuild: Bool = { @@ -229,6 +230,20 @@ final class AppDefaults: Sendable { } } + // The iPad timeline (supplementary) column width. nil until the user has resized it. + var timelineWidth: Int? { + get { + return AppDefaults.store.object(forKey: Key.timelineWidth) as? Int + } + set { + if let newValue { + AppDefaults.store.set(newValue, forKey: Key.timelineWidth) + } else { + AppDefaults.store.removeObject(forKey: Key.timelineWidth) + } + } + } + var lastRefresh: Date? { get { return AppDefaults.date(for: Key.lastRefresh) diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 444ab027e..a506c3074 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -304,13 +304,32 @@ struct SidebarItemNode: Hashable, Sendable { } } + private static let minimumTimelineWidth: CGFloat = 280 + private static let maximumTimelineWidth: CGFloat = 440 + + private static func clampTimelineWidth(_ width: CGFloat) -> CGFloat { + if width < minimumTimelineWidth { + return minimumTimelineWidth + } + if width > maximumTimelineWidth { + return maximumTimelineWidth + } + return width + } + init(rootSplitViewController: RootSplitViewController) { self.rootSplitViewController = rootSplitViewController self.rootSplitViewController.minimumPrimaryColumnWidth = 300 self.rootSplitViewController.maximumPrimaryColumnWidth = 500 - self.rootSplitViewController.minimumSupplementaryColumnWidth = 300 - self.rootSplitViewController.preferredSupplementaryColumnWidth = 320 - self.rootSplitViewController.maximumSupplementaryColumnWidth = 360 + self.rootSplitViewController.minimumSupplementaryColumnWidth = SceneCoordinator.minimumTimelineWidth + self.rootSplitViewController.maximumSupplementaryColumnWidth = SceneCoordinator.maximumTimelineWidth + let restoredTimelineWidth: CGFloat + if let savedTimelineWidth = AppDefaults.shared.timelineWidth { + restoredTimelineWidth = CGFloat(savedTimelineWidth) + } else { + restoredTimelineWidth = 320 + } + self.rootSplitViewController.preferredSupplementaryColumnWidth = Self.clampTimelineWidth(restoredTimelineWidth) self.rootSplitViewController.preferredSplitBehavior = .tile self.treeController = TreeController(delegate: treeControllerDelegate) @@ -744,6 +763,19 @@ struct SidebarItemNode: Hashable, Sendable { func didEnterBackground() { hidingReadArticlesState.save() saveExpandedContainers() + saveTimelineWidth() + } + + private func saveTimelineWidth() { + // Only meaningful when the timeline is its own column (iPad, expanded); when collapsed its view fills the screen. + guard !rootSplitViewController.isCollapsed else { + return + } + let width = mainTimelineViewController?.view.bounds.width ?? 0 + guard width > 0 else { + return + } + AppDefaults.shared.timelineWidth = Int(SceneCoordinator.clampTimelineWidth(width)) } func suspend() {