| ... | ... | @@ -67,16 +67,24 @@ export function estimateTimelineMessageHeight( |
| 67 | 67 | message: TimelineMessageHeightInput, |
| 68 | 68 | layout: TimelineHeightEstimateLayout = { timelineWidthPx: null }, |
| 69 | 69 | ): number { |
| 70 | | if (message.role !== "user") { |
| 70 | if (message.role === "assistant") { |
| 71 | 71 | const charsPerLine = estimateCharsPerLineForAssistant(layout.timelineWidthPx); |
| 72 | 72 | const estimatedLines = estimateWrappedLineCount(message.text, charsPerLine); |
| 73 | 73 | return ASSISTANT_BASE_HEIGHT_PX + estimatedLines * LINE_HEIGHT_PX; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | | const charsPerLine = estimateCharsPerLineForUser(layout.timelineWidthPx); |
| 76 | if (message.role === "user") { |
| 77 | const charsPerLine = estimateCharsPerLineForUser(layout.timelineWidthPx); |
| 78 | const estimatedLines = estimateWrappedLineCount(message.text, charsPerLine); |
| 79 | const attachmentCount = message.attachments?.length ?? 0; |
| 80 | const attachmentRows = Math.ceil(attachmentCount / ATTACHMENTS_PER_ROW); |
| 81 | const attachmentHeight = attachmentRows * USER_ATTACHMENT_ROW_HEIGHT_PX; |
| 82 | return USER_BASE_HEIGHT_PX + estimatedLines * LINE_HEIGHT_PX + attachmentHeight; |
| 83 | } |
| 84 | |
| 85 | // `system` messages are not rendered in the chat timeline, but keep a stable |
| 86 | // explicit branch in case they are present in timeline data. |
| 87 | const charsPerLine = estimateCharsPerLineForAssistant(layout.timelineWidthPx); |
| 77 | 88 | const estimatedLines = estimateWrappedLineCount(message.text, charsPerLine); |
| 78 | | const attachmentCount = message.attachments?.length ?? 0; |
| 79 | | const attachmentRows = Math.ceil(attachmentCount / ATTACHMENTS_PER_ROW); |
| 80 | | const attachmentHeight = attachmentRows * USER_ATTACHMENT_ROW_HEIGHT_PX; |
| 81 | | return USER_BASE_HEIGHT_PX + estimatedLines * LINE_HEIGHT_PX + attachmentHeight; |
| 89 | return ASSISTANT_BASE_HEIGHT_PX + estimatedLines * LINE_HEIGHT_PX; |
| 82 | 90 | } |