← Back to Pull requests

feat: add global environment variables in launcher settings #31

Open
unknown opened this pull request with 213 lines diff across 2 files
View on GitHub
unknown unknown commented on Oct 30, 2026 07:58 UTC
Author

修改内容

设置页最底部新增「全局环境变量」,支持按行填写 KEY=VALUE、校验和显式保存,统一应用到所有本地实例的下一次启动。此前只能逐个实例配置同样的变量。

  • 启动时按系统/所选运行环境 → 全局配置 → 实例配置覆盖;KIRA_LAUNCH_SOURCE 仍由启动器固定为 launcher。

  • Windows 下环境变量名按大小写不敏感合并,避免 Path/PATH 重复导致覆盖失效。

  • 复用全局与实例的解析、校验逻辑,保留空值、空格以及值中的等号;中英文界面同步更新。

  • 兼容旧版 settings.json:缺少 environmentVariables 时默认为空,保持旧版本的启动行为。原有 project-store 校验导出仍保留,调用接口不变。

  • 变量以明文存于本机设置文件;仅作用于实例运行,不用于依赖安装或修改系统环境,也不影响已运行实例。
  • 设置类型、持久化、渲染进程保存队列、实例启动和相关测试夹具需要同步修改,因此在同一个功能 PR 中交付。

    回归验证

  • npm run build:通过(Vue/前端/Electron TypeScript);Vite 提示产物 chunk 大小警告,未阻止构建。

  • node --test --test-reporter=spec tests/.test.mjs:172 项全部通过。

  • git diff --cached --check:通过。

  • Vue 模板编译与设置区块顺序校验:通过,全局环境变量位于设置最底部。

  • 覆盖配置持久化、旧配置默认值、清空后恢复继承、非法名称/重复项/长度限制、空字符、空值/空格/等号、跨平台合并、实际 spawn 环境、保留启动标记、并发设置保存,以及中英文 key/插值一致性。
  • 影响范围与潜在回归点

    调用链:设置页 → IPC settings.save → settings.json → 本地实例启动时合并环境。共享校验也用于单实例高级设置和项目配置读取;完整回归测试包含运行环境、部署、启停、会话恢复、更新和 WebUI 登录。

    主要回归点为保存其他设置时丢失全局变量、变量覆盖优先级和 Windows 名称大小写,已增加相应断言。云实例和依赖安装路径保持既有行为。未进行真实桌面界面点击测试或连接实际 KiraAI 服务的端到端启动测试。

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Added settings for global environment variables, which are applied to local project processes the next time they start.
    Global variables can be entered as KEY=value lines and saved in the app. Project-specific values take precedence over global values, which take precedence over system values.
    * Invalid entries are rejected with a validation message. Variables are stored locally as plain text and do not apply to dependency installation.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 213 lines (+159 / -54) across 2 files Reviewer: coderabbitai[bot] Review duration: 7m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.37) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 213 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.321
    Real PR Conversation Timeline
    1 comments
    "Review active on #31"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.6% (MEDIUM) · Higher = larger blast radius
    36.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.5% · Safe to merge
    19.5%