Conversation
- Built-ins from the stdlib (add, dup, swap, etc.) - Your definitions from the current session - Included module words (if you use include std:...) The completion filtering by prefix means you only see relevant matches as you type. Ready to commit these changes? The diff includes: - crates/repl/src/lsp_client.rs (new) - LSP client with JSON-RPC - crates/repl/src/main.rs - SeqHelper with Tab completion - Cargo.toml / crates/repl/Cargo.toml - lsp-types dependency
Pull Request Review: LSP Integration for REPL Tab CompletionThis PR adds excellent LSP-based tab completion to the REPL. The implementation is well-architected and follows good Rust practices. Strengths
Critical Issues1. Infinite Loop Risk (lsp_client.rs:235-254)The read_response() function loops indefinitely waiting for a specific response ID. If the LSP server sends only notifications, this could hang forever. Recommendation: Add timeout or buffer for unmatched responses. 2. Windows URI Incompatibility (lsp_client.rs:82)
Fix: Use 3. Line Calculation Bug (main.rs:147-148)The virtual document line number calculation may be off-by-one depending on where insert_pos falls relative to newlines. Recommendation: Add test cases for various insert positions. 4. RefCell Panic Risk (main.rs:119)
Fix: Use Performance IssuesFile I/O on Every Completion (main.rs:126)Every Tab press reads the entire session file from disk. Recommendation: Cache file content in SeqHelper, invalidate on sync_document(). Double LSP Round-tripsEach completion sends did_change twice (virtual doc + restore). Impact: Doubles latency for remote/slow LSP servers. Other Concerns
Code Quality
Test Coverage Needed
Overall AssessmentThis is high-quality work that significantly improves the REPL UX. Main concerns:
Recommendation: Approve with requested changes - fix critical bugs and add basic tests. Great work! The LSP integration is a valuable addition. |
PR Review: LSP Integration for REPL Tab CompletionOverviewThis PR adds LSP-based tab completion to the REPL, along with vi mode support and an ✅ StrengthsCode Quality
Design Decisions
🔍 Issues & SuggestionsCritical: Potential Infinite Loop (lsp_client.rs:235-254)Severity: High The Problem: No timeout or message limit - the loop consumes messages indefinitely waiting for the expected response ID. Recommendation: Add a bound on skipped messages or implement a proper message queue for out-of-order handling. Security: Command Injection Risk (lsp_client.rs:316-345)Severity: Medium The Recommendations:
Bug: RefCell Borrow Panic Risk (main.rs:120)Severity: Medium Using Recommendation: Use Performance: Unnecessary File I/O (main.rs:127)Issue: Every tab completion reads the entire file from disk - inefficient for large REPL sessions. Recommendation: Cache file content and invalidate only on explicit modifications ( Error Handling: Silent FailuresIssue: Many operations silently swallow errors without logging:
Recommendation: Add debug logging for diagnostic purposes. 🧪 Test CoverageCritical Gap: No tests for the new functionality. Suggested Tests
Note: The codebase has runtime tests but no REPL tests. Consider adding 📝 DocumentationMissing Documentation
🔒 Security Concerns
🎯 Performance ConsiderationsGood
Needs Improvement
🌟 Nice Touches
📋 Summary
Action ItemsMust Fix:
Should Fix: Nice to Have: 🎉 ConclusionThis is a high-quality PR that adds significant value to the REPL experience. The LSP integration is well-designed with graceful degradation. Main concerns:
After addressing the "must fix" items and adding basic tests, this would be ready to merge. Great work! |
Issues Fixed:
1. Infinite loop risk (Critical) - Added MAX_SKIPPED_MESSAGES = 100 limit to read_response() to prevent hanging forever
2. RefCell panic risk (Medium) - Changed borrow_mut() to try_borrow_mut() in both sync_document() and complete() - gracefully returns empty completions on failure
3. Performance: File I/O on every completion - Added cached_content: RefCell<String> to SeqHelper - Cache is updated on sync_document() - get_content() uses cache, falls back to disk read if unavailable
4. Missing tests - Added 3 new tests (now 10 total):
- test_duplicate_include_detection
- test_template_has_all_markers
- test_vi_mode_detection
Not addressed (by design):
- Windows URI compatibility - project doesn't target Windows (macOS/Linux only)
- Security concerns about process spawning - acceptable for dev tool, documented
- Debug logging - could be added later if needed
All tests pass (10 tests), clippy clean, formatted.
PR Review: LSP Integration for REPLSummaryThis PR adds LSP-based tab completion to the Seq REPL by integrating with the existing Code Quality & Best PracticesStrengths ✅
Areas for Improvement
|
The completion filtering by prefix means you only see relevant matches as you type.
Ready to commit these changes? The diff includes: