Skip to content

Commit 657d88e

Browse files
committed
feat: replace the connect/disconnect buttons with status text
1 parent cbaed00 commit 657d88e

3 files changed

Lines changed: 3 additions & 48 deletions

File tree

pydantic-ai/listeners/actions/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from slack_bolt import App
44

5-
from .account_connection import handle_connect_account, handle_disconnect_account
5+
from .account_connection import handle_connect_account
66
from .issue_buttons import handle_issue_button
77
from .feedback_buttons import handle_feedback_button
88

@@ -11,4 +11,3 @@ def register(app: App):
1111
app.action(re.compile(r"^category_"))(handle_issue_button)
1212
app.action("feedback")(handle_feedback_button)
1313
app.action("connect_account")(handle_connect_account)
14-
app.action("disconnect_account")(handle_disconnect_account)
Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
from logging import Logger
22

3-
from slack_bolt import BoltContext
4-
from slack_sdk import WebClient
5-
6-
from listeners.views.app_home_builder import build_app_home_view
7-
83

94
def handle_connect_account(ack, logger: Logger):
105
"""Handle the Connect button click on App Home.
@@ -13,25 +8,3 @@ def handle_connect_account(ack, logger: Logger):
138
browser, so we only need to acknowledge the action.
149
"""
1510
ack()
16-
17-
18-
def handle_disconnect_account(
19-
ack, client: WebClient, context: BoltContext, logger: Logger
20-
):
21-
"""Handle the Disconnect button click on App Home."""
22-
ack()
23-
try:
24-
from oauth import authorize_url_generator, installation_store, state_store
25-
26-
user_id = context.user_id
27-
installation_store.delete_installation(
28-
enterprise_id=context.enterprise_id or "",
29-
team_id=context.team_id or "",
30-
user_id=user_id,
31-
)
32-
state = state_store.issue()
33-
authorize_url = authorize_url_generator.generate(state)
34-
view = build_app_home_view(authorize_url=authorize_url)
35-
client.views_publish(user_id=user_id, view=view)
36-
except Exception as e:
37-
logger.exception(f"Failed to handle disconnect: {e}")

pydantic-ai/listeners/views/app_home_builder.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,10 @@ def build_app_home_view(
9595
"text": {
9696
"type": "mrkdwn",
9797
"text": (
98-
":white_check_mark: *Your Slack account is connected.*\n"
98+
"🟢 *Slack MCP Server is connected.*\n"
9999
"Casey has access to search messages, read channels, and more."
100100
),
101101
},
102-
"accessory": {
103-
"type": "button",
104-
"text": {"type": "plain_text", "text": "Disconnect"},
105-
"action_id": "disconnect_account",
106-
"style": "danger",
107-
},
108102
}
109103
)
110104
elif authorize_url:
@@ -113,18 +107,7 @@ def build_app_home_view(
113107
"type": "section",
114108
"text": {
115109
"type": "mrkdwn",
116-
"text": (
117-
":electric_plug: *Connect your Slack account*\n"
118-
"Unlock full functionality including searching messages, "
119-
"reading channels, and more."
120-
),
121-
},
122-
"accessory": {
123-
"type": "button",
124-
"text": {"type": "plain_text", "text": "Connect"},
125-
"url": authorize_url,
126-
"action_id": "connect_account",
127-
"style": "primary",
110+
"text": f"🔴 *Slack MCP Server is disconnected.* <{authorize_url}|Connect now.>",
128111
},
129112
}
130113
)

0 commit comments

Comments
 (0)