refactor: rebuild chat composer on SwiftUI TextField#1076
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR B of the chat panel redesign tracked in
docs/refactor/ai-chat-redesign.md. Drops the 292-LOCChatComposerTextView(NSViewRepresentablearoundNSTextView+NSScrollView+ manualNSLayoutManagercaret math +NSPopover+NSHostingController) and rebuilds the composer on pure SwiftUI primitives.What changed
ChatComposerView(new, 189 LOC):TextField(text:, axis: .vertical)+.lineLimit(1...5)+.onSubmit+.onKeyPress(.upArrow / .downArrow / .tab / .escape)+ native SwiftUI.popover. Pill-shapedCapsulebackground. Apple Intelligence focus glow on@FocusStatechange.BC82F3purple,F5B9EApink,8D9FFFblue,FF6778red,FFBA71orange,C686FFlavender). RespectsaccessibilityReduceMotion.clock) and new-conversation (square.and.pencil) move from the composer footer to the inspector header bar, trailing theDetails / AI Chatsegmented picker. Composer footer is now a single row of 5 actions:@,/, mode, model, send.EmptyStateView(which wraps macOS 14ContentUnavailableView) for consistency with every other empty state in the app.ChatComposerTextView.swift(292 LOC), theNSTextViewsubclass, theNSScrollViewcontainer, the manualintrinsicContentSizemath, and the deprecated TextKit 1NSLayoutManager.glyphIndexForCharacter/boundingRect(forGlyphRange:)caret math.Mention popover
The old composer anchored the mention popover at the caret using
NSLayoutManagerglyph rects. The new composer anchors it at the bottom of the composer (.popover(attachmentAnchor: .point(.bottom), arrowEdge: .top)). This matches Slack, Discord, Apple Mail address-autofill, and removes the only TextKit 1 dependency.MentionDetector,MentionPopoverState, andMentionSuggestionListVieware unchanged.Net code
ChatComposerTextView.swift)ChatComposerView.swift, including the inline shimmer)NSViewRepresentable, 0 lines of TextKit 1, 0 lines of manual NSPopoverTest plan
Details | AI Chaton the left andclock | square.and.pencilon the right.@. Confirm the mention popover opens anchored to the bottom of the composer.