Migrate the reflection fetch onto runFetchAsync
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+17
-23
@@ -243,29 +243,23 @@ func (c *Controller) startReflectionFetchLocked() {
|
||||
// bounded to reflectionHistoryN summaries and runs once per Review entry, not
|
||||
// on any hot path.
|
||||
history := buildReflectionHistory(c.auditPath)
|
||||
go func() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), reflectionTimeout)
|
||||
defer cancel()
|
||||
refl, err := reviewer.Review(ctx, finished, history)
|
||||
|
||||
c.mu.Lock()
|
||||
if gen != c.reflectionGen {
|
||||
c.mu.Unlock()
|
||||
return // superseded review: discard
|
||||
}
|
||||
if err != nil || strings.TrimSpace(refl.Recap) == "" {
|
||||
c.reflectionStatus = reflectionAbsent
|
||||
c.reflectionRecap = ""
|
||||
c.carryForward = ""
|
||||
} else {
|
||||
c.reflectionStatus = reflectionReady
|
||||
c.reflectionRecap = refl.Recap
|
||||
c.carryForward = refl.CarryForward
|
||||
}
|
||||
_ = c.persistLocked()
|
||||
c.mu.Unlock()
|
||||
c.notify()
|
||||
}()
|
||||
var refl ai.Reflection
|
||||
var err error
|
||||
c.runFetchAsync(reflectionTimeout,
|
||||
func(ctx context.Context) { refl, err = reviewer.Review(ctx, finished, history) },
|
||||
func() bool { return gen != c.reflectionGen },
|
||||
func() {
|
||||
if err != nil || strings.TrimSpace(refl.Recap) == "" {
|
||||
c.reflectionStatus = reflectionAbsent
|
||||
c.reflectionRecap = ""
|
||||
c.carryForward = ""
|
||||
} else {
|
||||
c.reflectionStatus = reflectionReady
|
||||
c.reflectionRecap = refl.Recap
|
||||
c.carryForward = refl.CarryForward
|
||||
}
|
||||
_ = c.persistLocked()
|
||||
})
|
||||
}
|
||||
|
||||
// buildReflectionFinishedLocked renders the just-finished session as a compact
|
||||
|
||||
Reference in New Issue
Block a user