Compare commits

..
4 Commits
588 changed files with 20517 additions and 74697 deletions

No files matched your search

+47 -5
View File
@@ -95,14 +95,10 @@ offline-backend-20260512/backend/packages/harness/deerflow/skills/*
hermes-agent-main/
.gitignore
offline-backend-20260512/backend/tests/*
!offline-backend-20260512/backend/tests/test_goview_projects.py
!offline-backend-20260512/backend/tests/test_goview_templates.py
!offline-backend-20260512/backend/tests/test_goview_assets.py
!offline-backend-20260512/backend/tests/test_skill_versioning.py
!offline-backend-20260512/backend/tests/test_large_file_safety.py
!offline-backend-20260512/backend/tests/test_account_authentication.py
# HTML 结构化模板(no.1)引擎/存储/路由回归
!offline-backend-20260512/backend/tests/test_structured_templates.py
!offline-backend-20260512/backend/tests/test_agent_skill_migration.py
!offline-backend-20260512/backend/tests/test_html_runtime_addresses.py
!offline-backend-20260512/backend/tests/test_app_identity.py
!offline-backend-20260512/backend/tests/test_roundtable_room_limit.py
@@ -141,6 +137,9 @@ offline-backend-20260512/backend/tests/*
!offline-backend-20260512/backend/tests/test_gongwen_documents.py
# Keep the openGauss URL/dialect/schema compatibility regression coverage versioned.
!offline-backend-20260512/backend/tests/test_gauss_database.py
!offline-backend-20260512/backend/tests/test_gauss_mysql_compat.py
!offline-backend-20260512/backend/tests/test_chat_history_migration_seed.py
!offline-backend-20260512/backend/tests/test_gauss_data_adaptation_seed.py
!offline-backend-20260512/backend/tests/test_llmwiki_weknora.py
!offline-backend-20260512/backend/tests/test_llmwiki_knowledge_management.py
!offline-backend-20260512/backend/tests/test_llmwiki_smart_reasoning.py
@@ -270,8 +269,51 @@ docs/backups
offline-backend-20260512/backend/skills/*
!offline-backend-20260512/backend/skills/public/
offline-backend-20260512/backend/skills/public/*
!offline-backend-20260512/backend/skills/public/_shared/
!offline-backend-20260512/backend/skills/public/_shared/**
!offline-backend-20260512/backend/skills/public/analysis-mindmap/
!offline-backend-20260512/backend/skills/public/analysis-mindmap/SKILL.md
!offline-backend-20260512/backend/skills/public/facebook-page-generator/
!offline-backend-20260512/backend/skills/public/facebook-page-generator/**
!offline-backend-20260512/backend/tests/test_facebook_page_generator_skill.py
!offline-backend-20260512/backend/skills/public/x-page-generator/
!offline-backend-20260512/backend/skills/public/x-page-generator/**
!offline-backend-20260512/backend/tests/test_x_page_generator_skill.py
!offline-backend-20260512/backend/skills/public/tiktok-page-generator/
!offline-backend-20260512/backend/skills/public/tiktok-page-generator/**
!offline-backend-20260512/backend/tests/test_tiktok_page_generator_skill.py
!offline-backend-20260512/backend/skills/public/youtube-page-generator/
!offline-backend-20260512/backend/skills/public/youtube-page-generator/**
!offline-backend-20260512/backend/tests/test_youtube_page_generator_skill.py
!offline-backend-20260512/backend/skills/public/threads-page-generator/
!offline-backend-20260512/backend/skills/public/threads-page-generator/**
!offline-backend-20260512/backend/tests/test_threads_page_generator_skill.py
!offline-backend-20260512/backend/skills/public/cnn-page-generator/
!offline-backend-20260512/backend/skills/public/cnn-page-generator/**
!offline-backend-20260512/backend/tests/test_cnn_page_generator_skill.py
!offline-backend-20260512/backend/skills/public/bbc-page-generator/
!offline-backend-20260512/backend/skills/public/bbc-page-generator/**
!offline-backend-20260512/backend/tests/test_bbc_page_generator_skill.py
!offline-backend-20260512/backend/skills/public/xinhua-page-generator/
!offline-backend-20260512/backend/skills/public/xinhua-page-generator/**
!offline-backend-20260512/backend/tests/test_xinhua_page_generator_skill.py
!offline-backend-20260512/backend/skills/public/white-house-page-generator/
!offline-backend-20260512/backend/skills/public/white-house-page-generator/**
!offline-backend-20260512/backend/tests/test_white_house_page_generator_skill.py
!offline-backend-20260512/backend/skills/public/manila-times-page-generator/
!offline-backend-20260512/backend/skills/public/manila-times-page-generator/**
!offline-backend-20260512/backend/tests/test_manila_times_page_generator_skill.py
!offline-backend-20260512/backend/skills/public/gma-news-page-generator/
!offline-backend-20260512/backend/skills/public/gma-news-page-generator/**
!offline-backend-20260512/backend/tests/test_gma_news_page_generator_skill.py
!offline-backend-20260512/backend/skills/public/yahoo-japan-page-generator/
!offline-backend-20260512/backend/skills/public/yahoo-japan-page-generator/**
!offline-backend-20260512/backend/tests/test_yahoo_japan_page_generator_skill.py
!offline-backend-20260512/backend/skills/public/yomiuri-news-page-generator/
!offline-backend-20260512/backend/skills/public/yomiuri-news-page-generator/**
!offline-backend-20260512/backend/tests/test_yomiuri_news_page_generator_skill.py
!offline-backend-20260512/backend/tests/test_fast_page_generator_specs.py
!offline-backend-20260512/backend/tests/test_sync_builtin_skills.py
# Built-in skill-creator ported from bytedance/deer-flow (product source too).
!offline-backend-20260512/backend/skills/public/skill-creator/
!offline-backend-20260512/backend/skills/public/skill-creator/**
@@ -1,47 +0,0 @@
## 背景
配置管理页(`/page/strategy/custom-deeplink-entry` 的上游配置工具)允许用户自定义任意多个业务类型,每个类型绑定一个执行智能体,深链落地到 `AgentChatPage` 的 landing 态。目前所有智能体的落地页完全一样(红色调 BotIcon 头像 + 「Hi,我是XX」+ 描述 + 输入框),用户从不同类型进来看到同一张脸,会觉得奇怪。
类型数量不定、由用户自由创建,人工逐个挑样式不可扩展。方案:**预设 6 套落地页风格 + 按智能体 id 确定性自动分配**——同一智能体永远同一套风格(深链入口、智能体管理「对话」按钮进入都一致),不同智能体尽量落在不同套;零配置、零后端改动。
纯前端改动,只用显式 hex/rgba 色值(遵循 globals.css:1840 注释的旧 Chrome 兼容铁律,不用 color-mix)。
## 实施步骤
### 1. 新增 `frontend-web/src/core/agents/appearance.ts`
- FNV-1a 字符串 hash(项目里无现成工具);
- `AGENT_LANDING_STYLE_COUNT = 6`;
- `agentLandingStyleIndex(id: string): number` = hash % 6(稳定,id 不变风格不变);
- 每套风格对应的头像图标表(lucide:Bot / Sparkles / Brain / Compass / MessagesSquare / Workflow),导出 `agentLandingStyleIcon(index)`。
### 2. `frontend-web/src/pages/AgentChatPage.tsx`
- 在 `<main>`(~1471 行)上加 `data-agent-style={agentLandingStyleIndex(agent_id)}`,同时内联覆盖 `--primary: var(--agent-accent)`(CSS 里按风格定义)——让页头智能体胶囊图标、发送按钮等**纯色** primary 元素自动跟随风格(纯色工具类不依赖 color-mix,旧 Chrome 安全);
- landing 分支(~1635 行)里加一个绝对定位、`pointer-events-none` 的氛围光斑 div(`.agent-style-glow`),按风格给页面顶部一层淡淡的对应色径向渐变,增强「换了个地方」的观感。
### 3. `frontend-web/src/components/workspace/agent-welcome.tsx`
- 头像图标从写死 `BotIcon` 改为按风格轮换(`agentLandingStyleIcon(index)`);
- 给问候语标题加 `agent-welcome-name` class 钩子(供 CSS 做渐变字等风格差异);
- `.agent-avatar` 结构不动。
### 4. `frontend-web/src/styles/globals.css`
- `.gemini-gradient-border::before` 的 conic-gradient 改为 `var(--agent-gemini-gradient, <现有四色默认>)`(默认值 = 现状,不影响其他页面);
- 文件末尾新增一个非 layer 块「智能体专属落地页风格」,6 套风格 × 明/暗两版(沿用 `.dark` 前缀模式),每套定义:
- `--agent-accent`(主色)、`--agent-accent-soft`(浅底)、`--agent-accent-border`(描边 rgba)、`--agent-gemini-gradient`(输入框专属旋转描边渐变);
- `[data-agent-style="N"] .agent-avatar` 的底色/图标色/内描边(显式 hex,放在现有 `.agent-avatar` 主题块之后,非 layer 规则优先级高于工具类);
- `[data-agent-style="N"] .agent-style-glow` 的径向渐变;
- 2-3 套风格给 `.agent-welcome-name` 加渐变字/下划线装饰等排版差异,头像圆角形状在圆角方/圆形间轮换,让 6 套不只是换色。
- 顺带处理 `input-box.tsx:754` 唯一的透明度主色用法(`border-primary/20 bg-primary/5 hover:bg-primary/10` 的 promptPrefix 横幅)→ 改用 `var(--agent-accent-border/-soft)` 显式变量 + 默认兜底,旧 Chrome 下不会退化成实色块。
### 5. 单测(轻量)
- `frontend-web/src/core/agents/appearance.test.ts`:hash 稳定性(同一 id 结果恒定)、索引落在 0–5、不同 id 有分散性;沿用 vitest(参考 `core/settings/composer-scope.test.ts` 的位置与写法)。
## 明确不做 / 后续可选
- 不改后端、不加配置字段。若以后想让管理员在配置管理页手动指定某类型的风格,可在此基础上把「风格号」存进业务映射配置、路由透传覆盖 hash 值即可(本次不做)。
- 多个类型绑定同一智能体时共享同一套风格(这是智能体的身份,属预期行为);确实需要区分可创建不同智能体。
- 会话开始后的消息流保持全局主题不变,只有页头智能体胶囊保留专属色 + landing 态整页风格化。
## 验证
1. `cd frontend-web && pnpm typecheck` + `pnpm test:composer-session` 同款方式跑新增单测(或 `pnpm test` 过滤 appearance)。
2. `pnpm dev` 起前端,打开 `http://localhost:5173/#/page/strategy/custom-deeplink-entry?goPath=测试`,确认落到绑定智能体且 landing 风格与全局红色主题不同;
3. 在智能体管理临时建 2-3 个测试智能体分别进入问答页,确认不同 id 落到不同风格、同一智能体刷新/换入口风格恒定;
4. 切深色主题复查 6 套风格的暗色变体;发送一条消息进入会话态,确认消息流恢复全局主题、页头胶囊保留专属色、输入框描边过渡正常。
@@ -1,366 +0,0 @@
# GoView 第一阶段离线项目模板与发布实施方案
## 1. 阶段目标
第一阶段只解决 GoView 的离线可用和内容管理闭环。
用户在保留原有画布编辑器的前提下,能够完成:
1. 我的项目:新建、编辑、重命名、删除、保存、预览和发布;
2. 我的模板:把自己的项目保存为模板、查看、编辑模板信息和用模板创建项目;
3. 模板市场:查看内置模板、用模板创建个人项目;
4. 离线部署:项目 JSON、缩略图、模板封面和地图瓦片均由本地部署提供;
5. 发布链接:项目发布后获得可直接访问的只读预览链接;
6. 地图瓦片背景:在原有画布的组件库中增加一张可离线使用的 Leaflet 瓦片地图背景组件。
现有画布的拖拽、缩放、分组、样式、数据面板和事件面板不在本阶段改造范围内。
### 原生数据面板完整保留
截图中的“数据”标签页属于每个 GoView 组件自身的画布配置,不属于项目、模板或发布后台。第一阶段必须完整保留:
- 静态数据和 JSON 在线编辑;
- JSON 或 TXT 导入、下载;
- 动态请求;
- 公共接口和数据池;
- 数据字段映射及匹配状态;
- 组件原有的刷新与轮询配置。
项目保存接口把整份 ChartEditStorage 作为 content_json 原样保存,其中已包含组件的 request、filter、option.dataset、字段映射和其它数据配置。模板创建和“使用模板”也只深拷贝同一份 JSON,不能删除、重置或改写这些数据配置。
后续如要增加新的数据来源,只能在这个数据面板中新增选项或适配器,不能替换、收窄或移除现有的静态数据、动态请求和公共接口能力。
## 2. 已核实的 GoView 基线
前端基线使用 H:\code\go-view 的官方 origin/master-fetch 分支。
| 功能 | 开源现状 | 第一阶段处理 |
| --- | --- | --- |
| 我的项目 | 已有项目卡片、创建、保存、删除、发布和预览请求 | 本地 Gateway 实现兼容接口 |
| 我的模板 | 页面仅显示“暂时还没有东西呢” | 新增模板列表和模板操作 |
| 模板市场 | 页面只展示 GoView Pro 宣传图和外链 | 替换为本地模板卡片列表 |
| 新建弹窗模板入口 | “我的模板”和“模板市场”按钮处于禁用状态 | 启用并跳转到可用模板页 |
| 项目发布 | 已有 state 字段和发布按钮 | 保存状态,并生成公开预览链接 |
| 地图组件 | 有 ECharts 和高德地图组件,无离线 XYZ 瓦片背景组件 | 新增 Leaflet 瓦片背景组件 |
因此,项目画布本身不需要重写;模板中心不是“补一个后端开关”即可完成,必须同时补前端页面和接口。
## 3. 总体结构
~~~text
GoView master-fetch 前端
|
| /api/goview/*
v
DeerFlow Gateway
|
+-- 项目和项目内容
+-- 个人模板和市场模板
+-- 本地图片与缩略图
+-- 已发布项目的只读数据
+-- 离线地图瓦片
~~~
GoView 保持为独立的 Vue 前端。其他现有前端工程不参与第一阶段改造。
## 4. 接口兼容策略
### 4.1 保留现有项目接口前缀
GoView master-fetch 的请求前缀是 /api/goview,项目页和画布保存逻辑已经依赖下面的路径。Gateway 应优先兼容这些接口,避免改动画布同步逻辑。
| 方法和路径 | 请求 | 响应用途 |
| --- | --- | --- |
| GET /api/goview/project/list | page、limit | 我的项目卡片和分页 |
| POST /api/goview/project/create | JSON:projectName、remarks、indexImage | 新建项目,返回 id |
| GET /api/goview/project/getData | projectId | 编辑器读取项目元信息和 content |
| POST /api/goview/project/save/data | 表单:projectId、content | 自动保存画布 JSON |
| POST /api/goview/project/edit | JSON:id 和可编辑元信息 | 修改名称、说明或封面 |
| POST /api/goview/project/rename | JSON:id、projectName | 快速重命名 |
| DELETE /api/goview/project/delete | ids | 删除自己的项目 |
| PUT /api/goview/project/publish | JSON:id、state | 发布或取消发布 |
| POST /api/goview/project/upload | multipart:object | 上传本地缩略图或图片 |
响应保持 GoView 的 ResultEnum 约定:
~~~json
{
"code": 200,
"msg": "获取成功",
"data": {},
"count": 0
}
~~~
项目列表的 count 与 data 同级,保持现有项目页的读取方式。项目详情使用现有字段 id、projectName、state、createTime、indexImage、createUserId、remarks 和 content。
### 4.2 新增模板接口
模板页面当前没有可复用接口,因此新增清晰的模板 API,不伪装成项目接口。
| 方法和路径 | 权限 | 用途 |
| --- | --- | --- |
| GET /api/goview/templates/mine | 登录用户 | 我的模板列表和分页 |
| POST /api/goview/templates/from-project | 项目所有者 | 从一个项目创建个人模板 |
| GET /api/goview/templates/{id} | 模板所有者或市场可见 | 读取模板详情与 canvas JSON |
| PUT /api/goview/templates/{id} | 模板所有者 | 修改名称、说明、封面 |
| DELETE /api/goview/templates/{id} | 模板所有者 | 删除个人模板 |
| GET /api/goview/templates/market | 登录用户或公开读取 | 模板市场列表 |
| POST /api/goview/templates/{id}/create-project | 登录用户 | 深拷贝模板为新项目并返回项目 id |
| POST /api/goview/templates/admin/seed | 管理员或启动期内部调用 | 导入内置模板,不在普通 UI 展示 |
市场模板只能“使用并创建项目”,不能直接编辑模板内容。个人模板只能由模板创建者编辑或删除。管理员维护市场模板不需要引入租户、空间和成员模型。
### 4.3 已发布项目访问链接
编辑器继续使用:
~~~text
/#/chart/home/{projectId}
~~~
发布后的用户访问链接使用原有预览路由:
~~~text
/#/chart/preview/{projectId}
~~~
为了让链接在没有登录态时可直接访问,新增只读接口:
~~~text
GET /api/goview/project/published/{projectId}
~~~
该接口仅当项目 state 为 1 时返回项目元信息和 content;未发布、已取消发布或不存在的项目统一返回 404。编辑器接口 getData 保持登录和所有者校验,不能为了预览方便而开放草稿。
预览页面启动时根据路由判断:
1. 编辑预览或已登录所有者预览,读取 getData;
2. 直接打开已发布链接,读取 published/{projectId};
3. published 接口返回 404 时显示“项目未发布或不存在”页面。
发布接口成功后返回 relative_view_url,例如 /#/chart/preview/id_38xq54e9uoo000。前端用当前站点 origin 拼成完整链接并提供“复制链接”按钮,不在后端写死域名、端口或部署前缀。
## 5. 持久化设计
第一阶段只需要项目、项目内容、模板和本地资源存储。
### 5.1 goview_projects
| 字段 | 说明 |
| --- | --- |
| id | 字符串主键,兼容 GoView 的 id 路由参数 |
| project_name | 项目名 |
| remarks | 说明 |
| state | -1 未发布,1 已发布 |
| index_image | 缩略图资源地址 |
| owner_id | 当前登录用户 ID |
| created_at / updated_at | 创建和更新时间 |
### 5.2 goview_project_contents
| 字段 | 说明 |
| --- | --- |
| project_id | 一对一关联项目,唯一 |
| content_json | GoView ChartEditStorage 的完整 JSON,使用 PortableLongText |
| updated_at | 最后保存时间 |
列表查询不读取 content_json,只有编辑器和预览页读取,避免大画布 JSON 进入列表响应。
### 5.3 goview_templates
| 字段 | 说明 |
| --- | --- |
| id | 模板主键 |
| name / description | 模板名称和描述 |
| cover_image | 模板封面资源地址 |
| content_json | 可直接复制为项目内容的 GoView JSON |
| owner_id | 个人模板的创建者;内置市场模板可为空 |
| scope | personal 或 market |
| is_builtin | 内置模板标记;内置模板不可由普通用户删除 |
| sort_order | 市场排序 |
| created_at / updated_at | 创建和更新时间 |
### 5.4 本地资源目录
上传的图片、缩略图和模板封面保存到运行时可持久化目录,例如:
~~~text
{runtime_dir}/goview-assets/
~~~
上传服务校验文件类型、大小、文件名和真实图片格式,使用服务端生成的随机文件名,禁止保留用户路径。资源通过 Gateway 的受控 GET 接口提供,不依赖 OSS、CDN 或公网地址。
离线发版的镜像、离线依赖和部署脚本与业务源码分开维护;业务源码仓库只保留接口、数据库迁移、内置模板定义和前端源码。
## 6. 身份与权限
不新建 GoView 用户系统。项目和模板直接复用平台现有登录态。
| 场景 | 规则 |
| --- | --- |
| 我的项目 | 只列出 owner_id 为当前用户的项目 |
| 我的模板 | 只列出 owner_id 为当前用户且 scope 为 personal 的模板 |
| 模板市场 | 所有登录用户可读 market 模板 |
| 创建项目 | 当前用户成为 owner |
| 发布、保存、删除、重命名 | 仅项目 owner;无鉴权单用户部署按单管理空间规则处理 |
| 维护市场模板 | 管理员 |
| 发布项目预览 | 无需登录,但只读且仅返回已发布 content |
GoView 现有 axios 登录逻辑依赖自己的 GO_SYSTEM_STORE 和 /login。第一阶段替换为平台现有 Bearer Token 与 Cookie 逻辑;这个改动只影响网络层和路由守卫,不改编辑器画布。
## 7. 前端最小改造清单
### 7.1 保持不动的部分
- /chart/home/:id 的画布、左侧组件库、右侧样式/动画/数据/事件面板;
- ChartEditStorage 的序列化结构;
- useSync 中动态注册组件、恢复画布和自动保存机制;
- 现有项目卡片布局和发布状态展示。
### 7.2 项目页
项目页继续调用现有 project.api.ts。适配 axios 的平台鉴权后,项目列表、新建、保存、删除、发布和缩略图上传可直接对接 Gateway。
项目卡片新增两个轻量操作:
1. 复制发布链接:仅已发布时显示;
2. 保存为模板:把当前项目的最新 content 创建为个人模板。
### 7.3 我的模板
替换 src/views/project/mtTemplate/index.vue 的空状态页。
页面提供模板卡片列表、分页、预览、编辑名称/描述/封面、删除和“使用模板”按钮。点击使用模板调用 create-project,成功后直接跳转 /chart/home/{newProjectId}。
新建弹窗中“我的模板”按钮解除禁用,跳转到该页面或直接打开模板选择抽屉。
### 7.4 模板市场
替换 src/views/project/templateMarket/index.vue 的 Pro 宣传图和外链。
页面读取 market 接口,以与项目卡片相同的视觉语言展示内置模板。市场模板至少准备:
1. 深色通用数据驾驶舱;
2. 地图基础概览大屏;
3. 指标总览与趋势分析大屏;
4. 时间轴与进度概览大屏。
模板内容作为版本化的内置 seed 文件随 Gateway 发布。首次启动只插入不存在的内置模板,后续升级不覆盖管理员已修改或新增的模板。
新建弹窗中“模板市场”按钮解除禁用,跳转到该页面或打开市场模板选择抽屉。
### 7.5 公开预览
预览页保留现有 /chart/preview/:id 和原始画布渲染。只修改加载项目数据的入口:未登录时走 published 接口,已登录编辑场景继续走 getData。预览页不显示编辑、保存、删除、模板和管理员操作。
## 8. 离线地图瓦片背景组件
### 8.1 目标
新增一个“地图瓦片背景”组件。第一阶段只提供离线底图和通用显示配置。
### 8.2 实现方式
在 GoView 组件库新增 Leaflet 组件:
~~~text
src/packages/components/Business/Maps/LeafletTileBackground/
config.ts
index.vue
config.vue
~~~
依赖使用 Leaflet 1.9,并在 GoView 入口加载 Leaflet CSS。组件作为普通 GoView 图层,可调整位置、尺寸、层级、边框、透明度和隐藏状态。
配置面板只暴露:
- 底图样式:默认离线底图、管理员配置的其他离线底图;
- 初始中心点和缩放级别;
- 最小和最大缩放;
- 是否允许鼠标缩放和拖拽;
- 明暗遮罩、透明度和灰度效果。
不允许用户输入任意瓦片 URL,避免离线部署失效、内网地址泄漏和任意外部请求。
### 8.3 瓦片服务
Gateway 新增受控瓦片路由:
~~~text
GET /api/goview/map-tiles/{style}/{z}/{x}/{y}.png
~~~
瓦片数据位于部署的可持久化目录或只读地图资源卷。路由严格校验 style、z、x、y 范围并阻止路径穿越。
第一期配置一个默认样式,对接部署时挂载的 XYZ 瓦片目录。GoView 组件始终只使用 Gateway 的受控地址。
编辑器内默认关闭地图拖拽,避免和画布选择、移动组件冲突;预览页可按组件配置开启交互。组件卸载时必须调用 map.remove(),避免切换项目时保留 DOM、瓦片和事件监听。
## 9. 后端代码落点
建议新增:
~~~text
offline-backend-20260512/backend/
app/gateway/routers/goview_projects.py
app/gateway/routers/goview_templates.py
app/gateway/routers/goview_assets.py
app/gateway/routers/goview_map_tiles.py
packages/harness/deerflow/persistence/goview/
__init__.py
models.py
project_store.py
template_store.py
packages/harness/deerflow/persistence/migrations/versions/
YYYYMMDD_NN_goview_projects_and_templates.py
app/gateway/goview_builtin_templates.py
tests/test_goview_projects.py
tests/test_goview_templates.py
tests/test_goview_assets.py
~~~
并在 app/gateway/deps.py 创建 Store,在 app/gateway/app.py 注册路由,在 persistence/models/__init__.py 导入 ORM 模型。Harness 只保存数据和仓储,HTTP 表单解析、上传、鉴权、公开预览和瓦片文件响应只放在 app/gateway。
## 10. 实施顺序
### A. 项目闭环
1. 实现 goview_projects 和 goview_project_contents;
2. 兼容 project/list、create、getData、save/data、edit、rename、delete、publish、upload;
3. 替换 GoView axios 登录逻辑为 DeerFlow 登录态;
4. 实现 published 接口和复制发布链接。
验收:用户在当前画布编辑页保存,回到“全部项目”可以看到项目;发布后,无登录浏览器可通过 /#/chart/preview/{id} 查看同一画布。
### B. 模板闭环
1. 实现模板表和模板接口;
2. 完成“保存为模板”和“我的模板”页面;
3. 替换模板市场宣传页;
4. 内置至少四套离线模板;
5. 从任意模板创建独立项目。
验收:模板市场的模板不会被用户编辑;点击“使用模板”后生成新项目,修改新项目不会改变模板或其他用户的项目。
### C. 地图瓦片背景
1. 接入 Leaflet;
2. 实现受控瓦片路由和默认离线瓦片配置;
3. 新增 LeafletTileBackground 组件;
4. 把地图背景加入至少一套内置模板。
验收:断开公网后,地图背景仍能显示;编辑器与预览页都不会因地图组件引发拖拽冲突或内存泄漏。
## 11. 测试清单
1. 项目列表只返回当前用户的项目;
2. 项目所有者外的登录用户不能读取、保存、删除或发布草稿;
3. 已发布预览只返回 state 为 1 的项目;
4. 取消发布后原公开链接返回 404;
5. 项目 content 为大 JSON 时能完整保存和恢复;
6. 模板创建项目为深拷贝,模板 content 不被后续项目保存覆盖;
7. 内置模板重复启动不重复插入,不覆盖已存在记录;
8. 上传拒绝非图片、超大文件和路径穿越文件名;
9. 瓦片路由拒绝非法 style、缩放层级和路径穿越;
10. 无公网网络下,项目缩略图、模板封面和默认瓦片可正常加载。
+1 -1
View File
@@ -889,7 +889,7 @@ Step 2(chat 步骤)
| `@tanstack/react-query` | - | 服务端状态缓存 |
| `@langchain/langgraph-sdk` | - | LangGraph WebSocket 连接 |
| `next-themes` | - | 主题管理 |
| `tdesign-react` | - | 全局消息、确认对话框与输入提示 |
| `sonner` | - | Toast 通知 |
| `lucide-react` | - | 图标库 |
| `tailwindcss` | - | CSS 框架 |
| `rehype` 系列 | - | Markdown 渲染 |
@@ -290,7 +290,7 @@ chain 模式的 Step 2 init **完全复用** `initMultiAgent`:`agentNames = ch
**目标**:能创建/编辑/保存/删除链条。
- [x] 路由:`WorkspaceRoutes.tsx` 注册 `roundtable/chains`(套 `WorkspaceLayout`;本页**不需要** `ChatRuntime`,无沙箱依赖)。
- [x] 页面 `roundtable-planning/pages/BusinessChainEditorPage.tsx`:
- [x] 顶部:链条列表下拉(`<select>` 列出已存链条 + 新建项)/ 新建按钮 / 标题+描述输入 / 保存 / 删除(TDesign 确认对话框)。
- [x] 顶部:链条列表下拉(`<select>` 列出已存链条 + 新建项)/ 新建按钮 / 标题+描述输入 / 保存 / 删除(`window.confirm`)。
- [x] **左栏**:候选智能体(`listAgents()` + `filterRecommendCandidates`),竖排卡片,可拖、可点「+」快捷加入;已加入的置灰「已加入」。
- [x] **右栏**:有序长条卡片(序号 tag + 名称 + 描述 + 移除),`SortableContext` 内拖拽排序;空态有占位提示。
- [x] 拖拽用 `@dnd-kit`:左栏 `useDraggable`,右栏 `useDroppable` + `SortableContext`/`useSortable`,`onDragEnd` 计算插入 index(pool→右栏按落点插入;seat→seat `arrayMove`);`DragOverlay` 跟手卡片。
@@ -591,7 +591,7 @@ isOrchestrating = false
| Step 2 干预 | 底部输入框 → `runOrchestration` 新 seed,wrap 进「用户人工干预新指令:...」 prompt |
| Step 2 Persona | 点圆桌头像打开抽屉;保存后下一轮该席位使用所选模型 |
| 新建任务 | `handleStartNewTask`:abort 全部、清 state、`runStep1Init`,与 Step 3「重新起草」共用 |
| 历史草稿 | 顶栏下拉:加载 / 重命名 / 删除(删除使用 TDesign 确认对话框) |
| 历史草稿 | 顶栏下拉:加载 / 重命名 / 删除(删除带 `window.confirm`) |
| Step 3 预览 | 文本类 → 模态预览;其它 → 新窗口下载 |
---
+4 -4
View File
@@ -343,7 +343,7 @@ const [thread, sendMessage, isUploading] = useThreadStream({
5. **附件上传**:先 `uploadFiles(threadId, files)` 上传到 Gateway `/api/threads/:threadId/uploads`,然后将 `path/filename/size` 写入 `messages[0].additional_kwargs.files`,与 lead_agent 后端约定一致。
6. **TanStack Query 失效**:流式完成或新建会话时调用 `queryClient.invalidateQueries({ queryKey: ["threads", "search"] })`,让侧边栏「最近会话」自动刷新。
7. **错误降级**:`onError` 通过项目反馈层弹出 TDesign Message;`getStreamErrorMessage(error)` 兜底解析对象/嵌套字段。
7. **错误降级**:`onError` 弹 sonner toast;`getStreamErrorMessage(error)` 兜底解析对象/嵌套字段。
### 7.4 重要回调事件
@@ -423,7 +423,7 @@ LocalSettings = {
### 9.1 `src/components/ui/`
shadcn 风格的「无业务」基础组件:`button`、`badge`、`avatar`、`card`、`carousel`、`command`、`dialog`、`dropdown-menu`、`hover-card`、`input`、`input-group`、`item`、`progress`、`resizable`、`scroll-area`、`select`、`separator`、`sidebar`、`skeleton`、`switch`、`tabs`、`textarea`、`toggle`、`toggle-group`、`tooltip` 等。全局消息、确认框和输入提示统一使用 `src/core/ui/feedback.tsx` 封装的 TDesign 反馈层。
shadcn 风格的「无业务」基础组件:`button`、`badge`、`avatar`、`card`、`carousel`、`command`、`dialog`、`dropdown-menu`、`hover-card`、`input`、`input-group`、`item`、`progress`、`resizable`、`scroll-area`、`select`、`separator`、`sidebar`、`skeleton`、`sonner`、`switch`、`tabs`、`textarea`、`toggle`、`toggle-group`、`tooltip` 等。
特色组件:
- `aurora-text` / `flickering-grid` / `magic-bento` / `spotlight-card` / `shine-border` / `confetti-button` —— Landing 视觉效果
@@ -695,7 +695,7 @@ URL 加 `?mock=true` 时,`useThreadChat()` 设 `isMock=true`,`getAPIClient(t
### 18.4 在浏览器调试 SSE
LangGraph SDK 走标准 SSE。开发期通过 Chrome DevTools `Network -> EventSource` 可以直接查看 frames。失败原因(如 422)可在 TDesign Message 中看到 `getStreamErrorMessage()` 的解析结果。
LangGraph SDK 走标准 SSE。开发期通过 Chrome DevTools `Network -> EventSource` 可以直接查看 frames。失败原因(如 422)可在 sonner toast 看到 `getStreamErrorMessage()` 的解析结果。
---
@@ -795,7 +795,7 @@ setSettings("context", { model_name: "gpt-5" }); // 仅当前线程
| 发起 GET/POST | `apiFetch(`${getBackendBaseURL()}/api/...`, { method, body })` |
| 发起 SSE 聊天 | `useThreadStream({ threadId, context, ... })` |
| 跨标签同步偏好 | `useLocalSettings()` / `useThreadSettings(threadId)` |
| 弹全局消息 | `import { toast } from "@/core/ui/feedback"; toast.success("done")` |
| 弹 toast | `import { toast } from "sonner"; toast.success("done")` |
| 弹浏览器通知 | `useNotification().showNotification(title, { body })` |
| 国际化 | `const { t } = useI18n(); t.common.loading` |
| 合并 className | `cn("base", cond && "x-y")` |
+9
View File
@@ -88,6 +88,7 @@
"remark-gfm": "^4.0.1",
"remark-math": "^6.0.0",
"shiki": "3.15.0",
"sonner": "^2.0.7",
"streamdown": "1.4.0",
"tailwind-merge": "^3.4.0",
"tdesign-react": "^1.12.3",
@@ -9742,6 +9743,14 @@
"@types/hast": "^3.0.4"
}
},
"node_modules/sonner": {
"version": "2.0.7",
"license": "MIT",
"peerDependencies": {
"react": "^18.0.0 || ^19.0.0 || ^19.0.0-rc",
"react-dom": "^18.0.0 || ^19.0.0 || ^19.0.0-rc"
}
},
"node_modules/sortablejs": {
"version": "1.15.7",
"resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.15.7.tgz",
+1 -2
View File
@@ -20,11 +20,9 @@
"test:users-paged": "node scripts/test-users-paged.mjs",
"test:auth-entry": "node scripts/test-auth-entry.mjs",
"test:b5-1-theme": "node --experimental-strip-types --test src/core/auth/b5-1-theme.test.mjs",
"test:task-entry": "node --experimental-strip-types --test src/core/auth/task-entry.test.mjs",
"test:html-preview": "pnpm exec esbuild src/core/utils/legacy-html-preview.test.ts --bundle --platform=node --format=esm --outfile=.runtime/unit-tests/legacy-html-preview.test.mjs && node --test .runtime/unit-tests/legacy-html-preview.test.mjs",
"test:visualizations": "node --experimental-strip-types --test src/components/workspace/visualizations/visualization-spec.test.ts src/components/workspace/visualizations/map-style.test.ts",
"test:composer-session": "node --experimental-strip-types --test src/core/settings/composer-scope.test.ts",
"test:agent-appearance": "node --experimental-strip-types --test src/core/agents/appearance.test.ts",
"test:report-collaboration": "npx esbuild src/report-collaboration/tests/event-reducer.test.ts --bundle --platform=node --format=esm --outfile=.runtime/unit-tests/event-reducer.test.mjs && npx esbuild src/report-collaboration/tests/message-adapter.test.ts --bundle --platform=node --format=esm --outfile=.runtime/unit-tests/message-adapter.test.mjs && node --test .runtime/unit-tests/event-reducer.test.mjs .runtime/unit-tests/message-adapter.test.mjs",
"check:chrome109-css": "node scripts/check-chrome109-css.mjs",
"check:legacy-chrome-css": "node scripts/check-chrome109-css.mjs",
@@ -112,6 +110,7 @@
"remark-gfm": "^4.0.1",
"remark-math": "^6.0.0",
"shiki": "3.15.0",
"sonner": "^2.0.7",
"streamdown": "1.4.0",
"tailwind-merge": "^3.4.0",
"tdesign-react": "^1.12.3",
Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 5.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 5.6 MiB

+7 -9
View File
@@ -13,7 +13,11 @@ window.__CM_RUNTIME_CONFIG__ = {
// 也可以把下方图片地址改为其他 PNG 地址,无需重新打包。
// 是否显示整块欢迎页图标区域:"true" 显示,"false" 隐藏,默认隐藏。
VITE_WELCOME_LOGO_VISIBLE: "false",
// 深色主题顶栏 Logo 位置:"center" 显示在中间,"left" 显示在左上角,默认中间。
// 红白主题是否使用浅红色科技感顶栏,并完整复用深色主题的导航布局。
// "true" 启用;"false" 保持原来的红白主题顶栏。
VITE_LIGHT_RED_TOP_NAV_ENABLED: "true",
// 科技感顶栏 Logo 位置:"center" 显示在中间,"left" 显示在左上角,默认中间。
// 同时作用于深色主题和启用后的浅红色顶栏。
VITE_DARK_LOGO_POSITION: "center",
// 红白主题的顶栏系统 Logo 图片地址。
VITE_BRAND_LOGO_LIGHT_URL: "brand-assets/brand-logo-light.png",
@@ -23,13 +27,7 @@ window.__CM_RUNTIME_CONFIG__ = {
VITE_BRAND_LOGO_LIGHTGREEN_URL: "brand-assets/brand-logo-light.png",
// 深色主题的顶栏系统 Logo 图片地址。
VITE_BRAND_LOGO_DARK_URL: "brand-assets/brand-logo-dark.png",
// 红白主题的欢迎页 Logo 图片地址:为空时显示原有 CM 文字和渐变背景。
VITE_BRAND_WELCOME_LIGHT_URL: "",
// 浅蓝主题的欢迎页 Logo 图片地址:为空时显示原有 CM 文字和渐变背景。
VITE_BRAND_WELCOME_LIGHTBLUE_URL: "",
VITE_BRAND_WELCOME_LIGHTGREEN_URL: "",
// 深色主题的欢迎页 Logo 图片地址:为空时显示原有 CM 文字和渐变背景。
VITE_BRAND_WELCOME_DARK_URL: "",
// 简洁模式欢迎区复用上面的 VITE_BRAND_LOGO_* 系统 Logo,不再单独配置欢迎页图片。
// DeerFlow Gateway 地址:前端自有后端接口,例如 /api/agents、/api/auth、/api/threads 等。
// VITE_BACKEND_BASE_URL: "https://ch1.b.uat.4.cn/deerflow",
@@ -42,7 +40,7 @@ window.__CM_RUNTIME_CONFIG__ = {
// 地图瓦片地址模板:仅供普通问答消息列表中的交互地图使用。
// 后续接入内网瓦片服务时,只需替换此项并保留 {z}/{x}/{y} 占位符。
VITE_MAP_TILE_URL: "http://119.254.86.251:8023/tiles/{z}/{x}/{y}.png",
VITE_MAP_TILE_URL: "http://119.254.86.251:8023/tiles/{z}/{x}/{y}.png?v=zh-z14-13",
// routeKey 短路由的用户名直登口令:例如 #/login/admin?routeKey=a。
// 填值时优先使用这里的 password;留空时使用 URL 中的 ?password=。
+7 -1
View File
@@ -6,6 +6,7 @@ import { DesensitizeWordsLoader } from "@/components/desensitize-words-loader";
import { FontScaleApplier } from "@/components/font-scale";
import { QueryClientProvider } from "@/components/query-client-provider";
import { RouteLoadingFallback } from "@/components/route-loading";
import { Toaster } from "@/components/ui/sonner";
import { AuthSyncWatcher } from "@/core/auth/sync";
import { RequireAccount } from "@/core/auth/require-account";
import { I18nProvider } from "@/core/i18n/context";
@@ -27,7 +28,6 @@ import {
} from "@/core/embed/embed-session";
import { HashRouter, useLocation } from "react-router-dom";
import {
isPositionRoundtableStandaloneMode,
POSITION_ROUNDTABLE_ROUTE,
@@ -35,6 +35,7 @@ import {
const LandingPage = lazy(() => import("./pages/LandingPage"));
const LoginPage = lazy(() => import("./pages/LoginPage"));
const RegisterPage = lazy(() => import("./pages/RegisterPage"));
const PageRoutes = lazy(() => import("./pages/PageRoutes"));
const MarkdownDocxEditorPage = lazy(() => import("./pages/MarkdownDocxEditorPage"));
const PublicScheduledTaskPage = lazy(() => import("./pages/PublicScheduledTaskPage"));
@@ -201,6 +202,10 @@ export function App() {
positionStandaloneMode ? standaloneLoginRedirect : <LoginPage />
}
/>
<Route
path="/register"
element={<RegisterPage />}
/>
<Route path="/landing" element={<LandingPage />} />
{/* Anonymous standalone tool: no workspace navigation or login gate. */}
<Route
@@ -208,6 +213,7 @@ export function App() {
element={
<div className="h-dvh overflow-hidden">
<MarkdownDocxEditorPage />
<Toaster />
</div>
}
/>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

@@ -1,4 +0,0 @@
<svg width="28" height="20" viewBox="0 0 28 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1 2L17 10L1 18V2Z" fill="#F5222D"/>
<path d="M8 2L24 10L8 18V2Z" fill="#FDDADC"/>
</svg>

Before

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

@@ -1,17 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="152" height="42.359" viewBox="0 0 152 42.359" fill="none">
<defs>
<linearGradient id="bg" x1="0" y1="0" x2="152" y2="42.359" gradientUnits="userSpaceOnUse">
<stop stop-color="#A90F1A"/>
<stop offset="0.5" stop-color="#D82932"/>
<stop offset="1" stop-color="#941019"/>
</linearGradient>
<linearGradient id="shine" x1="76" y1="0" x2="76" y2="42.359" gradientUnits="userSpaceOnUse">
<stop stop-color="#FFF" stop-opacity=".34"/>
<stop offset="1" stop-color="#FFF" stop-opacity="0"/>
</linearGradient>
</defs>
<path d="M5 0h142a5 5 0 0 1 5 5v32.359a5 5 0 0 1-5 5H5a5 5 0 0 1-5-5V5a5 5 0 0 1 5-5Z" fill="url(#bg)"/>
<path d="M5 .75h142a4.25 4.25 0 0 1 4.25 4.25v32.359a4.25 4.25 0 0 1-4.25 4.25H5A4.25 4.25 0 0 1 .75 37.359V5A4.25 4.25 0 0 1 5 .75Z" stroke="#FFF" stroke-opacity=".34" stroke-width="1.5"/>
<path d="M1 1h150v18.5c-29.8 10.6-119.1 10.6-150 0V1Z" fill="url(#shine)" opacity=".62"/>
<path d="M22 40.859h108" stroke="#FFF" stroke-opacity=".8" stroke-width="2" stroke-linecap="round"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="152" height="42.359" viewBox="0 0 152 42.359"><defs><style>.a{fill:url(#a);}</style><pattern id="a" preserveAspectRatio="none" width="100%" height="100%" viewBox="0 0 536 150"><image width="536" height="150" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhgAAACWCAYAAACcofGRAABDtklEQVR42u2dW5bkOJJkVUC6R2RlzRLmu9fSK56t9Hz3EqarMjLcCJ0PgCQA4kkCfJjD8sTJCHcz2hu4FBUVBfVLvzS6/J//+N94g6eBb3Kf73Dhb3KfVS//+X//m/tHp1/6QtYvHSie+z3o37XvByPcgaNfOmD0S7+8P1DgDb5D/ft6/sbN3x0+OnD0S1+w+qVDRZvPNfp3r0PJScflDhv90gGjXzpQvNfnF/071S83BgbuwNEvHTD6pYPFcz636N+ffjlxg7/LMTpo9EsHjH7pUFHpM4pv/v1A91Pc+jnwu71+HTb6pQNGv9wNKNCViP7dfDNQuVK14A4c/dIXsX75rmCBb6ZGoH+3b7Uh8jdTPbiDRr90wOiXDhTXKxpX32f/Xt4DGp4U3MUdOPqlA0a/dLC4l7LxLt0r/fJ+3RxnKBUdNPqlA0a/PAYsWgLF3UOt+vfp+wLJXcO/HgMcHTQ6YPRLB4p3gAm86/eFH/6dxjO6Su5ovHw76OjA0QGjX74fWLSAhDvBBDogdEA5ET7uAB18Z9jooNEBo1/eFyqeAhR3LbVUhwZ80+8tV97ccG9PBXfg6LDRAaNf3hUungAWt4OKWjCB/t28BD5OhI4rN/FHg0aHjA4Y/dKh4qoZH7gjPHRgeB8gwfPKGjWO1WGjXzpgdKi4dNM+s30TdwGIp8LDWX4PPDQOfC+E4LryxtntuFfAUIeNDhj9cmOwqLl544kwUbKxops+u6mzEoTgmlLHmXHlZ0JQB40OGP3ypnDxOLC4O1TcASRqPe/aZsyngMeFsHEn0OiQ0S8dML4JVNRSIs4ACpy5UeNhps/u42gDMGeBSO5jxnllDr7RfXCHjQ4Y/fJeYNF6w28OFDmbN25o+mwNCk8tq7Te7G/mqch+TLgXDLQ8fgeNDhj98lCoaF2SQKvP2RUgsWeTxgnPs1/aA8EeEKkNISeBB1847fUMhaXDRgeMDhYXQsXtgOJMmCjd0Pfcb4eG94ORUgCpBR8nQMdVwHEZbHTQ6IDR4eJecHEJWFwBFaX3+Y4wkXoN7mDovBo6rjB3pu7zhqDRIaMDRr90qLgeKM6EiZL7eqdOD+oGz1MA5ESPRfS+bgYcHTY6YPRLh4o6x2upTtSEiLMB4omdLE9sJT0bSnKfV2v4aKRydNjolw4YDweLI9BweemjlTpRCyZabrg4qTumX9oAS0sYyXl8V0IH6k6CbVFKuQQ2Omh0wPjuYFEbKqqpFHs33BqqR4uNutXz6ZdnwEgLAKkBHrWfT2V1ozZsdNDogNHh4iQFoWYJ5HKl4ugx7zAavcNE7yi5CjZagFNFZePMkkyHjA4Y3x4szlQsmkJF7Y04o3vhsoTMGwIE3tfT+T26S47ed23oqKhsnAEbpysaHTQ6YDwVLGqqFYeh4g5AUWNDf0i3SP8+PhhManeXHLm/mwJHLdi4jarRQaMvaHcBi7PUiiZQgRN9GUc2+Bt2jDS5H/zjz2/13eV//4ufDCM1O0tqqxy1gONmsHGqqtFBowPGHcGillqBFqUPnFA+aQ0TDUECbwMILNs8Fgh+I0DhO3eW1FQ5apSCKpVS+GmqRgeNDhgdLi4Gi6ObfutySu3vymkw0QoUTl+VzgGTg9BxOnAcLauEjn0j0OiQ0QGjg0UjsHgMVJylVJxp9DzyfTgMEO8CBm8GKgcA5NTOktrD2WoAx41ho4NGB4zHwkUpWOAsb0ULqKgJFCfDBE6Bhw4Obw8ihRDCd4WOUuA4ETZqeDVKYYU7ZHTAeIJicalacQQqSlSK2upEJZhoM9TsH392gPjOAPLvf7VqU+W7lVd8xzuqbjSAjZaqRlc0OmBcBhctyyC3gYpaPorGQIHqIPHHH+jfXeqZGLmXv/5q0aLKdwGOEv/GA2DjsvLJd4MMdLh4X7hoUQK5EVjUhYp7AkVXSJ4KH5nAcQZstAaN2iWUDhkdML4rXJwJFk0Vi1ZqRaPOEbyJOnGr7xszn/J4AHAHkiYqB5/VUXKGqlFZ0bg1aHwXyEAHiyY+i6ZqRWuouBgo8FBVAu8CBLdftM4BFn6o2sF3Ao4LYKO2qsFdzeiAcRfF4lSwuAIqzgaK5HNsDxHooNDB5DIQScBHBgBcAhwtYeNmoNEVje8EGDdWLN4KKrjuwLU8VaItTKBDQ79UhBG+UvHgyhtiSUfJG8FGVzQ6YHS4KL3NBWrFXcECHSj65QTg4HcAjTNUjQ4Z7wUZ6HBxus+iCBJqKRZ3USsuKnmgQ0Tww4PGKwx3+DgRPPaXVC5VNWooGjtB45b+jHeBDHS4uIdicVStuLgEght4KN4fIri3rT4NWi6Hj2MeDr5DCaWRqnF7ReMdIANdtciGgepg0aIEwge6MGpAxUlAgbcAiA4M3x5ICgGEn6BwHCmlpJSNBrDRGjS+tZqBrlpUybJAa7XCvF0tqGiuUtQvd+ARUHEDcAA9q7zDdIOsjAtB5HTQyICOq9WNEGzsTQrdoWrs7dDhrmY8GDBOhIs9qkVVuGilWPCxltr44z4OFs9RKC6AiafBw6Mh5GL141TwiKgbR5WN2pCxd+hbA8g4Tc14ImTgm8FFrkJxa7B4Q6i4pzLREB6+KyS8JZycDCEF0MHvChsPAQ2u/b48DTLQVYv7lEOOqhWnQcUJCsWpMFERJK4CB36zlnNcFOddFUROBI9M6KiucFwBG0dUjYvKJt9WzcA3VS2agsXVagXvN6S28FPcR52oABKtAYL7gLNbg0kVADkBPJqrHOW+Da7RunqhqnE70HgCZKDDxXVwcaFigW8DFgehohVQdJB4D/A4DByNYeNmoMEPVzQ6ZLwTYNwALpqUQ46AxZOhohlM3EyZ6PDQIeTOSkcGdDwSNvaCRuOyybeGDHSwqKta7FUsStWKm0DFuUBxACQ6QPTL2wBIZfBoAhyNYaNE1diraHQ14w0B4wBctAAL1Ij0jl2vgVrREipuDxQ1QKIDRL9cBSC7wOPuwFERNmqqGpVAw33Ml4LG3SAD3wguqigWez0WR8CiGlRUVCmalDsKgOIoSLwRRODtO0w7fJSBR4PSSgQ6uGE3CtdSNWqARuK6RxWNt4QMdOWifjmklseiahmkolpRFS5OUikeDBRdTXlDANkDHFerGwllg58MGbkejYplk2+hZOAb+C2qlESOlkNKPBYXKhZtoeIEmHgASHRg6EBSDTyugo67w8Zej0YDf8ZlSsYdQANdtbgOLI6WQipAxa2A4g1gAtTh5R0ggL8VdNwJOPJgo4mqcSFovK2agW+oWlT1WpwAFmm14i5Q0dBDwd9j8+7qxnMAgd8WOg4CRyvYKFU1WoJGI2/G26kZ+MZGTpROLa0JFierFW2gIhMoHuSZQAeHDiJPhI+mno4DwFEFNiqrGq0UjSeUTc6GDDxYubisJHI5XFRQLDpYNPsOdJjo0HEZbDwQNGoqGpdAxkUlk0coGfgGykVxSeQNwOIRUPFQmOgA0QHkbaHjEbDxbNAoeayPVzLwjeDiNLA44rF4ElS8OUx0kOiXM6HhudDxUNjI9WicABpvCxl4EFzs9Vvs9lqUBmVdABZ1oeKZQNFVCSIC81sBEQPcoeM88LgDcByCjcagURrUtaNsctSXcUvIwBvCRTPVolIpBC3Uim8CFW+vSrwbKHQweZ7acWPYqKFqcK3SyQ3VjD2ZKPSf/9UOMvBmZZGqcFFZtWhWCtkFFxmeily4uDlYoMNEh443hY1bgEaWb2MHaDSEjOBxjqgZJ0BGznPgPatjK8jAd1QuWngtdoHFmVDxHKDA00HibHB41+FsONmXcDMQYboZdFwJHLVgYw9o1PZm3ErJMFaOFpAx3jgFcQ9c7FItGoFFjXJIU7C4AVA8EiZaAkSf5HrstTgCJan39WQAwc4NFa2gwxM+yDnrihc45nUpEzTmdc8BDWQ9vz/+wAwZRrmbjWNw5GSUPbeJXsf8ubtvxH7vPB9Enpf7u9S/3yedcId6cQvV4hTFIg8smqsVKbC4GVDgHUDiMnC4exnmItWgpjpysfLBdBOVI/Wa1vZr7FI1KpROShSN26sZzupQW8XAxWWRZnBRU7U4rFjsUCveQKl4jDpxFCSawkP3aVwGKIdHrF8DHpeXVqqUUo7DBh8onew2gpaUTTLKKu0hI7C61AKN8aHqCXKPcxJcHPFZNFMscsCC75FkiacpE02gosNEndes0sburBN89HN2EnBgJzSgFmjkvm7z+hQsoRRABjOjuHzilE6csgmFSidY1Qf4yia+35s/d0smifeE71b2OH1hb6BenOq3eBxY3K8EgrsCxRGYqPY6dXB4a/XjiNJxssrBdGEp5awSytHSSa2ySW47a2GXyd4oci5diWuoGHiQ5+I0v0VO7gWF7qsQLIrUimcqFbeHiSqvzftBBOjBI87vAB97weOm0MFnl5+CwFGgbBSXTsIejaJcjFJfxomtrFzyLT8KGXgHuLhKtTiiWNRQK05WKnAnheISmLgfRKDHcD8LPm4OHXxHz0YNr8YR0MjxZ5yoZtSFjIwV5Ahk4EFwUaxavCNYxKDiXYHidJi4DiTuAAx4AxjgJ4HHjaHjdsBxVNV4GmgcKJnkQUbmt30vZIxPPhO7Yt7FXrg4Wgo5Ua3At4OLine truncated

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 23 KiB

@@ -78,7 +78,7 @@ import {
useRef,
useState,
} from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
// ============================================================================
// Provider Context & Types
@@ -1225,7 +1225,7 @@ export const PromptInputButton = ({
}: PromptInputButtonProps) => {
return (
<InputGroupButton
className={cn("agent-composer-tool", className)}
className={cn(className)}
size="sm"
type="button"
variant={variant}
@@ -1306,10 +1306,9 @@ export const PromptInputSubmit = ({
<InputGroupButton
aria-label={ariaLabel}
className={cn(
// 皮肤本体在 globals.css 的 .agent-composer-send(主题色扁平渐变
// 圆钮);流式态切 .agent-composer-send--stop 低对比停止钮。
"agent-composer-send transition-all duration-300",
status === "streaming" && "agent-composer-send--stop",
"transition-all duration-300",
status === "streaming" &&
"animate-breathe-stop bg-primary/10 text-primary border-primary/25 shadow-[0_0_0_0_rgba(217,33,33,0.25)] hover:bg-primary/14",
className,
)}
size={size}
@@ -1,5 +1,5 @@
import { FileOutput } from "lucide-react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import responsibilityIcon from "@/assets/position-roundtable/责任岗位.svg";
import resultTimeIcon from "@/assets/position-roundtable/时间.svg";
@@ -24,7 +24,7 @@ import {
Trash2,
} from "lucide-react";
import { Button } from "@/components/ui/button";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { getStoredAuth } from "@/core/auth";
import { readRuntimeEnv } from "@/env";
import "./document-upload-popup.css";
@@ -20,7 +20,7 @@ import {
UsersRound,
} from "lucide-react";
import { Button } from "@/components/ui/button";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { getStoredAuth } from "@/core/auth";
import { authenticatedFetch } from "@/components/assistant-ui/document-upload-popup";
import { readRuntimeEnv } from "@/env";
+2 -1
View File
@@ -14,7 +14,7 @@ import {
* 「仅文字」把倍数写到 `--ui-font-scale`,只放大 Tailwind 字号 token 和正文继承字号。
* 「整页缩放」改在 `<html>` 上设置 CSS zoom,写死的 px 字号、间距和图标一起变;
* 此时 `--ui-font-scale` 固定为 1,避免和 zoom 叠乘。
* `fontScale === 1` 即默认 16px。
* 默认倍率为 `1.375`,即 22px。
*/
export const BASE_FONT_PX = 16;
@@ -24,6 +24,7 @@ export const FONT_SCALE_OPTIONS: { value: number; label: string; px: number }[]
{ value: 1, label: "标准", px: 16 },
{ value: 1.125, label: "大", px: 18 },
{ value: 1.25, label: "特大", px: 20 },
{ value: 1.375, label: "超大", px: 22 },
];
export const FONT_SCALE_MODE_OPTIONS: {
+53 -1
View File
@@ -772,7 +772,7 @@ html[data-custom-theme="true"] .light-topnav-item--active::after {
color: var(--brand-900);
}
/* 侧边栏底部:设置入口(浅色模式不支持收起,故无收起按钮) */
/* 侧边栏底部:设置入口 + 收起面板按钮 */
.light-sidebar__footer {
margin-top: auto;
display: flex;
@@ -782,6 +782,58 @@ html[data-custom-theme="true"] .light-topnav-item--active::after {
border-top: 1px solid var(--border);
}
/* 侧边栏收起后的左下角浮动展开入口(交互同深色 sidebar-collapse-btn--floating,配色用浅色主题变量) */
.light-sidebar-expand-btn {
position: fixed;
left: 10px;
bottom: 10px;
z-index: 60;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 6px;
width: 36px;
height: 36px;
padding: 0 10px;
border: 1px solid var(--brand-200);
border-radius: 8px;
background: #ffffff;
color: var(--brand-900);
font-family: var(--font-sans);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
cursor: pointer;
overflow: hidden;
transition: width 0.22s ease, background-color 0.2s ease, border-color 0.2s ease;
}
.light-sidebar-expand-btn:hover {
width: 104px;
background: var(--brand-200);
}
.light-sidebar-expand-btn__icon {
width: 16px;
height: 16px;
flex: 0 0 16px;
color: var(--brand-900);
}
.light-sidebar-expand-btn__label {
font-size: 14px;
line-height: 1;
white-space: nowrap;
max-width: 0;
opacity: 0;
transform: translateX(-4px);
transition: max-width 0.22s ease, opacity 0.16s ease, transform 0.22s ease;
}
.light-sidebar-expand-btn:hover .light-sidebar-expand-btn__label {
max-width: 64px;
opacity: 1;
transform: translateX(0);
}
/* ── 三级列条目(左对齐图标 + 文字,参考 xiugai-1.png)─────────────────────── */
.light-sidebar-subnav {
display: flex;
+41 -3
View File
@@ -13,6 +13,8 @@ import {
MessageSquareText,
MousePointerClick,
BriefcaseBusiness,
PanelLeftClose,
PanelLeftOpen,
Settings,
ShieldAlert,
ShieldCheck,
@@ -100,14 +102,24 @@ export function PageSidebar({
/>
);
}
return <SecondaryNavSidebar headerHidden={headerHidden} />;
return (
<SecondaryNavSidebar
collapsed={collapsed}
onToggleCollapsed={onToggleCollapsed}
headerHidden={headerHidden}
/>
);
}
/**
* 浅色二级导航侧边栏(图标卡片,红/蓝主题色经 --brand-* 变量自动切换)。
* 浅色模式不支持侧边栏收起,故无收起按钮、不接收 collapsed 相关 props。
* 收起交互与深色侧边栏一致:收起后整栏隐藏,仅左下角保留浮动展开入口。
*/
function SecondaryNavSidebar({ headerHidden }: { headerHidden: boolean }) {
function SecondaryNavSidebar({
collapsed,
onToggleCollapsed,
headerHidden,
}: PageSidebarProps) {
const isAdmin = getStoredAuth()?.system_role === "admin";
const visibleMenuItems = useSidebarMenuItems(!!isAdmin);
const { t } = useI18n();
@@ -151,6 +163,22 @@ function SecondaryNavSidebar({ headerHidden }: { headerHidden: boolean }) {
const thirdItems = getActiveThirdLevelItems(visibleMenuItems, pathname);
const expanded = thirdItems.length > 0;
// 收起时整栏不占宽度,仅保留左下角浮动入口以便随时恢复(交互同深色侧边栏)。
if (collapsed) {
return (
<button
type="button"
title="展开侧边栏"
aria-label="展开侧边栏"
className="light-sidebar-expand-btn"
onClick={onToggleCollapsed}
>
<PanelLeftOpen className="light-sidebar-expand-btn__icon" aria-hidden="true" />
<span className="light-sidebar-expand-btn__label">展开面板</span>
</button>
);
}
return (
<>
<SettingsDialog
@@ -311,6 +339,16 @@ function SecondaryNavSidebar({ headerHidden }: { headerHidden: boolean }) {
</DropdownMenuContent>
</DropdownMenu>
) : null}
<button
type="button"
title="收起侧边栏"
aria-label="收起侧边栏"
onClick={onToggleCollapsed}
className="light-sidebar-item"
>
<PanelLeftClose className="light-sidebar-item__icon h-7 w-7" />
<span className="light-sidebar-item__label">收起面板</span>
</button>
</div>
</div>
@@ -52,7 +52,6 @@ function ResizablePanel({
function ResizableHandle({
withHandle,
className,
children,
...props
}: React.ComponentProps<typeof ResizablePrimitive.Separator> & {
withHandle?: boolean;
@@ -71,7 +70,6 @@ function ResizableHandle({
)}
{...props}
>
{children}
{withHandle && (
<div className="bg-border z-10 flex h-8 w-4 items-center justify-center rounded-sm border shadow-sm">
<GripVerticalIcon className="size-3.5" />
+40
View File
@@ -0,0 +1,40 @@
"use client";
import {
CircleCheckIcon,
InfoIcon,
Loader2Icon,
OctagonXIcon,
TriangleAlertIcon,
} from "lucide-react";
import { useTheme } from "next-themes";
import { Toaster as Sonner, type ToasterProps } from "sonner";
const Toaster = ({ ...props }: ToasterProps) => {
const { theme = "system" } = useTheme();
return (
<Sonner
theme={theme as ToasterProps["theme"]}
className="toaster group"
icons={{
success: <CircleCheckIcon className="size-4" />,
info: <InfoIcon className="size-4" />,
warning: <TriangleAlertIcon className="size-4" />,
error: <OctagonXIcon className="size-4" />,
loading: <Loader2Icon className="size-4 animate-spin" />,
}}
style={
{
"--normal-bg": "var(--popover)",
"--normal-text": "var(--popover-foreground)",
"--normal-border": "var(--border)",
"--border-radius": "var(--radius)",
} as React.CSSProperties
}
{...props}
/>
);
};
export { Toaster };
@@ -1,6 +1,6 @@
import { Plus, Trash2 } from "lucide-react";
import { useEffect, useMemo, useState } from "react";
import { confirmAction, promptAction, toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -136,12 +136,7 @@ export function FolderManageDialog({
};
const handleRename = async (folderId: string, current: string) => {
const next = await promptAction("输入新的完整路径,使用斜杠分隔层级。", {
title: "重命名 / 移动目录",
defaultValue: current,
placeholder: "例如:业务资料/项目文档",
confirmText: "保存",
});
const next = window.prompt("重命名 / 移动目录(输入新的完整路径,斜杠分隔)", current);
if (next === null) return;
try {
await rename.mutateAsync({ folderId, path: next });
@@ -152,11 +147,7 @@ export function FolderManageDialog({
};
const handleDelete = async (folderId: string, path: string) => {
if (!(await confirmAction(`删除目录「${path}」?其中的知识将变为未归类(不会被删除)。`, {
title: "删除目录?",
confirmText: "删除",
danger: true,
}))) return;
if (!window.confirm(`删除目录「${path}」?其中的知识将变为未归类(不会被删除)。`)) return;
try {
await remove.mutateAsync({ folderId });
toast.success("目录已删除");
@@ -301,11 +292,7 @@ export function ExtractTemplateManageDialog({
};
const handleDelete = async (t: KnowledgeExtractTemplate) => {
if (!(await confirmAction(`删除模板「${t.name}」?`, {
title: "删除模板?",
confirmText: "删除",
danger: true,
}))) return;
if (!window.confirm(`删除模板「${t.name}」?`)) return;
try {
await remove.mutateAsync(t.id);
if (selectedId === t.id) setSelectedId(null);
@@ -1,7 +1,7 @@
import { ExternalLink, Sparkles } from "lucide-react";
import { useEffect, useMemo, useRef, useState } from "react";
import { useNavigate } from "react-router-dom";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Input } from "@/components/ui/input";
import {
@@ -2,7 +2,7 @@
import { useState } from "react";
import { Check, Loader2, Pencil, Plus, Trash2, X } from "lucide-react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
@@ -3,15 +3,18 @@
import {
Activity,
Gauge,
Loader2,
OctagonX,
RefreshCw,
Square,
Zap,
} from "lucide-react";
import { useId, useMemo, useState } from "react";
import { Button, Switch, Tag } from "tdesign-react";
import { confirmAction, toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Switch } from "@/components/ui/switch";
import type {
ActiveRunItem,
ConcurrencyPoint,
@@ -32,9 +35,6 @@ import { cn } from "@/lib/utils";
/** lookback window (hours) per granularity. */
const LOOKBACK: Record<Granularity, number> = { minute: 3, hour: 48 };
/** 主题色(浅红主题下为深红),SVG 引用以跟随换肤。 */
const BRAND_COLOR = "var(--td-brand-color, #C1121F)";
function fmtBucket(iso: string, granularity: Granularity): string {
const date = new Date(iso);
if (Number.isNaN(date.getTime())) return iso;
@@ -103,11 +103,7 @@ function latestOf(values: (number | null)[]): number | null {
return null;
}
/**
* Dependency-free SVG line chart in the 浅红 UI spec style: soft area fill
* under the first series, dashed gridlines, hollow hover markers and a dark
* hover tooltip (ref: 8.2 图表-折线图 mock).
*/
/** Minimal dependency-free SVG line chart: legend + 1–2 series + area + caption. */
function LineChart({
labels,
series,
@@ -123,7 +119,6 @@ function LineChart({
note?: string;
emptyHint: string;
}) {
const [hoverIdx, setHoverIdx] = useState<number | null>(null);
const gradId = `cm-area-${useId().replace(/:/g, "")}`;
const width = 760;
const height = 220;
@@ -137,25 +132,17 @@ function LineChart({
const ticks = buildTicks(dataMax, integer);
const axisMax = ticks[ticks.length - 1] || 1;
const handleMove = (event: React.MouseEvent<HTMLDivElement>) => {
const rect = event.currentTarget.getBoundingClientRect();
const vx = ((event.clientX - rect.left) / rect.width) * width;
const rel = (vx - pad.left) / cw;
const idx = Math.round(rel * (n - 1));
setHoverIdx(Math.max(0, Math.min(n - 1, idx)));
};
// Legend always renders (even with no data) so the lines are self-explanatory.
const legend = (
<div className="mb-2 flex flex-wrap items-center gap-x-4 gap-y-1">
{series.map((s) => {
const latest = latestOf(s.values);
return (
<span key={s.name} className="flex items-center gap-1.5 text-xs text-muted-foreground">
<span key={s.name} className="flex items-center gap-1.5 text-xs text-[#5F6368] dark:text-slate-300">
<span className="inline-block h-[3px] w-4 rounded-full" style={{ backgroundColor: s.color }} />
{s.name}
{latest != null && (
<span className="font-semibold tabular-nums text-card-foreground">
<span className="font-semibold tabular-nums text-[#231815] dark:text-white">
{Number.isInteger(latest) ? latest : latest.toFixed(1)}
{unit}
</span>
@@ -167,14 +154,14 @@ function LineChart({
);
const caption = note ? (
<p className="mt-2 text-[11px] leading-4 text-muted-foreground">{note}</p>
<p className="mt-2 text-[11px] leading-4 text-[#8B6B6B] dark:text-[#7FACF2]">{note}</p>
) : null;
if (n === 0) {
return (
<div>
{legend}
<div className="flex h-[160px] items-center justify-center rounded-[5px] border border-dashed border-border/70 text-sm text-muted-foreground">
<div className="flex h-[160px] items-center justify-center rounded-lg border border-dashed border-[#F1D6D6] text-sm text-[#5F6368] dark:border-[#213D5E] dark:text-slate-400">
{emptyHint}
</div>
{caption}
@@ -207,22 +194,16 @@ function LineChart({
return `${line} L ${xFor(n - 1).toFixed(1)} ${(pad.top + ch).toFixed(1)} L ${xFor(0).toFixed(1)} ${(pad.top + ch).toFixed(1)} Z`;
})();
const hoverX = hoverIdx != null ? xFor(hoverIdx) : null;
const labelStep = Math.max(1, Math.ceil(n / 7));
return (
<div>
{legend}
<div
className="relative"
onMouseMove={handleMove}
onMouseLeave={() => setHoverIdx(null)}
>
<svg viewBox={`0 0 ${width} ${height}`} className="w-full" role="img" aria-label="时序折线图">
<defs>
<linearGradient id={gradId} x1="0" x2="0" y1="0" y2="1">
<stop offset="0%" stopColor={first?.color ?? BRAND_COLOR} stopOpacity="0.14" />
<stop offset="100%" stopColor={first?.color ?? BRAND_COLOR} stopOpacity="0.01" />
<stop offset="0%" stopColor={first?.color ?? "#C1121F"} stopOpacity="0.18" />
<stop offset="100%" stopColor={first?.color ?? "#C1121F"} stopOpacity="0.02" />
</linearGradient>
</defs>
{ticks.map((t) => {
@@ -235,33 +216,19 @@ function LineChart({
y1={y}
y2={y}
stroke="currentColor"
className="text-border/70"
className="text-[#E5E7EB] dark:text-[#3F3F46]"
strokeWidth="1"
strokeDasharray="4 4"
/>
<text x={pad.left - 6} y={y + 3} textAnchor="end" className="fill-muted-foreground text-[10px]">
<text x={pad.left - 6} y={y + 3} textAnchor="end" className="fill-[#9CA3AF] text-[10px]">
{fmtAxis(t, integer)}
</text>
</g>
);
})}
{areaPath && <path d={areaPath} fill={`url(#${gradId})`} />}
{hoverX != null && (
<line
x1={hoverX}
x2={hoverX}
y1={pad.top}
y2={pad.top + ch}
stroke={BRAND_COLOR}
strokeWidth="1"
strokeDasharray="3 3"
opacity="0.45"
/>
)}
{series.map((s, sIndex) => (
<g key={s.name}>
{/* 基线:实色线 */}
{series.map((s) => (
<path
key={s.name}
d={linePath(s.values)}
fill="none"
stroke={s.color}
@@ -269,90 +236,50 @@ function LineChart({
strokeLinecap="round"
strokeLinejoin="round"
/>
{/* 流动高光:同路径短划沿 dashoffset 无限循环,白亮光带从左向右流过 */}
<path
d={linePath(s.values)}
fill="none"
stroke="rgba(255, 255, 255, 0.75)"
strokeWidth="2"
strokeLinecap="round"
pathLength={1}
className="lb-line-flow"
style={{ animationDelay: `${sIndex * -2.75}s` }}
/>
</g>
))}
{hoverIdx != null &&
series.map((s) => {
const v = s.values[hoverIdx];
if (v == null) return null;
return (
<circle
key={`${s.name}-hover`}
cx={xFor(hoverIdx)}
cy={yFor(v)}
r="4"
fill="var(--td-bg-color-container, #fff)"
stroke={s.color}
strokeWidth="2"
/>
);
})}
{labels.map((label, i) => {
if (i !== 0 && i !== n - 1 && i % labelStep !== 0) return null;
return (
<text key={`${label}-${i}`} x={xFor(i)} y={height - 8} textAnchor="middle" className="fill-muted-foreground text-[10px]">
<text key={`${label}-${i}`} x={xFor(i)} y={height - 8} textAnchor="middle" className="fill-[#6B7280] text-[10px]">
{label}
</text>
);
})}
</svg>
{hoverIdx != null && (
<div
className="pointer-events-none absolute top-2 z-10 min-w-[110px] -translate-x-1/2 rounded-[5px] bg-[#1D2939]/95 px-2.5 py-1.5 text-xs text-white shadow-lg"
style={{ left: `${Math.min(92, Math.max(8, (xFor(hoverIdx) / width) * 100))}%` }}
>
<div className="mb-1 font-medium text-white/90">{labels[hoverIdx]}</div>
{series.map((s) => {
const v = s.values[hoverIdx];
return (
<div key={s.name} className="flex items-center gap-1.5 whitespace-nowrap">
<span className="size-1.5 rounded-full" style={{ backgroundColor: s.color }} aria-hidden />
<span className="text-white/75">{s.name}</span>
<span className="ml-auto font-semibold tabular-nums">{v == null ? "-" : `${Number.isInteger(v) ? v : v.toFixed(1)}${unit}`}</span>
</div>
);
})}
</div>
{series.map((s) =>
s.values.map((v, i) =>
v == null ? null : (
<circle key={`${s.name}-${i}`} cx={xFor(i)} cy={yFor(v)} r={2.5} fill={s.color}>
<title>{`${labels[i]} · ${s.name}: ${v}${unit}`}</title>
</circle>
),
),
)}
</div>
</svg>
{caption}
</div>
);
}
/** 浅红 UI 规范的「▎标题」小节头(面板内使用)。 */
function ChartSection({
title,
function ChartCard({
icon: Icon,
extra,
title,
subtitle,
children,
}: {
icon: typeof Activity;
title: string;
icon?: typeof Activity;
extra?: React.ReactNode;
subtitle: string;
children: React.ReactNode;
}) {
return (
<div className="rounded-[5px] bg-muted/30 p-4">
<div className="mb-3 flex items-center gap-2.5">
<span className="h-3.5 w-[3px] shrink-0 rounded-full bg-primary" aria-hidden />
{Icon ? <Icon className="size-4 shrink-0 text-muted-foreground" /> : null}
<h3 className="text-sm font-semibold text-card-foreground">{title}</h3>
<span className="ml-auto text-xs text-muted-foreground">{extra}</span>
<section className="rounded-lg border border-[#F1D6D6] bg-white p-4 shadow-sm dark:border-[#213D5E] dark:bg-[#02244C]">
<div className="mb-3 flex items-center gap-2">
<Icon className="size-4 text-[#C1121F] dark:text-[#7FACF2]" />
<h3 className="font-semibold text-[#231815] dark:text-white">{title}</h3>
<span className="ml-auto text-xs text-[#8B6B6B] dark:text-[#7FACF2]">{subtitle}</span>
</div>
{children}
</div>
</section>
);
}
@@ -366,35 +293,36 @@ function ActiveRunRow({
stopping: boolean;
}) {
return (
<div className="grid grid-cols-[minmax(0,1.4fr)_minmax(0,1.2fr)_72px_64px_64px_72px] items-center gap-3 border-b border-border/60 px-3 py-2 text-sm transition-colors last:border-b-0 hover:bg-muted/40">
<div className="grid grid-cols-[minmax(0,1.4fr)_minmax(0,1.2fr)_72px_64px_64px_72px] items-center gap-3 border-b border-[#F1D6D6] px-3 py-2 text-sm last:border-b-0 dark:border-[#213D5E]">
<div className="min-w-0">
<div className="truncate font-medium text-card-foreground">{run.user_name || "未知用户"}</div>
<div className="truncate text-xs text-muted-foreground" title={run.thread_title}>
<div className="truncate font-medium text-[#202124] dark:text-white">{run.user_name || "未知用户"}</div>
<div className="truncate text-xs text-[#5F6368] dark:text-slate-400" title={run.thread_title}>
{run.thread_title || run.thread_id}
</div>
</div>
<div className="min-w-0 truncate text-card-foreground">{run.agent_name}</div>
<Tag variant="outline" size="small" className="justify-center">
<div className="min-w-0 truncate text-[#202124] dark:text-slate-100">{run.agent_name}</div>
<Badge variant="outline" className="justify-center">
{run.kind}
</Tag>
<span className="text-center">
{run.status === "running" ? (
<Tag theme="success" variant="light" size="small">运行中</Tag>
) : (
<Tag theme="warning" variant="light" size="small">排队中</Tag>
</Badge>
<span
className={cn(
"text-center text-xs font-medium",
run.status === "running" ? "text-[#0F766E] dark:text-teal-300" : "text-[#B45309] dark:text-amber-300",
)}
>
{run.status === "running" ? "运行中" : "排队中"}
</span>
<span className="text-center text-xs tabular-nums text-muted-foreground">
<span className="text-center text-xs tabular-nums text-[#5F6368] dark:text-slate-400">
{fmtElapsed(run.elapsed_seconds)}
</span>
<Button
size="small"
size="sm"
variant="outline"
theme="danger"
className="h-7 border-[#C1121F]/40 text-[#C1121F] hover:bg-[#FFF1F1] dark:border-rose-400/40 dark:text-rose-200"
disabled={stopping}
icon={<Square className="size-3.5" />}
onClick={() => onStop(run.run_id)}
>
{stopping ? <Loader2 className="size-3.5 animate-spin" /> : <Square className="size-3.5" />}
停止
</Button>
</div>
@@ -435,8 +363,8 @@ export function ConcurrencyMonitorPanel() {
return {
labels: points.map((p) => fmtBucket(p.bucket, granularity)),
series: [
{ name: "平均速度", color: "#2F6BFF", values: points.map((p) => p.avg_tokens_per_sec) },
{ name: "最慢", color: "#7C3AED", values: points.map((p) => p.min_tokens_per_sec) },
{ name: "平均速度", color: "#2563EB", values: points.map((p) => p.avg_tokens_per_sec) },
{ name: "最慢", color: "#9333EA", values: points.map((p) => p.min_tokens_per_sec) },
] as LineSeries[],
};
}, [tokenSpeed.data, granularity]);
@@ -455,11 +383,7 @@ export function ConcurrencyMonitorPanel() {
const handleStopAll = async () => {
if (runs.length === 0) return;
if (!(await confirmAction(`确定要停止当前全部 ${count} 个并发调用吗?这会中断这些用户正在生成的回答。`, {
title: "停止全部调用?",
confirmText: "全部停止",
danger: true,
}))) return;
if (!window.confirm(`确定要停止当前全部 ${count} 个并发调用吗?这会中断这些用户正在生成的回答。`)) return;
try {
const res = await cancelAll.mutateAsync();
toast.success(`已停止 ${res.cancelled_count} 个调用`);
@@ -478,56 +402,52 @@ export function ConcurrencyMonitorPanel() {
};
return (
<section className="lb-icon-gap space-y-4 rounded-[5px] bg-card p-4 shadow-[0_2px_8px_rgba(15,23,42,0.06)]">
<section className="space-y-4 rounded-xl border border-[#F1D6D6] bg-[#FFF7F7] p-4 shadow-sm dark:border-[#213D5E] dark:bg-[#011226]">
{/* header */}
<div className="flex flex-wrap items-center gap-3">
<div className="flex items-center gap-2">
<span className="flex size-9 items-center justify-center rounded-lg bg-primary text-primary-foreground">
<span className="flex size-9 items-center justify-center rounded-lg bg-[#C1121F] text-white dark:bg-[#2563EB]">
<Activity className="size-5" />
</span>
<div>
<div className="font-semibold text-card-foreground">实时并发监控</div>
<div className="text-xs text-muted-foreground">
<div className="font-semibold text-[#231815] dark:text-white">实时并发监控</div>
<div className="text-xs text-[#8B6B6B] dark:text-[#7FACF2]">
监控大模型并发压力,可直接停止任意对话调用
</div>
</div>
</div>
<div className="ml-auto flex h-8 flex-wrap items-center gap-2">
<div className="flex h-8 items-center gap-2 rounded-[5px] bg-muted/40 px-3">
<span className="text-xs text-muted-foreground">当前并发</span>
<div className="ml-auto flex flex-wrap items-center gap-3">
<div className="flex items-center gap-2 rounded-lg border border-[#F1D6D6] bg-white px-3 py-1.5 dark:border-[#213D5E] dark:bg-[#02244C]">
<span className="text-xs text-[#5F6368] dark:text-slate-300">当前并发</span>
<span
className={cn(
"text-lg font-semibold leading-none tabular-nums",
count > 0 ? "text-primary" : "text-card-foreground",
"text-2xl font-semibold tabular-nums",
count > 0 ? "text-[#C1121F] dark:text-[#7FACF2]" : "text-[#202124] dark:text-white",
)}
>
{count}
</span>
</div>
<div className="flex h-8 items-center gap-2 rounded-[5px] bg-muted/40 px-3">
<span className="text-xs text-muted-foreground">后台采样</span>
<Switch value={samplerOn} onChange={handleToggleSampler} loading={updateSettings.isPending} />
<div className="flex items-center gap-2 rounded-lg border border-[#F1D6D6] bg-white px-3 py-1.5 dark:border-[#213D5E] dark:bg-[#02244C]">
<span className="text-xs text-[#5F6368] dark:text-slate-300">后台采样</span>
<Switch checked={samplerOn} onCheckedChange={handleToggleSampler} disabled={updateSettings.isPending} />
</div>
<Button
variant="outline"
theme="default"
icon={<RefreshCw className={cn("size-4", isRefetching && "animate-spin")} />}
onClick={() => refetch()}
disabled={isRefetching}
>
<Button variant="outline" size="sm" onClick={() => refetch()} disabled={isRefetching}>
<RefreshCw className={cn("mr-1 size-4", isRefetching && "animate-spin")} />
刷新
</Button>
<Button
variant="outline"
theme="danger"
icon={<OctagonX className="size-4" />}
size="sm"
className="border-[#C1121F]/50 text-[#C1121F] hover:bg-[#FFF1F1] dark:border-rose-400/40 dark:text-rose-200"
onClick={handleStopAll}
disabled={cancelAll.isPending || runs.length === 0}
>
<OctagonX className="mr-1 size-4" />
全部停止
</Button>
<Button variant="text" theme="default" onClick={() => setOpen((v) => !v)}>
<Button variant="ghost" size="sm" onClick={() => setOpen((v) => !v)}>
{open ? "收起" : "展开"}
</Button>
</div>
@@ -536,38 +456,36 @@ export function ConcurrencyMonitorPanel() {
{open && (
<>
{!samplerOn && (
<div className="rounded-[5px] bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:bg-amber-400/10 dark:text-amber-100">
<div className="rounded-lg border border-amber-300/60 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:border-amber-300/30 dark:bg-amber-300/10 dark:text-amber-100">
后台采样默认关闭:实时并发数与「停止」功能始终可用。需要并发量历史折线图时,打开右上角「后台采样」开关即可开始记录(对线上服务影响极小,可随时关闭)。
</div>
)}
{/* granularity toggle */}
<div className="flex items-center gap-2">
<span className="text-xs text-muted-foreground">统计粒度</span>
<div className="lb-pill-group flex items-center gap-1.5">
<span className="text-xs text-[#5F6368] dark:text-slate-300">统计粒度</span>
{(["minute", "hour"] as Granularity[]).map((g) => (
<Button
key={g}
size="small"
variant={granularity === g ? "base" : "outline"}
theme={granularity === g ? "primary" : "default"}
size="sm"
variant={granularity === g ? "default" : "outline"}
className={cn("h-7", granularity === g && "bg-[#C1121F] hover:bg-[#A50F1A] dark:bg-[#2563EB]")}
onClick={() => setGranularity(g)}
>
{g === "minute" ? "按分钟" : "按小时"}
</Button>
))}
</div>
<span className="text-xs text-muted-foreground">
<span className="text-xs text-[#8B6B6B] dark:text-[#7FACF2]">
{granularity === "minute" ? "近 3 小时" : "近 48 小时"}
</span>
</div>
{/* charts */}
<div className="grid gap-3 xl:grid-cols-2">
<ChartSection icon={Gauge} title="并发量(系统压力)" extra={`每${granularity === "hour" ? "小时" : "分钟"}一个点`}>
<ChartCard icon={Gauge} title="并发量(系统压力)" subtitle={`每${granularity === "hour" ? "小时" : "分钟"}一个点`}>
{concurrency.isLoading ? (
<div className="flex h-[220px] items-center justify-center text-sm text-muted-foreground">
加载中…
<div className="flex h-[220px] items-center justify-center text-sm text-[#5F6368] dark:text-slate-400">
<Loader2 className="mr-2 size-4 animate-spin" /> 加载中
</div>
) : (
<LineChart
@@ -579,11 +497,11 @@ export function ConcurrencyMonitorPanel() {
emptyHint="暂无并发采样数据(需打开「后台采样」开关后才开始记录)"
/>
)}
</ChartSection>
<ChartSection icon={Zap} title="大模型出字速度" extra={`每${granularity === "hour" ? "小时" : "分钟"}一个点`}>
</ChartCard>
<ChartCard icon={Zap} title="大模型出字速度" subtitle={`每${granularity === "hour" ? "小时" : "分钟"}一个点`}>
{tokenSpeed.isLoading ? (
<div className="flex h-[220px] items-center justify-center text-sm text-muted-foreground">
加载中…
<div className="flex h-[220px] items-center justify-center text-sm text-[#5F6368] dark:text-slate-400">
<Loader2 className="mr-2 size-4 animate-spin" /> 加载中
</div>
) : (
<LineChart
@@ -594,24 +512,23 @@ export function ConcurrencyMonitorPanel() {
emptyHint="暂无大模型调用记录"
/>
)}
</ChartSection>
</ChartCard>
</div>
{/* active run list */}
<section className="overflow-hidden rounded-[5px] bg-muted/20">
<div className="flex items-center gap-2 border-b border-border/70 px-3 py-2">
<span className="h-3.5 w-[3px] rounded-full bg-primary" aria-hidden />
<span className="text-sm font-semibold text-card-foreground">正在进行的调用</span>
<Tag variant="outline" size="small">{count}</Tag>
{liveLoading && <span className="text-xs text-muted-foreground">加载中…</span>}
<section className="rounded-lg border border-[#F1D6D6] bg-white dark:border-[#213D5E] dark:bg-[#02244C]">
<div className="flex items-center gap-2 border-b border-[#F1D6D6] px-3 py-2 dark:border-[#213D5E]">
<span className="font-semibold text-[#231815] dark:text-white">正在进行的调用</span>
<Badge variant="outline">{count}</Badge>
{liveLoading && <Loader2 className="size-3.5 animate-spin text-[#8B6B6B]" />}
</div>
{runs.length === 0 ? (
<div className="py-10 text-center text-sm text-muted-foreground">
<div className="py-10 text-center text-sm text-[#5F6368] dark:text-slate-400">
当前没有正在进行的大模型调用
</div>
) : (
<div>
<div className="grid grid-cols-[minmax(0,1.4fr)_minmax(0,1.2fr)_72px_64px_64px_72px] gap-3 border-b border-border/60 bg-muted/30 px-3 py-2 text-xs text-muted-foreground">
<div className="grid grid-cols-[minmax(0,1.4fr)_minmax(0,1.2fr)_72px_64px_64px_72px] gap-3 border-b border-[#F1D6D6] px-3 py-2 text-xs text-[#8B6B6B] dark:border-[#213D5E] dark:text-[#7FACF2]">
<span>用户 / 会话</span>
<span>智能体</span>
<span className="text-center">类型</span>
@@ -11,7 +11,7 @@ import {
UsersIcon,
} from "lucide-react";
import { useEffect, useMemo, useState } from "react";
import { confirmAction, toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -391,11 +391,7 @@ export function PositionManagementPage() {
}, [positions, selectedId]);
const handleDelete = async (p: Position) => {
if (!(await confirmAction(`确认删除岗位「${p.name}」?其成员将回退到默认岗位。`, {
title: "删除岗位?",
confirmText: "删除",
danger: true,
}))) return;
if (!window.confirm(`确认删除岗位「${p.name}」?其成员将回退到默认岗位。`)) return;
try {
await deletePosition.mutateAsync(p.id);
if (selectedId === p.id) setSelectedId(null);
@@ -2,7 +2,7 @@
import { Loader2, PencilIcon, PlusIcon, Trash2Icon } from "lucide-react";
import { useState } from "react";
import { confirmAction, toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -172,11 +172,7 @@ export function TagManagementPage() {
setDialogOpen(true);
};
const handleDelete = async (tag: Tag) => {
if (!(await confirmAction(t.adminTags.deleteConfirm, {
title: "删除标签?",
confirmText: "删除",
danger: true,
}))) return;
if (!window.confirm(t.adminTags.deleteConfirm)) return;
try {
await deleteTag.mutateAsync(tag.id);
} catch (e) {
@@ -2,7 +2,7 @@
import { AlertCircle,CheckCircle2, Download, Loader2 } from "lucide-react";
import { useMemo, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
@@ -1,33 +1,11 @@
"use client";
import {
BotIcon,
BrainIcon,
CompassIcon,
MessagesSquareIcon,
SparklesIcon,
WorkflowIcon,
} from "lucide-react";
import { BotIcon } from "lucide-react";
import { type Agent } from "@/core/agents";
import { desensitize } from "@/lib/desensitize";
import { cn } from "@/lib/utils";
/**
* Per-style avatar glyphs — the landing style index (derived from the agent
* id in globals.css' [data-agent-style] block) also swaps the hero mark so
* two agents on different styles don't just differ by color. Keep in sync
* with AGENT_LANDING_STYLE_COUNT.
*/
const STYLE_ICONS = [
BotIcon,
SparklesIcon,
BrainIcon,
CompassIcon,
MessagesSquareIcon,
WorkflowIcon,
] as const;
/**
* Landing (home) hero shown above the input box before the first message of an
* agent conversation: centered avatar, a "Hi,我是{name}" greeting and the
@@ -35,33 +13,20 @@ const STYLE_ICONS = [
* (full text on hover) so a long blurb can never push the input box below the
* fold. The agent's 常用问题 are rendered by the page as a list beside the
* input box, not here.
*
* The avatar color/shape, greeting treatment and page glow are themed per
* agent via the ancestor `[data-agent-style]` attribute (AgentChatPage) —
* see the 智能体专属落地页风格 block in globals.css.
*/
export function AgentWelcome({
className,
agent,
agentName,
styleIndex,
}: {
className?: string;
agent: Agent | null | undefined;
agentName: string;
/** 仅自定义业务深链入口传入(风格分配完成后的档位;未分配完成时为
* undefined):启用按风格轮换的头像图标;缺省保持全局原样的 BotIcon。 */
styleIndex?: number;
}) {
const displayName = desensitize(agent?.name ?? agentName);
const description = agent?.description
? desensitize(agent.description)
: undefined;
const styleIcon =
styleIndex === undefined
? BotIcon
: (STYLE_ICONS[styleIndex % STYLE_ICONS.length] ?? BotIcon);
const StyleIcon = styleIcon;
return (
<div
@@ -70,15 +35,15 @@ export function AgentWelcome({
className,
)}
>
<div className="agent-avatar rounded-3xl mb-2 flex h-[72px] w-[72px] items-center justify-center">
<StyleIcon className="h-9 w-9" />
<div className="agent-avatar bg-primary/10 ring-primary/15 mb-2 flex h-[72px] w-[72px] items-center justify-center rounded-3xl ring-1">
<BotIcon className="text-primary h-9 w-9" />
</div>
<div className="agent-welcome-name text-3xl font-bold tracking-tight">
<div className="text-3xl font-bold tracking-tight">
Hi,我是{displayName}
</div>
{description && (
<p
className="agent-welcome-description text-muted-foreground line-clamp-2 max-w-xl text-base leading-relaxed"
className="text-muted-foreground line-clamp-2 max-w-xl text-base leading-relaxed"
title={description}
>
{description}
@@ -1,43 +0,0 @@
"use client";
import agentAvatarDark from "@/assets/agents-plaza/blue/robot.png";
import agentAvatarLight from "@/assets/agents-plaza/robot-orange.png";
import { useTheme } from "@/contexts/ThemeContext";
import { cn } from "@/lib/utils";
type AgentBrandIconProps = {
className?: string;
size?: "md" | "lg";
};
const SIZE_STYLES = {
md: "size-12",
lg: "size-16",
} as const;
/** The master-zl agent gallery mark, switching artwork with the app theme. */
export function AgentBrandIcon({
className,
size = "md",
}: AgentBrandIconProps) {
const { theme } = useTheme();
const avatarSrc = theme === "light" ? agentAvatarLight : agentAvatarDark;
return (
<span
aria-hidden="true"
className={cn(
"relative inline-flex shrink-0 overflow-hidden rounded-full",
SIZE_STYLES[size],
className,
)}
>
<img
src={avatarSrc}
alt=""
className="size-full object-contain"
draggable={false}
/>
</span>
);
}
@@ -1,6 +1,7 @@
"use client";
import {
BotIcon,
ClockIcon,
CopyIcon,
EyeIcon,
@@ -8,7 +9,6 @@ import {
GlobeIcon,
LockIcon,
MessageSquareIcon,
MoreHorizontalIcon,
PinIcon,
ShieldIcon,
SparklesIcon,
@@ -27,7 +27,7 @@ import {
useState,
type ReactNode,
} from "react";
import { confirmAction, toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
@@ -47,13 +47,6 @@ import {
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Input } from "@/components/ui/input";
import {
Select,
@@ -101,10 +94,10 @@ import { formatDateTime } from "@/core/utils/datetime";
import { desensitize } from "@/lib/desensitize";
import { cn } from "@/lib/utils";
import { AgentBrandIcon } from "./agent-brand-icon";
interface AgentCardProps {
agent: Agent;
/** Optional visual state supplied by management surfaces (for example selection). */
className?: string;
/** "card" (default) renders the full gallery card; "list" renders a compact
* single-row layout for the list view. All dialogs/actions are shared. */
layout?: "card" | "list";
@@ -229,6 +222,7 @@ function ClampedBadgeRow({ items }: { items: BadgeItem[] }) {
export function AgentCard({
agent,
className,
layout = "card",
onPublisherClick,
onToggleHidden,
@@ -506,7 +500,7 @@ export function AgentCard({
setPublishPickerOpen(true);
return;
}
if (!(await warnIfAccountSwitched())) {
if (!warnIfAccountSwitched()) {
return;
}
try {
@@ -524,22 +518,18 @@ export function AgentCard({
// 发布操作以实时 token 执行。若会话中途账号被切换(常见于另一标签页登录了别的
// 账号),先弹一次确认 —— 避免误以本人之外的账号执行发布。返回 false = 用户取消。
function warnIfAccountSwitched(): boolean | Promise<boolean> {
function warnIfAccountSwitched(): boolean {
if (!live.switched) {
return true;
}
return confirmAction(
return window.confirm(
`当前登录账号已从「${live.mountDisplayName}」切换为「${live.displayName}」。\n` +
`本次发布将以「${live.displayName}」执行。如需以「${live.mountDisplayName}」操作,请取消并刷新页面。`,
{
title: "登录账号已切换",
confirmText: "继续发布",
},
`本次发布将以「${live.displayName}」执行。如需以「${live.mountDisplayName}」操作,请取消并刷新页面。\n\n仍要继续吗?`,
);
}
async function handlePublishToSquare(squareId: string) {
if (!(await warnIfAccountSwitched())) {
if (!warnIfAccountSwitched()) {
return;
}
try {
@@ -621,12 +611,6 @@ export function AgentCard({
// both the card header and the compact list row.
const statusBadges = (
<>
{isPinned && (
<Badge className="border border-primary/20 bg-primary/5 px-2.5 py-1 text-xs font-medium text-primary hover:bg-primary/5 dark:border-primary/40 dark:bg-primary/15">
<PinIcon className="mr-1 size-3.5 fill-current" />
置顶
</Badge>
)}
{isBuiltin && (
<Badge variant="secondary" className="text-xs">
内置
@@ -749,12 +733,7 @@ export function AgentCard({
...(agent.tool_groups ?? []).map((group) => ({
key: `tg:${group}`,
node: (
<Badge
key={`tg:${group}`}
variant="outline"
className="rounded-full border-border/50 bg-muted/40 text-muted-foreground text-xs"
title="工具组"
>
<Badge key={`tg:${group}`} variant="outline" className="text-xs">
{desensitize(group)}
</Badge>
),
@@ -764,8 +743,8 @@ export function AgentCard({
node: (
<Badge
key={`sk:${skill}`}
variant="outline"
className="cursor-pointer rounded-full border-primary/20 bg-primary/5 text-primary hover:border-primary/40 hover:bg-primary/15 text-xs"
variant="secondary"
className="hover:bg-secondary/70 cursor-pointer text-xs"
title={t.settings.skills.viewDetailAction}
onClick={(e) => {
e.stopPropagation();
@@ -940,193 +919,75 @@ export function AgentCard({
const chatButton = (
<Button
variant={isList ? "default" : "outline"}
size="sm"
className={cn(
isList
? "shrink-0 rounded-xl bg-primary px-4 font-medium text-primary-foreground hover:bg-primary/90"
: "h-11 w-full rounded-lg border-primary/35 bg-background font-medium text-primary shadow-none hover:border-primary/55 hover:bg-primary/5 dark:bg-slate-900",
)}
className={cn(isList ? "shrink-0" : "w-full")}
onClick={() => void handleChat()}
>
<MessageSquareIcon className="mr-1.5 h-3.5 w-3.5" />
{isList ? t.agents.chat : "开始对话"}
{t.agents.chat}
</Button>
);
const cardStatusBadge = (
<>
{agent.is_private ? (
<Badge className="border-0 bg-purple-50 px-2.5 py-1 text-xs font-normal text-purple-600 hover:bg-purple-50 dark:bg-purple-500/15 dark:text-purple-300">
<span className="mr-1.5 size-1.5 rounded-full bg-purple-500" />
私密
</Badge>
) : agent.published || isBuiltin ? (
<Badge className="border-0 bg-primary/5 px-2.5 py-1 text-xs font-normal text-primary hover:bg-primary/5 dark:bg-primary/15">
<span className="mr-1.5 size-1.5 rounded-full bg-primary" />
已发布
</Badge>
) : (
<Badge className="border-0 bg-emerald-50 px-2.5 py-1 text-xs font-normal text-emerald-600 hover:bg-emerald-50 dark:bg-emerald-500/15 dark:text-emerald-300">
<span className="mr-1.5 size-1.5 rounded-full bg-emerald-500" />
运行中
</Badge>
)}
</>
);
const updatedAtText = formatDateTime(agent.updated_at ?? agent.created_at);
const cardActionsMenu = (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
size="icon"
variant="ghost"
className="size-8 rounded-lg text-slate-500 hover:bg-slate-100 hover:text-slate-900 dark:hover:bg-slate-800 dark:hover:text-white"
title="更多操作"
>
<MoreHorizontalIcon className="size-5" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-44">
{canFavorite && (
<DropdownMenuItem onSelect={() => void handleToggleFavorite()}>
<StarIcon className={cn("size-4", isFavorite && "fill-current text-amber-500")} />
{isFavorite ? "取消收藏" : "收藏到我的"}
</DropdownMenuItem>
)}
<DropdownMenuItem onSelect={() => void handleTogglePin()}>
<PinIcon className={cn("size-4", isPinned && "fill-current text-emerald-600")} />
{isPinned ? "取消置顶" : "置顶"}
</DropdownMenuItem>
{isAdmin && (
<DropdownMenuItem onSelect={() => void handleToggleFeatured()}>
<SparklesIcon className="size-4" />
{agent.featured_order != null ? "取消推荐" : "设为推荐"}
</DropdownMenuItem>
)}
<DropdownMenuItem onSelect={() => setTagPickerOpen(true)}>
<TagsIcon className="size-4" />
{t.adminTags.manageTags}
</DropdownMenuItem>
{isOwned && (
<DropdownMenuItem onSelect={() => void handleTogglePublished()}>
{agent.published ? <LockIcon className="size-4" /> : <GlobeIcon className="size-4" />}
{agent.published ? "取消发布" : "发布"}
</DropdownMenuItem>
)}
{(isOwned || isAdmin) && (
<DropdownMenuItem onSelect={() => void handleTogglePrivate()}>
<ShieldIcon className="size-4" />
{agent.is_private ? "移出私密广场" : "放入私密广场"}
</DropdownMenuItem>
)}
{onToggleHidden && (
<DropdownMenuItem
disabled={toggleHiddenPending}
onSelect={() => void onToggleHidden(!agent.hidden)}
>
{agent.hidden ? <EyeIcon className="size-4" /> : <EyeOffIcon className="size-4" />}
{agent.hidden ? "恢复展示" : "隐藏智能体"}
</DropdownMenuItem>
)}
<DropdownMenuSeparator />
<DropdownMenuItem onSelect={() => void handleDuplicate()}>
<CopyIcon className="size-4" />
复制智能体
</DropdownMenuItem>
{canEdit && (
<DropdownMenuItem onSelect={() => setEditOpen(true)}>
<SquarePenIcon className="size-4" />
编辑智能体
</DropdownMenuItem>
)}
{canDelete && (
<>
<DropdownMenuSeparator />
<DropdownMenuItem
className="text-destructive focus:text-destructive"
onSelect={() => setDeleteOpen(true)}
>
<Trash2Icon className="size-4" />
{t.agents.delete}
</DropdownMenuItem>
</>
)}
</DropdownMenuContent>
</DropdownMenu>
);
const cardLayout = (
<Card
className={cn(
"group flex min-h-[300px] min-w-0 flex-col gap-0 overflow-hidden rounded-[5px] border-0 bg-gradient-to-br from-primary/[0.04] via-card to-card py-0 shadow-[0_2px_8px_rgba(15,23,42,0.06)] transition-[background-color,border-color,box-shadow] duration-200 hover:!shadow-[0_4px_14px_rgba(15,23,42,0.10)] dark:from-primary/[0.07] dark:via-card dark:to-card",
(agent.featured_order != null || agent.is_pinned) && "ring-1 ring-primary/25",
"group flex min-w-0 flex-col transition-[border-color,box-shadow,background-color] hover:shadow-md",
agent.hidden && "opacity-60",
className,
)}
data-agent-guide="agent-card"
>
<CardHeader className="min-w-0 gap-0 px-5 pb-2 pt-5">
{(isPinned || agent.featured_order != null) && (
<div className="mb-2 flex h-7 items-center justify-between">
<div className="flex min-w-0 items-center gap-2">
{isPinned && (
<Badge className="border border-primary/20 bg-primary/5 px-2.5 py-1 text-xs font-medium text-primary hover:bg-primary/5 dark:border-primary/40 dark:bg-primary/15">
<PinIcon className="mr-1 size-3.5 fill-current" />
置顶
</Badge>
)}
{agent.featured_order != null && (
<Badge className="border border-primary/20 bg-primary/5 px-2.5 py-1 text-xs font-medium text-primary hover:bg-primary/5 dark:border-primary/40 dark:bg-primary/15">
<SparklesIcon className="mr-1 size-3.5 fill-current" />
推荐
</Badge>
)}
<CardHeader className="min-w-0 pb-2">
<div className="flex min-w-0 items-start justify-between gap-2">
<div className="flex min-w-0 flex-1 items-center gap-2 overflow-hidden">
<div className="agent-avatar bg-primary/10 text-primary flex h-9 w-9 shrink-0 items-center justify-center rounded-lg">
<BotIcon className="h-5 w-5" />
</div>
{cardActionsMenu}
</div>
)}
{/* 标题与 logo 同行,避免头部留白过高 */}
<div className="flex w-full items-start justify-between gap-3">
<div className="flex min-w-0 flex-1 items-center gap-3">
<AgentBrandIcon size="lg" className="shrink-0" />
<div className="min-w-0 flex-1 overflow-hidden">
<CardTitle
className="min-w-0 flex-1 overflow-hidden text-[17px] leading-6 font-semibold tracking-[-0.015em] text-ellipsis whitespace-nowrap text-slate-950 dark:text-white"
className="block w-full min-w-0 overflow-hidden text-base text-ellipsis whitespace-nowrap"
title={desensitize(agent.name)}
>
{desensitize(agent.name)}
</CardTitle>
{agent.model && (
<Badge variant="secondary" className="mt-0.5 text-xs">
{desensitize(agent.model)}
</Badge>
)}
</div>
</div>
<div className="flex shrink-0 flex-wrap items-center justify-end gap-1">
{statusBadges}
</div>
{!isPinned && agent.featured_order == null && cardActionsMenu}
</div>
{agent.description && (
<CardDescription className="mt-2 line-clamp-2 text-[14px] leading-[22px] text-slate-600 dark:text-slate-400">
<CardDescription className="mt-2 line-clamp-2 text-sm">
{desensitize(agent.description)}
</CardDescription>
)}
{(agent.tags?.length ?? 0) > 0 && (
<div className="mt-2.5">
<TagChipList tags={agent.tags!} />
</div>
)}
{publisherNode && <div className="mt-2">{publisherNode}</div>}
{createdAtNode && <div className="mt-1">{createdAtNode}</div>}
</CardHeader>
{(agent.tags?.length ?? 0) > 0 && (
<CardContent className="pt-0 pb-2">
<TagChipList tags={agent.tags!} />
</CardContent>
)}
{hasSkillsOrTools && (
<CardContent className="px-5 pb-2 pt-0">
<CardContent className="pt-0 pb-2">
<ClampedBadgeRow items={skillBadgeItems} />
</CardContent>
)}
<CardFooter className="mt-auto flex flex-col items-stretch gap-4 px-5 pb-4 pt-2">
<div className="flex min-w-0 items-center gap-3">
{cardStatusBadge}
<span
className="min-w-0 truncate text-xs text-slate-400"
title={updatedAtText ? `更新于 ${updatedAtText}` : undefined}
>
{updatedAtText ? `更新于 ${updatedAtText}` : ""}
</span>
<CardFooter className="mt-auto flex flex-col items-stretch gap-2 pt-2">
{showActionRow && (
<div className="flex flex-wrap items-center justify-end gap-1">
{actionButtons}
</div>
)}
{chatButton}
</CardFooter>
</Card>
@@ -1135,14 +996,15 @@ export function AgentCard({
const listLayout = (
<div
className={cn(
"group flex min-w-0 items-center gap-3 rounded-[5px] border-0 p-2.5 shadow-[0_2px_8px_rgba(15,23,42,0.06)] transition-shadow hover:shadow-[0_4px_14px_rgba(15,23,42,0.10)]",
"bg-gradient-to-br from-primary/[0.04] via-card to-card dark:from-primary/[0.07] dark:via-card dark:to-card",
agent.is_pinned && "ring-1 ring-primary/25",
"group flex min-w-0 items-center gap-3 rounded-lg border p-2.5 transition-[border-color,box-shadow,background-color] hover:shadow-sm dark:border-[#213D5E] dark:bg-[#02244C]",
agent.hidden && "opacity-60",
className,
)}
data-agent-guide="agent-card"
>
<AgentBrandIcon size="md" className="agent-avatar" />
<div className="agent-avatar bg-primary/10 text-primary flex h-9 w-9 shrink-0 items-center justify-center rounded-lg">
<BotIcon className="h-5 w-5" />
</div>
<div className="min-w-0 flex-1 overflow-hidden">
<div className="flex min-w-0 items-center gap-2">
<span
@@ -21,7 +21,7 @@ import {
import Link from "next/link";
import { useParams, usePathname, useRouter } from "next/navigation";
import { useCallback, useEffect, useMemo, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { agentColor } from "@/components/workspace/agent-icon-color";
import { Button } from "@/components/ui/button";
@@ -6,7 +6,6 @@ import {
CheckIcon,
DatabaseIcon,
GlobeIcon,
GripVertical,
InfoIcon,
// Link2Icon,
Loader2Icon,
@@ -24,17 +23,8 @@ import {
XIcon,
} from "lucide-react";
import { useRouter } from "next/navigation";
import {
useCallback,
useEffect,
useMemo,
useRef,
useState,
type KeyboardEvent as ReactKeyboardEvent,
type PointerEvent as ReactPointerEvent,
type ReactNode,
} from "react";
import { confirmAction, toast } from "@/core/ui/feedback";
import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
import { toast } from "sonner";
// import { AgentChatLinkFields } from "@/components/workspace/agents/agent-chat-link-fields";
import { Badge } from "@/components/ui/badge";
@@ -89,30 +79,6 @@ import { usePublishSquares } from "@/core/system-settings/hooks";
import { desensitize } from "@/lib/desensitize";
import { cn } from "@/lib/utils";
const AGENT_DETAIL_WIDTH_STORAGE_KEY = "workspace:agent-detail-panel-width";
const AGENT_DETAIL_MIN_WIDTH = 280;
const AGENT_DETAIL_DEFAULT_WIDTH = 360;
const AGENT_DETAIL_MAX_WIDTH = 640;
const AGENT_DETAIL_KEYBOARD_STEP = 16;
function readStoredAgentDetailWidth(): number {
if (typeof window === "undefined") return AGENT_DETAIL_DEFAULT_WIDTH;
const raw = window.localStorage.getItem(AGENT_DETAIL_WIDTH_STORAGE_KEY);
if (!raw) return AGENT_DETAIL_DEFAULT_WIDTH;
const parsed = Number(raw);
return Number.isFinite(parsed)
? Math.min(AGENT_DETAIL_MAX_WIDTH, Math.max(AGENT_DETAIL_MIN_WIDTH, Math.round(parsed)))
: AGENT_DETAIL_DEFAULT_WIDTH;
}
function maximumAgentDetailWidth(): number {
const viewportBound = Math.max(
AGENT_DETAIL_MIN_WIDTH,
window.innerWidth - 520,
);
return Math.min(AGENT_DETAIL_MAX_WIDTH, viewportBound);
}
/** Local edit-mode draft — committed in one `updateAgent` call on 保存. */
interface AgentDraft {
@@ -162,7 +128,7 @@ function Section({
children: ReactNode;
}) {
return (
<section className={cn("agent-detail-section bg-card/60 rounded-xl border p-4", className)}>
<section className={cn("bg-card/60 rounded-xl border p-4", className)}>
<div className="mb-3 flex items-center justify-between gap-2">
<h4 className="text-foreground flex items-center gap-1.5 text-sm font-semibold">
{icon}
@@ -259,109 +225,6 @@ export function AgentDetailPanel({
if (collapsedProp === undefined) setInternalCollapsed(next);
onCollapsedChange?.(next);
};
// 智能体问答页的右侧信息栏可拖宽。宽度记在本面板,不走对话/预览那条分隔条。
const [panelWidth, setPanelWidth] = useState(readStoredAgentDetailWidth);
const [isResizingPanel, setIsResizingPanel] = useState(false);
const panelResizeStart = useRef<{ x: number; width: number } | null>(null);
const latestPanelWidth = useRef(panelWidth);
const bodyStyleBeforeResize = useRef<{ cursor: string; userSelect: string } | null>(null);
const constrainPanelWidth = useCallback(
(width: number) =>
Math.min(
maximumAgentDetailWidth(),
Math.max(AGENT_DETAIL_MIN_WIDTH, Math.round(width)),
),
[],
);
const setAndPersistPanelWidth = useCallback(
(width: number, persist = false) => {
const next = constrainPanelWidth(width);
latestPanelWidth.current = next;
setPanelWidth(next);
if (persist) {
window.localStorage.setItem(AGENT_DETAIL_WIDTH_STORAGE_KEY, String(next));
}
},
[constrainPanelWidth],
);
const finishPanelResize = useCallback(() => {
const previousBodyStyle = bodyStyleBeforeResize.current;
if (previousBodyStyle) {
document.body.style.cursor = previousBodyStyle.cursor;
document.body.style.userSelect = previousBodyStyle.userSelect;
bodyStyleBeforeResize.current = null;
}
panelResizeStart.current = null;
setIsResizingPanel(false);
window.localStorage.setItem(
AGENT_DETAIL_WIDTH_STORAGE_KEY,
String(latestPanelWidth.current),
);
}, []);
const handlePanelResizeStart = useCallback(
(event: ReactPointerEvent<HTMLElement>) => {
if (event.button !== 0) return;
event.preventDefault();
event.stopPropagation();
event.currentTarget.setPointerCapture(event.pointerId);
const width = constrainPanelWidth(latestPanelWidth.current);
latestPanelWidth.current = width;
panelResizeStart.current = { x: event.clientX, width };
bodyStyleBeforeResize.current = {
cursor: document.body.style.cursor,
userSelect: document.body.style.userSelect,
};
document.body.style.cursor = "col-resize";
document.body.style.userSelect = "none";
setIsResizingPanel(true);
},
[constrainPanelWidth],
);
const handlePanelResizeMove = useCallback(
(event: ReactPointerEvent<HTMLElement>) => {
if (!panelResizeStart.current || event.buttons !== 1) return;
// 面板在右侧:向左拖变宽,向右拖变窄。
setAndPersistPanelWidth(
panelResizeStart.current.width - (event.clientX - panelResizeStart.current.x),
);
},
[setAndPersistPanelWidth],
);
const handlePanelResizeEnd = useCallback(
(event: ReactPointerEvent<HTMLElement>) => {
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
event.currentTarget.releasePointerCapture(event.pointerId);
}
if (!panelResizeStart.current) return;
finishPanelResize();
},
[finishPanelResize],
);
const handlePanelResizeKeyDown = useCallback(
(event: ReactKeyboardEvent<HTMLElement>) => {
if (event.key === "ArrowLeft") {
event.preventDefault();
setAndPersistPanelWidth(latestPanelWidth.current + AGENT_DETAIL_KEYBOARD_STEP, true);
} else if (event.key === "ArrowRight") {
event.preventDefault();
setAndPersistPanelWidth(latestPanelWidth.current - AGENT_DETAIL_KEYBOARD_STEP, true);
} else if (event.key === "Home") {
event.preventDefault();
setAndPersistPanelWidth(AGENT_DETAIL_MIN_WIDTH, true);
} else if (event.key === "End") {
event.preventDefault();
setAndPersistPanelWidth(maximumAgentDetailWidth(), true);
}
},
[setAndPersistPanelWidth],
);
const [mobileOpen, setMobileOpen] = useState(false);
const [editing, setEditing] = useState(false);
const [draft, setDraft] = useState<AgentDraft | null>(null);
@@ -581,7 +444,7 @@ export function AgentDetailPanel({
setPublishPickerOpen(true);
return;
}
if (!(await warnIfAccountSwitched())) {
if (!warnIfAccountSwitched()) {
return;
}
try {
@@ -599,23 +462,19 @@ export function AgentDetailPanel({
// 发布以实时 token 执行。会话中途账号被切换(常见于另一标签页登录了别的账号)时
// 先弹确认,避免误以本人之外的账号执行发布。返回 false = 用户取消。
function warnIfAccountSwitched(): boolean | Promise<boolean> {
function warnIfAccountSwitched(): boolean {
if (!live.switched) {
return true;
}
return confirmAction(
return window.confirm(
`当前登录账号已从「${live.mountDisplayName}」切换为「${live.displayName}」。\n` +
`本次发布将以「${live.displayName}」执行。如需以「${live.mountDisplayName}」操作,请取消并刷新页面。`,
{
title: "登录账号已切换",
confirmText: "继续发布",
},
`本次发布将以「${live.displayName}」执行。如需以「${live.mountDisplayName}」操作,请取消并刷新页面。\n\n仍要继续吗?`,
);
}
async function handlePublishToSquare(squareId: string) {
if (!agent) return;
if (!(await warnIfAccountSwitched())) {
if (!warnIfAccountSwitched()) {
return;
}
try {
@@ -766,7 +625,7 @@ export function AgentDetailPanel({
) : (
<div className="space-y-4 px-4 py-4">
{/* ── Identity / 基础信息 ─────────────────────────────────────────── */}
<section className="agent-detail-section agent-detail-identity bg-card/60 rounded-xl border p-4">
<section className="bg-card/60 rounded-xl border p-4">
<div className="flex items-start gap-3">
<div className="agent-avatar bg-primary/10 ring-primary/15 flex size-12 shrink-0 items-center justify-center rounded-2xl ring-1">
{avatarSrc ? (
@@ -787,7 +646,7 @@ export function AgentDetailPanel({
/>
) : (
<div
className="agent-detail-name truncate text-base font-bold"
className="truncate text-base font-bold"
title={displayName}
>
{displayName}
@@ -822,7 +681,7 @@ export function AgentDetailPanel({
className="min-h-16 text-sm"
/>
) : agent.description ? (
<p className="agent-detail-description text-muted-foreground text-sm leading-relaxed">
<p className="text-muted-foreground text-sm leading-relaxed">
{desensitize(agent.description)}
</p>
) : (
@@ -996,7 +855,7 @@ export function AgentDetailPanel({
<button
type="button"
onClick={beginEdit}
className="agent-detail-empty-add text-muted-foreground hover:text-foreground hover:border-border w-full rounded-lg border border-dashed px-3 py-4 text-center text-xs transition-colors"
className="text-muted-foreground hover:text-foreground hover:border-border w-full rounded-lg border border-dashed px-3 py-4 text-center text-xs transition-colors"
>
<PlusIcon className="mr-1 inline size-3.5 align-[-2px]" />
添加常用问题
@@ -1008,7 +867,7 @@ export function AgentDetailPanel({
return (
<div
key={index}
className="agent-detail-question-item border-border/60 bg-background/60 rounded-xl border p-2"
className="border-border/60 bg-background/60 rounded-xl border p-2"
>
{isEditingThis ? (
<div className="space-y-2">
@@ -1186,17 +1045,11 @@ export function AgentDetailPanel({
header「新对话」按钮右侧。 */
<div
className={cn(
"relative hidden h-full shrink-0 lg:block",
isResizingPanel ? "transition-none" : "transition-[width] duration-300 ease-in-out",
collapsed && "pointer-events-none",
"hidden h-full shrink-0 overflow-hidden transition-[width] duration-300 ease-in-out lg:block",
collapsed ? "w-0" : "w-[360px]",
)}
style={{ width: collapsed ? 0 : panelWidth }}
>
<div className="h-full overflow-hidden">
<aside
className="bg-card/40 flex h-full flex-col border-l"
style={{ width: panelWidth }}
>
<aside className="bg-card/40 flex h-full w-[360px] flex-col border-l">
{panelChrome(
<Tooltip content="收起">
<Button
@@ -1212,39 +1065,6 @@ export function AgentDetailPanel({
)}
</aside>
</div>
{!collapsed && (
<div className="group/detail-edge absolute inset-y-0 -left-1 z-30 w-8 cursor-default">
<div
role="separator"
aria-orientation="vertical"
aria-label="调整智能体信息宽度"
aria-valuenow={panelWidth}
aria-valuemin={AGENT_DETAIL_MIN_WIDTH}
aria-valuemax={AGENT_DETAIL_MAX_WIDTH}
tabIndex={0}
title="拖拽调整智能体信息宽度"
className="absolute top-1/2 left-1 z-30 flex h-16 w-10 -translate-x-1/2 -translate-y-1/2 cursor-col-resize touch-none items-center justify-center outline-none"
onPointerDown={handlePanelResizeStart}
onPointerMove={handlePanelResizeMove}
onPointerUp={handlePanelResizeEnd}
onPointerCancel={handlePanelResizeEnd}
onKeyDown={handlePanelResizeKeyDown}
>
<span
aria-hidden="true"
className={cn(
"bg-border pointer-events-none z-10 flex h-8 w-4 items-center justify-center rounded-sm border shadow-sm transition-opacity",
isResizingPanel
? "opacity-100"
: "opacity-0 group-hover/detail-edge:opacity-100 group-focus-within/detail-edge:opacity-100",
)}
>
<GripVertical className="size-3.5" />
</span>
</div>
</div>
)}
</div>
) : collapsed ? (
<div className="hidden shrink-0 items-start border-l px-2 pt-3 lg:flex">
<div className="flex items-center gap-1">
@@ -3,20 +3,17 @@
import { ArrowDownUpIcon, BotIcon, Compass, Loader2, LockIcon, PlusIcon, RefreshCwIcon, ShieldIcon, XIcon } from "lucide-react";
import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Pagination as TPagination } from "tdesign-react";
import { Pagination } from "@/components/ui/pagination";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { TagSearchBar } from "@/components/workspace/tags/tag-search-bar";
import { ViewModeToggle } from "@/components/workspace/view-mode-toggle";
import { getStoredAuth } from "@/core/auth";
import { useAgentsPaginated, usePrivateAgentsPaginated, useSyncAgentDirectory } from "@/core/agents";
import { useLocalSettings } from "@/core/settings";
import { resolveAgentGridLayout } from "@/core/settings/agent-grid";
import { useAppearanceSettings } from "@/core/system-settings/hooks";
import type { Agent, AgentSort } from "@/core/agents";
import { useI18n } from "@/core/i18n/hooks";
import { useRouteBase } from "@/core/route-base";
@@ -267,20 +264,10 @@ export function AgentGallery({
const handlePublisherClick = (p: { id: string; label: string }) =>
setPublisher(p);
// 置顶的智能体始终排在最前(后端按创建/更新时间分页,这里做展示层重排)。
const pinFirst = (items: Agent[]) =>
[...items].sort(
(a, b) => Number(b.is_pinned ?? false) - Number(a.is_pinned ?? false),
);
const [gridSettings] = useLocalSettings();
const { data: gridAppearance } = useAppearanceSettings();
const agentGrid = resolveAgentGridLayout(gridSettings.display, gridAppearance);
const renderGrid = (list: Agent[]) =>
viewMode === "list" ? (
<div className="flex flex-col gap-2">
{pinFirst(list).map((agent) => (
{list.map((agent) => (
<AgentCard
key={agent.id}
agent={agent}
@@ -289,29 +276,9 @@ export function AgentGallery({
/>
))}
</div>
) : agentGrid.adaptive ? (
<div
className="grid w-full grid-cols-4 gap-4 min-[3072px]:grid-cols-5"
data-agent-grid="adaptive"
>
{pinFirst(list).map((agent) => (
<AgentCard
key={agent.id}
agent={agent}
onPublisherClick={handlePublisherClick}
/>
))}
</div>
) : (
<div
className="grid w-full gap-4"
data-agent-grid="fixed"
data-agent-grid-columns={agentGrid.columns}
style={{
gridTemplateColumns: `repeat(${agentGrid.columns}, minmax(0, 1fr))`,
}}
>
{pinFirst(list).map((agent) => (
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
{list.map((agent) => (
<AgentCard
key={agent.id}
agent={agent}
@@ -372,12 +339,11 @@ export function AgentGallery({
</div>
</div>
)}
<TPagination
current={pages[tab] ?? 1}
<Pagination
page={pages[tab] ?? 1}
pageSize={PAGE_SIZE}
total={total}
showJumper
onChange={(pageInfo) => setTabPage(tab, pageInfo.current)}
onPageChange={(p) => setTabPage(tab, p)}
className="pt-2"
/>
</div>
@@ -401,7 +367,7 @@ export function AgentGallery({
className="mt-2 dark:border-[#2580FF] dark:bg-[#2580FF] dark:text-white dark:hover:border-[#2580FF] dark:hover:bg-[#2580FF]/90 dark:hover:text-white"
onClick={handleNewAgent}
>
<PlusIcon className="mr-2.5 h-4 w-4" />
<PlusIcon className="mr-1.5 h-4 w-4" />
{t.agents.newAgent}
</Button>
)}
@@ -492,32 +458,22 @@ export function AgentGallery({
};
return (
<div className="flex size-full min-h-0 flex-col bg-muted/40">
<div className="flex size-full min-h-0 flex-col">
{/* Page header */}
<div className="relative overflow-hidden border-b border-border/60 bg-card px-6 py-4">
{/* 顶部主题色渐变:自上而下淡出(跟随换肤) */}
<div
className="pointer-events-none absolute inset-x-0 top-0 h-24 bg-gradient-to-b from-primary/[0.09] via-primary/[0.03] to-transparent"
aria-hidden
/>
<div className="relative flex items-center justify-between gap-4">
<div className="flex items-center justify-between border-b px-6 py-4">
<div>
<div className="flex items-center gap-2">
<span className="h-4 w-[3px] rounded-full bg-primary" aria-hidden />
<h1 className="text-xl font-semibold">
{pageDescription?.title || t.agents.title}
</h1>
</div>
<p className="text-muted-foreground mt-0.5 text-sm">
{pageDescription?.description || t.agents.description}
</p>
</div>
<div className="flex items-center gap-1.5">
<div className="flex items-center gap-2">
{isAdmin && (
<Button
variant="ghost"
variant="outline"
size="sm"
className="h-9 gap-2.5 rounded-[5px] px-3 text-muted-foreground hover:bg-muted hover:text-foreground"
title="扫描 .deer-flow/agents 目录,把目录里的智能体同步进列表"
disabled={syncDirectory.isPending}
onClick={() => {
@@ -536,15 +492,14 @@ export function AgentGallery({
}}
>
<RefreshCwIcon
className={`h-4 w-4 ${syncDirectory.isPending ? "animate-spin" : ""}`}
className={`mr-1.5 h-4 w-4 ${syncDirectory.isPending ? "animate-spin" : ""}`}
/>
{syncDirectory.isPending ? "扫描中…" : "重新扫描智能体目录"}
</Button>
)}
<Button
variant="ghost"
variant="outline"
size="sm"
className="h-9 rounded-[5px] px-3 text-muted-foreground hover:bg-muted hover:text-foreground"
title="打开智能体广场视图"
onClick={() => router.push(`${routeBase}/agents/plaza`)}
>
@@ -553,24 +508,19 @@ export function AgentGallery({
<Button
variant="ghost"
size="sm"
className="h-9 gap-2.5 rounded-[5px] px-3 text-muted-foreground hover:bg-muted hover:text-foreground"
className="text-muted-foreground hover:text-foreground"
title="重新播放智能体使用引导"
onClick={() => startAgentGuide("list")}
>
<Compass className="h-4 w-4" />
<Compass className="mr-1.5 h-4 w-4" />
使用引导
</Button>
<Button
className="ml-1 h-9 gap-2.5 rounded-[5px] px-4 shadow-[0_2px_6px_rgba(193,18,31,0.25)] hover:shadow-[0_4px_12px_rgba(193,18,31,0.35)]"
onClick={handleNewAgent}
data-agent-guide="new-agent-btn"
>
<PlusIcon className="h-4 w-4" />
<Button onClick={handleNewAgent} data-agent-guide="new-agent-btn">
<PlusIcon className="mr-1.5 h-4 w-4" />
{t.agents.newAgent}
</Button>
</div>
</div>
</div>
{/* Tabs */}
<Tabs
@@ -8,7 +8,7 @@ import {
Trash2Icon,
} from "lucide-react";
import { useMemo, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -2,7 +2,7 @@
import { Bot, Loader2 } from "lucide-react";
import { useEffect, useMemo, useRef, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Select } from "tdesign-react";
import { Button } from "@/components/ui/button";
@@ -87,12 +87,12 @@ export function EnabledSkillList({
<div
key={name}
className={cn(
"agent-skill-row group/skill bg-background/60 flex items-start gap-2.5 rounded-xl border p-2.5 transition-colors",
"group/skill bg-background/60 flex items-start gap-2.5 rounded-xl border p-2.5 transition-colors",
onViewDetail && "hover:border-primary/40 hover:bg-accent/40",
offline && "bg-muted/60 border-dashed dark:bg-[#071D36]",
)}
>
<div className="agent-skill-avatar bg-primary/10 text-primary flex size-8 shrink-0 items-center justify-center rounded-lg text-sm font-semibold">
<div className="bg-primary/10 text-primary flex size-8 shrink-0 items-center justify-center rounded-lg text-sm font-semibold">
{skill ? skillInitial(skill) : "?"}
</div>
<div className="min-w-0 flex-1">
@@ -1,7 +1,7 @@
"use client";
import { useEffect, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -10,7 +10,7 @@ import {
XIcon,
} from "lucide-react";
import { useMemo, useRef, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
@@ -43,7 +43,7 @@ const triggerToneClass = (tone: AppearanceControlTone) =>
tone === "banner-dark"
? "text-slate-400 hover:bg-slate-800/50 hover:text-slate-400"
: tone === "banner-light"
? "text-white hover:bg-[var(--brand-900)] hover:text-white active:bg-[var(--brand-950)]"
? "text-white hover:bg-[var(--brand-950)] hover:text-white active:bg-[#8a0618]"
: tone === "banner-custom"
? "text-[var(--navigation-foreground)] hover:bg-white/20 hover:text-[var(--navigation-foreground)] active:bg-white/30"
: "text-muted-foreground hover:bg-muted hover:text-foreground";
@@ -21,7 +21,7 @@ import { useParams } from "next/navigation";
import { useNavigate } from "react-router-dom";
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
import type { AnchorHTMLAttributes, HTMLAttributes, ReactNode } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { defaultUrlTransform } from "react-markdown";
import {
@@ -1,6 +1,6 @@
import { DownloadIcon, LoaderIcon, PackageIcon } from "lucide-react";
import { useCallback, useState, type ReactNode } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -7,7 +7,7 @@ import {
useState,
type ReactNode,
} from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { useSidebarSafe } from "@/components/ui/sidebar";
import { env } from "@/env";
@@ -2,7 +2,7 @@
import { AlertCircleIcon, Loader2Icon, PackageIcon } from "lucide-react";
import { useEffect, useMemo, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -1,22 +0,0 @@
import historyChatAvatar from "@/assets/img/chat-history-avatar.png";
import historyCloudAvatar from "@/assets/img/chat-history-cloud-avatar.png";
import historyDeviceAvatar from "@/assets/img/chat-history-device-avatar.png";
const CHAT_HISTORY_AVATARS = [
historyChatAvatar,
historyCloudAvatar,
historyDeviceAvatar,
] as const;
/**
* Conversations do not carry an avatar in persisted state. Derive one from
* the stable thread id, so each history row keeps its mark across refreshes
* while the list uses varied purple, green, and blue artwork.
*/
export function historyAvatarForThread(threadId: string): string {
let hash = 0;
for (let index = 0; index < threadId.length; index += 1) {
hash = (hash * 31 + threadId.charCodeAt(index)) | 0;
}
return CHAT_HISTORY_AVATARS[(hash >>> 0) % CHAT_HISTORY_AVATARS.length]!;
}
@@ -0,0 +1,258 @@
"use client";
import { useQueryClient } from "@tanstack/react-query";
import { Loader2, Upload } from "lucide-react";
import { useRef, useState } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { Progress } from "@/components/ui/progress";
import {
exportAllThreadsInBackground,
importTransferThreads,
parseTransferBundle,
skipReasonLabel,
type SkippedThread,
type TransferProgress,
} from "@/core/threads/transfer";
function ProgressPanel({
progress,
label,
}: {
progress: TransferProgress | null;
label: string;
}) {
if (!progress) {
return (
<div className="text-muted-foreground flex items-center gap-2 py-6 text-sm">
<Loader2 className="size-4 animate-spin" />
{label}
</div>
);
}
const percent =
progress.total > 0
? Math.round((progress.processed / progress.total) * 100)
: 0;
return (
<div className="space-y-3 py-2">
<Progress value={percent} />
<p className="text-sm text-neutral-600">
已处理 {progress.processed} / {progress.total} 条,成功{" "}
{progress.succeeded},跳过 {progress.skipped}
</p>
</div>
);
}
function SkippedList({ items }: { items: SkippedThread[] }) {
if (items.length === 0) return null;
return (
<div className="max-h-40 space-y-1 overflow-auto rounded-lg border p-2 text-xs text-neutral-600">
{items.slice(0, 20).map((item) => (
<p key={`${item.thread_id}-${item.reason}`}>
{item.title || item.thread_id}:{skipReasonLabel(item.reason)}
</p>
))}
{items.length > 20 && <p>其余 {items.length - 20} 条已省略</p>}
</div>
);
}
export function ChatHistoryExportDialog({
open,
onOpenChange,
}: {
open: boolean;
onOpenChange: (open: boolean) => void;
}) {
const [running, setRunning] = useState(false);
const [progress, setProgress] = useState<TransferProgress | null>(null);
const [skipped, setSkipped] = useState<SkippedThread[]>([]);
async function handleExport() {
if (running) return;
setRunning(true);
setProgress(null);
setSkipped([]);
try {
setProgress({
total: 0,
processed: 0,
succeeded: 0,
skipped: 0,
});
const result = await exportAllThreadsInBackground(setProgress);
setSkipped(result.skipped);
if (result.succeeded === 0) {
toast.message(
result.total === 0 ? "没有可导出的对话" : "没有成功导出的对话",
);
return;
}
const extras = [
result.skipped.length > 0 ? `跳过 ${result.skipped.length} 条` : "",
result.skipped_files > 0 ? `跳过 ${result.skipped_files} 个过大附件` : "",
].filter(Boolean);
toast.success(
extras.length > 0
? `已导出 ${result.succeeded} 条,${extras.join(",")}`
: `已导出 ${result.succeeded} 条对话`,
);
if (result.skipped.length === 0) {
onOpenChange(false);
}
} catch (error) {
toast.error(error instanceof Error ? error.message : "导出失败");
} finally {
setRunning(false);
}
}
return (
<Dialog open={open} onOpenChange={running ? undefined : onOpenChange}>
<DialogContent className="sm:max-w-md">
<DialogHeader>
<DialogTitle>导出对话记录</DialogTitle>
<DialogDescription>
后台逐条打包当前账号的对话消息和附件,进度按条前进。单条上限 50MB,超出部分会跳过大附件,消息仍导出;一条失败不影响其余记录。
</DialogDescription>
</DialogHeader>
{running || progress ? (
<ProgressPanel progress={progress} label="正在准备导出…" />
) : (
<p className="text-muted-foreground text-sm">
导出文件可拷到另一台机器,在本页「导入记录」还原。
</p>
)}
<SkippedList items={skipped} />
<div className="flex justify-end gap-2">
<Button
variant="outline"
disabled={running}
onClick={() => onOpenChange(false)}
>
取消
</Button>
<Button disabled={running} onClick={() => void handleExport()}>
{running && <Loader2 className="size-4 animate-spin" />}
{running ? "导出中" : "开始导出"}
</Button>
</div>
</DialogContent>
</Dialog>
);
}
export function ChatHistoryImportDialog({
open,
onOpenChange,
}: {
open: boolean;
onOpenChange: (open: boolean) => void;
}) {
const queryClient = useQueryClient();
const inputRef = useRef<HTMLInputElement>(null);
const [running, setRunning] = useState(false);
const [progress, setProgress] = useState<TransferProgress | null>(null);
const [skipped, setSkipped] = useState<SkippedThread[]>([]);
async function handleFile(file: File) {
if (running) return;
setRunning(true);
setProgress(null);
setSkipped([]);
try {
const threads = parseTransferBundle(await file.text());
setProgress({
total: threads.length,
processed: 0,
succeeded: 0,
skipped: 0,
});
const result = await importTransferThreads(threads, setProgress);
setSkipped(result.skipped);
void queryClient.invalidateQueries({ queryKey: ["threads"] });
if (result.imported === 0) {
toast.message(
result.skipped.length > 0
? `没有导入新对话,跳过 ${result.skipped.length} 条`
: "没有导入新对话",
);
return;
}
toast.success(
result.skipped.length > 0
? `已导入 ${result.imported} 条,跳过 ${result.skipped.length} 条`
: `已导入 ${result.imported} 条对话`,
);
if (result.skipped.length === 0) {
onOpenChange(false);
}
} catch (error) {
toast.error(error instanceof Error ? error.message : "导入失败");
} finally {
setRunning(false);
if (inputRef.current) inputRef.current.value = "";
}
}
return (
<Dialog open={open} onOpenChange={running ? undefined : onOpenChange}>
<DialogContent className="sm:max-w-md">
<DialogHeader>
<DialogTitle>导入对话记录</DialogTitle>
<DialogDescription>
选择从另一台机器导出的 JSON 文件。逐条写入,进度按条前进。已存在或失败的记录会跳过,不影响其余记录。
</DialogDescription>
</DialogHeader>
{running || progress ? (
<ProgressPanel progress={progress} label="正在读取文件…" />
) : (
<p className="text-muted-foreground text-sm">
导入后归属当前登录账号,可继续查看和提问。附件会一并还原。
</p>
)}
<SkippedList items={skipped} />
<input
ref={inputRef}
type="file"
accept="application/json,.json"
className="hidden"
onChange={(event) => {
const file = event.target.files?.[0];
if (file) void handleFile(file);
}}
/>
<div className="flex justify-end gap-2">
<Button
variant="outline"
disabled={running}
onClick={() => onOpenChange(false)}
>
取消
</Button>
<Button
disabled={running}
onClick={() => inputRef.current?.click()}
>
{running ? (
<Loader2 className="size-4 animate-spin" />
) : (
<Upload className="size-4" />
)}
{running ? "导入中" : "选择文件"}
</Button>
</div>
</DialogContent>
</Dialog>
);
}
@@ -1,6 +1,6 @@
import type { Message } from "@langchain/langgraph-sdk";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { FilesIcon, GripVertical, XIcon } from "lucide-react";
import { FilesIcon, XIcon } from "lucide-react";
import { usePathname, useSearchParams } from "next/navigation";
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import type { GroupImperativeHandle } from "react-resizable-panels";
@@ -859,48 +859,13 @@ const ChatBox: React.FC<{
</ResizablePanel>
<ResizableHandle
id={`${resizableIdBase}-separator`}
onPointerDownCapture={(event) => {
const target = event.target;
// The library starts a drag from any pointerdown inside the separator.
// Hovering the edge only reveals the grip; the grip is the only drag target.
if (!(target instanceof Element) || !target.closest("[data-resize-grip]")) {
event.stopPropagation();
}
}}
className={cn(
"group/split z-20",
stackArtifactPanel
? "h-px w-full opacity-33 hover:opacity-100 after:inset-x-0 after:inset-y-auto after:top-1/2 after:h-4 after:w-full after:-translate-x-0 after:-translate-y-1/2 after:cursor-row-resize"
: // The default hit box is a full-height strip and covers both the chat
// scrollbar and the panel on the right. The separator itself stays
// inert; only the short center grip starts a drag.
"pointer-events-none after:pointer-events-none after:w-0",
"opacity-33 hover:opacity-100",
stackArtifactPanel &&
"h-px w-full after:inset-x-0 after:inset-y-auto after:top-1/2 after:h-4 after:w-full after:-translate-x-0 after:-translate-y-1/2 after:cursor-row-resize",
!sidePanelOpen && "pointer-events-none opacity-0",
)}
>
{!stackArtifactPanel && (
<>
<span
aria-hidden="true"
className={cn(
"absolute inset-y-0 left-0 z-20 w-8 cursor-default",
sidePanelOpen ? "pointer-events-auto" : "pointer-events-none",
)}
/>
<span
data-resize-grip=""
className={cn(
"absolute top-1/2 left-1/2 z-30 flex h-16 w-10 -translate-x-1/2 -translate-y-1/2 items-center justify-center",
sidePanelOpen ? "pointer-events-auto cursor-col-resize" : "pointer-events-none",
)}
>
<span className="bg-border z-10 flex h-8 w-4 items-center justify-center rounded-sm border shadow-sm opacity-0 transition-opacity group-hover/split:opacity-100 group-focus-visible/split:opacity-100">
<GripVertical className="size-3.5" />
</span>
</span>
</>
)}
</ResizableHandle>
<ResizablePanel
className={cn(
"bg-background transition-all duration-300 ease-in-out",
@@ -1,8 +1,7 @@
"use client";
import { Download } from "lucide-react";
import { FileSpreadsheet } from "lucide-react";
import { useCallback } from "react";
import { toast } from "@/core/ui/feedback";
import { Button } from "@/components/ui/button";
import { consumerThreadMaterialsDownloadUrl } from "@/core/threads/consumer-thread-values-client";
@@ -10,33 +9,6 @@ import { consumerThreadMaterialsDownloadUrl } from "@/core/threads/consumer-thre
import { useThread } from "./messages/context";
import { Tooltip } from "./tooltip";
const MATERIALS_DOWNLOAD_FRAME_ID = "consumer-materials-download-frame";
const MATERIALS_DOWNLOAD_FRAME_NAME = "consumer-materials-download-frame";
function submitDownloadWithoutNavigation(downloadUrl: string): void {
let frame = document.getElementById(
MATERIALS_DOWNLOAD_FRAME_ID,
) as HTMLIFrameElement | null;
if (!frame) {
frame = document.createElement("iframe");
frame.id = MATERIALS_DOWNLOAD_FRAME_ID;
frame.name = MATERIALS_DOWNLOAD_FRAME_NAME;
frame.title = "资料下载";
frame.setAttribute("aria-hidden", "true");
frame.style.display = "none";
document.body.appendChild(frame);
}
const anchor = document.createElement("a");
anchor.href = downloadUrl;
anchor.target = frame.name;
anchor.download = "";
anchor.rel = "noopener";
document.body.appendChild(anchor);
anchor.click();
anchor.remove();
}
/** Downloads the Consumer-maintained source-material workbook for this chat. */
export function ConsumerMaterialsExportTrigger({
threadId,
@@ -47,13 +19,7 @@ export function ConsumerMaterialsExportTrigger({
const downloadUrl = consumerThreadMaterialsDownloadUrl(threadId);
const handleDownload = useCallback(() => {
if (!downloadUrl) return;
// The Consumer URL may be cross-origin, which makes browsers ignore an
// anchor's `download` hint and navigate the current document. Route the
// native download request through a persistent hidden frame instead, so
// the chat never leaves its current route and no extra window is opened.
submitDownloadWithoutNavigation(downloadUrl);
toast.message("正在准备资料下载…");
window.open(downloadUrl, "_blank", "noopener,noreferrer");
}, [downloadUrl]);
if (thread.messages.length === 0) return null;
@@ -69,7 +35,7 @@ export function ConsumerMaterialsExportTrigger({
disabled={!downloadUrl}
onClick={handleDownload}
>
<Download className="size-4" aria-hidden="true" />
<FileSpreadsheet />
导出资料
</Button>
</Tooltip>
@@ -1,6 +1,6 @@
import { CheckIcon, CopyIcon } from "lucide-react";
import { useCallback, useState, type ComponentProps } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { copyTextToClipboard } from "@/core/clipboard";
@@ -8,7 +8,7 @@ import {
Trash2Icon,
} from "lucide-react";
import { useCallback, useEffect, useRef, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -162,7 +162,7 @@ export function CustomPromptBar({
type="button"
variant="ghost"
size="icon"
className="agent-composer-tool text-muted-foreground hover:text-foreground hover:bg-muted/70 h-7 w-7 shrink-0 rounded-full"
className="text-muted-foreground hover:text-foreground hover:bg-muted/70 h-7 w-7 shrink-0 rounded-full"
title="管理常用提示词"
aria-label="管理常用提示词"
onClick={() => setManageOpen(true)}
@@ -2,7 +2,7 @@
import { Download, FileJson, FileText, FileType2 } from "lucide-react";
import { useCallback } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -23,6 +23,7 @@ import {
FileJson,
FileText,
Loader2,
MessageSquare,
MoreHorizontal,
Pencil,
Pin,
@@ -38,7 +39,7 @@ import Link from "next/link";
import { useParams, usePathname, useRouter, useSearchParams } from "next/navigation";
import { useCallback, useEffect, useMemo, useState } from "react";
import { useNavigate } from "react-router-dom";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Select } from "tdesign-react";
import { useTheme } from "@/contexts/ThemeContext";
@@ -105,12 +106,10 @@ import { cn } from "@/lib/utils";
import { strategyProjectWorkbenchPath } from "@/strategy-selection/project-routes";
import {
mergeRecentWorkspaceItems,
type RecentWorkspaceItem,
useRecentStrategyProjects,
} from "@/strategy-selection/recent-projects";
import { agentColor } from "./agent-icon-color";
import { historyAvatarForThread } from "./chat-history-avatar";
import { SidebarCollapseButton } from "./workspace-header";
// 智能体图标配色(按 id 稳定散列、分主题)抽到共享模块 ./agent-icon-color,
@@ -379,6 +378,7 @@ export function GeneralQaSidebar({
// 未搜索时与旧版一致:最多展示 10 条
return q ? list : list.slice(0, 10);
}, [query, recentItems, t.pages.newChat]);
const handleNewChatClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
if (event.metaKey || event.ctrlKey || event.shiftKey || event.button === 1) return;
event.preventDefault();
@@ -451,176 +451,6 @@ export function GeneralQaSidebar({
const isStatic = env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true";
const renderRecentHistoryItem = (item: RecentWorkspaceItem) => {
if (item.kind === "strategy-project") {
const { project } = item;
const href = strategyProjectWorkbenchPath(
"/page/strategy/qa/projects",
project.id,
);
const isActive = href === pathname;
return (
<div
key={`strategy-project:${project.id}`}
className="group/item relative flex items-center"
>
<Link
href={href}
title={desensitize(project.title)}
className={cn(
"gq-history-item relative flex min-h-11 min-w-0 flex-1 items-center gap-2 overflow-hidden rounded-xl px-2.5 py-1.5 text-[13px] outline-none transition-[background-color,color,box-shadow] duration-150 focus-visible:ring-2 focus-visible:ring-primary/55",
isActive
? "gq-history-item--active bg-primary/[0.11] font-medium text-primary shadow-[inset_0_0_0_1px_rgb(var(--legacy-primary-rgb)/22%),0_2px_8px_rgb(var(--legacy-primary-rgb)/7%)] hover:bg-primary/[0.15]"
: "text-foreground/80 hover:bg-muted/80 hover:text-foreground hover:shadow-[inset_0_0_0_1px_rgb(var(--legacy-primary-rgb)/9%)]",
)}
>
<MyProjectThreadIcon type="strategy" />
<span className="min-w-0 flex-1 flex flex-col items-start gap-0.5">
<span className="block w-full truncate">{desensitize(project.title)}</span>
<MyProjectThreadBadge
className="mr-3 max-w-[calc(100%_-_0.75rem)]"
projectName={project.title}
type="strategy"
/>
</span>
</Link>
</div>
);
}
const { thread } = item;
const href = buildFullChatNavigationPath(pathForThread(thread), currentSearch);
const isActive = href === pathname;
const isBoot = isBootstrapThread(thread);
const projectInfo = myProjectConversationInfoOfThread(
thread,
projectThreadNames,
);
const pinned = isThreadPinned(thread);
const favorited = isThreadFavorite(thread);
const title = desensitize(titleOfThread(thread, t.pages.newChat));
return (
<div key={`thread:${thread.thread_id}`} className="group/item relative flex items-center">
<Link
href={href}
title={title}
className={cn(
"gq-history-item relative flex h-9 min-w-0 flex-1 items-center gap-2 overflow-hidden rounded-xl px-2.5 pr-8 text-[13px] outline-none transition-[background-color,color,box-shadow] duration-150 focus-visible:ring-2 focus-visible:ring-primary/55",
projectInfo && "h-auto min-h-11 py-1.5",
isActive
? "gq-history-item--active bg-primary/[0.11] font-medium text-primary shadow-[inset_0_0_0_1px_rgb(var(--legacy-primary-rgb)/22%),0_2px_8px_rgb(var(--legacy-primary-rgb)/7%)] hover:bg-primary/[0.15]"
: "text-foreground/80 hover:bg-muted/80 hover:text-foreground hover:shadow-[inset_0_0_0_1px_rgb(var(--legacy-primary-rgb)/9%)]",
)}
>
{isBoot ? (
<Bot
className={cn(
"size-3.5 shrink-0",
isActive ? "text-primary" : "text-muted-foreground/70",
)}
aria-label="智能体创建会话"
/>
) : projectInfo ? (
<MyProjectThreadIcon type={projectInfo.type} />
) : (
<img
src={historyAvatarForThread(thread.thread_id)}
alt=""
aria-hidden="true"
draggable={false}
className="size-5 shrink-0 object-contain"
/>
)}
{pinned && (
<Pin className="size-3 shrink-0 text-muted-foreground/70" aria-label="已置顶" />
)}
<span
className={cn(
"min-w-0 flex-1",
projectInfo && "flex flex-col items-start gap-0.5",
)}
>
<span className="block w-full truncate">{title}</span>
{projectInfo && (
<MyProjectThreadBadge
className="mr-3 max-w-[calc(100%_-_0.75rem)]"
projectName={projectInfo.projectName}
type={projectInfo.type}
/>
)}
</span>
</Link>
{!isStatic && (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<button
type="button"
aria-label={`${t.common.more}:${title}`}
className="absolute right-1 flex size-7 items-center justify-center rounded-lg text-muted-foreground opacity-0 outline-none transition-[opacity,background-color,color] duration-150 hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-primary/55 group-hover/item:opacity-100 group-focus-within/item:opacity-100 data-[state=open]:bg-background data-[state=open]:text-foreground data-[state=open]:opacity-100"
>
<MoreHorizontal className="size-4" />
</button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-48 rounded-lg" side="right" align="start">
<DropdownMenuItem
onSelect={() =>
handleRenameClick(thread.thread_id, titleOfThread(thread, t.pages.newChat))
}
>
<Pencil className="text-muted-foreground" />
<span>{t.common.rename}</span>
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => togglePin(thread.thread_id, !pinned)}>
{pinned ? (
<PinOff className="text-muted-foreground" />
) : (
<Pin className="text-muted-foreground" />
)}
<span>{pinned ? t.common.unpin : t.common.pin}</span>
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => toggleFavorite(thread.thread_id, !favorited)}>
<Star
className={
favorited
? "fill-amber-400 text-amber-400"
: "text-muted-foreground"
}
/>
<span>{favorited ? t.common.unfavorite : t.common.favorite}</span>
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => setShareThreadId(thread.thread_id)}>
<Share2 className="text-muted-foreground" />
<span>{t.common.share}</span>
</DropdownMenuItem>
<DropdownMenuSub>
<DropdownMenuSubTrigger>
<Download className="text-muted-foreground" />
<span>{t.common.export}</span>
</DropdownMenuSubTrigger>
<DropdownMenuSubContent>
<DropdownMenuItem onSelect={() => handleExport(thread, "markdown")}>
<FileText className="text-muted-foreground" />
<span>{t.common.exportAsMarkdown}</span>
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => handleExport(thread, "json")}>
<FileJson className="text-muted-foreground" />
<span>{t.common.exportAsJSON}</span>
</DropdownMenuItem>
</DropdownMenuSubContent>
</DropdownMenuSub>
<DropdownMenuSeparator />
<DropdownMenuItem onSelect={() => handleDelete(thread.thread_id)}>
<Trash2 className="text-muted-foreground" />
<span>{t.common.delete}</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)}
</div>
);
};
return (
// 背景走 sidebar token(浅主题=白、浅蓝主题=浅蓝);深蓝(.dark)主题下由 gq-sidebar
// 改为「深蓝主题底图 + 半透明蓝罩」玻璃面板(见 globals.css),与右侧 workspace-chat-bg
@@ -880,7 +710,191 @@ export function GeneralQaSidebar({
{query ? "没有匹配的会话" : t.chats.noChats}
</div>
) : (
filteredRecentItems.map(renderRecentHistoryItem)
filteredRecentItems.map((item) => {
if (item.kind === "strategy-project") {
const { project } = item;
const href = strategyProjectWorkbenchPath(
"/page/strategy/qa/projects",
project.id,
);
const isActive = href === pathname;
return (
<div
key={`strategy-project:${project.id}`}
className="group/item relative flex items-center"
>
<Link
href={href}
className={cn(
"gq-history-item relative flex min-h-12 min-w-0 flex-1 items-center gap-2 rounded-lg px-2.5 py-1.5 text-[13px] transition-colors",
isActive
? "gq-history-item--active border border-primary/40 bg-primary/5 font-medium text-primary"
: "text-muted-foreground hover:bg-accent/60 hover:text-foreground",
)}
>
<MyProjectThreadIcon type="strategy" />
<span className="min-w-0 flex-1 flex flex-col items-start gap-0.5">
<span className="w-full truncate">
{desensitize(project.title)}
</span>
<MyProjectThreadBadge
className="mr-4 max-w-[calc(100%_-_1rem)]"
projectName={project.title}
type="strategy"
/>
</span>
{isActive && (
<span className="absolute top-1/2 right-1 h-5 w-1 -translate-y-1/2 rounded-full bg-primary" />
)}
</Link>
</div>
);
}
const { thread } = item;
const href = buildFullChatNavigationPath(
pathForThread(thread),
currentSearch,
);
const isActive = href === pathname;
const isBoot = isBootstrapThread(thread);
const projectInfo = myProjectConversationInfoOfThread(
thread,
projectThreadNames,
);
const pinned = isThreadPinned(thread);
const favorited = isThreadFavorite(thread);
return (
<div
key={`thread:${thread.thread_id}`}
className="group/item relative flex items-center"
>
<Link
href={href}
className={cn(
"gq-history-item relative flex h-9 min-w-0 flex-1 items-center gap-2 rounded-lg px-2.5 text-[13px] transition-colors",
projectInfo && "h-auto min-h-12 py-1.5",
isActive
? "gq-history-item--active border border-primary/40 bg-primary/5 font-medium text-primary"
: "text-muted-foreground hover:bg-accent/60 hover:text-foreground",
)}
>
{isBoot ? (
<Bot
className={cn(
"size-3.5 shrink-0",
isActive ? "text-primary" : "text-muted-foreground/70",
)}
aria-label="智能体创建会话"
/>
) : projectInfo ? (
<MyProjectThreadIcon type={projectInfo.type} />
) : (
<MessageSquare
className={cn(
"size-3.5 shrink-0",
isActive ? "text-primary" : "text-muted-foreground/70",
)}
/>
)}
{pinned && (
<Pin className="size-3 shrink-0 text-muted-foreground/70" />
)}
<span
className={cn(
"min-w-0 flex-1",
projectInfo && "flex flex-col items-start gap-0.5",
)}
>
<span className="w-full truncate">
{desensitize(titleOfThread(thread, t.pages.newChat))}
</span>
{projectInfo && (
<MyProjectThreadBadge
className="mr-4 max-w-[calc(100%_-_1rem)]"
projectName={projectInfo.projectName}
type={projectInfo.type}
/>
)}
</span>
{isActive && (
<span className="absolute top-1/2 right-1 h-5 w-1 -translate-y-1/2 rounded-full bg-primary" />
)}
</Link>
{!isStatic && (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<button
type="button"
className="absolute right-1 flex size-6 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:bg-background group-hover/item:opacity-100 data-[state=open]:opacity-100"
>
<MoreHorizontal className="size-4" />
<span className="sr-only">{t.common.more}</span>
</button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-48 rounded-lg" side="right" align="start">
<DropdownMenuItem
onSelect={() =>
handleRenameClick(
thread.thread_id,
titleOfThread(thread, t.pages.newChat),
)
}
>
<Pencil className="text-muted-foreground" />
<span>{t.common.rename}</span>
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => togglePin(thread.thread_id, !pinned)}>
{pinned ? (
<PinOff className="text-muted-foreground" />
) : (
<Pin className="text-muted-foreground" />
)}
<span>{pinned ? t.common.unpin : t.common.pin}</span>
</DropdownMenuItem>
<DropdownMenuItem
onSelect={() => toggleFavorite(thread.thread_id, !favorited)}
>
<Star
className={
favorited
? "fill-amber-400 text-amber-400"
: "text-muted-foreground"
}
/>
<span>{favorited ? t.common.unfavorite : t.common.favorite}</span>
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => setShareThreadId(thread.thread_id)}>
<Share2 className="text-muted-foreground" />
<span>{t.common.share}</span>
</DropdownMenuItem>
<DropdownMenuSub>
<DropdownMenuSubTrigger>
<Download className="text-muted-foreground" />
<span>{t.common.export}</span>
</DropdownMenuSubTrigger>
<DropdownMenuSubContent>
<DropdownMenuItem onSelect={() => handleExport(thread, "markdown")}>
<FileText className="text-muted-foreground" />
<span>{t.common.exportAsMarkdown}</span>
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => handleExport(thread, "json")}>
<FileJson className="text-muted-foreground" />
<span>{t.common.exportAsJSON}</span>
</DropdownMenuItem>
</DropdownMenuSubContent>
</DropdownMenuSub>
<DropdownMenuSeparator />
<DropdownMenuItem onSelect={() => handleDelete(thread.thread_id)}>
<Trash2 className="text-muted-foreground" />
<span>{t.common.delete}</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)}
</div>
);
})
)}
{!query && (
<Link
@@ -1,7 +1,7 @@
"use client";
import type { ChatStatus } from "ai";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import {
BookMarkedIcon,
BrainCircuitIcon,
@@ -144,8 +144,6 @@ export function InputBox({
assistantId,
hideAdminRecommendedQuestions,
compact,
mirrorLandingFrame = false,
frameRadius = "default",
hideContextTools,
composerHeightPercent,
...props
@@ -155,13 +153,6 @@ export function InputBox({
/** 紧凑模式(正常 App)新对话落地态:去掉旋转彩边、用 CM 参考图的白卡输入框,
* 并在推荐问题上方加「试试这些高频业务场景」标题。仅落地态生效,默认 false。 */
compact?: boolean;
/**
* Reuse the non-compact new-chat visual frame for a conversation composer.
* This changes only the border shell; conversation behavior remains intact.
*/
mirrorLandingFrame?: boolean;
/** Visual-only radius variant for a mirrored landing frame. */
frameRadius?: "default" | "tight";
/** 隐藏输入框工具条上的「写作 / 参考文献」上下文开关按钮(任务深链工作区等
* 受控场景用;文件/模型等其他按钮不受影响)。 */
hideContextTools?: boolean;
@@ -736,7 +727,6 @@ export function InputBox({
maxHeight: `max(12rem, calc(${composerMinHeight} + 8rem))`,
}
: undefined;
const usesGeminiFrame = !compact && (isNewThread || mirrorLandingFrame);
return (
<div ref={promptRootRef} className="relative flex flex-col gap-6">
@@ -754,7 +744,7 @@ export function InputBox({
<button
key={question}
type="button"
className="agent-suggested-chip max-w-full rounded-full border px-4 py-2 text-left text-sm text-foreground transition-colors"
className="max-w-full rounded-full border border-primary/20 bg-primary/5 px-4 py-2 text-left text-sm text-foreground transition-colors hover:bg-primary/10"
onClick={() => {
fillPromptForEditing(question);
}}
@@ -830,42 +820,26 @@ export function InputBox({
}}
/>
)}
<div
className={cn(
usesGeminiFrame && "gemini-gradient-border gemini-shadow",
// 对话态(含紧凑会话):文心一言式外壳 —— 空闲主题色浅边白卡,
// 生成中主题色渐变流光描边(globals.css .composer-shell)。
// 落地态(Gemini 彩灯)与紧凑落地白卡维持各自形态。
!usesGeminiFrame &&
!(compact && isNewThread) &&
(composerStatus === "streaming"
? "composer-shell composer-shell--streaming"
: "composer-shell composer-shell--idle"),
)}
data-frame-radius={
usesGeminiFrame && frameRadius !== "default" ? frameRadius : undefined
}
>
<div className={cn(isNewThread && !compact && "gemini-gradient-border gemini-shadow")}>
<PromptInput
style={
composerMinHeight ? { minHeight: composerMinHeight } : undefined
}
className={cn(
"transition-all duration-300 ease-out",
// 内部 input-group:紧凑落地白卡与对话态外壳都去掉自带描边/底色,
// 只保留外层一层描边(Gemini 落地态维持现状的双层结构不动)。
// 紧凑落地态(CM 参考图):表单作为白卡,内部 input-group 透明无边框,
// 避免双层描边;圆角对齐 2xl。
compact && isNewThread
? "*:data-[slot='input-group']:rounded-2xl *:data-[slot='input-group']:border-0 *:data-[slot='input-group']:bg-transparent *:data-[slot='input-group']:shadow-none"
: usesGeminiFrame
? "*:data-[slot='input-group']:rounded-3xl"
: "*:data-[slot='input-group']:rounded-3xl *:data-[slot='input-group']:border-0 *:data-[slot='input-group']:bg-transparent *:data-[slot='input-group']:shadow-none",
: "*:data-[slot='input-group']:rounded-3xl",
// 紧凑落地态(CM 参考图):白卡 + 细边 + 轻阴影 + 主色聚焦环(无旋转彩边)
compact && isNewThread
? "rounded-2xl border border-gray-200/70 bg-white overflow-hidden shadow-[0_4.5px_22px_rgba(0,0,0,0.025)] transition-all duration-300 focus-within:border-[rgb(var(--legacy-primary-rgb)/35%)] focus-within:ring-4 focus-within:ring-[rgb(var(--legacy-primary-rgb)/5%)] focus-within:shadow-[0_10px_35px_rgb(var(--legacy-primary-rgb)/4%)] dark:border-slate-700 dark:bg-slate-800"
: // 表单本体一律透明:落地态由外层 gemini-gradient-border 供白卡 +
// 旋转彩边,对话态由外层 composer-shell 供边框/底色/阴影,
// 避免双层描边。
"rounded-3xl bg-transparent border-0 shadow-none ring-0",
: // landing 态:透明,让外层 gemini-gradient-border 提供白卡 + 旋转描边
// 对话态:常规白卡 + 中性边框 + 轻阴影
isNewThread
? "rounded-3xl bg-transparent border-0 shadow-none ring-0"
: "rounded-3xl bg-background border border-border shadow-sm transition-shadow hover:shadow-md focus-within:border-ring/40 focus-within:shadow-md focus-within:ring-1 focus-within:ring-ring/20 dark:bg-slate-800 dark:border-slate-700",
className,
)}
disabled={disabled}
@@ -1475,9 +1449,11 @@ export function InputBox({
</ModelSelectorContent>
</ModelSelector>}
<PromptInputSubmit
// 皮肤(主题色扁平渐变圆钮 / 流式低对比停止钮)统一由 globals.css 的
// .agent-composer-send 提供,这里只保留紧凑落地档的小尺寸。
className={cn(compact && "size-7")}
className={cn(
"rounded-full border-border bg-background shadow-sm hover:bg-muted dark:bg-blue-500 dark:border-blue-500 dark:text-white dark:hover:bg-blue-400 dark:shadow-none",
compact &&
"size-7 rounded-lg border-0 bg-[var(--primary)] text-[var(--button-foreground,var(--primary-foreground))] hover:opacity-90 disabled:bg-muted disabled:text-muted-foreground/40 dark:bg-[var(--primary)] dark:border-0 dark:text-[var(--button-foreground,var(--primary-foreground))] dark:hover:opacity-90 dark:disabled:bg-muted",
)}
disabled={disabled}
onClick={(event) => {
if (composerStatus !== "streaming") return;
@@ -1486,6 +1462,7 @@ export function InputBox({
event.preventDefault();
handleStopCurrentGeneration();
}}
variant="outline"
status={composerStatus}
{...(documentRewriteActive
? { "aria-label": "停止 AI 全文改写" }
@@ -2,7 +2,7 @@
import { BookMarked } from "lucide-react";
import { useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { useKnowledgeActions } from "@/core/knowledge/hooks";
@@ -608,7 +608,7 @@ export function LlmWikiKnowledgeSelector({
variant="ghost"
size="sm"
className={cn(
"agent-composer-tool h-8 max-w-52 gap-1.5 rounded-full border-0 bg-transparent px-2.5 text-muted-foreground shadow-none hover:bg-muted/70 hover:text-foreground",
"h-8 max-w-52 gap-1.5 rounded-full border-0 bg-transparent px-2.5 text-muted-foreground shadow-none hover:bg-muted/70 hover:text-foreground",
selectedCount > 0 && "bg-primary/8 text-primary hover:bg-primary/12 hover:text-primary",
className,
)}
@@ -7,7 +7,7 @@ import {
ThumbsUpIcon,
} from "lucide-react";
import { useEffect, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -1,6 +1,6 @@
import { Trash2Icon } from "lucide-react";
import { useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -12,7 +12,7 @@ import {
XCircleIcon,
} from "lucide-react";
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { ArtifactFileList } from "@/components/workspace/artifacts/artifact-file-list";
@@ -1,6 +1,6 @@
import { FileText, Loader2, MessagesSquare } from "lucide-react";
import { useState, type ComponentProps } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -449,7 +449,7 @@ function HumanMessageBlock({
setEditing(false);
}
}}
className="min-h-20 resize-none text-[15px] leading-7"
className="min-h-20 resize-none text-[calc(15px*var(--ui-font-scale,1))] leading-7"
/>
<div className="flex items-center justify-end gap-2">
<Button
@@ -473,7 +473,7 @@ function HumanMessageBlock({
}
const messageResponse = text ? (
<div className="whitespace-pre-wrap break-words text-[15px] leading-7">
<div className="whitespace-pre-wrap break-words text-[calc(15px*var(--ui-font-scale,1))] leading-7">
{text}
</div>
) : null;
@@ -1353,7 +1353,7 @@ function AssistantDisplayContent({
content={part.content}
isLoading={isLoading}
rehypePlugins={rehypePlugins}
className="my-3"
className="chat-assistant-markdown my-3"
components={components}
/>
) : (
@@ -729,7 +729,9 @@ export function MessageList({
<ConversationContent
className={cn(
"mx-auto w-full max-w-(--container-width-lg)",
hasSingleRoundRag ? "gap-4 pt-4" : "gap-8 pt-12",
hasSingleRoundRag
? "gap-4 pt-4"
: "chat-message-list gap-8 pt-12",
contentClassName,
)}
>
@@ -752,6 +754,13 @@ export function MessageList({
</div>
) : null}
{(() => {
const rewriteItemsAboveFile = documentRewriteItems.filter(
(item) => item.operation !== "generate",
);
const rewriteItemsBelowFile = documentRewriteItems.filter(
(item) => item.operation === "generate",
);
let didRenderRewriteAboveFile = false;
let didRenderLiveKnowledgeRetrieval = false;
const grouped = groupMessages(
displayMessages,
@@ -1,6 +1,6 @@
import { ChevronDownIcon, DownloadIcon, EyeIcon, Loader2Icon } from "lucide-react";
import { useContext, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -36,11 +36,6 @@ export function ModelNameSelect({
title?: string;
}) {
const { models } = useModels();
// 后端约定:配置顺序的第一个模型即默认对话模型(models[0])。
const defaultModel = models[0];
const defaultModelLabel = defaultModel
? `${defaultModel.display_name || defaultModel.name}(默认)`
: defaultLabel;
return (
<Select
value={value ?? DEFAULT_VALUE}
@@ -51,10 +46,10 @@ export function ModelNameSelect({
className={cn("h-8 gap-1.5 text-xs", triggerClassName, className)}
title={title}
>
<SelectValue placeholder={defaultModelLabel} />
<SelectValue placeholder={defaultLabel} />
</SelectTrigger>
<SelectContent position="popper" side="bottom" sideOffset={4}>
<SelectItem value={DEFAULT_VALUE}>{defaultModelLabel}</SelectItem>
<SelectItem value={DEFAULT_VALUE}>{defaultLabel}</SelectItem>
{models.map((m) => (
<SelectItem key={m.name} value={m.name}>
{m.display_name || m.name}
@@ -10,7 +10,7 @@ import {
XIcon,
} from "lucide-react";
import { useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -7,19 +7,19 @@ import {
Download,
FileJson,
FileText,
MessageSquare,
MoreHorizontal,
Pencil,
Pin,
PinOff,
Search,
Share2,
Star,
Trash2,
} from "lucide-react";
import Link from "next/link";
import { useParams, usePathname, useRouter } from "next/navigation";
import { useCallback, useMemo, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { useCallback, useState } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -91,8 +91,6 @@ import {
useRecentStrategyProjects,
} from "@/strategy-selection/recent-projects";
import { historyAvatarForThread } from "./chat-history-avatar";
export function RecentChatList({
compact = false,
limit,
@@ -139,7 +137,6 @@ export function RecentChatList({
// Share dialog state — the conversation whose share code is being shown.
const [shareThreadId, setShareThreadId] = useState<string | null>(null);
const [query, setQuery] = useState("");
const handleDelete = useCallback(
(threadId: string) => {
@@ -221,27 +218,10 @@ export function RecentChatList({
recentStrategyProjects,
);
const shownItems = useMemo(() => {
const normalizedQuery = query.trim().toLowerCase();
const matchingItems = normalizedQuery
? recentItems.filter((item) =>
(item.kind === "thread"
? titleOfThread(item.thread, t.pages.newChat)
: item.project.title
)
.toLowerCase()
.includes(normalizedQuery),
)
: recentItems;
return normalizedQuery || limit == null
? matchingItems
: matchingItems.slice(0, limit);
}, [limit, query, recentItems, t.pages.newChat]);
if (recentItems.length === 0) {
return null;
}
const shownItems = limit != null ? recentItems.slice(0, limit) : recentItems;
return (
<>
<SidebarGroup
@@ -279,42 +259,26 @@ export function RecentChatList({
}`}
>
<SidebarMenu>
<div className="relative mb-1.5 px-1">
<Search className="pointer-events-none absolute top-1/2 left-3.5 size-3.5 -translate-y-1/2 text-muted-foreground/60" />
<Input
type="search"
value={query}
onChange={(event) => setQuery(event.target.value)}
placeholder="搜索历史会话…"
aria-label="搜索历史会话"
className="h-8 rounded-xl border-border bg-card pl-8 pr-2 text-[12px] shadow-none"
/>
</div>
<div className="flex w-full flex-col gap-0.5">
{shownItems.length === 0 ? (
<div className="px-3 py-4 text-center text-[12px] text-muted-foreground/70">
没有匹配的会话
</div>
) : shownItems.map((item) => {
{shownItems.map((item) => {
if (item.kind === "strategy-project") {
const { project } = item;
const href = strategyProjectWorkbenchPath(
"/page/strategy/qa/projects",
project.id,
);
const isActive = href === pathname;
return (
<SidebarMenuItem
key={`strategy-project:${project.id}`}
className="group/side-menu-item"
>
<SidebarMenuButton
isActive={isActive}
isActive={href === pathname}
asChild
className={cn(
"gq-history-item relative h-auto min-h-11 overflow-hidden rounded-xl px-3 py-1.5 text-[13px] text-foreground/80 transition-[background-color,color,box-shadow] duration-150 hover:bg-muted/80 hover:text-foreground hover:shadow-[inset_0_0_0_1px_rgb(var(--legacy-primary-rgb)/9%)]",
isActive && "gq-history-item--active",
"data-[active=true]:bg-primary/[0.11] data-[active=true]:font-medium data-[active=true]:text-primary data-[active=true]:shadow-[inset_0_0_0_1px_rgb(var(--legacy-primary-rgb)/22%),0_2px_8px_rgb(var(--legacy-primary-rgb)/7%)] data-[active=true]:hover:bg-primary/[0.15]",
"h-auto min-h-11 rounded-lg px-3 py-1.5 text-[13px] text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground",
"data-[active=true]:bg-white data-[active=true]:text-foreground data-[active=true]:shadow-[0_1px_2px_rgba(15,23,42,0.05)]",
"dark:data-[active=true]:bg-slate-700/80 dark:data-[active=true]:text-slate-100 dark:data-[active=true]:shadow-none",
compact &&
"min-h-11 gap-2 rounded-md px-2.5 data-[active=true]:border data-[active=true]:border-border",
)}
@@ -328,7 +292,7 @@ export function RecentChatList({
>
<MyProjectThreadIcon type="strategy" />
<span className="min-w-0 flex-1 flex flex-col items-start gap-0.5">
<span className="block w-full truncate">
<span className="w-full truncate">
{desensitize(project.title)}
</span>
<MyProjectThreadBadge
@@ -362,9 +326,9 @@ export function RecentChatList({
isActive={isActive}
asChild
className={cn(
"gq-history-item relative h-9 overflow-hidden rounded-xl px-3 text-[13px] text-foreground/80 transition-[background-color,color,box-shadow] duration-150 hover:bg-muted/80 hover:text-foreground hover:shadow-[inset_0_0_0_1px_rgb(var(--legacy-primary-rgb)/9%)]",
isActive && "gq-history-item--active",
"data-[active=true]:bg-primary/[0.11] data-[active=true]:font-medium data-[active=true]:text-primary data-[active=true]:shadow-[inset_0_0_0_1px_rgb(var(--legacy-primary-rgb)/22%),0_2px_8px_rgb(var(--legacy-primary-rgb)/7%)] data-[active=true]:hover:bg-primary/[0.15]",
"h-7 rounded-lg px-3 text-[13px] text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground",
"data-[active=true]:bg-white data-[active=true]:text-foreground data-[active=true]:shadow-[0_1px_2px_rgba(15,23,42,0.05)]",
"dark:data-[active=true]:bg-slate-700/80 dark:data-[active=true]:text-slate-100 dark:data-[active=true]:shadow-none",
compact &&
"h-9 gap-2 rounded-md px-2.5 data-[active=true]:border data-[active=true]:border-border",
projectInfo && "h-auto min-h-11 py-1.5",
@@ -388,13 +352,16 @@ export function RecentChatList({
) : projectInfo ? (
<MyProjectThreadIcon type={projectInfo.type} />
) : (
<img
src={historyAvatarForThread(thread.thread_id)}
alt=""
aria-hidden="true"
draggable={false}
className="size-5 shrink-0 object-contain"
compact && (
<MessageSquare
className={
"size-3.5 shrink-0 " +
(isActive
? "text-[var(--primary)]"
: "text-muted-foreground/70")
}
/>
)
)}
{pinned && (
<Pin className="size-3 shrink-0 text-muted-foreground/70" />
@@ -405,7 +372,7 @@ export function RecentChatList({
projectInfo && "flex flex-col items-start gap-0.5",
)}
>
<span className="block w-full truncate">
<span className="w-full truncate">
{desensitize(titleOfThread(thread, t.pages.newChat))}
</span>
{projectInfo && (
@@ -518,7 +485,7 @@ export function RecentChatList({
</SidebarMenuItem>
);
})}
{moreHref && !query.trim() && (
{moreHref && (
<SidebarMenuItem>
<SidebarMenuButton
asChild
@@ -9,7 +9,7 @@ import {
Trash2Icon,
} from "lucide-react";
import { useEffect, useState } from "react";
import { confirmAction, toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -92,11 +92,7 @@ export function ShareRoundtableDraftDialog({
}
async function handleRevoke() {
if (!share || !(await confirmAction("撤销后此分享立即失效,确定吗?", {
title: "撤销分享?",
confirmText: "撤销分享",
danger: true,
}))) return;
if (!share || !window.confirm("撤销后此分享立即失效,确定吗?")) return;
try {
await revokeShare.mutateAsync(share.share_code);
toast.success("已撤销分享");
@@ -1,7 +1,7 @@
"use client";
import { CopyIcon, LogOutIcon, UserIcon } from "lucide-react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
@@ -0,0 +1,71 @@
"use client";
import { ArrowRightLeftIcon, Loader2Icon } from "lucide-react";
import { toast } from "sonner";
import { Switch } from "@/components/ui/switch";
import {
useAgentSkillMigrationSettings,
useUpdateAgentSkillMigrationSettings,
} from "@/core/system-settings/hooks";
export function AgentSkillMigrationSettingsPage() {
const { data, isLoading, isError } = useAgentSkillMigrationSettings();
const update = useUpdateAgentSkillMigrationSettings();
const enabled = data?.enabled ?? false;
const handleChange = async (checked: boolean) => {
try {
await update.mutateAsync({ enabled: checked });
toast.success(
checked
? "智能体与技能迁移功能已开启"
: "智能体与技能迁移功能已关闭",
);
} catch (error) {
toast.error(error instanceof Error ? error.message : "保存失败");
}
};
return (
<section className="space-y-6">
<div className="space-y-1">
<h3 className="flex items-center gap-2 text-lg font-semibold">
<ArrowRightLeftIcon className="size-5" />
智能体与技能迁移
</h3>
<p className="text-muted-foreground text-sm">
控制智能体/技能迁移入口,以及对话页的导出记录、导入记录和卡片导出按钮。默认关闭,只有管理员显式开启后才可使用。
</p>
</div>
<div className="flex items-center justify-between gap-6 rounded-lg border p-4">
<div className="space-y-1">
<div className="font-medium">启用跨服务器迁移</div>
<p className="text-muted-foreground text-sm">
开启后,对话页会显示记录导出和导入按钮;智能体与技能请先复制目录,再通过清单同步归属、状态和标签。
</p>
</div>
{isLoading ? (
<Loader2Icon className="text-muted-foreground size-5 animate-spin" />
) : (
<Switch
checked={enabled}
disabled={isError || update.isPending}
onCheckedChange={handleChange}
aria-label="启用智能体与技能跨服务器迁移"
/>
)}
</div>
{isError && (
<p className="text-destructive text-sm">
无法读取迁移开关,系统将按关闭处理。
</p>
)}
<p className="text-muted-foreground text-xs">
关闭后前端入口和对应接口都会停用;已经复制或导入的内容不会被删除或修改。
</p>
</section>
);
}
@@ -2,7 +2,7 @@
import { useEffect, useState } from "react";
import { Clock3Icon, DatabaseIcon, GlobeIcon, RefreshCwIcon, SaveIcon, SearchIcon } from "lucide-react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
@@ -9,7 +9,7 @@ import {
type ChangeEvent,
type RefObject,
} from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import defaultLightRedNavActive from "@/assets/img/nav-active-light-red.svg";
import defaultLightRedHeaderBackground from "@/assets/img/top-bg-light-red.svg";
@@ -19,7 +19,7 @@ import {
} from "lucide-react";
import { useEffect, useMemo, useState, type ComponentType, type SVGProps } from "react";
import { useNavigate } from "react-router-dom";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { useTheme, type ThemeType } from "@/contexts/ThemeContext";
@@ -41,8 +41,7 @@ import { migrateAuthToSession } from "@/core/auth/scoped-storage";
import { isIsolatedSession, setIsolatedSession } from "@/core/embed/embed-session";
import { enUS, isLocale, zhCN, type Locale } from "@/core/i18n";
import { useI18n } from "@/core/i18n/hooks";
import { useLocalSettings } from "@/core/settings";
import { resolveAgentGridLayout } from "@/core/settings/agent-grid";
import { DEFAULT_FONT_SCALE, useLocalSettings } from "@/core/settings";
import {
AGENT_COMPOSER_WIDTH_MAX,
AGENT_COMPOSER_WIDTH_MIN,
@@ -80,6 +79,11 @@ import type {
CompactShortcutButton,
CompactShortcutRouteParam,
} from "@/core/system-settings/api";
import {
DEFAULT_MESSAGE_MAP_TILE_MAX_ZOOM,
DEFAULT_MESSAGE_MAP_TILE_MIN_ZOOM,
MESSAGE_MAP_DISPLAY_MAX_ZOOM,
} from "@/core/utils/map-tile-config";
import { cn } from "@/lib/utils";
import { createClientId } from "@/lib/client-id";
import {
@@ -494,20 +498,43 @@ export function AppearanceSettingsPage({ onClose }: { onClose?: () => void }) {
const [htmlRuntimeDraft, setHtmlRuntimeDraft] = useState<{
base_url: string;
map_tile_url: string;
message_map_tile_min_zoom: string;
message_map_tile_max_zoom: string;
} | null>(null);
const runtimeBaseUrl = htmlRuntimeDraft?.base_url ?? htmlRuntime?.base_url ?? "";
const runtimeTileUrl =
htmlRuntimeDraft?.map_tile_url ?? htmlRuntime?.map_tile_url ?? "";
const runtimeTileMinZoom =
htmlRuntimeDraft?.message_map_tile_min_zoom ??
String(
htmlRuntime?.message_map_tile_min_zoom ?? DEFAULT_MESSAGE_MAP_TILE_MIN_ZOOM,
);
const runtimeTileMaxZoom =
htmlRuntimeDraft?.message_map_tile_max_zoom ??
String(
htmlRuntime?.message_map_tile_max_zoom ?? DEFAULT_MESSAGE_MAP_TILE_MAX_ZOOM,
);
const parsedRuntimeTileMinZoom = Number(runtimeTileMinZoom);
const parsedRuntimeTileMaxZoom = Number(runtimeTileMaxZoom);
const runtimeTileZoomValid =
runtimeTileMinZoom.trim() !== "" &&
runtimeTileMaxZoom.trim() !== "" &&
Number.isInteger(parsedRuntimeTileMinZoom) &&
Number.isInteger(parsedRuntimeTileMaxZoom) &&
parsedRuntimeTileMinZoom >= 0 &&
parsedRuntimeTileMaxZoom <= MESSAGE_MAP_DISPLAY_MAX_ZOOM &&
parsedRuntimeTileMinZoom <= parsedRuntimeTileMaxZoom;
const htmlRuntimeDirty =
!!htmlRuntime &&
(runtimeBaseUrl !== htmlRuntime.base_url ||
runtimeTileUrl !== htmlRuntime.map_tile_url ||
parsedRuntimeTileMinZoom !==
(htmlRuntime.message_map_tile_min_zoom ?? DEFAULT_MESSAGE_MAP_TILE_MIN_ZOOM) ||
parsedRuntimeTileMaxZoom !==
(htmlRuntime.message_map_tile_max_zoom ?? DEFAULT_MESSAGE_MAP_TILE_MAX_ZOOM));
const globalDefault = appearance?.default_theme ?? "light";
const globalSkillView = appearance?.default_skill_view ?? "list";
const globalAgentView = appearance?.default_agent_view ?? "card";
const agentGrid = resolveAgentGridLayout(settings.display, appearance);
const agentGridSummary = agentGrid.adaptive
? "自适应(普通屏 4 列,3K 以上 5 列)"
: `固定每行 ${agentGrid.columns} 张`;
const adminGridSummary = agentGrid.adminAdaptive
? "自适应(普通屏 4 列,3K 以上 5 列)"
: `固定每行 ${agentGrid.adminColumns} 张`;
const globalLayoutMode = appearance?.default_layout_mode ?? "compact";
const globalDefaultLabel = useMemo(() => {
const customTheme = (appearance?.custom_themes ?? []).find(
@@ -1220,175 +1247,6 @@ export function AppearanceSettingsPage({ onClose }: { onClose?: () => void }) {
</p>
</div>
))}
<div className="flex items-start justify-between gap-4 rounded-lg border p-4">
<div>
<div className="text-sm font-medium">智能体卡片每行数量(个人)</div>
<p className="text-muted-foreground mt-1 max-w-md text-xs leading-relaxed">
{agentGrid.followingAdmin
? `列表当前按管理员设置显示:${adminGridSummary}。只影响本浏览器。`
: `列表当前使用个人设置:${agentGridSummary},没有采用管理员的${adminGridSummary}。打开右侧开关后立即改回管理员设置。`}
</p>
</div>
<div className="flex shrink-0 items-center gap-2">
<span className="text-xs text-muted-foreground">跟随管理员</span>
<Switch
checked={agentGrid.followingAdmin}
onCheckedChange={(checked) => {
if (checked) {
setSettings("display", {
agentGridFollowAdmin: undefined,
agentGridAdaptive: undefined,
agentGridColumns: undefined,
});
return;
}
setSettings("display", {
agentGridFollowAdmin: false,
agentGridAdaptive: agentGrid.adminAdaptive,
agentGridColumns: agentGrid.adminAdaptive
? undefined
: agentGrid.adminColumns,
});
}}
aria-label="跟随管理员的智能体卡片列数"
/>
</div>
</div>
{!agentGrid.followingAdmin && (
<div className="flex items-start justify-between gap-4 rounded-lg border p-4">
<div>
<div className="text-sm font-medium">个人自适应</div>
<p className="text-muted-foreground mt-1 max-w-md text-xs leading-relaxed">
开启后按窗口宽度排列(普通屏 4 列、3K 以上 5 列)。关闭后使用下方固定列数。
</p>
</div>
<Switch
checked={agentGrid.adaptive}
onCheckedChange={(checked) =>
setSettings("display", {
agentGridFollowAdmin: false,
agentGridAdaptive: checked,
agentGridColumns: checked ? undefined : agentGrid.columns,
})
}
aria-label="个人自适应列数"
/>
</div>
)}
{!agentGrid.followingAdmin && !agentGrid.adaptive && (
<div className="flex items-start justify-between gap-4 rounded-lg border p-4">
<div>
<div className="text-sm font-medium">每行卡片数(个人固定)</div>
<p className="text-muted-foreground mt-1 max-w-md text-xs leading-relaxed">
卡片视图固定使用该列数(1-8),只影响本浏览器。
</p>
</div>
<div className="flex shrink-0 items-center gap-2">
<Button
variant="outline"
size="icon"
className="size-8"
aria-label="减少每行卡片数"
disabled={agentGrid.columns <= 1}
onClick={() =>
setSettings("display", {
agentGridFollowAdmin: false,
agentGridAdaptive: false,
agentGridColumns: Math.max(1, agentGrid.columns - 1),
})
}
>
-
</Button>
<span className="w-8 text-center text-sm font-semibold tabular-nums">
{agentGrid.columns}
</span>
<Button
variant="outline"
size="icon"
className="size-8"
aria-label="增加每行卡片数"
disabled={agentGrid.columns >= 8}
onClick={() =>
setSettings("display", {
agentGridFollowAdmin: false,
agentGridAdaptive: false,
agentGridColumns: Math.min(8, agentGrid.columns + 1),
})
}
>
+
</Button>
</div>
</div>
)}
{isAdmin && (
<div className="flex items-start justify-between gap-4 rounded-lg border border-primary/25 bg-primary/[0.03] p-4">
<div>
<div className="text-sm font-medium">智能体卡片网格默认值(管理员)</div>
<p className="text-muted-foreground mt-1 max-w-md text-xs leading-relaxed">
关闭自适应后,智能体卡片页按这里的固定列数排列。已经关掉「跟随管理员」的浏览器仍用自己的列数。
</p>
</div>
<div className="flex shrink-0 flex-col items-end gap-2">
<div className="flex items-center gap-2">
<span className="text-xs text-muted-foreground">自适应</span>
<Switch
checked={appearance?.default_agent_grid_adaptive ?? true}
disabled={updateAppearance.isPending}
onCheckedChange={(checked) =>
void updateAppearance.mutateAsync({
default_agent_grid_adaptive: checked,
})
}
aria-label="默认自适应列数"
/>
</div>
{!((appearance?.default_agent_grid_adaptive ?? true)) && (
<div className="flex items-center gap-2">
<span className="text-xs text-muted-foreground">固定列数</span>
<Button
variant="outline"
size="icon"
className="size-8"
aria-label="减少默认每行卡片数"
disabled={(appearance?.default_agent_grid_columns ?? 4) <= 1 || updateAppearance.isPending}
onClick={() =>
void updateAppearance.mutateAsync({
default_agent_grid_columns: Math.max(
1,
(appearance?.default_agent_grid_columns ?? 4) - 1,
),
})
}
>
-
</Button>
<span className="w-8 text-center text-sm font-semibold tabular-nums">
{appearance?.default_agent_grid_columns ?? 4}
</span>
<Button
variant="outline"
size="icon"
className="size-8"
aria-label="增加默认每行卡片数"
disabled={(appearance?.default_agent_grid_columns ?? 4) >= 8 || updateAppearance.isPending}
onClick={() =>
void updateAppearance.mutateAsync({
default_agent_grid_columns: Math.min(
8,
(appearance?.default_agent_grid_columns ?? 4) + 1,
),
})
}
>
+
</Button>
</div>
)}
</div>
</div>
)}
</div>
</SettingsSection>
</>
@@ -1398,11 +1256,11 @@ export function AppearanceSettingsPage({ onClose }: { onClose?: () => void }) {
<SettingsSection
title="字号"
description="调整界面字号。默认 16px(标准)。「仅文字」只放大文字;「整页缩放」会连间距、图标和写死的字号一起变。"
description="调整界面字号。默认 22px(超大)。「仅文字」只放大文字;「整页缩放」会连间距、图标和写死的字号一起变。"
>
<div className="space-y-3">
<Select
value={String(settings.display.fontScale ?? 1)}
value={String(settings.display.fontScale ?? DEFAULT_FONT_SCALE)}
onValueChange={(value) => {
const scale = Number(value);
if (Number.isFinite(scale) && scale > 0) {
@@ -1610,6 +1468,8 @@ export function AppearanceSettingsPage({ onClose }: { onClose?: () => void }) {
setHtmlRuntimeDraft({
base_url: event.target.value,
map_tile_url: runtimeTileUrl,
message_map_tile_min_zoom: runtimeTileMinZoom,
message_map_tile_max_zoom: runtimeTileMaxZoom,
})
}
placeholder="https://你的域名/api/public/html-runtime"
@@ -1630,12 +1490,75 @@ export function AppearanceSettingsPage({ onClose }: { onClose?: () => void }) {
setHtmlRuntimeDraft({
base_url: runtimeBaseUrl,
map_tile_url: event.target.value,
message_map_tile_min_zoom: runtimeTileMinZoom,
message_map_tile_max_zoom: runtimeTileMaxZoom,
})
}
placeholder="https://tiles.example/{z}/{x}/{y}.png"
className="mt-1 font-mono text-xs"
spellCheck={false}
/>
<div className="mt-4 rounded-lg border bg-muted/20 p-3">
<div className="text-xs font-medium">消息列表地图瓦片层级</div>
<p className="text-muted-foreground mt-1 text-xs leading-relaxed">
只作用于普通问答消息列表里的地图,生成 HTML 网页暂不受影响。请填写瓦片服务真实存在的层级;地图仍可放大到 {MESSAGE_MAP_DISPLAY_MAX_ZOOM} 级,超过最大真实层级后会放大已有瓦片。
</p>
<div className="mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2">
<div>
<label className="block text-xs font-medium" htmlFor="message-map-tile-min-zoom">
最小真实层级
</label>
<Input
id="message-map-tile-min-zoom"
type="number"
min={0}
max={MESSAGE_MAP_DISPLAY_MAX_ZOOM}
step={1}
inputMode="numeric"
value={runtimeTileMinZoom}
disabled={!htmlRuntime || updateHtmlRuntime.isPending}
onChange={(event) =>
setHtmlRuntimeDraft({
base_url: runtimeBaseUrl,
map_tile_url: runtimeTileUrl,
message_map_tile_min_zoom: event.target.value,
message_map_tile_max_zoom: runtimeTileMaxZoom,
})
}
className="mt-1"
/>
</div>
<div>
<label className="block text-xs font-medium" htmlFor="message-map-tile-max-zoom">
最大真实层级
</label>
<Input
id="message-map-tile-max-zoom"
type="number"
min={0}
max={MESSAGE_MAP_DISPLAY_MAX_ZOOM}
step={1}
inputMode="numeric"
value={runtimeTileMaxZoom}
disabled={!htmlRuntime || updateHtmlRuntime.isPending}
onChange={(event) =>
setHtmlRuntimeDraft({
base_url: runtimeBaseUrl,
map_tile_url: runtimeTileUrl,
message_map_tile_min_zoom: runtimeTileMinZoom,
message_map_tile_max_zoom: event.target.value,
})
}
className="mt-1"
/>
</div>
</div>
{!runtimeTileZoomValid ? (
<p className="mt-2 text-xs text-destructive" role="alert">
请输入 0~{MESSAGE_MAP_DISPLAY_MAX_ZOOM} 的整数,且最小真实层级不能大于最大真实层级。
</p>
) : null}
</div>
<div className="mt-3 flex justify-end">
<Button
type="button"
@@ -1643,23 +1566,28 @@ export function AppearanceSettingsPage({ onClose }: { onClose?: () => void }) {
disabled={
!htmlRuntime ||
updateHtmlRuntime.isPending ||
(runtimeBaseUrl === htmlRuntime.base_url &&
runtimeTileUrl === htmlRuntime.map_tile_url)
!runtimeTileZoomValid ||
!htmlRuntimeDirty
}
onClick={() =>
updateHtmlRuntime.mutate(
{ base_url: runtimeBaseUrl.trim(), map_tile_url: runtimeTileUrl.trim() },
{
base_url: runtimeBaseUrl.trim(),
map_tile_url: runtimeTileUrl.trim(),
message_map_tile_min_zoom: parsedRuntimeTileMinZoom,
message_map_tile_max_zoom: parsedRuntimeTileMaxZoom,
},
{
onSuccess: () => {
setHtmlRuntimeDraft(null);
toast.success("HTML 运行地址已保存,之后新画的网页会使用这个地址");
toast.success("地址与消息列表地图瓦片层级已保存");
},
onError: (error) => toast.error(error.message || "保存失败"),
},
)
}
>
{updateHtmlRuntime.isPending ? "保存中..." : "保存地址"}
{updateHtmlRuntime.isPending ? "保存中..." : "保存设置"}
</Button>
</div>
</div>
@@ -3,7 +3,7 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Switch } from "@/components/ui/switch";
@@ -1,7 +1,7 @@
"use client";
import { BarChart3Icon, Loader2Icon } from "lucide-react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Switch } from "@/components/ui/switch";
import {
@@ -10,7 +10,6 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/com
import { getStoredAuth } from "@/core/auth";
import { apiFetch } from "@/core/api";
import { getBackendBaseURL } from "@/core/config";
import { confirmAction } from "@/core/ui/feedback";
import {
ACTIVE_ARCHIVE_JOB_STATUSES as ACTIVE,
archiveMonthDisplayStatus,
@@ -145,11 +144,7 @@ export function ChatArchiveSettingsPage() {
const confirmation = action === "purge"
? "确认清理该月已归档的 PostgreSQL 数据?系统会逐会话重新校验 SQLite 备份,只清理校验通过的会话;失败、未归档和正在运行的会话不会清理。"
: "确认回滚到 PostgreSQL?月度 SQLite 文件中的归档记录会保留。";
if (action !== "archive" && !(await confirmAction(confirmation, {
title: action === "purge" ? "清理 PostgreSQL 归档数据?" : "回滚归档数据?",
confirmText: action === "purge" ? "确认清理" : "确认回滚",
danger: action === "purge",
}))) return;
if (action !== "archive" && !window.confirm(confirmation)) return;
setBusyMonth(month.month);
setError(null);
try {
@@ -2,7 +2,7 @@
import { ListOrderedIcon, Loader2Icon, ShrinkIcon } from "lucide-react";
import { useEffect, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -15,7 +15,7 @@ import {
} from "lucide-react";
import { useEffect, useId, useMemo, useState, type CSSProperties } from "react";
import { ColorPickerPanel } from "tdesign-react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -0,0 +1,410 @@
"use client";
import {
Image,
ImageOff,
ImageUp,
Loader2,
RotateCcw,
} from "lucide-react";
import {
useEffect,
useMemo,
useRef,
useState,
type ChangeEvent,
} from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { Switch } from "@/components/ui/switch";
import {
useDeleteGeneratedPageBrandingSettings,
useGeneratedPageBrandingSettings,
useUpdateGeneratedPageBrandingSettings,
} from "@/core/system-settings/hooks";
import {
resolveGeneratedPageLogoUrl,
type GeneratedPageBrandLogoMode,
} from "@/core/system-settings/api";
import { SettingsSection } from "./settings-section";
const MAX_LOGO_BYTES = 10 * 1024 * 1024;
const ACCEPTED_LOGO_TYPES = new Set([
"image/png",
"image/jpeg",
"image/webp",
]);
const DEFAULT_LOGO_URL = "/api/public/html-runtime/brand-logo-dark.png";
export function GeneratedPageBrandingSettingsPage() {
const { data: branding, isPending } = useGeneratedPageBrandingSettings();
const updateBranding = useUpdateGeneratedPageBrandingSettings();
const deleteBranding = useDeleteGeneratedPageBrandingSettings();
const fileInputRef = useRef<HTMLInputElement>(null);
const [systemName, setSystemName] = useState("");
const [chromeEnabled, setChromeEnabled] = useState(true);
const [headerLayout, setHeaderLayout] = useState<"left" | "center">("center");
const [logoMode, setLogoMode] =
useState<GeneratedPageBrandLogoMode>("custom");
const [pendingLogo, setPendingLogo] = useState<File | null>(null);
const [resetOpen, setResetOpen] = useState(false);
useEffect(() => {
setChromeEnabled(branding?.chrome_enabled ?? true);
setHeaderLayout(branding?.header_layout === "left" ? "left" : "center");
setSystemName(branding?.system_name ?? "");
setLogoMode(branding?.logo_mode ?? "custom");
setPendingLogo(null);
if (fileInputRef.current) fileInputRef.current.value = "";
}, [
branding?.logo_version,
branding?.system_name,
branding?.footer_text,
branding?.logo_mode,
branding?.chrome_enabled,
branding?.header_layout,
]);
const previewUrl = useMemo(
() => (pendingLogo ? URL.createObjectURL(pendingLogo) : undefined),
[pendingLogo],
);
useEffect(
() => () => {
if (previewUrl) URL.revokeObjectURL(previewUrl);
},
[previewUrl],
);
const currentLogoUrl = resolveGeneratedPageLogoUrl(branding?.logo_url);
const defaultLogoUrl = resolveGeneratedPageLogoUrl(DEFAULT_LOGO_URL);
const displayedLogoUrl =
previewUrl ??
(logoMode === "default"
? defaultLogoUrl
: logoMode === "custom" && branding?.logo_mode === "custom"
? currentLogoUrl
: undefined);
const normalizedName = systemName.trim();
const configurationWillBeActive = Boolean(
normalizedName &&
chromeEnabled &&
(logoMode !== "custom" || displayedLogoUrl),
);
const hasChanges =
chromeEnabled !== (branding?.chrome_enabled ?? true) ||
headerLayout !== (branding?.header_layout ?? "center") ||
normalizedName !== (branding?.system_name ?? "") ||
logoMode !== (branding?.logo_mode ?? "custom") ||
Boolean(pendingLogo);
const busy = updateBranding.isPending || deleteBranding.isPending;
const handleLogoChange = (event: ChangeEvent<HTMLInputElement>) => {
const file = event.target.files?.[0];
if (!file) return;
if (!ACCEPTED_LOGO_TYPES.has(file.type)) {
toast.error("Logo 仅支持 PNG、JPG 或 WebP 图片");
event.target.value = "";
return;
}
if (file.size > MAX_LOGO_BYTES) {
toast.error("Logo 文件不能超过 10MB");
event.target.value = "";
return;
}
setPendingLogo(file);
setLogoMode("custom");
};
const handleLogoModeChange = (mode: GeneratedPageBrandLogoMode) => {
setLogoMode(mode);
if (mode !== "custom") {
setPendingLogo(null);
if (fileInputRef.current) fileInputRef.current.value = "";
}
};
const logoModeDescription =
logoMode === "default"
? "保存后,生成网页会使用系统内置的默认头像。"
: logoMode === "none"
? "保存后,生成网页的品牌页头仅显示系统名称,不显示头像。"
: "上传的自定义 Logo 将显示在生成网页的品牌页头。";
const handleSave = async () => {
try {
const saved = await updateBranding.mutateAsync({
chromeEnabled,
headerLayout,
systemName: normalizedName,
logoMode,
logo: pendingLogo,
});
toast.success("生成网页标识已保存", {
description: saved.active
? "名称和头像显示方式已配置,之后新生成的 HTML 页面将自动加上品牌页头(不加页脚)。"
: "请填写系统名称,并在上传自定义、默认头像或不显示头像中完成选择。",
});
} catch (error) {
toast.error(
error instanceof Error ? error.message : "生成网页标识保存失败",
);
}
};
const handleReset = async () => {
try {
await deleteBranding.mutateAsync();
setResetOpen(false);
toast.success("已清除生成网页标识", {
description: "之后生成网页时将恢复原有生成逻辑。",
});
} catch (error) {
toast.error(
error instanceof Error ? error.message : "清除生成网页标识失败",
);
}
};
return (
<>
<SettingsSection
title="生成网页标识"
description="配置 AI 后续生成的 HTML 网页使用的名称与头像显示方式,并可单独开关平台的自动注入(只注入品牌页头,不加页脚)。这里只影响生成网页内容,不会修改 DeerFlow 自身的名称、导航或 Logo。"
>
<div className="space-y-6">
<div className="flex items-start justify-between gap-4 rounded-lg border bg-muted/20 px-4 py-3">
<div className="min-w-0 space-y-1">
<label
htmlFor="generated-page-chrome-enabled"
className="text-sm font-medium"
>
自动注入品牌页头
</label>
<p className="text-xs leading-5 text-muted-foreground">
开启后,平台会给新生成的网页自动加上统一品牌页头(多页面含页面导航),不加页脚。
关闭后,生成网页完全不加页头、保持原有输出,也不要求页面自行展示名称或头像。
</p>
</div>
<Switch
id="generated-page-chrome-enabled"
checked={chromeEnabled}
onCheckedChange={setChromeEnabled}
disabled={isPending || busy}
className="mt-1"
/>
</div>
<div className="rounded-lg border bg-muted/20 px-4 py-3 text-sm leading-6">
<span className="font-medium">
{configurationWillBeActive
? "配置完整:"
: !chromeEnabled
? "自动注入已关闭:"
: "当前未启用:"}
</span>
{configurationWillBeActive
? logoMode === "none"
? "保存后,新生成网页将自动加上仅含系统名称的品牌页头(不显示头像、不加页脚)。"
: "保存后,新生成网页将自动加上品牌页头(名称 + 头像,不加页脚)。"
: !chromeEnabled
? "生成网页完全不加页头,也不要求页面自行展示名称或头像。"
: "请填写系统名称,并选择上传自定义、使用默认头像或不显示头像。"}
</div>
<div className="space-y-2">
<label
htmlFor="generated-page-brand-name"
className="text-sm font-medium"
>
网页中的系统名称
</label>
<Input
id="generated-page-brand-name"
value={systemName}
onChange={(event) => setSystemName(event.target.value)}
placeholder="请输入要在网页页头展示的系统名称"
maxLength={80}
disabled={isPending || busy}
aria-describedby="generated-page-brand-name-help"
/>
<div
id="generated-page-brand-name-help"
className="flex justify-between gap-4 text-xs text-muted-foreground"
>
<span>最多 80 个字符;需选择头像显示方式才会启用。</span>
<span className="tabular-nums">{systemName.length}/80</span>
</div>
</div>
<div className="space-y-3">
<div>
<div className="text-sm font-medium">网页 Logo / 头像</div>
<p className="mt-1 text-xs leading-5 text-muted-foreground">
可上传自定义 Logo、使用系统默认头像,或只显示系统名称。启用后会进入品牌页头。
</p>
</div>
<div
className="grid gap-2 sm:grid-cols-3"
role="group"
aria-label="网页 Logo 显示方式"
>
{[
["custom", "上传自定义"],
["default", "使用默认头像"],
["none", "不显示头像"],
].map(([mode, label]) => (
<Button
key={mode}
type="button"
variant={logoMode === mode ? "default" : "outline"}
className="h-11 justify-center"
aria-pressed={logoMode === mode}
onClick={() =>
handleLogoModeChange(mode as GeneratedPageBrandLogoMode)
}
disabled={isPending || busy}
>
{mode === "custom" ? (
<ImageUp aria-hidden />
) : mode === "default" ? (
<Image aria-hidden />
) : (
<ImageOff aria-hidden />
)}
{label}
</Button>
))}
</div>
<div className="grid gap-4 rounded-lg border bg-muted/20 p-4 sm:grid-cols-[160px_minmax(0,1fr)]">
<div className="flex h-28 items-center justify-center overflow-hidden rounded-lg border border-dashed bg-background p-3">
{displayedLogoUrl ? (
<img
src={displayedLogoUrl}
alt="网页 Logo 预览"
className="max-h-full max-w-full object-contain"
/>
) : (
<div className="text-center text-xs leading-5 text-muted-foreground">
{logoMode === "none" ? (
<ImageOff className="mx-auto mb-1.5 size-6" aria-hidden />
) : (
<ImageUp className="mx-auto mb-1.5 size-6" aria-hidden />
)}
{logoMode === "none"
? "当前选择不显示头像"
: "当前未上传自定义 Logo"}
</div>
)}
</div>
<div className="flex min-w-0 flex-col justify-center gap-3">
{logoMode === "custom" ? (
<>
<input
ref={fileInputRef}
id="generated-page-brand-logo"
type="file"
accept="image/png,image/jpeg,image/webp"
className="sr-only"
onChange={handleLogoChange}
disabled={isPending || busy}
/>
<div className="flex flex-wrap gap-2">
<Button
type="button"
variant="outline"
className="h-11"
onClick={() => fileInputRef.current?.click()}
disabled={isPending || busy}
>
<ImageUp aria-hidden />
{displayedLogoUrl ? "更换 Logo" : "上传 Logo"}
</Button>
</div>
{pendingLogo && (
<p
className="truncate text-xs text-muted-foreground"
title={pendingLogo.name}
>
待上传:{pendingLogo.name}
</p>
)}
</>
) : (
<p className="text-xs leading-5 text-muted-foreground">
{logoModeDescription}
</p>
)}
</div>
</div>
</div>
<div className="flex flex-wrap items-center justify-between gap-3 border-t pt-5">
<Button
type="button"
variant="outline"
className="h-11"
onClick={() => setResetOpen(true)}
disabled={!branding?.customized || busy}
>
<RotateCcw aria-hidden />
清除配置
</Button>
<Button
type="button"
className="h-11 min-w-28"
onClick={handleSave}
disabled={!hasChanges || isPending || busy}
>
{updateBranding.isPending && <Loader2 className="animate-spin" aria-hidden />}
{updateBranding.isPending ? "保存中..." : "保存网页标识"}
</Button>
</div>
</div>
</SettingsSection>
<Dialog open={resetOpen} onOpenChange={setResetOpen}>
<DialogContent aria-describedby="generated-page-brand-reset-description">
<DialogHeader>
<DialogTitle>清除生成网页标识</DialogTitle>
</DialogHeader>
<p
id="generated-page-brand-reset-description"
className="text-sm leading-6 text-muted-foreground"
>
将移除网页展示名称与 Logo/头像显示方式,并把自动注入开关恢复为开启。DeerFlow 自身界面不会发生变化,之后生成的 HTML 页面将恢复原有生成逻辑。
</p>
<DialogFooter>
<Button
variant="outline"
onClick={() => setResetOpen(false)}
disabled={busy}
>
取消
</Button>
<Button variant="destructive" onClick={handleReset} disabled={busy}>
{deleteBranding.isPending && (
<Loader2 className="animate-spin" aria-hidden />
)}
{deleteBranding.isPending ? "清除中..." : "确认清除"}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</>
);
}
@@ -2,7 +2,7 @@
import { AlertCircleIcon, Loader2Icon } from "lucide-react";
import { useEffect, useMemo, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -1,7 +1,7 @@
"use client";
import { Loader2Icon, SearchIcon } from "lucide-react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Switch } from "@/components/ui/switch";
@@ -1,150 +0,0 @@
"use client";
import { DatabaseIcon, Loader2Icon, SaveIcon } from "lucide-react";
import { useEffect, useMemo, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { Button } from "@/components/ui/button";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { Switch } from "@/components/ui/switch";
import {
type LocalWikiAutoSyncSettings,
useLocalWikiAutoSyncSettings,
useLocalWikiAutoSyncSettingsActions,
} from "@/strategy-components/api/llmwiki";
import { SettingsSection } from "./settings-section";
const HOURS = Array.from({ length: 24 }, (_, hour) => hour);
function hourLabel(hour: number) {
return `${String(hour).padStart(2, "0")}:00`;
}
export function LocalWikiAutoSyncSettingsPage() {
const settings = useLocalWikiAutoSyncSettings();
const actions = useLocalWikiAutoSyncSettingsActions();
const [draft, setDraft] = useState<LocalWikiAutoSyncSettings | null>(null);
useEffect(() => {
if (settings.data) setDraft(settings.data);
}, [settings.data]);
const isDirty = useMemo(
() => !!draft && JSON.stringify(draft) !== JSON.stringify(settings.data),
[draft, settings.data],
);
const updateDraft = (patch: Partial<LocalWikiAutoSyncSettings>) => {
setDraft((current) => current ? { ...current, ...patch } : current);
};
const save = async () => {
if (!draft) return;
try {
await actions.save.mutateAsync(draft);
toast.success(draft.enabled ? "知识库自动同步设置已保存" : "知识库自动同步已关闭");
} catch (error) {
toast.error(error instanceof Error ? error.message : "保存失败,请稍后重试");
}
};
if (settings.isLoading || !draft) {
return (
<div className="flex min-h-36 items-center justify-center text-sm text-muted-foreground">
<Loader2Icon className="mr-2 size-4 animate-spin" />正在读取自动同步设置…
</div>
);
}
return (
<SettingsSection
title="本地 Wiki 自动同步"
description="设置 DeerFlow 本地 Wiki 镜像的后台同步时间。执行时间以服务器本地时间为准。"
>
<div className="space-y-4 rounded-lg border p-4">
<div className="flex items-start justify-between gap-6">
<div className="space-y-1">
<label className="flex items-center gap-2 font-medium" htmlFor="local-wiki-auto-sync-enabled">
<DatabaseIcon className="size-4" />自动同步
</label>
<p id="local-wiki-auto-sync-description" className="text-sm text-muted-foreground">
关闭后不再后台扫描所有知识库;单个知识库的手动同步和向量化不受影响。
</p>
</div>
<Switch
id="local-wiki-auto-sync-enabled"
aria-describedby="local-wiki-auto-sync-description"
checked={draft.enabled}
disabled={settings.isError || actions.save.isPending}
onCheckedChange={(enabled) => updateDraft({ enabled })}
/>
</div>
{draft.enabled && (
<div className="grid gap-4 border-t pt-4 sm:grid-cols-2">
<div className="space-y-2">
<label className="text-sm font-medium" htmlFor="local-wiki-auto-sync-schedule">
同步周期
</label>
<Select
value={draft.schedule}
disabled={actions.save.isPending}
onValueChange={(schedule: "hourly" | "daily") => updateDraft({ schedule })}
>
<SelectTrigger id="local-wiki-auto-sync-schedule">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="hourly">每小时整点</SelectItem>
<SelectItem value="daily">每天固定时间</SelectItem>
</SelectContent>
</Select>
</div>
{draft.schedule === "daily" && (
<div className="space-y-2">
<label className="text-sm font-medium" htmlFor="local-wiki-auto-sync-hour">
每日执行时间
</label>
<Select
value={String(draft.hour)}
disabled={actions.save.isPending}
onValueChange={(value) => updateDraft({ hour: Number(value) })}
>
<SelectTrigger id="local-wiki-auto-sync-hour">
<SelectValue />
</SelectTrigger>
<SelectContent>
{HOURS.map((hour) => (
<SelectItem key={hour} value={String(hour)}>{hourLabel(hour)}</SelectItem>
))}
</SelectContent>
</Select>
</div>
)}
</div>
)}
{settings.isError && (
<p className="text-destructive text-sm" role="alert">
无法读取自动同步设置,请刷新后重试。
</p>
)}
<div className="flex justify-end border-t pt-4">
<Button type="button" onClick={() => void save()} disabled={!isDirty || settings.isError || actions.save.isPending}>
{actions.save.isPending ? <Loader2Icon className="mr-2 size-4 animate-spin" /> : <SaveIcon className="mr-2 size-4" />}
保存设置
</Button>
</div>
</div>
</SettingsSection>
);
}
@@ -1,7 +1,7 @@
"use client";
import { useEffect, useMemo, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -1,7 +1,7 @@
"use client";
import { BrainIcon, Loader2Icon } from "lucide-react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Switch } from "@/components/ui/switch";
import {
@@ -2,7 +2,7 @@
import { PenLineIcon, PlusIcon, SearchIcon, Trash2Icon, Heart, BookOpen, Map, Zap, Target, ShieldAlert, Briefcase, UserRound, Sparkles, Clock, History, Archive } from "lucide-react";
import { useMemo, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import {
@@ -2,7 +2,7 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Switch } from "@/components/ui/switch";
@@ -2,7 +2,7 @@
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { useState, type FormEvent } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -1,7 +1,7 @@
"use client";
import { HistoryIcon, Loader2Icon } from "lucide-react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Switch } from "@/components/ui/switch";
import {
@@ -2,7 +2,7 @@
import { Clock3Icon, FileOutputIcon, ListOrderedIcon, Loader2Icon, UsersIcon } from "lucide-react";
import { useEffect, useState } from "react";
import { toast } from "@/core/ui/feedback";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Switch } from "@/components/ui/switch";
@@ -25,9 +25,6 @@ export function RoundtableRoomSettingsPage() {
const [maxHoldMinutes, setMaxHoldMinutes] = useState(
String(data?.max_hold_minutes ?? 30),
);
const [leaseMinutes, setLeaseMinutes] = useState(
String(data?.lease_minutes ?? 5),
);
const [maxCycles, setMaxCycles] = useState(String(data?.max_cycles ?? 8));
const [activeCount, setActiveCount] = useState<number | null>(null);
@@ -41,12 +38,6 @@ export function RoundtableRoomSettingsPage() {
}
}, [data?.max_hold_minutes]);
useEffect(() => {
if (data?.lease_minutes != null) {
setLeaseMinutes(String(data.lease_minutes));
}
}, [data?.lease_minutes]);
useEffect(() => {
if (data?.max_cycles != null) setMaxCycles(String(data.max_cycles));
}, [data?.max_cycles]);
@@ -74,7 +65,6 @@ export function RoundtableRoomSettingsPage() {
enabled?: boolean;
max_rooms?: number;
max_hold_minutes?: number;
lease_minutes?: number;
max_cycles?: number;
write_file_compatibility_enabled?: boolean;
}) => {
@@ -104,15 +94,6 @@ export function RoundtableRoomSettingsPage() {
void save({ max_hold_minutes: parsed });
};
const saveLeaseMinutes = () => {
const parsed = Number(leaseMinutes);
if (!Number.isInteger(parsed) || parsed < 1 || parsed > 60) {
toast.error("房间租约请填写 1 到 60 的整数");
return;
}
void save({ lease_minutes: parsed });
};
const saveMaxCycles = () => {
const parsed = Number(maxCycles);
if (!Number.isInteger(parsed) || parsed < 2 || parsed > 100) {
@@ -130,7 +111,7 @@ export function RoundtableRoomSettingsPage() {
会商并发与收口
</h3>
<p className="text-muted-foreground text-sm">
配置第二步的全站并发名额、房间租约、最长占用时间和总控强制收口轮数。所有账号共用房间名额;仅打开页面或查看历史记录不占用。
配置第二步的全站并发名额、最长占用时间和总控强制收口轮数。所有账号共用房间名额;仅打开页面或查看历史记录不占用。
</p>
</div>
@@ -206,39 +187,6 @@ export function RoundtableRoomSettingsPage() {
</Button>
</div>
<div className="flex flex-wrap items-end justify-between gap-4 rounded-lg border p-4">
<label className="space-y-1">
<span className="flex items-center gap-2 font-medium">
<Clock3Icon className="size-4" />
房间租约
</span>
<p className="text-muted-foreground text-sm">
默认 5 分钟,可改为 1 到 60 分钟。页面大约每 15 秒续一次;超过这个时间没有续上,房间会释放。保存后,下一次准入和心跳立即按新时长续租。它不会延长单个房间的最长占用时间。
</p>
<div className="mt-2 flex items-center gap-2">
<input
type="number"
min={1}
max={60}
value={leaseMinutes}
disabled={isError || update.isPending}
onChange={(event) => setLeaseMinutes(event.target.value)}
className="border-input bg-background h-9 w-24 rounded-md border px-3 text-sm"
aria-label="会商房间租约分钟数"
/>
<span className="text-muted-foreground text-sm">分钟</span>
</div>
</label>
<Button
type="button"
size="sm"
disabled={isError || update.isPending}
onClick={saveLeaseMinutes}
>
保存租约
</Button>
</div>
<div className="flex flex-wrap items-end justify-between gap-4 rounded-lg border p-4">
<label className="space-y-1">
<span className="flex items-center gap-2 font-medium">
@@ -1,16 +1,19 @@
"use client";
import {
ArchiveIcon,
ArrowRightLeftIcon,
BarChart3Icon,
BrainIcon,
BookPlusIcon,
CpuIcon,
DatabaseIcon,
ArchiveIcon,
FileOutputIcon,
HistoryIcon,
ImageIcon,
PaletteIcon,
SearchIcon,
ShieldCheckIcon,
ShrinkIcon,
SparklesIcon,
TypeIcon,
@@ -30,10 +33,13 @@ import {
import { ScrollArea } from "@/components/ui/scroll-area";
import { AboutSettingsPage } from "@/components/workspace/settings/about-settings-page";
import { AccountSettingsPage } from "@/components/workspace/settings/account-settings-page";
import { AgentSkillMigrationSettingsPage } from "@/components/workspace/settings/agent-skill-migration-settings-page";
import { AuthenticationSettingsPage } from "@/components/workspace/settings/authentication-settings-page";
import { AppearanceSettingsPage } from "@/components/workspace/settings/appearance-settings-page";
import { AppIdentitySettingsPage } from "@/components/workspace/settings/app-identity-settings-page";
import { ContextWindowSettingsPage } from "@/components/workspace/settings/context-window-settings-page";
import { AppIdentitySettingsPage } from "@/components/workspace/settings/app-identity-settings-page";
import { CallMetricsSettingsPage } from "@/components/workspace/settings/call-metrics-settings-page";
import { GeneratedPageBrandingSettingsPage } from "@/components/workspace/settings/generated-page-branding-settings-page";
import { ModelPromptSettingsPage } from "@/components/workspace/settings/model-prompt-settings-page";
import { WorkerPoolSettingsPage } from "@/components/workspace/settings/worker-pool-settings-page";
import { ApiReadCacheSettingsPage } from "@/components/workspace/settings/api-read-cache-settings-page";
@@ -42,12 +48,12 @@ import { RoundtableRoomSettingsPage } from "@/components/workspace/settings/roun
import { RetryKeepPartialSettingsPage } from "@/components/workspace/settings/retry-keep-partial-settings-page";
import { KnowledgeRetrievalSettingsPage } from "@/components/workspace/settings/knowledge-retrieval-settings-page";
import { KnowledgeBatchCreateSettingsPage } from "@/components/workspace/settings/knowledge-batch-create-settings-page";
import { LocalWikiAutoSyncSettingsPage } from "@/components/workspace/settings/local-wiki-auto-sync-settings-page";
import { MemoryRuntimeSettingsPage } from "@/components/workspace/settings/memory-runtime-settings-page";
import { ToolSettingsPage } from "@/components/workspace/settings/tool-settings-page";
import { UploadSettingsPage } from "@/components/workspace/settings/upload-settings-page";
import { WriteFileCompatibilitySettingsPage } from "@/components/workspace/settings/write-file-compatibility-settings-page";
import { getStoredAuth } from "@/core/auth";
import { useLiveAccount } from "@/core/auth/use-live-account";
import { useI18n } from "@/core/i18n/hooks";
import { cn } from "@/lib/utils";
import { LocalEncoderSettingsCard } from "@/strategy-components/components/resource-management/llmwiki/WeKnoraKnowledgeWorkspace";
@@ -56,6 +62,7 @@ import { ServerDiagnosticsPanel } from "@/pages/ServerDiagnosticsPage";
type SettingsSection =
| "account"
| "appearance"
| "authentication"
| "conversation-context"
| "model-prompts"
| "server-diagnostics"
@@ -65,8 +72,9 @@ type SettingsSection =
| "roundtable-rooms"
| "knowledge-retrieval"
| "knowledge-batch-create"
| "local-wiki-auto-sync"
| "appIdentity"
| "generatedPageBranding"
| "agentSkillMigration"
| "memory"
| "fileWriting"
| "callMetrics"
@@ -84,6 +92,7 @@ export function SettingsDialog(props: SettingsDialogProps) {
const { defaultSection = "appearance", ...dialogProps } = props;
const { t } = useI18n();
const isAdmin = getStoredAuth()?.system_role === "admin";
const live = useLiveAccount();
const [activeSection, setActiveSection] =
useState<SettingsSection>(defaultSection);
@@ -119,13 +128,15 @@ export function SettingsDialog(props: SettingsDialogProps) {
{ id: "chat-archive", label: "聊天记录归档", icon: ArchiveIcon },
{ id: "roundtable-rooms", label: "会商并发", icon: UsersIcon },
{ id: "knowledge-retrieval", label: "知识检索", icon: SearchIcon },
{ id: "local-wiki-auto-sync", label: "知识库同步", icon: DatabaseIcon },
{ id: "appIdentity", label: "系统名称", icon: TypeIcon },
{ id: "generatedPageBranding", label: "生成网页标识", icon: ImageIcon },
{ id: "agentSkillMigration", label: "智能体与技能迁移", icon: ArrowRightLeftIcon },
{ id: "memory", label: "问答记忆", icon: BrainIcon },
{ id: "fileWriting", label: "文件流式兼容", icon: FileOutputIcon },
{ id: "callMetrics", label: "调用统计", icon: BarChart3Icon },
{ id: "retryKeepPartial", label: "保留中间正文", icon: HistoryIcon },
{ id: "uploads", label: "上传设置", icon: UploadCloudIcon },
{ id: "authentication", label: "登录与注册", icon: ShieldCheckIcon },
]
: []),
{ id: "knowledge-batch-create", label: "批量新增知识库", icon: BookPlusIcon },
@@ -220,15 +231,24 @@ export function SettingsDialog(props: SettingsDialogProps) {
{activeSection === "knowledge-retrieval" && isAdmin && (
<KnowledgeRetrievalSettingsPage />
)}
{activeSection === "local-wiki-auto-sync" && isAdmin && (
<LocalWikiAutoSyncSettingsPage />
)}
{activeSection === "knowledge-batch-create" && (
<KnowledgeBatchCreateSettingsPage />
)}
{activeSection === "authentication" && isAdmin && (
<AuthenticationSettingsPage
key={live.userId}
onClose={() => props.onOpenChange?.(false)}
/>
)}
{activeSection === "appIdentity" && isAdmin && (
<AppIdentitySettingsPage />
)}
{activeSection === "generatedPageBranding" && isAdmin && (
<GeneratedPageBrandingSettingsPage />
)}
{activeSection === "agentSkillMigration" && isAdmin && (
<AgentSkillMigrationSettingsPage />
)}
{activeSection === "memory" && isAdmin && (
<MemoryRuntimeSettingsPage />
)}
File diff suppressed because it is too large. Load diff
Loaded 100 of 588 files, more files were not shown because too many files have changed in this diff. Show more