Skip to content

feat: preliminary implementation for daemon + CLI#67

Merged
georgeh0 merged 6 commits intomainfrom
g/daemon-cli
Mar 14, 2026
Merged

feat: preliminary implementation for daemon + CLI#67
georgeh0 merged 6 commits intomainfrom
g/daemon-cli

Conversation

@georgeh0
Copy link
Member

#52

georgeh0 and others added 6 commits March 13, 2026 13:05
- Use AF_PIPE (named pipes) on Windows instead of AF_UNIX sockets, since
  AF_UNIX is not reliably supported on Windows Python 3.11
- Add _connection_family() helper in daemon.py, used by both daemon and client
- Make daemon_socket_path() return \\.\pipe\cocoindex_code_<user> on Windows
- Use os.path.exists() instead of Path.exists() for socket/pipe path checks
  (more reliable for Windows named pipe paths)
- Skip socket file unlink on Windows (named pipes auto-clean on close)
- Catch NotImplementedError in add_signal_handler (Windows asyncio limitation)
- Catch AttributeError in accept loop settimeout (AF_PIPE has no ._socket)
- Fix _find_ccc_executable() to check for ccc.exe on Windows
- Stop find_parent_with_marker() traversal at home directory to avoid
  false positives on CI runners where ~/.git exists
- Update tests to use platform-appropriate connection family and socket paths

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The root cause: test_daemon.py's session fixture patched dm.user_settings_dir
at the module level, causing this patch to leak across all subsequent test
modules. When test_e2e.py teardown called stop_daemon(), it was connecting
to the wrong daemon socket and reading a PID file that contained pytest's
own PID (written by the thread-based daemon via os.getpid()), then sending
SIGTERM to pytest itself.

Fixes:
- client.py stop_daemon(): add `pid != os.getpid()` guard to never SIGTERM
  the current process (safety net for thread-based daemons in tests)
- test_daemon.py: use COCOINDEX_CODE_DIR env var for isolation instead of
  directly patching dm.user_settings_dir (which leaked across modules);
  use yield fixture to restore env var and create_embedder patch at session end

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@georgeh0 georgeh0 merged commit 9000f1d into main Mar 14, 2026
5 checks passed
@georgeh0 georgeh0 deleted the g/daemon-cli branch March 14, 2026 22:57
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