Skip to content

Comments

dbeaver/pro#8068 [CB] Fix: form reload on save and AI settings language#4140

Open
SychevAndrey wants to merge 7 commits intodevelfrom
8068-cb-ai-language-dropdown-improvement
Open

dbeaver/pro#8068 [CB] Fix: form reload on save and AI settings language#4140
SychevAndrey wants to merge 7 commits intodevelfrom
8068-cb-ai-language-dropdown-improvement

Conversation

@SychevAndrey
Copy link
Contributor

Don't autoselect on Enter if allowCustomValue

…een loaded=false and savingPromise

Problem:
FormPart.save() sets loaded=false after successful save, expecting
useAutoLoad to call load() and reload data from server. However,
load() is blocked by formState.savingPromise guard (added recently in dbeaver/pro#8151, 9c406a4),
which is only cleared later in FormState.save() finally block.
By the time savingPromise is cleared, no observable changes trigger
a React re-render, so useAutoLoad never retries — loaded stays false
forever and isChanged always returns false, permanently disabling
the Save button.

Solution:
Make FormPart.save() self-contained by adding an inline post-save
reload. After saveChanges(), set loaded=false (so setInitialState
resets both initialState and state), call loader() directly, then
set loaded=true. This eliminates the dependency on the external
useAutoLoad mechanism for post-save reload, avoiding the race
condition with savingPromise entirely.
When allowCustomValue is enabled, pressing Enter was selecting
an auto-highlighted item from the dropdown instead of keeping
the user's typed value. Disable autoSelect and close the popover
via Ariakit store on Enter to match the blur behavior.
Comment on lines 119 to 124
try {
await this.loader();
this.exception = null;
} finally {
this.loaded = true;
}
Copy link
Member

Choose a reason for hiding this comment

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

This should not be here, form will be automatically loaded after saving in another process. Loading is not a part of saving so loading error should not be handled in this place. And loading should not be triggered here

@Wroud
Copy link
Member

Wroud commented Feb 16, 2026

You described a bug with previous fix with no proper observable, this can be fixed by modifying one of the loading state interface flags (you can set isOutdated to false and isLoaded to true) there is already mechanism for such cases, so you need to fix a bug, not modify behavior. In some cases there is no need to load data after saving if form closed or data was modified imperatively.

@SychevAndrey SychevAndrey requested a review from Wroud February 18, 2026 12:52
Copy link
Member

@Wroud Wroud left a comment

Choose a reason for hiding this comment

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

I will suggest the next solution:
in the ILoadableState interface:

  1. add optional field isLoadable (you might choose a different name, but keep in mind that CachedResource has this field already, so if you will use different name, it's better to rename isLodable in the CachedResource to that name)

in the useAutoLoad:

  1. In getComputed, add a call to the isLoadable to trigger re-render when this flag changes
  2. In the loadFunctionName function, skip loading the call if isLoadable?.() === false

in the FormPart class:

  1. Implement the isLoadable function return !this.formState.savingPromise
  2. Use this new function in the load function instead of this.formState.savingPromise

motivation:

  1. There might be many parts with heavy data in a single form, we don't want to load all this data until the user switches to the specified part
  2. We can't just set the current state to the initialState because there are sometimes bugs on the backend side or concurrent collisions resulting in different frontend and backend state

}

this.loaded = false;
this.setInitialState(toJS(this.state));
Copy link
Member

Choose a reason for hiding this comment

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

this is very bad idea, because backend might return different value for state

@SychevAndrey SychevAndrey requested a review from Wroud February 20, 2026 09:11
getComputed(
// activate mobx subscriptions
() => (!loader.isLoaded() || loader.isOutdated?.() === true) && !loader.isError(),
() => (!loader.isLoaded() || loader.isOutdated?.() === true) && !loader.isError() && loader.isLoadable?.() !== false,
Copy link
Member

Choose a reason for hiding this comment

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

loader.isLoadable?.() === true ?
as !== false will include undefined

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.

3 participants