Repository navigation
fix(client): give the host MarkdownText the labels it dereferences - #107
Merged
Merged
Conversation
A remote `.md` containing a fenced code block opened to a blank pane: the file was read (SFTP returned the bytes) but nothing rendered, and no error was shown. The host's MarkdownText takes its chrome strings from a `labels` prop and dereferences them UNGUARDED while rendering those nodes — `labels.code.copyLabel` / `.copiedLabel` / `.toolbarLabels`, and `labels.footnotes`. The viewer passed only `text`, so the first code fence threw inside the host renderer; the error boundary around the pane swallowed the exception and the body stayed empty. Documents without a code fence or footnote were unaffected, which is why the failure looked file-specific. Pass the bundle the host expects (code-block chrome + footnote caption) and wrap the renderer in a small boundary so that a future host asking for one more label degrades to source instead of an empty body. The boundary is a no-op under partial React faces that omit `Component`, which keeps the module loadable in the existing harnesses. Add the regression at the layer that missed it: the render harness stubbed MarkdownText as a plain text div, so flymysql#74's test stayed green while production threw. `strictMarkdownText` makes the stub perform the same dereferences as the host, and the new panel test feeds a fenced code block. Co-authored-by: huangjun <[email protected]>
flymysql
pushed a commit
that referenced
this pull request
Nov 10, 2026
Owner
|
又一个干净的修复,已合入并随 v0.8.85 发布。特别点赞两点:①严格模式测试桩的思路——让桩做与真实宿主相同的无守卫解引用,这类契约断裂今后红灯伺候而不是悄无声息;②顺手做了 mutation 对照(拆掉 labels 修复新测试必挂、老 #74 测试不受影响),举证责任尽到了。 |
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.
Symptom
In a remote Session, opening a
.mdfile that contains a fenced code block shows an empty pane: the read succeeds (SFTP returns the bytes), nothing renders, and no error is displayed. Markdown without a code fence or footnote renders normally, which makes the failure look file-specific.Reproduced with DSH 0.2.2-rc.1 + dsh-remote 0.8.83, remote host Linux.
Root cause
The host's
MarkdownTextreads its chrome strings from alabelsprop and dereferences them without a guard while rendering the affected nodes:RemoteFileTabpasses onlytext/variant:So the first fenced code block throws
TypeError: Cannot read properties of undefined (reading 'code')inside the host renderer. The error boundary around the pane swallows it, and the body stays empty — the "opened a file, got a blank page" report. The same unguarded reads exist in 0.2.1-rc.5, so this is not a host regression; the viewer has never suppliedlabels.Fix
code.{copyLabel,copiedLabel,toolbarLabels},footnotes), localized through the existing zh/en tables.Componentthe boundary is a pass-through, which keeps the module loadable in the existing harnesses.Why the suite missed it
test/harness/render.jsstubbedMarkdownTextas(props) => <div className="md-stub">{props.text}</div>. The stub never touchedlabels, so the #74 test stayed green while production threw. The stub now supportsstrictMarkdownText, which performs the same dereferences as the real host, and the new panel test feeds a fenced code block.Verification
node --check lib/client.js test/harness/render.js test/ui-panels.test.js— passnpm test— 1086 pass, 0 fail, 7 skipped (1093 tests)labelschange reverted, the new test fails (13 pass / 1 fail) and the old [Bug] Remote session: .md links open the local mirror instead of the remote file #74 test still passes — the new test is what pins the behaviourgit diff --check— clean, LF endings preserved