Skip to content

fix: consolidate control validation into layoutNow#340

Merged
jdneo merged 3 commits into
mainfrom
chatview-consolidate-control-validation
Jul 7, 2026
Merged

fix: consolidate control validation into layoutNow#340
jdneo merged 3 commits into
mainfrom
chatview-consolidate-control-validation

Conversation

@jdneo

@jdneo jdneo commented Jul 7, 2026

Copy link
Copy Markdown
Member

requestLayout and flushPendingLayoutRequests each filtered out null/ disposed controls via a shared validControls helper before delegating to layoutNow, duplicating the same defensive check at every call site.

layoutNow now performs its own null/disposed filtering right where it dereferences the controls (getShell(), shell.layout(...)), so the invariant is enforced in exactly one place instead of trusted by two separate callers. requestLayout becomes a pure dispatcher: it no longer pre-filters, it just forwards the raw controls to pendingLayoutRequests or layoutNow.

fix #335

requestLayout and flushPendingLayoutRequests each filtered out null/
disposed controls via a shared validControls helper before delegating
to layoutNow, duplicating the same defensive check at every call site.

layoutNow now performs its own null/disposed filtering right where it
dereferences the controls (getShell(), shell.layout(...)), so the
invariant is enforced in exactly one place instead of trusted by two
separate callers. requestLayout becomes a pure dispatcher: it no
longer pre-filters, it just forwards the raw controls to
pendingLayoutRequests or layoutNow.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 7, 2026 07:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 refactors Chat view layout triggering to avoid expensive relayout work while the Chat view is hidden (e.g., stacked behind another part), addressing UI freezes described in issue #335. It centralizes control validation inside the layout executor and introduces a deferred “replay” mechanism when the view becomes visible again.

Changes:

  • Replaces the previous full-view layout call path with a targeted requestLayout(Control...) API that defers requests while the view is not visible.
  • Adds a pendingLayoutRequests queue and flushes it on partVisible to replay suppressed layout requests.
  • Updates ReferencedFile#setFile(...) to request layout for the specific child controls that may change rather than triggering a full layout.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/ReferencedFile.java Switches from chatView.layout(true, true) to targeted chatView.requestLayout(...) calls to avoid full relayout and stale cached sizes.
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/ChatView.java Introduces deferred targeted layout (requestLayout, pendingLayoutRequests, flushPendingLayoutRequests, layoutNow) and flush-on-visible behavior.

jdneo and others added 2 commits July 7, 2026 15:16
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
The prior "Potential fix for pull request finding" commit (04e7682)
badly spliced a null-check into requestLayout, leaving a dangling
duplicate `layoutNow(changed); }` outside the method body and
dedenting the whole method. This left invalid Java that failed the
Tycho/ECJ compile in CI.

Restores correct syntax/indentation while keeping the null-guard
around Collections.addAll(pendingLayoutRequests, changed), which is
the same defensive check layoutNow already applies to its own
`controls` parameter.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@xinyi-gong xinyi-gong left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@jdneo jdneo merged commit de828cc into main Jul 7, 2026
4 checks passed
@jdneo jdneo deleted the chatview-consolidate-control-validation branch July 7, 2026 07:49
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.

[Bug] UI Freezes on editor switch if Chat view has longer conversation

3 participants