Repository: microsoft/vscode
File: src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatQuestionCarouselPart.ts (TypeScript)

Code before:
				const defaultOption = defaultOptionId !== undefined
					? question.options?.find(opt => opt.id === defaultOptionId)
					: undefined;
				const selectedValue = defaultOption?.value;

				// Always return structured format for single-select (freeform is always shown)
				return selectedValue !== undefined ? { selectedValue, freeformValue: undefined } : undefined;
			}

			case 'multiSelect': {
				const defaultIds = Array.isArray(question.defaultValue)
					? question.defaultValue
					: (typeof question.defaultValue === 'string' ? [question.defaultValue] : []);
				const selectedValues = question.options
					?.filter(opt => defaultIds.includes(opt.id))
					.map(opt => opt.value)
					.filter(v => v !== undefined) ?? [];

				// Always return structured format for multi-select (freeform is always shown)
				return selectedValues.length > 0 ? { selectedValues, freeformValue: undefined } : undefined;
			}

			default:
				return question.defaultValue;
		}
	}

	/**
	 * Returns whether auto-focus should be enabled.
	 * Disabled when screen reader mode is active or when explicitly disabled via options.
	 */
	private _shouldAutoFocus(): boolean {
		if (this._options.shouldAutoFocus === false) {
			return false;
		}
		// Disable auto-focus for screen reader users to allow them to read the question first
		return !this._accessibilityService.isScreenReaderOptimized();
	}

	/**
	 * Updates the aria-label of the carousel container based on the current question.
	 */
	private _updateAriaLabel(): void {
		const question = this.carousel.questions[this._currentIndex];
		if (!question) {
			this.domNode.setAttribute('aria-label', localize('chat.questionCarousel.label', 'Chat question'));
			return;
		}

		const questionText = question.message ?? question.title;
		const messageContent = this.getQuestionText(questionText);

Review comment (suggestion):
I still don't really understand why this is necessary. Seems like `scanDomNode` is meant to measure things for you.

Code after:
		const scrollableNode = inputScrollable.getDomNode();
		const scrollableContent = scrollableNode.firstElementChild;
		if (!dom.isHTMLElement(scrollableContent)) {
			return;
		}

		// Use the flex-resolved container height (constrained by CSS max-height)
		// instead of window.innerHeight, so the scroll viewport tracks actual chat space.
		const maxContainerHeight = this._questionContainer.clientHeight;

		const computedStyle = dom.getWindow(this._questionContainer).getComputedStyle(this._questionContainer);
		const contentVerticalPadding =
			Number.parseFloat(computedStyle.paddingTop || '0') +
			Number.parseFloat(computedStyle.paddingBottom || '0');

		const nonScrollableContentHeight = Array.from(this._questionContainer.children)
			.filter(child => child !== scrollableNode)
			.reduce((sum, child) => sum + (child as HTMLElement).offsetHeight, 0);

		const availableScrollableHeight = Math.floor(maxContainerHeight - contentVerticalPadding - nonScrollableContentHeight);
		const constrainedScrollableHeight = Math.max(0, availableScrollableHeight);

		// Constrain the content element (DomScrollableElement._element) so that
		// scanDomNode sees clientHeight < scrollHeight and enables scrolling.
		// The wrapper inherits the same constraint via CSS flex.
		scrollableContent.style.height = `${constrainedScrollableHeight}px`;
		scrollableContent.style.maxHeight = `${constrainedScrollableHeight}px`;
		inputScrollable.scanDomNode();
	}

	/**
	 * Skips the carousel with default values - called when user wants to proceed quickly.
	 * Returns defaults for all questions.
	 */
	public skip(): boolean {
		if (this._isSkipped || !this.carousel.allowSkip) {
			return false;
		}

		const defaults = this.getDefaultAnswers();
		this._options.onSubmit(defaults);

		// Reset answers to match submitted defaults for summary display
		this._answers.clear();
		for (const [key, value] of defaults) {
			this._answers.set(key, value);
		}
		this.hideAndShowSummary();
		return true;
	}