Skip to content

Refactor/migrate server local - #19

Merged
lius-new merged 61 commits into
mainfrom
refactor/migrate-server-local
Aug 12, 2026
Merged

Refactor/migrate server local#19
lius-new merged 61 commits into
mainfrom
refactor/migrate-server-local

Conversation

@lius-new

Copy link
Copy Markdown
Contributor

Summary

How did you test this change?

Screenshots or recordings

Checklist

  • I read CONTRIBUTING.md.
  • I kept this pull request focused and avoided unrelated changes.
  • I ran the checks or validations relevant to this change, or explained why I could not.
  • I did not include secrets, credentials, or other sensitive production-only material.

lius-new and others added 30 commits February 3, 2026 15:52
Co-authored-by: Cursor <cursoragent@cursor.com>
- 删除 config.console-gateway.*.toml
- 新增 configs/README.md
- 更新 lib、main 及 routes

Co-authored-by: Cursor <cursoragent@cursor.com>
- 删除 config.update-gateway.*.toml(update-gateway 独立为 simprint-update-server)
- 新增 migrations/20250127000003_create_machine_tags_tables.sql

Co-authored-by: Cursor <cursoragent@cursor.com>
- 数据库迁移: version_types 增加 is_auto_download,versions 增加内核相关字段,插入默认版本类型
- 配置: minio 增加 version_resource_bucket
- 新增: machine_tags 模块 (dto/entitys/models/services)
- 重构: gray_releases、gray_resources、machine_gray_allocations、machine_users、maintenance、strategy_types、version_types、versions、extensions 等
- 调整: handlers、middlewares、utils 等

Co-authored-by: Cursor <cursoragent@cursor.com>
- 新增 browser_kernel service/handler/route 模块
- 新增 query_browser_kernel_latest_versions 模型查询
- 筛选 SIMPRINT_KERNEL_* 类型,按 resource_name 分组取最新版本
- 最新判定优先级:is_latest > pub_date/created_at > id
- 支持可选 platform 参数过滤
- 路由: POST /browser-kernels/list

Co-authored-by: Cursor <cursoragent@cursor.com>
- 将 ListBrowserKernelsRequest 移至 entitys/browser_kernel.rs
- 查询接口新增 type_code 参数,支持按版本类型过滤
- models/versions 支持 type_code_filter 四种组合查询
- config: 新增 extension_bucket 配置

Co-authored-by: Cursor <cursoragent@cursor.com>
- UpdateUserRequest: 新增 phone、email 字段
- UserResponse: 新增 avatar_url 头像完整 URL
- update_user_info: 支持更新 phone、email
- get_current_user_service: 返回 avatar_url(基于 minio 拼接)

Co-authored-by: Cursor <cursoragent@cursor.com>
核心功能:
- 实现 Redis Stream 事件发布系统
- 为所有数据变更操作添加事件通知
- 支持增量同步和全量刷新降级
- 事件包含 affected_apis 字段用于缓存失效

新增模块:
- dto/events.rs: 事件数据结构定义
- services/events.rs: 事件发布服务(Redis Stream)
- handlers/events.rs: 事件同步 API 处理器
- routes/events.rs: 事件同步路由

事件发布集成:
- environments.rs: 23 个操作(环境/分组/标签 CRUD + 关联操作)
- accounts.rs: 4 个操作(账号 CRUD)
- proxies.rs: 4 个操作(代理 CRUD)

基础设施:
- middlewares.rs: 添加路径提取函数(去除 /api/v*/ 前缀)
- auth.rs: 在 RequestContext 中设置 resource_identifier
- state.rs: 添加 resource_identifier 字段和访问方法

事件存储:
- Redis Stream 存储,72 小时 TTL
- 支持 last_event_id 增量同步
- 超过 72 小时触发 full_refresh 标志
修复问题:
- 修复total字段返回错误(返回当前页数量而非数据库总数)
- 实现keyword搜索功能(支持按环境名称和UUID搜索)
- 实现tag_uuids过滤功能(支持按标签过滤)

主要改动:
1. services/environments.rs
   - 从payload.filters中提取keyword和tag_uuids参数
   - 调用fetch_environments_count获取数据库总数
   - 将keyword和tag_uuids传递给models层
   - 修复total返回值(使用数据库总数而非过滤后数量)

2. models/environments.rs
   - fetch_environments_base: 添加keyword和tag_uuids参数
     * keyword: 使用ILIKE进行模糊搜索(name和uuid字段)
     * tag_uuids: 使用LEFT JOIN environment_tags表进行过滤
     * 使用动态SQL构建查询,支持可选参数
   - fetch_environments_count: 添加相同的过滤条件
     * 使用COUNT(DISTINCT e.id)避免JOIN导致的重复计数

