Repository navigation
Allow configurable Dock max width #4385
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
1b2ae13
Add configurable Dock max width
austinywang b9357d0
Address Dock max width review feedback
austinywang 4c4f0e7
Add Dock max width settings UI
austinywang 15f37ab
Localize Dock max width settings
austinywang 1af444a
merge: resolve conflicts with main
austinywang 3320119
Localize Dock width settings in Khmer
austinywang 006d9b1
Fix Dock max width warning budget
austinywang 8592831
Merge origin/main into issue-4375-dock-max-width-config
austinywang 68895bf
Fix right sidebar width CGFloat conversion
austinywang 164ca31
Expose Dock width policy through app module
austinywang 69320e3
Preserve remembered Dock max width
austinywang 7e63912
Clamp Dock max width policy consistently
austinywang c6a3fc8
Share Dock max width default cap
austinywang d13636c
Merge remote-tracking branch 'origin/main' into issue-4375-dock-max-w…
austinywang 51ad5da
fix: make right sidebar width policy instantiable
austinywang de69fea
Merge remote-tracking branch 'origin/main' into issue-4375-dock-max-w…
austinywang c51e77d
fix: align settings json mappings with catalog keys
austinywang 042b0f5
fix: bound sidebar metadata block rendering
austinywang 854860f
fix: use catalog key for sidebar branch layout
austinywang 93ab5f6
fix: bound sidebar workspace row text
austinywang 4c35a93
Merge remote-tracking branch 'origin/main' into issue-4375-dock-max-w…
austinywang 6c3bcaf
Merge remote-tracking branch 'origin/main' into issue-4375-dock-max-w…
austinywang e0e5250
Merge remote-tracking branch 'origin/main' into issue-4375-dock-max-w…
austinywang f964f62
Merge remote-tracking branch 'origin/main' into issue-4375-dock-max-w…
austinywang 8e023d8
Merge remote-tracking branch 'origin/main' into issue-4375-dock-max-w…
austinywang dd08243
Merge remote-tracking branch 'origin/main' into issue-4375-dock-max-w…
austinywang c4b84a2
fix: use BrowserSearchSettingsStore after main rename (merge fixup)
austinywang c61fe60
merge: resolve automation settings parsing against #5547 (keep data-d…
austinywang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| {"sessionId":"5c2a62d0-99c2-42c0-9452-f67b6fbaacda","pid":75304,"procStart":"Thu Jun 4 23:34:54 2026","acquiredAt":1780616564932} | ||
| {"sessionId":"4311956b-e43f-405e-8b49-c3990850966d","pid":43365,"procStart":"Sun Jun 14 21:55:11 2026","acquiredAt":1781485012958} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
Packages/CmuxSettings/Sources/CmuxSettings/Policies/RightSidebarWidthSettings.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import Foundation | ||
|
|
||
| /// Policy values and normalization helpers for the right sidebar width override. | ||
| public struct RightSidebarWidthSettings: Sendable { | ||
| /// Creates a stateless right sidebar width policy value. | ||
| public init() {} | ||
|
|
||
| /// The `cmux.json` key under `sidebar` that stores the right sidebar maximum width. | ||
| public static let jsonKey = "rightMaxWidth" | ||
|
|
||
| /// The dotted settings path for the right sidebar maximum width override. | ||
| public static let settingsPath = "sidebar.rightMaxWidth" | ||
|
|
||
| /// The `UserDefaults` key that stores the active right sidebar maximum width override. | ||
| public static let maxWidthKey = "rightSidebarMaxWidth" | ||
|
|
||
| /// The `UserDefaults` key that remembers the previous right sidebar maximum width override. | ||
| public static let rememberedMaxWidthKey = "rightSidebarRememberedMaxWidth" | ||
|
|
||
| /// The stored sentinel value that means the built-in dynamic width cap is active. | ||
| public static let noOverrideValue = -1.0 | ||
|
|
||
| /// The smallest allowed right sidebar width, in points. | ||
| public static let minimumWidth = 276.0 | ||
|
|
||
| /// The built-in right sidebar maximum width, in points, used when no override is active. | ||
| public static let builtInMaximumWidth = 1200.0 | ||
|
|
||
| /// The width restored when enabling the override without a remembered value. | ||
| public static let defaultConfiguredMaximumWidth = builtInMaximumWidth | ||
|
|
||
| /// The largest width accepted by settings editors and imported `cmux.json` values. | ||
| public static let settingsEditorMaximumWidth = 4096.0 | ||
|
|
||
| /// Returns the effective configured maximum width for a stored value. | ||
| /// | ||
| /// - Parameter storedValue: The persisted width override value. | ||
| /// - Returns: A clamped width when the stored value enables the override, or `nil`. | ||
| public func configuredMaximumWidth(from storedValue: Double) -> Double? { | ||
| guard storedValue.isFinite, storedValue > 0 else { | ||
| return nil | ||
| } | ||
| return clampedSettingsEditorMaximumWidth(storedValue) | ||
| } | ||
|
|
||
| /// Clamps a settings-editor width to the supported range. | ||
| /// | ||
| /// - Parameter value: The requested width in points. | ||
| /// - Returns: A finite rounded width within the settings editor bounds. | ||
| public func clampedSettingsEditorMaximumWidth(_ value: Double) -> Double { | ||
| guard value.isFinite else { | ||
| return Self.defaultConfiguredMaximumWidth | ||
| } | ||
| return min(Self.settingsEditorMaximumWidth, max(Self.minimumWidth, value.rounded())) | ||
| } | ||
|
|
||
| /// Returns the remembered width to restore for a persisted value. | ||
| /// | ||
| /// - Parameter storedValue: The stored remembered width. | ||
| /// - Returns: A clamped remembered width, or the default configured width. | ||
| public func rememberedMaximumWidth(from storedValue: Double) -> Double { | ||
| guard let configuredMaximumWidth = configuredMaximumWidth(from: storedValue) else { | ||
| return Self.defaultConfiguredMaximumWidth | ||
| } | ||
| return clampedSettingsEditorMaximumWidth(configuredMaximumWidth) | ||
| } | ||
|
|
||
| /// Returns the width displayed in settings for the active and remembered values. | ||
| /// | ||
| /// - Parameters: | ||
| /// - activeStoredValue: The currently active stored override value. | ||
| /// - rememberedStoredValue: The remembered override value used when inactive. | ||
| /// - Returns: The clamped editor width to show. | ||
| public func editorMaximumWidth(activeStoredValue: Double, rememberedStoredValue: Double) -> Double { | ||
| if let configuredMaximumWidth = configuredMaximumWidth(from: activeStoredValue) { | ||
| return clampedSettingsEditorMaximumWidth(configuredMaximumWidth) | ||
| } | ||
| return rememberedMaximumWidth(from: rememberedStoredValue) | ||
| } | ||
|
|
||
| /// Returns the stored value to write when enabling the override. | ||
| /// | ||
| /// - Parameter rememberedStoredValue: The remembered override value. | ||
| /// - Returns: The clamped override width to store as active. | ||
| public func storedMaximumWidthWhenEnabling(rememberedStoredValue: Double) -> Double { | ||
| rememberedMaximumWidth(from: rememberedStoredValue) | ||
| } | ||
|
|
||
| /// Returns the remembered value to preserve before disabling the override. | ||
| /// | ||
| /// - Parameters: | ||
| /// - activeStoredValue: The currently active stored override value. | ||
| /// - rememberedStoredValue: The remembered override value used as fallback. | ||
| /// - Returns: The clamped width to store as remembered. | ||
| public func storedRememberedMaximumWidth(activeStoredValue: Double, rememberedStoredValue: Double) -> Double { | ||
| editorMaximumWidth(activeStoredValue: activeStoredValue, rememberedStoredValue: rememberedStoredValue) | ||
| } | ||
| } | ||
48 changes: 48 additions & 0 deletions
48
Packages/CmuxSettings/Tests/CmuxSettingsTests/RightSidebarWidthSettingsTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import Testing | ||
| @testable import CmuxSettings | ||
|
|
||
| @Suite("RightSidebarWidthSettings") | ||
| struct RightSidebarWidthSettingsTests { | ||
| private let settings = RightSidebarWidthSettings() | ||
|
|
||
| @Test func disabledOverrideRestoresRememberedCustomMaximumWhenEnabledAgain() { | ||
| let restored = settings.storedMaximumWidthWhenEnabling( | ||
| rememberedStoredValue: 1_234 | ||
| ) | ||
|
|
||
| #expect(restored == 1_234) | ||
| } | ||
|
|
||
| @Test func invalidRememberedMaximumFallsBackToDefaultWhenEnabled() { | ||
| let restored = settings.storedMaximumWidthWhenEnabling( | ||
| rememberedStoredValue: RightSidebarWidthSettings.noOverrideValue | ||
| ) | ||
|
|
||
| #expect(restored == RightSidebarWidthSettings.defaultConfiguredMaximumWidth) | ||
| } | ||
|
|
||
| @Test func activeCustomMaximumWinsOverRememberedValueForEditor() { | ||
| let editorValue = settings.editorMaximumWidth( | ||
| activeStoredValue: 1_500, | ||
| rememberedStoredValue: 900 | ||
| ) | ||
|
|
||
| #expect(editorValue == 1_500) | ||
| } | ||
|
|
||
| @Test func configuredMaximumWidthIsClampedToEditorRange() throws { | ||
| let configured = try #require( | ||
| settings.configuredMaximumWidth(from: 10_000) | ||
| ) | ||
|
|
||
| #expect(configured == RightSidebarWidthSettings.settingsEditorMaximumWidth) | ||
| } | ||
|
|
||
| @Test func rememberedCustomMaximumIsClampedToEditorRange() { | ||
| let restored = settings.storedMaximumWidthWhenEnabling( | ||
| rememberedStoredValue: 10_000 | ||
| ) | ||
|
|
||
| #expect(restored == RightSidebarWidthSettings.settingsEditorMaximumWidth) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.