Skip to content

Conversation

@brunobergher
Copy link
Collaborator

@brunobergher brunobergher commented Sep 30, 2025

Description

Up to now, the "Done" button in settings would always warn about unsaved changes, even when there weren't any.
This fixes the behavior of one of the panels, which was flipping a dirty bit unnecessarily.

Test Procedure

There are automated tests, but to manually check it:

  1. Go to settings
  2. Click done – you should get no popup
  3. Go back to settings
  4. Change something
  5. Click done – you should get a popup

Important

Fixes overeager unsaved changes dialog in settings by refining change detection logic in SettingsView.tsx and ApiOptions.tsx.

  • Behavior:
    • Fixes overeager unsaved changes dialog in SettingsView.tsx by refining change detection logic.
    • Adjusts setApiConfigurationField in ApiOptions.tsx to pass false for non-user actions.
  • Tests:
    • Adds SettingsView.change-detection.spec.tsx to test change detection logic.
    • Adds SettingsView.unsaved-changes.spec.tsx to verify unsaved changes dialog behavior.
  • Misc:
    • Updates setCachedState logic in SettingsView.tsx to prevent unnecessary change detection.

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

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. bug Something isn't working labels Sep 30, 2025
// This prevents the dirty state when the component initializes and auto-syncs values
const isInitialSync = !isUserAction && previousValue === undefined && value !== undefined
// Treat undefined, null, and empty string as uninitialized states
const isInitialSync =
Copy link

Choose a reason for hiding this comment

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

Nice improvement: treating undefined, null, and empty string as uninitialized prevents false change detection. Consider extracting this check into a helper for reuse and clarity.

This comment was generated because it violated a code review rule: irule_tTqpIuNs8DV0QFGj.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 30, 2025
Copy link

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

I found some issues that need attention. See inline comments for details.

setApiConfigurationField("apiModelId", selectedModelId)
// Pass false as third parameter to indicate this is not a user action
// This is an internal sync, not a user-initiated change
setApiConfigurationField("apiModelId", selectedModelId, false)
Copy link

Choose a reason for hiding this comment

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

[P2] Internal sync path correctly marks isUserAction=false. To avoid future drift, audit similar internal sync sites (provider/model defaults, migrations) and consider centralizing via a small helper to ensure they always pass false.

const isInitialSync = !isUserAction && previousValue === undefined && value !== undefined
// Treat undefined, null, and empty string as uninitialized states
const isInitialSync =
!isUserAction &&
Copy link

Choose a reason for hiding this comment

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

[P3] The isInitialSync detection is duplicated logic you’ll likely want consistent across fields. Consider extracting a small helper (e.g., isInitializingValue(prev, next, isUserAction)) and unit-testing it so future edits don’t regress this behavior.

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Sep 30, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 30, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Sep 30, 2025
@mrubens mrubens merged commit 9bcd991 into main Oct 1, 2025
26 checks passed
@mrubens mrubens deleted the bb/unsaved-settings branch October 1, 2025 11:39
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Oct 1, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs Review size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants