Преглед изворни кода

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 месеци
родитељ
комит
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")
         nameLabel.font = .systemFont(ofSize: 11, weight: .semibold)
         nameLabel.textColor = Theme.secondaryText
+        nameLabel.alignment = .left
         nameLabel.translatesAutoresizingMaskIntoConstraints = false
 
         let bubble = makeChatBubbleContainer(text: text, isUser: false)
@@ -1604,7 +1605,8 @@ final class DashboardView: NSView, NSTextFieldDelegate {
         let column = NSStackView(views: [nameLabel, bubble])
         column.orientation = .vertical
         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
 
         if let jobs, !jobs.isEmpty {
@@ -1622,6 +1624,7 @@ final class DashboardView: NSView, NSTextFieldDelegate {
 
         host.addSubview(avatar)
         host.addSubview(column)
+        host.userInterfaceLayoutDirection = .leftToRight
         NSLayoutConstraint.activate([
             avatar.leadingAnchor.constraint(equalTo: host.leadingAnchor),
             avatar.topAnchor.constraint(equalTo: host.topAnchor),
@@ -1631,7 +1634,8 @@ final class DashboardView: NSView, NSTextFieldDelegate {
             column.leadingAnchor.constraint(equalTo: avatar.trailingAnchor, constant: 12),
             column.trailingAnchor.constraint(equalTo: host.trailingAnchor),
             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)
         ])
     }