Repository navigation
moped CLI: open new files, and fix --wait on current macOS - #104
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Save As handling and shared wait attributes can leave callers hanging or release independent sessions prematurely.
Review effort: Balanced
Findings: 1
Open (4)
What changed in this PR
Updates the moped CLI to create new files and replace sandbox-dependent wait sessions with extended-attribute coordination.
Changes:
- Creates and conditionally removes placeholder files.
- Tracks
--waitstate through file attributes. - Updates documentation and manual verification steps.
| File | Description |
|---|---|
Moped/WaitManager.swift |
Removes the previous session manager. |
Moped/Resources/moped |
Implements placeholder creation and attribute-based waiting. |
Moped/MopedApp.swift |
Marks displayed CLI documents as open. |
Moped/CLIFileTags.swift |
Manages wait and placeholder attributes. |
Moped/AppDelegate.swift |
Starts the new attribute manager. |
Moped.xcodeproj/project.pbxproj |
Replaces the source file in the target. |
manual-checklist.md |
Adds CLI verification scenarios. |
DOCUMENTATION.md |
Documents new-file and wait behavior. |
CHANGELOG.md |
Records both user-facing changes. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Create placeholder files with noclobber, so a file appearing between the existence check and creation is never tagged and later deleted. - Detect `moped --wait` on an already-open file through the document's file watcher (now also listening for .attrib), instead of relying on a key-window change that never comes when the window is already key. - Release wait and placeholder tags on the URL a document leaves on Save As. - Give each `moped --wait` its own tag (wait.<uuid>), so concurrent waits on one file no longer release each other. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Two
mopedCLI changes. Both rely on extended attributes on the opened files, the only channel the script and the sandboxed app both have.moped <file>on a file that doesn't exist yetPreviously this stopped with "The file … does not exist." Now the script creates the file empty, exclusively (noclobber, so an existing file is never claimed), and opens it, and ⌘S saves straight to it. The sandboxed app can't create the file itself, because it may only write where it was handed a file. The script tags the new file with
net.machorro.roberto.Moped.placeholder. If that file is still empty when its window closes, or when Moped quits, Moped deletes it, so changing your mind leaves nothing behind. Files that already existed are never deleted.moped --waitfailing with "Operation not permitted"--waitkept its session file in Moped's sandbox container. Current macOS no longer lets other apps create files there, sotouchfailed underset -eandgit commitaborted with "there was a problem with the editor".--waitnow tags each file with its ownnet.machorro.roberto.Moped.wait.<uuid>, so concurrent waits on one file stay independent:pendingbefore callingopen.openwhen the window shows the file. For a file that's already open, the document's file watcher (now also listening for.attrib) sees the new tag. Moped removes the tag when the window closes, Moped quits, or the document moves away on Save As.pendingafter about 10 s means Moped refused the file (binary, too large), so the script stops waiting for it.This removes the container session file, the osascript distributed notification, the 1 s startup sleep and the repost. Because the tag is in place before Moped launches, the cold-launch race is gone.
WaitManager.swiftand the interimPlaceholderFiles.swiftare replaced byCLIFileTags.swift.FileWatcherdoesn't watch.attrib, so tag changes don't trigger the "changed on disk" prompt.Behavior changes:
--waitcan't wait for a file you can't write to. It printsmoped: cannot wait for …and skips that file.--waiton a path whose folder doesn't exist now returns at once withopen's error, instead of after about 10 s.Test plan
swiftlint --strict,swift test --package-path MopedEditor(229 tests),./scripts/check_localized_strings.shopen -ato target that build:--wait, cold launch: tag wentpendingthenopen, returned on close.--waiton an already-open file plus a new file: waits for both.--waiton an already-open file while Moped is frontmost and the window is already key: still waits.--waiton one file: terminating one leaves the other waiting.--wait new.txt, then Save As: returns, and the emptynew.txtis removed.--waiton a binary file: released after about 12 s with no tag left.--waitand quitting Moped: returned.git commitwithGIT_EDITOR='moped --wait': commit created with the typed message./usr/local/bin/mopedresolving viaopen -b. The new cases are inmanual-checklist.md.🤖 Generated with Claude Code