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 <sihyeon.jang@navercorp.com>
This commit is contained in:
@@ -136,6 +136,12 @@ class SlackChannel(BaseChannel):
|
|||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Failed to upload file {}: {}", media_path, 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:
|
except Exception as e:
|
||||||
logger.error("Error sending Slack message: {}", e)
|
logger.error("Error sending Slack message: {}", e)
|
||||||
|
|
||||||
@@ -233,6 +239,28 @@ class SlackChannel(BaseChannel):
|
|||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("Error handling Slack message from {}", sender_id)
|
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:
|
def _is_allowed(self, sender_id: str, chat_id: str, channel_type: str) -> bool:
|
||||||
if channel_type == "im":
|
if channel_type == "im":
|
||||||
if not self.config.dm.enabled:
|
if not self.config.dm.enabled:
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ class Base(BaseModel):
|
|||||||
|
|
||||||
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
|
||||||
|
|
||||||
|
|
||||||
class ChannelsConfig(Base):
|
class ChannelsConfig(Base):
|
||||||
"""Configuration for chat channels.
|
"""Configuration for chat channels.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user