Skip to content

fix(diff-view): make auto-closing edited files opt-in#720

Merged
edelauna merged 1 commit into
mainfrom
issue/719
Jun 25, 2026
Merged

fix(diff-view): make auto-closing edited files opt-in#720
edelauna merged 1 commit into
mainfrom
issue/719

Conversation

@edelauna

@edelauna edelauna commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Related GitHub Issue

Closes: #719

Description

autoCloseZooOpenedFiles defaulted to true, so on upgrade every edited file's tab was closed the instant its diff was accepted — reversing years of prior behavior with no opt-in. This was the core of the community-reported regression ("the editor in the right frame does not show anymore"; "files being edited no longer show up"). The checkbox only became user-toggleable after #668 fixed #667 (where it couldn't be unchecked), so upgraders had no escape hatch until that follow-up shipped.

This PR flips the default to opt-in (false) so edited files stay open by default (the long-standing behavior), and centralizes the three auto-close defaults in a single source of truth so the value can't silently diverge across consumers again — that same divergence (saved-but-not-read-back) is what allowed the #667 bug to slip through in the first place.

How:

  • Adds DEFAULT_AUTO_CLOSE_ZOO_OPENED_FILES / _AFTER_USER_EDITED / _NEW_FILES constants to @roo-code/types (mirroring the existing DEFAULT_WRITE_DELAY_MS pattern). Deliberately using exported constants rather than zod .default(...) to match the convention used by every other boolean setting in global-settings.ts.
  • All consumers read the constants instead of carrying their own ?? true / ?? false:
    • DiffViewProvider.saveChanges (accept path)
    • DiffViewProvider.revertChanges (deny path)
    • DiffViewProvider.keepOrCloseEditedFile signature defaults + decision-table comment
    • ClineProvider.getStateToPostToWebview
    • UISettings (3 checkboxes)
    • SettingsViewthe save payload. This one matters most: without it, a user who never touched the checkbox would have true written back to global state on the next save, silently undoing the opt-in default.

Note on interaction: with the new default, enabling only autoCloseZooOpenedFilesAfterUserEdited no longer closes touched tabs on its own — the override is (and was documented as) a refinement that has no effect when the base setting is off. The affected test was updated to set both.

Test Procedure

