Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 17 additions & 0 deletions Packages/CraCore/Sources/CraCore/LibraryRailIcons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,23 @@ public enum LibraryRailTile {
return Column(top: top, slot: slot, tileHeight: tile, showsLabel: slot > labelSlotFloor)
}

/// The rail's foot (Arc 1.170, AX frames, 27 Oct 2026): the back arrow, 32 × 32 pt at x 8 and 8 pt above the
/// bottom, leaves the Library; the gift button at x 73, the arrow's place mirrored against the 113 pt rail, opens
/// Share Cra with a Friend where Arc's opens "Share Arc with a friend".
public static let footButton: CGFloat = 32
public static let footInset: CGFloat = 8

/// The back arrow in a rail `railHeight` tall, from the rail's top-left.
public static func backFrame(railHeight: CGFloat) -> CGRect {
CGRect(x: footInset, y: railHeight - footInset - footButton, width: footButton, height: footButton)
}

/// The gift button: on the back arrow's row, as far in from the rail's right edge as the arrow is from its left.
public static func giftFrame(railHeight: CGFloat) -> CGRect {
CGRect(x: CGFloat(LibraryWidth.rail) - footInset - footButton, y: railHeight - footInset - footButton,
width: footButton, height: footButton)
}

/// The sidebar's ink is the system's label colour: white on a dark theme and black on a light one,
/// at this strength. The tile's wash and its label are shares of it.
public static let inkStrength = 0.85
Expand Down
12 changes: 12 additions & 0 deletions Packages/CraCore/Tests/CraCoreTests/LibraryRailIconsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ import Testing
#expect(T.tooltipDelay == 0.45)
}

/// Arc 1.170's foot (AX frames): the back arrow 32 x 32 pt at x 8, 8 pt above the bottom, and the gift button at
/// x 73 on its row, 8 pt in from the 113 pt rail's right edge.
@Test func theGiftButtonSitsRightOfTheBackArrowAsArcs() {
typealias T = LibraryRailTile
#expect(T.backFrame(railHeight: 1000) == CGRect(x: 8, y: 960, width: 32, height: 32))
#expect(T.giftFrame(railHeight: 1000) == CGRect(x: 73, y: 960, width: 32, height: 32))
// A short window moves the row with the bottom, and the gift stays clear of the arrow and inside the rail.
let back = T.backFrame(railHeight: 300), gift = T.giftFrame(railHeight: 300)
#expect(gift.minY == back.minY && gift.minX > back.maxX)
#expect(gift.maxX + 8 == CGFloat(LibraryWidth.rail))
}

