Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

Handle system timeline messages with assistant height rules

Julius Marminge7c7fcf46c230
diff --git a/apps/web/src/components/timelineHeight.test.ts b/apps/web/src/components/timelineHeight.test.ts
index 613b20957..73a21cd08 100644
--- a/apps/web/src/components/timelineHeight.test.ts
+++ b/apps/web/src/components/timelineHeight.test.ts
@@ -12,6 +12,15 @@ describe("estimateTimelineMessageHeight", () => {
).toBe(122);
});
+ it("uses assistant sizing rules for system messages", () => {
+ expect(
+ estimateTimelineMessageHeight({
+ role: "system",
+ text: "a".repeat(144),
+ }),
+ ).toBe(122);
+ });
+
it("adds one attachment row for one or two user attachments", () => {
expect(
estimateTimelineMessageHeight({
diff --git a/apps/web/src/components/timelineHeight.ts b/apps/web/src/components/timelineHeight.ts
index 993736789..78a5f6539 100644
--- a/apps/web/src/components/timelineHeight.ts
+++ b/apps/web/src/components/timelineHeight.ts
@@ -67,16 +67,24 @@ export function estimateTimelineMessageHeight(
message: TimelineMessageHeightInput,
layout: TimelineHeightEstimateLayout = { timelineWidthPx: null },
): number {
- if (message.role !== "user") {
+ if (message.role === "assistant") {
const charsPerLine = estimateCharsPerLineForAssistant(layout.timelineWidthPx);
const estimatedLines = estimateWrappedLineCount(message.text, charsPerLine);
return ASSISTANT_BASE_HEIGHT_PX + estimatedLines * LINE_HEIGHT_PX;
}
- const charsPerLine = estimateCharsPerLineForUser(layout.timelineWidthPx);
+ if (message.role === "user") {
+ const charsPerLine = estimateCharsPerLineForUser(layout.timelineWidthPx);
+ const estimatedLines = estimateWrappedLineCount(message.text, charsPerLine);
+ const attachmentCount = message.attachments?.length ?? 0;
+ const attachmentRows = Math.ceil(attachmentCount / ATTACHMENTS_PER_ROW);
+ const attachmentHeight = attachmentRows * USER_ATTACHMENT_ROW_HEIGHT_PX;
+ return USER_BASE_HEIGHT_PX + estimatedLines * LINE_HEIGHT_PX + attachmentHeight;
+ }
+
+ // `system` messages are not rendered in the chat timeline, but keep a stable
+ // explicit branch in case they are present in timeline data.
+ const charsPerLine = estimateCharsPerLineForAssistant(layout.timelineWidthPx);
const estimatedLines = estimateWrappedLineCount(message.text, charsPerLine);
- const attachmentCount = message.attachments?.length ?? 0;
- const attachmentRows = Math.ceil(attachmentCount / ATTACHMENTS_PER_ROW);
- const attachmentHeight = attachmentRows * USER_ATTACHMENT_ROW_HEIGHT_PX;
- return USER_BASE_HEIGHT_PX + estimatedLines * LINE_HEIGHT_PX + attachmentHeight;
+ return ASSISTANT_BASE_HEIGHT_PX + estimatedLines * LINE_HEIGHT_PX;
}