Node 20.20.2 (the repo's required version). Unit tests (all green):

# extension (src package)
pnpm exec vitest run integrations/editor/__tests__/DiffViewProvider.spec.ts   # 70 passed
pnpm exec vitest run core/webview/__tests__/ClineProvider.spec.ts -t autoClose  # 3 passed

# webview-ui
pnpm exec vitest run src/components/settings/__tests__/UISettings.spec.tsx                       # 15 passed
pnpm exec vitest run src/components/settings/__tests__/SettingsView.change-detection.spec.tsx    # 2 passed

Type checks (both clean): pnpm exec tsc --noEmit in src/ and webview-ui/. Prettier + eslint clean on all changed files.

New/changed coverage:

  • Added DiffViewProvider test: transient tab is kept when autoCloseZooOpenedFiles is unset (the opt-in default).
  • Added UISettings test: checkbox is unchecked when the prop is unset (regression guard against re-introducing ?? true).
  • Updated the legacy userTouchedDocument close/keep behavior suite to enable auto-close explicitly in its getState mock — those tests assert the close path, which is no longer the default.

Manual repro (reviewers): with all settings at defaults, have Zoo edit an existing file and accept the diff → the file's tab should remain open in the editor (previously it closed immediately). Toggling "Auto-close files Zoo opened" on restores the close-on-accept behavior.

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.

Screenshots / Videos

No visible UI layout change — only the default checked-state of one existing checkbox flips (checked → unchecked).

Documentation Updates

  • No documentation updates are required.
  • Yes, documentation updates are required. The documented default behavior of "Auto-close files Zoo opened" changes from on to off (opt-in). Any user-facing docs/settings reference that states or implies the file is closed after editing should be updated to reflect that edited files now stay open by default.

Additional Notes

Get in Touch

Summary by CodeRabbit

  • New Features

    • Added a shared default for “auto-close opened files” settings, including separate defaults for edited and new files.
    • Updated the settings UI to reflect the new opt-in default behavior for these options.
  • Bug Fixes

    • Fixed inconsistent auto-close behavior across the app by using the same defaults everywhere.
    • Adjusted file/tab handling so unopened or unchanged transient tabs are no longer closed unexpectedly when settings are unset.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 71e74e19-6a2c-4eb5-ac41-1966439cbcf2

📥 Commits

Reviewing files that changed from the base of the PR and between 0084cc8 and b458419.

📒 Files selected for processing (8)
  • packages/types/src/global-settings.ts
  • src/core/webview/ClineProvider.ts
  • src/core/webview/__tests__/ClineProvider.spec.ts
  • src/integrations/editor/DiffViewProvider.ts
  • src/integrations/editor/__tests__/DiffViewProvider.spec.ts
  • webview-ui/src/components/settings/SettingsView.tsx
  • webview-ui/src/components/settings/UISettings.tsx
  • webview-ui/src/components/settings/__tests__/UISettings.spec.tsx

📝 Walkthrough

Walkthrough

This PR centralizes the default values for the three Zoo auto-close settings, then updates the webview state, settings UI, and diff cleanup paths to read those shared defaults. Tests were adjusted to expect autoCloseZooOpenedFiles to default to off.

Changes

Zoo auto-close defaults

Layer / File(s) Summary
Shared defaults contract
packages/types/src/global-settings.ts
Exports default values for the three Zoo auto-close settings in the shared settings module.
Webview state serialization
src/core/webview/ClineProvider.ts, src/core/webview/__tests__/ClineProvider.spec.ts
Posts the shared defaults in webview state and updates the unset-value expectations in the provider spec.
Settings UI defaults
webview-ui/src/components/settings/SettingsView.tsx, webview-ui/src/components/settings/UISettings.tsx, webview-ui/src/components/settings/__tests__/UISettings.spec.tsx
Uses the shared defaults when rendering the three checkboxes and when submitting settings updates, with a new unchecked default-state test.
Diff tab auto-close behavior
src/integrations/editor/DiffViewProvider.ts, src/integrations/editor/__tests__/DiffViewProvider.spec.ts
Reads the shared defaults in save/revert cleanup and updates the decision-table tests for the opt-in behavior and the after-edit case.

Sequence Diagram(s)

sequenceDiagram
  participant ClineProvider
  participant SettingsView
  participant UISettings
  ClineProvider->>SettingsView: post webview state with autoCloseZooOpened* defaults
  SettingsView->>UISettings: pass checkbox props
  SettingsView->>ClineProvider: send updateSettings(autoCloseZooOpened*)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Zoo-Code-Org/Zoo-Code#589 — Also changes src/integrations/editor/DiffViewProvider.ts in the save/revert cleanup path that decides whether to close Zoo-opened tabs.
  • Zoo-Code-Org/Zoo-Code#668 — Also touches src/core/webview/ClineProvider.ts around the same autoCloseZooOpenedFiles* fields and their state round-trip.

Suggested reviewers

  • taltas
  • JamesRobert20
  • hannesrudolph
  • navedmerchant

Poem

A bunny hopped through settings bright,
and tucked the defaults just right.
Tabs stay open, by choice not fate,
unless I say, “close now, mate.”
🐇 Thump!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: making edited-file auto-closing opt-in.
Description check ✅ Passed The PR description is mostly complete and includes the linked issue, implementation details, tests, checklist, and documentation notes.
Linked Issues check ✅ Passed The changes satisfy #719 and #667 by flipping the default off, centralizing defaults, and updating all consumers and tests.
Out of Scope Changes check ✅ Passed All modified files support the auto-close default change or its tests; no unrelated scope is evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue/719

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/integrations/editor/DiffViewProvider.ts 88.88% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@edelauna edelauna marked this pull request as ready for review June 25, 2026 15:23
@edelauna edelauna added this pull request to the merge queue Jun 25, 2026
Merged via the queue into main with commit 1b26b6a Jun 25, 2026
18 checks passed
@edelauna edelauna deleted the issue/719 branch June 25, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants