Skip to content
This repository was archived by the owner on Apr 14, 2026. It is now read-only.

Commit 7f31faf

Browse files
committed
refactor useCredentials and ProvidersSettings: remove unused restart logic and improve scroll handling
Eliminate the restart logic from the useCredentials hook, as it is no longer necessary. Update ProvidersSettings to enhance scroll handling by replacing a fragile container reference with a more reliable approach. Additionally, clean up the code in AgentProviderCard and SettingsModal for better readability.
1 parent 0b1a74f commit 7f31faf

File tree

5 files changed

+17
-34
lines changed

5 files changed

+17
-34
lines changed

src/features/providers/hooks/useCredentials.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,23 @@ import {
55
deleteProviderConfig,
66
type ProviderStatus,
77
checkAllProviderStatus,
8-
restartApp,
98
} from "@/features/providers/api/credentials";
109
import type { ProviderFieldValue } from "@/shared/types/providers";
1110

1211
interface UseCredentialsReturn {
1312
configuredIds: Set<string>;
1413
loading: boolean;
1514
saving: boolean;
16-
needsRestart: boolean;
1715
getConfig: (providerId: string) => Promise<ProviderFieldValue[]>;
1816
save: (key: string, value: string) => Promise<void>;
1917
remove: (providerId: string) => Promise<void>;
20-
restart: () => Promise<void>;
2118
completeNativeSetup: () => Promise<void>;
2219
}
2320

