From e236c892dca29a7e4556dc2a544562f9695bea81 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Thu, 14 May 2026 10:24:06 -0700 Subject: [PATCH 1/3] fix(integrations): gdrive trashed search, slack blocks-with-file, slack get_message ts - Google Drive search/list: skip default `trashed = false` when user query already specifies a `trashed = ...` predicate, so trashed-file searches work. - Slack send-message with files: forward `blocks` through to `files.completeUploadExternal` so Block Kit renders when files are attached. - Slack get_message: switch from `conversations.history` (oldest lower-bound returned the next message after) to `conversations.replies` with `ts=` for exact-match lookup, plus a defensive ts-equality guard and clearer error. --- apps/sim/app/api/tools/slack/utils.ts | 13 +++++++++++-- apps/sim/tools/google_drive/list.ts | 9 +++++++-- apps/sim/tools/google_drive/search.ts | 11 ++++++++--- apps/sim/tools/slack/get_message.ts | 23 ++++++++++++++++++----- 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/apps/sim/app/api/tools/slack/utils.ts b/apps/sim/app/api/tools/slack/utils.ts index d74b078595f..c0d43792e24 100644 --- a/apps/sim/app/api/tools/slack/utils.ts +++ b/apps/sim/app/api/tools/slack/utils.ts @@ -141,7 +141,8 @@ async function completeSlackFileUpload( channel: string, text: string, accessToken: string, - threadTs?: string | null + threadTs?: string | null, + blocks?: unknown[] | null ): Promise<{ ok: boolean; files?: any[]; error?: string }> { const response = await fetch('https://slack.com/api/files.completeUploadExternal', { method: 'POST', @@ -154,6 +155,7 @@ async function completeSlackFileUpload( channel_id: channel, initial_comment: text, ...(threadTs && { thread_ts: threadTs }), + ...(blocks && blocks.length > 0 && { blocks }), }), }) @@ -295,7 +297,14 @@ export async function sendSlackMessage( } // Complete file upload with thread support - const completeData = await completeSlackFileUpload(fileIds, channel, text, accessToken, threadTs) + const completeData = await completeSlackFileUpload( + fileIds, + channel, + text, + accessToken, + threadTs, + blocks + ) if (!completeData.ok) { logger.error(`[${requestId}] Failed to complete upload:`, completeData.error) diff --git a/apps/sim/tools/google_drive/list.ts b/apps/sim/tools/google_drive/list.ts index afc4ee2c7cb..ca7cb331a76 100644 --- a/apps/sim/tools/google_drive/list.ts +++ b/apps/sim/tools/google_drive/list.ts @@ -66,8 +66,13 @@ export const listTool: ToolConfig value.replace(/\\/g, '\\\\').replace(/'/g, "\\'") - // Build the query conditions - const conditions = ['trashed = false'] // Always exclude trashed files + // Build the query conditions. Default to excluding trashed files unless + // the user-supplied query explicitly specifies a `trashed = ...` predicate. + const userSpecifiesTrashed = params.query ? /\btrashed\s*=/.test(params.query) : false + const conditions: string[] = [] + if (!userSpecifiesTrashed) { + conditions.push('trashed = false') + } const folderId = (params.folderId || params.folderSelector)?.trim() if (folderId) { const escapedFolderId = escapeQueryValue(folderId) diff --git a/apps/sim/tools/google_drive/search.ts b/apps/sim/tools/google_drive/search.ts index 52eccb7ef62..33851c83ec6 100644 --- a/apps/sim/tools/google_drive/search.ts +++ b/apps/sim/tools/google_drive/search.ts @@ -64,9 +64,14 @@ export const searchTool: ToolConfig = { id: 'slack_get_message', name: 'Slack Get Message', @@ -49,11 +52,10 @@ export const slackGetMessageTool: ToolConfig { - const url = new URL('https://slack.com/api/conversations.history') + const url = new URL('https://slack.com/api/conversations.replies') url.searchParams.append('channel', params.channel?.trim() ?? '') - url.searchParams.append('oldest', params.timestamp?.trim() ?? '') + url.searchParams.append('ts', params.timestamp?.trim() ?? '') url.searchParams.append('limit', '1') - url.searchParams.append('inclusive', 'true') return url.toString() }, method: 'GET', @@ -63,8 +65,9 @@ export const slackGetMessageTool: ToolConfig { + transformResponse: async (response: Response, params?: SlackGetMessageParams) => { const data = await response.json() + const requestedTs = params?.timestamp?.trim() ?? '' if (!data.ok) { if (data.error === 'missing_scope') { @@ -78,15 +81,25 @@ export const slackGetMessageTool: ToolConfig Date: Thu, 14 May 2026 10:39:02 -0700 Subject: [PATCH 2/3] =?UTF-8?q?fix(google=5Fdrive):=20revert=20list.ts=20t?= =?UTF-8?q?rashed=20guard=20=E2=80=94=20query=20is=20plain=20text,=20not?= =?UTF-8?q?=20gdrive=20syntax?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/sim/tools/google_drive/list.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/sim/tools/google_drive/list.ts b/apps/sim/tools/google_drive/list.ts index ca7cb331a76..52bc22b80e5 100644 --- a/apps/sim/tools/google_drive/list.ts +++ b/apps/sim/tools/google_drive/list.ts @@ -66,13 +66,11 @@ export const listTool: ToolConfig value.replace(/\\/g, '\\\\').replace(/'/g, "\\'") - // Build the query conditions. Default to excluding trashed files unless - // the user-supplied query explicitly specifies a `trashed = ...` predicate. - const userSpecifiesTrashed = params.query ? /\btrashed\s*=/.test(params.query) : false - const conditions: string[] = [] - if (!userSpecifiesTrashed) { - conditions.push('trashed = false') - } + // Build the query conditions. `params.query` here is a plain-text name + // search term (wrapped in `name contains '...'` below), not Google Drive + // query syntax — so there's no caller-supplied `trashed` predicate to + // honour. Always exclude trashed files. + const conditions: string[] = ['trashed = false'] const folderId = (params.folderId || params.folderSelector)?.trim() if (folderId) { const escapedFolderId = escapeQueryValue(folderId) From db18b88ac3e519197e754fb37b06e926e7537da3 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Thu, 14 May 2026 11:24:39 -0700 Subject: [PATCH 3/3] fix(slack): omit initial_comment when blocks present so Block Kit actually renders on file uploads --- apps/sim/app/api/tools/slack/utils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/sim/app/api/tools/slack/utils.ts b/apps/sim/app/api/tools/slack/utils.ts index c0d43792e24..aebd295c30a 100644 --- a/apps/sim/app/api/tools/slack/utils.ts +++ b/apps/sim/app/api/tools/slack/utils.ts @@ -153,9 +153,11 @@ async function completeSlackFileUpload( body: JSON.stringify({ files: uploadedFileIds.map((id) => ({ id })), channel_id: channel, - initial_comment: text, + // Per Slack docs for files.completeUploadExternal: if `initial_comment` + // is provided, `blocks` is silently ignored. So when blocks are present + // we omit initial_comment and let blocks render instead. + ...(blocks && blocks.length > 0 ? { blocks } : { initial_comment: text }), ...(threadTs && { thread_ts: threadTs }), - ...(blocks && blocks.length > 0 && { blocks }), }), })