Skip to content

feat: 完善个人工作区文件管理#668

Merged
xerrors merged 16 commits intomainfrom
feat/workspace
May 4, 2026
Merged

feat: 完善个人工作区文件管理#668
xerrors merged 16 commits intomainfrom
feat/workspace

Conversation

@xerrors
Copy link
Copy Markdown
Owner

@xerrors xerrors commented Apr 30, 2026

变更描述

完善个人工作区能力:新增后端工作区文件服务与路由,补充前端工作区视图、侧边栏、文件列表、预览面板和 API 封装,并优化工作区路径选择与面包屑导航体验。

变更类型

  • 新功能
  • 文档更新

测试

  • 已在 Docker 环境测试
  • 相关功能正常工作

相关日志或者截图

image

说明

WIP PR,用于提前对齐个人工作区文件管理相关改动;合并前仍需补充 Docker 环境测试、功能验证与必要的 lint 检查。


💡 提示: 提交前可以运行 make lintmake format 检查代码规范

@gustinzhang
Copy link
Copy Markdown

文件解析失败,挨个点击解析效率比较低。请问有考虑增加一键重新解析的功能吗?
知识图谱的展示有计划增加3D展示的功能吗?

@xerrors xerrors marked this pull request as ready for review May 3, 2026 23:43
Copilot AI review requested due to automatic review settings May 3, 2026 23:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

本 PR(WIP)完善“个人工作区文件管理”能力:新增用户级 workspace 后端 API 与路由,并在前端增加独立的“工作区”页面用于浏览/预览/编辑/上传/下载/删除文件,同时将工作区 agents/AGENTS.md 内容注入到 agent 的 system prompt。

Changes:

  • 新增 workspace 后端服务与路由:目录树、文件读取/写入、上传、下载、删除,并初始化默认 agents/AGENTS.md
  • 新增前端工作区页面与组件:侧边栏、文件列表、预览/编辑面板、API 封装,并接入主导航与路由
  • Agent 输入上下文增强:读取并合并 agents/AGENTS.md 到 system prompt(带最大字节数与截断提示)

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
web/src/views/WorkspaceView.vue 新增工作区主页面:目录加载、预览/编辑、上传下载删除、内联预览布局与拖拽分栏
web/src/views/DataBaseView.vue 轻量格式调整(标题/注释缩进)
web/src/router/index.js 新增 /workspace 路由并挂载到 AppLayout
web/src/layouts/AppLayout.vue 主导航新增“工作区”入口
web/src/components/workspace/WorkspaceSidebar.vue 新增工作区侧边栏:个人工作区、快速访问、知识库占位、共享空间占位
web/src/components/workspace/WorkspacePreviewPane.vue 新增内联预览面板封装(复用 AgentFilePreview
web/src/components/workspace/WorkspaceFileList.vue 新增文件列表:面包屑、表格、批量选择/删除、下载入口
web/src/components/shared/InfoCard.vue 模板排版/格式整理
web/src/components/extensions/SkillDetailView.vue 移除未使用的 computed(格式/清理)
web/src/components/extensions/McpDetailView.vue 样式空行清理
web/src/components/ShareConfigForm.vue 样式格式化(transition 多行)
web/src/components/ConversationNavSection.vue 样式格式化(linear-gradient 多行)
web/src/components/AgentPanel.vue 文件系统面板交互调整:默认展开目录、预览关闭按钮变体、移除上传/新建等工具栏能力
web/src/components/AgentInputArea.vue “文件”按钮图标替换(FolderCode → FolderKanban)
web/src/components/AgentFilePreview.vue 预览组件增强:可编辑模式(md/txt)、保存/取消、关闭按钮变体与无障碍属性
web/src/assets/css/main.css 调整 .layout-container 样式(移除全局 padding)
web/src/apis/workspace_api.js 新增前端 workspace API 封装(tree/file/save/delete/upload/download)
docs/develop-guides/roadmap.md 路线图记录:工作区能力与扩展管理界面重构等
backend/test/unit/services/test_workspace_service.py 新增 workspace_service 单元测试(默认文件、路径安全、读写限制等)
backend/test/unit/services/test_chat_service_sync.py 更新/新增测试:注入 AGENTS.md prompt、补齐仓库依赖 monkeypatch
backend/server/routers/workspace_router.py 新增 workspace 路由:tree/file CRUD/upload/download
backend/server/routers/init.py 注册 workspace router 到 /api/workspace/*
backend/package/yuxi/utils/paths.py 增加 workspace agents 常量(agents 目录与 AGENTS.md 文件名)
backend/package/yuxi/services/workspace_service.py 新增 workspace 核心服务:路径解析防穿越、列表、读写、上传、下载、删除
backend/package/yuxi/services/chat_service.py 构建 agent 输入上下文时合并 agents/AGENTS.md 到 system prompt(限制 64KB)
backend/package/yuxi/agents/backends/sandbox/paths.py 新增 default workspace 文件初始化(ensure_workspace_default_files)并在 ensure_thread_dirs 中调用
backend/package/yuxi/agents/backends/sandbox/init.py 导出新增的 sandbox paths 工具函数
CLAUDE.md 更新开发准则文档内容(更细化的行为/改动边界建议)
AGENTS.md 补充代码组织建议(避免过度拆分 helper 等)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +229 to +242
async def upload_workspace_file(*, parent_path: str, file: UploadFile, current_user: User) -> dict:
root = _workspace_root(current_user)
file_name = _validate_child_name(Path(file.filename or "").name, field_name="文件名")
parent = _resolve_parent_directory(current_user, parent_path)
target = _resolve_new_child(root, parent, file_name)
created_file = False
upload_completed = False

try:
async with aiofiles.open(target, "xb") as buffer:
created_file = True
while chunk := await file.read(1024 * 1024):
await buffer.write(chunk)
upload_completed = True
Comment on lines +235 to +241
if (previewType === 'image' || previewType === 'pdf') {
const response = await downloadWorkspaceFile(entry.path)
const blob = await response.blob()
revokePreviewObjectUrl()
previewObjectUrl.value = URL.createObjectURL(blob)
file.previewUrl = previewObjectUrl.value
}
Comment on lines +559 to +563
const resizePreview = (event) => {
if (!workspaceMainRef.value || resizePointerId === null) return
const rect = workspaceMainRef.value.getBoundingClientRect()
const relativeX = event.clientX - rect.left
const nextPreviewPercent = Math.round(((rect.width - relativeX) / rect.width) * 100)
Comment on lines +172 to +176
const breadcrumbItems = computed(() => {
const normalizedPath = props.currentPath || '/'
if (normalizedPath === '/') {
return [{ name: '工作区', path: '/' }]
}
Comment thread web/src/assets/css/main.css
@xerrors xerrors changed the title WIP: 完善个人工作区文件管理 feat: 完善个人工作区文件管理 May 4, 2026
@xerrors xerrors merged commit 6f46089 into main May 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants