Repository navigation
Replies: 3 comments
中文版(同一问题的补充说明)现象桌面端右侧边栏的文档预览里,Markdown 中引用的本地图片——无论相对路径还是绝对路径——都只显示 alt 文字, 已验证鉴权文件路由本身是好的:在页面上下文里 环境
复现
# t



预期与实际预期前两张图渲染;实际 侧边栏该 tab 打开时,在控制台里可以看到: [...document.querySelectorAll('[data-document-markdown] img')].length // 0
document.baseURI // "dsh-app://app/"
new URL('api/file?path=' + encodeURIComponent('C:/some/where/t/figures/a.png'),
document.baseURI).href // "dsh-app://app/api/file?path=…"
// 本该被使用的地址其实是可用的:
await fetch('dsh-app://app/api/file?path=' + encodeURIComponent('C:/some/where/t/figures/a.png'))
.then(r => [r.status, r.headers.get('content-type')]) // [200, 'image/png']也就是说: 怀疑的根因
streaming: !content.eof( 当 { streaming: true, labels, fileMentions: void 0, pathImages: void 0, … }新冻结的节点和 tail 都用这个上下文。由于 结果就是:所有本地图片目标都降级为 alt 文字;而 建议的修法(三选一)
补充背景(不是 bug,只是定位信息)桌面端的页面源是 临时绕过把图片放到本地静态 HTTP 服务,并在 Markdown 里写绝对 |
|
相关历史记录(发帖时漏搜了,补上):
|
|
根因就是这个流式分支: 调用方其实把两个都传了—— <MarkdownText text={split?.body ?? text} streaming={!content.eof} labels={labels} pathImages={pathImages} />但到了
所以不是调用方漏传(#7125 那个根因已经修了),是流式渲染器缺这个能力。这也解释了为什么 http(s) 图片一直正常:它们是绝对 URL,走不走进 pathImages 都一样。 "永远不渲染"这点值得再确认一下:如果预览内容的 修法有两种形状,代价不一样:
只读了 master |
Uh oh!
There was an error while loading. Please reload this page.
Summary
In the right Sidebar document preview, a Markdown document that references a local
image — relative or absolute — renders only the alt text. No
<img>element iscreated inside
[data-document-markdown]. Remotehttp(s)images in the same documentrender normally, so the Markdown renderer, the
<img>pipeline and the CSP are all fine.The authenticated file route itself works:
dsh-app://app/api/file?path=…returns200 image/pngfrom the page context.Environment
@deepseek-ai/dsh-desktop0.2.1-rc.5, Windows 11 x64, Electron renderer whose shell origin isdsh-app://app/.@deepseek-ai/dsh-client-ui-sidebar-documentpreview(registersmd/markdown).Steps to reproduce
t/index.mdandt/figures/a.png.index.md:t/index.mdin the right Sidebar preview.Expected
The first two images render.
Actual
relativeandabsoluteshow as plain alt text; onlyremoterenders.In the console, right after the tab is open:
So:
document.baseURIpasses thefileMediaUrl()guard,fileMediaUrl()builds theright URL, and that URL returns a real PNG — yet the preview never calls it.
Suspected cause
MarkdownBodyhands the accumulated text to the sharedMarkdownTextprimitive with(two call sites in
client.js; the Markdown one is followed bylabels, pathImages).When
streamingis true, the primitive uses its incremental renderer, which builds theper-node render context as
for both the newly frozen nodes and the tail. With
pathImages: void 0, the imagehandler falls back to
nU(pathImages?.resolve(dest))→undefined→ the alt-text span.Already frozen elements are not re-rendered when
pathImageslater becomes available,and the incremental memoisation is keyed on the text only.
Consequence: every local image destination degrades to alt text, while
http(s)destinations are unaffected because they are resolved by a different branch
(
cw()/ scheme allow-list) that never consultspathImages.Suggested fix (any one)
pathImagesinto the incremental renderer: pass it to the renderer classalongside
labels, and use it in both contexts instead ofpathImages: void 0(also include it in the memoisation key so a later-arriving resolver re-renders).
streaming—MarkdownBodyalreadyre-renders on page append, and the full-parse path passes
pathImagescorrectly.pathImagesas "not yet resolvable" andre-render once the resolver arrives.
Additional data point (not a bug, just context)
On the desktop shell the page origin is
dsh-app://app/, the auth cookie lives only inthe main process (the forwarded response deliberately strips
set-cookie), and onlydsh-app://app/*(viaforwardWebRequest) and thews://127.0.0.1/*RPC get itattached. Therefore authoring an
http://127.0.0.1:<port>/api/file?path=…URL inMarkdown can never authenticate, and
dsh-app://app/api/file?…is the only viable form— which is exactly what
fileMediaUrl()produces.Path Ain Markdown cannot expressit (the scheme allow-list rejects non-
http(s)destinations), so the fix has to be onthe resolver side as described above.
Workaround
Serve the images from a local static HTTP server and author absolute
http://URLs inthe Markdown; those render (verified).
All reactions