Przeglądaj źródła

Fix chat layout: left-align assistant messages

Use leading stack alignment and explicit LTR on assistant rows so AI
bubbles, labels, and job cards read from the left after the avatar.
Cap assistant bubble width to mirror the user message max width.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 3 tygodni temu
rodzic
commit
3a2498b179
1 zmienionych plików z 6 dodań i 2 usunięć
  1. 6 2
      App for Indeed/Views/DashboardView.swift

+ 6 - 2
App for Indeed/Views/DashboardView.swift

@@ -1597,6 +1597,7 @@ final class DashboardView: NSView, NSTextFieldDelegate {
1597
         let nameLabel = NSTextField(labelWithString: "AI Job Finder")
1597
         let nameLabel = NSTextField(labelWithString: "AI Job Finder")
1598
         nameLabel.font = .systemFont(ofSize: 11, weight: .semibold)
1598
         nameLabel.font = .systemFont(ofSize: 11, weight: .semibold)
1599
         nameLabel.textColor = Theme.secondaryText
1599
         nameLabel.textColor = Theme.secondaryText
1600
+        nameLabel.alignment = .left
1600
         nameLabel.translatesAutoresizingMaskIntoConstraints = false
1601
         nameLabel.translatesAutoresizingMaskIntoConstraints = false
1601
 
1602
 
1602
         let bubble = makeChatBubbleContainer(text: text, isUser: false)
1603
         let bubble = makeChatBubbleContainer(text: text, isUser: false)
@@ -1604,7 +1605,8 @@ final class DashboardView: NSView, NSTextFieldDelegate {
1604
         let column = NSStackView(views: [nameLabel, bubble])
1605
         let column = NSStackView(views: [nameLabel, bubble])
1605
         column.orientation = .vertical
1606
         column.orientation = .vertical
1606
         column.spacing = 6
1607
         column.spacing = 6
1607
-        column.alignment = .width
1608
+        // Leading keeps the assistant label, text bubble, and job cards hugging the left (after the avatar); `.width` was letting narrow intrinsic widths sit on the trailing side so AI read like a second “user” column.
1609
+        column.alignment = .leading
1608
         column.translatesAutoresizingMaskIntoConstraints = false
1610
         column.translatesAutoresizingMaskIntoConstraints = false
1609
 
1611
 
1610
         if let jobs, !jobs.isEmpty {
1612
         if let jobs, !jobs.isEmpty {
@@ -1622,6 +1624,7 @@ final class DashboardView: NSView, NSTextFieldDelegate {
1622
 
1624
 
1623
         host.addSubview(avatar)
1625
         host.addSubview(avatar)
1624
         host.addSubview(column)
1626
         host.addSubview(column)
1627
+        host.userInterfaceLayoutDirection = .leftToRight
1625
         NSLayoutConstraint.activate([
1628
         NSLayoutConstraint.activate([
1626
             avatar.leadingAnchor.constraint(equalTo: host.leadingAnchor),
1629
             avatar.leadingAnchor.constraint(equalTo: host.leadingAnchor),
1627
             avatar.topAnchor.constraint(equalTo: host.topAnchor),
1630
             avatar.topAnchor.constraint(equalTo: host.topAnchor),
@@ -1631,7 +1634,8 @@ final class DashboardView: NSView, NSTextFieldDelegate {
1631
             column.leadingAnchor.constraint(equalTo: avatar.trailingAnchor, constant: 12),
1634
             column.leadingAnchor.constraint(equalTo: avatar.trailingAnchor, constant: 12),
1632
             column.trailingAnchor.constraint(equalTo: host.trailingAnchor),
1635
             column.trailingAnchor.constraint(equalTo: host.trailingAnchor),
1633
             column.topAnchor.constraint(equalTo: host.topAnchor),
1636
             column.topAnchor.constraint(equalTo: host.topAnchor),
1634
-            column.bottomAnchor.constraint(equalTo: host.bottomAnchor)
1637
+            column.bottomAnchor.constraint(equalTo: host.bottomAnchor),
1638
+            bubble.widthAnchor.constraint(lessThanOrEqualTo: host.widthAnchor, multiplier: 0.78)
1635
         ])
1639
         ])
1636
     }
1640
     }
1637
 
1641