Don't disable extensions after they fail to activate in new chat session (#5464)
This commit is contained in:
@@ -37,26 +37,22 @@ describe('Extension Manager', () => {
|
|||||||
mockAddToAgent.mockResolvedValue(undefined);
|
mockAddToAgent.mockResolvedValue(undefined);
|
||||||
|
|
||||||
await addToAgentOnStartup({
|
await addToAgentOnStartup({
|
||||||
addToConfig: mockAddToConfig,
|
|
||||||
sessionId: 'test-session',
|
sessionId: 'test-session',
|
||||||
extensionConfig: mockExtensionConfig,
|
extensionConfig: mockExtensionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(mockAddToAgent).toHaveBeenCalledWith(mockExtensionConfig, 'test-session', true);
|
expect(mockAddToAgent).toHaveBeenCalledWith(mockExtensionConfig, 'test-session', true);
|
||||||
expect(mockAddToConfig).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should successfully add extension on startup with custom toast options', async () => {
|
it('should successfully add extension on startup with custom toast options', async () => {
|
||||||
mockAddToAgent.mockResolvedValue(undefined);
|
mockAddToAgent.mockResolvedValue(undefined);
|
||||||
|
|
||||||
await addToAgentOnStartup({
|
await addToAgentOnStartup({
|
||||||
addToConfig: mockAddToConfig,
|
|
||||||
sessionId: 'test-session',
|
sessionId: 'test-session',
|
||||||
extensionConfig: mockExtensionConfig,
|
extensionConfig: mockExtensionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(mockAddToAgent).toHaveBeenCalledWith(mockExtensionConfig, 'test-session', true);
|
expect(mockAddToAgent).toHaveBeenCalledWith(mockExtensionConfig, 'test-session', true);
|
||||||
expect(mockAddToConfig).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should retry on 428 errors', async () => {
|
it('should retry on 428 errors', async () => {
|
||||||
@@ -67,7 +63,6 @@ describe('Extension Manager', () => {
|
|||||||
.mockResolvedValue(undefined);
|
.mockResolvedValue(undefined);
|
||||||
|
|
||||||
await addToAgentOnStartup({
|
await addToAgentOnStartup({
|
||||||
addToConfig: mockAddToConfig,
|
|
||||||
sessionId: 'test-session',
|
sessionId: 'test-session',
|
||||||
extensionConfig: mockExtensionConfig,
|
extensionConfig: mockExtensionConfig,
|
||||||
});
|
});
|
||||||
@@ -75,14 +70,13 @@ describe('Extension Manager', () => {
|
|||||||
expect(mockAddToAgent).toHaveBeenCalledTimes(3);
|
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');
|
const error428 = new Error('428 Precondition Required');
|
||||||
mockAddToAgent.mockRejectedValue(error428);
|
mockAddToAgent.mockRejectedValue(error428);
|
||||||
mockToastService.configure = vi.fn();
|
mockToastService.configure = vi.fn();
|
||||||
mockToastService.error = vi.fn();
|
mockToastService.error = vi.fn();
|
||||||
|
|
||||||
await addToAgentOnStartup({
|
await addToAgentOnStartup({
|
||||||
addToConfig: mockAddToConfig,
|
|
||||||
sessionId: 'test-session',
|
sessionId: 'test-session',
|
||||||
extensionConfig: mockExtensionConfig,
|
extensionConfig: mockExtensionConfig,
|
||||||
});
|
});
|
||||||
@@ -90,7 +84,7 @@ describe('Extension Manager', () => {
|
|||||||
expect(mockAddToAgent).toHaveBeenCalledTimes(4); // Initial + 3 retries
|
expect(mockAddToAgent).toHaveBeenCalledTimes(4); // Initial + 3 retries
|
||||||
expect(mockToastService.error).toHaveBeenCalledWith({
|
expect(mockToastService.error).toHaveBeenCalledWith({
|
||||||
title: 'test-extension',
|
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',
|
traceback: '428 Precondition Required',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ export async function activateExtension({
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface AddToAgentOnStartupProps {
|
interface AddToAgentOnStartupProps {
|
||||||
addToConfig: (name: string, extensionConfig: ExtensionConfig, enabled: boolean) => Promise<void>;
|
|
||||||
extensionConfig: ExtensionConfig;
|
extensionConfig: ExtensionConfig;
|
||||||
toastOptions?: ToastServiceOptions;
|
toastOptions?: ToastServiceOptions;
|
||||||
sessionId: string;
|
sessionId: string;
|
||||||
@@ -95,7 +94,6 @@ interface AddToAgentOnStartupProps {
|
|||||||
* TODO(Douwe): Delete this after basecamp lands
|
* TODO(Douwe): Delete this after basecamp lands
|
||||||
*/
|
*/
|
||||||
export async function addToAgentOnStartup({
|
export async function addToAgentOnStartup({
|
||||||
addToConfig,
|
|
||||||
extensionConfig,
|
extensionConfig,
|
||||||
sessionId,
|
sessionId,
|
||||||
}: AddToAgentOnStartupProps): Promise<void> {
|
}: AddToAgentOnStartupProps): Promise<void> {
|
||||||
@@ -113,21 +111,9 @@ export async function addToAgentOnStartup({
|
|||||||
toastService.configure({ silent: false });
|
toastService.configure({ silent: false });
|
||||||
toastService.error({
|
toastService.error({
|
||||||
title: extensionConfig.name,
|
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),
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ export const initializeSystem = async (
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await addToAgentOnStartup({
|
await addToAgentOnStartup({
|
||||||
addToConfig: options.addExtension!,
|
|
||||||
extensionConfig,
|
extensionConfig,
|
||||||
toastOptions: { silent: false },
|
toastOptions: { silent: false },
|
||||||
sessionId,
|
sessionId,
|
||||||
|
|||||||
Reference in New Issue
Block a user