Conversation
# Conflicts: # macos/Onit/Data/Fetching/Endpoints/ChatStreaming/OpenAIChatStreamingEndpoint.swift # macos/Onit/Data/Tools/CalendarTool.swift # macos/Onit/Data/Tools/DiffTool.swift # macos/Onit/Data/Tools/ToolRouter.swift # macos/Onit/UI/Panels/State/OnitPanelState+Chat.swift
# Conflicts: # macos/Onit/UI/Prompt/Generated/GeneratedContentView.swift
* WIP: UI - Display DiffTool call * WIP: UI - NotepadView looks like design * DiffTool compute a character sequence diff instead of character diff * Store in database the approved/changed diff operation * Pass the content's mimeType to the LLM # Conflicts: # macos/Onit/Data/Tools/DiffTool.swift
* Add replace operation in DiffTool * Re-work the indexes offset * Add support for tables (containing text) * Add support for non-text elements
* Display loader & alert if error occurs on document update * Insert enabled only when some change are approved * Make sure invisible characters are not replaced by LLM.
* Create a valid JSON of toolArguments while streaming * DiffTool: Fix rebase issue + crash when one argument is empty * Display automatically the DiffView after DiffTool succeeded
* UI - Handle streaming correctly * UI - Close the diff view when panel is closed. * API - User message structured * DiffTool - Add app name in arguments (used for text insertion). * Performance - Throttle of 300ms - Don't execute tool if arguments didn't change - Don't re-draw the view during streaming
* Move reused code around DiffSegment in DiffSegmentUtils * Supporting DiffRevision (variant) * UI - Show diff button in GeneratedToolbar * UI - Show revision toggle in diff view * UI - Show generated text in Chat
* UI Improvement - NotepadWindow is now resizable * UI Improvement - NotepadWindow is sticky to onitPanel (listen resize and move) * UI DiffView - Display alerts on insertion errors * UI QuickEdit - Display DiffTool * UI QuickEdit - Display DiffButton in generated toolbar * Clean - Move the diff preview generation in Response's model and reuse it everywhere * Feature Copy & Insert - As Prompt.generation is now returning the response diff preview or text -> The copy and insert feature will works with diff preview. * Feature Tethered - Handle correctly app minimized, app moved
There was a problem hiding this comment.
Greptile Summary
This PR implements a comprehensive diff view feature that allows users to review and selectively apply text changes generated by AI tools. The implementation includes:
Core Architecture:
- New
DiffToolthat generates structured text operations (insert, delete, replace) using an optimized LCS-based diff algorithm DiffViewModelfor managing diff state with SwiftData persistence throughDiffRevisionandDiffChangeStatemodelsDiffViewcomponent providing an interactive interface with approve/reject controls, keyboard shortcuts, and preview functionalityNotepadWindowControlleras a singleton floating panel manager for displaying diff content
Google Docs Integration:
- New service layer with
GoogleDocumentServiceProtocol,GoogleDocumentManager, and specialized services (GoogleDocsService,GoogleSheetsService,GoogleSlidesService) - Complex text reconstruction logic to map between plain text positions and Google Docs API indices
GoogleDocsParserfor converting JSON responses into structured Swift models- Comprehensive data structures mirroring Google API schemas for Docs, Sheets, and Slides operations
UI Integration:
ToolCallHandlerViewrouting system that displaysDiffToolViewfor diff operations- Diff buttons in toolbars (
GeneratedToolbar,QuickEditResponseView) that open the notepad window - Panel state management updates with
isDiffViewActivetracking andpanelFrameDidChangedelegate notifications - New color assets for diff visualization (
diffBgGreen,diffBgRed,AcceptBG, etc.)
Tool Call Enhancements:
- Enhanced tool execution with duplicate prevention using hash-based tracking
- JSON validation and repair in
StreamToolAccumulatorfor handling partial streaming data - Automatic diff window opening when diff tools complete execution
The feature integrates seamlessly with the existing chat interface, accessibility parsing system, and panel management architecture while maintaining separation of concerns through proper MVVM patterns.
Confidence score: 2/5
• This PR introduces significant complexity with several concerning implementation issues that could cause crashes or data corruption in production.
• Critical issues include unsafe string manipulation in DiffSegmentUtils, potential index bounds errors in StreamToolAccumulator, system color usage violations in DiffTextView, and complex offset calculations in GoogleDocsService that may fail.
• Files requiring immediate attention: DiffSegmentUtils.swift, StreamToolAccumulator.swift, DiffTextView.swift, GoogleDocsService.swift, DiffViewModel.swift, and ChatEndpointMessagesBuilder.swift.
Context used:
Rule - Use optional chaining syntax action?() instead of explicit nil checking with if-let statements for optional closures. (link)
58 files reviewed, 44 comments
No description provided.