feat: auto-collapse old roadmap comments when posting new ones#9
Conversation
Implements GitHub issue #5. When using --post, previous roadmap comments are automatically minimized (collapsed) using GitHub's GraphQL API before posting the new roadmap. This keeps PR conversations clean. Changes: - Add minimize_old_roadmap_comments() to GitHubClient - Call minimize before posting in main.py - Extract ROADMAP_HEADER_PREFIX constant for comment identification - Add 6 tests for the new functionality Behavior: - All comments starting with the roadmap header are collapsed - Comments from any user are collapsed (not just bots) - Minimize failures are non-blocking (warnings shown, posting continues) - Uses OUTDATED classifier for collapsed comments
This comment has been minimized.
This comment has been minimized.
|
🗺️ Auto-Generated Review Roadmap
🗺️ Review Roadmap: Auto-Collapse Old Roadmap CommentsHigh-Level SummaryThis PR implements automatic cleanup of stale roadmap comments. When you post a new review roadmap using The implementation adds a new GraphQL-based method to the GitHub client, wires it into the main posting workflow, and includes comprehensive test coverage. Recommended Review OrderReview in dependency order — understand the core API addition first, then the integration, then validate tests. 1️⃣ GitHub Client — Core Feature (
|
| Focus Area | What to Verify |
|---|---|
| GraphQL mutation structure | Check the mutation string and variable binding |
| Node ID usage | Critical: Ensure it uses node_id from comments, not numeric id |
| Error handling | Verify individual failures don't abort the entire operation |
| Return semantics | Confirm (minimized_count, error_count) tuple is correctly populated |
2️⃣ Main Orchestration — Integration (main.py)
File: review_roadmap/main.py
| Focus Area | Where to Look |
|---|---|
| Constant definition | ROADMAP_HEADER_PREFIX at line 14 — verify it matches what's used in format_pr_comment() |
| Updated comment formatting | Lines 24-36 — confirm the constant is used consistently |
| Minimize call placement | Should happen before posting, with non-blocking error handling |
| User feedback | Check the "Collapsed N previous roadmap(s)" output logic |
3️⃣ Test Suite — Validation (test_github_client.py)
File: tests/test_github_client.py
The PR adds 6 new tests. Skim for coverage of:
| Scenario | What to Check |
|---|---|
| Happy path | Multiple roadmaps found and minimized, returns (N, 0) |
| No matches | Non-roadmap comments present, returns (0, 0) |
| Empty state | No comments at all, returns (0, 0) |
| Partial failure | Some mutations fail, error_count increments correctly |
| GraphQL mocking | Mocked responses should match GitHub's actual GraphQL schema |
⚠️ Watch Outs
1. Node ID vs Numeric ID
The GraphQL minimizeComment mutation requires a global node ID (e.g., MDEyOklzc3VlQ29tbWVudDEyMzQ=), not the REST API's numeric ID. Verify the code extracts node_id from the comment response.
2. Prefix Matching Edge Cases
The filtering uses body.startswith(header_prefix). Consider:
- Comments with leading whitespace or newlines
- Unicode normalization issues with the 🗺️ emoji
- Case sensitivity (though emojis don't have case)
3. GraphQL Authentication
The client is configured for REST API. Verify the same auth headers work for the GraphQL endpoint (https://api.github.com/graphql) or if additional setup is needed.
4. Permission Model
The description says "Comments from any user are collapsed" — verify:
- Does the token need special permissions to minimize others' comments?
- Is there test coverage for permission denied scenarios?
5. Constant Duplication Risk
ROADMAP_HEADER_PREFIX is defined in main.py but passed to client.py. If client.py ever needs this constant independently, there's drift risk. Acceptable for now, but worth noting.
Existing Discussions Summary
The existing comment on this PR is itself a roadmap output (meta!). It calls out the same concerns I've noted:
- Node ID vs numeric ID verification
- Prefix matching robustness
- Non-blocking failure handling
- Missing permission error test coverage
This suggests these areas deserve extra scrutiny during your review.
Quick Review Checklist
-
node_idis used for GraphQL mutations (not numericid) -
ROADMAP_HEADER_PREFIXconstant is used consistently in both files - Minimize failures log warnings but don't prevent posting
- Test mocks accurately represent GitHub's GraphQL response structure
- No hardcoded header strings outside the constant
Summary
Implements Issue #5 - automatically collapse previous roadmap comments when posting a new one, similar to how Amber auto-review handles this.
Changes
review_roadmap/github/client.pyminimize_old_roadmap_comments()method that:minimizeCommentmutation withOUTDATEDclassifier(minimized_count, error_count)tuplereview_roadmap/main.pyROADMAP_HEADER_PREFIXconstant to identify roadmap commentsformat_pr_comment()to use the constanttests/test_github_client.pyBehavior
When using
--post:🗺️ **Auto-Generated Review Roadmap**are collapsedCollapsed N previous roadmap(s)Testing
All 76 tests pass with 85% coverage.
Closes #5