Skip to content

feat: add setting to auto-expand diffs in chat messages#11316

Draft
roomote[bot] wants to merge 1 commit intomainfrom
feature/auto-expand-diffs
Draft

feat: add setting to auto-expand diffs in chat messages#11316
roomote[bot] wants to merge 1 commit intomainfrom
feature/auto-expand-diffs

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Feb 8, 2026

Related GitHub Issue

Closes: #10955

Description

This PR attempts to address Issue #10955. It adds a new boolean setting autoExpandDiffs (default: false) that automatically expands diff views in "Roo wants to edit this file" chat messages.

Key implementation details:

  • Follows the existing pattern used by reasoningBlockCollapsed for the full settings flow
  • When enabled, a useEffect in ChatView detects diff tool messages (editedExistingFile, appliedDiff, insertContent, searchAndReplace, newFileCreated) and auto-expands them
  • Diffs remain constrained to max-h-[300px] (300px) with overflow-y: auto, so even auto-expanded diffs will not be too verbose -- they get a scrollbar for anything taller than 300px
  • The setting is exposed in Settings > UI section with a checkbox toggle
  • Default is false to preserve existing behavior (collapsed diffs)

Files changed:

  • packages/types/src/global-settings.ts -- Add autoExpandDiffs to schema
  • packages/types/src/vscode-extension-host.ts -- Add to ExtensionState type
  • src/core/webview/ClineProvider.ts -- Wire setting through state
  • webview-ui/src/context/ExtensionStateContext.tsx -- Default value and context
  • webview-ui/src/components/chat/ChatView.tsx -- Auto-expand logic
  • webview-ui/src/components/settings/UISettings.tsx -- UI toggle
  • webview-ui/src/components/settings/SettingsView.tsx -- Wire prop
  • webview-ui/src/i18n/locales/en/settings.json -- English translations
  • Test fixture updates for settings tests

Feedback and guidance are welcome.

Test Procedure

  1. Enable "Auto-expand diffs in chat messages" in Settings > UI
  2. Ask Roo to edit a file -- the diff should auto-expand in the chat
  3. Verify the diff container is constrained to 300px max height with scrollbar
  4. Disable the setting -- diffs should revert to collapsed (click to expand)
  5. Toggle still works manually even when auto-expand is on

Automated tests:

  • UISettings.spec.tsx -- 4/4 passing (updated with new prop)
  • SettingsView.change-detection.spec.tsx -- 3/3 passing (updated fixtures)
  • SettingsView.unsaved-changes.spec.tsx -- 3/3 passing (updated fixtures)
  • ExtensionStateContext.spec.tsx -- 9/9 passing
  • All 14 lint tasks passing, all 14 type-check tasks passing

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

This addresses the user's concern about verbosity: the CodeAccordian component applies max-h-[300px] on the expanded content container, so even auto-expanded diffs are height-constrained with a scrollbar.


Important

Adds autoExpandDiffs setting to auto-expand diffs in chat messages, with UI and tests updated accordingly.

  • Behavior:
    • Adds autoExpandDiffs setting to auto-expand diffs in chat messages, defaulting to false.
    • ChatView.tsx uses useEffect to auto-expand diffs for specific message types when setting is enabled.
    • Diffs are constrained to 300px height with scrollbar.
  • Settings:
    • UISettings.tsx and SettingsView.tsx updated to include autoExpandDiffs toggle.
    • global-settings.ts schema updated to include autoExpandDiffs.
  • Tests:
    • Updates to UISettings.spec.tsx, SettingsView.change-detection.spec.tsx, and SettingsView.unsaved-changes.spec.tsx to cover new setting.
  • Misc:
    • English translations added to settings.json for new setting.

This description was created by Ellipsis for d1bddd3. You can customize this summary. It will automatically update as commits are pushed.

Adds a new boolean setting `autoExpandDiffs` (default: false) that
automatically expands diff views in "Roo wants to edit this file" chat
messages. Diffs are still constrained to max-h-[300px] with scrollbar.

Changes:
- Add autoExpandDiffs to GlobalSettings schema (packages/types)
- Add autoExpandDiffs to ExtensionState type (packages/types)
- Wire setting through ClineProvider state to webview
- Add auto-expand logic in ChatView for diff tool messages
- Add UI toggle in Settings > UI section
- Add English i18n translations
- Update test fixtures

Closes #10955
@roomote
Copy link
Contributor Author

roomote bot commented Feb 8, 2026

Rooviewer Clock   See task

