feat: Add directory tree tab to session files

This commit is contained in:
weishu
2026-02-06 20:18:46 +08:00
parent dc7472f1d0
commit fb9abc18d4
13 changed files with 573 additions and 32 deletions
+30
View File
@@ -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
}