feat(goose): support customizing extension timeout (#1428)
This commit is contained in:
@@ -3,13 +3,17 @@ import { type View } from './App';
|
||||
import { type SettingsViewOptions } from './components/settings/SettingsView';
|
||||
import { toast } from 'react-toastify';
|
||||
|
||||
export const DEFAULT_EXTENSION_TIMEOUT: number = 300;
|
||||
|
||||
// ExtensionConfig type matching the Rust version
|
||||
// TODO: refactor this
|
||||
export type ExtensionConfig =
|
||||
| {
|
||||
type: 'sse';
|
||||
name: string;
|
||||
uri: string;
|
||||
env_keys?: string[];
|
||||
timeout?: number;
|
||||
}
|
||||
| {
|
||||
type: 'stdio';
|
||||
@@ -17,11 +21,13 @@ export type ExtensionConfig =
|
||||
cmd: string;
|
||||
args: string[];
|
||||
env_keys?: string[];
|
||||
timeout?: number;
|
||||
}
|
||||
| {
|
||||
type: 'builtin';
|
||||
name: string;
|
||||
env_keys?: string[];
|
||||
timeout?: number;
|
||||
};
|
||||
|
||||
// FullExtensionConfig type matching all the fields that come in deep links and are stored in local storage
|
||||
@@ -38,6 +44,7 @@ export interface ExtensionPayload {
|
||||
args?: string[];
|
||||
uri?: string;
|
||||
env_keys?: string[];
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
export const BUILT_IN_EXTENSIONS = [
|
||||
@@ -48,6 +55,7 @@ export const BUILT_IN_EXTENSIONS = [
|
||||
enabled: true,
|
||||
type: 'builtin',
|
||||
env_keys: [],
|
||||
timeout: DEFAULT_EXTENSION_TIMEOUT,
|
||||
},
|
||||
{
|
||||
id: 'computercontroller',
|
||||
@@ -57,6 +65,7 @@ export const BUILT_IN_EXTENSIONS = [
|
||||
enabled: false,
|
||||
type: 'builtin',
|
||||
env_keys: [],
|
||||
timeout: DEFAULT_EXTENSION_TIMEOUT,
|
||||
},
|
||||
{
|
||||
id: 'memory',
|
||||
@@ -65,6 +74,7 @@ export const BUILT_IN_EXTENSIONS = [
|
||||
enabled: false,
|
||||
type: 'builtin',
|
||||
env_keys: [],
|
||||
timeout: DEFAULT_EXTENSION_TIMEOUT,
|
||||
},
|
||||
{
|
||||
id: 'jetbrains',
|
||||
@@ -73,6 +83,7 @@ export const BUILT_IN_EXTENSIONS = [
|
||||
enabled: false,
|
||||
type: 'builtin',
|
||||
env_keys: [],
|
||||
timeout: DEFAULT_EXTENSION_TIMEOUT,
|
||||
},
|
||||
{
|
||||
id: 'tutorial',
|
||||
@@ -93,6 +104,7 @@ export const BUILT_IN_EXTENSIONS = [
|
||||
'GOOGLE_DRIVE_CREDENTIALS_PATH',
|
||||
'GOOGLE_DRIVE_OAUTH_CONFIG',
|
||||
],
|
||||
timeout: DEFAULT_EXTENSION_TIMEOUT,
|
||||
},*/
|
||||
];
|
||||
|
||||
@@ -121,6 +133,7 @@ export async function addExtension(
|
||||
name: sanitizeName(extension.name),
|
||||
}),
|
||||
env_keys: extension.env_keys,
|
||||
timeout: extension.timeout,
|
||||
};
|
||||
|
||||
const response = await fetch(getApiUrl('/extensions/add'), {
|
||||
@@ -327,6 +340,7 @@ export async function addExtensionFromDeepLink(
|
||||
const id = parsedUrl.searchParams.get('id');
|
||||
const name = parsedUrl.searchParams.get('name');
|
||||
const description = parsedUrl.searchParams.get('description');
|
||||
const timeout = parsedUrl.searchParams.get('timeout');
|
||||
|
||||
// split env based on delimiter to a map
|
||||
const envs = envList.reduce(
|
||||
@@ -339,6 +353,9 @@ export async function addExtensionFromDeepLink(
|
||||
);
|
||||
|
||||
// Create a ExtensionConfig from the URL parameters
|
||||
// Parse timeout if provided, otherwise use default
|
||||
const parsedTimeout = timeout ? parseInt(timeout, 10) : null;
|
||||
|
||||
const config: FullExtensionConfig = {
|
||||
id,
|
||||
name,
|
||||
@@ -348,6 +365,10 @@ export async function addExtensionFromDeepLink(
|
||||
description,
|
||||
enabled: true,
|
||||
env_keys: Object.keys(envs).length > 0 ? Object.keys(envs) : [],
|
||||
timeout:
|
||||
parsedTimeout !== null && !isNaN(parsedTimeout) && Number.isInteger(parsedTimeout)
|
||||
? parsedTimeout
|
||||
: DEFAULT_EXTENSION_TIMEOUT,
|
||||
};
|
||||
|
||||
// Store the extension config regardless of env vars status
|
||||
|
||||
Reference in New Issue
Block a user