mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
0223f4cd61
- Remove unused setIsGoosehintsModalOpen parameter in AppLayout - Add eslint-disable comments for insights and error in SessionsInsights - Remove unused TabsList and TabsTrigger imports in SettingsView
4.0 KiB
4.0 KiB
Document Editor Implementation Plan
Current Status
✅ Completed
-
Frontend Components
CollaborativeDocEditor.tsx- Main editor with Tiptapwindow.gooseEditorsAPI exposed for programmatic control- Event-driven communication (
goose-doc-assist,populate-chat-input) - Visual feedback for Goose editing state
-
Chat Integration (Frontend)
ChatInput.tsxenhanced to capture document context- Document metadata passed with messages (docId, content, selection)
-
Backend Integration (Partial)
crates/goose-server/src/routes/reply.rs- Parsesdocument_contextfrom requests- Document context injected as system message for AI
crates/goose/src/agents/document_tools.rs- Tool schema definedcrates/goose/src/agents/agent.rs- Tool registered in agent
-
Electron IPC (Already in place)
ui/desktop/src/main.ts- IPC handlers for document collaborationui/desktop/src/preload.ts- IPC exposed to renderer- Document state management in main process
🚧 In Progress
Implement tool execution in Rust
The edit_document tool is defined and registered, but needs execution logic.
Implementation Approach
Option 1: HTTP-based IPC (Recommended)
Since goose-server already runs an HTTP server that Electron communicates with, we can add a new endpoint for document editing.
Pros:
- Consistent with existing architecture
- No new IPC mechanism needed
- Easy to test and debug
Steps:
- Add new route in
crates/goose-server/src/routes/for document editing - Implement handler that sends IPC message to Electron via existing WebSocket/SSE connection
- Update
dispatch_tool_callinagent.rsto route to this handler
Option 2: Direct WebSocket/SSE
Use the existing notification stream to send document edit commands.
Pros:
- Real-time, bidirectional
- Already set up for notifications
Steps:
- Add document edit notification type
- Frontend listens for these notifications
- Execute
window.gooseEditorsmethods on receipt
Recommended Implementation
Use Option 2 (WebSocket/SSE) because:
- The infrastructure already exists
- Document edits are essentially "notifications" to the frontend
- No new routes needed
- Consistent with how other real-time updates work
Next Steps
-
Add document edit handling in
agent.rselse if tool_call.name == EDIT_DOCUMENT_TOOL_NAME { // Extract parameters // Send notification via existing notification stream // Return success response } -
Update
CollaborativeDocEditor.tsxto listen for notifications- Already has
window.gooseEditorsAPI - Just needs to listen for incoming edit commands
- Already has
-
Test end-to-end flow
- User opens document
- User asks Goose to edit via chat
- AI calls
edit_documenttool - Frontend receives notification and executes edit
- User sees real-time update
Architecture Overview
User Chat Input
↓
ChatInput.tsx (captures document context)
↓
goose-server/routes/reply.rs (receives context)
↓
Agent processes with AI
↓
AI calls edit_document tool
↓
agent.rs dispatches tool call
↓
Sends notification to frontend
↓
CollaborativeDocEditor.tsx receives notification
↓
Executes window.gooseEditors[docId].method()
↓
User sees real-time edit in document
Files to Modify
crates/goose/src/agents/document_tools.rs- Export tool name constantcrates/goose/src/agents/agent.rs- Add tool execution indispatch_tool_callui/desktop/src/components/CollaborativeDocEditor.tsx- Listen for edit notifications- Test the full flow
Testing Checklist
- Open document editor
- Document state tracked in main process
- Chat input captures document context
- Backend receives document context
- AI can call edit_document tool
- Frontend receives edit command
- Document updates in real-time
- Visual feedback shows Goose is editing
- Multiple edit actions work (insert, replace, format, etc.)