|
144 | 144 |
|
145 | 145 | let selectedToolIds = []; |
146 | 146 | let selectedFilterIds = []; |
| 147 | + let pendingOAuthTools = []; |
147 | 148 |
|
148 | 149 | let imageGenerationEnabled = false; |
149 | 150 | let webSearchEnabled = false; |
|
274 | 275 | const resetInput = () => { |
275 | 276 | selectedToolIds = []; |
276 | 277 | selectedFilterIds = []; |
| 278 | + pendingOAuthTools = []; |
277 | 279 | webSearchEnabled = false; |
278 | 280 | imageGenerationEnabled = false; |
279 | 281 | codeInterpreterEnabled = false; |
|
298 | 300 | if (model) { |
299 | 301 | // Set Default Tools |
300 | 302 | if (model?.info?.meta?.toolIds) { |
301 | | - selectedToolIds = [ |
| 303 | + const defaultIds = [ |
302 | 304 | ...new Set( |
303 | 305 | [...(model?.info?.meta?.toolIds ?? [])].filter((id) => $tools.find((t) => t.id === id)) |
304 | 306 | ) |
305 | 307 | ]; |
| 308 | +
|
| 309 | + // Separate unauthenticated OAuth tools |
| 310 | + const unauthed = []; |
| 311 | + const authed = []; |
| 312 | + for (const id of defaultIds) { |
| 313 | + const tool = $tools.find((t) => t.id === id); |
| 314 | + if (tool && tool.authenticated === false) { |
| 315 | + const parts = id.split(':'); |
| 316 | + const serverId = parts.at(-1) ?? id; |
| 317 | + const authType = parts.length > 1 ? parts[0] === 'server' ? parts[1] : parts[0] : null; |
| 318 | + unauthed.push({ id, name: tool.name ?? id, serverId, authType }); |
| 319 | + } else { |
| 320 | + authed.push(id); |
| 321 | + } |
| 322 | + } |
| 323 | + selectedToolIds = authed; |
| 324 | + pendingOAuthTools = unauthed; |
306 | 325 | } else if ($settings?.tools) { |
307 | 326 | selectedToolIds = $settings.tools; |
308 | 327 | } else { |
|
1765 | 1784 | selectedModels = _selectedModels; |
1766 | 1785 | } |
1767 | 1786 |
|
| 1787 | + if (pendingOAuthTools.length > 0) { |
| 1788 | + toast.warning( |
| 1789 | + $i18n.t('Please connect all required integrations before sending a message') |
| 1790 | + ); |
| 1791 | + return; |
| 1792 | + } |
1768 | 1793 | if (userPrompt === '' && files.length === 0) { |
1769 | 1794 | toast.error($i18n.t('Please enter a prompt')); |
1770 | 1795 | return; |
|
2843 | 2868 | bind:selectedFilterIds |
2844 | 2869 | bind:imageGenerationEnabled |
2845 | 2870 | bind:codeInterpreterEnabled |
| 2871 | + {pendingOAuthTools} |
2846 | 2872 | bind:webSearchEnabled |
2847 | 2873 | bind:atSelectedModel |
2848 | 2874 | bind:showCommands |
|
2930 | 2956 | bind:atSelectedModel |
2931 | 2957 | bind:showCommands |
2932 | 2958 | bind:dragged |
| 2959 | + {pendingOAuthTools} |
2933 | 2960 | toolServers={$toolServers} |
2934 | 2961 | {stopResponse} |
2935 | 2962 | {createMessagePair} |
|
0 commit comments