Skip to content

fix: harden macimed socket server reliability - #6

Open
tlhc wants to merge 1 commit into
riodelphino:4.xfrom
tlhc:4.x
Open

fix: harden macimed socket server reliability#6
tlhc wants to merge 1 commit into
riodelphino:4.xfrom
tlhc:4.x

Conversation

@tlhc

@tlhc tlhc commented Jul 22, 2026

Copy link
Copy Markdown
  • 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

Copilot AI review requested due to automatic review settings July 22, 2026 13:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 InputSourceCache to cache TISInputSource snapshots 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 test in 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.

Comment thread Sources/MacIMEKit/IME.swift
Comment thread Sources/MacIMEKit/IMED.swift
 - 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
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.

2 participants