Skip to content

Commit c9c2cf0

Browse files
luoxuanzaoQoder-AI
andauthored
refactor(chat): drop the inert min-height calculation from the live composer
End-to-end measurement showed the min-height that updateHeight() wrote never participated in layout on the CodeMirror path: the editor's height tracks its content and is capped by max-height, while the host's content-based flex minimum propagates growth to the wrapper. The computed value stayed at the 60px base in every observed state, so remove the calculation and pin the editor's min-height to the constant the variable always fell back to. The legacy textarea path keeps its own resize contract untouched. Co-authored-by: QoderAI (Qwen 3.8 Max) <qoder_ai@qoder.com>
1 parent 5e40c1e commit c9c2cf0

2 files changed

Lines changed: 6 additions & 21 deletions

File tree

‎src/features/chat/ui/composer/live-composer.ts‎

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ import {
1313
} from '@codemirror/view';
1414
import { setIcon } from 'obsidian';
1515

16-
import {
17-
calculateTextareaMaxHeight,
18-
calculateTextareaMinHeight,
19-
TEXTAREA_BASE_MIN_HEIGHT,
20-
} from '../textarea-resize';
16+
import { calculateTextareaMaxHeight } from '../textarea-resize';
2117
import {
2218
type ComposerReference,
2319
type ComposerReferenceRange,
@@ -273,27 +269,16 @@ export class LiveComposer {
273269
}
274270

275271
/**
276-
* Mirrors the textarea auto-resize contract: grows with content, capped at
277-
* a share of the view height. Metrics come from the CodeMirror scroller.
272+
* Caps the editor at a share of the view height. The editor's own height
273+
* tracks its content and the host's content-based flex minimum propagates
274+
* it to the wrapper, so only the cap needs writing here.
278275
*/
279276
private updateHeight(): void {
280277
const viewHeight = this.view.dom.closest('.qoderian-container')?.clientHeight
281278
?? this.view.dom.ownerDocument.defaultView?.innerHeight
282279
?? 0;
283-
const maxHeight = calculateTextareaMaxHeight(viewHeight);
284-
285-
const scroller = this.view.dom.querySelector<HTMLElement>('.cm-scroller');
286-
const contentHeight = scroller
287-
? Math.min(scroller.scrollHeight, maxHeight)
288-
: TEXTAREA_BASE_MIN_HEIGHT;
289-
const minHeight = calculateTextareaMinHeight({
290-
contentHeight,
291-
flexAllocatedHeight: this.view.dom.offsetHeight,
292-
});
293-
294280
this.view.dom.setCssProps({
295-
'--qoderian-textarea-min-height': `${minHeight}px`,
296-
'--qoderian-textarea-max-height': `${maxHeight}px`,
281+
'--qoderian-textarea-max-height': `${calculateTextareaMaxHeight(viewHeight)}px`,
297282
});
298283
}
299284
}

‎src/style/components/composer.css‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
height bounds) so the wrapper layout stays identical. */
2121
.qoderian-input-wrapper .qoderian-live-composer.cm-editor {
2222
flex: 1 1 auto;
23-
min-height: var(--qoderian-textarea-min-height, 60px);
23+
min-height: 60px;
2424
max-height: var(--qoderian-textarea-max-height, none);
2525
background: transparent;
2626
color: var(--text-normal);

0 commit comments

Comments
 (0)