技术细节:
- 使用动态SQL构建,根据参数动态添加WHERE条件
- 标签过滤使用ANY操作符支持多标签查询
- 搜索使用ILIKE支持不区分大小写的模糊匹配

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- 添加回收站列表查询接口
- 实现环境恢复功能(单个和批量)
- 实现永久删除功能(单个和批量)
- 支持回收站数据的过滤和分页
- 注册回收站相关路由

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- 实现 batch_get_environments_handler 接口
- 支持一次请求获取多个环境的完整详情
- 返回 HashMap<String, EnvironmentDetailResponse> 格式
- 对查询失败或不存在的环境自动跳过,不影响其他环境
- 注册路由 POST /environments/batch-detail
- 优化前端批量启动性能,减少 API 调用次数

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- 修复 ON CONFLICT 约束匹配问题,使用正确的唯一约束 (team_uuid, user_uuid, workspace_uuid)
- 修改接受邀请逻辑:使用被邀请用户的工作空间而非团队所属工作空间
- 添加 fetch_user_current_workspace 函数获取用户当前工作空间
- 添加邀请用户存在性检测:只允许邀请已注册用户
- 简化邀请流程:移除不必要的 Option 判断

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
将扩展相关表的 status 字段默认值从 'installed' 改为 'active',
注释从 'installed, disabled' 改为 'active, inactive',
以对齐代码实现中使用的状态值。

影响的表:
- user_extensions
- team_extensions
- group_extensions
- environment_extensions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
## 功能说明
- 普通用户可以禁用团队安装的插件(无需卸载权限)
- 禁用后插件不会在浏览器中加载,但可随时重新启用
- 禁用状态仅对当前用户生效,不影响其他团队成员

## 数据库变更
- 新增 user_team_extension_preferences 表存储用户对团队插件的偏好设置
- 添加 is_disabled 字段标识禁用状态

## 后端变更
- 新增 DTO: UserTeamExtensionPreferenceDto
- 新增 Model 函数:
  - fetch_user_disabled_team_extensions: 查询用户禁用的团队插件列表
  - set_user_team_extension_preference: 设置禁用状态
  - delete_user_team_extension_preference: 删除禁用设置
  - fetch_team_shared_group_uuids_by_extension_id: 查询团队共享的分组UUID
- 修改 Service:
  - disable_extension_service: 使用新表存储禁用状态
  - enable_extension_service: 删除禁用设置
  - get_team_installed_extensions_service: 查询并标记用户禁用的插件
- 修改 Handler:
  - disable_extension_handler: 获取team_uuid并传递
  - enable_extension_handler: 获取team_uuid并传递

## 修复问题
- 修复 fetch_team_member 函数调用缺少 workspace_uuid 参数的编译错误
- 修复团队插件查询时错误显示个人分组的问题(只显示团队共享分组)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- 添加数据库迁移文件,为 extensions 表添加 hash 字段(VARCHAR(255),允许为空)
- 更新 ExtensionDto 和 ExtensionSummaryDto,添加 hash 字段
- 更新 CreateExtensionParams 和 UpdateExtensionParams,支持 hash 字段
- 更新所有扩展相关的 SQL 查询(CREATE、UPDATE、SELECT)
- 在 get_environment_extensions_service 中填充 hash 字段
- environments/list 接口返回的 extensions 现在包含 hash 字段

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- get_environment_handler: 添加扩展列表查询
- batch_get_environments_handler: 批量查询时也返回扩展数据
- 调用 get_environment_extensions_service 获取用户、团队、分组的扩展
- 移除硬编码的空数组,返回实际扩展数据

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
在环境详情和代理摘要接口中添加 username 和 password_encrypted 字段,
支持前端获取完整的代理配置信息用于启动浏览器。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lius-new added 29 commits May 6, 2026 12:14
Import the complete Simprint Server source tree under server/ while preserving its repository history as a merge parent.

git-subtree-dir: server

git-subtree-mainline: df5f4a2

git-subtree-split: a62acd4
Move route registration and service startup into the library so the desktop application can embed the server on a loopback address with graceful shutdown. Fix secret tests to resolve fixtures from the crate root.
Format response metadata directly and add a regression test so Display can no longer recurse until stack overflow.
Use an in-process TTL cache when Redis is omitted, add a local filesystem object storage backend with traversal protection, and expose local assets without API authentication. Preserve Redis and S3 compatibility.
Drop the unused MinIO upload subsystem and Redis backend. Keep only URL formatting for externally hosted download resources and transient in-process state required by the temporary HTTP compatibility layer.
Preserve the existing implementation, SQL models, migrations, and service code byte-for-byte under src-tauri/crates/business before adapting or removing the standalone server shell.
Rename the copied crate to business, wire it into simprint, and remove the standalone HTTP, deployment, and transport-encryption shell while preserving models, services, DTOs, entities, and migrations.
Remove server-only billing, marketplace, and referral domains, then adapt the original model queries and connection pool in place for embedded SQLite. No parallel repository or duplicated business implementation is introduced.
Move business APIs and authentication to the embedded local database, remove remote-only product flows, add the local browser-kernel registry, and make startup readiness deterministic.
Replace the custom forced updater with the official Tauri v2 updater and an in-app update prompt. Publish embedBootstrapper and fixed-runtime installers for x64, ARM64, and x86 while keeping latest.json limited to embedBootstrapper artifacts.
Publish signed fixed-runtime updater artifacts through latest-fixed.json while keeping latest.json dedicated to embedBootstrapper. Validate build-mode configuration and resolve manifest asset IDs against release metadata before publishing.
@lius-new
lius-new merged commit 5f47b71 into main Aug 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant