feat(composer): inline code quotes and fenced code blocks behind a flag - #3530
feat(composer): inline code quotes and fenced code blocks behind a flag#3530kliment-slice wants to merge 2 commits into
Conversation
Adds backtick quoting to the message composer, gated by the posthog-code-prompt-code-blocks feature flag (dev builds bypass it): - `inline code` styles as a code chip the moment the trailing backtick is typed; ArrowRight exits the mark. - ``` + Shift+Enter opens a fenced code block (optionally ```lang). Shift+Enter inside adds newlines; the stock space/enter input rules are disabled so Shift+Enter is the only trigger. - Enter always submits, regardless of cursor position — including inside a code block. Only Shift+Enter makes a line. - Arrow keys move in and out of the block; a custom ArrowUp escape mirrors Tiptap's exitOnArrowDown for a block at the top of the doc. - Content serializes to standard markdown (backticks/fences) so the model sees the quoted content verbatim and the chat thread renders it as code; drafts round-trip fences without corrupting whitespace. Flag created in PostHog project 2 (#766905), active at 0% rollout. Generated-By: PostHog Code Task-Id: 6340d9d8-aa7e-43e6-b1de-c99c8b52c738
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 1 · PR risk: 0/10 |
Bash-mode detection ran on editor.getText(), which strips markup — with code quoting enabled, `!rm -rf ~` typed as an inline quote (or a fenced block starting with !) lost its backticks and read as a leading-! bash command, so content rendered as a quoted literal would execute as a shell command on submit. Detection (indicator, submit, isBashMode) now uses the serialized content text, where quoted code keeps its backticks/fences and can never start with !. Plain !commands are unaffected, and real bash commands containing an inline quote now keep their backticks instead of silently losing them. Addresses the review finding on #3530. Generated-By: PostHog Code Task-Id: 6340d9d8-aa7e-43e6-b1de-c99c8b52c738
|
This PR has had no activity for 7 days and has been marked stale. We are moving to the monorepo and tightening PR staleness in preparation, so it will be closed in 7 days if no further activity occurs. |
|
Closing stale PRs ahead of Friday's monorepo migration. If this is a mistake, rebase and reopen for review. |
Problem
When typing an inline quote rn backticks and triple backticks are plain text. Proposing similar mechanics to other apps out there, which render inline quotes and code blocks in the prompt composer box.
Changes
Adds backtick quoting to the composer, gated by the
posthog-code-prompt-code-blocksfeature flag (#766905, created at 0% rollout, dev builds bypass it):`code`restyles as an inline code chip the moment the trailing backtick is typed; ArrowRight exits the mark.```(optionally```lang) + Shift+Enter opens a styled code block. The stock Tiptap input rules are stripped (they also fire on space/Enter) so Shift+Enter is the only trigger.```line.CodeBlockArrowExitextension mirrors Tiptap'sexitOnArrowDownfor ArrowUp when the block is the doc's first node. Prompt-history recall no longer hijacks arrows while inside a block.contentToXml— markdown is plain text to the wire format.How did you test this?
@posthog/uisuite passes (197 files / 1740 tests), pluspnpm typecheckand biome lint.```+space staying literal, and draft round-trip across a renderer reload.Automatic notifications
Created with PostHog Code