Commit graph

47 commits

Author SHA1 Message Date
DJP
e6ff68b962 Add shared chat actions menu, rename functionality, and debug logging 2025-10-01 20:32:34 -04:00
DJP
33465ea337 Add better error handling and logging to pipeline query 2025-10-01 20:29:08 -04:00
DJP
2197405344 Add ChatSession imports to toggle and delete functions 2025-10-01 20:26:15 -04:00
DJP
26e03b1650 Fix chat session dict access (was trying to call object) 2025-10-01 20:24:11 -04:00
DJP
235a59ddb9 Fix chat history loading (corrupted code) 2025-10-01 20:21:38 -04:00
DJP
064e23127f Add ChatSession import and better error logging 2025-10-01 20:15:08 -04:00
DJP
2e0cc49423 Add error handling and debugging for chat session creation 2025-10-01 20:12:30 -04:00
DJP
85a9faec9f Complete chat system overhaul with privacy and session management
Chat Session Privacy:
- Chats are PRIVATE by default (only creator sees them)
- Added is_shared column to chat_sessions
- Users can toggle chat sharing with ⋮ menu
- Shared chats visible to all notebook collaborators
- Owner name shown on shared chats

Chat Session Management:
- Left sidebar shows all chat sessions
- "My Chats" section (private conversations)
- "Shared Chats" section (team conversations)
- Current chat marked with ▶ indicator
- Inactive chats have ○ indicator

New Chat Functionality:
- Fixed "New Chat" button (now works!)
- Creates fresh session with no stale context
- Clears message history
- Essential when documents are added/removed

Chat Actions (⋮ menu):
- Toggle sharing: 🔒 Private ↔ 🤝 Shared
- Delete chat (only owner)
- Close menu

UI Layout:
- Split view: Sessions sidebar (25%) + Chat area (75%)
- Session list on left
- Active chat on right
- Clean separation

Features:
- Multiple chats per notebook per user
- Switch between chat sessions instantly
- Each chat loads its own message history
- Fresh context for each new chat
- Share valuable conversations with team
- Delete outdated chats

Database:
- Added is_shared BOOLEAN DEFAULT FALSE
- Indexed (notebook_id, is_shared)
- Indexed (user_id, notebook_id)

Functions Added:
- get_user_private_chats() - user's private chats only
- get_shared_chats() - team's shared chats
- toggle_chat_sharing() - switch private/shared
- delete_chat_session() - remove chat (owner only)

Privacy Model:
- Default: Private (only creator sees)
- Opt-in: Share (all collaborators see)
- Read-only for non-owners on shared chats
- Complete isolation between users' private chats

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 20:02:02 -04:00
DJP
eb991ce81d Simplify regeneration prompt and strengthen keyboard shortcut hiding 2025-10-01 19:51:14 -04:00
DJP
da0ab10161 Hide keyboard shortcut navigation (showing broken text) 2025-10-01 19:46:04 -04:00
DJP
9ebbd1fb86 Add prompt to regenerate analysis after adding new documents 2025-10-01 19:45:20 -04:00
DJP
1686cb1a0f Fix keyboard shortcut display (show << >> arrows instead of text) 2025-10-01 19:43:38 -04:00
DJP
4fa22e7891 Add pipeline_id to Notebook SQLAlchemy model 2025-10-01 19:38:16 -04:00
DJP
1571742b8b Remove custom navigation section, strengthen yellow button CSS 2025-10-01 19:35:12 -04:00
DJP
63c4864802 Fix: Keep bottom navigation visible, only hide duplicate username 2025-10-01 19:32:19 -04:00
DJP
e5f5c58016 Strengthen CSS to hide Streamlit auto-navigation and duplicate username 2025-10-01 19:30:59 -04:00
DJP
a5f2696e40 Fix notebook deletion to work with shares (CASCADE delete) 2025-10-01 19:28:25 -04:00
DJP
f51d442f66 Fix Admin Dashboard TaskStatus enum usage 2025-10-01 19:27:03 -04:00
DJP
109fe00ae4 CRITICAL FIX: Implement per-notebook pipeline isolation
Security Fix:
- Fixed critical data leakage where all users shared one pipeline
- Each notebook now gets dedicated LlamaCloud pipeline
- Complete data isolation between notebooks
- Users can ONLY query their own notebook's documents

Pipeline Management:
- Created pipeline_manager.py module
- create_notebook_pipeline() creates dedicated pipeline
- add_document_to_pipeline() adds to specific pipeline
- query_notebook_pipeline() queries only that pipeline
- get_notebook_query_engine() returns isolated query engine

