Files
goose/CHAT_INTEGRATION_EXAMPLE.md
spencrmartin 0223f4cd61 fix(lint): remove unused variables and imports
- Remove unused setIsGoosehintsModalOpen parameter in AppLayout
- Add eslint-disable comments for insights and error in SessionsInsights
- Remove unused TabsList and TabsTrigger imports in SettingsView
2025-11-06 12:59:50 -05:00

24 KiB

Chat + Document Integration - Visual Example

🎬 Complete User Flow

Step 1: User Opens Document

┌─────────────────────────────────────────────────────────────────────┐
│                         Goose Desktop                                │
├────────────────────────┬────────────────────────────────────────────┤
│                        │                                             │
│   Chat Panel           │   Document Editor                           │
│   ─────────           │   ───────────────                          │
│                        │                                             │
│   [Empty]              │   Collaborative Document                    │
│                        │   ID: doc-1730818800000                     │
│                        │   🤖 Goose enabled                          │
│                        │                                             │
│                        │   ┌─────────────────────────────────────┐  │
│                        │   │ The quick brown fox jumps over the  │  │
│                        │   │ lazy dog. This is a test document.  │  │
│                        │   │                                     │  │
│                        │   │ The fox is very fast.               │  │
│                        │   └─────────────────────────────────────┘  │
│                        │                                             │
└────────────────────────┴────────────────────────────────────────────┘

Step 2: User Selects Text

┌─────────────────────────────────────────────────────────────────────┐
│                         Goose Desktop                                │
├────────────────────────┬────────────────────────────────────────────┤
│                        │                                             │
│   Chat Panel           │   Document Editor                           │
│   ─────────           │   ───────────────                          │
│                        │                                             │
│   [Empty]              │   Collaborative Document                    │
│                        │   ID: doc-1730818800000                     │
│                        │   🤖 Goose enabled                          │
│                        │                                             │
│                        │   ┌─────────────────────────────────────┐  │
│                        │   │ The quick brown fox jumps over the  │  │
│                        │   │ lazy dog. This is a test document.  │  │
│                        │   │                                     │  │
│                        │   │ The fox is ⎡very fast⎤.            │  │
│                        │   │             └────────┘              │  │
│                        │   │             ↑ SELECTED              │  │
│                        │   └─────────────────────────────────────┘  │
│                        │                                             │
│                        │   [Ask Goose] ← User clicks                │
│                        │                                             │
└────────────────────────┴────────────────────────────────────────────┘

Step 3: Chat Input Gets Populated

┌─────────────────────────────────────────────────────────────────────┐
│                         Goose Desktop                                │
├────────────────────────┬────────────────────────────────────────────┤
│                        │                                             │
│   Chat Panel           │   Document Editor                           │
│   ─────────           │   ───────────────                          │
│                        │                                             │
│   ┌──────────────────┐│   Collaborative Document                    │
│   │ I'm working on a ││   ID: doc-1730818800000                     │
│   │ document and need││   🤖 Goose enabled                          │
│   │ help with this   ││                                             │
│   │ section:         ││   ┌─────────────────────────────────────┐  │
│   │                  ││   │ The quick brown fox jumps over the  │  │
│   │ "very fast"      ││   │ lazy dog. This is a test document.  │  │
│   │                  ││   │                                     │  │
│   │ Full document    ││   │ The fox is ⎡very fast⎤.            │  │
│   │ context:         ││   │             └────────┘              │  │
│   │ The quick brown  ││   │             ↑ SELECTED              │  │
│   │ fox jumps...     ││   └─────────────────────────────────────┘  │
│   │                  ││                                             │
│   │ [Send] 👈 Ready ││                                             │
│   └──────────────────┘│                                             │
│                        │                                             │
└────────────────────────┴────────────────────────────────────────────┘

Step 4: User Edits and Sends

┌─────────────────────────────────────────────────────────────────────┐
│                         Goose Desktop                                │
├────────────────────────┬────────────────────────────────────────────┤
│                        │                                             │
│   Chat Panel           │   Document Editor                           │
│   ─────────           │   ───────────────                          │
│                        │                                             │
│   ┌──────────────────┐│   Collaborative Document                    │
│   │ Make this more   ││   ID: doc-1730818800000                     │
│   │ exciting! 🚀     ││   🤖 Goose enabled                          │
│   │                  ││                                             │
│   │ [Send] 👈 Clicked││   ┌─────────────────────────────────────┐  │
│   └──────────────────┘│   │ The quick brown fox jumps over the  │  │
│                        │   │ lazy dog. This is a test document.  │  │
│   ↓ Sending...         │   │                                     │  │
│                        │   │ The fox is very fast.               │  │
│                        │   └─────────────────────────────────────┘  │
│                        │                                             │
└────────────────────────┴────────────────────────────────────────────┘

Step 5: Goose Responds in Chat

┌─────────────────────────────────────────────────────────────────────┐
│                         Goose Desktop                                │
├────────────────────────┬────────────────────────────────────────────┤
│                        │                                             │
│   Chat Panel           │   Document Editor                           │
│   ─────────           │   ───────────────                          │
│                        │                                             │
│   👤 You               │   Collaborative Document                    │
│   Make this more       │   ID: doc-1730818800000                     │
│   exciting! 🚀         │   🤖 Goose enabled                          │
│                        │                                             │
│   🤖 Goose             │   ┌─────────────────────────────────────┐  │
│   I'll make it more    │   │ The quick brown fox jumps over the  │  │
│   dynamic!             │   │ lazy dog. This is a test document.  │  │
│                        │   │                                     │  │
│   ✏️ Editing doc...    │   │ The fox is very fast.               │  │
│                        │   └─────────────────────────────────────┘  │
│                        │                                             │
└────────────────────────┴────────────────────────────────────────────┘

Step 6: Goose Edits Document

┌─────────────────────────────────────────────────────────────────────┐
│                         Goose Desktop                                │
├────────────────────────┬────────────────────────────────────────────┤
│                        │                                             │
│   Chat Panel           │   Document Editor                           │
│   ─────────           │   ───────────────                          │
│                        │                                             │
│   👤 You               │   Collaborative Document                    │
│   Make this more       │   ID: doc-1730818800000                     │
│   exciting! 🚀         │   🤖 Goose is editing... ⚡                │
│                        │                                             │
│   🤖 Goose             │   ┌─────────────────────────────────────┐  │
│   I'll make it more    │   │ The quick brown fox jumps over the  │  │
│   dynamic!             │   │ lazy dog. This is a test document.  │  │
│                        │   │                                     │  │
│   ✏️ Editing doc...    │   │ The fox is ⎡lightning-fast⎤!       │  │
│                        │   │             └──────────────┘        │  │
│                        │   │             ↑ CHANGED!              │  │
│                        │   └─────────────────────────────────────┘  │
│                        │                                             │
└────────────────────────┴────────────────────────────────────────────┘

Step 7: Goose Confirms

┌─────────────────────────────────────────────────────────────────────┐
│                         Goose Desktop                                │
├────────────────────────┬────────────────────────────────────────────┤
│                        │                                             │
│   Chat Panel           │   Document Editor                           │
│   ─────────           │   ───────────────                          │
│                        │                                             │
│   👤 You               │   Collaborative Document                    │
│   Make this more       │   ID: doc-1730818800000                     │
│   exciting! 🚀         │   🤖 Goose enabled                          │
│                        │                                             │
│   🤖 Goose             │   ┌─────────────────────────────────────┐  │
│   I'll make it more    │   │ The quick brown fox jumps over the  │  │
│   dynamic!             │   │ lazy dog. This is a test document.  │  │
│                        │   │                                     │  │
│   ✏️ Editing doc...    │   │ The fox is lightning-fast!          │  │
│                        │   │            ✨ NEW ✨                │  │
│   ✅ Done! I changed   │   └─────────────────────────────────────┘  │
│   "very fast" to       │                                             │
│   "lightning-fast" to  │                                             │
│   add more excitement! │                                             │
│                        │                                             │
└────────────────────────┴────────────────────────────────────────────┘

🔄 Multi-Turn Example

Turn 1: Initial Request

Chat:                          Document:
─────                          ─────────
👤 You                         "The fox is very fast."
Make this more exciting!       
                               
🤖 Goose                       "The fox is lightning-fast!"
Done! Changed to               ✨ EDITED ✨
"lightning-fast"               

Turn 2: Follow-up

Chat:                          Document:
─────                          ─────────
👤 You                         "The fox is lightning-fast!"
Actually, make it more         
professional                   
                               
🤖 Goose                       "The fox demonstrates
Okay, making it more           remarkable speed."
professional!                  ✨ EDITED ✨
                               
Done! Changed to               
"demonstrates remarkable       
speed"                         

Turn 3: Refinement

Chat:                          Document:
─────                          ─────────
👤 You                         "The fox demonstrates
Perfect! Now add a             remarkable speed."
description of the dog         
                               
🤖 Goose                       "The fox demonstrates
I'll add that!                 remarkable speed, while
                               the dog rests peacefully
Done! Added description        in the afternoon sun."
of the dog                     ✨ EDITED ✨

🎯 Different Request Types

