Skip to content

fix(feishu): read full CardKit streaming card content via raw_card_content param - #55466

Closed
guoqunabc wants to merge 6 commits into
openclaw:mainfrom
guoqunabc:fix/feishu-raw-card-content
Closed

guoqunabc wants to merge 6 commits into
openclaw:mainfrom
guoqunabc:fix/feishu-raw-card-content

Conversation

@guoqunabc

Copy link
Copy Markdown
Contributor

Problem

When reading messages that were sent as CardKit streaming cards (created via POST /cardkit/v1/cards), the IM API (GET /im/v1/messages/{message_id}) returns fallback content (a screenshot image + placeholder text like [Interactive Card]) instead of the actual card text content. This makes it impossible to retrieve the full text of bot replies that use streaming cards.

Root Cause

CardKit streaming cards are referenced by card_id in the message body ({"type":"card","data":{"card_id":"xxx"}}). The CardKit API only provides write endpoints — there is no read API to fetch card content by card_id. However, the IM message read API supports an undocumented query parameter card_msg_content_type=raw_card_content that instructs the API to inline the full card structure as a json_card field in the response content.

Fix

1. Pass card_msg_content_type parameter

Add card_msg_content_type: "raw_card_content" to both:

  • client.im.message.get() — used by getMessageFeishu() for single message reads
  • client.im.message.list() — used by listFeishuThreadMessages() for thread history

2. Parse json_card format in parseInteractiveCardContent

Before the existing element-based parsing, check for the json_card field (a JSON string) and extract text from:

  • config.summary.content — the card summary (streaming cards write the full reply text here)
  • body.elements — recursively extract plain_text and markdown nodes, including nested structures like column_set

Falls through to the existing elements / body.elements parsing if json_card is absent or unparseable.

3. Tests

Added 3 new test cases:

  • Verifies card_msg_content_type param is passed to message.get
  • Verifies json_card format is correctly parsed (summary + nested body elements)
  • Verifies fallback to legacy elements when json_card contains invalid JSON

Related Issues

References

  • The official Lark plugin (larksuite/openclaw-lark) uses the same card_msg_content_type=raw_card_content parameter in its fetchCardContent function (src/messaging/inbound/parse-io.ts).

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime channel: feishu Channel integration: feishu size: M labels Mar 27, 2026
@greptile-apps

greptile-apps Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes the inability to read full text content from Feishu CardKit streaming cards by passing the undocumented card_msg_content_type=raw_card_content query parameter to both the single-message and thread-list IM API calls. It also adds a json_card parsing branch (with recursive element extraction) that runs before the existing legacy elements/body.elements path, and extends the buildSessionEventSnapshot helper in server-chat.ts to promote several additional session metadata fields to the top level of the broadcast payload.

  • send.ts: card_msg_content_type added to both message.get and message.list; new extractJsonCardTexts helper recursively extracts plain_text and markdown content from column/element trees; parseInteractiveCardContent tries the json_card path first and gracefully falls through on parse failure.
  • send.test.ts: Three targeted new test cases cover param forwarding, json_card parsing (including column_set nesting), and JSON parse-error fallback — good coverage of the new code paths.
  • server-chat.ts: Many additional session row fields (fastMode, verboseLevel, sendPolicy, responseUsage, etc.) are now promoted to the top level of the session snapshot, bringing it in line with what session already exposes nested.
  • server-chat.agent-events.test.ts: New lifecycle test validates that the promoted fields arrive correctly in the broadcast payload.

Confidence Score: 4/5

Safe to merge; changes are additive with clean fallback behaviour and solid test coverage.

The core Feishu fix is well-implemented — it adds the undocumented param, parses the new response format, falls back gracefully on parse failure, and is backed by three new tests. The server-chat.ts snapshot expansion is additive and validated by a new test. The one minor inconsistency (the rows field is declared in the type but never iterated over) is a P2 cleanup item that does not affect the primary user path or introduce any regressions.

No files require special attention; extensions/feishu/src/send.ts has one minor type/logic gap around rows worth a follow-up.

Important Files Changed

