mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-08 07:17:39 +00:00
feat: Add directory tree tab to session files
This commit is contained in:
@@ -9,6 +9,10 @@ const fileSearchSchema = z.object({
|
||||
limit: z.coerce.number().int().min(1).max(500).optional()
|
||||
})
|
||||
|
||||
const directorySchema = z.object({
|
||||
path: z.string().optional()
|
||||
})
|
||||
|
||||
const filePathSchema = z.object({
|
||||
path: z.string().min(1)
|
||||
})
|
||||
@@ -180,5 +184,31 @@ export function createGitRoutes(getSyncEngine: () => SyncEngine | null): Hono<We
|
||||
return c.json({ success: true, files })
|
||||
})
|
||||
|
||||
app.get('/sessions/:id/directory', async (c) => {
|
||||
const engine = requireSyncEngine(c, getSyncEngine)
|
||||
if (engine instanceof Response) {
|
||||
return engine
|
||||
}
|
||||
|
||||
const sessionResult = requireSessionFromParam(c, engine)
|
||||
if (sessionResult instanceof Response) {
|
||||
return sessionResult
|
||||
}
|
||||
|
||||
const sessionPath = sessionResult.session.metadata?.path
|
||||
if (!sessionPath) {
|
||||
return c.json({ success: false, error: 'Session path not available' })
|
||||
}
|
||||
|
||||
const parsed = directorySchema.safeParse(c.req.query())
|
||||
if (!parsed.success) {
|
||||
return c.json({ error: 'Invalid query' }, 400)
|
||||
}
|
||||
|
||||
const path = parsed.data.path ?? ''
|
||||
const result = await runRpc(() => engine.listDirectory(sessionResult.sessionId, path))
|
||||
return c.json(result)
|
||||
})
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user