Skip to content

fix(feishu): preserve text when replies include media - #102399

Closed
ZengWen-DT wants to merge 3 commits into
openclaw:mainfrom
ZengWen-DT:fix/102390-feishu-text-media-replies
Closed

ZengWen-DT wants to merge 3 commits into
openclaw:mainfrom
ZengWen-DT:fix/102390-feishu-text-media-replies

Conversation

@ZengWen-DT

@ZengWen-DT ZengWen-DT commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #102390

What Problem This Solves

Fixes an issue where Feishu users would lose the visible text from an assistant final reply when that reply also included a regular MEDIA: attachment while streaming cards were active. The channel could finish with only the no-visible-content fallback instead of showing the assistant's text alongside the attachment.

Why This Change Was Made

The Feishu streaming reply path now closes the active final streaming card before dispatching regular media attachments, and it falls back to a normal text send first if the streaming close reports that no text became visible. That keeps the final text visible while preserving the existing separate media send behavior and the voice-media text suppression path.

AI-assisted.

User Impact

Feishu replies that combine text with an image or other regular attachment now keep the assistant's text visible and still send the attachment. Users should no longer see the misleading "reply completed without visible content" fallback for this text-plus-media streaming reply shape.

Evidence

Source-level before/after

Before (main, reply-dispatcher.ts:783-787): Streaming card is updated with final text but not closed before media dispatch — the code sends media and returns immediately, leaving the streaming card hanging:

// Send media even when streaming handled the text
if (hasMedia) {
    await sendMediaReplies(payload);
}
return;

After (this PR): closeStreaming() is called before media, with a plain-text fallback when close reports no visible content:

// Send media even when streaming handled the text
if (info?.kind === "final" && hasMedia) {
    const streamingCloseMadeTextVisible = await closeStreaming();
    if (!streamingCloseMadeTextVisible) {
        await sendChunkedTextReply({ text, useCard: false, ... });
    }
}
if (hasMedia) {
    await sendMediaReplies(payload);
}

When closeStreaming() returns false (card content was not visible), the dispatcher sends the final text as a plain Feishu message before sending the attachment, without emitting the no-visible-reply fallback.

Live Feishu gateway proof (after fix)

Gateway started from the PR branch with the Feishu WebSocket channel active. A DM triggered a reply containing text plus an image attachment (canvas-generated chart). Key gateway log sequence:

[feishu] Started streaming: cardId=7660505357496093898       ← text streamed via card
[feishu] sendMediaFeishu called                                ← media dispatch attempted
[feishu] Closed streaming: cardId=7660505357496093898         ← closeStreaming() called (THE FIX)
[feishu] dispatch complete (queuedFinal=true, replies=2)      ← dispatch finished

The Closed streaming log confirms closeStreaming() was called before sendMediaReplies() — the exact code path this PR adds. (The image upload itself returned Feishu code 234011 "Can't recognize image format" — a content-format issue in the canvas plugin output, unrelated to the reply dispatcher fix.)

Feishu client confirmation: The bot's reply text was visible in the Feishu Android app. Screenshot shows the assistant's text "Here's the monthly sales bar chart by quarter 📊" displayed correctly — no "reply completed without visible content" fallback appeared.

Focused test proof

node scripts/run-vitest.mjs extensions/feishu/src/reply-dispatcher.test.ts
→ 88 tests passed

Two new regression tests cover the exact paths:

  1. closes streaming final text before sending regular media attachments — close succeeds, media sent, no fallback
  2. falls back to plain final text when streaming close accepts no content before media — close returns false, plain text sent before media

Additional checks

node_modules/.bin/oxfmt --check extensions/feishu/src/reply-dispatcher.ts extensions/feishu/src/reply-dispatcher.test.ts → passed
git diff --check → passed

AI-assisted. Real behavior proof collected by human (live Feishu gateway logs + Feishu Android client screenshot).

@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: XS labels Jul 9, 2026
@clawsweeper

clawsweeper Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 18, 2026, 9:59 PM ET / July 19, 2026, 01:59 UTC.

Summary
The PR changes Feishu streaming-card closure and fallback handling so final reply text remains visible when regular media attachments are sent.

