Migrate the knowledge fetch onto runFetchAsync
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+23
-29
@@ -181,37 +181,31 @@ func (c *Controller) startKnowledgeFetchLocked() {
|
|||||||
c.knowledgeStatus = knowledgePending
|
c.knowledgeStatus = knowledgePending
|
||||||
src := c.knowledgeSrc
|
src := c.knowledgeSrc
|
||||||
path := c.knowledgePath
|
path := c.knowledgePath
|
||||||
go func() {
|
var prof knowledge.Profile
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), knowledgeTimeout)
|
var err error
|
||||||
defer cancel()
|
c.runFetchAsync(knowledgeTimeout,
|
||||||
prof, err := src.Load(ctx, path)
|
func(ctx context.Context) { prof, err = src.Load(ctx, path) },
|
||||||
|
func() bool { return gen != c.knowledgeGen || c.runtimeState != domain.RuntimePlanning },
|
||||||
c.mu.Lock()
|
func() {
|
||||||
if gen != c.knowledgeGen || c.runtimeState != domain.RuntimePlanning {
|
if err != nil {
|
||||||
c.mu.Unlock()
|
c.knowledgeStatus = knowledgeError
|
||||||
return // stale or left planning: discard
|
c.knowledgeText = ""
|
||||||
}
|
c.knowledgeChars = 0
|
||||||
if err != nil {
|
if prof.Path != "" {
|
||||||
c.knowledgeStatus = knowledgeError
|
c.knowledgePath = prof.Path
|
||||||
c.knowledgeText = ""
|
}
|
||||||
c.knowledgeChars = 0
|
} else if prof.Text == "" {
|
||||||
if prof.Path != "" {
|
c.knowledgeStatus = knowledgeAbsent
|
||||||
|
c.knowledgeText = ""
|
||||||
|
c.knowledgeChars = 0
|
||||||
|
c.knowledgePath = prof.Path
|
||||||
|
} else {
|
||||||
|
c.knowledgeStatus = knowledgeReady
|
||||||
|
c.knowledgeText = prof.Text
|
||||||
|
c.knowledgeChars = len(prof.Text)
|
||||||
c.knowledgePath = prof.Path
|
c.knowledgePath = prof.Path
|
||||||
}
|
}
|
||||||
} else if prof.Text == "" {
|
})
|
||||||
c.knowledgeStatus = knowledgeAbsent
|
|
||||||
c.knowledgeText = ""
|
|
||||||
c.knowledgeChars = 0
|
|
||||||
c.knowledgePath = prof.Path
|
|
||||||
} else {
|
|
||||||
c.knowledgeStatus = knowledgeReady
|
|
||||||
c.knowledgeText = prof.Text
|
|
||||||
c.knowledgeChars = len(prof.Text)
|
|
||||||
c.knowledgePath = prof.Path
|
|
||||||
}
|
|
||||||
c.mu.Unlock()
|
|
||||||
c.notify()
|
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetReviewer injects the AI reviewer. A nil reviewer keeps reflection idle and
|
// SetReviewer injects the AI reviewer. A nil reviewer keeps reflection idle and
|
||||||
|
|||||||
Reference in New Issue
Block a user