Преглед на файлове

Clarify Comment Writer compose flow with empty-until-Generate UX.

Mirror the Post Generator pattern so users don't treat the comment
field as an AI input:

- Add hasGeneratedContent to CommentWriterViewModel. Set on successful
  Generate and History restore; cleared on Reset.
- Rename the right Compose column from "Your Comment" to "Generated
  result" and show an empty-state placeholder until the first generation.
- Hide the comment editor until content is generated, then present it as
  editable AI output with updated copy.
- Keep thread context summary visible after generate so users can still
  review what they commented on.
- Add CommentWriterEmptyResultPlaceholder with green accent styling
  matching the Comment Writer tool.

Co-authored-by: Cursor <cursoragent@cursor.com>
Uzair Tahir преди 1 седмица
родител
ревизия
f7301bd42d

+ 6 - 0
App AI for Reddit/ViewModels/CommentWriterViewModel.swift

@@ -12,6 +12,9 @@ final class CommentWriterViewModel {
     var variants: [CommentVariant] = []
     var selectedVariantID: UUID?
     var showOverwriteConfirmation = false
+    /// True after a successful Generate or History restore. Cleared on Reset.
+    /// Controls whether the comment result field is shown in Compose.
+    private(set) var hasGeneratedContent = false
 
     private var hasPremiumAccess = false
     private var hasEverPurchasedPremium = false
@@ -182,6 +185,7 @@ final class CommentWriterViewModel {
 
     func resetDraft() {
         draft = CommentDraft()
+        hasGeneratedContent = false
         selectedTab = .compose
         variants = []
         selectedVariantID = nil
@@ -195,6 +199,7 @@ final class CommentWriterViewModel {
         draft = storedDraft.commentDraft
         variants = storedVariants.map(\.commentVariant)
         selectedVariantID = selectedID
+        hasGeneratedContent = true
         selectedTab = variants.isEmpty ? .compose : .preview
         clearMessages()
         successMessage = "Restored from history."
@@ -238,6 +243,7 @@ final class CommentWriterViewModel {
                 variants: variants,
                 selectedVariantID: selectedVariantID
             ))
+            hasGeneratedContent = true
             let engine = usedLiveAI ? "AI" : "local AI templates"
             successMessage = "Generated comment with \(result.variants.count) variants using \(engine)."
         } catch {

+ 16 - 6
App AI for Reddit/Views/CommentWriterView.swift

@@ -171,7 +171,7 @@ struct CommentWriterView: View {
                 composeColumn(title: "Configuration", icon: "slider.horizontal.3") {
                     configurationPanel
                 }
-                composeColumn(title: "Your Comment", icon: "bubble.left") {
+                composeColumn(title: "Generated result", icon: "bubble.left.and.bubble.right") {
                     editorPanel
                 }
             }
@@ -190,7 +190,7 @@ struct CommentWriterView: View {
                 .frame(width: 1)
                 .padding(.vertical, 2)
 
-            composeColumn(title: "Your Comment", icon: "bubble.left") {
+            composeColumn(title: "Generated result", icon: "bubble.left.and.bubble.right") {
                 editorPanel
             }
             .frame(maxWidth: .infinity)
@@ -336,16 +336,26 @@ struct CommentWriterView: View {
     }
 
     private var editorPanel: some View {
+        VStack(spacing: Layout.sectionSpacing) {
+            if viewModel.hasGeneratedContent {
+                generatedContentSection
+            } else {
+                CommentWriterEmptyResultPlaceholder()
+            }
+        }
+    }
+
+    private var generatedContentSection: some View {
         VStack(spacing: Layout.sectionSpacing) {
             PostFormCard(
-                title: "Your Comment",
+                title: "Comment",
                 subtitle: viewModel.draft.useMarkdown
-                    ? "Markdown supported — edit after generating"
-                    : "Plain text — edit after generating"
+                    ? "Generated by AI — markdown supported, edit if you like"
+                    : "Generated by AI — plain text, edit if you like"
             ) {
                 PostFormTextEditor(
                     label: "Comment Body",
-                    placeholder: "Generate a comment or write your own…",
+                    placeholder: "Edit the generated comment…",
                     text: $viewModel.draft.body,
                     minHeight: 190
                 )

+ 35 - 0
App AI for Reddit/Views/Components/CommentWriterComponents.swift

@@ -631,6 +631,41 @@ struct CommentWriterEmptyState: View {
     }
 }
 
+struct CommentWriterEmptyResultPlaceholder: View {
+    var body: some View {
+        VStack(spacing: 12) {
+            Image(systemName: "sparkles")
+                .font(.system(size: 28, weight: .medium))
+                .foregroundStyle(AppTheme.accentGreen)
+
+            VStack(spacing: 6) {
+                Text("Fill Configuration, then press Generate")
+                    .font(.system(size: 13, weight: .semibold))
+                    .foregroundStyle(AppTheme.textPrimary)
+                    .multilineTextAlignment(.center)
+
+                Text("AI writes your comment from thread context and settings on the left. You don't need to fill anything here first.")
+                    .font(.system(size: 11))
+                    .foregroundStyle(AppTheme.textSecondary)
+                    .multilineTextAlignment(.center)
+                    .fixedSize(horizontal: false, vertical: true)
+            }
+        }
+        .padding(.horizontal, 24)
+        .padding(.vertical, 36)
+        .frame(maxWidth: .infinity, minHeight: 180)
+        .background(AppTheme.panelBackground)
+        .clipShape(RoundedRectangle(cornerRadius: AppTheme.cornerRadiusSmall))
+        .overlay(
+            RoundedRectangle(cornerRadius: AppTheme.cornerRadiusSmall)
+                .strokeBorder(
+                    AppTheme.accentGreen.opacity(0.3),
+                    style: StrokeStyle(lineWidth: 1, dash: [6, 4])
+                )
+        )
+    }
+}
+
 struct CommentSecondaryButtonStyle: ButtonStyle {
     func makeBody(configuration: Configuration) -> some View {
         AppSecondaryButtonStyle().makeBody(configuration: configuration)