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

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 2 месяцев назад
Родитель
С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 {
         let nameLabel = NSTextField(labelWithString: "AI Job Finder")
         let nameLabel = NSTextField(labelWithString: "AI Job Finder")
         nameLabel.font = .systemFont(ofSize: 11, weight: .semibold)
         nameLabel.font = .systemFont(ofSize: 11, weight: .semibold)
         nameLabel.textColor = Theme.secondaryText
         nameLabel.textColor = Theme.secondaryText
+        nameLabel.alignment = .left
         nameLabel.translatesAutoresizingMaskIntoConstraints = false
         nameLabel.translatesAutoresizingMaskIntoConstraints = false
 
 
         let bubble = makeChatBubbleContainer(text: text, isUser: false)
         let bubble = makeChatBubbleContainer(text: text, isUser: false)
@@ -1604,7 +1605,8 @@ final class DashboardView: NSView, NSTextFieldDelegate {
         let column = NSStackView(views: [nameLabel, bubble])
         let column = NSStackView(views: [nameLabel, bubble])
         column.orientation = .vertical
         column.orientation = .vertical
         column.spacing = 6
         column.spacing = 6
-        column.alignment = .width
+        // 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.
+        column.alignment = .leading
         column.translatesAutoresizingMaskIntoConstraints = false
         column.translatesAutoresizingMaskIntoConstraints = false
 
 
         if let jobs, !jobs.isEmpty {
         if let jobs, !jobs.isEmpty {
@@ -1622,6 +1624,7 @@ final class DashboardView: NSView, NSTextFieldDelegate {
 
 
         host.addSubview(avatar)
         host.addSubview(avatar)
         host.addSubview(column)
         host.addSubview(column)
+        host.userInterfaceLayoutDirection = .leftToRight
         NSLayoutConstraint.activate([
         NSLayoutConstraint.activate([
             avatar.leadingAnchor.constraint(equalTo: host.leadingAnchor),
             avatar.leadingAnchor.constraint(equalTo: host.leadingAnchor),
             avatar.topAnchor.constraint(equalTo: host.topAnchor),
             avatar.topAnchor.constraint(equalTo: host.topAnchor),
@@ -1631,7 +1634,8 @@ final class DashboardView: NSView, NSTextFieldDelegate {
             column.leadingAnchor.constraint(equalTo: avatar.trailingAnchor, constant: 12),
             column.leadingAnchor.constraint(equalTo: avatar.trailingAnchor, constant: 12),
             column.trailingAnchor.constraint(equalTo: host.trailingAnchor),
             column.trailingAnchor.constraint(equalTo: host.trailingAnchor),
             column.topAnchor.constraint(equalTo: host.topAnchor),
             column.topAnchor.constraint(equalTo: host.topAnchor),
-            column.bottomAnchor.constraint(equalTo: host.bottomAnchor)
+            column.bottomAnchor.constraint(equalTo: host.bottomAnchor),
+            bubble.widthAnchor.constraint(lessThanOrEqualTo: host.widthAnchor, multiplier: 0.78)
         ])
         ])
     }
     }