Reviewed. The settings plumbing, types, UI toggle, and i18n look correct. Found 2 issues in the auto-expand useEffect in ChatView.tsx:

  • expandedRows in the dependency array causes unnecessary re-executions (every user expand/collapse re-iterates all messages with JSON.parse) and a double-run cycle on auto-expand. Use the functional updater of setExpandedRows and drop expandedRows from deps.
  • Auto-expansion triggers the existing expansion-tracking effect (lines 509-529) which disables stickyFollowRef (auto-scroll). During an active task, each new diff auto-expand stops the chat from scrolling to new messages.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Comment on lines +537 to +566
useEffect(() => {
if (!autoExpandDiffs) {
return
}

const newExpansions: Record<number, boolean> = {}

for (const msg of modifiedMessages) {
// Skip messages already tracked in expandedRows
if (expandedRows[msg.ts] !== undefined) {
continue
}

// Check if this message contains a diff tool
if (msg.text) {
try {
const tool = JSON.parse(msg.text)
if (tool.tool && DIFF_TOOL_TYPES.has(tool.tool)) {
newExpansions[msg.ts] = true
}
} catch {
// Not valid JSON, skip
}
}
}

if (Object.keys(newExpansions).length > 0) {
setExpandedRows((prev) => ({ ...prev, ...newExpansions }))
}
}, [modifiedMessages, autoExpandDiffs, expandedRows, DIFF_TOOL_TYPES])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including expandedRows in the dependency array here means this effect re-runs on every expansion/collapse (user or auto), iterating all modifiedMessages and JSON.parse-ing each one. It also causes a double execution when it auto-expands: the setExpandedRows call updates expandedRows, which re-triggers the effect (the second run is a no-op but still wasteful). You can fix both problems by moving the logic into the functional updater of setExpandedRows and dropping expandedRows from deps:

Suggested change
useEffect(() => {
if (!autoExpandDiffs) {
return
}
const newExpansions: Record<number, boolean> = {}
for (const msg of modifiedMessages) {
// Skip messages already tracked in expandedRows
if (expandedRows[msg.ts] !== undefined) {
continue
}
// Check if this message contains a diff tool
if (msg.text) {
try {
const tool = JSON.parse(msg.text)
if (tool.tool && DIFF_TOOL_TYPES.has(tool.tool)) {
newExpansions[msg.ts] = true
}
} catch {
// Not valid JSON, skip
}
}
}
if (Object.keys(newExpansions).length > 0) {
setExpandedRows((prev) => ({ ...prev, ...newExpansions }))
}
}, [modifiedMessages, autoExpandDiffs, expandedRows, DIFF_TOOL_TYPES])
useEffect(() => {
if (!autoExpandDiffs) {
return
}
setExpandedRows((prev) => {
const newExpansions: Record<number, boolean> = {}
for (const msg of modifiedMessages) {
if (prev[msg.ts] !== undefined) {
continue
}
if (msg.text) {
try {
const tool = JSON.parse(msg.text)
if (tool.tool && DIFF_TOOL_TYPES.has(tool.tool)) {
newExpansions[msg.ts] = true
}
} catch {
// Not valid JSON, skip
}
}
}
if (Object.keys(newExpansions).length > 0) {
return { ...prev, ...newExpansions }
}
return prev
})
}, [modifiedMessages, autoExpandDiffs, DIFF_TOOL_TYPES])

Fix it with Roo Code or mention @roomote and request a fix.

Comment on lines +537 to +566
useEffect(() => {
if (!autoExpandDiffs) {
return
}

const newExpansions: Record<number, boolean> = {}

for (const msg of modifiedMessages) {
// Skip messages already tracked in expandedRows
if (expandedRows[msg.ts] !== undefined) {
continue
}

// Check if this message contains a diff tool
if (msg.text) {
try {
const tool = JSON.parse(msg.text)
if (tool.tool && DIFF_TOOL_TYPES.has(tool.tool)) {
newExpansions[msg.ts] = true
}
} catch {
// Not valid JSON, skip
}
}
}

if (Object.keys(newExpansions).length > 0) {
setExpandedRows((prev) => ({ ...prev, ...newExpansions }))
}
}, [modifiedMessages, autoExpandDiffs, expandedRows, DIFF_TOOL_TYPES])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this effect auto-expands diffs via setExpandedRows, the existing effect at lines 509-529 will detect those transitions (from undefined to true) and set stickyFollowRef.current = false, disabling auto-scroll. It cannot distinguish between user-initiated and programmatic expansions. During an active task with autoExpandDiffs enabled, each new diff message gets auto-expanded, triggers that detection, and disables auto-scroll -- the user has to manually scroll to see subsequent messages, which undermines the purpose of this feature. Consider guarding against this by setting a ref flag (e.g. isAutoExpandingRef.current = true) before calling setExpandedRows here, and checking it in the expansion-tracking effect to skip the sticky-follow disable.

Fix it with Roo Code or mention @roomote and request a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add setting to auto-expand diffs in "Roo wants to edit this file" chat messages

1 participant