diff --git a/apple/Resources/macOS/Assets.xcassets/SidebarTint.colorset/Contents.json b/apple/Resources/macOS/Assets.xcassets/SidebarTint.colorset/Contents.json new file mode 100644 index 00000000..1be1f5df --- /dev/null +++ b/apple/Resources/macOS/Assets.xcassets/SidebarTint.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors": [ + { + "color": { + "color-space": "srgb", + "components": { + "alpha": "0.140", + "blue": "0.403922", + "green": "0.227451", + "red": "0.168627" + } + }, + "idiom": "universal" + }, + { + "appearances": [ + { + "appearance": "luminosity", + "value": "dark" + } + ], + "color": { + "color-space": "srgb", + "components": { + "alpha": "0.550", + "blue": "0.403922", + "green": "0.227451", + "red": "0.168627" + } + }, + "idiom": "universal" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/apple/Sources/Ganymede/ContentView.swift b/apple/Sources/Ganymede/ContentView.swift index e7216e25..bb86baa4 100644 --- a/apple/Sources/Ganymede/ContentView.swift +++ b/apple/Sources/Ganymede/ContentView.swift @@ -641,6 +641,11 @@ struct ContentView: View { ) { path in openWindow(value: EditorRequest(path: path, place: place)) } + // The navy glass (#873): a pale navy, or the navy itself in + // the dark, over the system's sidebar material and through the + // whole column. The lists hide their own background so this + // shows behind their rows. + .background(Color("SidebarTint").ignoresSafeArea()) // A restarted server has a new address and token. .id(place.isMachine ? model.serverURL : nil) } else { diff --git a/apple/Sources/Ganymede/NativeChrome.swift b/apple/Sources/Ganymede/NativeChrome.swift index 1cae7e82..923e2405 100644 --- a/apple/Sources/Ganymede/NativeChrome.swift +++ b/apple/Sources/Ganymede/NativeChrome.swift @@ -52,6 +52,7 @@ struct FolderSidebar: View { } } .listStyle(.sidebar) + .scrollContentBackground(.hidden) .modifier(SidebarKeys( selection: selection, isExpanded: { actions.isExpanded($0.url).wrappedValue }, @@ -348,9 +349,13 @@ private struct FolderContents: View { .accessibilityHint(canOpen ? "" : "Can't open here") .accessibilityAction { if canOpen { actions.open(entry) } } .padding(.vertical, 1) + // The open notebook's row, in a quiet grey (#873), so it + // doesn't read as a second selection beside the + // system's own, which keeps the accent while the list + // has focus. .listRowBackground( entry.serverPath == actions.openPath - ? Color.accentColor.opacity(0.18) : Color.clear + ? Color.primary.opacity(0.08) : Color.clear ) .contextMenu { menu(for: entry) } .tag(entry) @@ -458,6 +463,7 @@ struct RunningList: View { } } .listStyle(.sidebar) + .scrollContentBackground(.hidden) // The page asks the server for each kernel's memory only while // the list shows (#241). .onAppear { page.watchMemory(true) } @@ -507,24 +513,34 @@ private struct KernelRow: View { } } -/// The foot of the navigator sidebar (#246): where kernels run, and how -/// many kernels and terminals there are. A menu: open a terminal on a -/// remote, manage remotes. Where kernels run (#473) is an advanced choice -/// in the kernel menu now (#701); connected machines are places instead. -struct ServerLine: View { - var page: PageModel +/// The foot of the navigator sidebar (#873): the window's folder, named, and +/// where it is, over a menu: show it in the Finder, open a terminal on a +/// remote, manage remotes. Where kernels run (#473) is an advanced choice in +/// the kernel menu and the kernel button's popover now (#701, #867), and how +/// many run is in the Running tab and that popover: the foot is the project. +struct ProjectLine: View { + /// The window's folder: this Mac's own, or a machine's as its server + /// reports it (#740). + let folder: URL + /// This Mac's home folder, for the "~" in the line under the name; nil + /// for a machine's window, whose home this isn't. + var home: URL? + /// "This Mac", or the machine's name (#740). + let placeName: String + /// Whether the folder is on this Mac: only then can the menu show it in + /// the Finder, which lists this Mac's disk. + var showsInFinder = true /// The window's bottom panel, for terminals on remotes. var panel: PanelController? - /// A connected machine's name, for its window (#740): the kernels run - /// there, not where this device's setting says. - var machineName: String? var model = AppModel.shared - var terminals = OpenTerminals.shared var body: some View { - let locations = model.kernelLocations - let location = machineName ?? locations.title + let lines = ProjectLineText.lines(folder: folder, home: home, placeName: placeName) Menu { + if showsInFinder { + Button("Show in Finder") { NSWorkspace.shared.activateFileViewerSelecting([folder]) } + Divider() + } let remotes = model.remotes.filter { $0.hasServer || $0.ssh != nil } if let panel, !remotes.isEmpty { Section("New Terminal On") { @@ -537,32 +553,34 @@ struct ServerLine: View { } } } + Divider() } - Divider() - Button(locations.hasRemotes ? "Manage Remotes…" : "Add a Remote…") { + Button(model.kernelLocations.hasRemotes ? "Manage Remotes…" : "Add a Remote…") { SettingsOpener.show(.remotes) } } label: { HStack(spacing: 6) { - Circle() - .fill(page.state.backend == nil ? Color.secondary : Color("Ready")) - .frame(width: 7, height: 7) - .accessibilityHidden(true) - Image(systemName: machineName == nil && locations.selected == nil ? "laptopcomputer" : "server.rack") + Image(systemName: "folder") .foregroundStyle(.secondary) .accessibilityHidden(true) - Text(location) - .lineLimit(1) + VStack(alignment: .leading, spacing: 1) { + Text(lines.title) + .font(.callout) + .lineLimit(1) + Text(lines.detail) + .font(.caption) + // Not `.secondary`, which measured 3.6:1 on the + // light tint (#873): this keeps it past 4.5:1. + .foregroundStyle(Color.primary.opacity(0.72)) + .lineLimit(1) + .truncationMode(.middle) + } + Spacer(minLength: 4) Image(systemName: "chevron.up.chevron.down") .font(.system(size: 8, weight: .semibold)) .foregroundStyle(.secondary) .accessibilityHidden(true) - Spacer(minLength: 4) - Text(OpenTerminals.summary(kernels: page.state.sessions.count, terminals: terminals.entries.count)) - .foregroundStyle(.secondary) - .lineLimit(1) } - .font(.caption) .padding(.horizontal, 10) .padding(.vertical, 6) .contentShape(Rectangle()) @@ -570,14 +588,10 @@ struct ServerLine: View { .menuStyle(.button) .buttonStyle(.plain) .menuIndicator(.hidden) - .help(helpText(locations)) - .accessibilityLabel("Kernels run on \(location)") - } - - private func helpText(_ locations: KernelLocations) -> String { - var text = "Kernels run on \(machineName ?? locations.title)." - if page.state.backend == nil { text += " Not connected." } - return text + (machineName == nil ? " Click to open a terminal on a remote." : "") + // The whole path, for the line under the name, which is cut short. + .help(folder.path) + .accessibilityLabel(lines.title) + .accessibilityValue(lines.detail) } } diff --git a/apple/Sources/Ganymede/NavigatorSidebar.swift b/apple/Sources/Ganymede/NavigatorSidebar.swift index 75f49a37..d67665af 100644 --- a/apple/Sources/Ganymede/NavigatorSidebar.swift +++ b/apple/Sources/Ganymede/NavigatorSidebar.swift @@ -40,38 +40,24 @@ struct NavigatorSidebar: View { .padding(.horizontal, 10) .padding(.top, 8) } - HStack(spacing: 2) { - ForEach(tabs) { item in - Button { - tab = item - } label: { - Image(systemName: item.symbol) - .symbolVariant(shownTab == item ? .fill : .none) - .frame(width: 28, height: 22) - .contentShape(Rectangle()) - } - .buttonStyle(.plain) - .foregroundStyle(shownTab == item ? Color.accentColor : Color.secondary) - .help("\(item.title) (⌘\(String(item.shortcut.character)))") - .accessibilityLabel(item.title) - .accessibilityAddTraits(shownTab == item ? .isSelected : []) - .keyboardShortcut(item.shortcut, modifiers: .command) - // How many kernels and terminals run, on the Running tab. - .overlay(alignment: .topTrailing) { - if item == .running, running > 0 { - Text("\(running)") - .font(.system(size: 9, weight: .semibold)) - .padding(.horizontal, 3) - .background(Capsule().fill(Color("AccentFill"))) - .foregroundStyle(Color("OnAccent")) - .offset(x: 2, y: -2) - .accessibilityHidden(true) - } - } - } + // The app's mark and name (#873): the window's own header, above + // its navigators, as a Mac app's sidebar has. The icon is the + // app's, so only the name is read. + HStack(spacing: 8) { + Image(nsImage: NSApp.applicationIconImage) + .resizable() + .interpolation(.high) + .frame(width: 24, height: 24) + .accessibilityHidden(true) + Text("Ganymede") + .font(.title3.weight(.bold)) + Spacer(minLength: 0) } - .padding(.vertical, 6) - .frame(maxWidth: .infinity) + .padding(.horizontal, 10) + .padding(.top, 10) + .accessibilityElement(children: .combine) + .accessibilityAddTraits(.isHeader) + capsule Divider() switch shownTab { case .files: @@ -91,10 +77,105 @@ struct NavigatorSidebar: View { RecentsNavigator(page: page) } Divider() - ServerLine(page: page, panel: panel, machineName: place.machineID.flatMap(model.machineName(_:))) + ProjectLine( + folder: folder, + // A machine's home isn't this Mac's: its paths stay as its + // server reports them (#873). + home: place.isThisDevice ? projectHome : nil, + placeName: placeName, + showsInFinder: place.isThisDevice, + panel: panel) } } + /// The tabs in one capsule (#873): the shown tab draws its symbol and its + /// name on a raised fill and takes the width the others leave; the rest + /// draw the symbol alone. No segment's width depends on the Running + /// badge — it is an overlay — so nothing moves as kernels come and go. + private var capsule: some View { + HStack(spacing: 2) { + ForEach(tabs) { item in + Button { + tab = item + } label: { + segment(item) + } + .buttonStyle(.plain) + .foregroundStyle(shownTab == item ? Color.primary : Color.secondary) + .help(item.help) + .accessibilityLabel(item.title) + // How many kernels and terminals run, said here: the badge + // itself is hidden from VoiceOver. + .accessibilityValue(item == .running ? NavigatorTab.runningValue(running) : "") + .accessibilityAddTraits(shownTab == item ? .isSelected : []) + .keyboardShortcut(item.shortcut, modifiers: .command) + .overlay(alignment: .topTrailing) { badge(item) } + } + } + // One tab group to VoiceOver (#873): each segment is a tab in it, + // with its name and whether it is shown. + .accessibilityElement(children: .contain) + .accessibilityAddTraits(.isTabBar) + .padding(3) + .background(Capsule().fill(Color.primary.opacity(0.05))) + .overlay(Capsule().strokeBorder(Color.primary.opacity(0.12), lineWidth: 0.5)) + .padding(.horizontal, 8) + .padding(.top, 8) + .padding(.bottom, 6) + } + + @ViewBuilder + private func segment(_ item: NavigatorTab) -> some View { + if shownTab == item { + // The name gives way to the symbol alone when the capsule is too + // narrow for both: at the sidebar's 180pt the other five tabs + // leave it about 28pt, and a truncated word reads worse than the + // symbol on its own. The tooltip keeps the name to hand. + ViewThatFits(in: .horizontal) { + HStack(spacing: 5) { + Image(systemName: item.symbol) + .symbolVariant(.fill) + Text(item.title) + .lineLimit(1) + .fixedSize() + } + Image(systemName: item.symbol) + .symbolVariant(.fill) + } + .font(.caption.weight(.semibold)) + .padding(.horizontal, 6) + .frame(maxWidth: .infinity, minHeight: 22) + .background(RoundedRectangle(cornerRadius: 5).fill(Color.primary.opacity(0.1))) + .contentShape(Rectangle()) + } else { + Image(systemName: item.symbol) + .frame(width: 24, height: 22) + .contentShape(Rectangle()) + } + } + + /// How many kernels and terminals run, on the Running tab. + @ViewBuilder + private func badge(_ item: NavigatorTab) -> some View { + if item == .running, running > 0 { + Text("\(running)") + .font(.system(size: 9, weight: .semibold)) + .padding(.horizontal, 3) + .background(Capsule().fill(Color("AccentFill"))) + .foregroundStyle(Color("OnAccent")) + .offset(x: 2, y: -2) + .accessibilityHidden(true) + } + } + + /// This Mac's home folder, which the foot abbreviates to "~". + private var projectHome: URL { FileManager.default.homeDirectoryForCurrentUser } + + /// "This Mac", or the name of the machine whose window this is (#740). + private var placeName: String { + place.machineID.flatMap(model.machineName(_:)) ?? Places.deviceName + } + /// The tabs: not Recents for a machine, whose notebooks aren't in them. private var tabs: [NavigatorTab] { NavigatorTab.tabs(for: place) @@ -160,6 +241,7 @@ private struct SearchNavigator: View { } } .listStyle(.sidebar) + .scrollContentBackground(.hidden) .overlay { status } } @@ -304,6 +386,7 @@ private struct JournalsNavigator: View { } } .listStyle(.sidebar) + .scrollContentBackground(.hidden) .overlay { status(journals) } // Starts when the tab shows, and is cancelled when it hides or the // server (its address and token) changes. @@ -375,6 +458,7 @@ struct OutlineNavigator: View { } } .listStyle(.sidebar) + .scrollContentBackground(.hidden) .overlay { if headings.isEmpty { Text(page.state.hasNotebook ? "No headings in this notebook" : "No notebook open") @@ -402,7 +486,7 @@ private struct RecentsNavigator: View { } label: { VStack(alignment: .leading, spacing: 2) { Label(url.deletingPathExtension().lastPathComponent, systemImage: "book.closed") - Text(url.deletingLastPathComponent().path.replacingOccurrences(of: NSHomeDirectory(), with: "~")) + Text(ProjectLineText.abbreviate(url.deletingLastPathComponent().path, home: NSHomeDirectory())) .font(.caption) .foregroundStyle(.secondary) .lineLimit(1) @@ -419,6 +503,7 @@ private struct RecentsNavigator: View { } } .listStyle(.sidebar) + .scrollContentBackground(.hidden) .overlay { if recents.urls.isEmpty { Text("Notebooks you open show here").foregroundStyle(.secondary) diff --git a/apple/Sources/Ganymede/NavigatorTab.swift b/apple/Sources/Ganymede/NavigatorTab.swift index a443fcdf..b474ce72 100644 --- a/apple/Sources/Ganymede/NavigatorTab.swift +++ b/apple/Sources/Ganymede/NavigatorTab.swift @@ -42,6 +42,16 @@ enum NavigatorTab: String, CaseIterable, Identifiable { } } + /// The tab's tooltip (#873): its name and the key that shows it, as + /// "Files (⌘1)". + var help: String { "\(title) (⌘\(String(shortcut.character)))" } + + /// What the Running tab's accessibility value says (#873): "2 running", + /// or nothing while nothing runs. + static func runningValue(_ count: Int) -> String { + count > 0 ? "\(count) running" : "" + } + /// The tabs a window of `place` shows, the same on the Mac and the iPad /// (#758): every tab, but not Recents for a machine, whose notebooks /// aren't in them (`Place.indexesLocally`). Journals is for every place. diff --git a/apple/Sources/Ganymede/ProjectLineText.swift b/apple/Sources/Ganymede/ProjectLineText.swift new file mode 100644 index 00000000..854bbb68 --- /dev/null +++ b/apple/Sources/Ganymede/ProjectLineText.swift @@ -0,0 +1,30 @@ +import Foundation + +/// The two lines the sidebar's foot shows (#873): the window's folder, named, +/// and the folder it is in over the place's name — "moons", then +/// "~/notes · This Mac". Apart from the view, so a test can read them +/// without a window. +enum ProjectLineText { + /// The folder's name, and its parent over the place's name. A folder + /// under `home` reads "~" there; a machine's window passes no home, so + /// its paths stay as its server reports them. A root (a machine's + /// window opens on its root) has no parent: it reads "/" over the place. + static func lines(folder: URL, home: URL?, placeName: String) -> (title: String, detail: String) { + // Not `deletingLastPathComponent()`, which makes a root's parent "/..". + let path = folder.path + guard path != "/", !path.isEmpty else { return ("/", placeName) } + let parent = (path as NSString).deletingLastPathComponent + let shown = home.map { abbreviate(parent, home: $0.path) } ?? parent + return ((path as NSString).lastPathComponent, "\(shown) · \(placeName)") + } + + /// `path` with the home folder's part as "~". + static func abbreviate(_ path: String, home: String) -> String { + // A home at the root would make every path home. + guard home != "/" else { return path } + if path == home { return "~" } + let base = home.hasSuffix("/") ? home : home + "/" + if path + "/" == base { return "~" } + return path.hasPrefix(base) ? "~/" + path.dropFirst(base.count) : path + } +} diff --git a/apple/Sources/Ganymede/Terminal/OpenTerminals.swift b/apple/Sources/Ganymede/Terminal/OpenTerminals.swift index 6f78214f..86b20f07 100644 --- a/apple/Sources/Ganymede/Terminal/OpenTerminals.swift +++ b/apple/Sources/Ganymede/Terminal/OpenTerminals.swift @@ -35,16 +35,4 @@ final class OpenTerminals { func remove(_ id: Entry.ID) { entries.removeAll { $0.id == id } } - - /// The sidebar's server line: "2 kernels, 1 terminal", or "Nothing - /// running". - static func summary(kernels: Int, terminals: Int) -> String { - func count(_ n: Int, _ noun: String) -> String { "\(n) \(noun)\(n == 1 ? "" : "s")" } - switch (kernels, terminals) { - case (0, 0): return "Nothing running" - case (_, 0): return count(kernels, "kernel") - case (0, _): return count(terminals, "terminal") - default: return count(kernels, "kernel") + ", " + count(terminals, "terminal") - } - } } diff --git a/apple/Tests/GanymedeTests/NavigatorTabTests.swift b/apple/Tests/GanymedeTests/NavigatorTabTests.swift index 84dd6730..3341ea1b 100644 --- a/apple/Tests/GanymedeTests/NavigatorTabTests.swift +++ b/apple/Tests/GanymedeTests/NavigatorTabTests.swift @@ -61,6 +61,19 @@ final class NavigatorTabTests: XCTestCase { XCTAssertTrue(NavigatorTab.sidebarColumnShown(.automatic, portrait: true, compact: true)) } + /// The capsule's tooltips and the Running tab's value (#873). + func testEachTabNamesItselfAndItsKey() { + XCTAssertEqual(NavigatorTab.files.help, "Files (⌘1)") + XCTAssertEqual(NavigatorTab.running.help, "Running (⌘3)") + XCTAssertEqual(NavigatorTab.journals.help, "Journals (⌘6)") + } + + func testTheRunningTabsValueSaysHowManyRun() { + XCTAssertEqual(NavigatorTab.runningValue(0), "") + XCTAssertEqual(NavigatorTab.runningValue(1), "1 running") + XCTAssertEqual(NavigatorTab.runningValue(2), "2 running") + } + func testTheSplitViewsShowAndHideAreReadBack() { XCTAssertEqual(SidebarColumns(.all), .shown) XCTAssertEqual(SidebarColumns(.doubleColumn), .shown) diff --git a/apple/Tests/GanymedeTests/OpenTerminalsTests.swift b/apple/Tests/GanymedeTests/OpenTerminalsTests.swift index 29bfeb48..9130ec88 100644 --- a/apple/Tests/GanymedeTests/OpenTerminalsTests.swift +++ b/apple/Tests/GanymedeTests/OpenTerminalsTests.swift @@ -17,11 +17,4 @@ final class OpenTerminalsTests: XCTestCase { terminals.remove(first) XCTAssertEqual(terminals.entries.map(\.id), [second]) } - - func testSummarisesWhatRuns() { - XCTAssertEqual(OpenTerminals.summary(kernels: 0, terminals: 0), "Nothing running") - XCTAssertEqual(OpenTerminals.summary(kernels: 1, terminals: 0), "1 kernel") - XCTAssertEqual(OpenTerminals.summary(kernels: 0, terminals: 2), "2 terminals") - XCTAssertEqual(OpenTerminals.summary(kernels: 2, terminals: 1), "2 kernels, 1 terminal") - } } diff --git a/apple/Tests/GanymedeTests/ProjectLineTests.swift b/apple/Tests/GanymedeTests/ProjectLineTests.swift new file mode 100644 index 00000000..378467c0 --- /dev/null +++ b/apple/Tests/GanymedeTests/ProjectLineTests.swift @@ -0,0 +1,59 @@ +import XCTest + +/// The sidebar's foot in words (#873): the folder's name, and where it is. +final class ProjectLineTests: XCTestCase { + private let home = URL(fileURLWithPath: "/Users/tlockney", isDirectory: true) + private let id = "3F2B8C1E-AAAA-4BBB-8CCC-0123456789AB" + + private func lines(_ path: String, place: String = "This Mac") -> (title: String, detail: String) { + ProjectLineText.lines(folder: URL(fileURLWithPath: path, isDirectory: true), home: home, placeName: place) + } + + func testAFolderUnderHomeReadsItsPathFromHome() { + XCTAssertEqual(lines("/Users/tlockney/notes/moons").title, "moons") + XCTAssertEqual(lines("/Users/tlockney/notes/moons").detail, "~/notes · This Mac") + } + + func testAFolderOutsideHomeReadsItsWholeParent() { + XCTAssertEqual(lines("/Volumes/Secondary/notes").title, "notes") + XCTAssertEqual(lines("/Volumes/Secondary/notes").detail, "/Volumes/Secondary · This Mac") + // A folder whose name only starts with the home folder's is not in it. + XCTAssertEqual(lines("/Users/tlockney2/notes").detail, "/Users/tlockney2 · This Mac") + } + + func testAFolderInHomeReadsTilde() { + XCTAssertEqual(lines("/Users/tlockney/notes").detail, "~ · This Mac") + } + + /// A root has no parent: "/" over the place, not "/..". + func testARootReadsSlashOverThePlace() throws { + XCTAssertEqual(lines("/").title, "/") + XCTAssertEqual(lines("/").detail, "This Mac") + let root = try XCTUnwrap(FolderEntry.machineURL(id, path: "")) + let machine = ProjectLineText.lines(folder: root, home: nil, placeName: "workmbp") + XCTAssertEqual(machine.title, "/") + XCTAssertEqual(machine.detail, "workmbp") + } + + func testAbbreviatingKeepsOtherPathsAndARootHome() { + XCTAssertEqual(ProjectLineText.abbreviate("/Users/x/notes", home: "/Users/x/"), "~/notes") + XCTAssertEqual(ProjectLineText.abbreviate("/Users/x", home: "/Users/x/"), "~") + // A home at the root would make every path home. + XCTAssertEqual(ProjectLineText.abbreviate("/notes", home: "/"), "/notes") + } + + /// The home folder is named, and the folder it is in, which isn't home. + func testTheHomeFolderIsNamedOverTheFolderItIsIn() { + XCTAssertEqual(lines("/Users/tlockney").title, "tlockney") + XCTAssertEqual(lines("/Users/tlockney").detail, "/Users · This Mac") + } + + /// A machine's window takes the path its server reports, and the + /// machine's name: this Mac's home is nothing to it. + func testAMachinesWindowNamesTheMachine() throws { + let folder = try XCTUnwrap(FolderEntry.machineURL(id, path: "notes/moons")) + let lines = ProjectLineText.lines(folder: folder, home: nil, placeName: "workmbp") + XCTAssertEqual(lines.title, "moons") + XCTAssertEqual(lines.detail, "/notes · workmbp") + } +} diff --git a/apple/project.yml b/apple/project.yml index fbb04a1e..cedf6056 100644 --- a/apple/project.yml +++ b/apple/project.yml @@ -621,6 +621,8 @@ targets: - path: Sources/Ganymede/SidebarKey.swift - path: Sources/Ganymede/FileSource.swift - path: Sources/Ganymede/NavigatorTab.swift + # The sidebar's foot in words (#873). + - path: Sources/Ganymede/ProjectLineText.swift - path: Sources/Ganymede/WorkspaceTabs.swift - path: Sources/Ganymede/FileSearch.swift - path: Sources/Ganymede/Terminal/SSHKey.swift @@ -704,6 +706,8 @@ targets: - path: Sources/Ganymede/SidebarKey.swift - path: Sources/Ganymede/FileSource.swift - path: Sources/Ganymede/NavigatorTab.swift + # The sidebar's foot in words (#873). + - path: Sources/Ganymede/ProjectLineText.swift - path: Sources/Ganymede/WorkspaceTabs.swift - path: Sources/Ganymede/FileSearch.swift - path: Sources/Ganymede/Terminal/SSHKey.swift diff --git a/docs/apps.md b/docs/apps.md index 0cfaa764..fbb6f29f 100644 --- a/docs/apps.md +++ b/docs/apps.md @@ -64,6 +64,17 @@ On first launch the app asks once whether to send crash reports ### Sidebar +> [!NOTE] +> **Unreleased.** Available only from a build of `main` (HEAD), not in +> the latest release, where the sidebar has a row of icons for its tabs +> and its foot shows where kernels run. + +At the sidebar's top are the app's mark and its name, and under them the +tabs in one capsule: the tab on show draws its symbol and its name, the +others the symbol alone, and Running counts what is running. The column +is a pale navy over the system's sidebar material, and the navy itself in +the dark. + The sidebar has six tabs (⌘1 to ⌘6). Each window keeps its sidebar shown or hidden, its tab and its expanded folders across launches. @@ -89,8 +100,7 @@ shown or hidden, its tab and its expanded folders across launches. reports it (a Ganymede server does), and the terminals open in any window. Click a terminal to bring it to the front, or right-click a kernel or terminal to shut it down (or choose Kernel > Shut Down Other - Kernels). The foot of the sidebar shows where kernels run and how many - kernels and terminals there are. + Kernels). - **Recents** lists the notebooks opened lately. - **Outline** lists the open notebook's headings; click one to go to its cell. @@ -102,6 +112,13 @@ shown or hidden, its tab and its expanded folders across launches. asked every 5 seconds while the tab shows; an older server's 404 (before ganymede#893) says it is too old to list journals. +The foot of the sidebar names the window's folder: its name, over the +folder it is in and the place, as "moons" over "~/notes · This Mac" (the +home folder shortened to "~"; a machine's paths as its server reports +them, with the machine's name). Its menu shows the folder in the Finder +(this Mac's windows only), opens a terminal on a remote and opens +Settings > Remotes. + ### Toolbar and menus - A notebook's window has its title in the toolbar, with the kernel's @@ -196,14 +213,20 @@ shown or hidden, its tab and its expanded folders across launches. menu the browser's status line opens. Nothing shows while no kernel runs or before it has replied. +> [!NOTE] +> **Unreleased.** Available only from a build of `main` (HEAD), not in +> the latest release, where the sidebar's foot names where kernels run +> and the kernel's button doesn't. + - Kernels can run on a remote server instead. Add the remote in Settings > Remotes (its editor can switch kernels to it), then pick where kernels run from the kernel's button in the toolbar or Kernel > - Advanced > Run Kernels On. The sidebar's foot names where they run now - ("This Mac" or the remote); its menu is where you open a terminal on - a remote. The choice is app-wide, and switching shuts down running - kernels, so the Mac asks first while any run. To work on another - machine's own notebooks, connect it instead + Advanced > Run Kernels On. The kernel's button says where they run now + ("This Mac" or the remote), and its popover has the setting; the + sidebar's foot names the window's folder, and its menu is where you + open a terminal on a remote. The choice is app-wide, and switching shuts + down running kernels, so the Mac asks first while any run. To work on + another machine's own notebooks, connect it instead ([Connected machines](#connected-machines)). - Kernels that run on a remote carry its name wherever they are listed: diff --git a/docs/notes/2026-11-26-mac-sidebar.md b/docs/notes/2026-11-26-mac-sidebar.md new file mode 100644 index 00000000..7565575a --- /dev/null +++ b/docs/notes/2026-11-26-mac-sidebar.md @@ -0,0 +1,74 @@ +## 2026-11-26, Mac sidebar look (#873) + +The Mac's sidebar was a row of six icon buttons over a list, with a foot +that said where kernels run and how many ran. Neither said what the +window was: the buttons were unlabelled, and the folder the Files +navigator lists was named only in the list's own section header. The +foot's words ("This Mac", "2 kernels, 1 terminal") are in the kernel +button and the Running tab already. Step 4 of the Mac redesign (#844); +the Find tab, which joins Search and Outline, is a separate change. + +- The column is navy glass: `SidebarTint`, a colorset in the macOS + assets, is #2B3A67 at 14% in the light and at 55% in the dark, laid + behind the whole column (`ContentView`'s `sidebar`) and so over the + system's sidebar material. 8% in the light was invisible in the + running app. Measured from the PR's screenshots (strongest text pixel + against the foot's background), the foot's folder name reads 11.0:1 in + the light and 9.8:1 in the dark. Its second line, in the system's + `.secondary`, read 3.6:1 in the light (5.1:1 in the dark), so it is + `Color.primary` at 72% instead, about 4.7:1 by the same arithmetic. + The lists' own secondary captions (Recents' folders) stay the system's; + the tint costs them little (about 3.8:1 to 3.6:1 in the light). The + color stays translucent, because an opaque fill would take away the + material's vibrancy. +- The lists in the column hide their own scroll background + (`.scrollContentBackground(.hidden)`), so the tint is behind their rows + and not only around them. `OutlineNavigator` is also the inspector's + outline, where the list now shows the inspector's background through it. +- Above the tabs is the app's mark, `NSApp.applicationIconImage` at 24pt, + and "Ganymede" in `.title3.weight(.bold)`. The image is hidden from + VoiceOver and reads with the name as a heading. +- The tabs share one capsule (a 3pt-padded container with a faint + `Color.primary` fill and a hairline border). The tab on show draws its + symbol with `.fill` and its name on a raised fill and takes the width + the other icons leave; the others draw the symbol alone. When the + capsule is too narrow for the name (at the sidebar's 180pt it gives the + shown tab about 28pt), the name gives way to the symbol alone + (`ViewThatFits`) rather than truncating. The Running badge is an + overlay, as it was, so no segment's width changes when it appears. +- The badge is hidden from VoiceOver, and the Running tab's + `accessibilityValue` says "2 running" instead + (`NavigatorTab.runningValue`, empty while nothing runs). The tooltip's + words are a property (`NavigatorTab.help`, "Files (⌘1)"), so both are + tested without a window. The capsule is one element with the tab bar + trait (`.isTabBar`, its segments contained), so VoiceOver reads the + segments as tabs. +- The selected row keeps the system's highlight. The mockup had a grey + one, but on the Mac a focused sidebar list draws its selection in the + app's accent whatever `.tint` or `.accentColor` the list or its rows + carry (tried in the running app); it turns grey by itself when the + window isn't key. Drawing our own would mean hiding the system's and + rechecking focus and keyboard visuals, so the system's stays. The + open notebook's row is `Color.primary` at 8% instead of the accent at + 18%, so it doesn't read as a second selection. +- The foot is the project: `ProjectLine` replaces `ServerLine`, with the + folder symbol, the folder's name in `.callout` and, in `.caption` + secondary, the folder it is in and the place: "~/notes · This Mac". + The home folder is shortened to "~" for this Mac's windows; a + machine's keep the path its server reports and take the machine's name. + The help tag is the whole path. The menu keeps "New Terminal On" and + the remotes item and adds Show in Finder for this Mac's windows; the + count of kernels and terminals and "Kernels run on" are gone, with + `OpenTerminals.summary` and its test. A root (a machine's window opens + on its root) reads "/" over the place alone: Foundation's + `deletingLastPathComponent()` makes a root's parent "/..", so the + parent comes from the path string. Recents' folder line uses the same + `abbreviate`, which, unlike the `replacingOccurrences` it replaces, leaves + "/Users/x2" alone for a home of "/Users/x". +- `ProjectLineText.lines` is the words alone, in its own file listed in + both test targets (`project.yml`), which compile the sources they need + rather than the app. + +Checked with `npm run check`, `xcodebuild test` for the `Ganymede` scheme +on macOS (721 tests), a Debug build, and `build-for-testing` for +`Ganymede-iOS`.