Filename Overview
extensions/feishu/src/send.ts Adds card_msg_content_type=raw_card_content param to both message.get and message.list, and a new extractJsonCardTexts helper + json_card parsing branch in parseInteractiveCardContent. Logic is sound with proper fallback; minor inconsistency between the typed rows field and missing recursion over it.
extensions/feishu/src/send.test.ts Three new test cases cover param forwarding, json_card parsing with nested column_set elements, and fallback on invalid JSON — good coverage of the new code paths.
src/gateway/server-chat.ts Promotes many additional session row fields (fastMode, verboseLevel, sendPolicy, responseUsage, etc.) to the top level of the session snapshot object. Additive change that mirrors what was already done for totalTokens/contextTokens.
src/gateway/server-chat.agent-events.test.ts Adds a lifecycle test validating that promoted session metadata fields are present at the top level of the broadcast payload; also fixes the module mock for loadGatewaySessionRow to prevent test bleed.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/feishu/src/send.ts
Line: 189-212

Comment:
**`rows` field typed but never recursed into**

The node type includes `rows?: unknown[]`, and the comment references "form elements, etc." as a motivation for recursion — but there is no corresponding loop over `rows`. Any CardKit elements that store text inside rows (e.g., a `form` element with row-based layout) would be silently skipped.

Either add the recursion or remove the `rows` field from the type to keep the declared surface and the implementation in sync:

```suggestion
    const node = el as {
      tag?: string;
      property?: { content?: string };
      elements?: unknown[];
      columns?: unknown[];
    };
    if (node.tag === "plain_text" && typeof node.property?.content === "string") {
      texts.push(node.property.content);
    }
    if (node.tag === "markdown" && typeof (node as { content?: string }).content === "string") {
      texts.push((node as { content?: string }).content!);
    }
    // Recurse into nested structures (column_set columns, form elements, etc.)
    if (Array.isArray(node.elements)) {
      texts.push(...extractJsonCardTexts(node.elements));
    }
    if (Array.isArray(node.columns)) {
      for (const col of node.columns) {
        if (
          col &&
          typeof col === "object" &&
          Array.isArray((col as { elements?: unknown[] }).elements)
        ) {
          texts.push(...extractJsonCardTexts((col as { elements: unknown[] }).elements));
        }
      }
    }
```

Or, if rows are intentionally planned for the future, add a `// TODO: recurse into rows` comment so it is not forgotten.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(feishu): read full CardKit streaming..." | Re-trigger Greptile

Comment thread extensions/feishu/src/send.ts Outdated
Comment on lines +189 to +212
rows?: unknown[];
};
if (node.tag === "plain_text" && typeof node.property?.content === "string") {
texts.push(node.property.content);
}
if (node.tag === "markdown" && typeof (node as { content?: string }).content === "string") {
texts.push((node as { content?: string }).content!);
}
// Recurse into nested structures (column_set columns, form elements, etc.)
if (Array.isArray(node.elements)) {
texts.push(...extractJsonCardTexts(node.elements));
}
if (Array.isArray(node.columns)) {
for (const col of node.columns) {
if (
col &&
typeof col === "object" &&
Array.isArray((col as { elements?: unknown[] }).elements)
) {
texts.push(...extractJsonCardTexts((col as { elements: unknown[] }).elements));
}
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 rows field typed but never recursed into

The node type includes rows?: unknown[], and the comment references "form elements, etc." as a motivation for recursion — but there is no corresponding loop over rows. Any CardKit elements that store text inside rows (e.g., a form element with row-based layout) would be silently skipped.

Either add the recursion or remove the rows field from the type to keep the declared surface and the implementation in sync:

Suggested change
rows?: unknown[];
};
if (node.tag === "plain_text" && typeof node.property?.content === "string") {
texts.push(node.property.content);
}
if (node.tag === "markdown" && typeof (node as { content?: string }).content === "string") {
texts.push((node as { content?: string }).content!);
}
// Recurse into nested structures (column_set columns, form elements, etc.)
if (Array.isArray(node.elements)) {
texts.push(...extractJsonCardTexts(node.elements));
}
if (Array.isArray(node.columns)) {
for (const col of node.columns) {
if (
col &&
typeof col === "object" &&
Array.isArray((col as { elements?: unknown[] }).elements)
) {
texts.push(...extractJsonCardTexts((col as { elements: unknown[] }).elements));
}
}
}
}
const node = el as {
tag?: string;
property?: { content?: string };
elements?: unknown[];
columns?: unknown[];
};
if (node.tag === "plain_text" && typeof node.property?.content === "string") {
texts.push(node.property.content);
}
if (node.tag === "markdown" && typeof (node as { content?: string }).content === "string") {
texts.push((node as { content?: string }).content!);
}
// Recurse into nested structures (column_set columns, form elements, etc.)
if (Array.isArray(node.elements)) {
texts.push(...extractJsonCardTexts(node.elements));
}
if (Array.isArray(node.columns)) {
for (const col of node.columns) {
if (
col &&
typeof col === "object" &&
Array.isArray((col as { elements?: unknown[] }).elements)
) {
texts.push(...extractJsonCardTexts((col as { elements: unknown[] }).elements));
}
}
}

