| 1 | package main |
| 2 | |
| 3 | import "reasonix/internal/control" |
| 4 | |
| 5 | // abort releases admission before entering the serialized rebuild transaction. |
| 6 | func (a *App) applyTurnModelSettings(tab *WorkspaceTab, ctrl control.SessionAPI, usingApplied bool, abort func()) (bool, error) { |
| 7 | if a.ctx == nil || usingApplied { |
| 8 | return false, nil |
| 9 | } |
| 10 | needed, err := modelSettingsNeedApply(ctrl) |
| 11 | if err != nil { |
| 12 | abort() |
| 13 | return false, newModelApplicationError(ctrl, err) |
| 14 | } |
| 15 | if !needed { |
| 16 | return false, nil |
| 17 | } |
| 18 | a.mu.RLock() |
| 19 | pending := tab.PendingCreateOperationID != "" |
| 20 | a.mu.RUnlock() |
| 21 | abort() |
| 22 | if pending { |
| 23 | return false, control.ErrModelChoiceStale |
| 24 | } |
| 25 | if err := a.refreshTabModelSettings(tab); err != nil { |
| 26 | return false, err |
| 27 | } |
| 28 | return true, nil |
| 29 | } |
| 30 |