-
-
Notifications
You must be signed in to change notification settings - Fork 0
Implement VSCode Outliner Extension Spec #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement VSCode Outliner Extension Spec #10
Conversation
Implement Task 9 from vscode-outliner-extension spec to centralize
node ID generation in the backend, ensuring consistency across all
operations and eliminating duplicate ID generation logic.
Changes:
- Added getDocumentTree() method to PythonBridge TypeScript class to
request tree structure with backend-assigned IDs via JSON-RPC
- Added BackendTreeNode and DocumentTreeResponse type definitions to
support backend tree serialization format
- Updated DocumentOutlineProvider to use backend tree when available:
- Added pythonBridge constructor parameter
- Implemented deserializeBackendTree() method to convert backend
TreeNode structure to frontend OutlineNode format
- Modified updateFromDocument() to call backend getDocumentTree()
with fallback to local parsing if backend unavailable
- Updated extension.ts to initialize DocumentOutlineProvider with
pythonBridge for centralized ID generation
- Kept local parseDocument() as robust fallback when backend offline
- Fixed Python code formatting in dsl/executor.py and dsl/lexer.py
(pre-existing formatting issues found during quality checks)
Task completion:
- Task 9.1: Frontend now requests tree from backend ✓
- Task 9.2: Backend tests already comprehensive (25 tests) ✓
- Task 8.1: Granular edits already implemented ✓
Tests:
- All 168 Python tests pass (2 skipped)
- Backend has 13 tests for build_tree_with_ids
- Backend has 12 tests for get_document_tree RPC method
- Ruff linting and formatting checks pass
This addresses PR #6 Issue #5 (Medium priority) and ensures node IDs
are generated consistently by the backend, preventing ID mismatches
between tree view and operations.
Summary of ChangesHello @tommcd, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the reliability and consistency of the VSCode Outliner extension by migrating the responsibility of generating unique node IDs from the frontend to the backend. This change addresses a critical issue of potential ID mismatches, ensuring that the outline view accurately reflects document structure across all operations. The frontend has been updated to communicate with the backend for tree generation, while also retaining a robust local parsing fallback for resilience. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request successfully centralizes node ID generation in the backend, a significant improvement for ensuring data consistency in the outliner. The frontend is correctly updated to request the document tree from the Python bridge, with a robust fallback to local parsing if the backend is unavailable. The code is well-structured and the changes align with the PR's objective. My review includes a few suggestions for the new deserializeBackendTree method in outlineProvider.ts to enhance code clarity, metadata correctness, and robustness.
Address three code review comments from PR #10: 1. Remove unused parameter (Medium priority) - Removed unused 'parent' parameter from deserializeBackendTree() function signature as parent-child relationships are already handled within the nested convertNode helper function 2. Add explicit error logging (Medium priority) - Added warning log when backend returns out-of-bounds line numbers - Helps identify synchronization issues between frontend and backend - Warning includes node label, line number, and document line count for easier debugging 3. Fix hardcoded metadata placeholders (Medium priority) - Removed hardcoded metadata placeholder values that were perpetually inaccurate (hasContent: false, contentLength: 0, lastModified) - Added explanatory comment noting metadata requires document content analysis and is intentionally omitted to avoid incorrect tooltips - Added TODO for future enhancement to calculate real metadata values Testing: - All 168 Python tests pass (2 skipped) - Ruff linting and formatting checks pass - No functional changes, only code quality improvements Addresses: #10 (review)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements Task 9 from the vscode-outliner-extension spec to centralize node ID generation in the backend, ensuring consistency across all operations and preventing ID mismatches between tree view and operations.
Key Changes:
- Added backend tree request via JSON-RPC with
getDocumentTree()method in PythonBridge - Updated DocumentOutlineProvider to use backend-generated IDs with local parsing as fallback
- Added BackendTreeNode and DocumentTreeResponse type definitions for backend tree serialization
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/doctk/dsl/lexer.py | Fixed string quote formatting (pre-existing formatting issue) |
| src/doctk/dsl/executor.py | Removed extra blank line (pre-existing formatting issue) |
| extensions/doctk-outliner/src/types.ts | Added BackendTreeNode and DocumentTreeResponse interfaces for backend tree structure |
| extensions/doctk-outliner/src/pythonBridge.ts | Added getDocumentTree() method to request tree from backend with centralized IDs |
| extensions/doctk-outliner/src/outlineProvider.ts | Added backend tree support with deserializeBackendTree() and updated constructor to accept PythonBridge |
| extensions/doctk-outliner/src/extension.ts | Updated initialization order to pass PythonBridge to DocumentOutlineProvider |
| .kiro/specs/vscode-outliner-extension/tasks.md | Marked tasks 9.1 and 9.2 as completed with implementation notes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| new vscode.Position(bNode.line, bNode.column), | ||
| new vscode.Position(bNode.line, endColumn) |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent line number usage. The code clamps the line number on line 175 to prevent out-of-bounds access, but then uses the unclamped bNode.line value when creating the Range. This defeats the purpose of the clamping and could cause exceptions if the backend returns an out-of-bounds line number.
Both instances of bNode.line on lines 180-181 should be replaced with the clamped line variable:
const range = new vscode.Range(
new vscode.Position(line, bNode.column),
new vscode.Position(line, endColumn)
);| new vscode.Position(bNode.line, bNode.column), | |
| new vscode.Position(bNode.line, endColumn) | |
| new vscode.Position(line, bNode.column), | |
| new vscode.Position(line, endColumn) |
| const endColumn = lineText.length; | ||
|
|
||
| const range = new vscode.Range( | ||
| new vscode.Position(bNode.line, bNode.column), | ||
| new vscode.Position(bNode.line, endColumn) |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing column validation. The code validates and clamps the line number, but doesn't validate the column value. If the backend returns a column that exceeds the line length, it could cause issues with VS Code Position creation.
Consider adding column validation after line 177:
const line = Math.min(bNode.line, document.lineCount - 1);
const lineText = document.lineAt(line).text;
const column = Math.min(bNode.column, lineText.length);
const endColumn = lineText.length;Then use column instead of bNode.column when creating the Position.
| const endColumn = lineText.length; | |
| const range = new vscode.Range( | |
| new vscode.Position(bNode.line, bNode.column), | |
| new vscode.Position(bNode.line, endColumn) | |
| const column = Math.min(bNode.column, lineText.length); | |
| const endColumn = lineText.length; | |
| const range = new vscode.Range( | |
| new vscode.Position(line, column), | |
| new vscode.Position(line, endColumn) |
Address two validation issues identified by Copilot in PR #10: 1. Inconsistent line number usage (Lines 183-184) - Previously: Clamped line number to 'line' variable but used unclamped 'bNode.line' when creating Range - Fixed: Now use clamped 'line' variable consistently in both Position constructors - Impact: Prevents potential exceptions from out-of-bounds line numbers returned by backend 2. Missing column validation (Lines 179-184) - Previously: Validated and clamped line numbers but not columns - Fixed: Added column clamping to prevent out-of-bounds access (column = Math.min(bNode.column, lineText.length)) - Impact: Prevents exceptions if backend returns column value exceeding line length Both changes ensure robust handling of potentially invalid backend data and prevent VS Code Position exceptions. Testing: - All 168 Python tests pass (2 skipped) - Ruff linting and formatting checks pass - Changes are defensive improvements with no functional impact on correct backend data Addresses: #10 (review)
Implement Task 9 from vscode-outliner-extension spec to centralize node ID generation in the backend, ensuring consistency across all operations and eliminating duplicate ID generation logic.
Changes:
Task completion:
Tests:
This addresses PR #6 Issue #5 (Medium priority) and ensures node IDs are generated consistently by the backend, preventing ID mismatches between tree view and operations.