From 8aebe20caca6684610ce44496f5e95e002e525c4 Mon Sep 17 00:00:00 2001 From: Sihyeon Jang Date: Wed, 11 Mar 2026 07:40:43 +0900 Subject: [PATCH] feat(slack): update reaction emoji on task completion Remove the in-progress reaction (reactEmoji) and optionally add a done reaction (doneEmoji) when the final response is sent, so users get visual feedback that processing has finished. Signed-off-by: Sihyeon Jang --- nanobot/channels/slack.py | 28 ++++++++++++++++++++++++++++ nanobot/config/schema.py | 1 - 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/nanobot/channels/slack.py b/nanobot/channels/slack.py index c9f353d..1b683f7 100644 --- a/nanobot/channels/slack.py +++ b/nanobot/channels/slack.py @@ -136,6 +136,12 @@ class SlackChannel(BaseChannel): ) except Exception as e: logger.error("Failed to upload file {}: {}", media_path, e) + + # Update reaction emoji when the final (non-progress) response is sent + if not (msg.metadata or {}).get("_progress"): + event = slack_meta.get("event", {}) + await self._update_react_emoji(msg.chat_id, event.get("ts")) + except Exception as e: logger.error("Error sending Slack message: {}", e) @@ -233,6 +239,28 @@ class SlackChannel(BaseChannel): except Exception: logger.exception("Error handling Slack message from {}", sender_id) + async def _update_react_emoji(self, chat_id: str, ts: str | None) -> None: + """Remove the in-progress reaction and optionally add a done reaction.""" + if not self._web_client or not ts: + return + try: + await self._web_client.reactions_remove( + channel=chat_id, + name=self.config.react_emoji, + timestamp=ts, + ) + except Exception as e: + logger.debug("Slack reactions_remove failed: {}", e) + if self.config.done_emoji: + try: + await self._web_client.reactions_add( + channel=chat_id, + name=self.config.done_emoji, + timestamp=ts, + ) + except Exception as e: + logger.debug("Slack done reaction failed: {}", e) + def _is_allowed(self, sender_id: str, chat_id: str, channel_type: str) -> bool: if channel_type == "im": if not self.config.dm.enabled: diff --git a/nanobot/config/schema.py b/nanobot/config/schema.py index 033fb63..c067231 100644 --- a/nanobot/config/schema.py +++ b/nanobot/config/schema.py @@ -13,7 +13,6 @@ class Base(BaseModel): model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True) - class ChannelsConfig(Base): """Configuration for chat channels.