#19970·lobehub

[Bug] Share export: Text and PDF tabs are blank — the export template ignores virtual assistantGroup messages

Author: liangxyzCreated Sep 25, 2026Updated Sep 25, 2026

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:

  1. The four share tabs do not read the same data. ShareDataProvider exposes both dbMessages and displayMessages:

    • Screenshot / JSON → dbMessages (raw DB rows)
    • Text / PDF → displayMessages, i.e. the flatList produced by parse() from @lobechat/conversation-flow
  2. parse() folds every tool-calling assistant turn into a virtual aggregate message, whose top-level content is emptied and whose real text is moved into children[]:

    typescript
    // 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: ''), and tasks / groupTasks keep their payload in tasks[] instead of content.

  3. The chat UI renders these correctly; the export template does not. src/features/ShareModal/ShareText/template.ts → generateMarkdown() only recognises user | assistant | tool:

    typescript
    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 / supervisor entry contributes a blank line and nothing else. The same generateMarkdown is used by SharePdf/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?

  1. Self-hosted instance; use any agent that performs tool calls.
  2. Open a topic in which at least one assistant turn used a tool call.
  3. Topic list → the topic's ⋯ menu → Share.
  4. Switch to the Text tab → only the title and your own message are present; every assistant answer is gone.
  5. Switch to the PDF tab → the generated PDF is effectively blank (same markdown source).
  6. 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.
  7. 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 ShareText template has the identical user | assistant | tool-only branch, and the shipped ShareDataProvider still maps displayMessages = getDisplayMessagesByKey(...) and dbMessages = getDbMessagesByKey(...). So this is not a build/stale-cache artefact.
  • SharePdf only guards if (activeId && displayMessages.length > 0) — with displayMessages non-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 its flatList, and assert the assistant's text appears in the output (and that a conversation made only of assistantGroup messages does not produce a blank document).
  • Related prior art inside the repo: src/store/chat/utils/topicTitle.ts already handles this class of message via resolveAssistantGroupFinalContent(), which is a good model for the fix. Any other consumer of displayMessages that assumes content is 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.