[Bug] Share export: Text and PDF tabs are blank — the export template ignores virtual assistantGroup messages
Client Type
Web (Desktop Browser)
Operating System
Other Linux
Deployment Platform
Self hosting Docker
Version
v2.2.19-canary.4
Browser
Chrome
What happened?
On a self-hosted instance, opening a topic's Share modal and switching to the Text or PDF tab produces an (almost) empty export: the title and the user's own message are there, but every assistant reply is missing. The Screenshot and JSON tabs of the same modal are completely fine.
Root cause — verified in the source, in the deployed frontend bundle, and by replaying the real message rows through the actual pipeline:
The four share tabs do not read the same data.
ShareDataProviderexposes bothdbMessagesanddisplayMessages:- Screenshot / JSON →
dbMessages(raw DB rows) - Text / PDF →
displayMessages, i.e. theflatListproduced byparse()from@lobechat/conversation-flow
- Screenshot / JSON →
parse()folds every tool-calling assistant turn into a virtual aggregate message, whose top-levelcontentis emptied and whose real text is moved intochildren[]:// FlatListBuilder.createAssistantGroupMessage() const result: Message = { ...firstAssistant, children, content: '', role: isSupervisor ? 'supervisor' : 'assistantGroup', }; delete result.imageList; delete result.metadata; delete result.reasoning; delete result.tools;createSupervisorContentMessage()does the same (content: ''), andtasks/groupTaskskeep their payload intasks[]instead ofcontent.The chat UI renders these correctly; the export template does not.
src/features/ShareModal/ShareText/template.ts→generateMarkdown()only recognisesuser | assistant | tool:for (const chat of filteredMessages) { parts.push(''); if (withRole) { if (chat.role === 'user') parts.push('##### User:', ''); else if (chat.role === 'assistant') parts.push('##### Assistant:', ''); else if (chat.role === 'tool') parts.push('##### Tools Calling:', ''); } if (chat.role === 'tool') parts.push('```json', String(chat.content), '```'); else { parts.push(String(chat.content)); // assistantGroup / supervisor → pushes an empty string if (includeTool && chat.tools?.length) parts.push('', '```json', JSON.stringify(chat.tools, null, 2), '```'); } }So every
assistantGroup/supervisorentry contributes a blank line and nothing else. The samegenerateMarkdownis used bySharePdf/index.tsx, so the PDF tab is affected identically.
Measured by replaying parse() + generateMarkdown() over the actual topic rows:
| Topic | virtual aggregate messages | assistant prose present in children[] |
assistant prose visible in the export |
|---|---|---|---|
| A — tool-heavy agent run | 77 | 7,937 chars | 0 chars |
| B — mostly tool calls, few plain replies | 153 | 262 chars | 1,290 chars |
| C — no tool calls at all | 3 | 0 chars | 7,497 chars |
Topic A's entire export is 102 characters:
# <topic title>
##### User:
<the user's message>
(…77 blank lines…)Topic C exports normally (~28 KB), which is why the bug looks intermittent — it only shows up once the conversation contains tool-calling assistant turns.
Turning on Include tool calls does not help: it merely dumps the tool-call JSON (~356 KB for topic A) while the assistant's actual words still never appear.
How to reproduce it?
- Self-hosted instance; use any agent that performs tool calls.
- Open a topic in which at least one assistant turn used a tool call.
- Topic list → the topic's
⋯menu → Share. - Switch to the Text tab → only the title and your own message are present; every assistant answer is gone.
- Switch to the PDF tab → the generated PDF is effectively blank (same markdown source).
- Compare with the Screenshot / JSON tabs of the same modal → content is complete, which proves the stored data is intact and only the Text/PDF path is at fault.
- Optional, makes it literal: turn off the "Include tool calls" field in the Text tab → the output collapses to
title + user message + blank lines.
What it should be?
Text and PDF should export the conversation the user actually sees, i.e. at minimum the assistant's visible answers.
Concretely, generateMarkdown() should resolve virtual roles before writing text — for example use resolveAssistantGroupFinalContent(chat) (or join children[].content) for assistantGroup / supervisor, expand tasks[] for tasks / groupTasks, and emit an ##### Assistant: header for them as well.
Alternative: have Text/PDF read dbMessages like JSON/Screenshot do. The first option is preferable, because it matches what the UI renders — the workflow-step vs final-answer separation is already implemented in partitionAssistantGroupBlocks().
Additional Information
- Verified against canary source
2a3f0bc(2026-09-18) with@lobechat/[email protected]. - Also verified in the deployed frontend chunks of the running instance: the shipped
ShareTexttemplate has the identicaluser | assistant | tool-only branch, and the shippedShareDataProviderstill mapsdisplayMessages = getDisplayMessagesByKey(...)anddbMessages = getDbMessagesByKey(...). So this is not a build/stale-cache artefact. SharePdfonly guardsif (activeId && displayMessages.length > 0)— withdisplayMessagesnon-empty but content-less, PDF generation proceeds and produces an empty document rather than failing loudly.- Suggested regression test: a fixture containing a tool-calling assistant turn, run
generateMarkdown()over itsflatList, and assert the assistant's text appears in the output (and that a conversation made only ofassistantGroupmessages does not produce a blank document). - Related prior art inside the repo:
src/store/chat/utils/topicTitle.tsalready handles this class of message viaresolveAssistantGroupFinalContent(), which is a good model for the fix. Any other consumer ofdisplayMessagesthat assumescontentis populated is likely to share this bug.
✅ Validations
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a LobeChat issue and not a third-party library or provider issue.
- Check that this is a concrete bug. For Q&A, please use GitHub Discussions or join our Discord Server.
Source: lobehub/lobehub