Repository Public License
1import Foundation2import LunarDesign3import NavigatorCore4import WebRuntime56/// Stable identifiers of the shell's commands, for `registry.run(_:in:)`, `window.run(_:)`, toolbar items and7/// `-ORIXRun`.8public enum ShellCommandID {9 public static let newTab = "tab.new"10 public static let closeTab = "tab.close"11 public static let reopenClosedTab = "tab.reopenClosed"12 public static let duplicateTab = "tab.duplicate"13 public static let pinTab = "tab.pin"14 public static let muteTab = "tab.mute"15 public static let closeOtherTabs = "tab.closeOthers"16 public static let nextTab = "tab.next"17 public static let previousTab = "tab.previous"18 public static let moveTabLeft = "tab.moveLeft"19 public static let moveTabRight = "tab.moveRight"20 public static let moveTabToNewWindow = "tab.moveToNewWindow"21 public static let reloadTab = "tab.reload"22 public static let showTabSwitcher = "tabs.showSwitcher"23 /// `tab.select.1` … `tab.select.8`, and `tab.select.last`.24 public static func selectTab(_ number: Int) -> String { number >= 9 ? "tab.select.last" : "tab.select.\(number)" }25 public static let newWindow = "window.new"26 public static let closeWindow = "window.close"27 public static let focusOmnibox = "omnibox.focus"28 public static let back = "nav.back"29 public static let forward = "nav.forward"30 public static let reload = "page.reload"31 public static let reloadFromOrigin = "page.reloadFromOrigin"32 public static let stop = "page.stop"33 public static let find = "find.show"34 public static let findNext = "find.next"35 public static let findPrevious = "find.previous"36 public static let zoomIn = "view.zoomIn"37 public static let zoomOut = "view.zoomOut"38 public static let zoomReset = "view.zoomReset"39 public static let toggleSidebar = "view.toggleSidebar"40 public static func tabLayout(_ mode: TabLayoutMode) -> String { "view.layout.\(mode.rawValue)" }41 public static let toggleContentMode = "page.toggleContentMode"42 public static let copyURL = "page.copyURL"43 public static let share = "page.share"44 public static let print = "page.print"45 public static let savePDF = "page.savePDF"46 public static let addBookmark = "bookmark.add"47 public static let showBookmarks = "panel.bookmarks"48 public static let showHistory = "panel.history"49 public static let showDownloads = "panel.downloads"50 public static let showSettings = "panel.settings"51 public static let closePanel = "panel.close"52 public static let clearBrowsingData = "privacy.clearData"53 public static let showHelp = "help.show"54 public static let showWelcome = "help.welcome"55}5657/// The shell's actions, as registry commands. Menus, context menus and buttons run these; nothing else in the58/// shell implements an action a second time.59@MainActor60enum ShellCommands {61 typealias ID = ShellCommandID6263 static func register(in registry: FeatureRegistry) {64 registry.register(commands: tabs + windows + navigation + page + view + panels + help)65 }6667 private static func focusNewTab(_ context: CommandContext) {68 if let window = context.window {69 window.newTab()70 window.omnibox.focus()71 } else {72 context.store.openNewWindow()73 }74 }7576 // MARK: Tabs7778 private static var tabs: [NavigatorCommand] {79 var commands: [NavigatorCommand] = [80 NavigatorCommand(id: ID.newTab, title: T("New Tab"), category: .tabs, icon: .symbol("plus"),81 shortcut: CommandShortcut("t"), keywords: [L("open"), L("blank")],82 placements: [.menuBar(.file, group: 10, order: 10), .windowMenu(group: 10, order: 10)],83 perform: { focusNewTab($0) }),84 NavigatorCommand(id: ID.closeTab, title: T("Close Tab"), category: .tabs, icon: .symbol("xmark"),85 shortcut: CommandShortcut("w"),86 placements: [.menuBar(.file, group: 30, order: 10), .tabContextMenu(group: 40, order: 10)],87 isAvailable: { $0.tab != nil },88 perform: { context in if let tab = context.tab { context.window?.close(tab.id) } }),89 NavigatorCommand(id: ID.closeOtherTabs, title: T("Close Other Tabs"), category: .tabs, icon: .symbol("xmark.square"),90 placements: [.menuBar(.file, group: 30, order: 30), .tabContextMenu(group: 40, order: 20)],91 isAvailable: { context in92 guard let window = context.window, let tab = context.tab else { return false }93 return window.unpinnedTabs.contains { $0.id != tab.id }94 },95 perform: { context in if let tab = context.tab { context.window?.closeOtherTabs(keeping: tab.id) } }),96 NavigatorCommand(id: ID.reopenClosedTab, title: T("Reopen Closed Tab"), category: .tabs,97 icon: .symbol("arrow.uturn.backward"), shortcut: CommandShortcut("t", modifiers: [.command, .shift]),98 keywords: [L("undo"), L("restore")],99 placements: [.menuBar(.history, group: 20, order: 20)],100 isAvailable: { $0.window != nil && !$0.isEphemeralWindow && $0.store.closedTabCount > 0 },101 perform: { $0.window?.reopenClosedTab() }),102 NavigatorCommand(id: ID.reloadTab, title: T("Reload"), category: .tabs, icon: .symbol("arrow.clockwise"),103 placements: [.tabContextMenu(group: 10, order: 10)],104 isAvailable: { $0.hasPage }, perform: { $0.engine?.reload() }),105 NavigatorCommand(id: ID.duplicateTab, title: T("Duplicate Tab"), category: .tabs, icon: .symbol("plus.square.on.square"),106 placements: [.menuBar(.file, group: 40, order: 10), .tabContextMenu(group: 10, order: 20)],107 isAvailable: { $0.tab != nil },108 perform: { context in if let tab = context.tab { context.window?.duplicate(tab.id) } }),109 NavigatorCommand(id: ID.pinTab, title: T("Pin Tab"), category: .tabs, icon: .symbol("pin"),110 placements: [.menuBar(.file, group: 40, order: 20), .tabContextMenu(group: 10, order: 30)],111 dynamicTitle: { $0.tab?.isPinned == true ? T("Unpin Tab") : nil },112 isAvailable: { $0.tab != nil },113 perform: { context in114 if let tab = context.tab { context.window?.setPinned(!tab.isPinned, for: tab.id) }115 }),116 NavigatorCommand(id: ID.muteTab, title: T("Mute Tab"), category: .tabs, icon: .symbol("speaker.slash"),117 keywords: [L("sound"), L("audio")],118 placements: [.menuBar(.file, group: 40, order: 30), .tabContextMenu(group: 10, order: 40)],119 dynamicTitle: { $0.engine?.isMuted == true ? T("Unmute Tab") : nil },120 isAvailable: { $0.hasPage },121 perform: { context in if let tab = context.tab { context.window?.toggleMute(tab.id) } }),122 NavigatorCommand(id: ID.moveTabLeft, title: T("Move Tab Left"), category: .tabs, icon: .symbol("arrow.left.to.line"),123 placements: [.menuBar(.window, group: 20, order: 10)],124 isAvailable: { context in125 context.tab.map { context.window?.canMoveTab($0.id, by: -1) ?? false } ?? false126 },127 perform: { context in if let tab = context.tab { context.window?.moveTab(tab.id, by: -1) } }),128 NavigatorCommand(id: ID.moveTabRight, title: T("Move Tab Right"), category: .tabs, icon: .symbol("arrow.right.to.line"),129 placements: [.menuBar(.window, group: 20, order: 20)],130 isAvailable: { context in131 context.tab.map { context.window?.canMoveTab($0.id, by: 1) ?? false } ?? false132 },133 perform: { context in if let tab = context.tab { context.window?.moveTab(tab.id, by: 1) } }),134 NavigatorCommand(id: ID.moveTabToNewWindow, title: T("Move Tab to New Window"), category: .tabs,135 icon: .symbol("macwindow.badge.plus"),136 placements: [.menuBar(.window, group: 20, order: 30), .tabContextMenu(group: 20, order: 10)],137 hidesWhenUnavailable: true,138 isAvailable: { context in139 context.tab != nil && (context.window?.tabs.count ?? 0) > 1 && context.store.supportsMultipleWindows140 },141 perform: { context in if let tab = context.tab { context.store.moveTabToNewWindow(tab.id) } }),142 NavigatorCommand(id: ID.nextTab, title: T("Show Next Tab"), category: .tabs, icon: .symbol("chevron.right.square"),143 shortcut: CommandShortcut(.tab, modifiers: .control),144 placements: [.menuBar(.window, group: 10, order: 10)],145 isAvailable: { ($0.window?.tabs.count ?? 0) > 1 },146 perform: { $0.window?.selectAdjacentTab(offset: 1) }),147 NavigatorCommand(id: ID.previousTab, title: T("Show Previous Tab"), category: .tabs, icon: .symbol("chevron.left.square"),148 shortcut: CommandShortcut(.tab, modifiers: [.control, .shift]),149 placements: [.menuBar(.window, group: 10, order: 20)],150 isAvailable: { ($0.window?.tabs.count ?? 0) > 1 },151 perform: { $0.window?.selectAdjacentTab(offset: -1) }),152 NavigatorCommand(id: ID.showTabSwitcher, title: T("Show All Tabs"), category: .tabs, icon: .symbol("square.on.square"),153 keywords: [L("overview"), L("switcher")],154 isAvailable: { $0.window != nil && $0.isCompactWidth },155 perform: { context in156 guard let window = context.window else { return }157 if let tab = window.selectedTab { await context.store.refreshThumbnail(of: tab) }158 window.isTabSwitcherVisible = true159 }),160 ]161 // ⌘1…⌘8 select by position; ⌘9 always goes to the last tab, as in other browsers.162 for number in 1...9 {163 let title = number == 9 ? T("Show Last Tab") : tabTitles[number - 1]164 commands.append(NavigatorCommand(165 id: ID.selectTab(number), title: title, category: .tabs, icon: .symbol(number == 9 ? "arrow.right.to.line" : "\(number).square"),166 shortcut: CommandShortcut(Character("\(number)")),167 placements: [.menuBar(.window, group: 30, order: number * 10)],168 isAvailable: { context in169 let count = context.window?.tabs.count ?? 0170 return number == 9 ? count > 0 : count >= number171 },172 perform: { $0.window?.selectTab(atIndex: number - 1) }))173 }174 return commands175 }176177 /// One literal key per position, so that the catalog audit sees every title.178 private static let tabTitles = [179 T("Show Tab 1"), T("Show Tab 2"), T("Show Tab 3"), T("Show Tab 4"),180 T("Show Tab 5"), T("Show Tab 6"), T("Show Tab 7"), T("Show Tab 8"),181 ]182183 // MARK: Windows184185 private static var windows: [NavigatorCommand] {186 var commands = [187 NavigatorCommand(id: ID.newWindow, title: T("New Window"), category: .windows, icon: .symbol("macwindow.badge.plus"),188 shortcut: CommandShortcut("n"),189 placements: [.menuBar(.file, group: 10, order: 20), .windowMenu(group: 10, order: 20)],190 hidesWhenUnavailable: true,191 isAvailable: { $0.store.supportsMultipleWindows && !$0.isCompactWidth },192 perform: { $0.store.openNewWindow() }),193 NavigatorCommand(id: ID.focusOmnibox, title: T("Open Location…"), category: .navigation, icon: .symbol("magnifyingglass"),194 shortcut: CommandShortcut("l"), keywords: [L("address"), L("search"), L("url")],195 placements: [.menuBar(.file, group: 20, order: 10)],196 isAvailable: { $0.window != nil },197 perform: { context in198 context.window?.dismissOverlay()199 context.window?.omnibox.focus()200 }),201 ]202 #if os(macOS)203 commands.append(NavigatorCommand(id: ID.closeWindow, title: T("Close Window"), category: .windows, icon: .symbol("xmark.rectangle"),204 shortcut: CommandShortcut("w", modifiers: [.command, .shift]),205 placements: [.menuBar(.file, group: 30, order: 20)],206 isAvailable: { $0.window != nil },207 perform: { $0.window?.platformWindow?.performClose(nil) }))208 #endif209 return commands210 }211212 // MARK: Navigation213214 private static var navigation: [NavigatorCommand] {215 [216 NavigatorCommand(id: ID.back, title: T("Back"), category: .navigation, icon: .symbol("chevron.left"),217 shortcut: CommandShortcut("["), placements: [.menuBar(.history, group: 10, order: 10)],218 isAvailable: { $0.engine?.canGoBack ?? false }, perform: { $0.engine?.goBack() }),219 NavigatorCommand(id: ID.forward, title: T("Forward"), category: .navigation, icon: .symbol("chevron.right"),220 shortcut: CommandShortcut("]"), placements: [.menuBar(.history, group: 10, order: 20)],221 isAvailable: { $0.engine?.canGoForward ?? false }, perform: { $0.engine?.goForward() }),222 NavigatorCommand(id: ID.reload, title: T("Reload Page"), category: .navigation, icon: .symbol("arrow.clockwise"),223 shortcut: CommandShortcut("r"), keywords: [L("refresh")],224 placements: [.menuBar(.view, group: 10, order: 10)],225 isAvailable: { $0.hasPage }, perform: { $0.engine?.reload() }),226 NavigatorCommand(id: ID.reloadFromOrigin, title: T("Reload from Origin"), category: .navigation,227 icon: .symbol("arrow.clockwise.circle"), shortcut: CommandShortcut("r", modifiers: [.command, .shift]),228 keywords: [L("refresh"), L("cache")],229 placements: [.menuBar(.view, group: 10, order: 20)],230 isAvailable: { $0.hasPage }, perform: { $0.engine?.reloadFromOrigin() }),231 NavigatorCommand(id: ID.stop, title: T("Stop"), category: .navigation, icon: .symbol("xmark"),232 shortcut: CommandShortcut("."), placements: [.menuBar(.view, group: 10, order: 30)],233 isAvailable: { $0.engine?.isLoading ?? false }, perform: { $0.engine?.stop() }),234 ]235 }236237 // MARK: Page238239 private static var page: [NavigatorCommand] {240 [241 NavigatorCommand(id: ID.find, title: T("Find in Page…"), category: .page, icon: .symbol("magnifyingglass"),242 shortcut: CommandShortcut("f"), keywords: [L("search")],243 placements: [.menuBar(.edit, group: 10, order: 10), .windowMenu(group: 30, order: 10)],244 isAvailable: { $0.window?.hasPage ?? false }, perform: { $0.window?.showFind() }),245 NavigatorCommand(id: ID.findNext, title: T("Find Next"), category: .page, icon: .symbol("chevron.down"),246 shortcut: CommandShortcut("g"), placements: [.menuBar(.edit, group: 10, order: 20)],247 isAvailable: { ($0.window?.isFindVisible ?? false) && !($0.window?.findQuery.isEmpty ?? true) },248 perform: { $0.window?.find() }),249 NavigatorCommand(id: ID.findPrevious, title: T("Find Previous"), category: .page, icon: .symbol("chevron.up"),250 shortcut: CommandShortcut("g", modifiers: [.command, .shift]),251 placements: [.menuBar(.edit, group: 10, order: 30)],252 isAvailable: { ($0.window?.isFindVisible ?? false) && !($0.window?.findQuery.isEmpty ?? true) },253 perform: { $0.window?.find(backwards: true) }),254 NavigatorCommand(id: ID.addBookmark, title: T("Bookmark This Page…"), category: .bookmarks, icon: .symbol("bookmark.fill"),255 shortcut: CommandShortcut("d"), keywords: [L("favourite"), L("save")],256 placements: [.menuBar(.bookmarks, group: 10, order: 10), .windowMenu(group: 20, order: 40)],257 isAvailable: { $0.window?.hasPage ?? false }, perform: { $0.window?.bookmarkCurrentPage() }),258 NavigatorCommand(id: ID.copyURL, title: T("Copy Page Address"), category: .page, icon: .symbol("link"),259 shortcut: CommandShortcut("c", modifiers: [.command, .shift]), keywords: [L("link"), L("url")],260 placements: [.menuBar(.edit, group: 20, order: 10), .tabContextMenu(group: 30, order: 10)],261 isAvailable: { context in context.url.map { !InternalAddress.isInternal($0) } ?? false },262 perform: { context in263 guard let url = context.url else { return }264 PageActions.copy(url.absoluteString)265 context.window?.showToast(L("Address copied"), status: .success)266 }),267 NavigatorCommand(id: ID.share, title: T("Share…"), category: .page, icon: .symbol("square.and.arrow.up"),268 placements: [.menuBar(.file, group: 50, order: 10)],269 isAvailable: { context in context.window != nil && (context.url.map { !InternalAddress.isInternal($0) } ?? false) },270 perform: { context in271 if let window = context.window, let tab = context.tab { PageActions.share(tab, in: window) }272 }),273 NavigatorCommand(id: ID.savePDF, title: T("Save as PDF…"), category: .page, icon: .symbol("doc.richtext"),274 keywords: [L("export")], placements: [.menuBar(.file, group: 50, order: 20)],275 isAvailable: { $0.window != nil && $0.hasPage && $0.engine?.webView != nil },276 perform: { context in277 if let window = context.window, let tab = context.tab { await PageActions.savePDF(of: tab, in: window) }278 }),279 NavigatorCommand(id: ID.print, title: T("Print…"), category: .page, icon: .symbol("printer"),280 shortcut: CommandShortcut("p"), placements: [.menuBar(.file, group: 50, order: 30)],281 isAvailable: { $0.window != nil && $0.hasPage && $0.engine?.webView != nil },282 perform: { context in283 if let window = context.window, let tab = context.tab { await PageActions.print(tab, in: window) }284 }),285 NavigatorCommand(id: ID.toggleContentMode, title: contentModeTitle(wantsAlternate: true), category: .page,286 icon: .symbol(alternateContentMode == .mobile ? "iphone" : "desktopcomputer"),287 keywords: [L("user agent")],288 placements: [.menuBar(.view, group: 30, order: 10), .windowMenu(group: 30, order: 40)],289 hidesWhenUnavailable: true,290 dynamicTitle: { context in291 context.engine?.contentMode == alternateContentMode ? contentModeTitle(wantsAlternate: false) : nil292 },293 isAvailable: { $0.window != nil && $0.hasPage },294 perform: { context in295 guard let window = context.window, let engine = context.engine, context.tab?.id == window.selectedTabID else { return }296 window.setContentMode(engine.contentMode == alternateContentMode ? .automatic : alternateContentMode)297 }),298 ]299 }300301 /// The mode a page does not get by default on this platform: the mobile site on a Mac, the desktop site on302 /// iPhone and iPad.303 private static var alternateContentMode: UserAgentMode {304 #if os(macOS)305 .mobile306 #else307 .desktop308 #endif309 }310311 private static func contentModeTitle(wantsAlternate: Bool) -> LocalizedText {312 (alternateContentMode == .mobile) == wantsAlternate ? T("Request Mobile Site") : T("Request Desktop Site")313 }314315 // MARK: View316317 private static var view: [NavigatorCommand] {318 var commands = [319 NavigatorCommand(id: ID.zoomIn, title: T("Zoom In"), category: .view, icon: .symbol("plus.magnifyingglass"),320 shortcut: CommandShortcut("+"),321 placements: [.menuBar(.view, group: 20, order: 10), .windowMenu(group: 30, order: 20)],322 hidesWhenUnavailable: true,323 isAvailable: { $0.window?.hasPage ?? false }, perform: { $0.window?.zoomIn() }),324 NavigatorCommand(id: ID.zoomOut, title: T("Zoom Out"), category: .view, icon: .symbol("minus.magnifyingglass"),325 shortcut: CommandShortcut("-"),326 placements: [.menuBar(.view, group: 20, order: 20), .windowMenu(group: 30, order: 30)],327 hidesWhenUnavailable: true,328 isAvailable: { $0.window?.hasPage ?? false }, perform: { $0.window?.zoomOut() }),329 NavigatorCommand(id: ID.zoomReset, title: T("Actual Size"), category: .view, icon: .symbol("1.magnifyingglass"),330 shortcut: CommandShortcut("0"), placements: [.menuBar(.view, group: 20, order: 30)],331 isAvailable: { context in332 (context.window?.hasPage ?? false) && abs((context.window?.selectedTab?.engine.pageZoom ?? 1) - 1) >= 0.01333 },334 perform: { $0.window?.resetZoom() }),335 NavigatorCommand(id: ID.toggleSidebar, title: T("Hide Sidebar"), category: .view, icon: .symbol("sidebar.left"),336 shortcut: CommandShortcut("s"), placements: [.menuBar(.view, group: 40, order: 10)],337 dynamicTitle: { $0.window?.isSidebarCollapsed == true ? T("Show Sidebar") : nil },338 isAvailable: { $0.window?.tabLayout == .vertical && !$0.isCompactWidth },339 perform: { context in if let window = context.window { window.isSidebarCollapsed.toggle() } }),340 ]341 for (index, mode) in TabLayoutMode.allCases.enumerated() {342 commands.append(NavigatorCommand(343 id: ID.tabLayout(mode), title: mode.layoutCommandTitle, category: .view, icon: .symbol(mode.symbolName),344 keywords: [L("tabs"), L("layout")],345 placements: [.menuBar(.view, group: 50, order: index * 10), .windowMenu(group: 40, order: index * 10)],346 hidesWhenUnavailable: true,347 isAvailable: { $0.window != nil && !$0.isCompactWidth && $0.registry.supportedLayouts.contains(mode) },348 isChecked: { $0.window?.tabLayout == mode },349 perform: { context in350 context.window?.tabLayout = mode351 context.settings.defaultTabLayout = mode352 }))353 }354 return commands355 }356357 // MARK: Panels358359 private static func panelCommand(id: String, panel: SidePanelID, title: LocalizedText, icon: String,360 shortcut: CommandShortcut?, keywords: [String] = [], placements: [CommandPlacement],361 isAvailable: @escaping @MainActor (CommandContext) -> Bool = { _ in true }) -> NavigatorCommand {362 NavigatorCommand(id: id, title: title, category: panel == .bookmarks ? .bookmarks : panel == .history ? .history : .view,363 icon: .symbol(icon), shortcut: shortcut, keywords: keywords, placements: placements,364 hidesWhenUnavailable: true,365 isAvailable: { $0.window != nil && isAvailable($0) },366 isChecked: { $0.window?.panel == panel },367 perform: { context in368 // Menus and shortcuts toggle; the window menu and launch arguments open.369 if context.source == .menuBar { context.window?.togglePanel(panel) } else { context.window?.panel = panel }370 })371 }372373 private static var panels: [NavigatorCommand] {374 [375 panelCommand(id: ID.showHistory, panel: .history, title: T("Show History"), icon: "clock.arrow.circlepath",376 shortcut: CommandShortcut("y"),377 placements: [.menuBar(.history, group: 20, order: 10), .windowMenu(group: 20, order: 10)]),378 panelCommand(id: ID.showBookmarks, panel: .bookmarks, title: T("Show Bookmarks"), icon: "bookmark",379 shortcut: CommandShortcut("b", modifiers: [.command, .option]),380 placements: [.menuBar(.bookmarks, group: 10, order: 20), .windowMenu(group: 20, order: 20)]),381 panelCommand(id: ID.showDownloads, panel: .downloads, title: T("Show Downloads"), icon: "arrow.down.circle",382 shortcut: CommandShortcut("j", modifiers: [.command, .shift]),383 placements: [.menuBar(.view, group: 40, order: 20), .windowMenu(group: 20, order: 30)],384 isAvailable: { $0.store.downloads != nil }),385 panelCommand(id: ID.showSettings, panel: .settings, title: T("Settings…"), icon: "gearshape",386 shortcut: CommandShortcut(","), keywords: [L("preferences"), L("options")],387 placements: [.menuBar(.app, group: 10, order: 10), .windowMenu(group: 90, order: 10)]),388 NavigatorCommand(id: ID.closePanel, title: T("Close Side Panel"), category: .view, icon: .symbol("sidebar.right"),389 isAvailable: { $0.window?.panel != nil }, perform: { $0.window?.panel = nil }),390 NavigatorCommand(id: ID.clearBrowsingData, title: T("Clear Browsing Data…"), category: .privacy, icon: .symbol("trash"),391 keywords: [L("history"), L("cookies"), L("cache")],392 placements: [.menuBar(.history, group: 30, order: 10)],393 isAvailable: { $0.window != nil },394 perform: { context in395 context.window?.panel = .settings396 context.window?.settingsSectionRequest = ShellSettingsSectionID.privacy397 }),398 ]399 }400401 // MARK: Help402403 private static var help: [NavigatorCommand] {404 [405 panelCommand(id: ID.showHelp, panel: .help, title: T("ORIX Navigator Help"), icon: "questionmark.circle",406 shortcut: CommandShortcut("/", modifiers: [.command, .shift]),407 keywords: [L("shortcuts"), L("keyboard")],408 placements: [.menuBar(.help, group: 10, order: 10), .windowMenu(group: 90, order: 20)]),409 NavigatorCommand(id: ID.showWelcome, title: T("Show Welcome Screens"), category: .app, icon: .symbol("sparkles"),410 placements: [.menuBar(.help, group: 20, order: 10)],411 perform: { $0.environment.isOnboardingVisible = true }),412 ]413 }414}415416extension TabLayoutMode {417 var layoutCommandTitle: LocalizedText {418 switch self {419 case .vertical: T("Vertical Tabs")420 case .horizontal: T("Horizontal Tabs")421 case .compact: T("Compact Tabs")422 case .grid: T("Grid of Tabs")423 case .orbit: T("Orbit Tabs")424 }425 }426427 var symbolName: String {428 switch self {429 case .vertical: "sidebar.left"430 case .horizontal: "rectangle.topthird.inset.filled"431 case .compact: "rectangle.compress.vertical"432 case .grid: "square.grid.2x2"433 case .orbit: "circle.hexagongrid"434 }435 }436}437