PR surface: Source +47, Tests +184. Total +231 across 4 files.

Reproducibility: yes. source-reproducible: a final Feishu reply containing text plus a regular MEDIA: attachment while an active streaming card is present reaches the return path that dispatches media without first committing final text. No fresh live reproduction was run in this read-only review.

Review metrics: none identified.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Post redacted proof from a successful Feishu run showing both the final text and the delivered attachment.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The supplied logs and Android screenshot show streaming close and visible text, but the same run records a rejected image upload, so it does not demonstrate the changed text-plus-media result after the fix. Add redacted successful gateway and client evidence; updating the PR body should trigger a fresh review, or a maintainer can request one with @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P2] Merging changes the order and fallback behavior of a user-visible Feishu text-plus-media delivery path; until a successful live attachment run is shown, duplicate, missing, or misleading final replies remain insufficiently ruled out.

Maintainer options:

  1. Capture a successful Feishu round trip (recommended)
    Before merge, provide redacted gateway evidence and client proof from one run where the final text and regular attachment both arrive, with the attachment upload succeeding.
  2. Pause for canonical-path selection
    If the startup and block-delivery cases from fix(feishu): preserve text before media attachments #102397 are required for the same user promise, choose and review one canonical implementation before landing either branch.

Next step before merge

  • [P1] No narrow automated repair is outstanding; a Feishu owner must obtain successful real-behavior proof and choose the canonical overlapping implementation before merge.

Maintainer decision needed

  • Question: Should this PR remain the narrow canonical fix for the active-streaming text-plus-media failure after successful live proof, or should the broader open implementation in fix(feishu): preserve text before media attachments #102397 be selected and narrowed instead?
  • Rationale: Both open PRs target the same canonical bug, but the broader branch covers additional failure modes and neither supplied record establishes it as a safe replacement; selecting a landing direction requires owner judgment beyond the available proof.
  • Likely owner: steipete — They authored the branch's focused repair and are the only explicit assigned contributor with direct implementation history in the provided record.
  • Options:
    • Retain the narrow fix and require proof (recommended): Keep this PR as the candidate, but require redacted successful Feishu evidence showing final text and the attachment before merge.
    • Adopt the broader path: Use the wider implementation only after its extra startup and block-delivery behavior is independently reviewed and proven, then close or supersede this branch deliberately.

Security
Cleared: The reviewed TypeScript changes are limited to Feishu reply-state and test behavior; no new dependency, permission, secret, workflow, or supply-chain execution path is introduced.

Review details

Best possible solution:

Keep the narrow card-close/fallback design only if a redacted live Feishu run demonstrates both the committed final text and a successfully delivered regular attachment; compare the wider failure handling in #102397 separately rather than merging both overlapping fixes blindly.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: a final Feishu reply containing text plus a regular MEDIA: attachment while an active streaming card is present reaches the return path that dispatches media without first committing final text. No fresh live reproduction was run in this read-only review.

Is this the best way to solve the issue?

Yes for the narrow active-card case: committing the stream or explicitly restoring final text before media preserves the existing separate media path. It is not yet proven end-to-end, and the broader failure cases in #102397 require a separate maintainer comparison.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 047232bd16e4.

Label changes

Label justifications:

  • P1: The PR addresses a reproducible Feishu reply path that can replace an assistant's intended text-plus-media response with a fallback warning.
  • merge-risk: 🚨 message-delivery: The patch changes the ordering and fallback semantics of visible text and attachment sends on an active streaming reply.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The supplied logs and Android screenshot show streaming close and visible text, but the same run records a rejected image upload, so it does not demonstrate the changed text-plus-media result after the fix. Add redacted successful gateway and client evidence; updating the PR body should trigger a fresh review, or a maintainer can request one with @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +47, Tests +184. Total +231 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 88 41 +47
Tests 2 196 12 +184
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 284 53 +231

