feat(bcs): fire system message on session file upload complete#445
Open
zh-bupt wants to merge 1 commit into
Open
feat(bcs): fire system message on session file upload complete#445zh-bupt wants to merge 1 commit into
zh-bupt wants to merge 1 commit into
Conversation
When a bot or human completes a session file upload, fire a
GenericNotification system message to the other bots (via chat.inject)
and the frontend ws, using the fixed text format:
{prefix} {uploader} 上传了一个文件 {fileName} ({fileId},{readableSize}),下载链接:{url}
prefix is "Bot" for a bot uploader and "用户" for a human. Reuses the
existing GenericNotification path — no new event kind, producer, or
bootstrap registration. Recipients are the session's bot participants
excluding the uploader; if there are no other bots the notification is
skipped entirely (the generic producer falls back to all bots on empty
receivers, which would self-inject the uploader). Notify is best-effort
and only runs on the successful upload path, so it never fails the
upload response. The download link uses bcs_endpoint with an
http://{bind}:{port} fallback and a URL-encoded session id.
Adds four private helpers in the session_files route module:
human_readable_size, file_download_url, file_upload_receivers,
uploader_display_name; a RecordingSystemMessage test spy wired into the
in-module TestApp fixture; and integration + unit tests covering the
bot/human uploader cases and the empty-receivers guard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When a bot or human completes a session file upload, fire a
GenericNotificationsystem message to the other bots (viachat.inject) and the frontend ws, using the fixed text format:prefixisBotfor a bot uploader,用户for a human.Bot 测试Agent 上传了一个文件 readme.md (THISISFILEID,12 KB),下载链接:https://bcn.alipay.com/sessions/SESSION_ID/files/THISISFILEID/contentHow
Reuses the existing
SystemMessageEvent::GenericNotificationpath — no new event kind, producer, or bootstrap registration. All changes live in one file:crates/adapters/http/bcs-http/src/routes/session_files.rs.complete_uploadcaptures the session and, on success, calls a new best-effortnotify_file_uploadedhelper.notifyis best-effort and only runs on theOkpath, so it never fails the upload response.GenericNotificationMessageProducerfalls back to all bot participants on emptyreceivers, which would self-inject the uploader.bcs_endpoint(fromBcsConfig.bcs_endpoint) with anhttp://{bind}:{port}fallback and a URL-encoded session id. The link is permanent and resolves for all recipients (bot bearers / human session members).registry.get(..)->capabilities.name(fallback id); human vianick_name(fallbackstaff_no).New private helpers in the route module:
human_readable_size,file_download_url,file_upload_receivers,uploader_display_name; plus aRecordingSystemMessagetest spy wired into the in-moduleTestAppfixture.Diff scope
session_files.rsonly — +405 / −7.Testing
cargo test -p bcs-http --lib→ 74 passed / 0 failed;cargo build -p bcs-httpwarning-free.Coverage:
group_id, andreceivers == [other-bot].用户 ...message delivered to all bots.