GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [FEATURE]: Validate and handle malformed fenced code blocks in user messages (follow-up to #20942) · Issue #20952 · anomalyco/opencode

[FEATURE]: Validate and handle malformed fenced code blocks in user messages (follow-up to #20942) #20952

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
[FEATURE]: Validate and handle malformed fenced code blocks in user messages (follow-up to #20942)#20952
Copy link
Assignees
kitlangton

Description

@sandikodev
sandikodev
opened on Apr 4, 2026
Issue body actions

PR #20942 introduces rendering of fenced code blocks in user messages. As a
direct consequence, unbalanced triple backticks — common when users paste
terminal output, incident reports, or AI-generated content that already
contains code fences — can produce malformed renders: broken code blocks,
incorrect collapse behavior, and confusing spacing.

A minimal fallback is already included in #20942: if the number of triple
backticks is odd, fall back to plain text. This prevents the worst case.

A more complete solution could include:

  • Auto-closing unclosed fences at the render layer
  • Escaping nested triple backticks before sending to the model
  • Sanitizing user input at submission time, not just at render time

This pattern is a known limitation across major chat interfaces (ChatGPT,
Claude, Gemini) — addressing it at the input/render layer would improve
both UX and the quality of context sent to the model.

The current fix in #20942 is a starting point for discussion.

Related issues

  • Collapsed multi-line pasted code expands into the middle of subsequent text, causing data loss and split sentences #15690 — similar rendering problem when pasting code in TUI input
  • Desktop App: UI renders massively duplicated content when streaming responses with code blocks #14560 — code fence causes duplicated render in Desktop streaming
  • fix(tui): remove outer backtick wrapper in session transcript tool formatting #11566 — nested triple backticks in session transcripts caused invalid markdown (fixed in TUI, same class of problem)
  • Streaming response truncates at backticks when using separate reasoning_content with LM Studio + Qwen3.5 #15774 — streaming parser truncates at backtick characters

Activity

  1. sandikodev
    added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Apr 4, 2026
  2. github-actions
    assigned
    thdxr
    on Apr 4, 2026
  3. github-actions
    added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 4, 2026
  4. sandikodev commented on Apr 4, 2026

    @sandikodev
    sandikodev
    on Apr 4, 2026
    Author
    More actions

    Progress update from PR #20942:

    A minimal implementation is already in place at the render layer:

    • If triple backticks are unbalanced (odd count), the last unclosed fence is auto-closed before rendering
    • This is non-destructive — raw text sent to the model is unchanged

    Open questions for discussion:

    1. Should we also sanitize at submission time (before sending to the model)?
      • Pro: model receives cleaner context
      • Con: silently mutates user input, harder to debug
    2. Should there be a visual indicator when a fence is auto-closed?
    3. Is a context-aware heuristic (detect if it's actually code vs plain text) worth the complexity?

    Happy to hear maintainer's thoughts before going further.

  5. thdxr
    assigned
    rekram1-node
    and unassigned
    thdxr
    on Apr 26, 2026
  6. thdxr
    removed
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  7. thdxr
    assigned
    kitlangton
    and unassigned
    rekram1-node
    on May 3, 2026
  8. github-actions commented on Jul 3, 2026

    @github-actions
    github-actionsBot
    on Jul 3, 2026 – with GitHub Actions
    Contributor
    More actions

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  9. github-actions
    closed this as not plannedon Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @kitlangton
    kitlangton

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.