Skip to content

[Windows/Install] 快捷方式依赖源码目录 / Installed shortcuts depend on the source checkout #56

Description

@rwang23

中文

平台与版本

  • 平台:Windows x64
  • Dream Skin:main5fd8af532efbaa87d2d0092297fd2d45cd56574e
  • 问题类型:安装后的快捷方式失效

问题

Windows 安装器创建的启动、恢复和托盘快捷方式直接指向执行安装时的源码目录。用户移动、重命名或删除仓库克隆后,快捷方式会引用不存在的 *.ps1 文件。主题状态已经保存在 %LOCALAPPDATA%\CodexDreamSkin,运行脚本却仍留在源码目录。

源码中的路径关系可以直接确认:

  • windows/scripts/install-dream-skin.ps1$PSScriptRoot 生成 start-dream-skin.ps1restore-dream-skin.ps1tray-dream-skin.ps1 的绝对路径。
  • 三类快捷方式的 ArgumentsWorkingDirectory 都保留这个源码路径。
  • PR Add configurable and safer Windows Dream Skin flow #3 同样从 $PSScriptRoot 创建快捷方式;它处理主题配置和启动安全,没有安装独立运行时。

复现路径

  1. 将仓库克隆到目录 A。
  2. 关闭 Codex,运行 windows/scripts/install-dream-skin.ps1
  3. 查看 Codex Dream SkinCodex Dream Skin - RestoreCodex Dream Skin - Tray 快捷方式的参数。
  4. 把目录 A 移到目录 B,或删除目录 A。
  5. 再运行任一快捷方式。

预期结果

安装完成后的快捷方式只依赖受管安装目录,原始仓库克隆的位置和生命周期不会影响启动、恢复或托盘入口。

实际结果

快捷方式继续执行目录 A 下的脚本。目录 A 不存在后,启动、恢复和托盘入口都会失效。

建议修复

安装时把运行所需的 assets/scripts/ 复制到:

%LOCALAPPDATA%\CodexDreamSkin\engine

安装流程应当:

  1. 先复制到同一状态目录内的 staging 目录。
  2. 拒绝源码和现有 engine 中的 junction、符号链接等 reparse point。
  3. 校验 staged 文件数量和 SHA-256。
  4. 用同卷目录移动替换现有 engine,替换失败时恢复上一份 engine;恢复失败时保留备份并报告准确路径。
  5. 让启动、恢复和托盘快捷方式及其 WorkingDirectory 全部指向受管 engine。
  6. 重装前检查旧托盘进程,避免新旧脚本混用。

验收标准

  • 三个快捷方式只引用 %LOCALAPPDATA%\CodexDreamSkin\engine 下的文件。
  • 原始仓库克隆被移动或删除后,受管 engine 中的三个入口仍然存在并可解析。
  • 重装完整替换旧 engine,不保留源码中已经删除的运行文件。
  • 不完整或校验失败的源码不会替换当前 engine,也不会留下正常事务残留。
  • 源码路径包含空格和中文时仍可安装。
  • 不修改 Codex 官方安装目录、config.toml 处理方式、CDP 绑定或主题格式。

自检与关联


English

Platform and version

  • Platform: Windows x64
  • Dream Skin: main at 5fd8af532efbaa87d2d0092297fd2d45cd56574e
  • Category: installed shortcuts fail after the checkout moves

Problem

The Windows installer creates launch, restore, and tray shortcuts that point directly to the source checkout used during installation. Moving, renaming, or deleting that checkout leaves the shortcuts pointing to missing *.ps1 files. Theme state already lives in %LOCALAPPDATA%\CodexDreamSkin, but the runtime scripts remain in the source tree.

The source establishes the path dependency directly:

  • windows/scripts/install-dream-skin.ps1 derives the absolute paths for start-dream-skin.ps1, restore-dream-skin.ps1, and tray-dream-skin.ps1 from $PSScriptRoot.
  • The shortcut arguments and working directories retain that source path.
  • PR Add configurable and safer Windows Dream Skin flow #3 also creates shortcuts from $PSScriptRoot. It covers theme configuration and launch safety rather than a standalone installed runtime.

Reproduction path

  1. Clone the repository into directory A.
  2. Close Codex and run windows/scripts/install-dream-skin.ps1.
  3. Inspect the arguments of the Codex Dream Skin, Codex Dream Skin - Restore, or Codex Dream Skin - Tray shortcut.
  4. Move directory A to directory B, or delete directory A.
  5. Run any shortcut again.

Expected behavior

Installed shortcuts depend only on a managed installation directory. The location and lifecycle of the original checkout do not affect launch, restore, or tray entry points.

Actual behavior

The shortcuts continue to execute scripts under directory A. Once directory A is gone, the launch, restore, and tray entry points fail.

Proposed fix

Copy the required assets/ and scripts/ into this managed location during installation:

%LOCALAPPDATA%\CodexDreamSkin\engine

The installer should:

  1. Copy the runtime into a staging directory under the same state root.
  2. Reject junctions, symbolic links, and other reparse points in the source and existing engine.
  3. Verify staged file counts and SHA-256 hashes.
  4. Replace the existing engine with same-volume directory moves and restore the previous engine if replacement fails. Preserve the backup at a reported path if restoration fails.
  5. Point all shortcut arguments and working directories at the managed engine.
  6. Check for an older tray process before reinstalling to avoid mixing source and managed scripts.

Acceptance criteria

  • All three shortcuts reference only files under %LOCALAPPDATA%\CodexDreamSkin\engine.
  • All three managed entry points remain present and parse after the original checkout is moved or removed.
  • Reinstall completely replaces the old engine and removes files deleted from the source.
  • An incomplete or invalid source leaves the current engine unchanged and leaves no normal transaction artifacts.
  • Installation works when the source path contains spaces and Chinese characters.
  • The change does not modify the official Codex package, config.toml behavior, CDP binding, or theme format.

Self-check and links

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions