diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index a12ab41a..b98db535 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -6,6 +6,7 @@ import { Navbar } from '@/components/layout/navbar'; import { Projects } from '@/pages/projects'; import { ProjectTasks } from '@/pages/project-tasks'; import { useTaskViewManager } from '@/hooks/useTaskViewManager'; +import { usePreviousPath } from '@/hooks/usePreviousPath'; import { AgentSettings, @@ -37,6 +38,9 @@ function AppContent() { const { config, updateAndSaveConfig, loading } = useUserSystem(); const { isFullscreen } = useTaskViewManager(); + // Track previous path for back navigation + usePreviousPath(); + const showNavbar = !isFullscreen; useEffect(() => { diff --git a/frontend/src/hooks/usePreviousPath.ts b/frontend/src/hooks/usePreviousPath.ts new file mode 100644 index 00000000..03515cdd --- /dev/null +++ b/frontend/src/hooks/usePreviousPath.ts @@ -0,0 +1,28 @@ +import { useCallback, useEffect } from 'react'; +import { useLocation, useNavigate } from 'react-router-dom'; + +const globalVisited: string[] = []; + +export function usePreviousPath() { + const navigate = useNavigate(); + const location = useLocation(); + + // Track pathnames as user navigates + useEffect(() => { + if (globalVisited[globalVisited.length - 1] !== location.pathname) { + globalVisited.push(location.pathname); + // Keep only last 50 entries to prevent memory bloat + if (globalVisited.length > 50) { + globalVisited.splice(0, globalVisited.length - 50); + } + } + }, [location]); + + return useCallback(() => { + // Find last non-settings route in history + const lastNonSettingsPath = [...globalVisited] + .reverse() + .find((p) => !p.startsWith('/settings')); + navigate(lastNonSettingsPath || '/'); + }, [navigate]); +} diff --git a/frontend/src/i18n/locales/en/settings.json b/frontend/src/i18n/locales/en/settings.json index 606f8b46..71ca25f9 100644 --- a/frontend/src/i18n/locales/en/settings.json +++ b/frontend/src/i18n/locales/en/settings.json @@ -8,7 +8,8 @@ "agents": "Agents", "agentsDesc": "Coding agent configurations", "mcp": "MCP Servers", - "mcpDesc": "Model Context Protocol servers" + "mcpDesc": "Model Context Protocol servers", + "backToApp": "Back to app" } }, "general": { diff --git a/frontend/src/i18n/locales/es/settings.json b/frontend/src/i18n/locales/es/settings.json index 893ee960..a5a48bf7 100644 --- a/frontend/src/i18n/locales/es/settings.json +++ b/frontend/src/i18n/locales/es/settings.json @@ -8,7 +8,8 @@ "agents": "Agentes", "agentsDesc": "Configuraciones de agentes", "mcp": "Servidores MCP", - "mcpDesc": "Servidores de Protocolo de Contexto de Modelo (MCP)" + "mcpDesc": "Servidores de Protocolo de Contexto de Modelo (MCP)", + "backToApp": "Volver a la app" } }, "general": { @@ -134,7 +135,10 @@ "mcp": { "title": "Configuración de Servidor MCP", "description": "Configura los servidores del Protocolo de Contexto de Modelos (MCP) para ampliar las capacidades del agente de codificación con herramientas y recursos personalizados.", - "loading": "Cargando configuración MCP...", + "loading": { + "jsonEditor": "Cargando...", + "configuration": "Cargando configuración actual del servidor MCP..." + }, "applying": "Aplicando configuración...", "labels": { "agent": "Agente", @@ -145,10 +149,6 @@ "serverHelper": "Haz clic en una tarjeta para insertar ese Servidor MCP en el JSON de arriba.", "saveLocation": "Los cambios se guardarán en:" }, - "loading": { - "jsonEditor": "Cargando...", - "configuration": "Cargando configuración actual del servidor MCP..." - }, "errors": { "loadFailed": "Error al cargar la configuración.", "invalidJson": "Formato JSON inválido", diff --git a/frontend/src/i18n/locales/ja/settings.json b/frontend/src/i18n/locales/ja/settings.json index a28dd0be..d20f5876 100644 --- a/frontend/src/i18n/locales/ja/settings.json +++ b/frontend/src/i18n/locales/ja/settings.json @@ -8,7 +8,8 @@ "agents": "エージェント", "agentsDesc": "コーディングエージェントの設定", "mcp": "MCPサーバー", - "mcpDesc": "モデルコンテキストプロトコルサーバー" + "mcpDesc": "モデルコンテキストプロトコルサーバー", + "backToApp": "アプリに戻る" } }, "general": { diff --git a/frontend/src/pages/settings/SettingsLayout.tsx b/frontend/src/pages/settings/SettingsLayout.tsx index 2a4bb45b..7d9fc2d0 100644 --- a/frontend/src/pages/settings/SettingsLayout.tsx +++ b/frontend/src/pages/settings/SettingsLayout.tsx @@ -1,7 +1,9 @@ import { NavLink, Outlet } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; -import { Settings, Cpu, Server } from 'lucide-react'; +import { Settings, Cpu, Server, ArrowLeft } from 'lucide-react'; import { cn } from '@/lib/utils'; +import { Button } from '@/components/ui/button'; +import { usePreviousPath } from '@/hooks/usePreviousPath'; const settingsNavigation = [ { @@ -20,6 +22,7 @@ const settingsNavigation = [ export function SettingsLayout() { const { t } = useTranslation('settings'); + const goToPreviousPath = usePreviousPath(); return (
@@ -27,6 +30,10 @@ export function SettingsLayout() { {/* Sidebar Navigation */}