Skip to content

Commit ee68f1c

Browse files
committed
feat: update to use the feedback blocks
1 parent e890220 commit ee68f1c

6 files changed

Lines changed: 30 additions & 30 deletions

File tree

listeners/actions/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@
88

99
def register(app: App):
1010
app.action(re.compile(r"^category_"))(handle_category_button)
11-
app.action("feedback_good")(handle_feedback)
12-
app.action("feedback_bad")(handle_feedback)
11+
app.action("feedback")(handle_feedback)

listeners/actions/feedback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def handle_feedback(ack: Ack, body: dict, client: WebClient, logger: Logger):
1414
message_ts = body["message"]["ts"]
1515
feedback_value = body["actions"][0]["value"]
1616

17-
if feedback_value == "good":
17+
if feedback_value == "good-feedback":
1818
client.chat_postEphemeral(
1919
channel=channel_id,
2020
user=user_id,

listeners/events/app_mentioned.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def handle_app_mentioned(client: WebClient, event: dict, logger: Logger, say: Sa
6565
)
6666

6767
# Post response in thread with feedback buttons
68-
feedback_blocks = create_feedback_block(thread_ts)
68+
feedback_blocks = create_feedback_block()
6969
response_blocks = [
7070
{
7171
"type": "section",

listeners/events/message_im.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def handle_message_im(client: WebClient, event: dict, logger: Logger, say: Say):
6262
)
6363

6464
# Post response in thread with feedback buttons
65-
feedback_blocks = create_feedback_block(thread_ts)
65+
feedback_blocks = create_feedback_block()
6666
response_blocks = [
6767
{
6868
"type": "section",

listeners/views/feedback_block.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
from slack_sdk.models.blocks import (
2-
ActionsBlock,
3-
ButtonElement,
2+
Block,
3+
ContextActionsBlock,
4+
FeedbackButtonObject,
5+
FeedbackButtonsElement,
46
)
57

68

7-
def create_feedback_block(message_ts: str = "") -> list[dict]:
8-
"""Create feedback block with thumbs up/down buttons.
9-
10-
Args:
11-
message_ts: Optional timestamp to identify which message feedback is for.
12-
"""
13-
block = ActionsBlock(
14-
block_id=f"feedback_{message_ts}" if message_ts else "feedback",
15-
elements=[
16-
ButtonElement(
17-
text=":thumbsup:",
18-
action_id="feedback_good",
19-
value="good",
20-
),
21-
ButtonElement(
22-
text=":thumbsdown:",
23-
action_id="feedback_bad",
24-
value="bad",
25-
),
26-
],
27-
)
28-
return [block.to_dict()]
9+
def create_feedback_block() -> list[Block]:
10+
"""Create feedback block with thumbs up/down buttons."""
11+
return [
12+
ContextActionsBlock(
13+
elements=[
14+
FeedbackButtonsElement(
15+
action_id="feedback",
16+
positive_button=FeedbackButtonObject(
17+
text="Good Response",
18+
accessibility_label="Submit positive feedback on this response",
19+
value="good-feedback",
20+
),
21+
negative_button=FeedbackButtonObject(
22+
text="Bad Response",
23+
accessibility_label="Submit negative feedback on this response",
24+
value="bad-feedback",
25+
),
26+
)
27+
]
28+
)
29+
]

listeners/views/issue_modal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def handle_issue_submission(ack: Ack, body: dict, client: WebClient, logger: Log
4949
result = casey_agent.run_sync(user_message, model=DEFAULT_MODEL, deps=deps)
5050

5151
# Post the response in thread with feedback buttons
52-
feedback_blocks = create_feedback_block(thread_ts)
52+
feedback_blocks = create_feedback_block()
5353
response_blocks = [
5454
{
5555
"type": "section",

0 commit comments

Comments
 (0)