Repository navigation
Conversation
…iagram direction The adaptive diagram direction parser kept only the leading [A-Za-z0-9_]+ of each node id, so kebab-case ids such as api-gateway and api-auth collapsed to the same node. That produced self-loops (a swallowed CycleError) or merged nodes, and the direction was never adapted.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
⚙️ Agent run details
|
PR Code Suggestions ✨No code suggestions found for the PR. ⚙️ Agent run details
|
This branch has not been deployed
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.
User description
Summary
With
pr_description.pr_diagram_direction = "adaptive"(the default),apply_diagram_directionparses the flowchart's edges and switchesLRtoTDwhen the longest chain is longer thanpr_diagram_direction_thresholdnodes. The edge parser reads each node id withDIAGRAM_NODE_ID_PATTERN = r'[A-Za-z0-9_]+', which keeps only the part before the first hyphen. Kebab-case ids therefore collapse into one node:api-gateway --> api-authis read asapi --> api, a self-loop._longest_diagram_chainraisesCycleError, which is caught and logged at debug level, so the diagram is returned untouched.api-auth,api-users) merge, so chains are miscounted.The net effect is that a diagram written with hyphenated ids never gets the adaptive direction: a 6-node kebab-case chain stays
LRwith the default threshold of 5. The same module already treats hyphens as part of a node id when it quotes labels (DIAGRAM_SQUARE_NODE_PATTERNuses[A-Za-z0-9_][A-Za-z0-9_-]*), and the prompt does not forbid them.Repro (on
main@ db4c4ad, Python 3.12)Fix
Connectors (
--,-->,-.->,==>,---, ...) are split out byDIAGRAM_CONNECTOR_PATTERNbefore this pattern runs, and it needs two or more connector characters, so only single inner hyphens reach the node-id pattern. The new pattern has no overlapping quantifiers, so it stays linear (checked on 100k-character inputs: under 3 ms).Behaviour diff (old pattern vs new, over
_parse_diagram_edges)Unchanged: every existing
TestDiagramEdgeParsinginput, plusA-->B,A <--> B,A~~~B,A--oB,A-.-B,A["x"]-->B["y"]-->C["z"],A-- text-with-hyphen -->B,x- --> y,-x --> y,subgraph s-1,click A-1 call x().Changed (only ids with an inner hyphen):
api-gateway --> api-auth[('api', 'api')][('api-gateway', 'api-auth')]a-b-->c[('a', 'c')][('a-b', 'c')]A & B-1 --> C-2[('A', 'C'), ('B', 'C')][('A', 'C-2'), ('B-1', 'C-2')]node-1:::cls --> node-2[('node', 'node')][('node-1', 'node-2')]Tests
TestDiagramEdgeParsing::test_hyphenated_node_ids_are_kept_wholeandTestApplyDiagramDirection::test_long_chain_of_hyphenated_ids_becomes_vertical: both fail onmainand pass with the change.tests/unittest/test_pr_description.py: 149 passed.PYTHONPATH=. pytest -q tests/unittest-> 18719 passed, 66 skipped, 0 failed (baseline onmain@ db4c4ad: 18717 passed, 66 skipped; the 2 extra are the new tests).tests/packaging/test_help_docs_package.py: 4 passed;uv lock --check: clean. Not run locally: Python 3.13/3.14, the Docker build, andscripts/review_context.uv run ruff checkanduvx pre-commit run --fileson both changed files: clean.AI disclosure: this change was prepared by an AI coding agent (Claude Code) and submitted with the authorization of the PR author.
🤖 Generated with Claude Code
PR Type
Bug fix, Tests
Description
Preserve hyphenated Mermaid node identifiers during parsing.
Restore adaptive direction for long hyphenated chains.
Add regression tests for parsing and adaptation.
Diagram Walkthrough
File Walkthrough
pr_description.py
Preserve hyphenated node IDs during diagram parsingpr_agent/commands/pr_description.py
DIAGRAM_NODE_ID_PATTERNto retain single internal hyphens innode identifiers.
or self-loops.
test_pr_description.py
Cover hyphenated identifiers and adaptive diagram directiontests/unittest/test_pr_description.py
including labeled nodes and edges.
LRtoTDunderadaptive direction.
⚙️ Agent run details