Skip to content

fix(cli): recover sessions after their working directory moves #2529

Closed

Description

@me2seeks

Problem

An interactive session cannot be recovered after its project directory is moved or renamed.

I reproduced this on current main (671c4a64):

  1. Start the TUI in repository A and create a session.

  2. Exit Maka and move repository A to a new path.

  3. Run maka --resume <session-id>.

  4. Maka reports:

    Could not resume session <id>: Session cwd no longer exists: <old-path>. Starting fresh.
    

The safety behavior is correct: Maka must not silently rebind the session to the shell's current directory. The recovery gap is that /move is only available after a session has opened, while this session is rejected before the user can run /move.

Expected behavior

Provide an explicit recovery path that preserves the existing session and moves its working-directory authority before opening it, for example:

maka --resume <session-id> --cwd <new-path>

This should reuse the existing session relocation boundary rather than adding a second writer:

  • validate and canonicalize the replacement directory;
  • persist the new cwd through session.cwd.relocate;
  • preserve the existing Runtime Host relocation semantics and surface the committed path;
  • open the same session only after relocation succeeds;
  • keep invalid or omitted overrides fail-closed;
  • mention the recovery form in the missing-cwd error.

No automatic fallback to process.cwd() is intended.

I can take this.

简体中文

问题

项目目录被移动或重命名后,交互式 Session 无法恢复。

我在当前 main(671c4a64)上完成了复现:

  1. 在仓库 A 中启动 TUI 并创建 Session;
  2. 退出 Maka,把仓库 A 移动到新路径;
  3. 执行 maka --resume <session-id>;
  4. Maka 提示原 cwd 已不存在,并启动一个新 Session。

拒绝静默使用当前 shell 目录是正确的安全行为。真正的缺口在于:/move 只能在 Session 成功打开后执行,而 cwd 已失效的 Session 会在用户能够执行 /move 之前被拒绝。

期望行为

提供显式恢复入口,例如:

maka --resume <session-id> --cwd <new-path>

该入口应复用现有 session.cwd.relocate 权威边界,先校验并持久化新 cwd,再打开同一个 Session,并向用户显示 Host 最终提交的路径。未提供或无效的 override 仍应安全失败,不应自动采用 process.cwd()。

我愿意修复这个问题。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions