Skip to content

feat(feishu): stream replies into a live interactive card - #7823

Open
roycema-vibecoding wants to merge 1 commit into
kirodotdev:mainfrom
roycema-vibecoding:feat/feishu-streaming-card
Open

roycema-vibecoding wants to merge 1 commit into
kirodotdev:mainfrom
roycema-vibecoding:feat/feishu-streaming-card

Conversation

@roycema-vibecoding

@roycema-vibecoding roycema-vibecoding commented Sep 2, 2026 •

Copy link
Copy Markdown

Problem / Motivation

Goal: Show the answer as it is produced, without giving up the guarantee that a failure still delivers the complete reply.

The Feishu channel renders a whole turn into a buffer and sends it as one plain-text
message on on_done. FEISHU_CAPABILITIES accordingly declares streaming=False,
edit=False, rich_blocks=False.

What a user observes:

  • A long turn looks like a dead bot. Nothing at all appears until the answer is
    complete — no typing indicator, no placeholder, no partial text.
  • Sending a second message meanwhile gets merged into the in-flight turn and
    answered with a placeholder, while the real answer arrives as a quote-reply
    anchored to the earliest message of the batch — easy to miss entirely in a
    busy DM.
  • The reply is plain text, so tables, headings and code fences arrive as raw
    markdown.

The renderer's own docstring anticipates the follow-up, and the module spec lists
edit-in-place streaming as the natural next step.

Why it matters

This is the difference between a channel that feels broken and one that feels
alive. For any turn that takes more than a couple of seconds — which is most
non-trivial ones — the user cannot tell whether the bot received the message, is
working, or has crashed, so the rational response is to send it again, which makes
things worse by triggering the merge-into-placeholder path.

Feishu/Lark is the primary work chat for a large number of teams in China, and it
is the one first-party channel where a long answer is invisible until it is
finished.

Not a goal

What changed (motivation → approach → change)

With feishu.streaming on, a direct message now shows its answer in a live Feishu card that fills in as the model writes. Any failure falls back to today's single text reply, so turning it on can never cost the answer.

Feishu's own streaming primitive is a CardKit card, not an edited text message. Each push carries the whole answer so far and the server animates the difference, so a dropped frame repairs itself on the next push and on the final full replace. The approach is ported from two MIT-licensed Feishu plugins and attributed in NOTICE and THIRD-PARTY-NOTICES.

Part What it does
feishu/streaming_card.py (new) Opens the card, pushes on a 100 ms throttle, seals it, and maps each Feishu error code to drop the frame, demote tables, retire, or stop because the message is gone. A retired card is taken out of streaming mode.
Card text Clamps headings, spaces code blocks and turns bare URLs into links. Code blocks are found line by line, so their contents are never rewritten. An image the card cannot load becomes a link or its alt text, never deleted. The renderer's redaction screen runs again on the finished card body, so text the card rewrites is scanned as shown.
feishu/renderer.py Opens the card at turn start and pushes frames that are built only when a push is due. The redaction notice counts the body the card shows.
feishu/client.py Adds the CardKit calls through the SDK's generic BaseRequest path, which owns the tenant token and the domain, and reads the error code Feishu puts in an HTTP 200 body.
feishu/transport.py, transport_dispatch.py Streams only when the flag is on in the live config and the chat is a direct message, so turning it on or off applies on the next turn. FEISHU_CAPABILITIES keeps streaming=False; a streaming turn uses FEISHU_STREAMING_CAPABILITIES.
config/sections_channels.py, config/section_builders.py, config-baseline.json Adds feishu.streaming (default off). Its help text names the cardkit:card:write permission the Feishu app needs.

Docs: docs/system-specs/modules/messaging.md describes the two modes, src/kiro_crew/docs/channel-capabilities.md says Feishu streams only with the flag on in a direct message, and src/kiro_crew/docs/feishu-integration.md lists feishu.streaming.

Backwards compatibility

Compatible: the new key defaults to off, and with it off every Feishu turn takes the same buffered path as before.

