package supplementimpact import ( "context" "log/slog" "time" ) // TriggerAsync kicks CreateFromSupplement in a background goroutine with panic recovery // so chat / mutate paths are never blocked by impact analysis. func TriggerAsync(svc *Service, projectID, userID int64, sessionID, summary, markdown string) { if svc == nil { return } go func() { defer func() { if rec := recover(); rec != nil { slog.Error("supplementimpact: TriggerAsync panic", "recover", rec, "project_id", projectID) } }() ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) defer cancel() if _, err := svc.CreateFromSupplement(ctx, projectID, userID, sessionID, summary, markdown); err != nil { slog.Warn("supplementimpact: CreateFromSupplement failed", "project_id", projectID, "user_id", userID, "error", err) } }() }