Conversation
tlhc
commented
Jul 22, 2026
- Cache TextInputSources snapshots and refresh after lookup or selection failures
- Serialize daemon command execution for non-thread-safe TextInputSources APIs
- Configure accepted sockets with SO_NOSIGPIPE, SO_RCVTIMEO, and SO_SNDTIMEO
- Retry socket response writes after short writes and EINTR
- Run blocking client I/O on a concurrent DispatchQueue
- Raise the pending-connection backlog from 5 to 64
- Add CI integration tests for source-cache refresh, idle peers, disconnected clients, concurrent requests, and JSON responses
There was a problem hiding this comment.
Pull request overview
This PR hardens the macimed UNIX-domain socket daemon to be more reliable under concurrency, idle/disconnected clients, and transient socket I/O issues, while also improving input-source handling by caching TIS snapshots with refresh-on-failure behavior and adding CI-covered tests.
Changes:
- Introduce an
InputSourceCacheto cacheTISInputSourcesnapshots and refresh on lookup/selection failures. - Improve socket server robustness (socket options, concurrent connection handling, serialized command execution for non-thread-safe TIS/TSM APIs, backlog increase, retry short writes/EINTR).
- Add new unit/integration test targets and run
swift testin CI.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/MacIMEKitTests/IMECacheTests.swift | Adds unit tests validating cache refresh and selection retry behavior. |
| Tests/MacIMEIntegrationTests/IMEDSocketTests.swift | Adds integration tests for idle/disconnected clients, concurrency, and JSON response validity. |
| Sources/MacIMEKit/IMED.swift | Hardens daemon socket handling (socket options, queues, write-retry, backlog increase). |
| Sources/MacIMEKit/IME.swift | Adds InputSourceCache and selection retry/refresh logic for input sources. |
| Package.swift | Registers new test targets for unit + integration tests. |
| .github/workflows/test.yml | Runs swift test in CI (and keeps release build + direct CLI sanity check). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Cache TextInputSources snapshots and refresh after lookup or selection failures - Serialize daemon command execution for non-thread-safe TextInputSources APIs - Configure accepted sockets with SO_NOSIGPIPE, SO_RCVTIMEO, and SO_SNDTIMEO - Retry socket response writes after short writes and EINTR - Run blocking client I/O on a concurrent DispatchQueue - Raise the pending-connection backlog from 5 to 64 - Add CI integration tests for source-cache refresh, idle peers, disconnected clients, concurrent requests, and JSON responses
|
@tlhc |
|
@tlhc There are quite a lot of changes, and honestly most of them go beyond my current level of Swift understanding — I had to ask an AI to help me understand the purpose behind each change. Given that, I'm a bit hesitant about merging this without fully understanding it myself 😅 One thing I wanted to ask:in d44f8e7 commit, I replaced all This PR reintroduces |
Yes, you are right, Make sure the req is safe to handle |