Removes nothing: the change adds a mode and a config key; no key, path or public function is removed.

Tests

  • test/test_feishu_streaming_card.py (new): the five-step lifecycle and its order, sequence numbers, each error code, delivered, the throttle and stutter rules, every markdown fixup, links that stop at bold markers and CJK text, code blocks whose contents are never rewritten, tables inside code blocks left alone, image demotion that never joins the text around it, redaction of a credential that a card transform would join, lazy frames, and closing streaming mode on a retired card.
  • test/test_feishu_renderer.py: card opening, pushes, fallback to text, and redaction of live frames.
  • test/test_feishu_dispatch.py: the mode choice for flag off, flag on in a DM, flag on in a group, and a live change of the flag.
  • test/test_feishu_client_cardkit.py (new): the CardKit calls through the SDK, including the HTTP 200 reply that carries a non-zero error code.

The new tests were run 3 times forward and 3 times in a different file and class order, all green; the link, code block, table and live flag tests fail against the previous head, which shows they catch those defects.

Manual verification

Earlier heads were checked against a live Feishu tenant by the author: the card appears within about a second and fills in, markdown renders, the flag off keeps the buffered reply, and group turns stay buffered. The current head is unit-verified only; the changes since then are the card text pipeline, the retired-card close, the SDK request path for the card calls and the live flag read, all covered above.

Related Issues

Closes #7548

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@roycema-vibecoding
roycema-vibecoding requested review from a team and patrigao September 2, 2026 07:46
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 2, 2026
@roycema-vibecoding

Copy link
Copy Markdown
Author

Architecture check — raising the objection against my own PR

Before a reviewer has to spend a round-trip on it: I think there is a legitimate
architectural argument against merging this as-is. I would rather put it on the table
myself, with the measurements, than have it discovered.

The objection

