Skip to content

Deliver local Bot reply images to Feishu with workspace checks and retry-safe sends - #1765

Closed
tianmazi wants to merge 2 commits into
Fei2411:devfrom
tianmazi:fix/1761-feishu-reply-images
Closed

tianmazi wants to merge 2 commits into
Fei2411:devfrom
tianmazi:fix/1761-feishu-reply-images

Conversation

@tianmazi

@tianmazi tianmazi commented Nov 17, 2026 •

Copy link
Copy Markdown

Issue

Fixes #1761

A Bot reply such as ![Screenshot](<output/screenshot.png>) can render an image in DS Bot while Feishu receives only its local Markdown path. The adapter never uploads those bytes or sends an image key.

What changed / 改了什么

  • Carry the replying Session and, for group replies, the member author into the existing origin-scoped send queue.
  • Extract explicitly linked local Markdown images outside code examples; remote URLs remain text.
  • Read images through the existing markdown-image endpoint, preserving its workspace, private-data-folder, symlink, size and Session checks. No second unrestricted filesystem reader is introduced.
  • Upload byte-identified PNG/JPEG/GIF/WebP as multipart image_type=message, then send the returned image_key as a native Feishu image to the originating chat.
  • Preserve completed chunks, upload keys and per-message UUIDs across retries/replacement runners, so a later failure does not duplicate already delivered captions or pictures. Read/upload failures reach the normal IM error/retry path.
  • Parse real Markdown image nodes with mdast-util-from-markdown (declared/pinned MIT dependency, attributed in NOTICE), excluding code/escaped examples and resolving balanced destinations and image-reference definitions.
  • Add fifteen adapter/parser cases and extend the existing host routing test to check direct/group author context and the shared image-reader call.

This is a focused companion to #1670 (Markdown cards) and #1680 (inbound rich posts/v2 buttons), and overlaps the Feishu image portion of #1257. It leaves their behavior changes to those PRs. The existing mixed-source/no-origin rule remains enforced. Typed deliverables and arbitrary remote image downloading are outside this patch; it handles local Markdown images explicitly included in a reply.

Changelog

Feishu now receives images explicitly linked in Bot replies as native pictures, including group-member replies, with workspace checks and retry-safe delivery.
飞书现在可以收到 Bot 回复中明确引用的本地图片,群聊成员回复同样支持,并保留工作目录检查及重试去重。

How I checked it / 怎么验证的

  • Focused upstream tests on Node 22.14 and Node 24.22.3: node --test test/im-feishu.test.js test/im-feishu-images.test.js — 35 passed after the review fixes.
  • Against the unmodified dev adapter, the ten new cases produce 7 failures; the patched adapter passes all ten.
  • node scripts/build-client.mjs --check.
  • git diff --check.
  • IM host integration: all 59 tests passed.
  • Full suite completed: 2,915 tests, 2,908 passed, 4 failed, 3 skipped. The four failures are connector-gateway slow-stream/error tests; three also fail against unchanged gateway code on dev, while one passes in the isolated baseline run. This is not a green full-suite result.
  • npm run lint: passed (existing warnings only).
  • Leak scan: no must-fix findings.
  • Bench smoke test not run: this environment has the isolated npm test harness but no DSH source checkout or pnpm. The reporter separately confirmed the combined local patches in a real restarted desktop/Feishu session.
  • Reporter confirmed image delivery after restarting with this media patch plus Keep IM routing through harness metadata and active goal continuations #1768 (the origin-classification fix), with the local Markdown-card/rich-post fixes also applied. This does not claim standalone live validation of this PR; automated tests use synthetic media only.
  • Screenshot: not applicable to DS Bot UI; src/client/ is unchanged.

Checklist / 检查

  • One subject: delivery of explicitly linked local reply images to Feishu.
  • src/client/ unchanged; no generated client edit.
  • No credentials, real conversations, personal paths, screenshots or DSH data in the patch.
  • Human commit author; no AI-tool author or co-author.

Opened as a draft from the reporter's fork. I recognize the current collaborator-only contribution policy; the linked issue and commit remain available for a collaborator to review or integrate if external PRs are not accepted.

Review follow-up

Commit fff96f0 replaces the regular-expression extractor with Markdown AST parsing and adds regressions for both review findings. Devin posted Resolved replies for both threads. The separate Harness snapshot origin failure is tracked and fixed by #1767 / #1768.

Resolve explicitly linked images through the existing workspace reader, upload them to Feishu, and retain per-job delivery progress and idempotency keys across retries.
devin-ai-integration[bot]

This comment was marked as resolved.

Respect code blocks, escaped markers and variable backtick spans, and resolve balanced destinations and reference image definitions using mdast. Add regressions for both review findings.

@Fei2411 Fei2411 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Verdict: COMMENT — defer; not ready to review for merge yet (draft).

The approach looks sound: images are read through the existing markdown-image endpoint, so workspace, symlink, size and Session checks are reused, and only local Markdown images are taken, not code examples or remote URLs. A few things need to happen before a full review:

  1. Base it on the snapshot fix that will land. The body says live validation depends on #1768, but #1768 is being recommended for closure in favour of #1750. Please validate against #1750 instead.
  2. Feishu card structure. #1680 replaces the schema-2.0 action container with column_set buttons, and #1670 turns every chunk into a card. This PR touches the same send path in feishu.js, so merge dev after those land and re-check.
  3. New runtime dependency. mdast-util-from-markdown (+613 lines of lockfile) needs maintainer approval under the repo rules. If the extraction can reuse a parser DS Bot or DSH already ships, that would be preferable. Otherwise keep the NOTICE entry and justify the choice in the PR body.
  4. The PR template asks for screenshot/GIF evidence of a real Feishu delivery when it leaves draft.

Mark it ready once 1–3 are settled, and I'll do a full review.

@Fei2411 Fei2411 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Needs changes now that this is out of draft. Rechecking on current dev, #1680's Feishu card work is already merged and combines cleanly with this branch; #1670 is still open. The remaining code issue I reproduced is partial delivery: ds-bot/src/host/im/platforms/feishu.js:408–441 sends text first, then awaits each image inside the same cursor loop. If the first image is missing, a valid second image is never read. The image endpoint reports bot/not-found without HTTP status; the IM queue classifies that as retryable (ds-bot/src/host/im/index.js:537–540,619–634) and revisits the same missing image on every retry. In my mock, a missing image followed by a valid one sent text only across two attempts; the valid image sent normally in isolation. Please isolate permanent per-image read/validation failures so later valid images can deliver, while still resuming on transient upload/send failures without repeating text. Please also validate against #1750 rather than the now-closed #1768.

@Fei2411

Fei2411 commented Nov 20, 2026

Copy link
Copy Markdown
Owner

感谢贡献!IM 回复原生发图已由支持 6 个平台的 #1868 覆盖,本草稿 PR 先致谢关闭。

@Fei2411 Fei2411 closed this Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants