Skip to content

Commit c050eb9

Browse files
committed
Merge branch 'main' into whoisthey/language-model-input-modalities
2 parents 7ba297b + 2d28a00 commit c050eb9

3 files changed

Lines changed: 10 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919

2020
### Fixed
2121
- Send anonymous server-side PostHog events as personless so unauthenticated requests don't inflate person counts. [#1367](https://github.com/sourcebot-dev/sourcebot/pull/1367)
22+
- [EE] Fixed Ask Sourcebot mermaid diagrams overflowing their container by contain-fitting them to both width and height, and made revealing a diagram from the answer jump it into view instantly to avoid over/undershooting. [#1373](https://github.com/sourcebot-dev/sourcebot/pull/1373)
2223

2324
## [5.0.4] - 2026-06-18
2425

packages/web/src/ee/features/chat/components/chatThread/mermaidDiagram.tsx

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,6 @@ const PANEL_MIN_HEIGHT = 240;
163163
const PANEL_VIEWPORT_MARGIN = 24;
164164
// Fallback when no scroll-area ancestor can be measured.
165165
const PANEL_FALLBACK_MAX_HEIGHT = 720;
166-
// Cap on enlarging a wide diagram: at most this many column-widths wide.
167-
const PANEL_MAX_OVERFLOW_FACTOR = 2.5;
168166

169167
// Zoom limits and the button step are relative to the fitted ("100%") scale, so
170168
// the usable range and ±25% readout steps are consistent across diagram sizes.
@@ -197,10 +195,11 @@ interface DiagramFit {
197195
panelHeight: number | null;
198196
}
199197

200-
// Pure fit, as a transform scale where 1 = "fills the available width". Inline
201-
// and fullscreen contain-fit the whole diagram; the panel contain-fits unless
202-
// the diagram is wider than the column, in which case it's enlarged to use the
203-
// readable height and overflows horizontally (bounded so it can't explode).
198+
// Pure fit, as a transform scale where 1 = "fills the available width". Both the
199+
// panel and fullscreen contain-fit the whole diagram, respecting width and
200+
// height, so it never overflows the container in either dimension (zoom/pan to
201+
// inspect details). The panel additionally grows its height to the fitted
202+
// diagram, clamped to the readable area.
204203
const computeFit = (
205204
{ width: iw, height: ih }: IntrinsicSize,
206205
availWidth: number,
@@ -211,20 +210,13 @@ const computeFit = (
211210
const widthFitHeight = availWidth * (ih / iw);
212211
const heightFitScale = availHeight / widthFitHeight;
213212

213+
// Contain-fit: never wider than the box, shrink to fit the height if tall.
214+
const fitScale = Math.min(1, heightFitScale) * FIT_MARGIN;
215+
214216
if (!autoHeight) {
215-
// Contain-fit: never wider than the box, shrink to fit the height if tall.
216-
const fitScale = Math.min(1, heightFitScale) * FIT_MARGIN;
217217
return { fitScale, panelHeight: null };
218218
}
219219

220-
const isWiderThanPanel = iw > availWidth;
221-
const fitScale = (isWiderThanPanel
222-
// Enlarge into the readable height and overflow horizontally (drag to
223-
// pan); never below filling the column width, capped at N column-widths.
224-
? Math.min(Math.max(heightFitScale, 1), PANEL_MAX_OVERFLOW_FACTOR)
225-
// Contain-fit: the whole diagram stays visible.
226-
: Math.min(1, heightFitScale)) * FIT_MARGIN;
227-
228220
const panelHeight = Math.round(Math.min(availHeight, Math.max(PANEL_MIN_HEIGHT, widthFitHeight * fitScale)));
229221
return { fitScale, panelHeight };
230222
};

packages/web/src/ee/features/chat/components/chatThread/referencedSourcesListView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const ReferencedSourcesListViewComponent = ({
6262
setCollapsedDiagramIds((prev) => prev.filter((id) => id !== selectedDiagramId));
6363
const element = document.getElementById(`diagram-panel-${selectedDiagramId}`);
6464
if (element) {
65-
scrollIntoView(element, { scrollMode: 'if-needed', block: 'center', behavior: 'smooth' });
65+
scrollIntoView(element, { scrollMode: 'if-needed', block: 'center', behavior: 'instant' });
6666
}
6767
setHighlightedDiagramId(selectedDiagramId);
6868
const timeout = window.setTimeout(() => setHighlightedDiagramId(undefined), 2000);

0 commit comments

Comments
 (0)