Skip to content

Commit dbfbd82

Browse files
committed
fix: add eyes reaction before setStatus for more natural UX
1 parent b2941bd commit dbfbd82

6 files changed

Lines changed: 56 additions & 56 deletions

File tree

claude-agent-sdk/listeners/events/app_mentioned.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ async def handle_app_mentioned(
4242
)
4343
return
4444

45+
# Add eyes reaction only to the first message (not threaded replies)
46+
if not event.get("thread_ts"):
47+
await client.reactions_add(
48+
channel=channel_id,
49+
timestamp=event["ts"],
50+
name="eyes",
51+
)
52+
4553
# Set assistant thread status with loading messages
4654
await client.assistant_threads_setStatus(
4755
channel_id=channel_id,
@@ -56,14 +64,6 @@ async def handle_app_mentioned(
5664
],
5765
)
5866

59-
# Add eyes reaction only to the first message (not threaded replies)
60-
if not event.get("thread_ts"):
61-
await client.reactions_add(
62-
channel=channel_id,
63-
timestamp=event["ts"],
64-
name="eyes",
65-
)
66-
6767
# Get session ID for conversation context
6868
existing_session_id = session_store.get_session(channel_id, thread_ts)
6969

claude-agent-sdk/listeners/events/message_im.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ async def handle_message_im(
3939
thread_ts = event.get("thread_ts") or event["ts"]
4040
user_id = event.get("user")
4141

42+
# Get session ID for conversation context
43+
existing_session_id = session_store.get_session(channel_id, thread_ts)
44+
45+
# Add eyes reaction only to the first message in a thread
46+
if not existing_session_id:
47+
await client.reactions_add(
48+
channel=channel_id,
49+
timestamp=event["ts"],
50+
name="eyes",
51+
)
52+
4253
# Set assistant thread status with loading messages
4354
await client.assistant_threads_setStatus(
4455
channel_id=channel_id,
@@ -53,17 +64,6 @@ async def handle_message_im(
5364
],
5465
)
5566

56-
# Get session ID for conversation context
57-
existing_session_id = session_store.get_session(channel_id, thread_ts)
58-
59-
# Add eyes reaction only to the first message in a thread
60-
if not existing_session_id:
61-
await client.reactions_add(
62-
channel=channel_id,
63-
timestamp=event["ts"],
64-
name="eyes",
65-
)
66-
6767
# Run the agent
6868
response_text, new_session_id = await run_casey_agent(
6969
text, session_id=existing_session_id

openai-agents-sdk/listeners/events/app_mentioned.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ def handle_app_mentioned(client: WebClient, event: dict, logger: Logger, say: Sa
4141
)
4242
return
4343

44+
# Add eyes reaction
45+
client.reactions_add(
46+
channel=channel_id,
47+
timestamp=event["ts"],
48+
name="eyes",
49+
)
50+
4451
# Set assistant thread status with loading messages
4552
client.assistant_threads_setStatus(
4653
channel_id=channel_id,
@@ -55,13 +62,6 @@ def handle_app_mentioned(client: WebClient, event: dict, logger: Logger, say: Sa
5562
],
5663
)
5764

58-
# Add eyes reaction
59-
client.reactions_add(
60-
channel=channel_id,
61-
timestamp=event["ts"],
62-
name="eyes",
63-
)
64-
6565
# Get conversation history
6666
history = conversation_store.get_history(channel_id, thread_ts)
6767

openai-agents-sdk/listeners/events/message_im.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ def handle_message_im(client: WebClient, event: dict, logger: Logger, say: Say):
3838
thread_ts = event.get("thread_ts") or event["ts"]
3939
user_id = event["user"]
4040

41+
# Get conversation history
42+
history = conversation_store.get_history(channel_id, thread_ts)
43+
44+
# Add eyes reaction only to the first message in a thread
45+
if history is None:
46+
client.reactions_add(
47+
channel=channel_id,
48+
timestamp=event["ts"],
49+
name="eyes",
50+
)
51+
4152
# Set assistant thread status with loading messages
4253
client.assistant_threads_setStatus(
4354
channel_id=channel_id,
@@ -52,17 +63,6 @@ def handle_message_im(client: WebClient, event: dict, logger: Logger, say: Say):
5263
],
5364
)
5465

55-
# Get conversation history
56-
history = conversation_store.get_history(channel_id, thread_ts)
57-
58-
# Add eyes reaction only to the first message in a thread
59-
if history is None:
60-
client.reactions_add(
61-
channel=channel_id,
62-
timestamp=event["ts"],
63-
name="eyes",
64-
)
65-
6666
# Build input for the agent
6767
if history:
6868
input_items = history + [{"role": "user", "content": text}]

pydantic-ai/listeners/events/app_mentioned.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ def handle_app_mentioned(client: WebClient, event: dict, logger: Logger, say: Sa
4040
)
4141
return
4242

43+
# Add eyes reaction only to the first message (not threaded replies)
44+
if not event.get("thread_ts"):
45+
client.reactions_add(
46+
channel=channel_id,
47+
timestamp=event["ts"],
48+
name="eyes",
49+
)
50+
4351
# Set assistant thread status with loading messages
4452
client.assistant_threads_setStatus(
4553
channel_id=channel_id,
@@ -54,14 +62,6 @@ def handle_app_mentioned(client: WebClient, event: dict, logger: Logger, say: Sa
5462
],
5563
)
5664

57-
# Add eyes reaction only to the first message (not threaded replies)
58-
if not event.get("thread_ts"):
59-
client.reactions_add(
60-
channel=channel_id,
61-
timestamp=event["ts"],
62-
name="eyes",
63-
)
64-
6565
# Get conversation history
6666
history = conversation_store.get_history(channel_id, thread_ts)
6767

pydantic-ai/listeners/events/message_im.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ def handle_message_im(client: WebClient, event: dict, logger: Logger, say: Say):
3737
thread_ts = event.get("thread_ts") or event["ts"]
3838
user_id = event["user"]
3939

40+
# Get conversation history
41+
history = conversation_store.get_history(channel_id, thread_ts)
42+
43+
# Add eyes reaction only to the first message in a thread
44+
if history is None:
45+
client.reactions_add(
46+
channel=channel_id,
47+
timestamp=event["ts"],
48+
name="eyes",
49+
)
50+
4051
# Set assistant thread status with loading messages
4152
client.assistant_threads_setStatus(
4253
channel_id=channel_id,
@@ -51,17 +62,6 @@ def handle_message_im(client: WebClient, event: dict, logger: Logger, say: Say):
5162
],
5263
)
5364

54-
# Get conversation history
55-
history = conversation_store.get_history(channel_id, thread_ts)
56-
57-
# Add eyes reaction only to the first message in a thread
58-
if history is None:
59-
client.reactions_add(
60-
channel=channel_id,
61-
timestamp=event["ts"],
62-
name="eyes",
63-
)
64-
6565
# Run the agent
6666
deps = CaseyDeps(
6767
client=client,

0 commit comments

Comments
 (0)