feat: Implement DiffContextManager for precise diff analysis#194
Merged
feat: Implement DiffContextManager for precise diff analysis#194
Conversation
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.
Pull Request
📝 Summary
This PR introduces
DiffContextManager, a new centralized class for parsing and queryinggit diffoutput. This manager provides a structured, line-number-aware representation of changes, which is used to improve the accuracy of AI analysis and comment placement. Additionally, this work includes centralizing the application's logging system and enhancing the developer experience by automatically enabling debug logs for thetitan-devexecutable.🔧 Changes Made
DiffContextManagerImplementation: Introduced a new class to parse the unified diff format. It indexes files, hunks, and line mappings between the old and new file versions.DiffContextManageras the single source of truth for diff information, simplifying comment rendering logic and other dependent components.Makefileto setTITAN_ENV=developmentfor thetitan-devscript, which automatically enables more verbose logging during development.🧪 Testing
poetry run pytest)make test)titan-devAn extensive new test suite (
test_diff_context_manager.py) was added to validate theDiffContextManager. It covers various scenarios including simple diffs, multi-hunk files, multi-file diffs, handling of deleted lines, and the logic for finding specific lines by code snippets.📊 Logs
diff_parse_start(DEBUG) — Fired when theDiffContextManagerbegins parsing a raw diff string.diff_parse_complete(DEBUG) — Fired when parsing is complete, includesfile_count,hunk_count, andduration.find_line_by_snippet_miss(DEBUG) — Fired when a code snippet cannot be located in the diff for a given file, includesfile_path.✅ Checklist