Repository navigation
Add settings sidebar shell #3244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
d2c9ca9
95d4ca1
f28dc75
30e443a
d440142
187987d
4349366
a918a4c
10a792d
63e86f0
d30f8c4
59d27a3
b84f6d7
aaac7df
d4bd7a9
ce772ae
963e40a
ec7ca8f
da0f416
440d5cc
1d697b3
0e607d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # THIS IS AUTOGENERATED. DO NOT EDIT MANUALLY | ||
| version = 1 | ||
| name = "SettingsShellLab" | ||
|
|
||
| [setup] | ||
| script = "" | ||
|
|
||
| [[actions]] | ||
| name = "Run" | ||
| icon = "run" | ||
| command = "./script/build_and_run.sh" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| .build/ | ||
| dist/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // swift-tools-version: 5.9 | ||
|
|
||
| import PackageDescription | ||
|
|
||
| let package = Package( | ||
| name: "SettingsShellLab", | ||
| platforms: [ | ||
| .macOS(.v14), | ||
| ], | ||
| products: [ | ||
| .executable(name: "SettingsShellLab", targets: ["SettingsShellLab"]), | ||
| ], | ||
| targets: [ | ||
| .executableTarget( | ||
| name: "SettingsShellLab", | ||
| path: "Sources/SettingsShellLab" | ||
| ), | ||
| ] | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import AppKit | ||
| import SwiftUI | ||
|
|
||
| @main | ||
| struct SettingsShellLabApp: App { | ||
| @NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate | ||
|
|
||
| var body: some Scene { | ||
| WindowGroup(String(localized: "app.window.title", defaultValue: "Settings Shell Lab")) { | ||
| SettingsShellView() | ||
| } | ||
| .defaultSize(width: 900, height: 620) | ||
| .commands { | ||
| SidebarCommands() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| final class AppDelegate: NSObject, NSApplicationDelegate { | ||
| func applicationDidFinishLaunching(_ notification: Notification) { | ||
| NSApp.setActivationPolicy(.regular) | ||
| NSApp.activate(ignoringOtherApps: true) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import SwiftUI | ||
|
|
||
| enum SettingsSection: String, CaseIterable, Identifiable { | ||
| case general | ||
| case terminal | ||
| case sidebar | ||
| case browser | ||
| case keyboard | ||
| case automation | ||
| case advanced | ||
|
|
||
| var id: Self { self } | ||
|
|
||
| var title: String { | ||
| switch self { | ||
| case .general: | ||
| return String(localized: "section.general.title", defaultValue: "General") | ||
| case .terminal: | ||
| return String(localized: "section.terminal.title", defaultValue: "Terminal") | ||
| case .sidebar: | ||
| return String(localized: "section.sidebar.title", defaultValue: "Sidebar") | ||
| case .browser: | ||
| return String(localized: "section.browser.title", defaultValue: "Browser") | ||
| case .keyboard: | ||
| return String(localized: "section.keyboard.title", defaultValue: "Keyboard") | ||
| case .automation: | ||
| return String(localized: "section.automation.title", defaultValue: "Automation") | ||
| case .advanced: | ||
| return String(localized: "section.advanced.title", defaultValue: "Advanced") | ||
| } | ||
| } | ||
|
|
||
| var symbolName: String { | ||
| switch self { | ||
| case .general: | ||
| return "gearshape" | ||
| case .terminal: | ||
| return "terminal" | ||
| case .sidebar: | ||
| return "sidebar.left" | ||
| case .browser: | ||
| return "globe" | ||
| case .keyboard: | ||
| return "keyboard" | ||
| case .automation: | ||
| return "bolt.horizontal" | ||
| case .advanced: | ||
| return "wrench.and.screwdriver" | ||
| } | ||
| } | ||
|
|
||
| var detail: String { | ||
| switch self { | ||
| case .general: | ||
| return String(localized: "section.general.detail", defaultValue: "Language, appearance, updates") | ||
| case .terminal: | ||
| return String(localized: "section.terminal.detail", defaultValue: "Font, scrollback, bell") | ||
| case .sidebar: | ||
| return String(localized: "section.sidebar.detail", defaultValue: "Layout, badges, metadata") | ||
| case .browser: | ||
| return String(localized: "section.browser.detail", defaultValue: "Search, links, history") | ||
| case .keyboard: | ||
| return String(localized: "section.keyboard.detail", defaultValue: "Shortcuts and chords") | ||
| case .automation: | ||
| return String(localized: "section.automation.detail", defaultValue: "Socket, hooks, ports") | ||
| case .advanced: | ||
| return String(localized: "section.advanced.detail", defaultValue: "Diagnostics and reset") | ||
| } | ||
| } | ||
|
|
||
| var searchText: String { | ||
| "\(title) \(detail)" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import SwiftUI | ||
|
|
||
| struct SettingsDetailView: View { | ||
| let section: SettingsSection | ||
|
|
||
| @State private var isEnabled = true | ||
| @State private var selectedMode = Mode.system | ||
| @State private var numericValue = 12.0 | ||
|
|
||
| var body: some View { | ||
| Form { | ||
| Section { | ||
| LabeledContent( | ||
| String(localized: "detail.section", defaultValue: "Section"), | ||
| value: section.title | ||
| ) | ||
|
|
||
| Toggle( | ||
| String(localized: "detail.toggle", defaultValue: "Enable"), | ||
| isOn: $isEnabled | ||
| ) | ||
|
|
||
| Picker(String(localized: "detail.mode", defaultValue: "Mode"), selection: $selectedMode) { | ||
| ForEach(Mode.allCases) { mode in | ||
| Text(mode.title).tag(mode) | ||
| } | ||
| } | ||
| .pickerStyle(.segmented) | ||
|
|
||
| Slider( | ||
| value: $numericValue, | ||
| in: 0...24 | ||
| ) { | ||
| Text(String(localized: "detail.slider", defaultValue: "Amount")) | ||
| } | ||
| } header: { | ||
| Text(section.title) | ||
| } | ||
|
|
||
| Section { | ||
| Button(String(localized: "detail.primaryAction", defaultValue: "Open Related File")) { | ||
| } | ||
|
|
||
| Button(String(localized: "detail.secondaryAction", defaultValue: "Restore Defaults")) { | ||
| } | ||
| } | ||
| } | ||
| .formStyle(.grouped) | ||
| .padding() | ||
| } | ||
| } | ||
|
|
||
| private enum Mode: String, CaseIterable, Identifiable { | ||
| case system | ||
| case compact | ||
| case expanded | ||
|
|
||
| var id: Self { self } | ||
|
|
||
| var title: String { | ||
| switch self { | ||
| case .system: | ||
| return String(localized: "mode.system", defaultValue: "System") | ||
| case .compact: | ||
| return String(localized: "mode.compact", defaultValue: "Compact") | ||
| case .expanded: | ||
| return String(localized: "mode.expanded", defaultValue: "Expanded") | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import SwiftUI | ||
|
|
||
| struct SettingsShellView: View { | ||
| @SceneStorage("selectedSettingsSection") private var selectedSectionRaw = SettingsSection.general.rawValue | ||
| @State private var searchText = "" | ||
|
|
||
| private var selectedSection: SettingsSection { | ||
| SettingsSection(rawValue: selectedSectionRaw) ?? .general | ||
| } | ||
|
|
||
| private var filteredSections: [SettingsSection] { | ||
| let query = searchText.trimmingCharacters(in: .whitespacesAndNewlines) | ||
| guard !query.isEmpty else { return SettingsSection.allCases } | ||
| return SettingsSection.allCases.filter { section in | ||
| section.searchText.localizedStandardContains(query) | ||
| } | ||
| } | ||
|
|
||
| var body: some View { | ||
| NavigationSplitView { | ||
| List(selection: $selectedSectionRaw) { | ||
| ForEach(filteredSections) { section in | ||
| Label(section.title, systemImage: section.symbolName) | ||
| .tag(section.rawValue) | ||
| } | ||
| } | ||
| .listStyle(.sidebar) | ||
| .navigationTitle(String(localized: "settings.sidebar.title", defaultValue: "Settings")) | ||
| .searchable( | ||
| text: $searchText, | ||
| placement: .sidebar, | ||
| prompt: Text(String(localized: "settings.search.prompt", defaultValue: "Search Settings")) | ||
| ) | ||
| } detail: { | ||
| SettingsDetailView(section: selectedSection) | ||
| .navigationTitle(selectedSection.title) | ||
| .toolbar { | ||
| ToolbarItem { | ||
| Button { | ||
| } label: { | ||
| Label( | ||
| String(localized: "toolbar.reset", defaultValue: "Reset"), | ||
| systemImage: "arrow.counterclockwise" | ||
| ) | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
| } | ||
| } | ||
| .navigationSplitViewStyle(.balanced) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| MODE="${1:-run}" | ||
| APP_NAME="SettingsShellLab" | ||
| BUNDLE_ID="com.cmux.prototype.SettingsShellLab" | ||
| MIN_SYSTEM_VERSION="14.0" | ||
|
|
||
| ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | ||
| DIST_DIR="$ROOT_DIR/dist" | ||
| APP_BUNDLE="$DIST_DIR/$APP_NAME.app" | ||
| APP_CONTENTS="$APP_BUNDLE/Contents" | ||
| APP_MACOS="$APP_CONTENTS/MacOS" | ||
| APP_BINARY="$APP_MACOS/$APP_NAME" | ||
| INFO_PLIST="$APP_CONTENTS/Info.plist" | ||
|
|
||
| cd "$ROOT_DIR" | ||
|
|
||
| pkill -x "$APP_NAME" >/dev/null 2>&1 || true | ||
|
|
||
| swift build | ||
| BUILD_BINARY="$(swift build --show-bin-path)/$APP_NAME" | ||
|
|
||
| rm -rf "$APP_BUNDLE" | ||
| mkdir -p "$APP_MACOS" | ||
| cp "$BUILD_BINARY" "$APP_BINARY" | ||
| chmod +x "$APP_BINARY" | ||
|
|
||
| cat >"$INFO_PLIST" <<PLIST | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>CFBundleExecutable</key> | ||
| <string>$APP_NAME</string> | ||
| <key>CFBundleIdentifier</key> | ||
| <string>$BUNDLE_ID</string> | ||
| <key>CFBundleName</key> | ||
| <string>$APP_NAME</string> | ||
| <key>CFBundlePackageType</key> | ||
| <string>APPL</string> | ||
| <key>LSMinimumSystemVersion</key> | ||
| <string>$MIN_SYSTEM_VERSION</string> | ||
| <key>NSPrincipalClass</key> | ||
| <string>NSApplication</string> | ||
| </dict> | ||
| </plist> | ||
| PLIST | ||
|
|
||
| open_app() { | ||
| /usr/bin/open -n "$APP_BUNDLE" | ||
| } | ||
|
|
||
| case "$MODE" in | ||
| run) | ||
| open_app | ||
| ;; | ||
| --debug|debug) | ||
| lldb -- "$APP_BINARY" | ||
| ;; | ||
| --logs|logs) | ||
| open_app | ||
| /usr/bin/log stream --info --style compact --predicate "process == \"$APP_NAME\"" | ||
| ;; | ||
| --telemetry|telemetry) | ||
| open_app | ||
| /usr/bin/log stream --info --style compact --predicate "subsystem == \"$BUNDLE_ID\"" | ||
| ;; | ||
| --verify|verify) | ||
| open_app | ||
| sleep 1 | ||
| pgrep -x "$APP_NAME" >/dev/null | ||
| ;; | ||
| *) | ||
| echo "usage: $0 [run|--debug|--logs|--telemetry|--verify]" >&2 | ||
| exit 2 | ||
| ;; | ||
| esac |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,9 +69,7 @@ final class WindowDecorationsController { | |
| } | ||
|
|
||
| private func trafficLightOffset(for window: NSWindow) -> NSPoint { | ||
| guard window.identifier?.rawValue == "cmux.settings" else { return .zero } | ||
| // Nudge controls slightly right/down to align with the custom Settings title row. | ||
| return NSPoint(x: 7, y: -4) | ||
| return .zero | ||
| } | ||
|
Comment on lines
71
to
73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep the zero offset scoped to the settings window.
🔧 Proposed fix private func trafficLightOffset(for window: NSWindow) -> NSPoint {
- return .zero
+ if window.identifier?.rawValue == "cmux.settings" {
+ return .zero
+ }
+ return /* existing non-settings offset logic */
}🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verified as not applicable. On main, non-settings windows already returned zero offset; this PR intentionally removes the Settings-only traffic-light offset, so no non-settings offset behavior was lost. — Claude Code
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verified as not applicable. On main, non-settings windows already returned zero offset; this PR intentionally removes the Settings-only traffic-light offset, so no non-settings offset behavior was lost. — Claude Code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
(ᓀ‸ᓂ) ✏️ Learnings added
🧠 Learnings usedThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
✏️ Learnings added
🧠 Learnings used |
||
|
|
||
| private func shouldHideTrafficLights(for window: NSWindow) -> Bool { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.