File tree Expand file tree Collapse file tree
[id]/chat-sessions/[sessionId] Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ import { auth } from '@/lib/auth';
55import { getDockerService } from '@/lib/docker' ;
66import { getKosukeGitHubToken , getUserGitHubToken } from '@/lib/github/client' ;
77import { verifyProjectAccess } from '@/lib/projects' ;
8- import { sessionManager } from '@/lib/sessions' ;
98
109/**
1110 * POST /api/projects/[id]/chat-sessions/[sessionId]/pull
@@ -45,6 +44,7 @@ export async function POST(
4544
4645 // Pull session branch using SessionManager
4746 console . log ( `Pulling session branch for project ${ projectId } session ${ sessionId } ` ) ;
47+ const { sessionManager } = await import ( '@/lib/sessions' ) ;
4848 const pullResult = await sessionManager . pullSessionBranch ( projectId , sessionId , githubToken ) ;
4949
5050 if ( ! pullResult . success ) {
Original file line number Diff line number Diff line change @@ -3,9 +3,7 @@ import { auth } from '@/lib/auth';
33import { db } from '@/lib/db/drizzle' ;
44import { chatMessages , chatSessions } from '@/lib/db/schema' ;
55import { getKosukeGitHubToken , getUserGitHubToken } from '@/lib/github/client' ;
6- import { GitOperations } from '@/lib/github/git-operations' ;
76import { verifyProjectAccess } from '@/lib/projects' ;
8- import { sessionManager } from '@/lib/sessions' ;
97import type { RevertToMessageRequest } from '@/lib/types/chat' ;
108import { and , eq } from 'drizzle-orm' ;
119import { NextRequest , NextResponse } from 'next/server' ;
@@ -124,9 +122,11 @@ export async function POST(
124122 }
125123
126124 // Get session path
125+ const { sessionManager } = await import ( '@/lib/sessions' ) ;
127126 const sessionPath = sessionManager . getSessionPath ( projectId , session . sessionId ) ;
128127
129128 // Perform git revert operation (reset + force push to remote)
129+ const { GitOperations } = await import ( '@/lib/github/git-operations' ) ;
130130 const gitOps = new GitOperations ( ) ;
131131 const success = await gitOps . revertToCommit ( sessionPath , message . commitSha , githubToken ) ;
132132
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import { getDockerService } from '@/lib/docker';
1111import { deleteDir } from '@/lib/fs/operations' ;
1212import { getKosukeGitHubToken , getUserGitHubToken } from '@/lib/github/client' ;
1313import { verifyProjectAccess } from '@/lib/projects' ;
14- import { sessionManager } from '@/lib/sessions' ;
1514import { uploadFile } from '@/lib/storage' ;
1615import { and , eq } from 'drizzle-orm' ;
1716
@@ -217,6 +216,7 @@ export async function DELETE(
217216 }
218217
219218 // Step 2: Delete session files after container is stopped
219+ const { sessionManager } = await import ( '@/lib/sessions' ) ;
220220 const sessionPath = sessionManager . getSessionPath ( projectId , sessionId ) ;
221221 let filesWarning = null ;
222222
@@ -415,7 +415,8 @@ export async function POST(
415415 }
416416
417417 // Validate session directory exists
418- const sessionValid = await sessionManager . validateSessionDirectory ( projectId , chatSession . sessionId ) ;
418+ const { sessionManager : sm } = await import ( '@/lib/sessions' ) ;
419+ const sessionValid = await sm . validateSessionDirectory ( projectId , chatSession . sessionId ) ;
419420
420421 if ( ! sessionValid ) {
421422 return new Response (
Original file line number Diff line number Diff line change @@ -9,7 +9,6 @@ import { db } from '@/lib/db/drizzle';
99import { projects } from '@/lib/db/schema' ;
1010import { createRepositoryFromTemplate } from '@/lib/github' ;
1111import { getUserGitHubToken } from '@/lib/github/client' ;
12- import { GitOperations } from '@/lib/github/git-operations' ;
1312
1413// GitHub needs time to initialize repos after creation
1514const GITHUB_REPO_INIT_DELAY_MS = 10_000 ; // 10 seconds
@@ -83,6 +82,7 @@ async function createGitHubRepository(
8382 // Clone the repository locally using GitHub App token
8483 try {
8584 const { getKosukeGitHubToken } = await import ( '@/lib/github/client' ) ;
85+ const { GitOperations } = await import ( '@/lib/github/git-operations' ) ;
8686 const kosukeToken = await getKosukeGitHubToken ( ) ;
8787 const gitOps = new GitOperations ( ) ;
8888 await gitOps . cloneRepository ( repoData . url , projectId , kosukeToken ) ;
@@ -128,6 +128,7 @@ async function importGitHubRepository(
128128 throw new Error ( 'GitHub token not found' ) ;
129129 }
130130
131+ const { GitOperations } = await import ( '@/lib/github/git-operations' ) ;
131132 const gitOps = new GitOperations ( ) ;
132133 const projectPath = await gitOps . cloneRepository ( repositoryUrl , projectId , githubToken ) ;
133134
You can’t perform that action at this time.
0 commit comments