Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/desktop/src/DocumentPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function DocumentPreview({ isOpen, onClose, documentUrl, filename, highlightText
const page = await pdf.getPage(i);
const textContent = await page.getTextContent();
const pageText = normalizeText(
textContent.items.map((item: { str?: string }) => item.str || '').join(' ')
textContent.items.map((item) => ('str' in item ? item.str : '')).join(' ')
);
if (pageText.includes(searchSnippet)) {
setPageNumber(i);
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/layout/SourcePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function SourcePanel({ onSourceClick }: SourcePanelProps) {

<div className="source-panel-list">
{activeSources.map((source, i) => {
const nbId = (source as Record<string, unknown>).notebook_id as string | undefined;
const nbId = source.notebook_id;
const nbName = nbId ? notebooks.find((nb) => nb.notebook_id === nbId)?.title : null;

return (
Expand Down
4 changes: 1 addition & 3 deletions apps/desktop/src/components/ui/SetupWizard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useRef, useState } from 'react';
import { fetchConfig, uploadDocument } from '../../api';
import { uploadDocument } from '../../api';
import { useAppStore } from '../../store/app-store';
import { useNotebooks } from '../../hooks/useNotebooks';
import { showToast } from './Toast';
Expand Down Expand Up @@ -34,7 +34,6 @@ export function SetupWizard({ onComplete }: { onComplete: () => void }) {
const [ollamaStatus, setOllamaStatus] = useState<OllamaStatus>({ state: 'checking' });
const [selectedModel, setSelectedModel] = useState<string | null>(null);
const [uploading, setUploading] = useState(false);
const [uploadedFilename, setUploadedFilename] = useState<string | null>(null);
const fileInputRef = useRef<HTMLInputElement>(null);
const { refresh: refreshNotebooks } = useNotebooks();

Expand Down Expand Up @@ -95,7 +94,6 @@ export function SetupWizard({ onComplete }: { onComplete: () => void }) {
const result = await uploadDocument(file);
useAppStore.getState().setActiveNotebookId(result.notebook_id);
await refreshNotebooks();
setUploadedFilename(file.name);
showToast(`${file.name} indexed successfully`, 'success');

// Mark wizard complete and hand off
Expand Down
1 change: 0 additions & 1 deletion apps/desktop/src/components/ui/ZoteroImport.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useEffect, useState } from 'react';
import { useAppStore } from '../../store/app-store';
import { useNotebooks } from '../../hooks/useNotebooks';
import { showToast } from './Toast';
import './zotero-import.css';
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/hooks/useChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function useChat() {
const sources: SourceChunk[] = (event.sources ?? []).map((src) => ({
...src,
document_name: src.source_path.split(/[/\\]/).pop() ?? src.source_path,
relevance_score: (src as Record<string, unknown>).relevance_score as number | undefined,
relevance_score: src.relevance_score,
}));
s.setActiveSources(sources);
// Capture conversation_id from backend (created on first message)
Expand Down
3 changes: 3 additions & 0 deletions apps/desktop/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export interface StreamSource {
source_path: string;
preview: string;
distance?: number | null;
relevance_score?: number;
notebook_id?: string;
}

export type ChatStreamEvent =
Expand Down Expand Up @@ -94,6 +96,7 @@ export interface SourceChunk {
distance?: number | null;
document_name: string;
relevance_score?: number;
notebook_id?: string;
}

export interface CreateNotebookRequest {
Expand Down
5 changes: 4 additions & 1 deletion backend/notebooklm_backend/models/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ class ChatRequest(BaseModel):
prompt: str
history: List[ChatMessage] | None = None
notebook_id: str | None = Field(None, description="Optional notebook ID for RAG-enabled chat")
notebook_ids: List[str] | None = Field(None, description="Optional list of notebook IDs for cross-notebook synthesis")
notebook_ids: List[str] | None = Field(
None,
description="Optional list of notebook IDs for cross-notebook synthesis",
)
conversation_id: str | None = Field(None, description="Optional conversation ID for persistence")


Expand Down
1 change: 0 additions & 1 deletion backend/notebooklm_backend/routes/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ async def event_generator():
accumulated_reply = ""
sources_data: list[dict] | None = None
conversation_id = payload.conversation_id
persist_warning = False

try:
# Create conversation on first message if no conversation_id provided
Expand Down
3 changes: 1 addition & 2 deletions backend/notebooklm_backend/services/conversation_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import uuid
from contextlib import contextmanager
from datetime import datetime, timezone
from dataclasses import dataclass, field
from pathlib import Path
from dataclasses import dataclass
from typing import Iterable

from ..config import AppConfig
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/test_conversation_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ def test_messages_ordered_by_created_at(store):

def test_conversations_ordered_by_updated_at(store):
c1 = store.create_conversation(notebook_id="nb1", title="Older")
c2 = store.create_conversation(notebook_id="nb1", title="Newer")
store.create_conversation(notebook_id="nb1", title="Newer")

# c2 was created after c1, so it should appear first (DESC order)
# The newer conversation was created after c1, so it should appear first (DESC order)
convs = store.list_conversations("nb1")
assert convs[0].title == "Newer"
assert convs[1].title == "Older"
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/test_cross_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest
from notebooklm_backend.config import AppConfig
from notebooklm_backend.services.vector_store import VectorStoreManager, create_vector_store
from notebooklm_backend.services.vector_store import create_vector_store
from notebooklm_backend.services.chunking import TextChunk


Expand Down
Loading