Remove ~1,200 lines of dead code across codebase#937
Open
PromtEngineer wants to merge 2 commits intomainfrom
Open
Remove ~1,200 lines of dead code across codebase#937PromtEngineer wants to merge 2 commits intomainfrom
PromtEngineer wants to merge 2 commits intomainfrom
Conversation
…tend Systematically identified and removed dead code in 5 phases ordered by risk: Phase 1 - Dead imports/comments: - Remove unused `import pymupdf`, duplicate `from PIL import Image`, commented `ChunkStore` import in retrieval_pipeline.py - Remove commented `BM25Generator` import in embedders.py - Remove unused `parse_qs` import in api_server.py - Remove commented-out overview refresh block in agent/loop.py - Remove dead `json as _json` import alias in backend/server.py - Remove commented-out remove button in empty-chat-state.tsx Phase 2 - Dead backend functions/variables: - Remove `ensure_overview_path()` (defined but never called) in server.py - Remove `pdf_processor` global variable (assigned but never read) in server.py - Remove deprecated `handle_pdf_upload()` (returns 410, never called) in server.py - Remove `get_simple_pdf_processor()` (never called) in simple_pdf_processor.py - Remove `main()` test function and `if __name__` block in ollama_client.py - Remove unimplemented `--stop` arg and handler in run_system.py Phase 3 - Dead RAG functions/config: - Remove `_get_bm25_retriever()` (references nonexistent BM25Retriever class) - Remove `show_graph()` (references nonexistent config key, would KeyError) - Remove dead `bm25` and `graph_rag` entries from PIPELINE_CONFIGS Phase 4 - Dead frontend files/exports: - Delete 6 unused files: IndexWizard.tsx, GlassSelect.tsx, badge.tsx, skeleton.tsx, sidebar.tsx (replaced by session-sidebar.tsx), chat-bubble-demo.tsx - Remove unused `LocalGPTChat` import in demo.tsx - Remove unused `layout` prop from ChatBubble component - Remove `hasExcessiveWhitespace()` (exported, never called) in textNormalization.ts - Remove `cleanupEmptySessions()` and `uploadPDFs()` (never called) in api.ts Phase 5 - Unused file: - Delete rag_system/api_server_with_progress.py (443 lines, never imported) Verified: all Python files compile, TypeScript type-check passes, RAG pipeline E2E test passes (index → query → streaming all functional). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… error events Root cause: _apply_index_embedding_model() wrote to logs/embedding_debug.log via open(), but the logs/ directory didn't exist. The FileNotFoundError crashed the entire streaming pipeline, which sent an SSE "error" event that the frontend had no handler for — leaving the UI stuck in loading. Backend fix: Replace fragile file-based debug logging with Python's standard logging module (logging.getLogger), which never crashes. Frontend fixes: - session-chat.tsx: Handle "error" SSE events by displaying the error message and stopping the loading state - api.ts: Close the stream reader on "error" events (not just "complete") so the caller unblocks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
api_server_with_progress.py,IndexWizard.tsx,GlassSelect.tsx,badge.tsx,skeleton.tsx,sidebar.tsx,chat-bubble-demo.tsxshow_graph,_get_bm25_retriever,handle_pdf_upload,get_simple_pdf_processor, etc.), unused imports, commented-out code blocks, and unreachable config entriesWhat was removed
What was NOT removed (verified as actively used)
sendMessage()in api.ts — used by quick-chat.tsxDatabaseicon import in session-chat.tsx — used at lines 587, 625onAddIndexprop in chat-input.tsx — passed from session-chat.tsxvalidate_model_config.py— useful developer toolTest plan
py_compile)tsc --noEmit)POST /index→ success)POST /chat→ correct answer with source docs)POST /chat/stream→ SSE events flow correctly)🤖 Generated with Claude Code