Repository navigation
perf(imessage): skip unused inline-code projection - #139912
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 4:03 AM ET / 08:03 UTC. ClawSweeper reviewWhat this changesThe iMessage formatter skips inline-code rendering and offset reconstruction when no code markers need restoration, preserving outgoing text and native styles. Merge readiness✅ Ready for maintainer review This remains a useful, bounded optimization absent from the inspected main and latest release. No introduced correctness defect was found; the maintainer-authored PR should proceed through normal review. Priority: P3 Review scores
Verification
How this fits togetherThe iMessage plugin converts Markdown replies into text and native formatting ranges before sending them through imsg. Its outbound sanitizer also invokes this formatter while inspecting rendered text. flowchart LR
A[Markdown reply] --> B[Parse text and styles]
B --> C[Render native formatting]
B --> D{Inline code present?}
D -->|Yes| E[Restore code markers]
D -->|No| F[Keep text and ranges]
C --> E
C --> F
E --> G[Outbound sanitizer]
F --> G
G --> H[iMessage transport]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +3. Total +3 across 1 file. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the local fast paths while preserving separate native-style and code-style rendering and the existing sanitizer checks. Do we have a high-confidence way to reproduce the issue? Not applicable as a behavioral bug: source confirms the redundant work, while the supplied benchmarks quantify its cost; no runtime execution was performed in this review. Is this the best way to solve the issue? Yes. The guards follow the existing projection invariant and avoid unnecessary work without combining renderers, changing public APIs, or weakening sanitization. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against bc7c52983c80. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
What Problem This Solves
iMessage formatting performs a second attributed-text render to recover inline-code markers even when a reply contains no inline code. It then rebuilds text and native-style offsets despite having no marker edits. The final outbound sanitizer also pays this cost when inspecting rendered projections.
Why This Change Was Made
Skip the code-only render when the parsed representation has no inline-code spans, and return the current text and freshly prepared native ranges when there are no code-marker edits. Construct fallbacks can shift or remove inline-code spans but do not create them. The native-style and code-style renders remain separate to preserve range compaction order. The change adds three production lines and leaves sanitizer policy, verification stages, and limits untouched.
User Impact
Replies without inline code avoid unnecessary formatting work while retaining identical visible text and native styles. Inline-code messages keep the existing marker restoration path. No appearance or transport-contract change is intended.
Evidence
At base
2239858f4dfd0de769e9d80b2f0b3f5452be2b05, fixed baseline/candidate verification followed by B0/C0/C1/B1 measured 42 formatter and full-sanitizer cases. All 44,604 outcomes were saved before assertions and matched complete baseline text/ranges, with independent UTF-16 boundary checks. Plain text, Unicode, native styles, links, lists, headings, fences, dense inline code and raw-sanitizer routes were retained.Results are not uniformly faster: 35/84 median comparisons were slower. The largest absolute median increase was full-sanitizer dense inline code, +30.544 µs (+1.50%) in reverse order; the largest relative increase was fenced-only extraction, +1.073 µs (+26.82%) in reverse order. Raw-sanitizer rows remain route controls because their security projection also invokes the formatter. All adverse samples and process resources were retained; no universal speedup or Gateway/delivery-latency claim is made.
Normal focused tests passed 386/386: formatter 23, send 90, monitor behavior 273, including the existing sanitizer cases. Managed P2 review was scoped-clean, exit 0. No new test-only seam or redundant call-count test was added. All 24 normal changed checks passed, including five doctor-contract tests, plugin and plugin-test typechecks, lint and boundary guards. The native owner confirmed closure with no problems in 205.62 seconds under the predeclared resource bounds. No build or live iMessage send is claimed.
Before publication, the unchanged formatter patch was merged with current main, including upstream #139894's unrelated browser-fixture isolation repair. Formatter SHA remains
6d51d9f614874d4bc9b10675d0705355146c548304bb811e94887048cede1848; all previous measurements and tests retain their original base attribution. Fresh hosted CI is required for the composed head.The first CI run reached a Knip provisioning failure: pnpm dlx could not import its native parser binary from the CI store (ENOENT). This was not an iMessage assertion or lockfile finding. One retry of failed jobs on the unchanged head completed successfully; required CI is green. The original failed log remains retained. No source changes or numerical reruns were used for that retry.