Import PPTX arrow callouts, brackets, and homePlate alias#253
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (20)
📝 WalkthroughWalkthroughThis PR extends the slides shape library from 117 to 128 ChangesArrow Callouts and Bracket/Brace Shape Support
Sequence DiagramsequenceDiagram
participant PPTX as PPTX Importer
participant Alias as PRST_ALIASES
participant PathBuilder as Path Builder Registry
participant Canvas as Canvas Renderer
participant Shapes as Shape Geometry
PPTX->>Alias: prstToShapeKind("homePlate")
Alias->>PathBuilder: lookup aliased "pentagonArrow"
alt Alias found and registered
PathBuilder-->>PPTX: return ShapeKind
else Fallback
PPTX->>PathBuilder: lookup direct "homePlate"
PathBuilder-->>PPTX: cast/check result
end
PPTX->>Canvas: render shape with ShapeKind
Canvas->>Shapes: buildArrowCallout/buildBracket(size, adjustments)
Shapes->>Shapes: compute geometry (shaft/head/depth/body or radius/notch)
Shapes-->>Canvas: return Path2D
alt Open-path kind (bracket/brace)
Canvas->>Canvas: skip ctx.fill(), apply ctx.stroke()
else Closed-path kind (callout)
Canvas->>Canvas: apply ctx.fill() + ctx.stroke()
end
Canvas-->>PPTX: rendered shape on canvas
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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.
Actionable comments posted: 6
🧹 Nitpick comments (1)
packages/slides/test/view/canvas/shapes/basic/brackets.test.ts (1)
30-35: ⚡ Quick winConsider adding explanatory comment for consistency.
The
leftBrackettest (lines 19-22) includes helpful geometric reasoning explaining why specific coordinates were chosen. Adding a similar comment here would improve consistency and maintainability. As per coding guidelines, comments should explain the 'why' behind complex logic—the choice of coordinates (39, 1) and (39, 199) involves geometric reasoning that would benefit from documentation similar to the leftBracket test.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/slides/test/view/canvas/shapes/basic/brackets.test.ts` around lines 30 - 35, The rightBracket test lacks the explanatory geometric comment present in leftBracket; add a brief comment in the it('rightBracket...') block explaining why points (39,1) and (39,199) were chosen — i.e., they sit just inside the bracket's carved top-right and bottom-right corners given buildRightBracket({ w: 40, h: 200 }, [50000]) — so future readers understand the geometric reasoning used to assert ctx.isPointInPath results for the buildRightBracket path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/design/slides/slides-shapes.md`:
- Line 398: Add the missing OOXML alias mapping by inserting the alias entry
"homePlate -> pentagonArrow" into the OOXML alias table in slides-shapes.md so
the canonical alias list matches the roadmap; ensure the new row uses the same
table format and ordering/style as the other alias rows in the OOXML alignment
section.
In `@docs/tasks/active/20260517-pptx-unsupported-shapes-todo.md`:
- Around line 75-78: Update the bracket/brace note under the "Brackets render
via a single PathBuilder" paragraph to reflect current rendering: instead of
saying filled open paths "auto-close acceptably," state that for open-path kinds
the renderer skips applying fill (only stroke is used). Keep the existing
mention of using a single open path and the adj: corner radius note (percent of
min(w,h)/2, default 8333), but replace the sentence about auto-closing with an
explicit statement that fills are omitted for open-path bracket/brace shapes.
- Around line 5-6: Remove the embedded absolute local path that contains the
username from the task note (the /Users/... path shown in the diff) and replace
it with a sanitized sample or placeholder (e.g. <path/to/file>.pptx or
Downloads/YourFile.pptx) so the note is non‑identifying and portable; update the
sentence mentioning slide 7 to reference the sanitized filename/placeholder
instead of the original absolute path and keep the descriptive text about the
empty rotated centre shape unchanged.
In `@packages/slides/src/view/canvas/shapes/basic/left-bracket.ts`:
- Around line 48-55: The bracket handle currently ignores the shape's stored
radius and mis-maps pointer drags: update position to call
bracketCornerRadius(size, /*current radius value from shape data*/ ) instead of
passing undefined so the handle location reflects the actual radius; in apply,
compute the pointer-to-radius mapping using the same geometry as
bracketCornerRadius (use min(w,h) and half of that for the vertical scale)
rather than h/2, keep the DEF_BRACKET_RADIUS fallback when height is
non-positive, and clamp the resulting raw value into [0,50000] as before (refer
to position, bracketCornerRadius, insetAlongAxis, apply, and DEF_BRACKET_RADIUS
to locate the changes).
In `@packages/slides/src/view/canvas/shapes/basic/right-bracket.ts`:
- Around line 21-28: The bracket handle mapping uses the frame height only,
desynchronizing radius when the frame is non-square; update the position and
apply logic in the right-bracket shape so the handle is computed relative to the
geometry's min(width,height) basis: in position (function position) compute the
corner inset using bracketCornerRadius(size, undefined) and call insetAlongAxis
with that radius against the min of size.w and size.h (instead of size.h), and
in apply ({ h }, _start, pointer) replace h/2 bounds with (Math.min(w, h) / 2)
(use the geometry width/height min) when clamping pointer.y and when deriving
raw (fall back to DEF_BRACKET_RADIUS as before); reference bracketCornerRadius,
insetAlongAxis, position and apply to locate the changes.
In `@packages/slides/src/view/canvas/shapes/callouts/right-arrow-callout.ts`:
- Around line 67-86: The handle compute in apply can produce adj4 values that
place the handle past the body/head seam for deep heads; reproduce the same
dx1/seam calculation used in buildRightArrowCallout and clamp pointer.x against
w - dx1 before converting to the 0..100000 adj4 value: derive dx1 from the
current head/depth parameters (start[1], start[2]) using the same formula/build
helper as buildRightArrowCallout, compute maxX = Math.max(0, w - dx1), clamp x =
Math.max(0, Math.min(maxX, pointer.x)), then compute newA4 = maxX > 0 ?
Math.round((x / w) * 100000) (or divide by maxX if buildRightArrowCallout maps
over that range) and finally bound newA4 to 0..100000 as before so the handle
cannot enter the dead range.
---
Nitpick comments:
In `@packages/slides/test/view/canvas/shapes/basic/brackets.test.ts`:
- Around line 30-35: The rightBracket test lacks the explanatory geometric
comment present in leftBracket; add a brief comment in the it('rightBracket...')
block explaining why points (39,1) and (39,199) were chosen — i.e., they sit
just inside the bracket's carved top-right and bottom-right corners given
buildRightBracket({ w: 40, h: 200 }, [50000]) — so future readers understand the
geometric reasoning used to assert ctx.isPointInPath results for the
buildRightBracket path.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 46e81fc3-559d-49d6-9347-4d26d6e3541b
⛔ Files ignored due to path filters (1)
packages/slides/test/view/canvas/shapes/__snapshots__/registry.snap.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (20)
docs/design/slides/slides-shapes.mddocs/tasks/active/20260517-pptx-unsupported-shapes-todo.mdpackages/slides/src/import/pptx/geometry.tspackages/slides/src/model/element.tspackages/slides/src/view/canvas/shape-renderer.tspackages/slides/src/view/canvas/shapes/basic/left-brace.tspackages/slides/src/view/canvas/shapes/basic/left-bracket.tspackages/slides/src/view/canvas/shapes/basic/right-brace.tspackages/slides/src/view/canvas/shapes/basic/right-bracket.tspackages/slides/src/view/canvas/shapes/callouts/down-arrow-callout.tspackages/slides/src/view/canvas/shapes/callouts/left-arrow-callout.tspackages/slides/src/view/canvas/shapes/callouts/left-right-arrow-callout.tspackages/slides/src/view/canvas/shapes/callouts/quad-arrow-callout.tspackages/slides/src/view/canvas/shapes/callouts/right-arrow-callout.tspackages/slides/src/view/canvas/shapes/callouts/up-arrow-callout.tspackages/slides/src/view/canvas/shapes/callouts/up-down-arrow-callout.tspackages/slides/src/view/canvas/shapes/index.tspackages/slides/test/import/pptx/geometry.test.tspackages/slides/test/view/canvas/shapes/basic/brackets.test.tspackages/slides/test/view/canvas/shapes/callouts/right-arrow-callout.test.ts
Verification: verify:selfResult: ✅ PASS in 212.6s
Verification: verify:integrationResult: ✅ PASS |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Slide 7 of the Yorkie 캐즘 deck rendered the centre shape as a rotated empty rectangle: PPTX preset `rightArrowCallout` was missing from `ShapeKind`, so `prstToShapeKind()` returned undefined and the importer silently fell back to `rect` (shape.ts:389). The same deck has two more presets with the identical symptom: `leftBracket` (slide 28) and `homePlate` (slide 31, a synonym for the existing `pentagonArrow`). Adding only the three presets we tripped on would leave their OOXML siblings as the next landmine, so this commit lights up the natural families: - 7 arrow callouts (right/left/up/down + leftRight/upDown/quad) - 4 brackets/braces (left/rightBracket, left/rightBrace) as open paths — OOXML separates fill and stroke paths; we collapse to a single open polyline that strokes correctly and auto-closes acceptably when filled (`<a:noFill>` is the common case in real decks) - `homePlate` → `pentagonArrow` import alias ShapeKind count moves 117 → 128; design doc roadmap and registry snapshot updated to match. The negative assertions in geometry.test.ts that pinned the three missing prsts flip to positive, plus a new alias assertion. Path-builder unit tests cover the seven arrow callouts and four brackets at nominal and degenerate frame sizes. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bb82c32 to
9321760
Compare
Summary
ShapeKindvalues (7 arrow callouts + 4 brackets/braces) and ahomePlate → pentagonArrowimport alias, fixing a silent import bug where slide 7 of a real Yorkie deck rendered the centre shape as an empty rotated rectangle.prstToShapeKind()returnedundefinedfor unsupported presets, and the importer fell back silently torect(shape.ts:389). The Yorkie 캐즘 deck has three such presets —rightArrowCallout(slide 7),leftBracket(slide 28),homePlate(slide 31).fillfor them (OPEN_PATH_KINDSinshape-renderer.ts) so the auto-close behavior doesn't produce misleading filled C-rects. Stroke (the dominant real-world usage) traces just the visible outline.Test plan
pnpm verify:fastgreen (slides 981, docs 787, others pass)geometry.test.tsnegative assertions to positive resolutions + newhomePlatealias testShapeKindspnpm devafter merge (UI affordances for handles)🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes