Просмотр исходного кода

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
Родитель
Сommit
3a2498b179
1 измененных файлов с 6 добавлено и 2 удалено
  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 1597
         let nameLabel = NSTextField(labelWithString: "AI Job Finder")
1598 1598
         nameLabel.font = .systemFont(ofSize: 11, weight: .semibold)
1599 1599
         nameLabel.textColor = Theme.secondaryText
1600
+        nameLabel.alignment = .left
1600 1601
         nameLabel.translatesAutoresizingMaskIntoConstraints = false
1601 1602
 
1602 1603
         let bubble = makeChatBubbleContainer(text: text, isUser: false)
@@ -1604,7 +1605,8 @@ final class DashboardView: NSView, NSTextFieldDelegate {
1604 1605
         let column = NSStackView(views: [nameLabel, bubble])
1605 1606
         column.orientation = .vertical
1606 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 1610
         column.translatesAutoresizingMaskIntoConstraints = false
1609 1611
 
1610 1612
         if let jobs, !jobs.isEmpty {
@@ -1622,6 +1624,7 @@ final class DashboardView: NSView, NSTextFieldDelegate {
1622 1624
 
1623 1625
         host.addSubview(avatar)
1624 1626
         host.addSubview(column)
1627
+        host.userInterfaceLayoutDirection = .leftToRight
1625 1628
         NSLayoutConstraint.activate([
1626 1629
             avatar.leadingAnchor.constraint(equalTo: host.leadingAnchor),
1627 1630
             avatar.topAnchor.constraint(equalTo: host.topAnchor),
@@ -1631,7 +1634,8 @@ final class DashboardView: NSView, NSTextFieldDelegate {
1631 1634
             column.leadingAnchor.constraint(equalTo: avatar.trailingAnchor, constant: 12),
1632 1635
             column.trailingAnchor.constraint(equalTo: host.trailingAnchor),
1633 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