The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.
Toolbar clicks, the command bar's closing click, Console/Network/Inspect and developer-mode subtitles as in Arc (#88) (#97)
Victor Kildahla972f6ccf2f9
diff --git a/Packages/CraCore/Sources/CraCore/DismissingClick.swift b/Packages/CraCore/Sources/CraCore/DismissingClick.swiftnew file mode 100644index 0000000..e303023--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/DismissingClick.swift@@ -0,0 +1,25 @@+import Foundation++/// A click on the address while the command bar is open takes focus from the bar, which closes+/// it, and then its mouse-up asked for the bar again: it reopened at once with a fresh query.+/// Arc 1.170 closes the bar on that click and opens it only on the next one (GitHub #88). Times+/// are event times, seconds since boot; synthetic clicks share event numbers, so the latest+/// mouse-down's time is what identifies a click.+public struct DismissingClick: Equatable {+ private var closedAt: TimeInterval?++ public init() {}++ /// The bar closed while handling a mouse-down at `time`; nil when no click closed it.+ public mutating func panelClosed(byMouseDownAt time: TimeInterval?) {+ closedAt = time+ }++ /// A mouse-up asks to open the bar and the latest mouse-down was at `lastMouseDown`: true when+ /// that is the click that closed it. Each close is consumed by the first ask.+ public mutating func isClosingClick(lastMouseDown: TimeInterval) -> Bool {+ defer { closedAt = nil }+ guard let closedAt else { return false }+ return abs(lastMouseDown - closedAt) < 0.05+ }+}diff --git a/Packages/CraCore/Sources/CraCore/SidebarModel.swift b/Packages/CraCore/Sources/CraCore/SidebarModel.swiftindex 88c7c1f..1958d31 100644--- a/Packages/CraCore/Sources/CraCore/SidebarModel.swift+++ b/Packages/CraCore/Sources/CraCore/SidebarModel.swift@@ -86,6 +86,18 @@ public struct TabData: Codable, Equatable {self.savedTitle = titleself.faviconKey = URL(string: url)?.host}++ /// The line under the tab's title in the sidebar. A live folder's pull request shows its+ /// author. Arc 1.170 shows the host under every tab of a site in developer mode (GitHub #88),+ /// and under a pinned tab only once it has left the pinned site (navigating within the same+ /// host shows nothing).+ public func sidebarSubtitle(navigatedAway: Bool, developerMode: Bool) -> String? {+ if let liveSubtitle, URL(string: url)?.host == "github.com" { return liveSubtitle }+ guard let host = URL(string: url)?.host?.replacingOccurrences(of: "www.", with: "") else { return nil }+ if developerMode { return host }+ guard navigatedAway, let saved = URL(string: savedURL)?.host, host != saved.replacingOccurrences(of: "www.", with: "") else { return nil }+ return host+ }}/// Arc's SidebarSplitViewData: a split is a sidebar item whose children arediff --git a/Packages/CraCore/Tests/CraCoreTests/DismissingClickTests.swift b/Packages/CraCore/Tests/CraCoreTests/DismissingClickTests.swiftnew file mode 100644index 0000000..3aa3270--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/DismissingClickTests.swift@@ -0,0 +1,31 @@+import CraCore+import Testing++/// The click that closes the command bar doesn't reopen it (#88).+struct DismissingClickTests {+ @Test func theClosingClickDoesNotReopen() {+ var d = DismissingClick()+ d.panelClosed(byMouseDownAt: 100)+ let first = d.isClosingClick(lastMouseDown: 100.01)+ let second = d.isClosingClick(lastMouseDown: 100.01)+ #expect(first, "the same click's mouse-up: stays closed")+ #expect(!second, "asked once per close")+ }++ @Test func theNextClickOpens() {+ var d = DismissingClick()+ d.panelClosed(byMouseDownAt: 100)+ let later = d.isClosingClick(lastMouseDown: 101.2)+ #expect(!later, "a later click opens the bar")+ }++ @Test func closedWithoutAClick() {+ var d = DismissingClick()+ d.panelClosed(byMouseDownAt: nil)+ let next = d.isClosingClick(lastMouseDown: 100)+ var fresh = DismissingClick()+ let none = fresh.isClosingClick(lastMouseDown: 0)+ #expect(!next, "Esc or another app: the next click opens")+ #expect(!none, "never closed")+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/SidebarModelTests.swift b/Packages/CraCore/Tests/CraCoreTests/SidebarModelTests.swiftindex c576e88..bb3c93b 100644--- a/Packages/CraCore/Tests/CraCoreTests/SidebarModelTests.swift+++ b/Packages/CraCore/Tests/CraCoreTests/SidebarModelTests.swift@@ -45,6 +45,23 @@ struct SidebarModelTests {#expect(tab.iconKey == "picked")}+ /// The line under a tab's title (GitHub #88): a developer-mode site shows its host on every+ /// tab, a pinned tab shows it once it has left its site, a pull request shows its author.+ @Test func sidebarSubtitle() {+ var tab = TabData(url: "https://www.youtube.com/watch?v=1", title: "Video")+ #expect(tab.sidebarSubtitle(navigatedAway: false, developerMode: false) == nil)+ #expect(tab.sidebarSubtitle(navigatedAway: false, developerMode: true) == "youtube.com", "developer mode: the host, without www.")+ tab.savedURL = "https://youtube.com/"+ #expect(tab.sidebarSubtitle(navigatedAway: true, developerMode: false) == nil, "still on the pinned site")+ tab.savedURL = "https://example.com/"+ #expect(tab.sidebarSubtitle(navigatedAway: true, developerMode: false) == "youtube.com", "left the pinned site")+ #expect(tab.sidebarSubtitle(navigatedAway: false, developerMode: false) == nil)+ var pull = TabData(url: "https://github.com/o/r/pull/1")+ pull.liveSubtitle = "octocat"+ #expect(pull.sidebarSubtitle(navigatedAway: false, developerMode: true) == "octocat", "a pull request's author wins")+ #expect(TabData(url: "notes").sidebarSubtitle(navigatedAway: false, developerMode: true) == nil, "no host, no line")+ }+@Test func containerKindsRoundTripAndNeedAKind() throws {for kind in [ContainerKind.favorites(spaceID: Self.space), .pinned(spaceID: Self.space), .today(spaceID: Self.space)] {#expect(try JSONDecoder().decode(ContainerKind.self, from: JSONEncoder().encode(kind)) == kind)diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swiftindex 98514a6..90c8c0d 100644--- a/Sources/Cra/App/AppDelegate.swift+++ b/Sources/Cra/App/AppDelegate.swift@@ -806,10 +806,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {case "zoomOut": main.zoom(by: -0.5)case "resetZoom": main.currentBrowser?.setZoomLevel(0)case "viewSource": main.currentBrowser?.viewSource()- case "devTools", "jsConsole":- // Toggle, like Chrome: ⌥⌘I closes the dock when it is already open.- main.browsers.toggleDevTools()- case "inspectElement": main.browsers.showDevTools()+ // Like Chrome: ⌥⌘I, ⌥⌘J and Network close the dock when it is already open.+ case "devTools": main.browsers.runDevTools(.toggle)+ case "jsConsole": main.browsers.runDevTools(.console)+ case "networkPanel": main.browsers.runDevTools(.network)+ case "inspectElement": main.browsers.runDevTools(.inspect)// Arc's Library is a mode of the window's sidebar; ⇧⌘J opens it on Downloads.case "openLibrary": main.toggleLibrary()case "viewArchive": main.showLibrary(.archive)diff --git a/Sources/Cra/Services/BrowserManager.swift b/Sources/Cra/Services/BrowserManager.swiftindex 0807129..9681bb8 100644--- a/Sources/Cra/Services/BrowserManager.swift+++ b/Sources/Cra/Services/BrowserManager.swift@@ -775,16 +775,14 @@ final class BrowserManager: NSObject, @preconcurrency CraBrowserDelegate {if let rt = runtimes[id] { perform(rt.devTools.didClose(), on: rt) }}- /// ⌥⌘I on the focused page: open its DevTools, or close them (DevToolsToggle).- func toggleDevTools() {+ /// ⌥⌘I, ⌥⌘J, ⌥⌘C and the developer bar's Console, Network and Inspect on the focused page+ /// (DevToolsToggle.Command).+ func runDevTools(_ command: DevToolsToggle.Command) {guard let rt = visibleRuntime else { return }- perform(rt.devTools.toggle(), on: rt)- }-- /// Inspect Element: DevTools open on the focused page, whatever they were doing.- func showDevTools() {- guard let rt = visibleRuntime else { return }- perform(rt.devTools.show(), on: rt)+ let (effect, frontend) = rt.devTools.run(command)+ // A press made while DevTools close is done when they reopen (DevToolsToggle.didClose).+ rt.browser.devToolsAction = frontend+ perform(effect, on: rt)}private func perform(_ effect: DevToolsToggle.Effect, on rt: TabRuntime) {diff --git a/Sources/Cra/Services/DevToolsToggle.swift b/Sources/Cra/Services/DevToolsToggle.swiftindex 8824b93..c233073 100644--- a/Sources/Cra/Services/DevToolsToggle.swift+++ b/Sources/Cra/Services/DevToolsToggle.swift@@ -37,6 +37,23 @@ struct DevToolsToggle: Equatable {}}+ /// The DevTools commands, as Chrome's DevToolsToggleAction (Arc 1.170's developer bar runs+ /// Chrome's commands, GitHub #88): ⌥⌘I toggles; Console (⌥⌘J) and Network toggle too and+ /// open on their panel; Inspect (⌥⌘C) always ends open, with the element picker armed.+ enum Command: Equatable { case toggle, console, network, inspect }++ /// The effect, and what the frontend is asked once open (CraBrowser.devToolsAction).+ mutating func run(_ command: Command) -> (effect: Effect, frontend: String?) {+ let effect = command == .inspect ? show() : toggle()+ guard effect != .close else { return (effect, nil) }+ switch command {+ case .toggle: return (effect, nil)+ case .console: return (effect, "console")+ case .network: return (effect, "network")+ case .inspect: return (effect, "inspect")+ }+ }+/// CEF made the DevTools view, also for DevTools opened from Chromium's own menu.mutating func didOpen() {if case .closing = state { return }diff --git a/Sources/Cra/UI/PaneToolbarView.swift b/Sources/Cra/UI/PaneToolbarView.swiftindex 81eabca..ded18d2 100644--- a/Sources/Cra/UI/PaneToolbarView.swift+++ b/Sources/Cra/UI/PaneToolbarView.swift@@ -59,6 +59,8 @@ final class PaneToolbarView: NSView {private let placeholderLabel = NSTextField.sidebarLabel(size: 13)private let hairline = NSView()private let devDivider = NSView()+ /// Arc's rule between the developer buttons and the extensions.+ private let devTrailingDivider = NSView()private let stripes = DeveloperStripesView()/// Arc lifts the whole developer bar ~9% toward white while its address field is edited.private let editVeil = NSView()@@ -73,6 +75,7 @@ final class PaneToolbarView: NSView {wantsLayer = truehairline.wantsLayer = truedevDivider.wantsLayer = true+ devTrailingDivider.wantsLayer = truestripes.isHidden = trueaddSubview(stripes)placeholderLabel.stringValue = "Search or Enter URL…"@@ -81,7 +84,7 @@ final class PaneToolbarView: NSView {urlButton.onEditingChange = { [weak self] in self?.editVeil.isHidden = !$0 }editVeil.wantsLayer = trueeditVeil.layer?.backgroundColor = NSColor.white.withAlphaComponent(0.09).cgColor- for v in [hairline, editVeil, devDivider, urlButton, placeholderLabel] as [NSView] {+ for v in [hairline, editVeil, devDivider, devTrailingDivider, urlButton, placeholderLabel] as [NSView] {v.isHidden = trueaddSubview(v)}@@ -249,8 +252,12 @@ final class PaneToolbarView: NSView {return glyph("copy", "link", help: "Copy URL (⇧⌘C)", width: 28) { $0.actions.performAction("copyURL") }case .divider:return devDivider- case .devTools:- return glyph("devtools", "terminal", help: "Developer Tools (⌥⌘I)", width: 28) { $0.actions.performAction("devTools") }+ case .console:+ return glyph("console", "terminal", help: "Toggle Console (⌥⌘J)", width: 28) { $0.actions.performAction("jsConsole") }+ case .network:+ return glyph("network", "globe", help: "Toggle Network Panel", width: 28) { $0.actions.performAction("networkPanel") }+ case .inspect:+ return glyph("inspect", "scope", help: "Inspect Element (⌥⌘C)", width: 28) { $0.actions.performAction("inspectElement") }case .pinnedExtension(let id):let e = m.pinned.first { $0.id == id }let b = button("ext:" + id) { ToolbarGlyphButton() }@@ -274,12 +281,14 @@ final class PaneToolbarView: NSView {let l = bar.left.compactMap { view($0) as? ToolbarGlyphButton }let r = bar.right.map(view)devDivider.layer?.backgroundColor = m.dividerColor.cgColor+ devTrailingDivider.layer?.backgroundColor = m.dividerColor.cgColorlet used = Set((l as [NSView] + r).map(ObjectIdentifier.init))for (k, b) in buttons where !used.contains(ObjectIdentifier(b)) {b.removeFromSuperview()buttons[k] = nil}devDivider.isHidden = !r.contains { $0 === devDivider }+ devTrailingDivider.isHidden = devDivider.isHidden || r.last === buttons["inspect"]left = lright = r@@ -322,13 +331,14 @@ final class PaneToolbarView: NSView {}let leftEnd = left.isEmpty ? 0 : x// Right group, from the trailing edge: pinned extensions … Split View 6 pt in; a split pane's- // close 4 pt in; developer copy · divider · DevTools spaced like the HStack around them.+ // close 4 pt in; developer copy | Console, Network, Inspect | spaced as in Arc 1.170 (#88).var rx = w - (m.inSplit ? 4 : (right.isEmpty ? 0 : 6))var trailing = rightvar devGroup: [NSView] = []- if m.kind == .developer, let i = trailing.firstIndex(where: { $0 === devDivider }) {- devGroup = Array(trailing[(i - 1)...(i + 1)])- trailing.removeSubrange((i - 1)...(i + 1))+ if m.kind == .developer, let i = trailing.firstIndex(where: { $0 === devDivider }),+ let end = trailing.firstIndex(where: { $0 === buttons["inspect"] }) {+ devGroup = Array(trailing[(i - 1)...end])+ trailing.removeSubrange((i - 1)...end)}for v in trailing.reversed() {let bw = (v as? ToolbarGlyphButton)?.width ?? 26@@ -336,12 +346,18 @@ final class PaneToolbarView: NSView {v.frame = NSRect(x: rx, y: (h - bh) / 2, width: bw, height: bh)}if !devGroup.isEmpty {- if !trailing.isEmpty { rx -= 6 }+ // Arc: Inspect, 7 pt, a rule, 8 pt, Extensions; copy, 14 pt, a rule, 13 pt, then the+ // next group (Arc's Capture buttons, which Cra doesn't have).+ if !trailing.isEmpty {+ rx -= 8 + 1+ devTrailingDivider.frame = NSRect(x: rx, y: (h - 14) / 2, width: 1, height: 14)+ rx -= 7+ }for v in devGroup.reversed() {if v === devDivider {- rx -= 6 + 5 + 1+ rx -= 13 + 1v.frame = NSRect(x: rx, y: (h - 14) / 2, width: 1, height: 14)- rx -= 5 + 6+ rx -= 14} else {let bw = (v as? ToolbarGlyphButton)?.width ?? 26rx -= bw@@ -360,10 +376,10 @@ final class PaneToolbarView: NSView {let ux = a + (b - a - uw) / 2urlButton.frame = NSRect(x: ux, y: (h - 28) / 2, width: uw, height: 28)case .developer:- // The URL fills half the room after its 8 pt lead; a Spacer(min 8) takes the rest.+ // Arc's address field (contentPanelTextField) runs from its 8 pt lead to 7 pt before+ // Copy Link (Arc 1.170, #88); it has no hover, so only clicks and long URLs see its width.let start = a + 8- let room = max(0, b - start - 6 - 8)- urlButton.frame = NSRect(x: start, y: (h - 28) / 2, width: room / 2 + 8, height: 28)+ urlButton.frame = NSRect(x: start, y: (h - 28) / 2, width: max(0, rightStart - 7 - start), height: 28)case .noTab, .emptyPane:let s = placeholderLabel.intrinsicContentSizelet pw = min(ceil(placeholderLabel.attributedStringValue.size().width), max(0, b - a))@@ -408,14 +424,20 @@ final class PaneToolbarView: NSView {menu.popUp(positioning: nil, at: NSPoint(x: 0, y: view.bounds.height + 4), in: view)}- // A click anywhere on the bar edits the URL (a pane's click also focuses it); a drag moves- // the window, as on Arc's toolbar.+ // Arc 1.170 opens the command bar from the address only (ToolbarURLButton) or the no-tab+ // placeholder; a click on the bar's empty space just focuses its pane (GitHub #88), and a+ // drag moves the window.override var mouseDownCanMoveWindow: Bool { false }override func acceptsFirstMouse(for event: NSEvent?) -> Bool { takesClickFromChildWindow }override func mouseDown(with event: NSEvent) { press.begin(event) }override func mouseDragged(with event: NSEvent) { press.drag(event) }override func mouseUp(with event: NSEvent) {- if press.finish() { editURL() }+ guard press.finish() else { return }+ if !placeholderLabel.isHidden, placeholderLabel.frame.contains(convert(event.locationInWindow, from: nil)) {+ editURL()+ } else if let id = paneTabID {+ actions.focusPane(id)+ }}}diff --git a/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift b/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swiftindex a35e5ff..d0f19e2 100644--- a/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift+++ b/Sources/Cra/UI/Sidebar/List/SidebarRowViews.swift@@ -724,6 +724,8 @@ final class TabRowView: SidebarRowView, ArcTooltipTarget, NSTextFieldDelegate {func apply(_ m: TabRowModel) {guard m != model else { return }+ // A subtitle coming or going moves the title (developer mode on a live tab, GitHub #88).+ if (m.subtitle == nil) != (model?.subtitle == nil) { needsLayout = true }model = mif m.githubMark { favicon.showGitHubMark(colors: colors) } else { favicon.show(m.icon, flip: m.flipIcon, colors: colors) }titleLabel.stringValue = m.titlediff --git a/Sources/Cra/UI/Sidebar/List/SpaceListView.swift b/Sources/Cra/UI/Sidebar/List/SpaceListView.swiftindex 5fce0fb..fe10b7f 100644--- a/Sources/Cra/UI/Sidebar/List/SpaceListView.swift+++ b/Sources/Cra/UI/Sidebar/List/SpaceListView.swift@@ -270,9 +270,10 @@ final class SpaceListView: NSView, NSDraggingSource {let selected = store.isSelected(item.id, window: window)let navigatedAway = pinned && tab.url != tab.savedURL && !tab.savedURL.isEmptylet (img, flip) = icon(tab.iconKey)+ let subtitle = tab.sidebarSubtitle(navigatedAway: navigatedAway, developerMode: store.settings.isDeveloperMode(url: tab.url))row.content = .tab(TabRowModel(id: item.id, depth: depth, pinned: pinned, title: item.displayTitle, customTitle: item.title != nil,- renameText: item.title ?? item.displayTitle, subtitle: Self.subtitle(tab, navigatedAway: navigatedAway),+ renameText: item.title ?? item.displayTitle, subtitle: subtitle,icon: img, flipIcon: flip, githubMark: tab.liveItemURL != nil && tab.customIconKey == nil,editing: renaming == item.id, selected: selected,highlighted: picks.isEmpty ? selected && !placeholder : picks.contains(item.id),@@ -322,15 +323,6 @@ final class SpaceListView: NSView, NSDraggingSource {line: drop?.line)}- /// Arc shows the host under a pinned tab only when it has left the pinned site (navigating- /// within the same host shows nothing); a live folder's pull request shows its author.- private static func subtitle(_ tab: TabData, navigatedAway: Bool) -> String? {- if let author = tab.liveSubtitle, URL(string: tab.url)?.host == "github.com" { return author }- guard navigatedAway, let host = URL(string: tab.url)?.host, let saved = URL(string: tab.savedURL)?.host,- host.replacingOccurrences(of: "www.", with: "") != saved.replacingOccurrences(of: "www.", with: "") else { return nil }- return host.replacingOccurrences(of: "www.", with: "")- }-/// A line inside the open live folder when there are no pull requests to show, or GitHub/// can't be read (Arc: "Sign back in to GitHub.", "Login with SSO to unlock this folder").private static func liveStatus(_ item: SidebarItem) -> (text: String, url: String?)? {diff --git a/Sources/Cra/UI/ToolbarComposition.swift b/Sources/Cra/UI/ToolbarComposition.swiftindex c50a8a5..c425672 100644--- a/Sources/Cra/UI/ToolbarComposition.swift+++ b/Sources/Cra/UI/ToolbarComposition.swift@@ -4,8 +4,10 @@ import Foundation/// and places the views. Measured against Arc 1.170: the full bar is sidebar toggle ← → ↻ on/// the left and pinned extensions, Extensions, Split View on the right; a split pane has only/// ← → and its options (focused pane) and close; the developer bar swaps the navigation for-/// copy · divider · DevTools. The toggle is there only while the sidebar is hidden or floating:-/// otherwise the sidebar's header carries it (Arc 1.171, GitHub #50).+/// copy · divider · Console, Network, Inspect (Arc's Toggle Console, Toggle Network Panel and+/// Inspect Element, GitHub #88; Arc's Capture Window and Capture between them are not in Cra).+/// The toggle is there only while the sidebar is hidden or floating: otherwise the sidebar's+/// header carries it (Arc 1.171, GitHub #50).struct ToolbarComposition: Equatable {enum Kind: Equatable { case noTab, emptyPane, normal, developer }@@ -17,7 +19,9 @@ struct ToolbarComposition: Equatable {case reload(loading: Bool, enabled: Bool)case copyURLcase divider- case devTools+ case console+ case network+ case inspectcase pinnedExtension(String)case extensionscase addSplit@@ -42,7 +46,7 @@ struct ToolbarComposition: Equatable {left += [.back(enabled: canGoBack), .forward(enabled: canGoForward)]if !inSplit { left.append(.reload(loading: isLoading, enabled: true)) }case .developer:- right += [.copyURL, .divider, .devTools]+ right += [.copyURL, .divider, .console, .network, .inspect]}// Arc's right end: pinned extensions, the Extensions button, then Split View; also on// the no-tab bar. A split pane has its options (focused pane only) and close instead.diff --git a/Sources/Cra/UI/Windows/LittleWindowController.swift b/Sources/Cra/UI/Windows/LittleWindowController.swiftindex d56f61e..a0117f3 100644--- a/Sources/Cra/UI/Windows/LittleWindowController.swift+++ b/Sources/Cra/UI/Windows/LittleWindowController.swift@@ -582,7 +582,9 @@ final class LittleWindowController: NSWindowController, NSWindowDelegate, @precocase "copyURL": copy(currentURL)case "copyURLMarkdown": copy("[\(browser?.currentTitle ?? state.title)](\(currentURL))")case "viewSource": browser?.viewSource()- case "devTools", "jsConsole", "inspectElement": browser?.showDevTools()+ case "devTools", "jsConsole", "inspectElement":+ browser?.devToolsAction = ["jsConsole": "console", "inspectElement": "inspect"][id]+ browser?.showDevTools()case "print": browser?.print()case "promoteLittleWindow": promote(to: nil)// No find bar or capture in little windows; keep them off the main window.diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swiftindex 44fdb4d..b0bf2a5 100644--- a/Sources/Cra/UI/Windows/MainWindowController.swift+++ b/Sources/Cra/UI/Windows/MainWindowController.swift@@ -46,6 +46,7 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserMprivate var shownTheme: SpaceTheme?private var lastSidebarWidth: CGFloat = 0private var commandBarOpenedAt = Date.distantPast+ private var commandBarClosingClick = DismissingClick()private var commandObserving = false/// Closed for good (another window stayed open): it no longer follows the store.private var isTornDown = false@@ -2057,6 +2058,12 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserMfunc openCommandBar(_ mode: CommandBarMode) {guard let window else { return }+ // A click on the address that closed the bar leaves it closed (Arc, GitHub #88).+ if mode == .editURL, NSApp.currentEvent?.type == .leftMouseUp,+ commandBarClosingClick.isClosingClick(lastMouseDown: ProcessInfo.processInfo.systemUptime+ - CGEventSource.secondsSinceLastEventType(.combinedSessionState, eventType: .leftMouseDown)) {+ return+ }// An empty split pane gets Arc's "Search or Enter URL…" bar; the result fills the pane.let fillingEmptyPane = selectedTab?.isEmptyTab == truelet prefill = mode == .editURL && !fillingEmptyPane ? selectedTab?.tab?.url : nil@@ -2329,6 +2336,8 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM}return}+ let event = NSApp.currentEvent+ commandBarClosingClick.panelClosed(byMouseDownAt: event?.type == .leftMouseDown ? event?.timestamp : nil)commandBar.close()}diff --git a/Sources/CraCEF/CraCEF.mm b/Sources/CraCEF/CraCEF.mmindex 0802b95..33ebdc5 100644--- a/Sources/CraCEF/CraCEF.mm+++ b/Sources/CraCEF/CraCEF.mm@@ -182,6 +182,7 @@ static CraClient* AsCraClient(CefClient* c) {- (void)adoptBrowser:(CefRefPtr<CefBrowser>)browser;- (void)devToolsBrowserCreated:(CefRefPtr<CefBrowser>)browser;- (void)devToolsBrowserClosed;+- (void)runDevToolsAction;- (void)browserClosed;- (void)downloadUpdated:(CraDownloadInfo*)download;- (CefRefPtr<CefBrowser>)cefBrowser;@@ -733,6 +734,10 @@ static const char kCraDevToolsHooks[] ="if(++n>60){clearInterval(timer);timer=null;var f=make();f.style.position='fixed';f.style.top='1px';f.style.right='4px';f.style.zIndex='2147483647';document.body.appendChild(f);}},150);}""function removeClose(){if(timer){clearInterval(timer);timer=null;}var b=find(document,'#cra-close');if(b)b.remove();}""h.closeWindow=function(){console.log('__cra_devtools_close');};"+ // Chrome asks the frontend for a panel or the element picker once it reports loadCompleted+ // (DevToolsWindow::DoAction); -runDevToolsAction queues on __craRun until then.+ "var lc=h.loadCompleted;h.loadCompleted=function(){var r=lc&&lc.apply(h,arguments);h.__craLoaded=1;"+ "var q=h.__craRun||[];h.__craRun=[];q.forEach(function(f){f();});return r;};""if(!/[?&]can_dock=/.test(location.search)){installClose();return;}""var sent=false;""h.setInspectedPageBounds=function(b){sent=true;try{console.log('__cra_devtools_bounds:'+JSON.stringify({x:b.x,y:b.y,width:b.width,height:b.height}));}catch(e){}};"@@ -786,6 +791,7 @@ public:if (!frame->IsMain()) return;CraDevToolsLog(@"OnLoadEnd %s", frame->GetURL().ToString().c_str());if (host_) Prepare(browser, frame);+ else if (CraBrowser* o = owner_; o && IsFrontend(frame->GetURL().ToString())) [o runDevToolsAction];}static bool IsFrontend(const std::string& url) {@@ -814,6 +820,7 @@ public:// The undockable load that MakeDockable replaced still reports its end.if (reloaded_ && url.find("can_dock=") == std::string::npos) return;frame->ExecuteJavaScript(kCraDevToolsHooks, frame->GetURL(), 0);+ if (CraBrowser* o = owner_) [o runDevToolsAction];}bool OnConsoleMessage(CefRefPtr<CefBrowser> browser, cef_log_severity_t level, const CefString& message,@@ -1838,12 +1845,17 @@ class CraDevToolsObserver : public CefDevToolsMessageObserver {if (!_browser) return;if (self.hostWindow) {// Chrome-style: Chrome docks DevTools inside the page window itself.+ BOOL open = _browser->GetHost()->HasDevTools();_browser->GetHost()->ShowDevTools(CefWindowInfo(), nullptr, CefBrowserSettings(), CefPoint((int)point.x, (int)point.y));+ // Open DevTools take the action now; new ones when DevToolsClient prepares the frontend.+ if (open && _devToolsBrowser && !_devToolsBrowser->IsLoading()) [self runDevToolsAction];return;}if (_browser->GetHost()->HasDevTools()) {_browser->GetHost()->ShowDevTools(CefWindowInfo(), nullptr, CefBrowserSettings(),CefPoint((int)point.x, (int)point.y));+ // A frontend still loading takes the action when DevToolsClient prepares it.+ if (_devToolsBrowser && !_devToolsBrowser->IsLoading()) [self runDevToolsAction];return;}NSView* host = [self.delegate devToolsHostViewForBrowser:self];@@ -1872,6 +1884,25 @@ class CraDevToolsObserver : public CefDevToolsMessageObserver {- (void)showDevTools { [self showDevToolsInspectingPoint:NSZeroPoint]; }- (void)closeDevTools { if (_browser) _browser->GetHost()->CloseDevTools(); }+// The frontend's own API, which Chrome's DevToolsWindow::DoAction calls through DevToolsAPI.+- (void)runDevToolsAction {+ NSString* action = _devToolsAction;+ if (!action || !_devToolsBrowser) return;+ _devToolsAction = nil;+ NSString* call;+ if ([action isEqualToString:@"inspect"]) call = @"enterInspectElementMode()";+ else if ([@[@"console", @"network", @"elements"] containsObject:action]) call = [NSString stringWithFormat:@"showPanel('%@')", action];+ else return;+ CraDevToolsLog(@"frontend %@", call);+ // Hooked frontends run it on loadCompleted (or at once once loaded); one loaded before the+ // hooks went in never reports it, so the call goes out after 3 s regardless.+ NSString* js = [NSString stringWithFormat:@"(function(){var h=window.InspectorFrontendHost,done=false;"+ "function run(){if(done)return;done=true;var a=window.InspectorFrontendAPI;if(a)a.%@;}"+ "if(!h||h.__craLoaded){run();return;}(h.__craRun=h.__craRun||[]).push(run);setTimeout(run,3000);})();", call];+ CefRefPtr<CefFrame> f = _devToolsBrowser->GetMainFrame();+ if (f) f->ExecuteJavaScript(CefStringFromNS(js), f->GetURL(), 0);+}+- (void)devToolsBrowserCreated:(CefRefPtr<CefBrowser>)browser { _devToolsBrowser = browser; }- (void)devToolsBrowserClosed { _devToolsBrowser = nullptr; }- (void)executeJavaScript:(NSString*)script inDevTools:(BOOL)inDevTools {diff --git a/Sources/CraCEF/include/CraCEF.h b/Sources/CraCEF/include/CraCEF.hindex 2d88b69..63edf43 100644--- a/Sources/CraCEF/include/CraCEF.h+++ b/Sources/CraCEF/include/CraCEF.h@@ -139,6 +139,10 @@ typedef NS_ENUM(NSInteger, CraDownloadState) {- (void)setFocused:(BOOL)focused;- (void)showDevToolsInspectingPoint:(NSPoint)point;- (void)showDevTools;+/// What the next -showDevTools asks of the frontend, as Chrome's DevToolsToggleAction does: a+/// panel to select ("console", "network", "elements"), or "inspect" for the element picker. Done+/// once the frontend is up (at once when DevTools are already open), then cleared.+@property (nonatomic, copy, nullable) NSString *devToolsAction;- (void)closeDevTools;- (double)zoomLevel;- (void)setZoomLevel:(double)level;diff --git a/Tests/BrowserManagerLifecycleTests.swift b/Tests/BrowserManagerLifecycleTests.swiftindex 124c73f..d267727 100644--- a/Tests/BrowserManagerLifecycleTests.swift+++ b/Tests/BrowserManagerLifecycleTests.swift@@ -263,17 +263,20 @@ enum BrowserManagerLifecycleTests {let id = store.createTab(url: "https://example.test/devtools").idmanager.show(id, focus: false)let browser = manager.runtime(for: id)!.browser- manager.toggleDevTools()+ manager.runDevTools(.toggle)manager.browser(browser, didCreateDevToolsView: NSView())- manager.toggleDevTools()- manager.toggleDevTools()+ manager.runDevTools(.toggle)+ manager.runDevTools(.console)expect(browser.devToolsRequests == ["show", "close"], "a press while DevTools close asks CEF for nothing yet")manager.browserDidCloseDevTools(browser)- expect(browser.devToolsRequests == ["show", "close", "show"], "once CEF reports them closed, the press opens them again")+ expect(browser.devToolsRequests == ["show", "close", "show"] && browser.devToolsAction == "console",+ "once CEF reports them closed, the press opens them again, on the Console (#88)")manager.browser(browser, didCreateDevToolsView: NSView())- manager.showDevTools()- expect(browser.devToolsRequests.last == "show" && manager.runtime(for: id)!.devTools.state == .open,- "Inspect Element on open DevTools keeps them open")+ manager.runDevTools(.inspect)+ expect(browser.devToolsRequests.last == "show" && manager.runtime(for: id)!.devTools.state == .open+ && browser.devToolsAction == "inspect", "Inspect Element on open DevTools keeps them open and arms the picker")+ manager.runDevTools(.network)+ expect(browser.devToolsRequests.last == "close" && browser.devToolsAction == nil, "Network on open DevTools closes them")manager.closeAll()}diff --git a/Tests/BrowserManagerSupport/CraCEF.swift b/Tests/BrowserManagerSupport/CraCEF.swiftindex f2dd8e0..54dde0a 100644--- a/Tests/BrowserManagerSupport/CraCEF.swift+++ b/Tests/BrowserManagerSupport/CraCEF.swift@@ -47,6 +47,8 @@ public final class CraBrowser {/// "show" / "close", in the order Cra asked.public var devToolsRequests: [String] = []public func showDevTools() { hasDevTools = true; devToolsRequests.append("show") }+ /// The frontend work asked of the next show (a panel, "inspect"); CEF clears it once done.+ public var devToolsAction: String?public func closeDevTools() { hasDevTools = false; devToolsRequests.append("close") }public func setAudioMuted(_ muted: Bool) {}public private(set) var backgroundProbes = 0diff --git a/Tests/PolicyTests.swift b/Tests/PolicyTests.swiftindex 972d8f0..ca1c2e4 100644--- a/Tests/PolicyTests.swift+++ b/Tests/PolicyTests.swift@@ -41,8 +41,8 @@ enum PolicyTests {expect(noTab.left == [.toggleSidebar, .back(enabled: false), .forward(enabled: false), .reload(loading: false, enabled: false)]&& noTab.right == [.pinnedExtension("a"), .extensions, .addSplit], "no tab: greyed navigation, the right end as usual")let dev = bar(.developer, pinned: ["a"])- expect(dev.left == [.toggleSidebar] && dev.right == [.copyURL, .divider, .devTools, .pinnedExtension("a"), .addSplit],- "the developer bar: copy · divider · DevTools before the right end")+ expect(dev.left == [.toggleSidebar] && dev.right == [.copyURL, .divider, .console, .network, .inspect, .pinnedExtension("a"), .addSplit],+ "the developer bar: copy · divider · Console, Network, Inspect before the right end (Arc 1.170, #88)")}private static func extensionLaunch() {@@ -88,6 +88,19 @@ enum PolicyTests {_ = userClosed.toggle()userClosed.didOpen()expect(userClosed.didClose() == .none && userClosed.toggle() == .show, "closed from DevTools' own button: the next press opens")++ // The developer bar and ⌥⌘J/⌥⌘C (#88): Chrome's toggle, with the frontend on a panel.+ var bar = DevToolsToggle()+ expect(bar.run(.console) == (.show, "console"), "Console on closed DevTools opens them on the Console")+ bar.didOpen()+ expect(bar.run(.network) == (.close, nil), "Network on open DevTools closes them, as Chrome's toggle does")+ expect(bar.run(.network) == (.none, "network") && bar.state == .closing(reopen: true), "pressed while closing: reopened on Network")+ expect(bar.didClose() == .show, "once closed")+ bar.didOpen()+ expect(bar.run(.inspect) == (.show, "inspect") && bar.state == .open, "Inspect never closes: the picker on open DevTools")+ expect(bar.run(.toggle) == (.close, nil), "⌥⌘I closes")+ var plain = DevToolsToggle()+ expect(plain.run(.toggle) == (.show, nil), "⌥⌘I opens DevTools as they were")}private static func featureFlags() {diff --git a/Tests/Snapshots/toolbar-developer.png b/Tests/Snapshots/toolbar-developer.pngindex ce0ca5e..1b4ebc7 100644Binary files a/Tests/Snapshots/toolbar-developer.png and b/Tests/Snapshots/toolbar-developer.png differdiff --git a/docs/arc-reverse-engineering.md b/docs/arc-reverse-engineering.mdindex f169cfb..813bfbd 100644--- a/docs/arc-reverse-engineering.md+++ b/docs/arc-reverse-engineering.md@@ -1916,6 +1916,29 @@ child window key; AppKit then spent the next toolbar click on making the main wibuttons accept first mouse while a child window is key. Clicks after the page had focus were not affected(real HID test).+## Toolbar clicks, developer bar buttons, developer-mode rows (Arc 1.170, 2 Nov 2026, issue #88)++AX reads of Arc's windows, 1x window captures, and HID clicks while the Mac was idle:++- [O] Normal bar address: `example.org/cra88/deep/path?q=1` shows host bright and path + query dim (AX+ static text carries all of it). Arc does not drop the path; Cra already matched. The link glyph before+ it is a separate button, "Copy Current URL".+- [O] Clicks: empty bar space left or right of the address opens nothing (window keyed by a page click+ first, two runs, captures); the address opens the command bar; a click on the address while the bar+ is open closes it and it stays closed; the next click opens it. Cra: PaneToolbarView only focuses its+ pane on empty space; `DismissingClick` keeps the closing click from reopening the bar.+- [O] Developer bar (AX descriptions, left to right): Site Settings (28 pt), `contentPanelTextField`+ from 40 pt to 7 pt before Copy Link (530 of 923 pt), Copy Link | Capture Window, Capture | Toggle+ Console, Toggle Network Panel, Inspect Element | Extensions Menu, pinned extensions, Split View Menu.+ Buttons 28 pt edge to edge; rules 1 pt: copy, 14, rule, 13, Capture Window; Capture, 8, rule, 8,+ Console; Inspect, 7, rule, 8, Extensions. Glyphs: terminal, globe, crosshair.+- [S] ArcCore names Chrome's commands (`DevTools_ToggleConsole`, `DevTools_InspectElement`,+ `enterInspectElementMode`, `showPanel`): Chrome's ToggleDevToolsWindow closes docked DevTools on+ Console (only Inspect forces them open). Cra runs the same (DevToolsToggle.Command) and asks the+ frontend for the panel or the picker once it reports `loadCompleted`, as DevToolsWindow::DoAction does.+- [O] Sidebar: a Today tab on a developer-mode host (example.com) shows the host under its title; one on+ another host (httpbin.org) shows nothing.+## Live sidebar blur (1 Nov 2026, issue #37)Arc's sidebar blur is `NSVisualEffectView` only (no `CABackdropLayer` in Arc's or ArcCore's strings). AppKit's