Conversation
📝 WalkthroughWalkthroughThe PR extends the DSL arrow syntax to support reverse ( Changes
Sequence DiagramsequenceDiagram
participant User as DSL Input
participant Lexer
participant Parser
participant TypeSys as Type System
participant Factory as Connection Factory
participant Excal as Excalidraw Output
User->>Lexer: [A] <-- [B]
Lexer->>Lexer: Recognize `<--` token<br/>(dashed, reversed)
Lexer->>Parser: Emit token with dashed=true
Parser->>Parser: Set pendingReversed=true<br/>pendingEdgeStyle.startArrowhead='arrow'
Parser->>TypeSys: Create GraphEdge<br/>(reversed=true)
TypeSys->>Factory: Pass edge with reversed flag
Factory->>Factory: Check endArrowhead key<br/>Set defaults via hasOwnProperty
Factory->>Excal: Emit arrow element<br/>(startArrowhead, strokeStyle: dashed)
Excal->>User: Render reverse dashed arrow
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR extends the flowchart DSL to support dashed reverse (<--) and dashed bidirectional (<-->) connections (alongside new solid <- / <-> variants), ensuring the generated Excalidraw arrows preserve the intended arrowhead semantics while applying dashed stroke styling.
Changes:
- Add tokenization/parsing for
<-,<->,<--, and<-->, including edge style arrowhead fields and areversedflag. - Update arrow creation/mapping so
endArrowhead: nullis preserved (instead of being defaulted back to'arrow'). - Add unit tests + README syntax examples for the new arrow variants.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/parser/dsl-parser.test.ts | Adds parsing and generation assertions for dashed reverse/bidirectional arrows and solid semantics. |
| src/types/dsl.ts | Extends GraphEdge with optional reversed metadata. |
| src/parser/dsl-parser.ts | Tokenizes and parses new arrow operators, deriving arrowhead styles and dashed stroke styles. |
| src/factory/connection-factory.ts | Adjusts arrowhead defaulting logic to allow explicit null arrowheads. |
| README.md | Documents the new arrow syntaxes and adds examples. |
| package-lock.json | Updates lockfile version metadata to 1.3.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (style.strokeStyle !== undefined) result.strokeStyle = style.strokeStyle; | ||
| if (style.roughness !== undefined) result.roughness = style.roughness; | ||
| result.startArrowhead = style.startArrowhead ?? null; | ||
| result.endArrowhead = style.endArrowhead ?? 'arrow'; | ||
| result.endArrowhead = Object.prototype.hasOwnProperty.call(style, 'endArrowhead') | ||
| ? style.endArrowhead | ||
| : 'arrow'; | ||
| return result; |
| startArrowhead: Object.prototype.hasOwnProperty.call(styleProps, 'startArrowhead') | ||
| ? styleProps.startArrowhead! | ||
| : null, | ||
| endArrowhead: Object.prototype.hasOwnProperty.call(styleProps, 'endArrowhead') | ||
| ? styleProps.endArrowhead! | ||
| : 'arrow', |
| startArrowhead: Object.prototype.hasOwnProperty.call(styleProps, 'startArrowhead') | ||
| ? styleProps.startArrowhead! | ||
| : null, | ||
| endArrowhead: Object.prototype.hasOwnProperty.call(styleProps, 'endArrowhead') | ||
| ? styleProps.endArrowhead! | ||
| : 'arrow', |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/factory/connection-factory.ts (1)
27-31: Consider consistent property-presence checks for both arrowheads.
startArrowheaduses nullish coalescing (??) whileendArrowheaduseshasOwnProperty. This asymmetry works correctly (sincenullis a validArrowheadTypeand??handles it properly), but using consistent patterns would improve readability.♻️ Optional: Use consistent pattern
- result.startArrowhead = style.startArrowhead ?? null; - result.endArrowhead = Object.prototype.hasOwnProperty.call(style, 'endArrowhead') - ? style.endArrowhead - : 'arrow'; + result.startArrowhead = Object.prototype.hasOwnProperty.call(style, 'startArrowhead') + ? style.startArrowhead + : null; + result.endArrowhead = Object.prototype.hasOwnProperty.call(style, 'endArrowhead') + ? style.endArrowhead + : 'arrow';🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/factory/connection-factory.ts` around lines 27 - 31, Make the property-presence checks consistent by changing the startArrowhead assignment to use the same owns-property pattern as endArrowhead: replace the nullish-coalescing assignment for result.startArrowhead with an Object.prototype.hasOwnProperty.call(style, 'startArrowhead') conditional that uses style.startArrowhead when present and falls back to null when absent, keeping the existing endArrowhead logic unchanged; reference the variables style, result, startArrowhead, and endArrowhead to locate and update the two assignments.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/factory/connection-factory.ts`:
- Around line 27-31: Make the property-presence checks consistent by changing
the startArrowhead assignment to use the same owns-property pattern as
endArrowhead: replace the nullish-coalescing assignment for
result.startArrowhead with an Object.prototype.hasOwnProperty.call(style,
'startArrowhead') conditional that uses style.startArrowhead when present and
falls back to null when absent, keeping the existing endArrowhead logic
unchanged; reference the variables style, result, startArrowhead, and
endArrowhead to locate and update the two assignments.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0483028b-cd80-4702-8103-fba417d0a9b0
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (5)
README.mdsrc/factory/connection-factory.tssrc/parser/dsl-parser.tssrc/types/dsl.tstests/unit/parser/dsl-parser.test.ts
Summary
<--and<-->alongside solid<-and<->Testing
Summary by CodeRabbit
New Features
<-,<--), bidirectional arrows (<->,<-->), and dashed variants to enable more directional connection options between nodes.Documentation