Commit graph

256 commits

Author SHA1 Message Date
Andrew Beal
ea9cd211fc refactor: extract MIME type mappings and improve attachment handling
- Move MimeTypeToFileTypes and FileTypeToMimeType mappings to dedicated FileTypeMimeTypeMapping enum file
- Add empty content validation for file attachments
- Add PDF support for Gemini
- Display attachment references in user messages with file info
- Fix OpenAI unsupported mime type message formatting
- Improve URI list handling in InputService to include text/plain
- Update chat area padding and styling for better attachment display
- Prevent drag selection on chat padding element
- Update test assertions for new unsupported mime type message format
2025-12-23 12:04:29 +00:00
Andrew Beal
13cdd0a162 feat: add support for file attachments via drag and drop and paste.
refactor: standardize file type and MIME type handling across AI providers

Introduce centralized MimeType enum and bidirectional mappings between file types and MIME types. Update Claude, Gemini, and OpenAI implementations to use consistent MIME type validation. Add file attachment support via drag-and-drop and paste in chat input. Expand supported file type detection to include programming languages, config files, and documentation formats.
2025-12-22 20:02:02 +00:00
Andrew Beal
2420cec7bf feat: add file monitoring guidelines to settings with provider-specific instructions
Add a new "File Monitoring Guidelines" section in plugin settings that displays provider-specific information about uploaded file retention and cleanup. The section includes a help button that opens the Plugin Guide modal and updates dynamically based on the selected AI provider (Claude, Gemini, or OpenAI). Also update help modal content with file monitoring information and fix example template link.
2025-12-20 15:11:40 +00:00
Andrew Beal
4d72bba087 Add page number tracking to search snippets
- Add pageNumber field to ISearchSnippet and IPageText interfaces
- Update extractSnippets to process content as paginated text
- Switch PDF reading to use readPDF helper for page extraction
- Update search results to include page numbers in snippets
- Add page number assertions to VaultService tests
2025-12-20 14:48:42 +00:00
Andrew Beal
051abbe43b Bump plugin version to 1.1.1 2025-12-20 11:38:22 +00:00
Andrew Beal
961904c471 Update project copy and readme. 2025-12-20 11:37:47 +00:00
Andrew Beal
cf952352d0 fix: optimize chat area layout updates and add fade gradients
- Add isObserver parameter to updateChatAreaLayout for instant ResizeObserver updates
- Wrap chat area in container with top and bottom fade gradients
- Improve scroll visual feedback with gradient overlays
- Update dependencies: openai 6.15.0, svelte-check 4.3.5, @testing-library/svelte 5.2.10
2025-12-20 11:20:43 +00:00
Andrew Beal
59db78d610 refactor: extract attachment processing logic to base class
Consolidate duplicate file upload and error handling code from Claude, Gemini, and OpenAI into shared `processAttachments` method in BaseAIClass. Remove unnecessary abort service wrapping from BaseAIFileService retry logic.
2025-12-20 10:39:24 +00:00
Andrew Beal
e24a5a02bf Add light unit testing for BaseAIFileService. Replace custom array methods with standard JavaScript methods 2025-12-20 10:07:07 +00:00
Andrew Beal
2d19eee2b6 Update remaining unit tests. 2025-12-20 09:55:15 +00:00
Andrew Beal
e3e30a2b47 fix: improve chat scroll calculation and conversation deletion handling
- Use getOuterHeight helper for accurate element measurements including margins
- Simplify gap calculation for thought and streaming indicators
- Add top fade gradient to chat area for better visual polish
- Queue AI file deletions to prevent blocking conversation deletion
- Only trigger modal close callback when no conversation is active
2025-12-20 01:34:41 +00:00
Andrew Beal
71d19545dd Update unit tests - WIP. 2025-12-19 22:03:57 +00:00
Andrew Beal
8a16ee125b refactor: migrate file upload from base64 to file ID API for all providers
- Add file ID storage and upload tracking to Attachment class
- Store provider field in BaseAIClass for file service integration
- Update Claude, Gemini, and OpenAI to use file ID references
- Replace fetch with requestUrl for native Obsidian HTTP handling
- Implement graceful upload failure handling with user notifications
- Add retry logic with default values to prevent conversation breaks
- Optimize file cache refresh to run only when attachments present
- Filter empty function responses in conversation content validation
2025-12-19 20:05:46 +00:00
Andrew Beal
e4f56e3877 refactor: improve type safety in file service and error handling
- Change listFiles() to synchronous method returning cached IDs
- Add type predicate to ApiError.isApiError() for better type narrowing
- Remove redundant ApiError union type in retry error handling
2025-12-19 12:36:28 +00:00
Andrew Beal
3e013f6c9f refactor: migrate from flag-based content types to typed properties
Replace boolean flags (isFunctionCall, isFunctionCallResponse,
isProviderSpecificContent) with explicit typed properties (functionCall,
functionResponse, attachments) in ConversationContent. Introduce Attachment
class and BaseAIFileService. Update all AI providers (Claude, Gemini, OpenAI)
to use new attachment-based binary file handling with proper error handling,
retry logic, and AbortService integration.
Implement new Files API service for all providers (not yet integrated).
2025-12-19 12:30:51 +00:00
Andrew Beal
05d6264e60 Add new services for AI file API. 2025-12-17 18:06:16 +00:00
Andrew Beal
87b6f42987 fix: prevent duplicate content in Gemini provider-specific messages
Skip adding text parts for provider-specific content (images/PDFs) to avoid
sending the same data twice and inflating token usage unnecessarily.
2025-12-17 11:43:51 +00:00
Andrew Beal
1af7895b83 Bump dependency versions. 2025-12-17 11:43:32 +00:00
Andrew Beal
385271cb75 Remove Token Services.
The token services weren't providing much value and have become more maintenance than they are worth given the addition of binary conversation data.
2025-12-17 10:54:04 +00:00
Andrew Beal
d96d4b4b29 Correct OpenAI binary image data handling. Update model tests. 2025-12-16 23:14:34 +00:00
Andrew Beal
30badb186a fix: prevent double-stringification of provider-specific content
Excludes image/PDF content blocks from text extraction when
isProviderSpecificContent flag is set, avoiding unnecessary token
usage. Updates ReadVaultFiles documentation to clarify image/PDF
reading capabilities and adds system prompt guidance for handling
binary file references.
2025-12-16 22:14:42 +00:00
Andrew Beal
fe086363a9 Update all test instantiations to include the new isProviderSpecificContent boolean parameter. Fix VaultService test to expect Error object instead of empty string for non-existent files. Update AIFunctionService tests to include type field in read_files response objects. 2025-12-16 21:47:08 +00:00
Andrew Beal
b2856aa294 feat: add image and PDF support to ReadVaultFiles function
Add support for reading images (PNG, JPG, JPEG, WebP) and PDFs in ReadVaultFiles. Implement provider-specific formatting for binary content (Claude, OpenAI, Gemini). Update conversation structure to handle binary files separately from text responses. Add unpdf library for PDF text extraction in search.
2025-12-16 20:50:28 +00:00
Andrew Beal
11e93eacb9 Bump plugin version to 1.1.0 2025-12-13 15:01:46 +00:00
Andrew Beal
1f099ed45c refactor: clean up imports and improve view focus handling
- Remove unused Platform import from ChatWindow
- Add grid column for mobile layout in TopBar
- Add await to tick() promise in UserInstruction
- Enhance refocusMainView with explicit focus setting in DiffView
2025-12-13 14:45:56 +00:00
Andrew Beal
5e7247d082 Bump plugin version to 1.0.9
Bump dependency versions.
2025-12-13 10:48:43 +00:00
Andrew Beal
c59bfeb06c fix: prevent auto-focus on mobile when opening diff viewer
Refactored focusInput to accept onMobile parameter to conditionally focus input based on platform, preventing annoying automatic keyboard popup on mobile devices when diff viewer opens/closes.
2025-12-13 10:40:20 +00:00
Andrew Beal
3e43d9f558 refactor: improve legacy tool call conversion format and system prompt clarity
Simplify historical tool call/result format from bracketed text to JSON with HTML comments indicating completed status. Update system prompt to clarify this is historical context, not a pattern to reproduce. Improve chat area layout performance with debouncing and reduce minimum padding. Update all tests to match new format.
2025-12-12 23:37:30 +00:00
Andrew Beal
3a24ae2274 Bump plugin version to 1.0.8 2025-12-11 17:14:24 +00:00
Andrew Beal
ad46a0fa7f fix: use cursor position for search query extraction instead of full text 2025-12-11 17:11:41 +00:00
Andrew Beal
a86d784888 refactor: remove unused backspace handling and element detection logic
Remove custom backspace key handler in ChatInput and unused getElementBeforeCursor method in InputService. Clean up unused imports and associated test cases.
2025-12-11 12:41:14 +00:00
Andrew Beal
187b831155 refactor: improve chat layout updates and remove unused imports
- Remove unused StoredFunctionCall/Response imports from AI classes
- Replace settled flag with shouldSettle parameter for better control
- Add ResizeObserver to handle dynamic content size changes
- Bind indicator elements for accurate height calculations
- Update layout calculation to account for indicators when not settled
2025-12-11 08:42:09 +00:00
Andrew Beal
565bfdfda7 Refactor: move legacy function conversion to BaseAIClass
Consolidate convertFunctionCallToText and convertFunctionResponseToText
methods from Claude and Gemini into BaseAIClass for code reuse. Update
OpenAI to handle missing function call IDs by converting to legacy text
format, preventing undefined call_id bugs during cross-provider switches.
2025-12-10 21:47:27 +00:00
Andrew Beal
d36815c214 feat: add Gemini thought signature support and OpenAI Responses API migration
Implement thought signature tracking for Gemini function calls to support Gemini 3 requirements. Migrate OpenAI integration from Chat Completions to Responses API with proper input/output item handling. Add cross-provider compatibility via legacy text format fallback for conversations without thought signatures or tool IDs. Improve chat auto-scroll behavior and conversation validation. Add and update AI class and conversation tests.
2025-12-10 21:27:58 +00:00
Andrew Beal
51a30613a3 test: update FileSystemService error message assertion 2025-12-07 13:45:20 +00:00
Andrew Beal
9b67c45a78 - Improve mobile keyboard focus ux in diff view events
- Improve readFile error message for non-existent files
2025-12-07 13:43:09 +00:00
Andrew Beal
3e0aaaf736 Bump plugin version to 1.0.7 2025-12-06 16:51:37 +00:00
Andrew Beal
01cb1bf557 Update readme. 2025-12-06 16:48:58 +00:00
Andrew Beal
58a0edcee8 chore: bump dependencies to latest versions 2025-12-06 16:43:53 +00:00
Andrew Beal
3c9b5f9b73 feat: add mobile support for diff view with accept/reject buttons
- Add mobile-specific controls with Accept/Reject buttons for diff review
- Centralize user rejection/suggestion messages in AIFunctionResponse
- Update VaultService to use centralized message constants
- Style mobile buttons with proper touch targets and theme colors
- Auto-focus main view after accepting/rejecting changes on mobile
2025-12-06 16:38:01 +00:00
Andrew Beal
33440d17bf refactor: standardize error handling and logging across codebase
Replace console.error/log with Exception.log helper, improve OpenAI error handling with retryable errors, add type-safe model validation, and add new AI models (Claude Opus 4.5, Gemini 3 Pro Preview, GPT-5.1)
2025-12-06 14:09:46 +00:00
Andrew Beal
6f5f72952c fix: improve submit button state handling in diff mode
Update submit button icon and behavior to correctly reflect state when diff
is open. Button now shows appropriate icon based on input content and
triggers correct action (stop vs suggestion) in diff mode.
2025-12-05 23:34:52 +00:00
Andrew Beal
065d475d74 Refactor file patching from unified diff to direct string replace
This change simplifies the patch mechanism by replacing the unified diff format with a straightforward find-and-replace approach. The PatchVaultFile function now accepts oldContent and newContent parameters instead of a diff patch string, making it more intuitive and reliable for AI agents to use.

