It does seem that the guy had some fairly serious mental health problems, and that involvement with jihadi websites was a corollary to that. Even a semi-competent lone wolf terrorist would not walk into the FBI building and get himself on their radar. While the visits to chatrooms may have shaped the type of the attack, it probably wouldn't have happened in the first place if the mental issues were not there.
The way I see it, we need to  provide some mechanism for law enforcement to sequester the guns of folks with serious mental health issues , while at the same time protecting our constitutional rights.