Or, if rows are intentionally planned for the future, add a // TODO: recurse into rows comment so it is not forgotten.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/feishu/src/send.ts
Line: 189-212

Comment:
**`rows` field typed but never recursed into**

The node type includes `rows?: unknown[]`, and the comment references "form elements, etc." as a motivation for recursion — but there is no corresponding loop over `rows`. Any CardKit elements that store text inside rows (e.g., a `form` element with row-based layout) would be silently skipped.

Either add the recursion or remove the `rows` field from the type to keep the declared surface and the implementation in sync:

```suggestion
    const node = el as {
      tag?: string;
      property?: { content?: string };
      elements?: unknown[];
      columns?: unknown[];
    };
    if (node.tag === "plain_text" && typeof node.property?.content === "string") {
      texts.push(node.property.content);
    }
    if (node.tag === "markdown" && typeof (node as { content?: string }).content === "string") {
      texts.push((node as { content?: string }).content!);
    }
    // Recurse into nested structures (column_set columns, form elements, etc.)
    if (Array.isArray(node.elements)) {
      texts.push(...extractJsonCardTexts(node.elements));
    }
    if (Array.isArray(node.columns)) {
      for (const col of node.columns) {
        if (
          col &&
          typeof col === "object" &&
          Array.isArray((col as { elements?: unknown[] }).elements)
        ) {
          texts.push(...extractJsonCardTexts((col as { elements: unknown[] }).elements));
        }
      }
    }
```

Or, if rows are intentionally planned for the future, add a `// TODO: recurse into rows` comment so it is not forgotten.

How can I resolve this? If you propose a fix, please make it concise.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9649267f22

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/feishu/src/send.ts Outdated
Comment on lines +423 to +424
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- card_msg_content_type is not in the SDK types yet
const listParams: any = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore type safety for Feishu list query params

This change introduces // eslint-disable-next-line @typescript-eslint/no-explicit-any and const listParams: any, which violates the documented repo rule in AGENTS.md (“Never add @ts-nocheck and do not disable no-explicit-any”). More importantly, it removes compile-time validation for the message.list query shape, so future SDK type changes or param typos here can silently pass CI and only fail when thread reads run in production; please use a typed local param shape (or a narrowly scoped cast) instead of disabling the rule.

Useful? React with 👍 / 👎.

