mirror of
https://github.com/aljazceru/goose.git
synced 2026-02-05 22:54:33 +01:00
no more esc toasts (#2109)
This commit is contained in:
@@ -23,6 +23,7 @@ export default function ExtensionsSection() {
|
||||
const [selectedExtension, setSelectedExtension] = useState<FixedExtensionEntry | null>(null);
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
const [isAddModalOpen, setIsAddModalOpen] = useState(false);
|
||||
// We don't need errorFormData anymore since we're not reopening modals on failure
|
||||
|
||||
const fetchExtensions = async () => {
|
||||
setLoading(true);
|
||||
@@ -72,38 +73,54 @@ export default function ExtensionsSection() {
|
||||
};
|
||||
|
||||
const handleAddExtension = async (formData: ExtensionFormData) => {
|
||||
// Close the modal immediately
|
||||
handleModalClose();
|
||||
|
||||
const extensionConfig = createExtensionConfig(formData);
|
||||
try {
|
||||
await activateExtension({ addToConfig: addExtension, extensionConfig: extensionConfig });
|
||||
} catch (error) {
|
||||
// Even if activation fails, the extension is added as disabled, so we want to show it
|
||||
console.error('Failed to activate extension:', error);
|
||||
// Even if activation fails, we don't reopen the modal
|
||||
} finally {
|
||||
handleModalClose();
|
||||
// Refresh the extensions list regardless of success or failure
|
||||
await fetchExtensions();
|
||||
}
|
||||
};
|
||||
|
||||
const handleUpdateExtension = async (formData: ExtensionFormData) => {
|
||||
const extensionConfig = createExtensionConfig(formData);
|
||||
|
||||
await updateExtension({
|
||||
enabled: formData.enabled,
|
||||
extensionConfig: extensionConfig,
|
||||
addToConfig: addExtension,
|
||||
});
|
||||
|
||||
// First refresh the extensions list
|
||||
await fetchExtensions();
|
||||
|
||||
// Then close the modal after data is refreshed
|
||||
// Close the modal immediately
|
||||
handleModalClose();
|
||||
|
||||
const extensionConfig = createExtensionConfig(formData);
|
||||
try {
|
||||
await updateExtension({
|
||||
enabled: formData.enabled,
|
||||
extensionConfig: extensionConfig,
|
||||
addToConfig: addExtension,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Failed to update extension:', error);
|
||||
// We don't reopen the modal on failure
|
||||
} finally {
|
||||
// Refresh the extensions list regardless of success or failure
|
||||
await fetchExtensions();
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteExtension = async (name: string) => {
|
||||
await deleteExtension({ name, removeFromConfig: removeExtension });
|
||||
// Close the modal immediately
|
||||
handleModalClose();
|
||||
await fetchExtensions();
|
||||
|
||||
try {
|
||||
await deleteExtension({ name, removeFromConfig: removeExtension });
|
||||
} catch (error) {
|
||||
console.error('Failed to delete extension:', error);
|
||||
// We don't reopen the modal on failure
|
||||
} finally {
|
||||
// Refresh the extensions list regardless of success or failure
|
||||
await fetchExtensions();
|
||||
}
|
||||
};
|
||||
|
||||
const handleModalClose = () => {
|
||||
|
||||
@@ -18,7 +18,7 @@ export async function activateExtension({
|
||||
}: ActivateExtensionProps): Promise<void> {
|
||||
try {
|
||||
// AddToAgent
|
||||
await addToAgent(extensionConfig, { silent: false, showEscMessage: true });
|
||||
await addToAgent(extensionConfig, { silent: false });
|
||||
} catch (error) {
|
||||
console.error('Failed to add extension to agent:', error);
|
||||
// add to config with enabled = false
|
||||
@@ -89,18 +89,15 @@ export async function addToAgentOnStartup({
|
||||
extensionConfig,
|
||||
}: AddToAgentOnStartupProps): Promise<void> {
|
||||
try {
|
||||
await retryWithBackoff(
|
||||
() => addToAgent(extensionConfig, { silent: true, showEscMessage: false }),
|
||||
{
|
||||
retries: 3,
|
||||
delayMs: 1000,
|
||||
shouldRetry: (error: any) =>
|
||||
error.message &&
|
||||
(error.message.includes('428') ||
|
||||
error.message.includes('Precondition Required') ||
|
||||
error.message.includes('Agent is not initialized')),
|
||||
}
|
||||
);
|
||||
await retryWithBackoff(() => addToAgent(extensionConfig, { silent: true }), {
|
||||
retries: 3,
|
||||
delayMs: 1000,
|
||||
shouldRetry: (error: any) =>
|
||||
error.message &&
|
||||
(error.message.includes('428') ||
|
||||
error.message.includes('Precondition Required') ||
|
||||
error.message.includes('Agent is not initialized')),
|
||||
});
|
||||
} catch (finalError) {
|
||||
toastService.configure({ silent: false });
|
||||
toastService.error({
|
||||
@@ -190,8 +187,6 @@ export async function toggleExtension({
|
||||
// add to agent with toast options
|
||||
await addToAgent(extensionConfig, {
|
||||
...toastOptions,
|
||||
// For toggle operations, we want to show toast but no ESC message
|
||||
showEscMessage: false,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error adding extension to agent. Will try to toggle back off.');
|
||||
|
||||
@@ -4,13 +4,11 @@ import { Button } from './components/ui/button';
|
||||
|
||||
export interface ToastServiceOptions {
|
||||
silent?: boolean;
|
||||
showEscMessage?: boolean;
|
||||
shouldThrow?: boolean;
|
||||
}
|
||||
|
||||
export default class ToastService {
|
||||
private silent: boolean = false;
|
||||
private showEscMessage: boolean = true;
|
||||
private shouldThrow: boolean = false;
|
||||
|
||||
// Create a singleton instance
|
||||
@@ -27,9 +25,7 @@ export default class ToastService {
|
||||
if (options.silent !== undefined) {
|
||||
this.silent = options.silent;
|
||||
}
|
||||
if (options.showEscMessage !== undefined) {
|
||||
this.showEscMessage = options.showEscMessage;
|
||||
}
|
||||
|
||||
if (options.shouldThrow !== undefined) {
|
||||
this.shouldThrow = options.shouldThrow;
|
||||
}
|
||||
@@ -52,11 +48,6 @@ export default class ToastService {
|
||||
|
||||
const toastId = toastLoading({ title, msg });
|
||||
|
||||
if (this.showEscMessage) {
|
||||
toast.info(
|
||||
'Press the ESC key on your keyboard to continue using goose while extension loads'
|
||||
);
|
||||
}
|
||||
return toastId;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user