Skip to content

🤖 feat: backslash symbol shortcuts (math + trading) in chat input#3436

Merged
ammario merged 4 commits into
mainfrom
chatinput-b731
Jun 1, 2026
Merged

🤖 feat: backslash symbol shortcuts (math + trading) in chat input#3436
ammario merged 4 commits into
mainfrom
chatinput-b731

Conversation

@ammar-agent
Copy link
Copy Markdown
Collaborator

@ammar-agent ammar-agent commented Jun 1, 2026

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 \sum expands 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 from greekConversion.ts via git mv):

  • Single curated SYMBOLS table 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 \name as an escape and is suppressed inside code (see below).
  • getSymbolSuggestionscase-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):

  • A name that is not a strict prefix of any other symbol name (all Greek, \int, \euro, \leq, \times, …) converts eagerly the instant it's fully typed — preserving the snappy \alpha → α feel.
  • A name that is a strict prefix of another (\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/isCursorInsideCodeRange were extracted out of inlineSkillReferences.ts (no behavior change there) so the \symbol trigger — like $skill — is suppressed inside inline-code spans and fenced blocks.

Wiring in index.tsx mirrors the existing @/$// systems: symbol* state, a caret useLayoutEffect, handleSymbolSelect, the handleKeyDown gate, suppressKeys, aria attributes, and a 4th <CommandSuggestions>. handleInputChange runs eager-then-terminator conversion before setInput, fixing the caret via the established requestAnimationFrame idiom.

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 (\in does NOT eager-convert while \int/\infty exist; menu lists all three with \in preselected), case-sensitivity, per-category conversions, the terminator-accept path + caret math, escape handling, and the code-range guard.
  • inlineSkillReferences.test.ts still green after the extraction (regression check for the shared util).
  • Full ChatInput suite 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 \div inside a non-code Windows path would still convert; documented and escapable via \. The collectCodeRanges extraction is a pure move with an unchanged-behavior regression test.


Generated with mux • Model: anthropic:claude-opus-4-8 • Thinking: xhigh • Cost: $18.80

Typing \alpha or \Alpha auto-converts to the matching Greek letter, and
typing \ opens an autocomplete menu reusing the existing CommandSuggestions UI.
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ 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".

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.
@ammar-agent ammar-agent changed the title 🤖 feat: convert \greek backslash commands into Greek letters in chat input 🤖 feat: backslash symbol shortcuts (math + trading) in chat input Jun 1, 2026
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/browser/features/ChatInput/symbolShortcuts.ts Outdated
- 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.
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ 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".

- 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.
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ 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".

@ammario ammario merged commit 7169c8d into main Jun 1, 2026
23 checks passed
@ammario ammario deleted the chatinput-b731 branch June 1, 2026 20:29
@mux-bot mux-bot Bot mentioned this pull request Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants