🤖 feat: backslash symbol shortcuts (math + trading) in chat input#3436
Conversation
Typing \alpha or \Alpha auto-converts to the matching Greek letter, and typing \ opens an autocomplete menu reusing the existing CommandSuggestions UI.
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Rename greekConversion -> symbolShortcuts and expand beyond Greek to math relations/operators, set theory, logic, arrows, currency/trading signs, and big operators. Prefix-aware eager conversion (unambiguous names convert on completion; ambiguous ones like \in vs \int wait for Tab/Enter or a space terminator). Extract collectCodeRanges into a shared util so the \symbol trigger is suppressed inside code spans/fences.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e7493c73d9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- Float exact full-name matches to the top of the suggestion menu so typing \in + Tab inserts the exact match (∈) rather than a longer prefix-completion (∞/∫); other matches keep curated order. - Add docs/config/symbol-shortcuts.mdx (usage, conversion timing, escaping, category reference) + nav entry; regenerate offline docs snapshot.
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
- Symbol shortcuts are always-on (not configurable), so move the page from Configuration to Guides. - Cross-reference the SYMBOLS table in symbolShortcuts.ts and the doc's example table so they stay in sync. - Regenerate offline docs snapshot.
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Adds LaTeX-style backslash symbol shortcuts to the chat input for math and trading use cases. Typing a command like
\alpha,\leq,\subseteq,\to,\euro, or\sumexpands it to the matching Unicode symbol, and typing\opens an autocomplete menu reusing the existing suggestion UI. This generalizes the original Greek-only feature.Background
Users writing math/physics/finance-flavored prompts want a fast, familiar way to enter symbols without OS-specific input tricks. The LaTeX convention (
\alpha,\leq, …) is the natural fit, and the chat input already had a well-worn pattern for trigger-based autocomplete (@-mentions,$-skills,/-commands) to mirror. The first iteration shipped Greek letters only; this PR broadens it to a curated cross-domain set.Implementation
Module
symbolShortcuts.ts(pure, renamed fromgreekConversion.tsviagit mv):SYMBOLStable of{ name, char, category }— Greek (generated lower/upper) plus math relations/operators, set theory & number sets, logic, arrows, currency/trading, and big operators (~150 entries total).findSymbolCommandAtCursor— caret-token matcher; treats\nameas an escape and is suppressed inside code (see below).getSymbolSuggestions— case-sensitive prefix filter; an exact full-name match is floated to the top so it wins the menu's default selection (e.g.\in+ Tab → ∈, not ∞/∫), while other matches keep curated order.convertSymbolCommandAtCursor(eager) +convertTerminatedSymbolCommand(terminator-accept).Conversion timing — prefix-aware (matches Julia REPL / Jupyter / VS Code completion UX):
\int,\euro,\leq,\times, …) converts eagerly the instant it's fully typed — preserving the snappy\alpha→ α feel.\in⊂\int/\infty,\to⊂\top,\subset⊂\subseteq,\R⊂\Rho/\Rightarrow) does not auto-convert; the menu stays open with the exact match preselected. Accept via Tab/Enter or a space/punctuation terminator (e.g.\in→∈).Shared code-range util (
src/browser/utils/markdown/codeRanges.ts):collectCodeRanges/isCursorInsideCodeRangewere extracted out ofinlineSkillReferences.ts(no behavior change there) so the\symboltrigger — like$skill— is suppressed inside inline-code spans and fenced blocks.Wiring in
index.tsxmirrors the existing@/$//systems:symbol*state, a caretuseLayoutEffect,handleSymbolSelect, thehandleKeyDowngate,suppressKeys, aria attributes, and a 4th<CommandSuggestions>.handleInputChangeruns eager-then-terminator conversion beforesetInput, fixing the caret via the establishedrequestAnimationFrameidiom.Docs: new user page
docs/config/symbol-shortcuts.mdx(usage, conversion timing, escaping, per-category reference) added to the Configuration nav group; offline docs snapshot regenerated.Validation
symbolShortcuts.test.ts: behavioral coverage for prefix collisions (\indoes NOT eager-convert while\int/\inftyexist; menu lists all three with\inpreselected), case-sensitivity, per-category conversions, the terminator-accept path + caret math, escape handling, and the code-range guard.inlineSkillReferences.test.tsstill green after the extraction (regression check for the shared util).ChatInputsuite green;make static-check-full(incl. docs link check + docs-sync) green.Risks
Low–moderate, isolated to the chat input. The central design risk — prefix collisions — is handled structurally by the prefix-aware timing + exact-match preselection (both computed from the table, so they stay correct as entries change). Residual false-positive surface: a standalone unambiguous token like
\divinside a non-code Windows path would still convert; documented and escapable via\. ThecollectCodeRangesextraction is a pure move with an unchanged-behavior regression test.Generated with
mux• Model:anthropic:claude-opus-4-8• Thinking:xhigh• Cost:$18.80