/// The icon's lines are the palette's maxContrastColor and its insides the cutoutColor: on a dark
/// sidebar the theme's light tint over its darkest shade, on a light one the other way round.
@Test func iconColoursAreTheThemesTwo() {
Expand Down
7 changes: 7 additions & 0 deletions Sources/Cra/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
CraLog.note("library back arrow: \(pressed ? "pressed" : "no library")")
return
}
// libraryGift=1: the Library rail's gift button, as its click sends it; cra.log says its glyph, tip and
// place beside the back arrow, and "share cra sheet:" whether the sheet opened on the window.
if dict["libraryGift"] != nil {
let readout = (main.shell.sidebarHost as? SidebarView)?.debugLibraryGift()
CraLog.note("library gift: \(readout.map { "pressed \($0)" } ?? "no library")")
return
}
if let name = dict["libraryRail"] {
guard let page = LibraryPage(rawValue: name), let sidebar = main.shell.sidebarHost as? SidebarView else {
CraLog.note("library rail: none"); return
Expand Down
5 changes: 4 additions & 1 deletion Sources/Cra/UI/Settings/MemberCardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ private struct ShareCraCard: View {
struct ShareCraSheet: View {
@Environment(\.dismiss) private var dismiss
@State private var copied = false
/// Set when AppKit hangs the sheet on a browser window (the Library's gift button): SwiftUI's dismiss closes only
/// what SwiftUI presented, as Settings' sheet is.
var close: (() -> Void)?

private static let background = Color(.sRGB, red: 0.11, green: 0.11, blue: 0.12)
private static let ticket = Color(.sRGB, red: 0.13, green: 0.19, blue: 0.2)
Expand All @@ -329,7 +332,7 @@ struct ShareCraSheet: View {
VStack(spacing: 0) {
HStack {
Spacer()
Button { dismiss() } label: {
Button { if let close { close() } else { dismiss() } } label: {
Image(systemName: "xmark").font(.system(size: 15, weight: .medium)).foregroundStyle(.white.opacity(0.8))
}
.buttonStyle(.plain)
Expand Down
33 changes: 29 additions & 4 deletions Sources/Cra/UI/Sidebar/LibraryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import UniformTypeIdentifiers
/// - The list column: a 36 pt search field ("Search Archive…") from x 120 and a Filter button
/// at the top, 10 pt from the window top; day headers ("Today", 13 pt semibold); rows 56 pt
/// apart with a 24 pt icon at x 130, the title at x 164 (14 pt) and the URL under it (12 pt).
/// - A back arrow (32×32 at x 8, 8 pt above the bottom) leaves the Library.
/// - A back arrow (32×32 at x 8, 8 pt above the bottom) leaves the Library; a gift button at x 73 on its row opens
/// "Share Arc with a friend", Cra's Share Cra with a Friend (LibraryRailTile.giftFrame).
/// - Arc leaves it by the shortcut, Escape, that arrow or a swipe (LibraryCloseSource), never by
/// clicking elsewhere, and reopens it on the page last shown.
/// - Opening takes 2–3 frames (the Library slides in from a little to the left); closing slides
Expand Down Expand Up @@ -49,6 +50,7 @@ final class LibraryView: NSView {
super.init(frame: .zero)
rail.onPick = { actions.showLibrary($0) }
rail.onBack = { actions.closeLibrary() }
rail.onGift = { actions.shareCra() }
rail.pageMenu = { [store, weak self] p in LibraryListView.pageMenu(p, store: store, profile: (self?.window?.windowController as? MainWindowController)?.profileDirectoryName) }
list.onEscape = { actions.closeLibrary() }
addSubview(rail)
Expand All @@ -69,6 +71,9 @@ final class LibraryView: NSView {
/// Scenarios (#726): the rail's back arrow, as its click sends it.
func debugBack() { rail.onBack() }

/// Scenarios: the rail's gift button, as its click sends it; its glyph, tip and place beside the back arrow's.
func debugGift() -> String { rail.pressGift() }

/// Scenarios (#649): see LibraryListView.debugDownloadMore.
func debugDownloadMore() -> String { list.debugDownloadMore() }

Expand Down Expand Up @@ -141,19 +146,21 @@ final class LibraryView: NSView {
}

/// The rail: a faint wash brightening to the right, ending in a hairline; the page buttons
/// centred; the back arrow at the bottom.
/// centred; the back arrow and the gift button at the bottom.
private final class LibraryRailView: NSView {
var onPick: (LibraryPage) -> Void = { _ in }
/// Arc's "Show media" folders, on a right-click of the Media button.
var pageMenu: (LibraryPage) -> NSMenu? = { _ in nil }
var onBack: () -> Void = {}
var onGift: () -> Void = {}
var colors = SidebarColors() { didSet { refresh() } }
/// The icons' two colours, from the space's theme: their lines, and what fills the shown page's.
var tones: (lines: NSColor, inside: NSColor) = (.white, .black) { didSet { refresh() } }
private let wash = CAGradientLayer()
private let hairline = CALayer()
private var buttons: [LibraryRailButton] = []
private var back: SidebarGlyphButton?
private var gift: SidebarGlyphButton?
private var page: LibraryPage = .downloads
let pages: [LibraryPage]
/// The panel's reach back past the rail's leading edge (LibraryView.railStretch).
Expand Down Expand Up @@ -221,23 +228,41 @@ private final class LibraryRailView: NSView {
addSubview(b)
back = b
}
if gift == nil {
// Arc's gift beside its back arrow, drawn as that arrow is.
let b = SidebarGlyphButton(symbol: "gift", size: 32, height: 32, iconSize: 15, weight: .regular,
help: "Share Cra with a friend", colors: colors) { [weak self] in self?.onGift() }
addSubview(b)
gift = b
}
back?.colors = colors
gift?.colors = colors
needsLayout = true
}

/// cra://debug?libraryGift: the gift button's click, and what it is and where, beside the back arrow.
func pressGift() -> String {
guard let gift, let back else { return "none" }
func place(_ f: NSRect) -> String { "\(Int(f.minX)),\(Int(f.minY)) \(Int(f.width))x\(Int(f.height))" }
let readout = "\(gift.debugReadout) at \(place(gift.frame)), back arrow at \(place(back.frame))"
gift.action()
return readout
}

override func layout() {
super.layout()
let w = LibraryMetrics.rail - 1, h = bounds.height
placeWash()
// Spacer(minLength: title area), the buttons 20 apart, Spacer, the back arrow 8 pt in.
// Spacer(minLength: title area), the buttons 20 apart, Spacer, the back arrow and the gift 8 pt in.
// The tiles between the title area and the back arrow; a short window shrinks them and drops their labels.
let column = LibraryRailTile.column(count: buttons.count, height: h, topInset: CraMetrics.titleAreaHeight, bottomInset: 40)
let width = LibraryRailTile.size.width
for (i, b) in buttons.enumerated() {
b.showsLabel = column.showsLabel
b.frame = NSRect(x: (w - width) / 2, y: column.top + CGFloat(i) * column.slot, width: width, height: column.tileHeight)
}
back?.frame = NSRect(x: 8, y: h - 8 - 32, width: 32, height: 32)
back?.frame = LibraryRailTile.backFrame(railHeight: h)
gift?.frame = LibraryRailTile.giftFrame(railHeight: h)
}
}

Expand Down
2 changes: 2 additions & 0 deletions Sources/Cra/UI/Sidebar/List/SidebarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ final class SidebarView: NSView {
libraryHost.debugBack()
return true
}
/// The Library rail's gift button, pressed (see LibraryView.debugGift); nil with no Library up.
func debugLibraryGift() -> String? { libraryHost?.debugGift() }
/// Arc's Create a Space page, over the space's column while one is being made.
private var creationHost: SpaceCreationView?
var debugSpaceCreation: String { creationHost?.debugLine ?? "none" }
Expand Down
2 changes: 2 additions & 0 deletions Sources/Cra/UI/SidebarUIState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ final class SidebarActions {
/// The Library in the sidebar: open it on a page, leave it, restore an archived tab from it.
var showLibrary: (LibraryPage) -> Void = { _ in }
var closeLibrary: () -> Void = {}
/// The Library's gift button: Share Cra with a Friend, as a sheet on this window.
var shareCra: () -> Void = {}
var restoreArchived: (UUID) -> Void = { _ in }
var resetPinnedTab: (UUID) -> Void = { _ in }
/// Arc's "Share this tab instead" on a row (TabSharing): the call shares that tab, which shows.
Expand Down
9 changes: 9 additions & 0 deletions Sources/Cra/UI/Windows/MainWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
sidebarActions.toggleLibrary = { [weak self] in self?.toggleLibrary() }
sidebarActions.showLibrary = { [weak self] page in self?.showLibrary(page) }
sidebarActions.closeLibrary = { [weak self] in self?.leaveLibrary() }
sidebarActions.shareCra = { [weak self] in self?.showShareCra() }
sidebarActions.restoreArchived = { [weak self] id in
guard let self else { return }
_ = self.store.restoreArchived(id)
Expand Down Expand Up @@ -3809,6 +3810,14 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
currentBrowser?.setFocused(true)
}

/// The Library's gift button (Arc's opens "Share Arc with a friend"): Settings' Share Cra with a Friend sheet, on
/// this window, with the Library left open under it.
func showShareCra() {
guard let window else { return }
let shown = DialogPanel.present(over: window) { close in ShareCraSheet(close: close) }
CraLog.note("share cra sheet: \(shown ? "opens on the window" : "not shown, a sheet is already up")")
}

/// Arc's floating sidebar lives in its own panel above the page windows (see FloatingSidebarController).
private(set) var floatingSidebar: FloatingSidebarController?

Expand Down
25 changes: 25 additions & 0 deletions Tests/Scenarios/library-gift.scenario
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# The Library's gift button sits right of its back arrow, as Arc's (Arc 1.170: the arrow 32×32 at x 8, 8 pt above the
# bottom, the gift at x 73), drawn as the arrow is, with the tip "Share Cra with a friend". Its click opens Settings'
# Share Cra with a Friend sheet on the browser window, as Arc's opens "Share Arc with a friend", and leaves the Library
# open under it. A second press while the sheet is up opens no second one.

cra://action/openLibrary
wait 1.5
cra://debug?windowState=before
expect-log window state before: main0 .* sheet=0
cra://debug?libraryGift=1
expect-log library gift: pressed gift "Share Cra with a friend" at 73,[0-9]+ 32x32, back arrow at 8,[0-9]+ 32x32
expect-log share cra sheet: opens on the window
wait 1
cra://debug?windowState=shared
expect-log window state shared: main0 .* sheet=1
cra://debug?libraryGift=1
expect-log share cra sheet: not shown, a sheet is already up

# Closed as Escape would: the window has no sheet again, and the Library is still there.
cra://debug?endSheets=1
Comment on lines +19 to +20

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Dismissal test skips user action

endSheets=1 calls endSheet directly, bypassing the new ShareCraSheet.close callback. This scenario would still pass if the sheet’s × button or Escape stopped closing it. Exercise the close button or Escape, then keep the checks that the sheet is gone and the Library remains open.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

wait 1
cra://debug?windowState=closed
expect-log window state closed: main0 .* sheet=0
cra://debug?libraryBack=1
expect-log library back arrow: pressed
2 changes: 1 addition & 1 deletion docs/arc-parity.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ or Arc-only service), per CONTRIBUTING.md.
| Page zoom | View ▸ Zoom In / Zoom Out / Zoom to Actual Size (⌘+ ⌘− ⌘0): Chrome's steps (100 → 110 → 125 %), each one shown as a toast at the page's top right ("125%", "100%"), gone after about 4.9 s or a click | done | Measured in Arc 1.174.3 (26 Nov 2026): the same ShinyToast as every other toast; no lasting badge in the address bar or sidebar field. `PageZoomSteps` (CraCore), `page-zoom-toast` scenario (#856). |
| Help menu | Getting Started, Release Notes, Contact the Team, Visit Help Center, Restore Data | done | Cra Help (Arc's Help Center and Getting Started guide), Release Notes, Report an Issue… (Contact the Team), Essential Keyboard Shortcuts, Troubleshooting ▸ Task Manager / Reveal Data / Copy Info. *skip*: Restore Data and Export Arc Notes (Arc's account and Notes), Record Trace (chrome://tracing is a developer tool). |
| Ad blocker upsell card, Account, Sign Out, Send to Dia, Share Space | | *skip* | Account/cloud. |
| Membership card, Gift Arc to a Friend | Settings ▸ Account | done (Cra's own) | Settings' first tab, named after the user like Arc's (GitHub #372): a member card made on the Mac (macOS name, a nickname, EARLY '26, a months stamp in the first year, then anniversaries, the day Cra first ran), its share, save and copy buttons, the default-browser banner, and "Share Cra with a Friend", whose sheet copies or shares crabrowser.app tagged `utm_campaign=share`. No account, server or gift unlocks. |
| Membership card, Gift Arc to a Friend | Settings ▸ Account | done (Cra's own) | Settings' first tab, named after the user like Arc's (GitHub #372): a member card made on the Mac (macOS name, a nickname, EARLY '26, a months stamp in the first year, then anniversaries, the day Cra first ran), its share, save and copy buttons, the default-browser banner, and "Share Cra with a Friend", whose sheet copies or shares crabrowser.app tagged `utm_campaign=share`. The Library's gift button, right of its back arrow as in Arc, opens the same sheet on the browser window (scenario library-gift). No account, server or gift unlocks. |
| Space icon: Emoji and Icon tabs | Space header icon, Change Space Icon… | done, plus an Image tab (Cra's own) | Arc's picker has Emoji and Icon. Cra adds Image (GitHub PR #395, Victor agreed 12 Nov 2026): a PNG, SVG or other picture, chosen or dropped, stored as a 96 px PNG in `Space.iconImage`. The dock fades it like an emoji while its space is closed. An older Cra shows the space with no icon (a dot) and drops the picture when it saves. |
| Max: 5-Second Previews | Settings ▸ Max | done | Arc's hover cards on the Mac's Apple Intelligence: Arc's links on Google, X and Hacker News, or Shift on any link (the small card within the site); Arc's prompt, card, timing and share menu (arc-reverse-engineering.md). |
| Max: Ask on Page | ⌘F, Settings ▸ Max | done | Arc's find-or-ask card on the Mac's Apple Intelligence (#393): typing finds, Ask asks about the page with Arc's prompt, quotes with Find on Page, "This page was long, so I read the first N%." (arc-reverse-engineering.md). |
Expand Down
2 changes: 2 additions & 0 deletions docs/arc-reverse-engineering.md
Original file line number Diff line number Diff line change
Expand Up @@ -2748,6 +2748,8 @@ Library button's hover list (downloads) and its click (the archive) showed diffe
leave. Opening it from a hidden sidebar shows the sidebar until it closes. Unlike Arc's quick slide-and-fade, the
button and ⇧⌘L slide the Library in and out on the swipe's spring when the sidebar is docked (Victor, 2 Nov 2026;
see "Swiping into the Library" below); a second press mid-slide turns it around at its current speed.
The gift button at x 73 (`LibraryRailTile.giftFrame`) opens Settings' Share Cra with a Friend sheet on the window
(`MainWindowController.showShareCra`, scenario library-gift).

## A tab open in two windows (Arc 1.170, 27 Oct 2026, Swift metadata)

Expand Down
Loading