Skip to content

Read game output with MarkupString's decoder instead of our own parsers - #118

Draft
HarryCordewener wants to merge 1 commit into
mainfrom
claude/project-thread-ii9qqf
Draft

HarryCordewener wants to merge 1 commit into
mainfrom
claude/project-thread-ii9qqf

Conversation

@HarryCordewener

Copy link
Copy Markdown
Member

Requested by Grave · project thread

Depends on MarkupString 2.27.0 (SharpMUSH/MarkupString#82). CI cannot restore packages until that version is on NuGet. Locally the suites ran against a 2.27.0 packed from that branch.

What changed

  • AnsiParser, MxpParser (and .Definitions), PuebloParser, ILineParser, SgrCodes, MxpTagCategory and MxpLineMode are deleted.
  • New Core/Text/MarkupLineParser holds one MarkupString.Decoding.Decoder per session: WithVt(), a literal-tab plugin, WithMxp(new MxpOptions { ShowRefusedTags = true, Supports = … }) and WithPueblo(). It folds each DisplayLine into the existing StyledLine/StyledSpan/SpanInteraction model, so scrollback, logging, triggers, the TUI and the window are untouched.
    • Flush() calls EndLine(), because the telnet layer strips terminators.
    • Switch(format) enables or disables MXP and Pueblo in place of swapping parsers.
    • Decoder events become the events WorldSession already handled: replies, entities, flags, gauges, sounds, and frame redirects (spawn lines).
    • Images become the same InlineImageRequest, so the Kitty, sixel and placeholder paths are unchanged.
  • MxpSupport becomes MxpClientSupport (the old name clashed with TelnetNegotiationCore's). It feeds MxpOptions.Supports, so <SUPPORT> answers stay the same.
  • Package references to MarkupString, .Ansi, .Mxp and .Pueblo 2.27.0.

Capability inventory and how it was checked

The inventory is the old parser test suites: AnsiParserTests, MxpParserTests, MxpLineModeTests, MxpDefinitionTests, MxpImageTests, PuebloParserTests, ParserBoundaryTests, and the WorldSession and TUI end-to-end tests. They were kept and run against the new adapter. Each failure was either fixed in MarkupString (#82 lists them, for example the self-nesting element stack overflow, temp-secure, open-line definitions, link ends, SEND hints, and pictures over text), fixed in the adapter, or accepted as a change, with the test updated:

Before Now
&nbsp; became a space U+00A0
ESC[2K dropped erases, as on a terminal (tests now use ESC[?25l for "dropped")
Pueblo <img> dropped [image: map.png] label, like MXP
<VERSION MXP=1.0 STYLE=0 CLIENT=SharpMUTerm …> values quoted; STYLE only once the server sets one with <VERSION n>
A cell-sized MXP image over written text covered it shown inline at the tag
<A HREF="mux:send:…"> was a link refused at click time plain text: the decoder's UrlPolicy.Safe rejects it first; the click-time http(s) gate stays
ESC[1\x01z treated as malformed the case was dropped from the test
Element-count internals were asserted rewritten as behaviour checks against MxpPlugin.MaxElements and MaxDefinitionLength

SgrCodesTests and MxpTagCategoryTests were deleted with their subjects.

Results (Release, compared with main)

Suite main this branch
Core 1719/1720 1669/1670
Client 245/245 245/245
Graphics 99/99 99/99
Scripting 92/92 92/92
Web 37/37 37/37
Tui 3015/3015 3015/3015
Avalonia 898/898 898/898

The one Core failure on both is AReadOnlyCacheDirectory_DegradesToMemoryOnly, which fails when the tests run as root. Core has 50 fewer tests because of the two deleted suites. The build has 0 warnings.

Not done here

  • CellRenderer. The Avalonia CellRenderer paints SharpConsoleUI's whole composed frame (panels, menus, output), and SharpConsoleUI owns that layout. MarkupString's CellRenderer is a layout step for a single text pane, so it does not replace ours without moving the output pane off SharpConsoleUI. That is a separate change.
  • WithPictures(). Server-sent Kitty, iTerm2 and sixel images (APC/OSC/DCS) are still consumed and not shown, as before. Turning them on needs a picture path from PictureStore into InlineImageHost. This is a follow-up.
  • OSC 8 and MSLP links on plain ANSI lines are now read (by WithVt), subject to UrlPolicy.Safe.

Generated by Claude Code

AnsiParser, MxpParser, PuebloParser and ILineParser are replaced by
MarkupLineParser, one MarkupString Decoder per session (WithVt, WithMxp,
WithPueblo) folded into the existing StyledLine model. The old parser test
suites are kept and run against the adapter as the capability inventory;
the gaps they found were fixed in MarkupString 2.27.0.

Behaviour changes the tests now record: &nbsp; is U+00A0, erase-line
erases, Pueblo <img> shows its label, VERSION values are quoted, a picture
that would cover text goes inline, and a forged non-web link is text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rqqt7WA8C5XG14TAWB6b9V
@HarryCordewener HarryCordewener self-assigned this Nov 7, 2026
@coderabbitai

coderabbitai Bot commented Nov 7, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Copy link
Copy Markdown
Member Author

build & test (windows-latest) fails at restore: NU1102: Unable to find package MarkupString with version (>= 2.27.0). The nearest version on nuget.org is 2.25.0. The later steps fail only because nothing was built.

This is the dependency stated in the description, not a code failure. It clears once SharpMUSH/MarkupString#82 is merged and v2.27.0 is tagged and published. No fix is possible from this PR until then. Locally, all seven suites pass against a 2.27.0 packed from that branch. I'll re-check CI once the package is out.


Generated by Claude Code

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