Key changes:
- Update PatchVaultFile function signature and documentation
- Replace diff.applyPatch() with String.replace()
- Simplify error handling for content matching
- Update all tests to reflect new API
- Remove unused applyPatch method from DiffService
- Fix diff container height calculation in CSS
- Fix error notification logic in ChatService
- Fix conversation deletion order in TopBar component
2025-12-05 23:02:55 +00:00
Andrew Beal
f7ff10699d Add PatchVaultFile function for incremental file updates
Implements unified diff patching as an alternative to WriteVaultFile for making targeted changes without replacing entire files. Includes new PatchVaultFile AI function, DiffService.applyPatch method, and comprehensive test coverage.
2025-12-05 22:48:54 +00:00
Andrew Beal
28772e7d0e feat: implement centralized abort controller with enhanced cancellation UX
Introduce a new AbortService to centralize cancellation logic across all async operations, replacing scattered AbortSignal parameters with a unified singleton service. This improves maintainability and provides consistent cancellation behavior throughout the application.

Key changes:
- Add AbortService for centralized abort signal management with automatic cleanup
- Refactor all AI providers (Claude, Gemini, OpenAI) to use AbortService instead of passing AbortSignal parameters
- Update streaming operations to use centralized abort handling
- Add CancellationIndicator component to show visual feedback during operation cancellation
- Rename ChatAreaThought to ThoughtIndicator for better semantic clarity
- Add Environment enum for consistent environment detection
- Enhance ChatService lifecycle with proper cancellation state management
- Remove scattered abort-related UI selectors and error messages in favor of dedicated indicator
- Add safeContinue() factory method to ConversationContent for internal continuations
- Update all tests to reflect new abort handling architecture

