Repository navigation
Add Show in Finder to workspace sidebar context menu #3632
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 11 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
0794542
Let users jump from a workspace row to its Finder folder
austinywang 7cab494
Keep Finder menu wiring within the sidebar row
austinywang 0980b72
Resolve tilde workspace paths before Finder validation
austinywang 8722e9b
Avoid file stats while building workspace context menus
austinywang aa4809e
Disable Finder menu for missing workspace folders
austinywang fab1c74
Keep Finder directory checks outside the sidebar row
austinywang 9a98c02
Refresh Finder directory cache per menu request
austinywang 3a54642
Keep Finder reveal scoped to local workspace directories
austinywang 3200922
Keep the local Finder guard within the Workspace budget
austinywang 71ab98a
Avoid redundant Finder cache writes while opening menus
austinywang 81a45fe
Retry transient CI dependency download
austinywang 0843b21
Keep Finder directory probes off the UI actor
austinywang d6d80fa
Let SwiftUI own Finder reveal requests
austinywang 5f8c4b2
Retry transient macOS dependency bootstrap
austinywang 2b8a0e0
Keep macOS CI out of Homebrew auto-update
austinywang 134f24a
Retry transient Zig downloads in macOS CI
austinywang 7dbf586
Keep Finder directory probing structurally cancellable
austinywang b2dd7ea
Use Swift 5-compatible Finder directory probing
austinywang 79ebf6f
Avoid Finder error feedback after cancellation
austinywang ba8a24c
Keep ended remote panels out of Finder targets
austinywang e8f6971
Keep Zig bootstrap independent of Homebrew
austinywang 45a2d58
Bound Zig download attempts in macOS CI
austinywang 6e4a768
Tolerate slow Zig archive downloads in CI
austinywang 11b5be5
Merge current main before PR iteration
austinywang 85e468f
Keep window-drag tests on current suppression API
austinywang 32a4ab4
Keep Finder menu cache stable while opening
austinywang 9402465
Merge current main after PR review fix
austinywang 49f28f0
Place Finder action beside workspace copy menu item
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
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
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,64 @@ | ||
| import AppKit | ||
| import Foundation | ||
|
|
||
| struct WorkspaceFinderDirectoryCacheKey: Equatable, Sendable { | ||
| var path: String? | ||
| var refreshID: UInt64 | ||
| } | ||
|
|
||
| struct WorkspaceFinderDirectoryCache: Equatable, Sendable { | ||
| var key: WorkspaceFinderDirectoryCacheKey? = nil | ||
| var directoryURL: URL? = nil | ||
|
|
||
| func url(for currentKey: WorkspaceFinderDirectoryCacheKey) -> URL? { | ||
| guard key == currentKey else { return nil } | ||
| return directoryURL | ||
| } | ||
| } | ||
|
|
||
| enum WorkspaceFinderDirectoryResolver { | ||
| @MainActor | ||
| static func path(for workspace: Workspace) -> String? { | ||
| guard let directory = workspace.sidebarFinderDirectory() else { return nil } | ||
| let path = NSString(string: directory).expandingTildeInPath | ||
| return path.isEmpty ? nil : path | ||
| } | ||
|
|
||
| static func cache(for key: WorkspaceFinderDirectoryCacheKey) async -> WorkspaceFinderDirectoryCache { | ||
| guard let path = key.path else { return WorkspaceFinderDirectoryCache(key: key) } | ||
| let directoryURL = await existingDirectoryURL(for: path) | ||
| return WorkspaceFinderDirectoryCache(key: key, directoryURL: directoryURL) | ||
| } | ||
|
|
||
| static func existingDirectoryURL(for path: String) async -> URL? { | ||
| await Task.detached(priority: .utility) { | ||
| existingDirectoryURLUnchecked(for: path) | ||
| }.value | ||
| } | ||
|
|
||
| private nonisolated static func existingDirectoryURLUnchecked(for path: String) -> URL? { | ||
| var isDirectory: ObjCBool = false | ||
| guard FileManager.default.fileExists(atPath: path, isDirectory: &isDirectory), | ||
| isDirectory.boolValue else { | ||
| return nil | ||
| } | ||
| return URL(fileURLWithPath: path, isDirectory: true).standardizedFileURL | ||
| } | ||
| } | ||
|
|
||
| enum WorkspaceFinderDirectoryOpener { | ||
| @MainActor | ||
| static func openInFinder(_ directoryURL: URL?) { | ||
| guard let directoryURL else { | ||
| NSSound.beep() | ||
| return | ||
| } | ||
| Task { @MainActor in | ||
| if let refreshedURL = await WorkspaceFinderDirectoryResolver.existingDirectoryURL(for: directoryURL.path) { | ||
| NSWorkspace.shared.activateFileViewerSelecting([refreshedURL]) | ||
| } else { | ||
| NSSound.beep() | ||
| } | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
| } | ||
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.
workspaceFinderDirectoryRefreshID &+= 1fires insideonAppear, which runs after SwiftUI has already rendered the context menu with the oldrefreshID. On macOS, SwiftUI context menus back ontoNSMenuand do re-evaluate their@ViewBuildercontent reactively when state changes. The result is: the menu appears with the button enabled (pre-populated cache key matches refreshID 0), thenonAppearfires → refreshID becomes 1 → SwiftUI re-evaluatesworkspaceContextMenu→cache.url(for: {path, refreshID: 1})returns nil (cache still holds refreshID 0) → button becomes disabled → the async task completes and re-enables it. Every context menu open produces this transient disabled flash.WorkspaceFinderDirectoryOpener.openInFinderalready callsexistingDirectoryURLbefore invokingactivateFileViewerSelectingand beeps on failure, so the deleted-directory safety case is fully covered without theonAppearrefresh. Removing theworkspaceFinderDirectoryRefreshID &+= 1line (or replacing it with a non-invalidating "kick a background check without changing the key") would keep the button enabled during the check while still protecting against stale URLs at click time.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 in 32a4ab4 by removing the context-menu refresh id from the Finder directory cache key. The menu now stays on the path-keyed cached state while the opener still revalidates the directory immediately before revealing it in Finder.
— Claude Code