Skip to content

feat(qoder): elevate NewQoder and Qoder IDE into 4 independent first-class platforms with isolated storage and multi-instance support - #2349

Open
zoutao212 wants to merge 3 commits into
jlcodes99:mainfrom
zoutao212:feat/qoder-four-independent-platforms
Open

zoutao212 wants to merge 3 commits into
jlcodes99:mainfrom
zoutao212:feat/qoder-four-independent-platforms

Conversation

@zoutao212

Copy link
Copy Markdown
Contributor

概述 (Summary)

本 PR 将 Qoder 从此前单一粗粒度的 Provider,彻底提升重构为 4 个物理隔离的一等公民独立系统平台,在架构设计上 100% 对齐现存成熟的 Trae 系列架构(trae、trae_solo、trae_cn、trae_solo_cn)。

Qoder 产品矩阵中的 4 款应用(国际版 IDE、国内版 IDE、国际版桌面 App、国内版桌面 App)均获得 Cockpit Tools 完整的独立平台地位:具备独立的路由页面、完全物理隔离的账号与凭据存储、独立的应用多开生命周期,以及完全解耦的启动路径与配置管理。


Qoder 四产品矩阵架构对照表

产品线 平台标识 (Platform ID) 凭据存储介质与加密机制 目标进程与主程序名 官方默认启动路径
1. Qoder IDE (国际版) qoder SQLite state.vscdb
%APPDATA%\Qoder\User\globalStorage
Qoder IDE.exe / Qoder.exe C:\Program Files\Qoder IDE\Qoder IDE.exe
2. Qoder CN IDE (国内版) qoder_cn_ide SQLite state.vscdb
%APPDATA%\QoderCN\User\globalStorage
Qoder CN IDE.exe / Qoder.exe C:\Program Files\Qoder CN IDE\Qoder CN IDE.exe
3. Qoder (国际版桌面 App) qoder_app DPAPI AES-256-GCM auth.v1.dat
%APPDATA%\com.qoder.app.stable
Qoder.exe C:\Program Files\Qoder\Qoder\Qoder.exe
4. Qoder CN (国内版桌面 App) qoder_cn_app DPAPI AES-256-GCM auth.v1.dat
%APPDATA%\com.qodercn.app.stable
Qoder CN.exe C:\Program Files\Qoder CN\Qoder CN\Qoder CN.exe

核心技术能力与实现细节

1. 四渠道凭据物理隔离(杜绝跨目录盲注与串号)

  • IDE 渠道 (qoder, qoder_cn_ide):
    • 账号凭据精准注入到各自对应的数据目录 state.vscdb SQLite 数据库中;
    • 启动前自动执行 SQLite WAL 截断并清理 -wal / -shm 临时缓存日志,彻底解决切换账号后被 SQLite 缓存回滚的顽疾。
  • 桌面 App 渠道 (qoder_app, qoder_cn_app):
    • 自动读取并解密 Electron 的 Local State(DPAPI v10 机制),提取 AES-GCM 主密钥;
    • 构造 auth.v1.dat 结构,采用 12 字节高强度随机 IV 进行 AES-256-GCM 加密,并保留完整的校验头,保证 App 启动直接识别。
  • 零跨端污染:4 个渠道各自管理自己的账号台账、额度缓存与当前选中游标,完全物理隔绝。

2. 四平台独立应用多开管理 (Multi-Instance)

  • 彻底解绑此前 Qoder 套件(suite)聚合多开的限制;
  • 4 个平台均享有完全独立的“应用多开”功能,各自可创建独立的实例槽位,支持指定专属的 --user-data-dir 用户目录隔离与自定义启动参数。

3. 双端 OpenAPI 容灾互备与 Token 自动续期

  • 端点自动分流与兜底:
    • 国际版账号默认路由到 https://openapi.qoder.sh;
    • 国内版/阿里内网等企业账号默认路由到 https://openapi.qoder.com.cn;
    • 若主端点返回 404/5xx,系统自动执行跨端点保活探测与故障切换。
  • 401 Token 自动续期:
    • 检测到凭据过期(HTTP 401)时,自动提取凭据中的 refresh_token 并调用 POST /api/v1/deviceToken/refresh 换取新令牌;
    • 自动将续期后的凭据回写持久化至当前平台账号存储,避免频繁退出登录。
  • 企业版配额精确解析:
    • 完整解析企业版账号中的 orgResourcePackage(含 cap 上限),精准对齐为 addOnQuota 资源包展示。

4. 设置页面与启动路径完全独立解耦

  • 快捷设置弹窗 (QuickSettingsPopover):
    • 移除了此前将 4 个路径聚合堆叠在一个弹窗中的旧逻辑;
    • 各 Qoder 页面点击右上角齿轮时,仅呼出当前平台专属的单一设置,只展示当前平台启动路径、文件选择与进程检测按钮。
  • 主设置页 (SettingsGeneralPanel):
    • 拆分为 4 个独立的设置卡片(Qoder IDE 设置、Qoder 设置、Qoder CN IDE 设置、Qoder CN 设置);
    • 均支持「选择路径」与 Windows 下的「检测运行中应用 (scan_app_launch_targets)」。
  • 侧边栏与布局:
    • 经典模式侧边栏上限由 6 个放宽至 10 个;
    • 启动时自动清洗与迁移用户本地 localStorage 历史脏数据(如 Qoder_app 等下划线命名),升级为无下划线的规范大写单例组。

