Skip to content

feat(cli): path resume --remote keeps an existing remote session file - #225

Open
ecalifornica wants to merge 1 commit into
ecalifornica/claude-retargetfrom
ecalifornica/resume-remote-ship-keep
Open

feat(cli): path resume --remote keeps an existing remote session file#225
ecalifornica wants to merge 1 commit into
ecalifornica/claude-retargetfrom
ecalifornica/resume-remote-ship-keep

Conversation

@ecalifornica

@ecalifornica ecalifornica commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Progress on the remote survives a re-push: an existing remote session file is kept, not replaced, unless --overwrite.

Demo:

path resume claude-<id> --remote user@host              # first push
ssh user@host tmux kill-session -t path-<short8>        # end the session without deleting the file
path resume claude-<id> --remote user@host              # kept notice; relaunches on the existing file
path resume claude-<id> --remote user@host --overwrite  # replaces the file

What a re-push does:

flowchart TD
    P[preflight] -->|tmux session live| A[attach]
    P -->|no live session| F{remote file}
    F -->|absent| W[write]
    F -->|smaller than local copy| W
    F -->|full size or larger| K[keep]
    F -->|"--overwrite"| W
    W --> L[launch tmux] --> A
    K --> L
Loading

This applies whenever the tmux session is not live at push time: tmux exited or was killed, the host rebooted, or an earlier push was interrupted mid-write.

A smaller file is that last case, a partial write, so it is replaced. A file at full size or larger carries the session, so it is kept with a notice and the launch runs on it.

The keep-or-replace decision runs on the remote in the same exec channel as the write, so there is no check-then-write race and no second round trip. The remote reports one TP_SHIP=shipped or TP_SHIP=kept line, parsed strictly.

Judgement calls:

  • --overwrite rather than repurposing --force: --force already means "re-fetch from Pathbase, overwrite the cache entry", and coupling the two overwrites ties unrelated behaviors to one flag.
  • Size compare rather than hash compare: size distinguishes the cases that occur (partial write, appended progress) with one wc -c.

Stacked on #223.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

The ship step writes only when the target file is absent or smaller
than the local serialization (a partial earlier ship). An existing
file at full size or larger is kept with a notice and the session
launches on it, so remote-side progress survives a re-push.

path-cli (0.18.0):

- ship_command guards the write remotely in the same exec channel as
  the write itself: no second round trip, no check-to-write race.
  Both branches drain stdin and report one TP_SHIP=shipped or
  TP_SHIP=kept line, parsed strictly.
- --overwrite replaces the target unconditionally. It requires
  --remote and is not spelled --force: that flag means "re-fetch from
  Pathbase, overwrite the cache entry".
- Known edge, accepted: a target at exactly the local size with
  different bytes reads as kept; --overwrite is the recovery.
- Unit, real-sh, and integration tests cover shipped, kept, and
  overwrite, including that a kept file keeps its appended entries.
@github-actions

Copy link
Copy Markdown

🔍 Preview deployed: https://4d68e0ac.toolpath.pages.dev

Comment on lines +445 to +448
format!(
"umask 077; if [ ! -e {t} ] || [ $(wc -c < {t}) -lt {local_len} ]; then \
mkdir -p {d} && cat > {t} && printf '{tag}={shipped}\\n'; \
else cat > /dev/null; printf '{tag}={kept}\\n'; fi",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ew

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