Database Changes:
- Added pipeline_id column to notebooks table
- Indexed for performance
- Stored when notebook created

Notebook Creation:
- create_notebook() now creates LlamaCloud pipeline
- Pipeline named: "notebook_{id}_{name}"
- pipeline_id stored in notebook record
- Async pipeline creation

Document Processing:
- execute_document_processing_task() uses notebook.pipeline_id
- Documents added to NOTEBOOK's pipeline (not shared!)
- Complete isolation per notebook
- Validates pipeline exists before processing

Chat Updates:
- Removed MCP client (was using shared pipeline!)
- Now uses pipeline_manager.query_notebook_pipeline()
- Queries ONLY the notebook's dedicated pipeline
- Shows warning if notebook has no pipeline
- Caption: "Chatting across X documents in this notebook only"

Bug Fixes:
- Fixed Admin Dashboard import (BackgroundTask from background_tasks)
- Yellow button CSS using correct selector (baseButton-primary)
- Delete buttons stay red using :has(div:contains()) selector

Data Isolation Verification:
- Each notebook = separate LlamaCloud pipeline
- Each pipeline = isolated index
- Chat queries single pipeline only
- No cross-notebook data leakage

Migration Note:
- Old notebooks without pipeline_id will show warning
- Need to create new notebooks to get pipeline isolation
- Could add migration script to create pipelines for existing notebooks

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 19:25:54 -04:00
DJP
009fd9959b Fix button colors and document critical data leakage issue
Button Color Fix:
- Changed CSS selector to target data-testid="baseButton-primary"
- Primary buttons now yellow (#FFC407) with black text
- Hover state: darker yellow (#E6B006)
- Delete/Remove buttons stay red for safety
- Better font-weight (600) for buttons

Critical Issue Documented:
- Created CRITICAL_ISSUE.md documenting data leakage
- ALL users share ONE LlamaCloud pipeline
- Chat queries return documents from ALL notebooks (not just user's)
- SEVERE privacy/security issue
- Must be fixed before production use

Issue Details:
- utils.py uses single PIPELINE_ID from .env
- All documents added to same index
- query_index() searches entire shared index
- No user/notebook isolation in queries

Recommended Fix:
- Per-notebook pipelines (best for NotebookLM model)
- Store pipeline_id in notebooks table
- Create pipeline when notebook created
- Query only that notebook's pipeline
- Complete data isolation

Background Queue Status:
- Document processing IS using background queue ✓
- Some tasks failing with "Event loop is closed"
- Need to investigate async/threading issues

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 19:20:32 -04:00
DJP
ffd871ef25 Change primary buttons to yellow (#FFC407), keep delete red 2025-10-01 19:12:07 -04:00
DJP
fbefffe002 Add logo to all pages, hide sidebar on login, create Admin Dashboard
Logo Implementation:
- Logo now appears on ALL pages automatically
- Moved logo display to apply_custom_styles() function
- 300px width, positioned at top with margin adjustments
- Uses SBLM.jpg from src/notebookllama/

Login Page Improvements:
- Sidebar completely hidden when not logged in
- Cleaner login experience
- No navigation shown to unauthenticated users
- Title updated to "Sandbox-NotebookLM - Login"

Admin Dashboard:
- Replaced Observability Dashboard with Admin Dashboard
- Shows platform usage statistics:
  * Total users, notebooks, documents, chat messages
  * Estimated costs (documents, chats, podcasts)
  * Recent activity (users, notebooks, documents)
  * Background task monitoring
  * User analytics (most active users)
  * System health (failed/pending tasks)

Admin Access Control:
- Only user ID 1 or users with "admin" in email can access
- Admin link only shows in sidebar for admins
- Protected with access check

Cost Tracking:
- Document processing: ~$0.60 each
- Chat messages: ~$0.01 each
- Podcasts: ~$0.50 each
- Total cost estimate displayed

Analytics Features:
- Top 5 most active users by notebook count
- Recent users/notebooks/documents lists
- Background task status with color coding
- System health indicators
- Real-time statistics

Files:
- Created pages/5_Admin_Dashboard.py
- Removed pages/5_Observability_Dashboard.py (backed up)
- Updated styles.py with show_logo() function
- Updated App.py navigation to show Admin conditionally

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 19:10:51 -04:00
DJP
8a33bd5b9a Add logo display at top of app 2025-10-01 19:05:10 -04:00
DJP
d0ae72ea2b Hide keyboard shortcut hints in header 2025-10-01 19:03:53 -04:00
DJP
ab0ad2c30d Add logo, hide deploy button, fix login title
UI Updates:
- Changed login page title to "Sandbox-NotebookLM - Login"
- Hidden deploy button in top right (toolbar hidden)
- Added Sandbox-NotebookLM logo to top left header
- Logo is SVG with concentric circles icon
- Logo shows "Sandbox" and "NotebookLM" text
- Montserrat font in logo matches app

CSS Changes:
- [data-testid="stToolbar"] display:none (hides deploy)
- [data-testid="stHeader"] background-image with logo SVG
- Logo positioned 10px from left, centered vertically
- 160px logo size
- Header padding adjusted for logo space

Visual Improvements:
- Cleaner header without deploy button
- Professional branding with logo
- Consistent typography throughout

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 19:03:27 -04:00
DJP
44b8e7fcfd Fix permission enum case mismatch (lowercase to uppercase) 2025-10-01 18:57:49 -04:00
DJP
030cd2ef30 Add Write+Share permission and voice selection
Permission System Upgrade:
- Added SHARE permission level to database enum
- Three permission tiers now:
  * READ: View and chat only
  * WRITE: View, chat, add documents, generate podcasts
  * SHARE (Write+Share): All of WRITE + can share with others
- Only owners can grant SHARE permission
- Users with SHARE can add more collaborators

Voice Selection for Podcasts:
- Added 8 popular ElevenLabs voices to choose from
- Speaker 1 (Analytical): Brian, Adam, Charlie, Daniel
- Speaker 2 (Explanatory): Sarah, Bella, Charlotte, Emily
- Voice IDs stored in task parameters
- Passed through to audio generation
- Default: Brian + Sarah (original voices)

Voice Options:
- Brian (Default Male) - nPczCjzI2devNBz1zQrb
- Sarah (Default Female) - Xb7hH8MSUJpSbSDYk0k2
- Adam (Deep Male) - pNInz6obpgDQGcFmaJgB
- Bella (Friendly Female) - EXAVITQu4vr4xnSDxMaL
- Charlie (Casual Male) - IKne3meq5aSn9XLyUdCD
- Charlotte (Professional Female) - XB0fDUnXU5powFXDhCwa
- Daniel (British Male) - onwK4e9ZLuTAKqWW03F9
- Emily (Warm Female) - LcfcDJNUP1GQjkzn1xUU

UI Updates:
- Voice selection dropdowns in podcast generation
- Helpful descriptions for each speaker role
- Permission level shown as "Write + Share" in UI
- Help text explains each permission tier
- Share button visible for users with SHARE permission

Technical:
- Updated audio.py to accept voice parameters
- Updated background_tasks.py to pass voices
- Database enum extended
- Permission checks updated throughout

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 18:15:26 -04:00
DJP
ec608b15fa Add background document processing and fix navigation
Background Document Processing:
- Documents now process in background queue (like podcasts!)
- Upload 10+ PDFs and navigate away immediately
- Each document processes independently (~1 minute each)
- Status tracking for all documents
- Can view processing progress in notebook detail
- Automatic refresh option to check status

Processing Status Display:
- Shows " X documents currently processing"
- Expandable status list with filename and state
- Icons:  pending, 🔄 in progress, ✓ completed
- Refresh button to check latest status
- Processing happens in parallel threads

Navigation Fix:
- Fixed CSS to hide Streamlit's auto-generated page list (bottom-left)
- Kept custom navigation at top of sidebar
- Better selector: section[data-testid="stSidebarNav"]
- Custom nav remains visible and functional

Technical:
- Extended background_tasks.py to handle document processing
- Created execute_document_processing_task function
- start_document_processing_background creates tasks
- get_notebook_processing_tasks retrieves status
- Task routing based on task_type
- Proper temp file cleanup in background

User Experience:
- Can upload 20 documents and leave immediately
- No more waiting 20+ minutes on one page
- Processing continues in background
- Come back anytime to check progress
- Much better for large batch uploads

Button Updates:
- "Upload & Process" → "Upload & Process in Background"
- Clear messaging about background processing
- Task IDs shown for tracking

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 18:09:02 -04:00
DJP
673a3f747e Rebrand to Sandbox-NotebookLM and refine UI
Rebranding:
- Changed app name from NotebookLlaMa to Sandbox-NotebookLM
- Updated all page titles
- Updated dashboard title and welcome message

UI Improvements:
- Reduced sidebar username size (was too large)
- Changed "Welcome, username!" to just "username" with emoji
- Email shown as caption below username
- Removed redundant bottom-left navigation menu (hidden via CSS)
- Sidebar navigation headers reduced to 14px
- Logout button now full-width for better UX

Typography Refinements:
- Sidebar headers: 16px → 14px
- Navigation items cleaner
- Better visual hierarchy
- More professional appearance

CSS Changes:
- Added [data-testid="stSidebarNav"] display:none to hide duplicate nav
- Reduced sidebar h1/h2/h3 to 14px
- Better spacing in sidebar
- Consistent font weights

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 18:04:58 -04:00
DJP
6cdca94608 Add Montserrat typography and refined UI styling
Typography:
- Applied Montserrat font globally across all pages
- Reduced main headers from 44px to 20px
- Subheaders scaled to 18px and 16px
- Body text standardized at 16px
- Source citations reduced to 14px for better readability
- Captions and small text at 13px

Style Improvements:
- Consistent font weights (300-700 range)
- Better line-height for readability (1.3-1.5)
- Reduced spacing for cleaner look
- Styled chat messages for consistency
- Smaller button text (14px)
- Refined expander headers
- Professional color scheme maintained

Files Modified:
- Created styles.py with centralized CSS
- Applied to App.py
- Applied to all 4 notebook pages
- Custom CSS injected via st.markdown

User Experience:
- Cleaner, more professional appearance
- Better visual hierarchy
- Easier to scan and read
- Sources less overwhelming
- Consistent across all pages

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 17:59:33 -04:00
DJP
dc1f27e041 Add custom podcast themes and complete sharing management
Podcast Enhancements:
- Custom theme/focus field for podcast generation
- Additional instructions textarea for personalized podcasts
- Theme and prompt integrated into outline generation
- Parameters passed through background task system
- Example: "Focus on actionable insights for executives"

Sharing Features:
- Show list of all users notebook is shared with
- Display email and permission level for each
- Add more users to existing shares (incremental)
- Remove users from shares with one click
- Update permissions for existing shares
- "Done" button instead of "Cancel" for better UX

Shared Notebook Improvements:
- Full view access for shared notebooks (all docs, summaries, Q&A)
- Permission-based UI (Read-only vs Write access)
- Read-only users see limited buttons (Chat, Listen to Podcast)
- Write users can add documents and generate podcasts
- Owner badge vs Shared badge in header
- Proper back navigation to Shared Notebooks page
- Fixed "Notebook not found or access denied" error

Access Control:
- Notebook Detail checks ownership OR sharing
- Chat checks ownership OR sharing
- Database validation for share access
- Session state tracks shared status
- Permission level enforced throughout UI

Bug Fixes:
- Fixed shared notebook access in Detail page
- Fixed shared notebook access in Chat page
- Hide edit/delete/share buttons for non-owners
- Hide document remove for read-only users

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 17:56:24 -04:00
DJP
075e568455 Fix shared notebook permissions and access control
Features:
- Shared notebooks now show full detail view (all docs, summaries, Q&A)
- Permission-based access control (Read vs Write)
- Read-only users can view and chat but not edit
- Shared notebook chat now works properly
- Fixed "Notebook not found or access denied" error

Access Control:
- Read permission: View, Chat only
- Write permission: View, Chat, Add Documents, Generate Podcast
- Owner: Full control (View, Chat, Add, Share, Edit, Delete)

UI Improvements:
- Shows "Shared with you (Read-only)" badge for shared notebooks
- Hides edit/delete/share buttons for non-owners
- Hides document remove button for read-only users
- Proper back navigation to Shared Notebooks page
- Access validation in both Detail and Chat pages

Bug Fixes:
- Fixed SQLAlchemy session error in shared notebooks list
- Fixed notebook access check to query database for shares
- Session state properly tracks shared status
- Permission level properly passed between pages

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 17:51:18 -04:00
DJP
ce09d57cef Add background podcast generation and UX improvements
Features:
- Background podcast generation (navigate away while processing!)
- Podcast status tracking (pending/in_progress/completed/failed)
- Database-backed task queue (no external dependencies)
- Podcast length control with slider (5-30 minutes)
- Fixed podcast delete to update UI immediately
- Collapsible source citations in chat (dropdown with count)
- Real-time status checking for background tasks

Technical:
- Created background_tasks.py module
- Added background_tasks table to database
- Threading-based background execution
- Task status tracking: PENDING, IN_PROGRESS, COMPLETED, FAILED
- Proper database session management in shared notebooks
- Fixed SQLAlchemy DetachedInstanceError in sharing view

UX Improvements:
- "Generate in Background" button instead of blocking
- Status indicator shows when podcast is generating
- "Check Status" refresh button
- Sources collapsed by default with count badge
- Podcast delete shows success message before rerun
- Can navigate away during long-running operations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 17:47:10 -04:00
DJP
b7cd5a58c7 Fix shared notebooks SQLAlchemy session error 2025-10-01 17:39:19 -04:00
DJP
68b12a3143 Add notebook-level synthesis and advanced features
New Features:
- Cross-document synthesis: Analyzes all docs together to find themes
- Cross-document Q&A: Questions that span multiple documents
- Structured podcast outline generation
- Podcast length control (5-30 minutes slider)
- Better visual source indicators with 🔗 badges
- Comparative findings across documents
- Key insights from combined analysis

Technical Changes:
- Created notebook_synthesis.py module
- Added NotebookSynthesis pydantic model
- Added PodcastOutline pydantic model
- Enhanced podcast generation with 3-step process
- Improved source attribution display
- Better visual hierarchy in notebook detail page

User Experience:
- "Generate Cross-Document Analysis" button
- Shows overall summary synthesizing ALL docs
- Displays common themes across documents
- Comparative findings (similarities/differences)
- Cross-document questions for exploration
- Podcast length selector (5, 10, 15, 20, 25, 30 min)
- Inline source citations with better formatting

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 17:37:28 -04:00
DJP
2292f8a511 Transform NotebookLlaMa to enterprise multi-user NotebookLM clone
Major Changes:
- Implemented notebook-first architecture (multi-document collections)
- Added user authentication and multi-tenancy
- Created comprehensive database schema (7 tables)
- Built complete notebook management system
- Implemented notebook-level chat across multiple documents
- Added podcast generation from notebooks
- Implemented notebook sharing with permissions
- Fixed MCP server crashes by bypassing for document processing
- Added all enterprise features requested

New Features:
- User login/signup with bcrypt password hashing
- Create/edit/delete notebooks
- Upload multiple PDFs to notebooks
- Add documents to existing notebooks
- Chat across all documents in a notebook
- Generate podcasts from entire notebooks
- Share notebooks with other users
- View shared notebooks
- Persistent chat history per notebook
- Document summaries, Q&A, and highlights

Technical Improvements:
- PostgreSQL database with SQLAlchemy ORM
- Connection pooling and proper cleanup
- Bypassed buggy MCP server for document processing
- Direct LlamaCloud API calls for reliability
- Proper CASCADE deletes
- Session management
- Error handling and logging

Documentation:
- ENTERPRISE_SETUP.md - Setup guide
- IMPLEMENTATION_SUMMARY.md - Technical details
- SIMPLIFIED_PLAN.md - Architecture overview
- CURRENT_STATUS.md - Status and known issues
- FINAL_README.md - User guide

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 17:28:06 -04:00
Clelia (Astra) Bertelli
ca9ee1250c Renaming to NotebookLlama 2025-06-30 22:31:22 +02:00
Clelia (Astra) Bertelli
b72424dded typecheck changes 2025-06-29 12:10:03 +02:00
Clelia (Astra) Bertelli
3ed767da23 Adding observability dashboard 2025-06-29 12:01:17 +02:00
Clelia (Astra) Bertelli
e9ac959a28 Adding document chat and moving to a multi-page app 2025-06-28 23:25:13 +02:00
Clelia (Astra) Bertelli
7ce3d1249b UI + final touches 2025-06-28 22:07:44 +02:00
Clelia (Astra) Bertelli
e0feb0ceec Refactor + workflow 2025-06-28 19:48:54 +02:00
Clelia (Astra) Bertelli
9f95e49463 Refactoring 2025-06-28 16:38:59 +02:00
Clelia (Astra) Bertelli
1e13a08701 Audio utils completed + tests 2025-06-28 12:39:43 +02:00
Clelia (Astra) Bertelli
e1d12c8497 more utils, server and tests 2025-06-28 11:25:08 +02:00
Clelia (Astra) Bertelli
1c947443cd utils functions 2025-06-28 09:36:33 +02:00
Clelia (Astra) Bertelli
3d86713cb3 first commit 2025-06-27 22:47:48 +02:00