fix(chat): restore windowed turn alignment

Keep the virtual-window measurement wrapper as a flex column so AgentTurn alignSelf rules remain active. Add regression coverage for the alignment context.
This commit is contained in:
2026-08-06 19:07:40 +08:00
parent 9e75e2df8a
commit 0a47534ddb
2 changed files with 27 additions and 1 deletions
@@ -216,6 +216,27 @@ describe("AgentWorkspace", () => {
expect(renderCounts.size).toBeLessThan(40); expect(renderCounts.size).toBeLessThan(40);
}); });
it("preserves the flex alignment context around windowed turns", () => {
const messages = Array.from({ length: 41 }, (_, index): Message => ({
id: `message-${index}`,
role: index % 2 === 0 ? "user" : "assistant",
content: `message ${index}`,
}));
render(
<AgentWorkspace
{...defaultProps}
isStreaming={false}
messages={messages}
/>,
);
expect(screen.getByTestId("turn-message-0").parentElement).toHaveStyle({
display: "flex",
flexDirection: "column",
});
});
it("keeps visible turns mounted when crossing the windowing threshold", () => { it("keeps visible turns mounted when crossing the windowing threshold", () => {
const messages = Array.from({ length: 41 }, (_, index): Message => ({ const messages = Array.from({ length: 41 }, (_, index): Message => ({
id: `message-${index}`, id: `message-${index}`,
+6 -1
View File
@@ -254,7 +254,12 @@ const MeasuredTurn = ({
return ( return (
<Box <Box
ref={rowRef} ref={rowRef}
sx={{ mb: measure ? `${TURN_GAP_PX}px` : 0, flexShrink: 0 }} sx={{
display: "flex",
flexDirection: "column",
flexShrink: 0,
mb: measure ? `${TURN_GAP_PX}px` : 0,
}}
> >
{children} {children}
</Box> </Box>