feat(composer): inline code quotes and fenced code blocks behind a flag#3530
Open
kliment-slice wants to merge 2 commits into
Open
feat(composer): inline code quotes and fenced code blocks behind a flag#3530kliment-slice wants to merge 2 commits into
kliment-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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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