docs/request-for-change/rfc-channel-plugin-architecture.md (status partial, doc-pr
#689) exists because every channel is built by copying the previous one — 7 duplicated
turn-dispatch skeletons, 3,796 lines, 9 hand-edited core files per channel. Its §1 closes
with:

An 8th channel (Feishu) is planned. On the current architecture it is copy #8 of the
skeleton and a tenth walk through the seams.

and its PR ⑤ is specifically:

PR ⑤ — Feishu ships as the first contract-native channel. … Estimated ~900 new
lines (adapter + panel) versus ~2,400 on the copy model.

Two facts follow, and neither favours this PR:

  1. Feishu shipped on the copy model rather than as the contract-native pilot, and PR ⑤ is
    still listed unstarted. Feishu is also not one of the 4 channels driving turns through
    messaging/dispatch.py (weixin, wecom, webex, teams).
  2. This PR takes src/kiro_crew/feishu/ from 1,368 to 2,167 lines (+799, +58%). The
    RFC predicted ~2,400 for Feishu on the copy model. I am, almost exactly, the outcome
    it warned about.

The duplication it warns about is real for streaming specifically: there is no shared
streaming/throttle helper
. messaging/renderer.py provides the event hooks plus the
table/redaction helpers and nothing else, so every streaming channel rolls its own.
Grepping the renderers for throttle|_stream_mid|_last_push|min_interval|edit_message:
telegram 38, discord 21, webex 12, wecom 10, slack 5, teams 5. This PR would be the 7th
such implementation.

So the strongest form of the objection is: extract a shared streaming helper first and
Feishu gets it for free; merging this instead makes that extraction bigger.
That is a
fair thing to say and I am not going to pretend otherwise.

The counter-argument, also measured

The one thing I did deliberately is keep the machinery out of the channel. All of it —
the CardKit lifecycle, the sequence counter, the single-flight throttle, the error-code
taxonomy, the markdown fixups — lives in one new module behind a six-member interface:

live / anchor_gone / delivered   (properties)
start()                 -> bool
push(text, *, force=False)
finish(text)            -> bool

feishu/renderer.py touches it in 8 places and never reaches past that interface. The
same grep that scores telegram's renderer at 38 scores Feishu's at 1. Every tunable is
a module-level constant in that one file (CARDKIT_THROTTLE_S, LONG_GAP_THRESHOLD_S,
BATCH_AFTER_GAP_S, the ERR_* codes).

Put plainly: of the seven streaming implementations this would be the only one already
shaped like the shared helper the RFC wants, rather than smeared through a renderer. It is
therefore the cheapest one to re-home later — and arguably the best available starting
point for the extraction, since the throttle / backoff / error-taxonomy split is already
factored out.

For accuracy, since I put this loosely elsewhere: Feishu is not the only channel
declaring streaming=False. Five declare True (slack, discord, telegram, wecom,
whatsapp) and five False (feishu, imessage, teams, webex, weixin) — though teams and
webex both declare edit=True, so updating in place without claiming streaming is already
precedent in this tree.

What I would like a decision on

  1. Merge as-is. It is opt-in (feishu.streaming, default off), DM-only, and every
    failure path falls back to today's buffered reply, so the blast radius with the flag off
    is nil. The RFC debt is real but unchanged in kind: this adds no new seam, it grows
    one module inside an existing channel.
  2. Have me extract messaging/streaming.py first — a shared throttled
    cumulative-push session — and land Feishu on top of it, either in this PR or in a
    preceding one. I am happy to do that; it is more work but it is where the RFC points. If
    you want it, say whether the first port should be Feishu alone or whether telegram and
    discord should move onto it in the same change. I would advise not, given how much of
    the recent conflict pain in this area has been concurrent edits to the same channel
    files.
  3. Hold this until PR ⑤. Reasonable — but note it leaves Feishu the channel where a
    long answer is invisible until it is finished, and Feishu channel: RuntimeError 'This event loop is already running' prevents connection #6534 already gates the channel
    entirely, so "later" here is compounding rather than neutral.

One practical note for whoever reviews: this needs the cardkit:card:write scope, granted
and published on the Open Platform. It is a separate permission set from
im:message:* and the card calls fail closed without it. I verified the full path against
a live tenant, which is the part the automated triage on #7548 correctly said it could not
exercise.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 2, 2026
@roycema-vibecoding

Copy link
Copy Markdown
Author

CI status: one red check, and it is not this diff

Final tally on 7cfe41b0a: 54 green, 11 skipped, 1 red.

The 11 skips are expected — a fork PR does not get the five AI reviewers or CodeQL.

The red one is Backend Tests (Windows) (3), and it fails in
test/test_session_control.py, not in anything this PR touches:

test_the_audit_write_does_not_run_on_the_event_loop
test_the_created_agent_name_is_sanitized_before_storage
  SessionControlError: too many sessions created recently; retry shortly

That is #7776 — "test isolation: the global session-create rate limiter makes
unrelated test shards fail intermittently"
— filed earlier today and already
labelled auto-fixable / claimed. The shared limiter carries state across tests in
a shard, so an unrelated shard trips it depending on ordering.

For the record, the 15 files in this PR are feishu/*, config/sections.py,
config/loader.py, config-baseline.json, the messaging module spec, NOTICE,
THIRD-PARTY-NOTICES, and four test files. Nothing under dashboard/, and no path
that session_control imports. The same Windows shard's Python 3.10 and 3.12
counterparts are green on this commit, which is the ordering-dependence #7776
describes rather than a platform problem in this change.

I cannot re-run it from here — gh run rerun answers cannot be rerun for a fork
contributor. A maintainer re-run should clear it; happy to rebase once #7776 lands if
you would rather see it green from a clean run.

Also worth flagging from this run, since it was caught and fixed rather than argued
with: the SAST scan flagged the CardKit urlopen call. Rather than suppress it, the
Open Platform origin is now asserted to be https before the request is built — it
comes from config, and urllib honours file:// — and only then is the audit rule
suppressed, matching the two existing precedents in this repo
(ops_mission_control/backend/providers/http.py, design_tweak/backend/dev_preview.py).
The second commit also lifted client.py 77% → 96% and renderer.py 72% → 98%, both
of which were under the 80 per-file floor after the first commit.

@JiaDe-Wu

JiaDe-Wu commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Cross-link rather than a review: I filed #7846 for the Feishu proactive-send gap (supports_proactive_send=False, the only channel where it is), and it touches every file this PR does — feishu/transport.py, client.py, renderer.py, transport_dispatch.py. This one should land first. It is far larger, and rebasing a small addressing change onto it is cheap where the reverse is not. I have not claimed the other work and would rebase onto whatever lands here.

Two things in this diff I flagged in that issue as the precedent to follow rather than re-litigate, in case it is useful to have them named by someone outside the change:

FEISHU_STREAMING_CAPABILITIES built with dataclasses.replace — keeping one TransportCapabilities(...) literal in the module so the AST-walking outbound-authz test still reads the real declaration — is the right shape for adding a capability to this channel without disturbing the base. I proposed following it rather than inventing a second pattern.

Pushing cumulative text to push() rather than accumulating deltas inside the card is also worth naming, because the alternative has a specific failure mode. On another project I recently fixed a streaming path that appended each delta to a flat list and joined it with the block separator: a delta is routinely a fragment of a single word, so the separator welded itself into the middle of words (" div" + "iding" → " div\n\niding"), 88 characters the model never emitted in one 45-delta reply, and the live display looked perfect the whole time because the raw chunk went to the renderer while only the stored copy was corrupted. Cumulative text cannot express that bug. The _ANTI_STUTTER_MAX_CHARS bound reads like it was written by someone who had already thought about the "nothing schedules a retry" consequence, which is the part that usually gets missed.

One question I could not answer from the diff, and cannot test without a Lark app of my own, so treat it as a question and not a finding: CARDKIT_THROTTLE_S = 0.10 permits up to ten patches per second per card. ERR_RATE_LIMITED (230020) is handled by dropping the frame and staying live, which is the right policy — but if Lark's published ceiling for the CardKit streaming update is below 10/s, then dropping becomes the normal path rather than the exception, and a stream that is silently shedding most of its frames looks the same in the code as one that is not. Did you get to measure the observed limit against a real app, or is 0.10 chosen as a conservative guess? If it is a guess, a one-line comment saying so would save the next person the same question.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 3, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

Open PR relationship audit

This is a consolidated, point-in-time code-level audit note. It compares complete merge-base diffs and current/merged code; it does not treat a shared topic as duplication or partial coverage as completion.

Relationship findings

  • This PR is OVERLAPPING with PR #8167. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #7823: REBASE. The only blocker is a trivial append-at-EOF collision in one test file; both classes belong in the file and no code hunk conflicts. Files: test/test_feishu_dispatch.py.
  • This PR is OVERLAPPING with PR #8228. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #7823: REBASE. Complementary Feishu improvements in opposite directions with no textual or semantic conflict; neither needs to wait on the other. Files: src/kiro_crew/feishu/client.py, src/kiro_crew/feishu/transport.py.

No PR, Issue, label, branch, or review state was changed by the relationship-note portion of this audit.

@dwu96 dwu96 added the needs-pr-triage PR scanner: awaiting automated triage label Sep 7, 2026
@NicholasRBowers NicholasRBowers added drive-to-green PR claimed by drive-to-green pipeline and removed needs-pr-triage PR scanner: awaiting automated triage labels Sep 7, 2026
@NicholasRBowers

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]: This PR has been inactive for 7+ days with failing CI. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author.

Assessment: Sole conflict is a trivial append-at-EOF collision in test/test_feishu_dispatch.py vs merged #8167 (keep both test classes), and the only CI red is the known Windows session-control rate-limiter flake (#7776). A rebase mints a new head, re-runs CI, and re-fires the skipped fork review lanes.

If you'd prefer I don't touch this PR, add the pr-no-autofix label.

@bolichen97
bolichen97 force-pushed the feat/feishu-streaming-card branch from 7cfe41b to 51c64cb Compare September 8, 2026 18:20
@bolichen97

Copy link
Copy Markdown
Contributor

Rebased onto main 1192049a by a maintainer as part of the 2026-09-08 open-PR audit (was 7cfe41b0, now 51c64cbe).

Conflicts resolved (both were textual, union-kept, no behaviour change):

  • src/kiro_crew/feishu/client.py: main's _WS_CLIENT_READY_TIMEOUT_SECS and this PR's FEISHU_OPEN_BASE / _CARD_HTTP_TIMEOUT_S / CardApiError both kept.
  • test/test_feishu_dispatch.py: append-at-EOF collision with merged fix(channels): gate /compact on backend capability (#8156) #8167; both TestCompactCapabilityGate and TestStreamingModeSelection kept.

config-baseline.json auto-merged and matches scripts/generate_config_baseline.py output exactly.

Gates run locally on changed files: black, isort, flake8 clean; pytest test/test_feishu_{client,dispatch,renderer,streaming_card}.py 193 passed; test/test_config_baseline.py 10 passed.

Please review the resolution. A maintainer push makes the maintainer the last pusher, so a second approver is needed under the repo's last-push rule. Reply if anything looks wrong.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention labels Sep 8, 2026
@bolichen97

Copy link
Copy Markdown
Contributor
  • span=3a5e87201079 Card markdown transform could rejoin a split credential

Outcome: fixed.
Fixed in 872af46. The session now redacts the prepared card body as the last step before every content push and the final replace (StreamingCardSession._prepare), using the renderer's own redact_for_target.
An image the card cannot load becomes a link or its alt text instead of being deleted, so the text on each side is not joined.
Test: TestRedactionAfterTheCardTransforms streams AKIA![]()IOSF... and asserts no published body carries the joined key; it fails on the previous head.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=b887172befbe Mixed image replies silently lose their image references

Outcome: fixed.
Fixed in 872af46. optimize_card_markdown turns an http(s) image into [alt](url) and a local one into its alt text or path, so the reference stays readable in the card.
Tests: test_an_http_image_feishu_cannot_resolve_becomes_a_link, test_a_local_image_keeps_its_alt_text.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=22a5494271ca Image reference dropped while the card still reports delivered (streaming_card.py:199)

Outcome: fixed.
Fixed in 872af46. The image is kept as a link or alt text, so a delivered card no longer hides it; the same change as the GPT image finding.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=22a5494271ca Retired card stays in streaming mode (streaming_card.py:492)

Outcome: fixed.
Fixed in 872af46. finish on a retired card now sends one best effort PATCH streaming_mode=false (_close_retired), skipped when the anchor is gone or the card never opened.
Tests: TestARetiredCardIsTakenOutOfStreamingMode.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=22a5494271ca Anti-stutter compares raw length with prepared length (streaming_card.py:459)

Outcome: fixed.
Fixed in 872af46. The session tracks the raw size of the pending frame and of the frame behind _shown, and compares those two.
Test: test_the_stutter_check_compares_raw_lengths_not_the_prepared_body.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=fb032aae4af3 Every chunk rescans the whole buffer on the loop

Outcome: fixed.
Fixed in 872af46. The renderer hands push a frame builder; the split, footer and redaction run only when a push is due past the throttle.
Test: test_a_frame_builder_runs_only_when_a_push_is_due.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=6522976909e6 Capability matrix shows Feishu without streaming

Outcome: fixed.
Fixed in 872af46. The cells stay ❌ because they mirror FEISHU_CAPABILITIES, the default the doc test checks; a new paragraph says Feishu streams and edits in place only with feishu.streaming on in a direct message.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=a18e1f8af3aa Name the cardkit:card:write scope

Outcome: fixed.
Fixed in 872af46. The feishu.streaming help text names the cardkit:card:write permission, and the card open failure warning tells the operator to check it.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=b1b10940540b Unverified claim that lark-oapi 1.4 lacks CardKit

Outcome: rebutted.
Verified: the lark_oapi-1.4.0 wheel, the pinned floor of lark-oapi>=1.4,<2, contains no lark_oapi/api/cardkit module, so the SDK path cannot serve the supported range.
The plain HTTPS client is therefore needed for the floor; raising the floor is a separate dependency decision.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=e2c73a4f0aed Import guard defends an already lost scenario

Outcome: fixed.
Fixed in 872af46. The guarded import of streaming_card and its None branch are removed; renderer.py imports it directly like its other same package modules.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 22, 2026
@bolichen97
bolichen97 force-pushed the feat/feishu-streaming-card branch 2 times, most recently from f38130f to 6e2a3a1 Compare October 22, 2026 20:38
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision 22b036b3f5408a0516723eee43988703a0d58b2e touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@bolichen97
bolichen97 force-pushed the feat/feishu-streaming-card branch from 6e2a3a1 to b6d3c1e Compare October 22, 2026 22:39
@bolichen97

Copy link
Copy Markdown
Contributor
  • span=76d86558c261 The CardKit transport is a second spelling of the SDK raw request path

Outcome: fixed in b6d3c1e.
card_api now sends every CardKit call through lark.BaseRequest with a tenant token type on an SDK client built once with its own timeout, the same path the bot info probe uses.
Removed: _sync_http, _sync_tenant_token, the token cache and lock, _open_base, FEISHU_OPEN_BASE, the urllib imports, the https guard and its scanner suppression.
The body code check stays in _card_data, so an HTTP 200 reply with a non zero code still raises CardApiError.
Tests: test/test_feishu_client_cardkit.py.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=52ecb41933b3 Streaming toggle ignores live configuration changes

Outcome: fixed in b6d3c1e.
The turn mode is read from self._live_cfg().feishu.streaming at the point of use, not from the constructor copy.
Test: test_the_mode_follows_the_live_config_not_the_boot_copy fails on the previous head and passes now.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=b887172befbe Card transformations rewrite fenced source content

Outcome: fixed in b6d3c1e.
A new _fence_roles classifies lines: a fence opens on a backtick line and closes only on a line of backticks at least as long, so a backtick run inside code does not close it, and an unterminated fence runs to the end of the frame.
_protect, the code block spacing in optimize_card_markdown and fence_excess_tables all use it, so link rewriting skips whole code blocks and a table inside a code block is neither counted nor wrapped.
Tests: test_backticks_inside_a_fenced_line_do_not_close_the_fence, test_an_unterminated_fence_is_protected_to_the_end, test_a_table_inside_a_fence_is_neither_counted_nor_wrapped, test_a_fenced_table_does_not_push_a_real_one_over_the_limit; all fail on the previous head.

@bolichen97

Copy link
Copy Markdown
Contributor

Answers to the non blocking notes on 6e2a3a1:

  • Opus note on the packaged Feishu guide (feishu-integration.md): fixed in b6d3c1e. The guide lists feishu.streaming and no longer says Feishu has no streaming.
  • Design note on a trailing flush: rebutted for this PR. Every frame the throttle drops is replaced by a later push and by the final full replace in finish, so no text is lost; a timer would add a scheduled task per turn for a cosmetic gap.
  • Design note on a separate executor for card calls: rebutted for this PR. Card calls now carry a 15 second SDK timeout, and a direct message turn makes at most one card call at a time, so four workers are not held for long.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=ebea49325181 Streaming toggle read from the boot copy of the config

Outcome: fixed in b6d3c1e.
handle_message reads self._live_cfg().feishu.streaming, like the other per turn reads in this class, so a live change applies on the next turn.
Test: test_the_mode_follows_the_live_config_not_the_boot_copy sets the boot copy off and the live config on and asserts the turn streams; it fails on the previous head.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=3a5e87201079 Bare URL match absorbs bold markers and CJK text

Outcome: fixed in b6d3c1e.
_BARE_URL_RE now ends a URL at * and at any non ASCII character, so bold markers, full width punctuation and CJK text after a URL stay outside the link.
Tests: test_bold_markers_stay_outside_the_link, test_cjk_text_after_a_url_stays_outside_the_link; both fail on the previous head.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 22, 2026
The Feishu renderer buffers a whole turn and sends one text message on
on_done, so a long answer leaves the bot looking dead, and a follow-up
sent meanwhile is merged into a placeholder while the real reply arrives
as an easily-missed quote-reply.

Add an opt-in streaming mode that pushes the answer into a Feishu CardKit
card as it arrives. The card is the platform's own streaming primitive: a
card entity is created, one ordinary message references its card_id, and
successive pushes carry the CUMULATIVE text, which the server diffs and
animates. Editing a plain text message is deliberately not used -- the
official Lark plugin treats that only as a degraded fallback.

The mode is off by default (feishu.streaming) and direct-message only; a
group turn keeps the buffered reply, because a card animating in a busy
room is noise for everyone who did not ask. Every failure path falls back
to the buffered text reply, so the worst case is today's behaviour rather
than a lost answer.

The base FEISHU_CAPABILITIES declaration is unchanged. A derived
FEISHU_STREAMING_CAPABILITIES flips only streaming and edit, and only for
a turn that actually streams, so a gateway with the flag off still
declares itself a non-streaming channel. rich_blocks stays False because
a CardKit card renders markdown, not tappable choices, and
returns_message_id is untouched because the card id lives in the
renderer, as it does for Telegram.

Ported from two MIT-licensed OpenClaw Feishu plugins; attribution is
recorded in NOTICE with the licence text in THIRD-PARTY-NOTICES.

The card transforms run before the final redaction pass, so text they
rewrite is scanned in the form the card shows. An image the card cannot
resolve becomes a link or its alt text instead of vanishing.
@bolichen97

Copy link
Copy Markdown
Contributor

self-added: yes
mechanism: fence marker dedent in normalize_card_links

  • span=b887172befbe Fence dedenting changes code-block contents

Outcome: fixed in 22b036b.
The dedent no longer runs a whole text regex. normalize_card_links classifies lines with _fence_roles and strips leading spaces only from opening and closing marker lines, so an indented backtick line inside a longer fence keeps its indentation.
Test: test_an_indented_backtick_line_inside_a_longer_fence_is_kept fails on the previous head and passes now.

@bolichen97

Copy link
Copy Markdown
Contributor

self-added: yes
mechanism: bare URL end set in _BARE_URL_RE

  • span=b887172befbe Linkification truncates Unicode URL paths

Outcome: fixed in 22b036b.
_BARE_URL_RE no longer stops at every non ASCII character. A URL now ends at whitespace, markdown brackets, a backtick, *, CJK punctuation, full width punctuation and curly quotes, so a path like /wiki/飞书 stays in the link while prose after , or 。 stays outside it.
Tests: test_a_non_ascii_url_path_stays_in_the_link fails on the previous head; test_cjk_text_after_a_url_stays_outside_the_link and test_bold_markers_stay_outside_the_link still pass.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=7fffc2bdb878 Concurrent-flush waits lack local deadlines

Outcome: fixed in 22b036b.
The concurrent flush test bounds the gated release wait, the entered wait and the final gather with asyncio.wait_for at 5 seconds, and a finally block sets release and cancels any task still running.
A missed signal now fails at the wait instead of hanging until the global timeout.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=771c016ed76e Settings sentence claims the panel can set streaming

Outcome: fixed in 22b036b.
The sentence under the Feishu settings table now reads "Everything above except hard_threshold_pct and streaming is editable in Settings", and says streaming is file only for now: set feishu.streaming: true in config.yaml after granting cardkit:card:write.
Adding a panel control is new UI surface and stays out of this PR.

@bolichen97

Copy link
Copy Markdown
Contributor

[operator: bolichen97]

@roycema-vibecoding, could you rebase this onto current main? #7846 waits on this PR's card-send path, per the 2026-10-08 ruling.

AI-assisted, approved by bolichen97

This branch has not been deployed

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

Labels

drive-to-green PR claimed by drive-to-green pipeline fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feishu: add interactive card rendering and streaming replies

6 participants