Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions src/frontend/web/von_interface/static/js/chatTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -2263,17 +2263,18 @@ function clampThinkingCardBodyHeightPx(value) {
);
}

function getThinkingCardInitialBodyHeightPx(detailEl = null) {
const contentHeight = (detailEl instanceof HTMLElement && Number.isFinite(detailEl.scrollHeight))
? detailEl.scrollHeight
: THINKING_CARD_BODY_DEFAULT_HEIGHT_PX;
return clampThinkingCardBodyHeightPx(
Math.max(contentHeight, THINKING_CARD_BODY_DEFAULT_HEIGHT_PX)
);
}

function ensureThinkingCardBodyHeightPx(request, detailEl = null) {
if (!request || typeof request !== 'object') {
const contentHeight = (detailEl instanceof HTMLElement && Number.isFinite(detailEl.scrollHeight))
? detailEl.scrollHeight
: THINKING_CARD_BODY_DEFAULT_HEIGHT_PX;
return clampThinkingCardBodyHeightPx(
Math.min(
Math.max(contentHeight, THINKING_CARD_BODY_MIN_HEIGHT_PX),
THINKING_CARD_BODY_DEFAULT_HEIGHT_PX
)
);
return getThinkingCardInitialBodyHeightPx(detailEl);
}

const existingHeight = Number(request.thinkingCardBodyHeightPx);
Expand All @@ -2282,15 +2283,7 @@ function ensureThinkingCardBodyHeightPx(request, detailEl = null) {
return request.thinkingCardBodyHeightPx;
}

const contentHeight = (detailEl instanceof HTMLElement && Number.isFinite(detailEl.scrollHeight))
? detailEl.scrollHeight
: THINKING_CARD_BODY_DEFAULT_HEIGHT_PX;
request.thinkingCardBodyHeightPx = clampThinkingCardBodyHeightPx(
Math.min(
Math.max(contentHeight, THINKING_CARD_BODY_MIN_HEIGHT_PX),
THINKING_CARD_BODY_DEFAULT_HEIGHT_PX
)
);
request.thinkingCardBodyHeightPx = getThinkingCardInitialBodyHeightPx(detailEl);
return request.thinkingCardBodyHeightPx;
}

Expand Down
22 changes: 19 additions & 3 deletions src/frontend/web/von_interface/static/js/test/chatTab.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8346,12 +8346,12 @@ describe('thinking card toggle accessibility', () => {
const retained = getRetainedThinkingCardElements();
retained.toggleButton.click();

expect(retained.detail.style.height).toBe('120px');
expect(retained.sizeDecreaseButton.disabled).toBe(true);
expect(retained.detail.style.height).toBe('220px');
expect(retained.sizeDecreaseButton.disabled).toBe(false);
expect(retained.sizeIncreaseButton.disabled).toBe(false);

retained.sizeIncreaseButton.click();
expect(retained.detail.style.height).toBe('200px');
expect(retained.detail.style.height).toBe('300px');
expect(retained.sizeDecreaseButton.disabled).toBe(false);

retained.sizeIncreaseButton.click();
Expand Down Expand Up @@ -8431,6 +8431,22 @@ describe('active thinking card manual resize persistence', () => {
};
}

test('starts tall enough for the initial thinking-card content', () => {
const request = createActiveThinkingRequest();
__testOnly_setThinkingCardRequests(request, null);

const detail = document.getElementById('loadingIndicatorDetail');
Object.defineProperty(detail, 'scrollHeight', {
configurable: true,
value: 360
});

__testOnly_refreshThinkingCardProgressUi(request);

expect(request.thinkingCardBodyHeightPx).toBe(360);
expect(detail.style.height).toBe('360px');
});

test('keeps a manually dragged active thinking-card height across live refreshes', () => {
const request = createActiveThinkingRequest();
__testOnly_setThinkingCardRequests(request, null);
Expand Down
Loading