Type 1: Selection-Based

User selects: "The quick brown fox"
User: "Make this more descriptive"

Goose edits: "The agile, quick brown fox"

Type 2: Whole Document

User: "Add a conclusion to this document"

Goose appends:
"
Conclusion

In summary, the fox's agility and the dog's 
peaceful nature create a perfect balance..."

Type 3: Formatting

User: "Format this as a bulleted list"

Goose converts:
"The fox is fast
The dog is lazy"

To:
• The fox is fast
• The dog is lazy

Type 4: Grammar Fix

User: "Fix the grammar in this paragraph"

Goose fixes:
"The fox are fast" → "The fox is fast"
"The dog sleep" → "The dog sleeps"

💬 Natural Conversation Examples

Example 1: Writing Assistant

👤: I need to write an introduction
🤖: What's the document about?
👤: It's about foxes and dogs
🤖: *writes intro* "This document explores the fascinating 
    relationship between foxes and dogs..."
👤: Great! Now add a section about their differences
🤖: *adds section* "Differences Between Foxes and Dogs..."
👤: Perfect!

Example 2: Iterative Editing

👤: Make this paragraph more concise
🤖: *edits* Done! Reduced from 150 to 80 words.
👤: It's too short now
🤖: *expands* Added more detail. Now 120 words.
👤: That's better, thanks!

Example 3: Style Adjustment

👤: This sounds too casual
🤖: *edits* Made it more formal.
👤: Now it's too stiff
🤖: *edits* Found a middle ground - professional but approachable.
👤: Perfect!

🎨 Visual Indicators

In Chat

User Message with Document Context:

┌────────────────────────────────┐
│ 👤 You                         │
│ Make this more exciting        │
│                                │
│ 📄 Document: doc-123           │
│ 📝 Selected: "very fast"       │
└────────────────────────────────┘

Goose Response with Edit Indicator:

┌────────────────────────────────┐
│ 🤖 Goose                       │
│ I'll make it more dynamic!     │
│                                │
│ ✏️ Editing document...         │
│ ✅ Edit complete!              │
└────────────────────────────────┘

In Document

Before Edit:

┌────────────────────────────────┐
│ 🤖 Goose enabled               │
├────────────────────────────────┤
│ The fox is very fast.          │
└────────────────────────────────┘

During Edit:

┌────────────────────────────────┐
│ 🤖 Goose is editing... ⚡      │
├────────────────────────────────┤
│ The fox is lightning-fast.     │
│            ^^^^^^^^^ typing... │
└────────────────────────────────┘

After Edit:

┌────────────────────────────────┐
│ 🤖 Goose enabled               │
├────────────────────────────────┤
│ The fox is lightning-fast!     │
│            ✨ recently edited  │
└────────────────────────────────┘

🔧 Technical Flow

1. User clicks "Ask Goose"
   ↓
2. Document editor dispatches event:
   window.dispatchEvent('populate-chat-input', {
     message: "I'm working on a document...",
     docId: "doc-123",
     metadata: { ... }
   })
   ↓
3. Chat input receives event:
   - Populates input field
   - Stores document context
   - Focuses input
   ↓
4. User edits/sends message
   ↓
5. Message sent to Goose with metadata:
   {
     text: "Make this more exciting",
     documentContext: {
       docId: "doc-123",
       content: "...",
       selectedText: "very fast",
       selection: { from: 45, to: 54 }
     }
   }
   ↓
6. Goose processes request:
   - Analyzes document
   - Generates improvement
   - Calls edit API
   ↓
7. Goose edits document:
   window.gooseEditors['doc-123'].replaceText(45, 54, "lightning-fast")
   ↓
8. Document updates:
   - Shows "Goose is editing..." indicator
   - Text changes in real-time
   - Indicator fades after 1 second
   ↓
9. Goose responds in chat:
   "Done! I changed 'very fast' to 'lightning-fast'"
   ↓
10. User sees:
    - Updated document
    - Goose's explanation in chat
    - Can undo with Cmd+Z if needed

Benefits

  1. Seamless Integration: Chat and document work together
  2. Context Awareness: Goose knows what you're working on
  3. Real-Time Feedback: See changes as they happen
  4. Natural Conversation: Talk to Goose like a collaborator
  5. Full Control: Can undo, disable, or modify anytime
  6. Visual Clarity: Always know what's happening

🚀 This Is The Magic!

The combination of:

  • Rich text editor
  • Real-time collaboration
  • Chat integration
  • Visual feedback

Creates a truly collaborative AI workspace where Goose feels like a real team member editing alongside you!


Status: Ready for implementation
Branch: spence/doceditor
Created: November 5, 2025