GeezerVison is showing github.com — Track markdown oracle parity follow-up. · opencode-mobile/opencode-mobile@82425f2
File treeExpand file treeCollapse file tree Open diff view settings docs/features/native-rendered-markdown shared/markdown-core/src/androidUnitTest kotlin/dev/opencode/mobile/markdown
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: docs/features/native-rendered-markdown/plan.md +13-4Lines changed: 13 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -81,10 +81,17 @@ Shell, YAML, CSS, HTML, Python, Rust, Go, and diff highlighting on Android and | 81 | 81 | iOS against checked-in Shiki golden fixtures. The popular-languages pack extends | 82 | 82 | bundled TextMate coverage to Java, C#, C/C++, Ruby, PHP, SQL, TOML, XML, Scala, | 83 | 83 | Lua, Docker, Vue, Svelte, GraphQL, PowerShell, Perl, Haskell, Elixir, Erlang, R, | 84 | | -Zig, and Make (`makefile` alias) with smoke tests and `java-basic` regression anchors. Until full Shiki | 85 | | -parity lands, native semantic fallback highlighting is allowed only as an | 86 | | -implementation scaffold and must emit/record a `HighlighterFallback` diagnostic | 87 | | -in the shared render tree. | | 84 | +Zig, and Make (`makefile` alias) with smoke tests and `java-basic` regression | | 85 | +anchors. Until full Shiki parity lands, native semantic fallback highlighting is | | 86 | +allowed only as an implementation scaffold and must emit/record a | | 87 | +`HighlighterFallback` diagnostic in the shared render tree. | | 88 | + | | 89 | +Follow-up `OPE-29` tracks a stronger oracle-parity pass: generate trusted Shiki | | 90 | +or `vscode-textmate` fixtures for representative fenced code snippets, compare | | 91 | +the shared KMP highlighter spans against those fixtures, add CommonMark-capable | | 92 | +parser oracle fixtures for supported markdown constructs, and then decide | | 93 | +whether to keep the handwritten parser behind differential tests or migrate | | 94 | +render-tree construction to `jetbrains.markdown`. | 88 | 95 |
| 89 | 96 | ## Implementation Milestones | 90 | 97 |
| @@ -138,6 +145,8 @@ in the shared render tree. | 138 | 145 | `css`, and `html` parity are active; `java-basic` regression and per-language | 139 | 146 | smoke tests are active; the full native comparison is present and ignored | 140 | 147 | until the engine exists.** | | 148 | + - add oracle-driven highlighter and parser parity coverage for high-risk | | 149 | + snippets and supported markdown constructs. **Planned in OPE-29.** | 141 | 150 | 4. Chat polish: | 142 | 151 | - tune outgoing collapse/expand thresholds; | 143 | 152 | - verify streaming parse debounce; | |
Collapse file Copy file name to clipboardExpand all lines: docs/features/native-rendered-markdown/progress.md +4Lines changed: 4 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 213 | 213 | - Expand active Shiki golden comparisons beyond the Android/Joni `diff`, `json`, | 214 | 214 | `yaml`, `css`, and `html` subsets and remove the ignored full native-vs-Shiki | 215 | 215 | highlighter comparison once the native TextMate engine is in place. | | 216 | +- Track OPE-29: add trusted Shiki/`vscode-textmate` highlighter oracle fixtures | | 217 | + and CommonMark-capable parser oracle fixtures for high-risk rendered-markdown | | 218 | + examples, including the large multi-language code sample that exposed recent | | 219 | + visual regressions. | 216 | 220 | - Add screenshot tests for both native renderers. | 217 | 221 | - Tune outgoing markdown collapse thresholds after device review. | 218 | 222 | - Run full manual scroll checks on long Session Chat timelines. | |
Collapse file Copy file name to clipboard +77Lines changed: 77 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +package dev.opencode.mobile.markdown | | 2 | + | | 3 | +import kotlin.test.Test | | 4 | + | | 5 | +class DistributedSchedulerReproTest { | | 6 | + @Test | | 7 | + fun reproParseStructure() { | | 8 | + val markdown = | | 9 | + DistributedSchedulerReproTest::class.java.classLoader!! | | 10 | + .getResource("repro/distributed-task-scheduler.md")!! | | 11 | + .readText() | | 12 | + | | 13 | + val highlighter = | | 14 | + OpenCodeSyntaxHighlighter( | | 15 | + grammarBundle = bundledGrammarBundle(), | | 16 | + textMateTokenizer = OpenCodeTextMateNativeTokenizer(OpenCodeJoniRegexBackend), | | 17 | + ) | | 18 | + | | 19 | + val doc = OpenCodeMarkdownParser.parse(markdown, highlighter) | | 20 | + | | 21 | + println("=== BLOCK STRUCTURE (${doc.blocks.size} blocks) ===") | | 22 | + doc.blocks.forEachIndexed { i, block -> | | 23 | + when (block) { | | 24 | + is MarkdownBlock.Heading -> println("[$i] Heading(level=${block.level}) ${plainTextFromMarkdownInlines(block.inlines)}") | | 25 | + is MarkdownBlock.Paragraph -> println("[$i] Paragraph: ${plainTextFromMarkdownInlines(block.inlines).take(60)}") | | 26 | + is MarkdownBlock.CodeBlock -> println( | | 27 | + "[$i] CodeBlock(lang=${block.language}, lines=${block.lines.size}, spans=${block.spans.size}, codeLen=${block.code.length})", | | 28 | + ) | | 29 | + is MarkdownBlock.OrderedList -> println("[$i] OrderedList(start=${block.start}, items=${block.items.size})") | | 30 | + is MarkdownBlock.BulletList -> println("[$i] BulletList(items=${block.items.size})") | | 31 | + is MarkdownBlock.DiffBlock -> println("[$i] DiffBlock(lines=${block.lines.size})") | | 32 | + is MarkdownBlock.Table -> println("[$i] Table") | | 33 | + is MarkdownBlock.BlockQuote -> println("[$i] BlockQuote") | | 34 | + MarkdownBlock.ThematicBreak -> println("[$i] ThematicBreak") | | 35 | + } | | 36 | + } | | 37 | + | | 38 | + println("=== DIAGNOSTICS ===") | | 39 | + doc.diagnostics.forEach { println(it) } | | 40 | + | | 41 | + val codeBlocks = doc.blocks.filterIsInstance<MarkdownBlock.CodeBlock>() | | 42 | + codeBlocks.forEach { cb -> | | 43 | + val len = cb.code.length | | 44 | + val bad = | | 45 | + cb.spans.withIndex().filter { (idx, span) -> | | 46 | + span.start < 0 || span.end > len || span.start >= span.end || | | 47 | + (idx > 0 && span.start < cb.spans[idx - 1].end) | | 48 | + } | | 49 | + println("=== CODE BLOCK span invariant violations: ${bad.size} ===") | | 50 | + bad.take(20).forEach { (idx, span) -> println(" span[$idx]=$span (codeLen=$len)") } | | 51 | + println("code utf16 len=${cb.code.length}, code first line='${cb.code.lineSequence().first()}'") | | 52 | + println("code last line='${cb.code.lineSequence().last()}'") | | 53 | + } | | 54 | + | | 55 | + codeBlocks.forEach { cb -> | | 56 | + println("=== LARGEST SPANS ===") | | 57 | + cb.spans | | 58 | + .sortedByDescending { it.end - it.start } | | 59 | + .take(12) | | 60 | + .forEach { span -> | | 61 | + val text = cb.code.substring(span.start, span.end).replace("\n", "\\n") | | 62 | + val shown = if (text.length > 80) text.take(80) + "…" else text | | 63 | + println(" ${span.role} len=${span.end - span.start} [${span.start},${span.end}) '$shown'") | | 64 | + } | | 65 | + } | | 66 | + | | 67 | + println("=== iOS JSON ROUND TRIP PATH ===") | | 68 | + val requestJson = | | 69 | + OpenCodeMarkdownJson.json.encodeToString( | | 70 | + MarkdownParseRequest(markdown = markdown, variant = "assistantMessage", isStreaming = false), | | 71 | + ) | | 72 | + val responseJson = OpenCodeMarkdownJson.parseMarkdownJson(requestJson) | | 73 | + println("responseJson length=${responseJson.length}") | | 74 | + val reDecoded = OpenCodeMarkdownJson.json.decodeFromString<MarkdownDocument>(responseJson) | | 75 | + println("reDecoded blocks=${reDecoded.blocks.size} types=${reDecoded.blocks.map { it::class.simpleName }}") | | 76 | + } | | 77 | +} |
Collapse file Copy file name to clipboard +90Lines changed: 90 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +package dev.opencode.mobile.markdown | | 2 | + | | 3 | +import kotlin.test.Test | | 4 | + | | 5 | +class PythonHighlightIsolationTest { | | 6 | + private fun highlighter(): OpenCodeSyntaxHighlighter = | | 7 | + OpenCodeSyntaxHighlighter( | | 8 | + grammarBundle = bundledGrammarBundle(), | | 9 | + textMateTokenizer = OpenCodeTextMateNativeTokenizer(OpenCodeJoniRegexBackend), | | 10 | + ) | | 11 | + | | 12 | + private fun dump( | | 13 | + label: String, | | 14 | + code: String, | | 15 | + ) { | | 16 | + val result = highlighter().highlight("python", code) | | 17 | + println("### $label") | | 18 | + result.spans.forEach { span -> | | 19 | + val t = code.substring(span.start, span.end).replace("\n", "\\n") | | 20 | + println(" ${span.role} [${span.start},${span.end}) '$t'") | | 21 | + } | | 22 | + println() | | 23 | + } | | 24 | + | | 25 | + private fun dumpRaw( | | 26 | + label: String, | | 27 | + code: String, | | 28 | + ) { | | 29 | + val bundle = bundledGrammarBundle() | | 30 | + val grammar = bundle.primaryGrammarFor("python")!! | | 31 | + val tokenizer = OpenCodeTextMateNativeTokenizer(OpenCodeJoniRegexBackend) | | 32 | + val result = tokenizer.tokenize(grammar, code, bundle) | | 33 | + println("### RAW $label") | | 34 | + result.tokens.forEach { token -> | | 35 | + val t = code.substring(token.start, token.end).replace("\n", "\\n") | | 36 | + println(" [${token.start},${token.end}) '$t' ${token.scopes}") | | 37 | + } | | 38 | + println() | | 39 | + } | | 40 | + | | 41 | + @Test | | 42 | + fun raw() { | | 43 | + dumpRaw( | | 44 | + "dict ternary", | | 45 | + listOf( | | 46 | + "d = {", | | 47 | + " \"start_time\": a.isoformat() if a else None,", | | 48 | + "}", | | 49 | + ).joinToString("\n"), | | 50 | + ) | | 51 | + dumpRaw("key colon value", "\"start_time\": value") | | 52 | + dumpRaw("assign string", "x = \"start_time\"") | | 53 | + } | | 54 | + | | 55 | + @Test | | 56 | + fun isolate() { | | 57 | + dump( | | 58 | + "fstring with format spec colon", | | 59 | + "x = f\"retrying in {delay}s: {str(e)}\"", | | 60 | + ) | | 61 | + dump( | | 62 | + "dict with ternary next lines", | | 63 | + listOf( | | 64 | + "d = {", | | 65 | + " \"start_time\": a.isoformat() if a else None,", | | 66 | + " \"end_time\": b.isoformat() if b else None,", | | 67 | + "}", | | 68 | + ).joinToString("\n"), | | 69 | + ) | | 70 | + dump( | | 71 | + "triple quoted docstring then code", | | 72 | + listOf( | | 73 | + "def f():", | | 74 | + " \"\"\"Docstring.\"\"\"", | | 75 | + " return 1", | | 76 | + "", | | 77 | + "@decorator(a=1, b=(X, Y))", | | 78 | + "def g():", | | 79 | + " pass", | | 80 | + ).joinToString("\n"), | | 81 | + ) | | 82 | + dump( | | 83 | + "single fstring line then def", | | 84 | + listOf( | | 85 | + "logger.warning(f\"Worker {worker_id} down\")", | | 86 | + "async def get(self, id: str) -> Optional[Dict[str, Any]]:", | | 87 | + ).joinToString("\n"), | | 88 | + ) | | 89 | + } | | 90 | +} |
|