验证与测试 (Verification)

  • 自动化单测:新增 src/types/qoder.test.ts,涵盖企业配额计算、资源包上限解析与渠道身份推导,执行 node --test 全部通过 (2/2 Passed);
  • 前端类型检查:执行 npm run typecheck (tsc --noEmit) 零错误通过;
  • Rust 后端编译:执行 cargo check --manifest-path src-tauri/Cargo.toml 零错误通过;
  • 正式发布包编译:执行官方打包流水线 npm run tauri build -- --no-bundle 构建成功,验证产物体积达 94.7 MB(完整内置前端静态资源,非白屏残壳);
  • 端到端实测:在 Windows 11 环境下,针对全部 4 款 Qoder 应用进行了完整的切号冷热启动、WAL 截断、多开实例拉起及路径重置检测测试,功能全部正常。

Summary

Elevate Qoder from a single rudimentary provider into 4 physically isolated, first-class platforms, aligning 1:1 with the established multi-product architecture of the Trae family (trae, trae_solo, trae_cn, trae_solo_cn).

Each product in the Qoder matrix is now an independent citizen within Cockpit Tools, featuring dedicated routing, isolated credential storage, independent multi-instance lifecycles, and separate path/refresh configuration pages.


The Qoder 4-Product Matrix Architecture

Product Platform ID Credential Storage & Encryption Process & Binary Target Default Path
Qoder IDE (Global) qoder SQLite state.vscdb
%APPDATA%\Qoder\User\globalStorage
Qoder IDE.exe / Qoder.exe C:\Program Files\Qoder IDE\Qoder IDE.exe
Qoder CN IDE (Domestic) qoder_cn_ide SQLite state.vscdb
%APPDATA%\QoderCN\User\globalStorage
Qoder CN IDE.exe / Qoder.exe C:\Program Files\Qoder CN IDE\Qoder CN IDE.exe
Qoder (Global Desktop App) qoder_app DPAPI AES-256-GCM auth.v1.dat
%APPDATA%\com.qoder.app.stable
Qoder.exe C:\Program Files\Qoder\Qoder\Qoder.exe
Qoder CN (Domestic Desktop App) qoder_cn_app DPAPI AES-256-GCM auth.v1.dat
%APPDATA%\com.qodercn.app.stable
Qoder CN.exe C:\Program Files\Qoder CN\Qoder CN\Qoder CN.exe

Key Features & Implementations

1. Physical Isolation Across All 4 Channels (No Cross-Directory Pollution)

  • IDE Channels (qoder, qoder_cn_ide):
    • Injects account credentials into respective state.vscdb databases.
    • Automatically truncates SQLite WAL journals (-wal and -shm) prior to launch to prevent credential reversion.
  • Desktop App Channels (qoder_app, qoder_cn_app):
    • Decrypts and parses electron Local State (DPAPI v10) to obtain the AES-GCM master key.
    • Generates and encrypts auth.v1.dat using 12-byte random IVs and AES-256-GCM payloads with strict binary integrity.
  • Zero Cross-Contamination: Each channel maintains its own independent account list, quota state, and active account cursor.

2. Multi-Instance Management Across All 4 Products

  • Fully unbinds Qoder from composite suites, allowing independent multi-instance creation for qoder, qoder_app, qoder_cn_ide, and qoder_cn_app.
  • Supports independent user data directory isolation (--user-data-dir) and custom process arguments for each instance.

3. Dual-Endpoint Fallback & Resilient Token Renewal

  • Domain Auto-Routing:
    • Global accounts route to https://openapi.qoder.sh.
    • Domestic/Alibaba enterprise accounts route to https://openapi.qoder.com.cn.
    • Automatic cross-endpoint fallback probing if the primary endpoint returns 404/5xx.
  • Auto-Renewal on 401:
    • Automatically extracts the refresh_token from credentials and calls POST /api/v1/deviceToken/refresh when access tokens expire.
    • Persists renewed tokens back into the active channel account seamlessly.
  • Enterprise Add-on Quota Parsing:
    • Accurately parses orgResourcePackage and enterprise resource plans into addOnQuota for all accounts.

4. Decoupled Settings & Navigation

  • Quick Settings Popover: Clicking the settings gear on any Qoder page now presents a clean, single-platform settings popover dedicated exclusively to that product.
  • General Settings: 4 separate settings cards in SettingsGeneralPanel, with independent launch path inputs, file pickers, and live process detection (scan_app_launch_targets).
  • Sidebar & Tray: Supports individual sidebar toggling, customized order, platform layout presets, and tray quick-switch menus.
  • Automatic Migration: Automatically normalizes legacy localStorage entries (e.g. Qoder_app, Qoder_cn_ide) into canonical platform identities without user data loss.

Verification & Testing

  • Unit Tests: Added src/types/qoder.test.ts covering enterprise quota models, orgResourcePackage calculations, and channel identity resolution.
  • Typecheck: npm run typecheck (tsc --noEmit) passes with 0 errors.
  • Rust Compilation: cargo check --manifest-path src-tauri/Cargo.toml passes with 0 errors.
  • Release Packaging: Built with official CLI npm run tauri build -- --no-bundle, verified output executable size (~94.7 MB) with full embedded frontend assets.
  • Runtime Verification: Tested full switch lifecycle, multi-instance launching, and path detection for all 4 Qoder products on Windows 11.

…ith isolated storage and multi-instance support

- Elevate Qoder into 4 physically isolated first-class platforms (qoder, qoder_app, qoder_cn_ide, qoder_cn_app), perfectly mirroring the Trae family architecture
- Support SQLite state.vscdb injection for IDE products and DPAPI AES-256-GCM auth.v1.dat encryption for Desktop App products
- Provide dedicated multi-instance creation, custom user data directories, and independent launch arguments
- Implement dual OpenAPI endpoint probing (openapi.qoder.sh / openapi.qoder.com.cn) and auto token renewal on 401
- Decouple quick settings popover and general settings cards into single-platform configuration views
- Normalize UI display names and provide full i18n support across English and Chinese

This branch has not been deployed

No deployments
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