Repository navigation
Stabilize sidebar directory ordering when split focus changes - #1798
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
📝 WalkthroughWalkthroughRefactored sidebar directory handling by introducing new workspace methods ( Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Sources/Workspace.swift`:
- Around line 5942-5947: The current canonicalization uses
NSString.expandingTildeInPath which expands ~ against the local machine; update
canonicalSidebarDirectoryKey(_:) and the matching canonicalizer inside
SidebarBranchOrdering.orderedUniqueBranchDirectoryEntries(...) to perform tilde
expansion against the workspace's remote/home context when the workspace is
remote (use the workspace/connection's remoteHome or live CWD to resolve "~"),
then continue to standardizePath and trim whitespace as before so both sidebar
keys and branch-directory entries canonicalize identically in remote workspaces.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: de2faa34-7c26-44ce-b388-e99cf25b3d09
📒 Files selected for processing (3)
Sources/ContentView.swiftSources/Workspace.swiftcmuxTests/WorkspaceUnitTests.swift
| private func canonicalSidebarDirectoryKey(_ directory: String?) -> String? { | ||
| guard let directory = normalizedSidebarDirectory(directory) else { return nil } | ||
| let expanded = NSString(string: directory).expandingTildeInPath | ||
| let standardized = NSString(string: expanded).standardizingPath | ||
| let cleaned = standardized.trimmingCharacters(in: .whitespacesAndNewlines) | ||
| return cleaned.isEmpty ? nil : cleaned |
There was a problem hiding this comment.
Make directory canonicalization remote-aware.
Line 5944 expands ~ against the local machine. In a remote workspace, that makes a requested cwd like ~/repo canonicalize differently from the later live cwd /home/remoteuser/repo, so the sidebar can still show duplicate entries for the same remote directory.
Suggested fix
private func canonicalSidebarDirectoryKey(_ directory: String?) -> String? {
guard let directory = normalizedSidebarDirectory(directory) else { return nil }
- let expanded = NSString(string: directory).expandingTildeInPath
- let standardized = NSString(string: expanded).standardizingPath
+ let pathForKey = isRemoteWorkspace
+ ? directory
+ : NSString(string: directory).expandingTildeInPath
+ let standardized = NSString(string: pathForKey).standardizingPath
let cleaned = standardized.trimmingCharacters(in: .whitespacesAndNewlines)
return cleaned.isEmpty ? nil : cleaned
}Please apply the same remote-aware rule to the matching canonicalizer inside SidebarBranchOrdering.orderedUniqueBranchDirectoryEntries(...) so the branch rows and plain directory summary stay consistent.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@Sources/Workspace.swift` around lines 5942 - 5947, The current
canonicalization uses NSString.expandingTildeInPath which expands ~ against the
local machine; update canonicalSidebarDirectoryKey(_:) and the matching
canonicalizer inside
SidebarBranchOrdering.orderedUniqueBranchDirectoryEntries(...) to perform tilde
expansion against the workspace's remote/home context when the workspace is
remote (use the workspace/connection's remoteHome or live CWD to resolve "~"),
then continue to standardizePath and trim whitespace as before so both sidebar
keys and branch-directory entries canonicalize identically in remote workspaces.
…ow-ai#1798) * Add sidebar directory ordering regression test * Stabilize sidebar directory ordering --------- Co-authored-by: Lawrence Chen <lawrencecchen@users.noreply.github.com>
Summary
Testing
Summary by cubic
Stabilizes sidebar directory ordering so it stays consistent when the focused split changes. Removes flicker and keeps path summary and branch entries in a stable order.
sidebarDirectoriesInDisplayOrder(...)and reuse it for the sidebar path summary and branch directory entries.testSidebarBranchDirectoryEntriesStayStableAcrossFocusedSplitChanges.Written for commit c8b495e. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests