[BUG] Diff view scroll position not preserved -- viewport jumps on open and after Save/Deny
Problem (one or two sentences)
When Zoo Code applies a file edit and opens the diff editor, the viewport is not reliably
positioned at the changed region. After the user clicks "Save" or "Deny", the viewport
always jumps to the top of the file, destroying their scroll position.
Context (who is affected and when)
Affects all users working on files longer than a screen height. The disruption compounds
in long files and in sessions with many edits. Two distinct failure points:
- The diff editor opens at the wrong scroll position -- behavior depends inconsistently
on whether the edit is a pure addition, pure deletion, or mixed.
- After clicking "Save" or "Deny", the viewport unconditionally resets to the top of
the file, regardless of where the user was before the diff appeared.
Additionally, files that were not already open before the diff are left as open tabs
after Save/Deny, polluting the user's tab bar.
Reproduction steps
Note: When testing manually, instruct Zoo to use the diff tool so that it does not attempt to use shell commands to apply the edits.
Scenario A -- file is ALREADY OPEN in the editor
| Operation |
Diff scroll behavior |
| Add 1 line at end |
Does NOT scroll to change |
| Remove 1 line at end |
Does NOT scroll to change |
| Remove 1 line + add 1 line |
DOES scroll to change |
Steps:
- Open a file of several hundred lines in VS Code.
- Ask Zoo Code to append a line near the end of the file (pure addition).
- Observe: diff editor opens with viewport at the top, not the changed line.
- Click "Save" or "Deny".
- Observe: viewport jumps to the top of the file.
- Repeat steps 2-5 with a pure deletion and then a mixed remove+add edit.
Scenario B -- file is NOT already open
| Operation |
Diff scroll behavior |
| Remove 1 line at end |
Opens file -- does NOT scroll to change |
| Add 1 line at end |
Opens file -- scrolls to end (correct) |
| Remove 1 line + add 1 line |
Opens file -- does NOT scroll to change |
Steps:
- Close the target file if it is open.
- Ask Zoo Code to edit a region near the end of the file.
- Observe: diff editor opens; viewport position depends on operation type (see table).
- Click "Save" or "Deny".
- Observe: viewport jumps to the top. The file tab remains open even though it was not
open before Zoo Code intervened.
Expected result
- The diff editor always opens with the viewport positioned at the first changed line,
regardless of whether the change is a pure addition, pure deletion, or mixed.
- After "Save": if the file was open before the diff, the viewport is restored to its
pre-diff scroll position. If the file was not open before, the tab is closed.
- After "Deny": same behavior as "Save".
Actual result
- The diff editor inconsistently positions the viewport. Pure additions and pure
deletions do not scroll to the change; only mixed (remove + add) edits sometimes do.
- After "Save" or "Deny", the viewport always resets to the top of the file.
- Files that were not previously open remain as open tabs after Save/Deny, polluting the
tab bar.
Variations tried
Occurs regardless of API provider or model. Observed with both write_to_file and
apply_diff tool calls.
App Version
(fill in current Zoo Code version before filing)
API Provider
Not Applicable -- reproducible with any provider and model.
Upstream prior art
This is a long-standing unresolved bug inherited from the Roo-Code codebase. Related
upstream issues (none resolved, none fixed):
Scroll / viewport
Tab management (related UX degradation)
Root cause note (from #8112)
Re-opening the document via the VS Code diff API resets the viewport to line 1.
When the target file is already the active editor, re-opening it resets the scroll
position unconditionally. The prescribed fix: when the target file is the currently
active editor, avoid re-opening it; apply the change in-place to preserve the viewport.
When the file is not already open, continue using the diff UI but scroll the diff
editor to the first changed line before displaying it.
The upstream proposal for tab cleanup (#6003) introduced a PostEditBehaviorUtils class
inside DiffViewProvider to centralize post-edit tab tracking and closure, with two
user settings (autoCloseRooTabs, autoCloseAllRooTabs) -- but this was never merged.
[BUG] Diff view scroll position not preserved -- viewport jumps on open and after Save/Deny
Problem (one or two sentences)
When Zoo Code applies a file edit and opens the diff editor, the viewport is not reliably
positioned at the changed region. After the user clicks "Save" or "Deny", the viewport
always jumps to the top of the file, destroying their scroll position.
Context (who is affected and when)
Affects all users working on files longer than a screen height. The disruption compounds
in long files and in sessions with many edits. Two distinct failure points:
on whether the edit is a pure addition, pure deletion, or mixed.
the file, regardless of where the user was before the diff appeared.
Additionally, files that were not already open before the diff are left as open tabs
after Save/Deny, polluting the user's tab bar.
Reproduction steps
Note: When testing manually, instruct Zoo to use the diff tool so that it does not attempt to use shell commands to apply the edits.
Scenario A -- file is ALREADY OPEN in the editor
Steps:
Scenario B -- file is NOT already open
Steps:
open before Zoo Code intervened.
Expected result
regardless of whether the change is a pure addition, pure deletion, or mixed.
pre-diff scroll position. If the file was not open before, the tab is closed.
Actual result
deletions do not scroll to the change; only mixed (remove + add) edits sometimes do.
tab bar.
Variations tried
Occurs regardless of API provider or model. Observed with both
write_to_fileandapply_difftool calls.App Version
(fill in current Zoo Code version before filing)
API Provider
Not Applicable -- reproducible with any provider and model.
Upstream prior art
This is a long-standing unresolved bug inherited from the Roo-Code codebase. Related
upstream issues (none resolved, none fixed):
Scroll / viewport
Tab management (related UX degradation)
Root cause note (from #8112)
The upstream proposal for tab cleanup (#6003) introduced a
PostEditBehaviorUtilsclassinside
DiffViewProviderto centralize post-edit tab tracking and closure, with twouser settings (
autoCloseRooTabs,autoCloseAllRooTabs) -- but this was never merged.