@guoqunabc
guoqunabc force-pushed the fix/feishu-raw-card-content branch from 9649267 to cf582f3 Compare March 27, 2026 02:01
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed gateway Gateway runtime size: M labels Mar 27, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf582f3a5e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/feishu/src/send.ts Outdated
Comment on lines +237 to +238
if (Array.isArray(jsonCard.body?.elements)) {
parts.push(...extractJsonCardTexts(jsonCard.body!.elements));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Parse top-level json_card elements

With card_msg_content_type=raw_card_content, interactive messages can be wrapped as {"json_card":"..."}. This new branch only reads jsonCard.body.elements, but schema 1.0 cards store textual blocks in top-level elements (which the legacy parser path already handled). In that case parts stays empty, then fallback parsing runs against the wrapper object (not the parsed card), and the function returns [Interactive Card] instead of the actual text. Please also extract from jsonCard.elements before falling through.

Useful? React with 👍 / 👎.

@EronFan EronFan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: ✅ Approve with suggestions

Solid fix overall — the approach is well-researched and the test coverage is thorough. Three issues to address before merge:


1. 🔴 Missing top-level json_card.elements extraction (P1)

When a schema 1.0 card has textual content at jsonCard.elements (not inside jsonCard.body.elements), the current code skips it entirely and falls through to legacy parsing. But legacy parsing runs against the parsed wrapper object — not the parsed card — so it returns [Interactive Card] instead of the actual text.

Fix: Also extract from jsonCard.elements before falling through:

if (Array.isArray(jsonCard.elements)) {
  parts.push(...extractJsonCardTexts(jsonCard.elements));
}

2. 🟡 rows field typed but never recursed into (P1)

extractJsonCardTexts types columns?: unknown[] and recurses into it, but the node type also has rows?: unknown[] which is never handled. If CardKit form elements store text inside rows, it is silently dropped.

Fix: Either recurse into rows (since the type already claims it exists) or remove rows from the type declaration to keep surface area and implementation in sync:

if (Array.isArray(node.rows)) {
  for (const row of node.rows) {
    if (row && typeof row === object && Array.isArray((row as { elements?: unknown[] }).elements)) {
      texts.push(...extractJsonCardTexts((row as { elements: unknown[] }).elements));
    }
  }
}

3. 🟡 Type safety: avoid Record<string, string> cast

Using params: { card_msg_content_type: raw_card_content } as Record<string, string> disables compile-time checking for the entire params object. If someone later adds another param with a non-string type, it passes silently.

Better approach: a narrow scoped cast:

const cardParams = { card_msg_content_type: raw_card_content } as Record<string, string>;
params: cardParams,

Or just as Record<'card_msg_content_type', string>.


Non-blocking notes:

  • The // TODO: recurse into rows approach is fine if rows handling is deferred — just add the comment so it is not forgotten.
  • Test coverage for the three cases is solid.

Overall the approach is correct. Fix items 1 (critical bug) and 2 (completeness) and this is good to merge.

@EronFan

EronFan commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Addressing the 3 Greptile items:

Item 1 (top-level json_card.elements): Confirmed critical. The code only checks jsonCard.body.elements, missing schema 1.0 cards that store text in jsonCard.elements. Please also extract from jsonCard.elements before falling through to legacy parsing.

Item 2 (rows recursion): Confirmed completeness issue. The rows field is typed but not handled in extractJsonCardTexts. Either add rows recursion or remove rows from the type.

Item 3 (type safety): Type cast noted. A narrowly scoped cast (as Record<'card_msg_content_type', string>) would be cleaner than Record<string, string>.

Overall the approach is sound and the test coverage is solid. These are all pre-merge fixable items.

@guoqunabc

Copy link
Copy Markdown
Contributor Author

CI Failure Analysis

All CI failures in this PR are pre-existing on main and unrelated to our changes.

Evidence

Our PR only modifies extensions/feishu/src/send.ts and extensions/feishu/src/send.test.ts. The feishu-specific CI job (extension-fast-feishu) passes.

Main branch CI (run 23627455328) also fails the same jobs:

  • check-additional — config-docs-drift + plugin-sdk-api-drift (baseline regeneration needed after upstream refactors)
  • checks-fast-contracts-protocol — runtime.contract.test.ts openai-codex OAuth refresh test
  • checks-fast-extensions — matrix Jiti proxy ownKeys TypeError (irc/config-schema.ts)
  • checks-node-test-1/2/3/4 — timeouts in registry/catalog/bundled-web-search contracts, cron owner-auth, config validation allowed-values
  • checks-windows-node-test-2/3/6 — same timeout failures on Windows

build-smoke (memory: 409.4 MB RSS vs 400 MB limit) is marginal and not caused by our +66 lines of pure function code. Main passes this at the boundary — it is a known flaky check.

Our Changes

  • ✅ extension-fast-feishu — PASS
  • ✅ No server-chat.ts or server-chat.agent-events.test.ts modifications (clean diff)
  • ✅ Only send.ts (add extractJsonCardTexts + json_card parsing) and send.test.ts (corresponding tests)

@guoqunabc

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review @EronFan! All 3 items addressed:

Item 1 (schema 1.0 elements): Fixed — now also extracts from jsonCard.elements (top-level) in addition to jsonCard.body.elements. Schema 1.0 cards are covered.

Item 2 (rows recursion): Already removed in the previous commit — confirmed rows is no longer in the type declaration.

Item 3 (type cast): For getMessageFeishu, the SDK's message.get params type requires an index-signature-compatible type, so Record<string, string> is the narrowest cast that compiles (a single-key Record triggers TS2559). For listFeishuThreadMessages, the cast already uses typeof listParams & { card_msg_content_type?: string } which is more precise.

Changes pushed — CI should re-run shortly.

@EronFan

EronFan commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

All 3 items confirmed addressed:

  1. ✅ Schema 1.0 elements: commit e7ea88f7 now extracts from jsonCard.elements in addition to jsonCard.body.elements — schema 1.0 cards covered.
  2. ✅ rows type: already removed in previous commit — surface area and implementation are now in sync.
  3. ✅ Type cast: SDK constraint understood.

The feishu extension CI job (extension-fast-feishu) passes. The pre-existing main CI failures are unrelated to this PR.

This PR looks good to merge.

@guoqunabc
guoqunabc force-pushed the fix/feishu-raw-card-content branch from e7ea88f to 9fff12d Compare March 27, 2026 06:24
@guoqunabc
guoqunabc requested a review from EronFan March 27, 2026 06:25

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9fff12dff4

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +190 to +194
if (node.tag === "plain_text" && typeof node.property?.content === "string") {
texts.push(node.property.content);
}
if (node.tag === "markdown" && typeof (node as { content?: string }).content === "string") {
texts.push((node as { content?: string }).content!);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Handle div nodes when extracting json_card text

With card_msg_content_type=raw_card_content, interactive content can arrive in json_card.elements using schema 1.0 blocks like {"tag":"div","text":{"content":"..."}} (which the legacy parser handled). extractJsonCardTexts currently only collects plain_text and markdown, so json_card payloads containing only div text produce no parts and fall through to parsing the wrapper object, resulting in [Interactive Card] instead of the message text. This regresses thread/message reads for existing schema 1.0 cards unless div.text.content is also extracted (or fallback parsing is applied to the parsed jsonCard object).

Useful? React with 👍 / 👎.

@guoqunabc
guoqunabc force-pushed the fix/feishu-raw-card-content branch 2 times, most recently from 1e2b37c to 4b94e46 Compare March 28, 2026 23:01
@guoqunabc
guoqunabc force-pushed the fix/feishu-raw-card-content branch from 4b94e46 to 0e256f3 Compare March 31, 2026 05:51

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e256f314a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@@ -122,6 +122,110 @@ describe("getMessageFeishu", () => {
});
expect(mockConvertMarkdownTables).toHaveBeenCalledWith("hello", "preserve");
expect(result).toEqual({ messageId: "om_send", chatId: "oc_send" });

it("passes card_msg_content_type param to message.get", async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Close the first test before declaring new test cases

it("passes card_msg_content_type param to message.get", ...) is currently declared inside the callback of it("sends text without requiring Feishu runtime text helpers", ...) because the outer test is missing its closing }); before this line. In Vitest/Jest-style runners, defining tests during test execution is invalid and can throw a nested-test error, which means this suite can fail and the newly added CardKit assertions won’t actually run as independent test cases.

Useful? React with 👍 / 👎.

@guoqunabc
guoqunabc force-pushed the fix/feishu-raw-card-content branch 3 times, most recently from 51490d8 to 6ec6946 Compare April 3, 2026 23:01
@guoqunabc
guoqunabc force-pushed the fix/feishu-raw-card-content branch from 6ec6946 to d571323 Compare April 9, 2026 23:01

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d5713233f0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +238 to +239
if (typeof jsonCard.config?.summary?.content === "string") {
parts.push(jsonCard.config.summary.content);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid prepending summary when body already has full card text

parseInteractiveCardContent always appends config.summary.content before body elements, but streaming cards written by this plugin store only a truncated prefix in summary and the full reply in body content (extensions/feishu/src/streaming-card.ts updates summary via truncateSummary during close). In that common path, reads become "<truncated prefix>\n<full reply>", duplicating the opening text and inflating downstream thread context/token usage; summary should be fallback-only (or deduplicated) when body extraction already succeeds.

Useful? React with 👍 / 👎.

@guoqunabc
guoqunabc force-pushed the fix/feishu-raw-card-content branch from 2172598 to 2fb2d64 Compare April 10, 2026 23:03
@guoqunabc
guoqunabc force-pushed the fix/feishu-raw-card-content branch from 2fb2d64 to d03a87c Compare April 12, 2026 23:06
@guoqunabc
guoqunabc force-pushed the fix/feishu-raw-card-content branch from d03a87c to 64e6dab Compare April 13, 2026 23:01
guoqunabc and others added 6 commits April 16, 2026 07:01
…ntent param

- Add card_msg_content_type=raw_card_content param to message.get and message.list
  API calls so the IM API returns the full json_card structure instead of fallback
  screenshot content for CardKit streaming cards.

- Extend parseInteractiveCardContent to extract text from the json_card format:
  reads config.summary.content and recursively extracts plain_text/markdown nodes
  from body.elements. Falls through to existing element parsing on failure.

- Add extractJsonCardTexts helper for recursive text extraction from nested
  CardKit element structures (column_set, nested elements, etc.).

- Add tests for json_card parsing, param passing, and fallback behavior.
The 'sends text without requiring Feishu runtime text helpers' test
was missing its closing '});', causing subsequent test cases to be
nested inside it. This fixes test isolation.
@guoqunabc
guoqunabc force-pushed the fix/feishu-raw-card-content branch from 64e6dab to 68d3e30 Compare April 15, 2026 23:01
@guoqunabc

Copy link
Copy Markdown
Contributor Author

Closing — no longer needed. Thanks for the review @EronFan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants