Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,22 @@ describe('Extension Manager', () => {
mockAddToAgent.mockResolvedValue(undefined);

await addToAgentOnStartup({
addToConfig: mockAddToConfig,
sessionId: 'test-session',
extensionConfig: mockExtensionConfig,
});

expect(mockAddToAgent).toHaveBeenCalledWith(mockExtensionConfig, 'test-session', true);
expect(mockAddToConfig).not.toHaveBeenCalled();
});

it('should successfully add extension on startup with custom toast options', async () => {
mockAddToAgent.mockResolvedValue(undefined);

await addToAgentOnStartup({
addToConfig: mockAddToConfig,
sessionId: 'test-session',
extensionConfig: mockExtensionConfig,
});

expect(mockAddToAgent).toHaveBeenCalledWith(mockExtensionConfig, 'test-session', true);
expect(mockAddToConfig).not.toHaveBeenCalled();
});

it('should retry on 428 errors', async () => {
Expand All @@ -67,30 +63,28 @@ describe('Extension Manager', () => {
.mockResolvedValue(undefined);

await addToAgentOnStartup({
addToConfig: mockAddToConfig,
sessionId: 'test-session',
extensionConfig: mockExtensionConfig,
});

expect(mockAddToAgent).toHaveBeenCalledTimes(3);
});

it('should disable extension after max retries', async () => {
it('should show error toast after max retries but keep extension enabled', async () => {
const error428 = new Error('428 Precondition Required');
mockAddToAgent.mockRejectedValue(error428);
mockToastService.configure = vi.fn();
mockToastService.error = vi.fn();

await addToAgentOnStartup({
addToConfig: mockAddToConfig,
sessionId: 'test-session',
extensionConfig: mockExtensionConfig,
});

expect(mockAddToAgent).toHaveBeenCalledTimes(4); // Initial + 3 retries
expect(mockToastService.error).toHaveBeenCalledWith({
title: 'test-extension',
msg: 'Extension failed to start and will be disabled.',
msg: 'Extension failed to start and will retry on a new session.',
traceback: '428 Precondition Required',
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export async function activateExtension({
}

interface AddToAgentOnStartupProps {
addToConfig: (name: string, extensionConfig: ExtensionConfig, enabled: boolean) => Promise<void>;
extensionConfig: ExtensionConfig;
toastOptions?: ToastServiceOptions;
sessionId: string;
Expand All @@ -95,7 +94,6 @@ interface AddToAgentOnStartupProps {
* TODO(Douwe): Delete this after basecamp lands
*/
export async function addToAgentOnStartup({
addToConfig,
extensionConfig,
sessionId,
}: AddToAgentOnStartupProps): Promise<void> {
Expand All @@ -113,21 +111,9 @@ export async function addToAgentOnStartup({
toastService.configure({ silent: false });
toastService.error({
title: extensionConfig.name,
msg: 'Extension failed to start and will be disabled.',
msg: 'Extension failed to start and will retry on a new session.',
traceback: finalError instanceof Error ? finalError.message : String(finalError),
});

try {
await toggleExtension({
toggle: 'toggleOff',
extensionConfig,
addToConfig,
toastOptions: { silent: true },
sessionId,
});
} catch (toggleErr) {
console.error('Failed to toggle off after error:', toggleErr);
}
}
}

Expand Down
1 change: 0 additions & 1 deletion ui/desktop/src/utils/providerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export const initializeSystem = async (

try {
await addToAgentOnStartup({
addToConfig: options.addExtension!,
extensionConfig,
toastOptions: { silent: false },
sessionId,
Expand Down
Loading