[PR #905] [MERGED] fix(artifacts): project compiled AppKit actions from the control to its target #2333

Closed
opened 2026-10-16 21:17:25 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/905
Author: @kaoru0822-kitauji
Created: 10/7/2026
Status: ✅ Merged
Merged: 10/7/2026
Merged by: @morluto

Base: main ← Head: fix/nib-control-connector-direction


📝 Commits (4)

  • b08228d fix(artifacts): project compiled AppKit actions from the control to its target
  • c60b737 test(artifacts): report observed action routes when a compiled route is missing
  • d421d3f test(artifacts): report compiled connector records when a storyboard route is missing
  • 53bfa7e test(artifacts): write the storyboard fixture's action in Cocoa syntax

📊 Changes

5 files changed (+193 additions, -104 deletions)

View changed files

📝 src/application/InterfaceBuilderAnalysis.ts (+6 -8)
➕ src/artifacts/NibArchive.fixture.ts (+94 -0)
📝 src/artifacts/NibArchive.test.ts (+1 -94)
📝 tests/boundary/filesystem/interfaceBuilderBundle.test.ts (+91 -1)
📝 tests/fixtures/interface-builder/MacFixture.storyboard (+1 -1)

📄 Description

Summary

In AppKit, NSNibControlConnector archives the sending control as NSSource and the action target as NSDestination. A nil target means the first responder. projectNibArchive swapped the two for control connectors (controlAction ? destination : source), which had two effects for every compiled (NIBArchive) AppKit NIB and storyboard:

  • Actions ran backwards (target → action → control). trace_native_ui_action selects a control and follows control → action, so it could not find these actions. The graph also keys the objc_selector node by the action's destination, which was the control instead of the target class.
  • First-responder actions were dropped. With a nil NSDestination, the swapped source was null and hit continue. That loses most menu-item actions.

The decoder output in real apps confirms the archived roles. For example, KeepingYouAwake's KYADurationSettingsViewController.nib has NSNibControlConnector src=NSButton dst=NSCustomObject label=setDefaultDuration:, and Music's MAPreferences.storyboardc has src=NSButton dst=NSNibExternalObjectPlaceholder label=doOK:. NSNibAuxiliaryActionConnector, which the projection did not swap, already came out control-first.

Action shapes in decode_interface_builder output (from -> action -> target, selector edges omitted):

App main this PR
Music MAPreferences.storyboardc placeholder → action → control: 39 control → action → placeholder: 39
Chess unknown → action → control: 20 control → action → target: 20, control → action → first responder: 29
KeepingYouAwake unknown → action → control: 28 control → action → target: 28, first responder: 7
Transmission 4.1.2 unknown → action → control: 234 control → action → target: 234, first responder: 14

Connectors now keep NSSource → NSDestination for every connector class. A nil destination becomes the graph's existing destination_object_missing_or_external action destination. Outlets were already unswapped and are unchanged.

The NIBArchive test encoder moved from NibArchive.test.ts into src/artifacts/NibArchive.fixture.ts (excluded from the build), so a bundle test can build compiled NIBs.

Why the ibtool test passed with the inversion: the hand-written tests/fixtures/interface-builder/MacFixture.storyboard declared its action with the iOS attribute, <action selector="buildTapped:" destination="vc1">. Cocoa documents name an action's receiver with target=. A diagnostic run on macos-14 dumped the compiled view NIB: NSNibControlConnector {NSSource=NSNibExternalObjectPlaceholder (the view controller), NSDestination=NSButton, NSLabel=buildTapped:}. That is the reverse of every Xcode-authored NIB above, and the old inversion was calibrated to it. This PR rewrites the fixture action as target="vc1", which is what Xcode writes for Cocoa. The test's existing assertion (control → action → placeholder) now matches what real apps archive. When it fails, its message reports the observed routes.

Related: #900 fixes the same mapping for flat keyed-archive NIBs (NSSource/NSDestination keys). #899 makes those flat NIBs decodable at all.

No schema or catalog change.

Verification

  • New tests/boundary/filesystem/interfaceBuilderBundle.test.ts case: a compiled NIB with a button → placeholder doOK: connector and a menu item → nil arrangeInFront: connector yields NSButton → doOK: → placeholder and NSMenuItem → arrangeInFront: → (first responder). Fails on main.
  • Real apps as in the table, comparing main and branch builds.
  • The ibtool-compiled storyboard test runs on the macOS CI job with the corrected fixture.
  • npm run check:changed passes, as do the native investigation and action-trace tests (EnhancedNativeInvestigation, nativeInvestigationGraph, enhancedTools.01). The ibtool-dependent tests fail locally the same way on main (no Xcode); CI's macOS job runs them.

No Hopper/Ghidra/IDA verification is needed.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/905 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/7/2026 **Status:** ✅ Merged **Merged:** 10/7/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/nib-control-connector-direction` --- ### 📝 Commits (4) - [`b08228d`](https://github.com/morluto/rea/commit/b08228d19f8a0f6dbc940e8d322ef2bb42d2ce1a) fix(artifacts): project compiled AppKit actions from the control to its target - [`c60b737`](https://github.com/morluto/rea/commit/c60b737f7db8e2c9a1982cdb4357fcda1f47ff08) test(artifacts): report observed action routes when a compiled route is missing - [`d421d3f`](https://github.com/morluto/rea/commit/d421d3f286ce515b5126859a0f9cac60667a168e) test(artifacts): report compiled connector records when a storyboard route is missing - [`53bfa7e`](https://github.com/morluto/rea/commit/53bfa7e3f792cdb9f2e95fc954f3616426414bcc) test(artifacts): write the storyboard fixture's action in Cocoa syntax ### 📊 Changes **5 files changed** (+193 additions, -104 deletions) <details> <summary>View changed files</summary> 📝 `src/application/InterfaceBuilderAnalysis.ts` (+6 -8) ➕ `src/artifacts/NibArchive.fixture.ts` (+94 -0) 📝 `src/artifacts/NibArchive.test.ts` (+1 -94) 📝 `tests/boundary/filesystem/interfaceBuilderBundle.test.ts` (+91 -1) 📝 `tests/fixtures/interface-builder/MacFixture.storyboard` (+1 -1) </details> ### 📄 Description ## Summary In AppKit, `NSNibControlConnector` archives the sending control as `NSSource` and the action target as `NSDestination`. A nil target means the first responder. `projectNibArchive` swapped the two for control connectors (`controlAction ? destination : source`), which had two effects for every compiled (NIBArchive) AppKit NIB and storyboard: - **Actions ran backwards** (`target → action → control`). `trace_native_ui_action` selects a control and follows `control → action`, so it could not find these actions. The graph also keys the `objc_selector` node by the action's destination, which was the control instead of the target class. - **First-responder actions were dropped.** With a nil `NSDestination`, the swapped source was null and hit `continue`. That loses most menu-item actions. The decoder output in real apps confirms the archived roles. For example, KeepingYouAwake's `KYADurationSettingsViewController.nib` has `NSNibControlConnector src=NSButton dst=NSCustomObject label=setDefaultDuration:`, and Music's `MAPreferences.storyboardc` has `src=NSButton dst=NSNibExternalObjectPlaceholder label=doOK:`. `NSNibAuxiliaryActionConnector`, which the projection did not swap, already came out control-first. Action shapes in `decode_interface_builder` output (`from -> action -> target`, selector edges omitted): | App | `main` | this PR | | --- | --- | --- | | Music `MAPreferences.storyboardc` | placeholder → action → control: 39 | control → action → placeholder: 39 | | Chess | unknown → action → control: 20 | control → action → target: 20, control → action → first responder: **29** | | KeepingYouAwake | unknown → action → control: 28 | control → action → target: 28, first responder: **7** | | Transmission 4.1.2 | unknown → action → control: 234 | control → action → target: 234, first responder: **14** | Connectors now keep `NSSource → NSDestination` for every connector class. A nil destination becomes the graph's existing `destination_object_missing_or_external` action destination. Outlets were already unswapped and are unchanged. The NIBArchive test encoder moved from `NibArchive.test.ts` into `src/artifacts/NibArchive.fixture.ts` (excluded from the build), so a bundle test can build compiled NIBs. **Why the ibtool test passed with the inversion:** the hand-written `tests/fixtures/interface-builder/MacFixture.storyboard` declared its action with the iOS attribute, `<action selector="buildTapped:" destination="vc1">`. Cocoa documents name an action's receiver with `target=`. A diagnostic run on macos-14 dumped the compiled view NIB: `NSNibControlConnector {NSSource=NSNibExternalObjectPlaceholder (the view controller), NSDestination=NSButton, NSLabel=buildTapped:}`. That is the reverse of every Xcode-authored NIB above, and the old inversion was calibrated to it. This PR rewrites the fixture action as `target="vc1"`, which is what Xcode writes for Cocoa. The test's existing assertion (control → action → placeholder) now matches what real apps archive. When it fails, its message reports the observed routes. Related: #900 fixes the same mapping for flat keyed-archive NIBs (`NSSource`/`NSDestination` keys). #899 makes those flat NIBs decodable at all. No schema or catalog change. ## Verification - New `tests/boundary/filesystem/interfaceBuilderBundle.test.ts` case: a compiled NIB with a button → placeholder `doOK:` connector and a menu item → nil `arrangeInFront:` connector yields `NSButton → doOK: → placeholder` and `NSMenuItem → arrangeInFront: → (first responder)`. Fails on `main`. - Real apps as in the table, comparing `main` and branch builds. - The ibtool-compiled storyboard test runs on the macOS CI job with the corrected fixture. - `npm run check:changed` passes, as do the native investigation and action-trace tests (`EnhancedNativeInvestigation`, `nativeInvestigationGraph`, `enhancedTools.01`). The ibtool-dependent tests fail locally the same way on `main` (no Xcode); CI's macOS job runs them. No Hopper/Ghidra/IDA verification is needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-16 21:17:25 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2333
No description provided.