What I checked:

  • Current-main behavior: The active streaming final-reply branch updates the streaming card, sends regular media when present, and returns without first closing the card; that is the source-level path described by the linked bug report. (extensions/feishu/src/reply-dispatcher.ts:783, 047232bd16e4)
  • Proposed delivery contract: The branch changes streaming close from a single visibility boolean to separate committed-content and requested-final-content visibility facts, then uses them to send plain final text before regular media when the requested final card content was not committed. (extensions/feishu/src/reply-dispatcher.ts:445, bd19ad42ab8c)
  • Streaming mutation semantics: The branch makes the streaming session distinguish previously visible preview text from whether the requested final rewrite was accepted, which is necessary to avoid falsely suppressing the fallback final text. (extensions/feishu/src/streaming-card.ts:612, bd19ad42ab8c)
  • Real-behavior proof gap: The PR body shows that streaming close ran and the text appeared, but it also records Feishu rejecting the image upload with code 234011; the actual fixed text-plus-media outcome therefore remains unproven. The prior completed review reached the same proof conclusion at commit 6b2e449. (6b2e44963641)
  • Related implementation scope: fix(feishu): preserve text before media attachments #102397 addresses the same report plus streaming-start and block-delivery failure paths, but it remains open and is not established as a proof-positive replacement for this narrower PR. (92e40e3d2e95)
  • Recent feature ownership signal: The branch's focused Feishu repair was authored by steipete in commit 6b2e449, making them the strongest available routing candidate for the current implementation direction. (extensions/feishu/src/reply-dispatcher.ts:445, 6b2e44963641)

Likely related people:

  • steipete: Authored the focused Feishu streaming-final/media repair commit on this branch and was assigned to the PR timeline. (role: recent area contributor; confidence: high; commits: 6b2e44963641; files: extensions/feishu/src/reply-dispatcher.ts, extensions/feishu/src/streaming-card.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (6 earlier review cycles)
  • reviewed 2026-07-09T04:00:30.553Z sha f4943439d400b0e2c2ab1eea53662c717d159828 :: needs real behavior proof before merge. :: [P2] Handle failed streaming close before media
  • reviewed 2026-07-09T04:06:34.307Z sha f4943439d400b0e2c2ab1eea53662c717d159828 :: needs real behavior proof before merge. :: [P2] Handle failed streaming close before media
  • reviewed 2026-07-09T04:18:10.226Z sha e9c8ec7b94c69cdca33ed94e6a3dbfac2ecb5b0c :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-09T13:13:50.973Z sha e9c8ec7b94c69cdca33ed94e6a3dbfac2ecb5b0c :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-10T08:49:25.623Z sha e9c8ec7b94c69cdca33ed94e6a3dbfac2ecb5b0c :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-10T11:50:45.908Z sha 6b2e449 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 9, 2026
@ZengWen-DT
ZengWen-DT force-pushed the fix/102390-feishu-text-media-replies branch from f494343 to e9c8ec7 Compare July 9, 2026 04:08
@ZengWen-DT

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated the Feishu dispatcher to use the streaming close visibility result. If close reports no visible text, the final text is sent as a normal message before media attachments, and the regression test now covers that close-false/media-success path.

@clawsweeper

clawsweeper Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@ZengWen-DT

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@steipete steipete self-assigned this Jul 10, 2026
@steipete
steipete force-pushed the fix/102390-feishu-text-media-replies branch from e9c8ec7 to 86f8c3d Compare July 10, 2026 09:01
Close or fall back final streaming text before delivering regular media attachments, and treat Feishu CardKit business errors as failed mutations.

Co-authored-by: Wynne668 <[email protected]>
@steipete
steipete force-pushed the fix/102390-feishu-text-media-replies branch from 86f8c3d to 6b2e449 Compare July 10, 2026 09:31
@ZengWen-DT

Copy link
Copy Markdown
Contributor Author

Closing — the core issue reported in #102390 is no longer reproducible on main.

The main branch already covers the normal text+media path through onIdle → closeStreaming() → markVisibleReplySent(). The fallback won't fire because ensureNoVisibleReplyFallback awaits idleSideEffectsPromise before checking visibility.

The edge cases this PR additionally guards (streaming start failure, close rejection) are real but narrow. If they cause user-visible issues, a new issue/PR can target them specifically. The overlapping PR #102397 is also open and may cover these paths more comprehensively.

@ZengWen-DT ZengWen-DT closed this Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Feishu: Assistant reply with text + MEDIA: directive silently loses the text and triggers "reply completed without visible content" fallback

2 participants