Skip to content

composer: no live visual feedback for Markdown while typing #516

Backlog

Description

@shubhook

The problem

Typing Markdown syntax in the composer, a leading - for a bullet, backticks around code, gives no visual feedback before you send.

The text just sits there as literal dashes and backticks. #235 (merged) makes Enter continue the same list marker as you type, but it doesn't style anything: the marker never becomes a bullet glyph, and wrapped text never becomes a code chip, until after the message is sent and goes through the chat renderer (which already handles both correctly: ul/ol get list-disc/list-decimal with indentation, fenced and inline code get CodeBlock/ui-code-chip).

What you'd like

Lightweight live feedback as you type, in the composer itself: bullet/number lines get indentation and a marker glyph, backtick-wrapped text gets a monospace/code-chip treatment, the way Notion or Linear's composer does, without needing to send the message first.

Anything else

Scope note: this is not a small follow-up to #235. That PR only changed key handling in a plain text input (continue the marker, Tab to nest). Live styling-as-you-type means the composer needs to become a decorated contenteditable (or equivalent), not a plain textarea, a materially bigger change that should be scoped as its own project.

Repro: type - text then a backtick-wrapped word in the composer, neither shows any visual change until sent.

Version: current dev (0.2.40). Platform: macOS, likely all platforms.

Activity

  1. added
    enhancement
    on Dec 4, 2026
  2. shubhook commented on Dec 4, 2026

    @shubhook
    ContributorAuthor

    I'm working on this, will open a PR soon

  3. shubhook commented on Dec 4, 2026

    @shubhook
    ContributorAuthor

    @SiddDevZ @ramxcodes I'd like a decision from you before I start: can the composer's <textarea> be replaced with an editor? This issue needs that change, and it would also remove the composer limitations in #518 (#515).

    Why the textarea blocks this

    MentionTextarea is a transparent <textarea> laid over a mirror <div> that paints the highlights. The mirror only lines up with the caret while every character has exactly the same width in both layers. Live Markdown changes widths:

    • A list line needs the chat's indent (ps-5) and a bullet or number glyph.
    • An inline code chip uses a monospace font and padding.

    Both push the mirror's text away from the real caret. CSS alone can't fix this. The field itself has to render the styled text.

    The same limit is why #518 draws a bot's face over the @ instead of a real chip. Its known issues are listed in that PR. The face can overlap a caret placed just before a mention, it crowds a word typed with no space before it, and it extends past the text's edge at the start of a line.

    Proposal: CodeMirror 6 as the composer field

    CodeMirror keeps the content as a plain string. What you send is exactly what you typed, and styling is applied on top as decorations.

    • @codemirror/state and @codemirror/view are already dependencies. apps/artifacts uses them in CodeView.
    • List lines get the chat's indent and a • or number. The marker characters stay in the text, so the caret and Backspace still work on them.
    • `code` gets the same ui-code-chip class the chat renderer uses, so nothing shifts when the message is sent. The backticks stay visible, dimmed.
    • Code fences get no list or chip styling.
    • A bot mention becomes an atomic chip with the bot's face and colour. Backspace removes it whole, and it never overlaps the caret. This replaces the overlay from Show a bot mention with the bot's face and colour #518. The sent-message chips in Show a bot mention with the bot's face and colour #518 stay as they are.
    • The composer: lists and quotes carry on while you type #235 list keys (markdownKeyEdit) carry over unchanged. Only the step that applies the edit changes.
    • A small handle keeps the textarea's members (value, selectionStart, setSelectionRange, focus), so most of Composer.tsx stays the same.

    Options considered

    Option Live Markdown Mention chips Cost and risk
    Keep the textarea (today, plus #518) No Face overlay only, with the limits above None
    CodeMirror 6 (proposed) Yes Yes, atomic Medium. Replaces the field and needs a full composer retest.
    Tiptap / ProseMirror Yes Yes Higher. It converts text into rich nodes and back, which can rewrite 1), *, spacing and code fences in what gets sent.
    A contenteditable we build ourselves Yes Yes Highest. We would write our own IME, undo, selection and paste handling.

    Pros

    • Live bullets, numbers and code chips as you type, matching the sent message.
    • Real mention chips in the composer, with none of Show a bot mention with the bot's face and colour #518's overlay limits.
    • One place to add more inline tokens later: thread refs, links, slash commands and files.
    • No second layer kept in sync with the text, so the mirror code, MIRROR_BLEED and the Android text-zoom adjustment go away.

    Cons and risks

    • It replaces the field the whole composer is built on. These need retesting:
      • paste (images to attachments, HTML as plain text)
      • Enter to send while typing with an IME (Japanese, Chinese)
      • the send-key setting
      • auto-height and the 6-line cap
      • the resize edge and the phone layout
      • dictation, and apps that write into the field directly
      • draft restore when switching chats
      • edit-last-message
      • focus returning from the find bar
    • contenteditable behaves differently in WebKit, Chromium and Android WebView. Mobile keyboards, autocorrect and spellcheck need checking on real devices.
    • About 22 composer test files query textarea. They need a shared helper, so most of the diff will be test changes.
    • The chat app doesn't load CodeMirror today, so the chat bundle grows by its size.

    Suggested rollout

    1. Swap only the chat Composer. BubbleEditor, AskCard and the other textareas stay as they are.
    2. Keep the current textarea behind a flag for one release, so it can be switched back.
    3. First PR: the field swap, live lists and code chips. Mention chips go in a follow-up that replaces Show a bot mention with the bot's face and colour #518's overlay.

    Are you OK with replacing the composer's textarea? If yes, is CodeMirror 6 the right choice, or do you prefer another option? Until you decide, #518 keeps the overlay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions