Skip to content

Commit c82037c

Browse files
committed
enhance: follow calender toolkit
1 parent 22ec722 commit c82037c

2 files changed

Lines changed: 71 additions & 2 deletions

File tree

src/components/AddWorker/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export function AddWorker({
164164
// call ToolSelect's install method
165165
if (toolSelectRef.current) {
166166
try {
167-
if (activeMcp.key === "EXA Search" || activeMcp.key === "Google Calendar" || activeMcp.key === "Google Gmail") {
167+
if (activeMcp.key === "EXA Search" || activeMcp.key === "Google Calendar" || activeMcp.key === "Google Gmail MCP") {
168168
await toolSelectRef.current.installMcp(
169169
activeMcp.id,
170170
{ ...envValues },
@@ -179,7 +179,7 @@ export function AddWorker({
179179
}
180180

181181
// For Google Calendar, close dialog after installMcp completes
182-
if (activeMcp.key === "Google Calendar") {
182+
if (activeMcp.key === "Google Calendar" || activeMcp.key === "Google Gmail MCP") {
183183
setShowEnvConfig(false);
184184
}
185185

src/components/IntegrationList/index.tsx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ export default function IntegrationList({
108108
setShowEnvConfig(true);
109109
}
110110
return;
111+
}
112+
113+
if (item.key === "Google Gmail MCP") {
114+
const mcp = createMcpFromItem(item, 15);
115+
if (isSelectMode) {
116+
onShowEnvConfig?.(mcp);
117+
} else {
118+
setActiveMcp(mcp);
119+
setShowEnvConfig(true);
120+
}
121+
return;
111122
}
112123

113124
if (installed[item.key]) return;
@@ -199,6 +210,64 @@ export default function IntegrationList({
199210
console.log("[IntegrationList onConnect] Polling timeout");
200211
return;
201212
}
213+
} else if (mcp.key === "Google Gmail MCP") {
214+
console.log(
215+
"[IntegrationList onConnect] Google Gmail detected, starting auth flow"
216+
);
217+
218+
// Trigger install/authorization
219+
const gmailItem = items.find((item) => item.key === "Google Gmail MCP");
220+
try {
221+
if (gmailItem && gmailItem.onInstall) {
222+
await gmailItem.onInstall();
223+
} else {
224+
await fetchPost("/install/tool/google_gmail");
225+
}
226+
} catch (_) {}
227+
228+
// Select mode: poll OAuth status
229+
if (isSelectMode) {
230+
console.log(
231+
"[IntegrationList onConnect] Starting OAuth status polling"
232+
);
233+
234+
const start = Date.now();
235+
const timeoutMs = 5 * 60 * 1000; // 5 minutes
236+
while (Date.now() - start < timeoutMs) {
237+
try {
238+
const statusRes: any = await fetchGet(
239+
"/oauth/status/google_gmail"
240+
);
241+
console.log(
242+
"[IntegrationList onConnect] OAuth status:",
243+
statusRes?.status
244+
);
245+
246+
if (statusRes?.status === "success") {
247+
console.log(
248+
"[IntegrationList onConnect] Success! Closing dialog"
249+
);
250+
await fetchInstalled();
251+
onClose();
252+
return;
253+
}
254+
if (
255+
statusRes?.status === "failed" ||
256+
statusRes?.status === "cancelled"
257+
) {
258+
console.log(
259+
"[IntegrationList onConnect] Failed/cancelled, keeping dialog open"
260+
);
261+
return;
262+
}
263+
} catch (err) {
264+
console.log("[IntegrationList onConnect] Polling error:", err);
265+
}
266+
await new Promise((r) => setTimeout(r, 1500));
267+
}
268+
console.log("[IntegrationList onConnect] Polling timeout");
269+
return;
270+
}
202271
}
203272

204273
// Select mode: add to tools and close

0 commit comments

Comments
 (0)