fix(ambient): re-check active mode after the judge call (coexistence TOCTOU)
This commit is contained in:
@@ -236,6 +236,16 @@ func (s *Sentinel) evaluate(ctx context.Context) {
|
||||
cancel()
|
||||
|
||||
s.mu.Lock()
|
||||
// A mode may have activated during the (off-lock) brain call; re-check so a
|
||||
// result computed while idle is not surfaced over an now-active mode.
|
||||
if s.activeModeLocked() != "" {
|
||||
changed := s.clearLocked()
|
||||
s.mu.Unlock()
|
||||
if changed {
|
||||
s.fireOnChange()
|
||||
}
|
||||
return
|
||||
}
|
||||
s.lastEvalTitles = joined
|
||||
if err != nil {
|
||||
s.mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user