Repository navigation
Add beta feature toggles for Feed and Dock #3537
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
7 commits
Select commit
Hold shift + click to select a range
3c7d9bd
Add beta feature toggles for Feed and Dock
lawrencecchen 3890b9b
Merge remote-tracking branch 'origin/main' into task-beta-features-fe…
lawrencecchen 0df7904
Address beta feature review feedback
lawrencecchen 2681d00
Retarget sidebar focus after beta mode disable
lawrencecchen be3a96d
Merge remote-tracking branch 'origin/main' into task-beta-features-fe…
lawrencecchen 2425dca
Keep beta feature changes within file budget
lawrencecchen 03f878b
Trigger CI rerun
lawrencecchen 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import SwiftUI | ||
|
|
||
| struct BetaFeaturesSettingsView: View { | ||
| @Binding var feedEnabled: Bool | ||
| @Binding var dockEnabled: Bool | ||
|
|
||
| private var feedSubtitle: String { | ||
| if feedEnabled { | ||
| return String( | ||
| localized: "settings.betaFeatures.feed.subtitleOn", | ||
| defaultValue: "Shows Feed in the right sidebar mode switcher for inline agent decisions." | ||
| ) | ||
| } | ||
| return String( | ||
| localized: "settings.betaFeatures.feed.subtitleOff", | ||
| defaultValue: "Hides Feed from the right sidebar until you enable it here." | ||
| ) | ||
| } | ||
|
|
||
| private var dockSubtitle: String { | ||
| if dockEnabled { | ||
| return String( | ||
| localized: "settings.betaFeatures.dock.subtitleOn", | ||
| defaultValue: "Shows Dock in the right sidebar mode switcher for custom terminal controls." | ||
| ) | ||
| } | ||
| return String( | ||
| localized: "settings.betaFeatures.dock.subtitleOff", | ||
| defaultValue: "Hides Dock from the right sidebar until you enable it here." | ||
| ) | ||
| } | ||
|
|
||
| var body: some View { | ||
| SettingsSectionHeader(title: String(localized: "settings.section.betaFeatures", defaultValue: "Beta Features")) | ||
| .settingsSearchAnchor(SettingsSearchIndex.sectionID(for: .betaFeatures)) | ||
| SettingsCard { | ||
| BetaFeaturesWarningNote( | ||
| String( | ||
| localized: "settings.betaFeatures.warning", | ||
| defaultValue: "These features are unstable and may change or break. Enable them only when you are testing them." | ||
| ) | ||
| ) | ||
|
|
||
| SettingsCardDivider() | ||
|
|
||
| SettingsCardRow( | ||
| configurationReview: .settingsOnly, | ||
| String(localized: "settings.betaFeatures.feed", defaultValue: "Feed"), | ||
| subtitle: feedSubtitle, | ||
| searchAnchorID: SettingsSearchIndex.settingID(for: .betaFeatures, idSuffix: "feed") | ||
| ) { | ||
| Toggle("", isOn: $feedEnabled) | ||
| .labelsHidden() | ||
| .controlSize(.small) | ||
| .accessibilityIdentifier("SettingsBetaFeedToggle") | ||
| .accessibilityLabel( | ||
| String(localized: "settings.betaFeatures.feed", defaultValue: "Feed") | ||
| ) | ||
| } | ||
|
|
||
| SettingsCardDivider() | ||
|
|
||
| SettingsCardRow( | ||
| configurationReview: .settingsOnly, | ||
| String(localized: "settings.betaFeatures.dock", defaultValue: "Dock"), | ||
| subtitle: dockSubtitle, | ||
| searchAnchorID: SettingsSearchIndex.settingID(for: .betaFeatures, idSuffix: "dock") | ||
| ) { | ||
| Toggle("", isOn: $dockEnabled) | ||
| .labelsHidden() | ||
| .controlSize(.small) | ||
| .accessibilityIdentifier("SettingsBetaDockToggle") | ||
| .accessibilityLabel( | ||
| String(localized: "settings.betaFeatures.dock", defaultValue: "Dock") | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private struct BetaFeaturesWarningNote: View { | ||
| let text: String | ||
|
|
||
| init(_ text: String) { | ||
| self.text = text | ||
| } | ||
|
|
||
| var body: some View { | ||
| HStack(alignment: .top, spacing: 8) { | ||
| Image(systemName: "exclamationmark.triangle.fill") | ||
| .font(.system(size: 12, weight: .semibold)) | ||
| .foregroundStyle(.yellow) | ||
| .accessibilityHidden(true) | ||
|
|
||
| Text(text) | ||
| .font(.caption) | ||
| .foregroundColor(.secondary) | ||
| .fixedSize(horizontal: false, vertical: true) | ||
| } | ||
| .padding(.horizontal, 14) | ||
| .padding(.vertical, 8) | ||
| .frame(maxWidth: .infinity, alignment: .leading) | ||
| } | ||
| } |
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
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,94 @@ | ||
| import AppKit | ||
| import SwiftUI | ||
|
|
||
| // MARK: - State (visibility toggle) | ||
|
|
||
| final class FileExplorerState: ObservableObject { | ||
| private static let modeKey = "rightSidebar.mode" | ||
|
|
||
| @Published var isVisible: Bool { | ||
| didSet { UserDefaults.standard.set(isVisible, forKey: "fileExplorer.isVisible") } | ||
| } | ||
| @Published var width: CGFloat { | ||
| didSet { UserDefaults.standard.set(Double(width), forKey: "fileExplorer.width") } | ||
| } | ||
|
|
||
| /// Proportion of sidebar height allocated to the tab list (0.0-1.0). | ||
| /// The file explorer gets the remaining space below. | ||
| @Published var dividerPosition: CGFloat { | ||
| didSet { UserDefaults.standard.set(Double(dividerPosition), forKey: "fileExplorer.dividerPosition") } | ||
| } | ||
|
|
||
| /// Whether hidden files (dotfiles) are shown in the tree. | ||
| @Published var showHiddenFiles: Bool { | ||
| didSet { UserDefaults.standard.set(showHiddenFiles, forKey: "fileExplorer.showHidden") } | ||
| } | ||
|
|
||
| @Published private var storedMode: RightSidebarMode | ||
|
|
||
| /// Active mode for the right sidebar (file tree, search, sessions, or enabled beta modes). | ||
| var mode: RightSidebarMode { | ||
| get { storedMode } | ||
| set { setMode(newValue) } | ||
| } | ||
|
|
||
| init() { | ||
| let defaults = UserDefaults.standard | ||
| self.isVisible = defaults.bool(forKey: "fileExplorer.isVisible") | ||
| let storedWidth = defaults.double(forKey: "fileExplorer.width") | ||
| self.width = storedWidth > 0 ? CGFloat(storedWidth) : 220 | ||
| let storedPosition = defaults.double(forKey: "fileExplorer.dividerPosition") | ||
| self.dividerPosition = storedPosition > 0 ? CGFloat(storedPosition) : 0.6 | ||
| let storedShowHidden = defaults.object(forKey: "fileExplorer.showHidden") | ||
| self.showHiddenFiles = storedShowHidden == nil ? true : defaults.bool(forKey: "fileExplorer.showHidden") | ||
| let storedMode = RightSidebarMode(rawValue: defaults.string(forKey: Self.modeKey) ?? "") ?? .files | ||
| self.storedMode = Self.availableMode(storedMode, defaults: defaults) | ||
| defaults.set(self.storedMode.rawValue, forKey: Self.modeKey) | ||
| } | ||
|
|
||
| func refreshModeAvailability(defaults: UserDefaults = .standard) { | ||
| setMode(storedMode, defaults: defaults) | ||
| } | ||
|
|
||
| func toggle() { | ||
| setVisible(!isVisible) | ||
| } | ||
|
|
||
| func setVisible(_ nextValue: Bool) { | ||
| guard isVisible != nextValue else { return } | ||
|
|
||
| // Suppress both SwiftUI transactions and AppKit/Core Animation implicit layout changes. | ||
| NSAnimationContext.beginGrouping() | ||
| CATransaction.begin() | ||
| defer { | ||
| CATransaction.commit() | ||
| NSAnimationContext.endGrouping() | ||
| } | ||
|
|
||
| NSAnimationContext.current.duration = 0 | ||
| NSAnimationContext.current.allowsImplicitAnimation = false | ||
| CATransaction.setDisableActions(true) | ||
|
|
||
| var transaction = Transaction(animation: nil) | ||
| transaction.disablesAnimations = true | ||
| withTransaction(transaction) { | ||
| isVisible = nextValue | ||
| } | ||
| } | ||
|
|
||
| private func setMode(_ mode: RightSidebarMode, defaults: UserDefaults = .standard) { | ||
| let nextMode = Self.availableMode(mode, defaults: defaults) | ||
| guard storedMode != nextMode else { | ||
| if defaults.string(forKey: Self.modeKey) != nextMode.rawValue { | ||
| defaults.set(nextMode.rawValue, forKey: Self.modeKey) | ||
| } | ||
| return | ||
| } | ||
| storedMode = nextMode | ||
| defaults.set(nextMode.rawValue, forKey: Self.modeKey) | ||
| } | ||
|
|
||
| private static func availableMode(_ mode: RightSidebarMode, defaults: UserDefaults) -> RightSidebarMode { | ||
| mode.isAvailable(defaults: defaults) ? mode : .files | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RightSidebarBetaFeatureSettingsstatic helpers should benonisolatedThe new static methods
isFeedEnabled(defaults:)andisDockEnabled(defaults:)read fromUserDefaults— a pure, thread-safe value operation with no UI coupling. Without an explicitnonisolatedannotation, they inherit the module's default actor isolation (likely@MainActorin a Swift 6 target), unnecessarily coupling them to the main actor and preventing calls from non-isolated async contexts. Per the actor-isolation rule, static utility helpers that do not interact with UI state should be markednonisolated.Rule Used: Flag new or materially worsened Swift 6 actor isol... (source)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by marking the pure RightSidebarBetaFeatureSettings lookup helpers nonisolated.
— Claude Code