Repository navigation
Fix desktop chat copy output and code blocks - #10421
Conversation
Failure-Class: none
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 20552a37ad
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .compactMap { block -> String? in | ||
| guard case .text(_, let text) = block else { return nil } |
There was a problem hiding this comment.
Include visible structured cards in copied text
When appendDiscoveryCard adds a profile/discovery card to an existing AI message, that row has contentBlocks but no .text block; ChatBubble renders the structured card instead of message.text. By filtering every non-.text block here and then falling back to message.text, the copy controls now copy stale/hidden fallback text instead of the visible discovery card contents for those card-only messages. Include the visible structured-card projection (at least discovery cards) or avoid falling back to hidden message.text when structured content is present.
Useful? React with 👍 / 👎.
Keep unchanged selectable message content behind an Equatable render boundary and localize code-copy feedback to its leaf control. This prevents parent copy feedback from re-entering SelectionOverlay layout while preserving content, sender, and font-scale updates. Failure-Class: new
Match the five-field failed telemetry event shape already introduced on the PR branch so the desktop test target compiles. Failure-Class: none
## Summary - Copy only the visible final assistant text from main and floating chat responses. - Add an accessible one-click copy control to each rendered fenced code block. - Prevent Copy feedback from rebuilding unchanged selectable Markdown and pinning the main thread in SwiftUI `SelectionOverlay`. - Repair stale desktop test expectations on this branch so the Swift test target compiles. ## Product invariants - INV-AGENT-* — agent-card and floating-chat rendering continue to use the shared selectable Markdown surface. - INV-AUTH-1 — no authentication/session behavior changed. - INV-CHAT-1 — preserved the shared canonical transcript and the same final-output copy projection in main and floating chat. - INV-VOICE-1 — no voice-turn behavior changed. - INV-MEM-1 — no memory behavior changed. ## Failure class Failure-Class: new Transient copy confirmation state rebuilt unchanged AppKit-backed selectable chat content. SwiftUI's `SelectionOverlay` then repeatedly called `setFont`, invalidated intrinsic size, and re-entered AttributeGraph layout until the main thread was pinned. `FC-selection-overlay-layout-loop` records the contract and the reusable prevention boundary. ## Verification - `xcrun swift test --package-path Desktop --filter AgentPillLifecycleTests` — 77 tests passed. - `xcrun swift test --package-path Desktop --skip-build --filter ChatQueryTelemetryTests` — 25 tests passed. - `python3 desktop/macos/scripts/check_desktop_test_quality.py` — passed. - `desktop/macos/scripts/swift-format-wrapper.sh format -i ...` and `git diff --check` — passed. - Built and launched `/Applications/omi-pr-10421.app` (`com.omi.omi-pr-10421`) against the dev backend on automation port 47921. Clicked the actual macOS Accessibility `Copy` control in a signed-in main chat; clipboard updated, the bridge remained responsive with a fresh snapshot, and the app settled at 1.8% CPU/sleeping instead of the reproduced ~100% SelectionOverlay loop. - `./scripts/agent-logic-harness.sh --cross-surface-smoke` — passed in the original PR verification. ## Review - Root cause confirmed from a live stable-app sample: the main thread was looping through `SelectionOverlay.updateNSView`, `NSControl.setFont`, intrinsic-size invalidation, and AttributeGraph after Copy toggled parent feedback state. - Prior merged PR BasedHardware#9267 fixed the same layout-loop class on agent-card chrome; this PR adds the reusable Equatable message-render boundary and a behavioral regression test. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/10421?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Summary
SelectionOverlay.Product invariants
Failure class
Failure-Class: new
Transient copy confirmation state rebuilt unchanged AppKit-backed selectable chat content. SwiftUI's
SelectionOverlaythen repeatedly calledsetFont, invalidated intrinsic size, and re-entered AttributeGraph layout until the main thread was pinned.FC-selection-overlay-layout-looprecords the contract and the reusable prevention boundary.Verification
xcrun swift test --package-path Desktop --filter AgentPillLifecycleTests— 77 tests passed.xcrun swift test --package-path Desktop --skip-build --filter ChatQueryTelemetryTests— 25 tests passed.python3 desktop/macos/scripts/check_desktop_test_quality.py— passed.desktop/macos/scripts/swift-format-wrapper.sh format -i ...andgit diff --check— passed./Applications/omi-pr-10421.app(com.omi.omi-pr-10421) against the dev backend on automation port 47921. Clicked the actual macOS AccessibilityCopycontrol in a signed-in main chat; clipboard updated, the bridge remained responsive with a fresh snapshot, and the app settled at 1.8% CPU/sleeping instead of the reproduced ~100% SelectionOverlay loop../scripts/agent-logic-harness.sh --cross-surface-smoke— passed in the original PR verification.Review
SelectionOverlay.updateNSView,NSControl.setFont, intrinsic-size invalidation, and AttributeGraph after Copy toggled parent feedback state.