Skip to content

Your lightweight open-source personal agent.

feat(slack): update reaction emoji on task completion

Sihyeon Jang8aebe20caca6
diff --git a/nanobot/channels/slack.py b/nanobot/channels/slack.py
index c9f353d65..1b683f755 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 033fb633a..c067231a5 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.