mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
refactor(frontend): extract navigation helpers and improve settings back navigation (#210)
* feat: add persistent model state storage with database backend - Create opencode_model_state table for storing user model preferences - Implement database-backed model state management (recent, favorite, variant) - Add atomic JSON file utilities with file locking for concurrent safety - Migrate providers routes from file-based to database storage - Add backfill migration to preserve existing model.json data - Include comprehensive tests for model-state and atomic-json modules - Refactor useSessionAgent hook to simplify agent/model resolution logic - Update getFileApiUrl to use consistent query parameter approach * fix: include workspace dependencies in Docker image * fix: overlay workspace node_modules after source to prevent layer overwrite * fix: ensure model state table exists for existing databases * feat: add model state persistence and improve model selection sync - Add setActiveModel to modelStore and useModelSelection for direct model updates - Sync session agent model/variant to store when messages load - Include model, agent, and variant in optimistic user messages - Fix useSessionAgent to check isFetching during message loading - Update env.ts to use getter for BASE_PATH for dynamic resolution - Fix test environment variable from OPENCODE_WORKSPACE_PATH to WORKSPACE_PATH * refactor(frontend): extract navigation helpers and improve settings back navigation - Move swipe-back route logic into shared navigation.ts module - Add getSessionListPath helper for consistent session list navigation - Add section history tracking to settings dialog for proper back navigation - Fix voice status overlay loading text visibility during starting state - Update env and vite config for production domain
This commit is contained in:
1 parent
549e0ac7b2
commit
e959cc409f
10 files changed
+361
-66
No files matched your search
+14
-33
@@ -1,7 +1,7 @@
|
||||
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { createBrowserRouter, RouterProvider, Outlet, useNavigate, useLocation } from 'react-router-dom'
|
||||
import { useEffect, useRef } from 'react'
|
||||
import { useEffect, useRef, useCallback } from 'react'
|
||||
import { Toaster } from 'sonner'
|
||||
import { Repos } from './pages/Repos'
|
||||
import { RepoDetail } from './pages/RepoDetail'
|
||||
@@ -29,6 +29,7 @@ import { SwipeNavigationProvider } from '@/contexts/SwipeNavigationContext'
|
||||
import { PermissionRequestDialog } from './components/session/PermissionRequestDialog'
|
||||
import { SSHHostKeyDialog } from './components/ssh/SSHHostKeyDialog'
|
||||
import { loginLoader, setupLoader, registerLoader, protectedLoader } from './lib/auth-loaders'
|
||||
import { getSwipeBackTarget } from '@/lib/navigation'
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
@@ -80,40 +81,20 @@ function AppShell() {
|
||||
const { open: openMobileSheet, openSheet } = useMobileTabBar()
|
||||
useTheme()
|
||||
|
||||
const getSwipeBackTarget = () => {
|
||||
const path = location.pathname
|
||||
if (path.match(/^\/repos\/[^/]+\/sessions\/[^/]+$/)) {
|
||||
const repoId = path.split('/')[2]
|
||||
return `/repos/${repoId}`
|
||||
}
|
||||
if (path.match(/^\/repos\/[^/]+$/)) {
|
||||
return '/'
|
||||
}
|
||||
if (path.match(/^\/repos\/[^/]+\/memories$/)) {
|
||||
const repoId = path.split('/')[2]
|
||||
return `/repos/${repoId}`
|
||||
}
|
||||
if (path.match(/^\/repos\/[^/]+\/schedules$/)) {
|
||||
const repoId = path.split('/')[2]
|
||||
return `/repos/${repoId}`
|
||||
}
|
||||
if (path === '/schedules') {
|
||||
return '/'
|
||||
}
|
||||
return null
|
||||
}
|
||||
const getRouteSwipeBackTarget = useCallback(
|
||||
() => getSwipeBackTarget(location.pathname, location.search),
|
||||
[location.pathname, location.search]
|
||||
)
|
||||
|
||||
const canSwipeBack = () => {
|
||||
const path = location.pathname
|
||||
return !['/login', '/setup', '/register', '/'].includes(path) && getSwipeBackTarget() !== null
|
||||
}
|
||||
const canSwipeBack = useCallback(
|
||||
() => getRouteSwipeBackTarget() !== null,
|
||||
[getRouteSwipeBackTarget]
|
||||
)
|
||||
|
||||
const handleSwipeBack = () => {
|
||||
const target = getSwipeBackTarget()
|
||||
if (target) {
|
||||
navigate(target)
|
||||
}
|
||||
}
|
||||
const handleSwipeBack = useCallback(() => {
|
||||
const target = getRouteSwipeBackTarget()
|
||||
if (target) navigate(target)
|
||||
}, [getRouteSwipeBackTarget, navigate])
|
||||
|
||||
const { bind: bindRouteSwipe } = useSwipeBack(
|
||||
() => {},
|
||||
|
||||
@@ -14,6 +14,7 @@ export function VoiceStatusOverlay({ show, label, state }: VoiceStatusOverlayPro
|
||||
}
|
||||
|
||||
const isLoading = state === 'starting' || state === 'processing' || state === 'sending'
|
||||
const showLoadingText = state !== 'starting'
|
||||
const topLabel = state === 'readyToSend'
|
||||
? 'Release'
|
||||
: state === 'starting'
|
||||
@@ -48,7 +49,9 @@ export function VoiceStatusOverlay({ show, label, state }: VoiceStatusOverlayPro
|
||||
{isLoading ? (
|
||||
<>
|
||||
<LoaderCircle className="h-6 w-6 animate-spin" />
|
||||
<span className="text-[10px] font-bold uppercase leading-none tracking-wide">{topLabel}</span>
|
||||
{showLoadingText && (
|
||||
<span className="text-[10px] font-bold uppercase leading-none tracking-wide">{topLabel}</span>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
@@ -61,11 +64,11 @@ export function VoiceStatusOverlay({ show, label, state }: VoiceStatusOverlayPro
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{isLoading ? (
|
||||
{isLoading && showLoadingText ? (
|
||||
<span className="relative text-[10px] font-bold uppercase leading-none tracking-wide">{bottomLabel}</span>
|
||||
) : (
|
||||
) : !isLoading ? (
|
||||
<X className="relative h-4 w-4" />
|
||||
)}
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { render, screen, fireEvent } from '@testing-library/react'
|
||||
import { MemoryRouter, useLocation, useNavigate } from 'react-router-dom'
|
||||
import { SettingsDialog } from './SettingsDialog'
|
||||
|
||||
vi.mock('@/components/settings/GeneralSettings', () => ({
|
||||
GeneralSettings: () => <div data-testid="general-settings">General Settings Content</div>,
|
||||
}))
|
||||
|
||||
vi.mock('@/components/settings/GitSettings', () => ({
|
||||
GitSettings: () => <div data-testid="git-settings">Git Settings Content</div>,
|
||||
}))
|
||||
|
||||
vi.mock('@/components/settings/KeyboardShortcuts', () => ({
|
||||
KeyboardShortcuts: () => <div data-testid="shortcuts-settings">Keyboard Shortcuts Content</div>,
|
||||
}))
|
||||
|
||||
vi.mock('@/components/settings/OpenCodeConfigManager', () => ({
|
||||
OpenCodeConfigManager: () => <div data-testid="opencode-settings">OpenCode Config Content</div>,
|
||||
}))
|
||||
|
||||
vi.mock('@/components/settings/ProviderSettings', () => ({
|
||||
ProviderSettings: () => <div data-testid="providers-settings">Provider Settings Content</div>,
|
||||
}))
|
||||
|
||||
vi.mock('@/components/settings/AccountSettings', () => ({
|
||||
AccountSettings: () => <div data-testid="account-settings">Account Settings Content</div>,
|
||||
}))
|
||||
|
||||
vi.mock('@/components/settings/VoiceSettings', () => ({
|
||||
VoiceSettings: () => <div data-testid="voice-settings">Voice Settings Content</div>,
|
||||
}))
|
||||
|
||||
vi.mock('@/components/settings/NotificationSettings', () => ({
|
||||
NotificationSettings: () => <div data-testid="notification-settings">Notification Settings Content</div>,
|
||||
}))
|
||||
|
||||
vi.mock('@/hooks/useMobile', () => ({
|
||||
useSwipeBack: vi.fn(() => ({
|
||||
bind: vi.fn(),
|
||||
swipeProgress: 0,
|
||||
swipeStyles: {},
|
||||
})),
|
||||
}))
|
||||
|
||||
describe('SettingsDialog', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('resets to menu state when dialog closes and reopens', () => {
|
||||
function TestWrapper() {
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const searchParams = new URLSearchParams(location.search)
|
||||
const isOpen = searchParams.get('settings') === 'open'
|
||||
|
||||
return (
|
||||
<>
|
||||
<button onClick={() => navigate('?settings=open&tab=general')}>Open Settings</button>
|
||||
<button onClick={() => navigate('/')}>Close Settings</button>
|
||||
{isOpen && <span data-testid="dialog-open">Dialog Open</span>}
|
||||
<SettingsDialog />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/']}>
|
||||
<TestWrapper />
|
||||
</MemoryRouter>
|
||||
)
|
||||
|
||||
fireEvent.click(screen.getByText('Open Settings'))
|
||||
expect(screen.getByTestId('dialog-open')).toBeInTheDocument()
|
||||
|
||||
fireEvent.click(screen.getByText('Close Settings'))
|
||||
expect(screen.queryByTestId('dialog-open')).not.toBeInTheDocument()
|
||||
|
||||
fireEvent.click(screen.getByText('Open Settings'))
|
||||
expect(screen.getByTestId('dialog-open')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('displays menu items in mobile view', () => {
|
||||
function TestWrapper() {
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const searchParams = new URLSearchParams(location.search)
|
||||
const isOpen = searchParams.get('settings') === 'open'
|
||||
|
||||
return (
|
||||
<>
|
||||
<button onClick={() => navigate('?settings=open')}>Open Settings</button>
|
||||
{isOpen && <span data-testid="dialog-open">Dialog Open</span>}
|
||||
<SettingsDialog />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/']}>
|
||||
<TestWrapper />
|
||||
</MemoryRouter>
|
||||
)
|
||||
|
||||
fireEvent.click(screen.getByText('Open Settings'))
|
||||
expect(screen.getByTestId('dialog-open')).toBeInTheDocument()
|
||||
|
||||
expect(screen.getAllByText('Account').length).toBeGreaterThanOrEqual(1)
|
||||
expect(screen.getAllByText('General').length).toBeGreaterThanOrEqual(1)
|
||||
expect(screen.getAllByText('Git').length).toBeGreaterThanOrEqual(1)
|
||||
expect(screen.getAllByText('Shortcuts').length).toBeGreaterThanOrEqual(1)
|
||||
expect(screen.getAllByText('OpenCode').length).toBeGreaterThanOrEqual(1)
|
||||
expect(screen.getAllByText('Providers').length).toBeGreaterThanOrEqual(1)
|
||||
})
|
||||
})
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState, useRef, useEffect } from 'react'
|
||||
import { useState, useRef, useEffect, useCallback } from 'react'
|
||||
import { GeneralSettings } from '@/components/settings/GeneralSettings'
|
||||
import { GitSettings } from '@/components/settings/GitSettings'
|
||||
import { KeyboardShortcuts } from '@/components/settings/KeyboardShortcuts'
|
||||
@@ -19,12 +19,44 @@ type SettingsView = 'menu' | 'general' | 'git' | 'shortcuts' | 'opencode' | 'pro
|
||||
export function SettingsDialog() {
|
||||
const { isOpen, close, activeTab, setActiveTab } = useSettingsDialog()
|
||||
const [mobileView, setMobileView] = useState<SettingsView>('menu')
|
||||
const [sectionHistory, setSectionHistory] = useState<SettingsView[]>([])
|
||||
const contentRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
const pushSectionHistory = useCallback((view: SettingsView) => {
|
||||
if (view === 'menu') return
|
||||
setSectionHistory((history) => {
|
||||
if (history.at(-1) === view) return history
|
||||
return [...history, view]
|
||||
})
|
||||
}, [])
|
||||
|
||||
const handleSettingsBack = useCallback(() => {
|
||||
if (mobileView === 'menu') {
|
||||
close()
|
||||
return
|
||||
}
|
||||
|
||||
const currentIndex = sectionHistory.lastIndexOf(mobileView)
|
||||
const previousHistory = currentIndex >= 0
|
||||
? sectionHistory.slice(0, currentIndex)
|
||||
: sectionHistory
|
||||
const previousView = previousHistory.at(-1)
|
||||
|
||||
if (previousView) {
|
||||
setSectionHistory(previousHistory)
|
||||
setMobileView(previousView)
|
||||
setActiveTab(previousView)
|
||||
return
|
||||
}
|
||||
|
||||
setSectionHistory([])
|
||||
setMobileView('menu')
|
||||
}, [mobileView, sectionHistory, close, setActiveTab])
|
||||
|
||||
const { bind: bindSwipe, swipeStyles } = useSwipeBack(close, {
|
||||
enabled: isOpen,
|
||||
canBack: () => mobileView !== 'menu',
|
||||
onBack: () => setMobileView('menu'),
|
||||
onBack: handleSettingsBack,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
@@ -32,7 +64,11 @@ export function SettingsDialog() {
|
||||
}, [bindSwipe])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isOpen) return
|
||||
if (!isOpen) {
|
||||
setMobileView('menu')
|
||||
setSectionHistory([])
|
||||
return
|
||||
}
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape') {
|
||||
e.stopPropagation()
|
||||
@@ -54,8 +90,17 @@ export function SettingsDialog() {
|
||||
{ id: 'providers', icon: Key, label: 'Providers', description: 'Manage AI provider API keys' },
|
||||
]
|
||||
|
||||
const handleOpenMobileView = useCallback((view: SettingsView) => {
|
||||
setMobileView(view)
|
||||
setActiveTab(view)
|
||||
pushSectionHistory(view)
|
||||
}, [setActiveTab, pushSectionHistory])
|
||||
|
||||
const handleTabChange = (tab: string) => {
|
||||
setActiveTab(tab as SettingsView)
|
||||
const nextView = tab as SettingsView
|
||||
setActiveTab(nextView)
|
||||
setMobileView(nextView)
|
||||
pushSectionHistory(nextView)
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -128,16 +173,16 @@ export function SettingsDialog() {
|
||||
<div className="sm:hidden flex flex-col h-full min-h-0 pt-safe">
|
||||
<div className="flex-shrink-0 bg-gradient-to-b from-background via-background to-transparent border-b border-border backdrop-blur-sm px-4 py-4 flex items-center justify-between">
|
||||
<div className="flex items-center gap-2 flex-1">
|
||||
{mobileView !== 'menu' && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={() => setMobileView('menu')}
|
||||
className="text-muted-foreground hover:text-foreground min-w-[44px] min-h-[44px]"
|
||||
>
|
||||
<ChevronLeft className="w-6 h-6" />
|
||||
</Button>
|
||||
)}
|
||||
{mobileView !== 'menu' && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={handleSettingsBack}
|
||||
className="text-muted-foreground hover:text-foreground min-w-[44px] min-h-[44px]"
|
||||
>
|
||||
<ChevronLeft className="w-6 h-6" />
|
||||
</Button>
|
||||
)}
|
||||
<h2 className="text-xl font-semibold bg-gradient-to-r from-foreground to-muted-foreground bg-clip-text text-transparent">
|
||||
{mobileView === 'menu' ? 'Settings' : menuItems.find(item => item.id === mobileView)?.label}
|
||||
</h2>
|
||||
@@ -156,14 +201,11 @@ export function SettingsDialog() {
|
||||
{mobileView === 'menu' && (
|
||||
<div className="space-y-3">
|
||||
{menuItems.map((item) => (
|
||||
<button
|
||||
key={item.id}
|
||||
onClick={() => {
|
||||
setMobileView(item.id as SettingsView)
|
||||
setActiveTab(item.id as SettingsView)
|
||||
}}
|
||||
className="w-full bg-gradient-to-br from-card to-card-hover border border-border rounded-xl p-4 hover:border-border transition-all duration-200 text-left"
|
||||
>
|
||||
<button
|
||||
key={item.id}
|
||||
onClick={() => handleOpenMobileView(item.id as SettingsView)}
|
||||
className="w-full bg-gradient-to-br from-card to-card-hover border border-border rounded-xl p-4 hover:border-border transition-all duration-200 text-left"
|
||||
>
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="p-3 bg-accent rounded-lg">
|
||||
<item.icon className="w-6 h-6 text-blue-600 dark:text-blue-400" />
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { getSessionListPath, getSwipeBackTarget } from './navigation';
|
||||
|
||||
describe('getSessionListPath', () => {
|
||||
it('returns repo path for non-assistant sessions', () => {
|
||||
expect(getSessionListPath(42, false)).toBe('/repos/42');
|
||||
expect(getSessionListPath('123', false)).toBe('/repos/123');
|
||||
});
|
||||
|
||||
it('returns assistant path with view=sessions for assistant sessions', () => {
|
||||
expect(getSessionListPath(42, true)).toBe('/repos/42/assistant?view=sessions');
|
||||
expect(getSessionListPath('123', true)).toBe('/repos/123/assistant?view=sessions');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getSwipeBackTarget', () => {
|
||||
describe('session detail routes', () => {
|
||||
it('returns repo path for normal session detail', () => {
|
||||
expect(getSwipeBackTarget('/repos/42/sessions/abc', '')).toBe('/repos/42');
|
||||
expect(getSwipeBackTarget('/repos/123/sessions/xyz-789', '')).toBe('/repos/123');
|
||||
});
|
||||
|
||||
it('returns assistant path for assistant session detail with assistant=1', () => {
|
||||
expect(getSwipeBackTarget('/repos/42/sessions/abc', '?assistant=1')).toBe(
|
||||
'/repos/42/assistant?view=sessions'
|
||||
);
|
||||
expect(getSwipeBackTarget('/repos/123/sessions/xyz', '?assistant=1')).toBe(
|
||||
'/repos/123/assistant?view=sessions'
|
||||
);
|
||||
});
|
||||
|
||||
it('returns repo path when assistant param is not 1', () => {
|
||||
expect(getSwipeBackTarget('/repos/42/sessions/abc', '?assistant=0')).toBe('/repos/42');
|
||||
expect(getSwipeBackTarget('/repos/42/sessions/abc', '?other=value')).toBe('/repos/42');
|
||||
});
|
||||
});
|
||||
|
||||
describe('assistant route', () => {
|
||||
it('returns assistant sessions path for assistant route', () => {
|
||||
expect(getSwipeBackTarget('/repos/123/assistant', '')).toBe('/repos/123/assistant?view=sessions');
|
||||
});
|
||||
|
||||
it('returns repo path for assistant session list route', () => {
|
||||
expect(getSwipeBackTarget('/repos/42/assistant', '?view=sessions')).toBe('/repos/42');
|
||||
});
|
||||
});
|
||||
|
||||
describe('repo route', () => {
|
||||
it('returns root for repo detail', () => {
|
||||
expect(getSwipeBackTarget('/repos/42', '')).toBe('/');
|
||||
expect(getSwipeBackTarget('/repos/123', '?sort=date')).toBe('/');
|
||||
});
|
||||
});
|
||||
|
||||
describe('memories route', () => {
|
||||
it('returns repo path', () => {
|
||||
expect(getSwipeBackTarget('/repos/42/memories', '')).toBe('/repos/42');
|
||||
expect(getSwipeBackTarget('/repos/123/memories', '?filter=all')).toBe('/repos/123');
|
||||
});
|
||||
});
|
||||
|
||||
describe('schedules routes', () => {
|
||||
it('returns repo path for repo schedules', () => {
|
||||
expect(getSwipeBackTarget('/repos/42/schedules', '')).toBe('/repos/42');
|
||||
});
|
||||
|
||||
it('returns root for top-level schedules', () => {
|
||||
expect(getSwipeBackTarget('/schedules', '')).toBe('/');
|
||||
});
|
||||
});
|
||||
|
||||
describe('null returns', () => {
|
||||
it('returns null for root path', () => {
|
||||
expect(getSwipeBackTarget('/', '')).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null for login', () => {
|
||||
expect(getSwipeBackTarget('/login', '')).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null for setup', () => {
|
||||
expect(getSwipeBackTarget('/setup', '')).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null for register', () => {
|
||||
expect(getSwipeBackTarget('/register', '')).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null for unknown paths', () => {
|
||||
expect(getSwipeBackTarget('/unknown/path', '')).toBeNull();
|
||||
expect(getSwipeBackTarget('/api/something', '')).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
export function getSessionListPath(repoId: string | number, isAssistantSession: boolean): string {
|
||||
const id = String(repoId);
|
||||
if (isAssistantSession) {
|
||||
return `/repos/${id}/assistant?view=sessions`;
|
||||
}
|
||||
return `/repos/${id}`;
|
||||
}
|
||||
|
||||
export function getSwipeBackTarget(pathname: string, search = ''): string | null {
|
||||
const sessionDetailRegex = /^\/repos\/([^/]+)\/sessions\/[^/]+$/;
|
||||
const match = pathname.match(sessionDetailRegex);
|
||||
|
||||
if (match) {
|
||||
const repoId = match[1];
|
||||
const params = new URLSearchParams(search);
|
||||
const isAssistant = params.get('assistant') === '1';
|
||||
return getSessionListPath(repoId, isAssistant);
|
||||
}
|
||||
|
||||
if (pathname === '/repos/:id/assistant' || /^\/repos\/[^/]+\/assistant$/.test(pathname)) {
|
||||
const repoId = pathname.split('/')[2];
|
||||
const params = new URLSearchParams(search);
|
||||
if (params.get('view') !== 'sessions') {
|
||||
return getSessionListPath(repoId, true);
|
||||
}
|
||||
return `/repos/${repoId}`;
|
||||
}
|
||||
|
||||
if (/^\/repos\/[^/]+$/.test(pathname)) {
|
||||
return '/';
|
||||
}
|
||||
|
||||
if (/^\/repos\/[^/]+\/memories$/.test(pathname)) {
|
||||
const repoId = pathname.split('/')[2];
|
||||
return `/repos/${repoId}`;
|
||||
}
|
||||
|
||||
if (/^\/repos\/[^/]+\/schedules$/.test(pathname)) {
|
||||
const repoId = pathname.split('/')[2];
|
||||
return `/repos/${repoId}`;
|
||||
}
|
||||
|
||||
if (pathname === '/schedules') {
|
||||
return '/';
|
||||
}
|
||||
|
||||
if (pathname === '/' || pathname === '/login' || pathname === '/setup' || pathname === '/register') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import { SourceControlPanel } from "@/components/source-control"
|
||||
import { ResetPermissionsDialog } from "@/components/repo/ResetPermissionsDialog"
|
||||
import { PendingActionsGroup } from "@/components/notifications/PendingActionsGroup"
|
||||
import { invalidateConfigCaches } from "@/lib/queryInvalidation"
|
||||
import { getSessionListPath } from "@/lib/navigation"
|
||||
import { SwitchConfigDialog } from "@/components/repo/SwitchConfigDialog"
|
||||
import { Loader2, Plus } from "lucide-react"
|
||||
|
||||
@@ -45,8 +46,11 @@ export function AssistantRedirect() {
|
||||
|
||||
const handleNavigate = useCallback((sessionId: string) => {
|
||||
setStatus("opening")
|
||||
if (!showSessionList) {
|
||||
window.history.replaceState(window.history.state, "", getSessionListPath(repoId, true))
|
||||
}
|
||||
navigate(`/repos/${repoId}/sessions/${sessionId}?assistant=1`)
|
||||
}, [navigate, repoId])
|
||||
}, [navigate, repoId, showSessionList])
|
||||
|
||||
const { openAssistant } = useAssistantSessionLauncher({
|
||||
repoId,
|
||||
|
||||
@@ -9,6 +9,7 @@ import { X, CornerUpLeft } from "lucide-react";
|
||||
import { ModelSelectDialog } from "@/components/model/ModelSelectDialog";
|
||||
import { Header } from "@/components/ui/header";
|
||||
import { SessionList } from "@/components/session/SessionList";
|
||||
import { getSessionListPath } from '@/lib/navigation'
|
||||
|
||||
import { FileBrowserSheet } from "@/components/file-browser/FileBrowserSheet";
|
||||
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
|
||||
@@ -297,8 +298,8 @@ export function SessionDetail() {
|
||||
}, [opcodeUrl, sessionId, repoDirectory, navigate, repoId, sessionRouteSuffix]);
|
||||
|
||||
const handleCloseSession = useCallback(() => {
|
||||
navigate(isAssistantSession ? `/repos/${repoId}/assistant?view=sessions` : `/repos/${repoId}`);
|
||||
}, [navigate, repoId, isAssistantSession]);
|
||||
navigate(getSessionListPath(repoId, isAssistantSession))
|
||||
}, [navigate, repoId, isAssistantSession])
|
||||
|
||||
const { leaderActive } = useKeyboardShortcuts({
|
||||
openModelDialog: () => setModelDialogOpen(true),
|
||||
@@ -414,7 +415,7 @@ export function SessionDetail() {
|
||||
}
|
||||
|
||||
const workspaceDisplayName = isAssistantSession ? 'Assistant' : getRepoDisplayName(repo.repoUrl, repo.localPath, repo.sourcePath);
|
||||
const sessionBackPath = isAssistantSession ? `/repos/${repoId}/assistant?view=sessions` : `/repos/${repoId}`;
|
||||
const sessionBackPath = getSessionListPath(repoId, isAssistantSession);
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
@@ -21,13 +21,13 @@ export default defineConfig(({ mode }) => {
|
||||
server: {
|
||||
host: "0.0.0.0",
|
||||
port: 5173,
|
||||
allowedHosts: ["argentina-somatopleuric-chauncey.ngrok-free.dev"],
|
||||
allowedHosts: ["test.getfit.us"],
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: `http://localhost:${backendPort}`,
|
||||
changeOrigin: true,
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': 'https://argentina-somatopleuric-chauncey.ngrok-free.dev',
|
||||
'Access-Control-Allow-Origin': 'https://test.getfit.us',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -99,7 +99,7 @@ export const ENV = {
|
||||
|
||||
AUTH: {
|
||||
SECRET: getEnvString('AUTH_SECRET', process.env.NODE_ENV === 'production' ? '' : generateDefaultSecret()),
|
||||
TRUSTED_ORIGINS: getEnvString('AUTH_TRUSTED_ORIGINS', 'http://localhost:5173,http://localhost:5003,https://argentina-somatopleuric-chauncey.ngrok-free.dev'),
|
||||
TRUSTED_ORIGINS: getEnvString('AUTH_TRUSTED_ORIGINS', 'http://localhost:5173,http://localhost:5003,https://test.getfit.us'),
|
||||
SECURE_COOKIES: getEnvBoolean('AUTH_SECURE_COOKIES', getEnvString('NODE_ENV', 'development') === 'production'),
|
||||
ADMIN_EMAIL: process.env.ADMIN_EMAIL,
|
||||
ADMIN_PASSWORD: process.env.ADMIN_PASSWORD,
|
||||
|
||||
Reference in new issue
Block a user