This change simplifies the API surface by removing AbortSignal parameters from method signatures while improving the user experience with clearer cancellation feedback.
2025-12-04 23:04:20 +00:00
Andrew Beal
d93e61bc9d fix: improve chat service lifecycle and diff handling reliability
- Stop chat service before loading conversations and resetting
- Add proper diff cancellation with resolve callback
- Add runtime type guards for plugin settings API access
- Improve diff view layout with padding adjustments
- Remove overly permissive TypeScript ESLint overrides
2025-11-27 16:47:21 +00:00
Andrew Beal
c69351404b Add ability for users to provide suggestions during diff review through new DiffControls component. Integrate suggestion workflow into chat input, allowing users to approve/reject changes or provide feedback without interrupting the review process.
Improve component lifecycle management by converting DiffService and StatusBarService to extend Component class, ensuring proper cleanup and event handling. Add automatic service cleanup in DependencyService during deregistration.

Refine error handling in AI function responses to return error messages instead of Error objects for better serialization. Update user rejection messaging to provide clearer guidance to AI about stopping actions.
2025-11-27 12:39:08 +00:00
Andrew Beal
2d5a1b52bf feat: add interactive diff viewer with user approval workflow
Implement a comprehensive diff viewing system that allows users to review and approve/reject file changes before they're applied. The system includes event-driven architecture for managing diff lifecycle and integrates diff2html for rich visual diffs.

Key changes:
- Add DiffService for managing diff approval workflow with accept/reject/suggest actions
- Create EventService for type-safe event handling (DiffOpened/DiffClosed)
- Add DiffView component with diff2html integration for visual diff rendering
- Modify VaultService to propose changes and require confirmation before file operations
- Update FileSystemService to support optional confirmation for write operations
- Add Event enum for centralized event type definitions
- Import custom styles and diff2html styles for proper diff rendering
- Update ConversationContent validation to support optional toolId field
- Remove FileManager from dependency injection (now accessed directly from app)
- Update .gitignore to track styles.css instead of main.css
2025-11-24 21:29:54 +00:00
Andrew Beal
6ec1c8aeb9 refactor: extract shared AI provider logic to BaseAIClass
Consolidate duplicate code from Claude, Gemini, and OpenAI implementations into a new BaseAIClass with common methods for parsing, filtering conversation contents, and error handling. Filter orphaned function calls without responses from conversation history to prevent API errors.
2025-11-24 09:11:07 +00:00
Andrew Beal
2d0022008c chore: update dependencies to latest versions 2025-11-22 10:36:57 +00:00