feat(ui): 添加底部状态栏和优化代码编辑器空状态

- 新增 StatusBar 组件,显示 Git 分支、诊断信息和连接状态
- 添加 Git API 端点 (GET /api/files/git) 获取分支和 dirty 状态
- 优化 CodeEditor 空状态,添加图标和引导提示
- 修复 Chat 页面高度问题 (h-screen -> h-full)
This commit is contained in:
2025-12-17 17:04:38 +08:00
parent 250d2cb4b5
commit a3ddc39771
7 changed files with 215 additions and 6 deletions
+35
View File
@@ -7,8 +7,12 @@
import { Hono } from 'hono';
import { readdir, stat, readFile, writeFile, mkdir } from 'node:fs/promises';
import { join, resolve, basename, extname, dirname } from 'node:path';
import { exec } from 'node:child_process';
import { promisify } from 'node:util';
import { searchFiles as coreSearchFiles, type FileIndexEntry } from '@ai-assistant/core';
const execAsync = promisify(exec);
const filesRouter = new Hono();
// 工作目录 (默认为当前目录)
@@ -444,4 +448,35 @@ filesRouter.put('/write', async (c) => {
}
});
// ============================================================================
// GET /api/files/git - 获取 Git 信息
// ============================================================================
filesRouter.get('/git', async (c) => {
try {
// 获取当前分支
const { stdout: branch } = await execAsync('git rev-parse --abbrev-ref HEAD', {
cwd: workingDirectory,
});
// 检查是否有未提交的更改
const { stdout: status } = await execAsync('git status --porcelain', {
cwd: workingDirectory,
});
return c.json({
success: true,
data: {
branch: branch.trim(),
dirty: status.trim().length > 0,
},
});
} catch {
// 可能不是 Git 仓库
return c.json({
success: true,
data: null,
});
}
});
export { filesRouter };