Repository navigation
Keep selected workspace visible after sidebar reorders #4083
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 8 commits
8853f05
4997db5
e30f3c7
4582e91
0ad6f29
ca4a73c
c775c45
423cefa
2ac8cee
8d07f15
6705ff2
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 |
|---|---|---|
|
|
@@ -143,6 +143,68 @@ final class SidebarWorkspaceSnapshotRefreshPolicyTests: XCTestCase { | |
| } | ||
| } | ||
|
|
||
| final class SidebarSelectedWorkspaceScrollPolicyTests: XCTestCase { | ||
| func testSkipsScrollWhenSelectedWorkspaceIdIsNil() { | ||
| XCTAssertFalse( | ||
| SidebarSelectedWorkspaceScrollPolicy.shouldScrollSelectedWorkspace( | ||
| selectedWorkspaceId: nil as String?, | ||
| oldWorkspaceIds: ["a"], | ||
| newWorkspaceIds: ["a"] | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| func testRequestsScrollWhenSelectedWorkspaceFirstAppears() { | ||
| XCTAssertTrue( | ||
| SidebarSelectedWorkspaceScrollPolicy.shouldScrollSelectedWorkspace( | ||
| selectedWorkspaceId: "b", | ||
| oldWorkspaceIds: ["a"], | ||
| newWorkspaceIds: ["a", "b"] | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| func testRequestsScrollWhenSelectedWorkspaceMovesToTop() { | ||
| XCTAssertTrue( | ||
| SidebarSelectedWorkspaceScrollPolicy.shouldScrollSelectedWorkspace( | ||
| selectedWorkspaceId: "c", | ||
| oldWorkspaceIds: ["a", "b", "c"], | ||
| newWorkspaceIds: ["c", "a", "b"] | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| func testSkipsScrollWhenAnotherReorderOnlyShiftsSelectedWorkspaceIndex() { | ||
| XCTAssertFalse( | ||
| SidebarSelectedWorkspaceScrollPolicy.shouldScrollSelectedWorkspace( | ||
| selectedWorkspaceId: "b", | ||
| oldWorkspaceIds: ["a", "b", "c"], | ||
| newWorkspaceIds: ["c", "a", "b"] | ||
| ) | ||
| ) | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
|
|
||
| func testSkipsScrollWhenReorderLeavesSelectedWorkspaceIndexUnchanged() { | ||
| XCTAssertFalse( | ||
| SidebarSelectedWorkspaceScrollPolicy.shouldScrollSelectedWorkspace( | ||
| selectedWorkspaceId: "a", | ||
| oldWorkspaceIds: ["a", "b", "c"], | ||
| newWorkspaceIds: ["a", "c", "b"] | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| func testSkipsScrollWhenSelectedWorkspaceIsMissing() { | ||
| XCTAssertFalse( | ||
| SidebarSelectedWorkspaceScrollPolicy.shouldScrollSelectedWorkspace( | ||
| selectedWorkspaceId: "b", | ||
| oldWorkspaceIds: ["a", "b"], | ||
| newWorkspaceIds: ["a", "c"] | ||
| ) | ||
| ) | ||
| } | ||
| } | ||
|
Comment on lines
+146
to
+206
Contributor
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.
The new
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. Fixed by adding explicit nil-selection coverage for SidebarSelectedWorkspaceScrollPolicy. — Claude Code |
||
|
|
||
| final class SidebarWorkspaceRowInteractionStateTests: XCTestCase { | ||
| func testHoverRevealIsIndependentFromStaleContextMenuVisibility() { | ||
| var state = SidebarWorkspaceRowInteractionState() | ||
|
|
||
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.
if let … !== tabManagerpattern only rejects notifications whose object is aTabManagerthat is not our manager; it silently accepts notifications with anilobject or a non-TabManagerobject (neither of which can be cast). In a multi-window app, any future code that posts.workspaceOrderDidChangewithout settingobject:would be processed by every sidebar instance, setting a spuriouspendingSelectedWorkspaceScrollIdand triggering an unexpected scroll. The correct guard requires the object to be exactly ourtabManager.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 requiring the notification object to be a TabManager and identical to this sidebar's tabManager before enqueueing a selected-workspace scroll. Notifications with nil or unrelated objects now return immediately.
— Claude Code