Skip to content

Remove ~1,200 lines of dead code across codebase#937

Open
PromtEngineer wants to merge 2 commits intomainfrom
claude/busy-bartik
Open

Remove ~1,200 lines of dead code across codebase#937
PromtEngineer wants to merge 2 commits intomainfrom
claude/busy-bartik

Conversation

@PromtEngineer
Copy link
Owner

Summary

  • Systematically identified and removed ~1,200 lines of dead code across 21 files (backend, RAG system, frontend) in 5 risk-ordered phases
  • Deleted 7 entirely unused files: api_server_with_progress.py, IndexWizard.tsx, GlassSelect.tsx, badge.tsx, skeleton.tsx, sidebar.tsx, chat-bubble-demo.tsx
  • Removed dead functions (show_graph, _get_bm25_retriever, handle_pdf_upload, get_simple_pdf_processor, etc.), unused imports, commented-out code blocks, and unreachable config entries

What was removed

Phase Risk Items
1 Lowest 7 dead imports and commented-out code blocks
2 Low 6 dead functions/variables in backend
3 Medium 3 broken/dead functions + config entries in RAG system
4 Medium 6 deleted files + 5 dead exports in frontend
5 Higher 1 entirely unused Python file (443 lines)

What was NOT removed (verified as actively used)

  • sendMessage() in api.ts — used by quick-chat.tsx
  • Database icon import in session-chat.tsx — used at lines 587, 625
  • onAddIndex prop in chat-input.tsx — passed from session-chat.tsx
  • Graph query code in agent/loop.py — guarded and extensible
  • validate_model_config.py — useful developer tool

Test plan

  • All Python files compile successfully (py_compile)
  • TypeScript type-check passes (tsc --noEmit)
  • RAG API starts without import errors
  • Document indexing works (POST /index → success)
  • Document querying works (POST /chat → correct answer with source docs)
  • Streaming works (POST /chat/stream → SSE events flow correctly)
  • No "Module not found" errors in browser console

🤖 Generated with Claude Code

PromtEngineer and others added 2 commits March 10, 2026 10:12
…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>
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.

1 participant