Skip to content

Fix webview comment and stack action lifecycle - #9049

Open
Henning Dieterichs (hediet) wants to merge 3 commits into
hediet/webview-preparationfrom
hediet/webview-lifecycle-fixes
Open

Henning Dieterichs (hediet) wants to merge 3 commits into
hediet/webview-preparationfrom
hediet/webview-lifecycle-fixes

Conversation

@hediet

@hediet Henning Dieterichs (hediet) commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Summary

Fix product issues exposed by rendering webviews repeatedly in Component Explorer, without adding Explorer tooling to this PR.

  • Register the quote-reply subscription once and remove it on unmount.
  • Keep CommentBody hook ordering independent of empty content.
  • Wire the controlled comment textarea through React's change event.
  • Use stable account/reviewer IDs as keys for collapsed sidebar avatars.
  • Avoid updating stack-action error/busy state after its component unmounts.
  • Add regression tests for controlled drafts, subscription cleanup, avatar keys, and pending stack-action disposal.

Relationship to the stack

This is separate from #9047 (preparation) and #9048 (Explorer adoption). It targets the preparation branch because its tests use the explicit host helper. The changes were deliberately excluded from those PRs and are owned here only. Merge preparation first, then this fix, then Explorer; retarget to main as the prerequisite lands.

Validation

  • npm run test:webviews: build succeeded and all 86 tests passed using locked dependencies from the preparation worktree.
  • npm run lint and npm run hygiene passed.
  • No package or lockfile changes.

The preparation dependency now builds on #9050, which independently owns the pending-reply Map/leak fix. That change is not part of this PR diff.

The viewport-only preparation was moved into #9048. This branch has been updated to the narrower preparation dependency; its product-fix additions and deletions are unchanged.

Clean up quote-reply subscriptions, preserve hook order, wire controlled drafts through onChange, assign stable avatar keys, and avoid stack-action state updates after unmount.

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

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.

🟢 Approval recommended

The lifecycle fixes are appropriately scoped and covered by targeted regression tests.

0 open findings

What changed in this PR

Fixes repeated-render lifecycle issues in webview comments, sidebar avatars, and stack actions.

Changes:

  • Stabilizes hook, subscription, and controlled-textarea behavior.
  • Adds stable avatar keys and guards asynchronous stack state updates after unmount.
  • Adds focused regression tests for these lifecycle scenarios.
File Description
webviews/​components/​comment.tsx Fixes hooks, event cleanup, and textarea changes.
webviews/​components/​sidebar.tsx Adds stable avatar keys.
webviews/​components/​pullRequestStack.tsx Prevents state updates after unmount.
webviews/​components/​test/​comment.test.tsx Tests drafts and subscription cleanup.
webviews/​components/​test/​sidebar.test.tsx Tests duplicate avatar-key prevention.
webviews/​components/​test/​pullRequestStack.test.tsx Tests pending-action disposal.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI balanced review requested due to automatic review settings October 9, 2026 17:06

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.

🟡 Changes recommended

Reviewer avatars still use display-derived keys rather than stable account IDs.

1 open finding

🧠 Review effort: Balanced

const sections: { label: string; value: React.ReactNode; count: number }[] = [];

const reviewersWithAvatar = reviewers?.filter((r): r is ReviewState & { reviewer: { avatarUrl: string } } => !!r.reviewer.avatarUrl).map(r => ({ avatarUrl: r.reviewer.avatarUrl, name: reviewerLabel(r.reviewer) }));
const reviewersWithAvatar = reviewers?.filter((r): r is ReviewState & { reviewer: { avatarUrl: string } } => !!r.reviewer.avatarUrl).map(r => ({ id: reviewerId(r.reviewer), avatarUrl: r.reviewer.avatarUrl, name: reviewerLabel(r.reviewer) }));
Update the preparation dependency without pulling Explorer-only responsive changes into this PR.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 18:15

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.

🟢 Approval recommended

The lifecycle fixes are focused, consistent with existing APIs, and covered by targeted regression tests.

1 open finding

🧠 Review effort: Balanced

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.

2 participants