Skip to content

feat(notes): add ai-powered url analyzer with opt-in toggle - #46

Open
sanjanasingineedi wants to merge 2 commits into
ManabBiswas:mainfrom
sanjanasingineedi:feat/notes-ai-url-analyzer
Open

feat(notes): add ai-powered url analyzer with opt-in toggle#46
sanjanasingineedi wants to merge 2 commits into
ManabBiswas:mainfrom
sanjanasingineedi:feat/notes-ai-url-analyzer

Conversation

@sanjanasingineedi

Copy link
Copy Markdown

Summary

Closes #42

Adds a Source URL Manager and AI-powered web content analyzer to the Notes Panel, allowing students to save reference URLs and generate structured study notes from them using a local AI model.

Type of Change

  • ✨ New feature (non-breaking change that adds functionality)

Related Issues

Closes #42

Changes Made

Part 1 — Source URL Manager (always visible)

  • New "Source URLs" section in the notes editor
  • Paste any public http/https URL and click Add to save it
  • Multiple URLs can be saved per note
  • URLs are stored in the database (source_urls column) with automatic migration for existing databases
  • Saved URLs are clickable (opens in default browser) with a remove button
  • URLs persist when switching between notes

Part 2 — AI Web Analyzer (opt-in toggle, off by default)

  • Toggle switch "AI Analyzer" — disabled by default as requested
  • When enabled, "Analyze with AI" button appears
  • On click, the Electron main process fetches all saved URLs (bypasses CORS), extracts readable text, and sends it to the local AI for analysis
  • AI generates structured study notes shown in a two-panel modal:
    • Left panel: section headings
    • Right panel: full content of selected section (selectable text)
  • Three import options:
    • Import Selected Text — highlight specific lines and import only those
    • Import Full Section — append entire section as markdown
    • Append All — import all sections at once
  • Graceful error message when no AI model is available

AI Stack

  • Tries embedded local LLM first (node-llama-cpp)
  • Falls back to Ollama (same pattern as existing generateNoteInsights)
  • Default Ollama model is phi (as configured in the project)
  • Shows a clear message if neither is available
  • Note: larger models (llama3, mistral) produce better structured output; smaller models like phi or tinyllama may return plain text which is auto-parsed into sections as a fallback

Files Changed

File Change
src/main/db/database.ts Added source_urls column + automatic migration for existing DBs
src/main/db/queries.ts Updated insertNote and updateNote to include source_urls
src/main/handlers/ipcHandlers.ts Added notes:fetchUrl and notes:analyzeUrls IPC handlers
src/preload.ts Exposed window.api.notes.fetchUrl and window.api.notes.analyzeUrls via contextBridge
src/shared/ipc.ts Added IPCUrlSection, IPCFetchUrlResult, IPCAnalyzeUrlsResult types; added source_urls to IPCNote, IPCNoteCreateInput, IPCNoteUpdateInput
src/index.d.ts Updated IPCNotes interface with fetchUrl and analyzeUrls
src/components/NotesPanel.tsx Full UI implementation — URL manager, toggle, analyzer modal

Testing

  • Tested with multiple GFG articles (OS, DBMS topics)
  • Tested with 2 URLs analyzed together
  • Verified toggle on/off behavior
  • Verified Import Selected Text, Import Full Section, Append All
  • Verified graceful fallback when no model available
  • Verified URL persistence across note switching
  • Verified note saving with source URLs

Limitations (by design)

  • Only public http/https URLs supported
  • Pages behind login walls (ChatGPT, Gemini, Claude) not supported
  • AI quality depends on locally available model — larger models
    (llama3, mistral) produce better structured output than tinyllama

Known Limitation & Proposed Improvement

When the AI returns plain text instead of structured JSON (common with smaller models like phi or tinyllama), the response is auto-parsed into sections by sentence chunking, which may produce fewer sections than expected.

Proposed follow-up improvement: Pre-section the content using HTML headings extracted during fetch (already available in the pipeline), then use AI only to summarize each section — this would give reliable sections regardless of model size and is planned as a follow-up.

Checklist

  • I have followed the code style guidelines
  • I have tested my changes locally
  • My changes don't introduce new warnings or errors

- add source_urls column to notes table with migration
- add url manager ui to save multiple source urls per note
- add ai analyzer toggle (disabled by default, opt-in)
- add notes:analyzeUrls ipc handler that fetches all saved urls
  via electron main process (bypasses cors), extracts readable
  text, sends to local llm / ollama fallback for analysis
- ai returns structured study notes shown in two-panel modal
  (section headings left, full content right)
- add import selected text, import full section, append all options
- add IPCAnalyzeUrlsResult, IPCUrlSection, IPCFetchUrlResult types
- expose window.api.notes.analyzeUrls via contextBridge preload
- graceful degradation when no ai model available

Closes ManabBiswas#42
@ManabBiswas

Copy link
Copy Markdown
Owner

@sanjanasingineedi can you give me demo video or its link here.

@ManabBiswas

Copy link
Copy Markdown
Owner

@sanjanasingineedi can you give me any screenshots?

@sanjanasingineedi can you give me demo video or its link here.

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.

[FEATURE] Add Source URL Importer to Notes Panel.

2 participants