Skip to content

Comments

Guard macOS restore paths for deleted worktrees#3

Merged
nicosuave merged 17 commits intomainfrom
nicosuave/fix-restore-path
Feb 21, 2026
Merged

Guard macOS restore paths for deleted worktrees#3
nicosuave merged 17 commits intomainfrom
nicosuave/fix-restore-path

Conversation

@nicosuave
Copy link
Member

This change prevents crash-loop restoration when saved terminal/worktree paths no longer exist on disk. It adds a shared RestorablePath helper and sanitizes restored and persisted pwd/worktree paths so only existing directories are used. It also clears invalid representedURL values before encode/load to avoid stale AppKit restoration state. Added RestorablePathTests for existing-directory normalization and rejection of missing/file paths.

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.

Reviewed commit: fab00e9a9f

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 6 to 8
let standardized = URL(fileURLWithPath: path).standardizedFileURL.path
var isDirectory: ObjCBool = false
guard FileManager.default.fileExists(atPath: standardized, isDirectory: &isDirectory),

Choose a reason for hiding this comment

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

P2 Badge Validate raw restore paths before canonicalizing

normalizedExistingDirectoryPath standardizes the input before checking existence, which can turn an invalid path into a valid parent (for example, "/tmp/missing/../" becomes "/tmp" and passes). Because this helper is now used for restoring and persisting pwd/worktree state, malformed or stale paths containing .. can be silently accepted as a different directory instead of being rejected, undermining the deleted-worktree guard.

Useful? React with 👍 / 👎.

@nicosuave nicosuave merged commit 1d16b19 into main Feb 21, 2026
115 of 117 checks passed
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