2421
export function useCredentials(): UseCredentialsReturn {
2522
const [statuses, setStatuses] = useState<ProviderStatus[]>([]);
2623
const [loading, setLoading] = useState(true);
2724
const [saving, setSaving] = useState(false);
28-
const [needsRestart, setNeedsRestart] = useState(false);
2925

3026
const refreshStatuses = useCallback(async () => {
3127
const nextStatuses = await checkAllProviderStatus();
@@ -55,7 +51,6 @@ export function useCredentials(): UseCredentialsReturn {
5551
try {
5652
await saveProviderField(key, value);
5753
await refreshStatuses();
58-
setNeedsRestart(true);
5954
} finally {
6055
setSaving(false);
6156
}
@@ -69,32 +64,24 @@ export function useCredentials(): UseCredentialsReturn {
6964
try {
7065
await deleteProviderConfig(providerId);
7166
await refreshStatuses();
72-
setNeedsRestart(true);
7367
} finally {
7468
setSaving(false);
7569
}
7670
},
7771
[refreshStatuses],
7872
);
7973

80-
const restart = useCallback(async () => {
81-
await restartApp();
82-
}, []);
83-
8474
const completeNativeSetup = useCallback(async () => {
8575
await refreshStatuses();
86-
setNeedsRestart(true);
8776
}, [refreshStatuses]);
8877

8978
return {
9079
configuredIds,
9180
loading,
9281
saving,
93-
needsRestart,
9482
getConfig,
9583
save,
9684
remove,
97-
restart,
9885
completeNativeSetup,
9986
};
10087
}

src/features/settings/ui/AgentProviderCard.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ import { Button } from "@/shared/ui/button";
55
import { Spinner } from "@/shared/ui/spinner";
66
import { getProviderIcon } from "@/shared/ui/icons/ProviderIcons";
77
import { IconCheck, IconAlertTriangle, IconPlus } from "@tabler/icons-react";
8-
import {
9-
Tooltip,
10-
TooltipTrigger,
11-
TooltipContent,
12-
} from "@/shared/ui/tooltip";
8+
import { Tooltip, TooltipTrigger, TooltipContent } from "@/shared/ui/tooltip";
139
import {
1410
checkAgentInstalled,
1511
checkAgentAuth,

src/features/settings/ui/ProvidersSettings.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@ export function ProvidersSettings({
9191
scrollRafRef.current = null;
9292
}
9393

94-
const container = scrollContainerRef?.current;
95-
if (!container) {
94+
const scrollEl = scrollContainerRef?.current;
95+
if (!scrollEl) {
9696
target.scrollIntoView({ behavior: "smooth" });
9797
return;
9898
}
9999

100100
const targetTop =
101101
target.getBoundingClientRect().top -
102-
container.getBoundingClientRect().top +
103-
container.scrollTop -
102+
scrollEl.getBoundingClientRect().top +
103+
scrollEl.scrollTop -
104104
16;
105-
const start = container.scrollTop;
105+
const start = scrollEl.scrollTop;
106106
const distance = targetTop - start;
107107
const duration = 500;
108108
let startTime: number | null = null;
@@ -111,17 +111,17 @@ export function ProvidersSettings({
111111
return p < 0.5 ? 4 * p * p * p : 1 - (-2 * p + 2) ** 3 / 2;
112112
}
113113

114-
function step(timestamp: number) {
114+
const step = (timestamp: number) => {
115115
if (!startTime) startTime = timestamp;
116116
const elapsed = timestamp - startTime;
117117
const progress = Math.min(elapsed / duration, 1);
118-
container.scrollTop = start + distance * easeInOut(progress);
118+
scrollEl.scrollTop = start + distance * easeInOut(progress);
119119
if (progress < 1) {
120120
scrollRafRef.current = requestAnimationFrame(step);
121121
} else {
122122
scrollRafRef.current = null;
123123
}
124-
}
124+
};
125125

126126
scrollRafRef.current = requestAnimationFrame(step);
127127
}, [scrollContainerRef]);

src/features/settings/ui/SettingsModal.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,7 @@ export function SettingsModal({
239239
>
240240
{activeSection === "appearance" && <AppearanceSettings />}
241241
{activeSection === "providers" && (
242-
<ProvidersSettings
243-
scrollContainerRef={contentScrollRef}
244-
/>
242+
<ProvidersSettings scrollContainerRef={contentScrollRef} />
245243
)}
246244
{activeSection === "doctor" && <DoctorSettings />}
247245
{activeSection === "general" && (

src/shared/i18n/locales/es/settings.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,18 @@
9595
},
9696
"providers": {
9797
"agents": {
98-
"description": "Los agentes manejan tus solicitudes usando sus propias herramientas y modelos",
98+
"connectModelLabel": "Conectar un proveedor de modelos para Goose",
99+
"connectModelTooltip": "Conectar un proveedor de modelos",
100+
"description": "Cada agente maneja tus solicitudes de manera diferente. Los agentes externos traen sus propios modelos. Goose usa los proveedores de modelos de abajo.",
99101
"installLabel": "Instalar {{name}}",
100102
"signIn": "Iniciar sesión",
101103
"signInLabel": "Iniciar sesión en {{name}}",
102-
"title": "Agentes"
104+
"title": "Proveedores de agentes"
103105
},
104-
"description": "Conecta agentes y modelos de IA para usar con Goose",
106+
"description": "Conecta un agente para comenzar. Goose usa los proveedores de modelos de abajo; otros agentes traen los suyos.",
105107
"disconnect": "Desconectar",
106108
"models": {
107-
"description": "Modelos de IA que alimentan a Goose. Expande un proveedor para revisar lo que necesita. Conectar inicia sesión con una cuenta existente, mientras que Configurar guarda claves API u otros ajustes del proveedor.",
109+
"description": "Conecta un proveedor de modelos para alimentar al agente Goose. Necesitas al menos uno conectado para usar Goose.",
108110
"notSet": "No configurado",
109111
"setup": {
110112
"connected": {
@@ -128,7 +130,7 @@
128130
"oauthTerminal": "Ejecuta `goose configure` en tu terminal para terminar de iniciar sesión."
129131
}
130132
},
131-
"title": "Modelos"
133+
"title": "Proveedores de modelos"
132134
},
133135
"saved": "Guardado",
134136
"showFewer": "Mostrar menos",

0 commit comments

Comments
 (0)