Skip to content

Conversation

@jasielmacedo
Copy link
Owner

This commit fixes model download issues and implements context-aware AI interactions:

Model Download Improvements:

  • Add retry logic with exponential backoff (max 3 retries)
  • Implement proper error handling for network issues (ECONNRESET, ETIMEDOUT, etc.)
  • Add heartbeat monitoring to detect stalled downloads (2-min timeout)
  • Add socket keep-alive to prevent connection drops
  • Track active downloads to prevent duplicate downloads
  • Provide user-friendly error messages
  • Add download cancellation support

Context Awareness Implementation:

  • Add PageContext type for current page URL, title, content, and selected text
  • Add AIContext type combining page context, browsing history, and bookmarks
  • Update GenerateOptions and ChatOptions to accept optional context
  • Implement buildContextualSystemPrompt() to inject context into AI prompts
  • Update generate() and chat() methods to use contextual prompts
  • Add page:getContext IPC handler to capture current page info
  • Update IPC handlers to validate and pass context to Ollama service

Technical Details:

  • Add error field to PullProgress for better error reporting
  • Add retry status to show retry attempts to users
  • Use HTTP/HTTPS agents with keep-alive for stable connections
  • Truncate page content to 5000 chars to avoid token limits
  • Validate all context fields for security

This enables the AI to be aware of:

  • Current browsing page (URL, title, content)
  • Selected text on the page
  • Recent browsing history
  • User bookmarks

All changes maintain backward compatibility.

This commit fixes model download issues and implements context-aware AI interactions:

Model Download Improvements:
- Add retry logic with exponential backoff (max 3 retries)
- Implement proper error handling for network issues (ECONNRESET, ETIMEDOUT, etc.)
- Add heartbeat monitoring to detect stalled downloads (2-min timeout)
- Add socket keep-alive to prevent connection drops
- Track active downloads to prevent duplicate downloads
- Provide user-friendly error messages
- Add download cancellation support

Context Awareness Implementation:
- Add PageContext type for current page URL, title, content, and selected text
- Add AIContext type combining page context, browsing history, and bookmarks
- Update GenerateOptions and ChatOptions to accept optional context
- Implement buildContextualSystemPrompt() to inject context into AI prompts
- Update generate() and chat() methods to use contextual prompts
- Add page:getContext IPC handler to capture current page info
- Update IPC handlers to validate and pass context to Ollama service

Technical Details:
- Add error field to PullProgress for better error reporting
- Add retry status to show retry attempts to users
- Use HTTP/HTTPS agents with keep-alive for stable connections
- Truncate page content to 5000 chars to avoid token limits
- Validate all context fields for security

This enables the AI to be aware of:
- Current browsing page (URL, title, content)
- Selected text on the page
- Recent browsing history
- User bookmarks

All changes maintain backward compatibility.
@jasielmacedo jasielmacedo merged commit fc0b26f into main Nov 5, 2025
1 check passed
@jasielmacedo jasielmacedo deleted the claude/fix-model-download-management-011CUq8ea9HYHkffLn4VbzwT branch November 5, 2025 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants