fix: restore chat prompt spellcheck

This commit is contained in:
Federico Jaramillo Martinez
2026-05-23 23:41:17 +02:00
parent 37c3aa79d8
commit 56fa641a8d
2 changed files with 25 additions and 0 deletions
@@ -0,0 +1,5 @@
---
"@jmfederico/pi-web": patch
---
Restore spellcheck and autocorrect for prose in the web chat prompt while keeping command-like input protected from autocorrection.
+20
View File
@@ -109,6 +109,7 @@ export class PromptEditor extends LitElement {
indentUnit.of(" "),
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
EditorView.lineWrapping,
EditorView.contentAttributes.of((view) => inputAssistanceContentAttributes(view.state.sliceDoc(0, view.state.selection.main.head))),
placeholder("Message pi... Use / for commands, @ for files"),
this.editableCompartment.of(EditorView.editable.of(!this.disabled)),
this.readOnlyCompartment.of(EditorState.readOnly.of(this.disabled)),
@@ -299,3 +300,22 @@ function emptyFileSuggestions(): FileSuggestion[] {
return [];
}
const proseInputAssistanceAttributes: Record<string, string> = {
spellcheck: "true",
autocorrect: "on",
autocapitalize: "sentences",
writingsuggestions: "true",
};
const codeLikeInputAssistanceAttributes: Record<string, string> = {
spellcheck: "false",
autocorrect: "off",
autocapitalize: "off",
writingsuggestions: "false",
};
function inputAssistanceContentAttributes(draftBeforeCursor: string): Record<string, string> {
// CodeMirror is optimized for code and disables these by default, but the chat prompt is usually prose.
return inputModeForDraft(draftBeforeCursor).kind === "normal" ? proseInputAssistanceAttributes : codeLikeInputAssistanceAttributes;
}