Skip to content

feat: add opt-in default messaging timeout for new elements - #1

Merged
diazdesandi merged 1 commit into
mainfrom
feat/default-messaging-timeout
Jul 25, 2026
Merged

feat: add opt-in default messaging timeout for new elements#1
diazdesandi merged 1 commit into
mainfrom
feat/default-messaging-timeout

Conversation

@diazdesandi

@diazdesandi diazdesandi commented Jul 25, 2026

Copy link
Copy Markdown
Member

Summary

  • Add UIElement.defaultMessagingTimeout so callers can opt in to a session-wide messaging timeout applied at element construction
  • Seed only freshly created storage; reused native references keep their existing timeout
  • Default remains 0 (system default), so behavior is unchanged unless opted in

Test plan

  • Unit tests cover default timeout seeding for new elements
  • CI swift test passes on the PR
  • After merge, tag 0.5.0 and confirm the Release workflow publishes notes

Summary by CodeRabbit

  • New Features

    • Added a configurable default messaging timeout for newly created UI elements.
    • Negative timeout values are automatically treated as zero.
    • Timeout settings apply when elements are created and do not change existing elements.
  • Bug Fixes

    • Improved timeout initialization reliability and handling for invalid or unavailable UI elements.

Every accessibility operation is synchronous IPC tied to the target process's event loop, so a wedged target blocks the caller until the
message times out. The system default is 6 seconds, far longer than a user-facing operation can afford.

setMessagingTimeout(_:) only binds a single native handle, so it does not propagate to elements obtained later from that one -- each attribute lookup returns a distinct native reference. Bounding a whole session therefore meant calling it at every construction site, including sites inside this library that callers cannot reach.

Apply the timeout in init(_:) instead, the single chokepoint every element funnels through. Defaults to 0 (system default), so behavior is
unchanged unless a caller opts in. Only fresh storage is seeded; elements reusing a known native reference keep the timeout they already have.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@diazdesandi
diazdesandi merged commit 2fd7eca into main Jul 25, 2026
1 of 2 checks passed
@diazdesandi
diazdesandi deleted the feat/default-messaging-timeout branch July 25, 2026 11:34
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f59a69a3-ef76-4fbc-b734-66d6d7993174

📥 Commits

Reviewing files that changed from the base of the PR and between 7c3c611 and 3db3346.

📒 Files selected for processing (2)
  • Sources/AXSwift6/UIElement.swift
  • Tests/AXSwift6Tests/DefaultMessagingTimeoutTests.swift

📝 Walkthrough

Walkthrough

UIElement.defaultMessagingTimeout now uses locked, non-negative storage and applies its value only when element storage is first created. Initialization avoids nested locks and handles timeout-seeding errors. New serialized tests cover defaults, clamping, opt-in initialization, and existing-element behavior.

Changes

Default messaging timeout

Layer / File(s) Summary
Timeout storage and element initialization
Sources/AXSwift6/UIElement.swift
The default timeout is synchronized and clamped to zero, documented as creation-time behavior, and applied only to newly created element storage with defined error handling.
Default timeout behavior tests
Tests/AXSwift6Tests/DefaultMessagingTimeoutTests.swift
Serialized tests verify the unset default, negative-value clamping, initialization of new elements, and unchanged timeouts for existing elements.

Estimated code review effort: 2 (Simple) | ~10 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/default-messaging-timeout

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

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