Migrate the reflection fetch onto runFetchAsync

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-01 18:12:10 -04:00
parent 59283be733
commit 895ad342c7
+7 -13
View File
@@ -243,16 +243,12 @@ func (c *Controller) startReflectionFetchLocked() {
// bounded to reflectionHistoryN summaries and runs once per Review entry, not // bounded to reflectionHistoryN summaries and runs once per Review entry, not
// on any hot path. // on any hot path.
history := buildReflectionHistory(c.auditPath) history := buildReflectionHistory(c.auditPath)
go func() { var refl ai.Reflection
ctx, cancel := context.WithTimeout(context.Background(), reflectionTimeout) var err error
defer cancel() c.runFetchAsync(reflectionTimeout,
refl, err := reviewer.Review(ctx, finished, history) func(ctx context.Context) { refl, err = reviewer.Review(ctx, finished, history) },
func() bool { return gen != c.reflectionGen },
c.mu.Lock() func() {
if gen != c.reflectionGen {
c.mu.Unlock()
return // superseded review: discard
}
if err != nil || strings.TrimSpace(refl.Recap) == "" { if err != nil || strings.TrimSpace(refl.Recap) == "" {
c.reflectionStatus = reflectionAbsent c.reflectionStatus = reflectionAbsent
c.reflectionRecap = "" c.reflectionRecap = ""
@@ -263,9 +259,7 @@ func (c *Controller) startReflectionFetchLocked() {
c.carryForward = refl.CarryForward c.carryForward = refl.CarryForward
} }
_ = c.persistLocked() _ = c.persistLocked()
c.mu.Unlock() })
c.notify()
}()
} }
// buildReflectionFinishedLocked renders the just-finished session as a compact // buildReflectionFinishedLocked renders the just-finished session as a compact