diff --git a/frontend/src/lib/navigation.test.ts b/frontend/src/lib/navigation.test.ts
new file mode 100644
index 00000000..5fa461fa
--- /dev/null
+++ b/frontend/src/lib/navigation.test.ts
@@ -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();
+ });
+ });
+});
diff --git a/frontend/src/lib/navigation.ts b/frontend/src/lib/navigation.ts
new file mode 100644
index 00000000..c50f1815
--- /dev/null
+++ b/frontend/src/lib/navigation.ts
@@ -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;
+}
diff --git a/frontend/src/pages/AssistantRedirect.tsx b/frontend/src/pages/AssistantRedirect.tsx
index a14a9788..b009f86b 100644
--- a/frontend/src/pages/AssistantRedirect.tsx
+++ b/frontend/src/pages/AssistantRedirect.tsx
@@ -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,
diff --git a/frontend/src/pages/SessionDetail.tsx b/frontend/src/pages/SessionDetail.tsx
index 4c3bd547..df831abc 100644
--- a/frontend/src/pages/SessionDetail.tsx
+++ b/frontend/src/pages/SessionDetail.tsx
@@ -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 (
{
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',
},
},
},
diff --git a/shared/src/config/env.ts b/shared/src/config/env.ts
index 371fa23b..9e903399 100644
--- a/shared/src/config/env.ts
+++ b/shared/src/config/env.ts
@@ -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,