Live folder watching for the file picker (v0.1.6) - #8
Merged
Conversation
termdown only scanned its target directory once at startup, so the file picker, "New tab" picker, and project search all went stale until the app was restarted. Add a macOS FSEvents watcher (FolderWatcher) that flags a change the same way SIGWINCH already flags a resize (Terminal.folderChanged), and have the picker re-scan and refresh entries/details/LiveGrep's cache live while it's open. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…down Code review of the previous commit caught two real bugs: - TerminalMenu.run() was non-mutating, so a folder-change refresh only updated a local shadow of items/details that was discarded when run() returned. Since main.swift reuses the same `menu` value for the whole session, any live refresh was silently reverted the next time the picker opened (e.g. after viewing a file and returning to it). Making run() mutating lets it write back to self directly, so the caller's `menu` keeps the refreshed list across calls. - FolderWatcher.stop() (FSEventStreamStop/Invalidate) was called from the SIGINT/SIGTERM handler, which isn't async-signal-safe and risked a deadlock on Ctrl-C if a CF/dispatch lock was held at signal time. It's also unnecessary there: that path calls _exit(0) immediately, so the whole process (and its FSEvents queue/fd) is torn down by the OS regardless. Only the atexit path (graceful quit) still calls it, since that's the one with cleanup that has an effect outliving the process (restoring the terminal). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 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
FolderWatcher(macOS FSEvents) flags changes the same wayTerminal.didResizealready flags a resize, and the picker re-scans and refreshes live while open.TerminalMenu.run()is nowmutatingso a live refresh persists across picker re-entries (it previously reverted the momentrun()returned), and FSEvents teardown was moved out of the SIGINT/SIGTERM handler (not async-signal-safe, and unnecessary since_exitalready tears the process down).appVersionto 0.1.6 and adds a CHANGELOG entry.Test plan
swift build— macOSswift test— 259/259 passingswiftformat --lint/swiftlint lint --strictclean on changed files🤖 Generated with Claude Code