Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): resizing a pane no longer crashes an expanded tool list #48266

Opentris203(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/48266/headopened View on GitHub

Showing 2 changed files with 57 additions and 10 deletions.

x
0 of 2 viewed, 2 left
38 additions and 0 deletionsapps/web/src/components/chat/MessagesTimeline.browser.test.tsxModified
View file
@@ -458,6 +458,44 @@
expect(screen.text()).not.toContain("Maximum update depth exceeded");
});
​
+ it("settles an expanded group that overflows only while it has the allowance", async () => {
+ // A group whose content measures taller with the allowance's extra height than without
+ // it (a resized pane rewrapping rows) used to toggle the allowance until React gave up.
+ const scrollHeight = Object.getOwnPropertyDescriptor(Element.prototype, "scrollHeight")!;
+ Object.defineProperty(Element.prototype, "scrollHeight", {
+ configurable: true,
+ get(this: Element) {
+ if (!(this instanceof HTMLElement) || !this.hasAttribute("data-tool-group-scroll")) {
+ return scrollHeight.get!.call(this) as number;
+ }
+ const withAllowance = this.style.maxHeight.endsWith(" 48px)");
+ return this.clientHeight + (withAllowance ? 2 : 40);
+ },
+ });
+ onTestFinished(() => {
+ Object.defineProperty(Element.prototype, "scrollHeight", scrollHeight);
+ });
+ await using screen = await renderTimeline(
+ Array.from({ length: 13 }, (_, index) =>
+ work(`tool-${index}`, {
+ tone: "tool",
+ itemType: "dynamic_tool",
+ label: `Tool ${index}`,
+ toolLifecycleStatus: "completed",
+ }),
+ ),