Lord Wensleydale) - relied on the authority of Hale to require the jury to find her insane - R v Dyson (1831).
A few years later came the case of R v Pritchard (1836). Pritchard was also "deaf and dumb" and stood trial for what was then the capital offence of "bestiality." Alderson B (the trial judge) relied on R v Dyson and empanelled a jury to decide whether he was "mute of malice of by visitation of God." The jury found the latter and were then required to decide whether he could plead. They found that he could do so and he entered a not guilty plea. The jury were then directed to decide whether he was sane or not. Alderson B told the jury that the defendant could be regarded as sane if he had sufficient intellect to comprehend the course of the proceedings so as to make a proper defence; to know that he could challenge any juror to whom he objected and to comprehend details of the evidence.
The test in Pritchard received the approval of the Court of Criminal Appeal in R v Podola  1 QB 325 and the test remains the basis of the law although it is outdated and inconsistent with modern psychiatry.
Under modern law, the question of fitness to plead is decided by the judge: Criminal Procedure (Insanity) Act 1964 as amended by the Criminal Procedure (Insanity and Fitness to Plead) Act 1991 and the Domestic Violence, Crime and Victims Act 2004. The judge must have reports from two or more registered medical practitioners at least one whom must be approved under the Mental Health Act 1983 s.12. If it is decided that the defendant is unfit to plead then the court moves to the so-called "s4A hearing" to determine whether the defendant did the act or made the omission constituting the actus reus of the offence charged against him. If there is a finding that the defendant did the act then certain disposals are possible - e.g. a Hospital Order.
In 2016, the Law Commission reported - A modern approach to Unfitness to Plead
This report is the outcome of the Commission's project which commenced in 2010.
The above post was concerned with the procedure in the Crown Court. It should be noted that somewhat different rules apply in the Magistrates' Court - see Part 8 here..