Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

When editing a file through a symlink, both LocalRuntime and SSHRuntime were replacing the symlink with a regular file instead of writing through it.

Changes

SSHRuntime: Changed from mv temp target to cat temp > target && rm temp which writes through symlinks naturally.

LocalRuntime: Added fs.realpath() resolution to write to the actual target file instead of replacing the symlink.

Testing

Added integration test verifying symlinks are preserved when editing files through them. All 90 runtime integration tests pass.

Generated with cmux

When editing a file through a symlink, both LocalRuntime and SSHRuntime
were replacing the symlink with a regular file instead of writing through
it to preserve the link.

SSHRuntime now uses 'cat temp > target' instead of 'mv temp target' to
write through symlinks. LocalRuntime resolves symlinks with fs.realpath()
before writing to the actual target.

Added integration test that verifies symlinks are preserved when editing
files through them in both local and SSH runtimes.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Use readlink -f to resolve symlinks first, then mv the temp file to the
resolved path. This maintains atomicity (readers see old or new file,
never partial) while preserving symlinks.

Addresses Codex review feedback.
Both LocalRuntime and SSHRuntime now preserve the original file
permissions when editing through symlinks. If the target file exists,
its permissions are read before writing and restored after. For new
files, default permissions apply (600 for SSH, system defaults for local).

Added integration test verifying permissions are preserved across edits.
@ammario ammario merged commit 6eebd73 into main Oct 28, 2025
13 checks passed
@ammario ammario deleted the ssh-symlinks branch October 28, 2025 17:28
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.

2 participants