Skip to content

Conversation

@sbatten
Copy link
Member

@sbatten sbatten commented Jan 17, 2026

Alternate fix for #288500

connor4312 and others added 2 commits January 16, 2026 14:19
Introduces a new LayoutAnchorMode.OVERLAP_OKAY that allows views to overlap
the anchor when they don't fit on the preferred side, rather than flipping
to the opposite side far away from the anchor.

This fixes large hovers appearing far from their target element when there
isn't enough space above/below.
Copilot AI review requested due to automatic review settings January 17, 2026 00:26
@sbatten sbatten assigned connor4312 and sbatten and unassigned connor4312 Jan 17, 2026
@sbatten sbatten requested a review from Tyriar January 17, 2026 00:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a fix for issue #288500 by adding a new OVERLAP_OKAY layout mode for context views. The mode allows large hovers to shift and overlap with anchors rather than being flipped to the opposite side when they don't fit perfectly on the preferred side.

Changes:

  • Adds OVERLAP_OKAY enum value to LayoutAnchorMode to enable overlap-tolerant positioning
  • Modifies the layout function to skip the "flip to other side" logic when OVERLAP_OKAY mode is active
  • Applies OVERLAP_OKAY mode to vertical anchors in context view positioning
  • Adds test case for large hover positioning behavior
  • Includes debugging code that adds repetitive 'more' text to agent session tooltips (should be removed)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/vs/base/browser/ui/contextview/contextview.ts Adds OVERLAP_OKAY mode and updates layout logic to prevent flipping when this mode is set
src/vs/base/test/browser/ui/contextview/contextview.test.ts Adds test case for large hover layout behavior
src/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsViewer.ts Contains debugging code adding 'more' text to tooltips (should be removed)

Comment on lines +363 to +375
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');

Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be debugging/test code that should not be committed. These 12 lines adding 'more' to the tooltip will result in unexpected UI behavior where tooltips display repeated "more" text. This should be removed before merging.

Suggested change
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');
lines.push('more');

Copilot uses AI. Check for mistakes.
AVOID,
ALIGN
ALIGN,
OVERLAP_OKAY
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new OVERLAP_OKAY enum value lacks documentation explaining its purpose and when it should be used, unlike the other layout modes. Consider adding a comment to describe when this mode is appropriate, especially given that it changes the layout behavior to prefer overlapping the anchor rather than flipping to the other side.

Copilot uses AI. Check for mistakes.
Comment on lines +30 to +33
test('layout large hover', () => {
// When the view is large and almost fits on the preferred side, we should prefer to shift it
// rather than flip it to the other side which might be far away.
assert.strictEqual(layout(1084, 306, { offset: 296, size: 2, position: LayoutAnchorPosition.After }), 0);
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test doesn't include the mode parameter in the anchor object, so it's testing the default AVOID behavior rather than the new OVERLAP_OKAY behavior that was introduced. To properly test the "shift rather than flip" behavior described in the comment, the test should specify mode: LayoutAnchorMode.OVERLAP_OKAY in the anchor object. Otherwise, the existing logic would flip to the other side rather than overlap.

Copilot uses AI. Check for mistakes.
@sbatten sbatten requested a review from sandy081 January 17, 2026 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants