Repository navigation
fix(web): keep the dragged region when commenting on an SVG - #648
Merged
Merged
Conversation
danyaberezun
requested review from
Olga Lavrichenko (OLavrik),
Rustam Sadykov (SBOne-Kenobi) and
Rinat S (rsolmano)
as code owners
October 5, 2026 22:05
Rinat S (rsolmano)
approved these changes
Oct 6, 2026
danyaberezun
enabled auto-merge
October 6, 2026 08:30
…nsform The locator instruction implied a linear map from region fractions onto the viewBox. The fractions are of the SVG's root viewport, so a viewBox whose aspect differs from width/height is letterboxed by the default preserveAspectRatio and the viewBox origin shifts the result; name the transform to invert instead.
danyaberezun
force-pushed
the
fix-image-region-comment-coords
branch
from
October 6, 2026 08:41
c4a52d1 to
a6ffe50
Compare
5 tasks done
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.
Problem
Dragging a region on an image and commenting on it sometimes reached the chat with the region's coordinates and sometimes as "the whole picture". It looked intermittent, but it was keyed on the file type: raster images (
thinkrail/image) always sent a normalizedregionselector, while SVGs (thinkrail/svg, the "Vector" renderer that outranks the raster one for.svg) deliberately replaced the dragged rectangle with a whole-file draft (svgFileDraft→selectors: [], labelfile). The drag rectangle and the "+" icon still appeared, so nothing suggested the geometry was about to be dropped; the comment left askind="file"/anchor-kind="file"with no locator, landed in "Comments not placed in Vector", and the agent was pointed at the whole file.Local review stores and sent packages confirmed it: the one PNG comment carried
region [0.523, 0.688, 0.138, 0.033]; both.svgcomments carried no selectors.Approach
Make SVG region authoring positional, the same way raster images already are. The SVG renderer already declares
anchors: { view: ["region"], diff: ["region"] }and already places region threads through the samecontainedMediaRectmath, and the host already narrows and keeps aregionselector on a text side (nolineRange, so no derived quote;outdatedon edit, like a PNG). So the fix is to stop overridingRegionReviewSurface's defaultregionDraftfor SVG — no server storage change, no new abstraction. The original spec rationale (SVG source spans aren't mapped) still holds: the anchor is geometry, not a line range; the send package now tells the agent to map the 0..1 fractions onto the SVG'sviewBox.Alternatives considered: keeping whole-file and removing the selection rectangle (honest, but gives up the coordinates the user wanted).
Changes
apps/web/src/panels/resources/svg/View.tsx,Diff.tsx: use the defaultregionDraft; diff label mirrors raster ("image region");svg-region-surfacetest id (mirrorsimage-region-surface).apps/web/src/panels/resources/svg/svgDocument.ts:svgFileDraftremoved (and its unit assertion).packages/server/src/reviews/packageRender.ts: the<instructions>locator bullet names a position "by geometry or document node rather than by lines" and adds the SVG →viewBoxmapping hint; pinned inpackageRender.test.tsand mirrored in the webreviewPackage.test.tsfixture that embeds the full package text.apps/web/src/panels/SPEC.md(thinkrail/svgauthors positional regions; the whole-file draft is recorded as a retired decision and why),packages/server/src/reviews/SPEC.md(locator wording).RENDERERS.svgfixture and areview.spec.tstest that drags 25%→75% on the SVG surface and asserts the persisted selector geometry.Screenshots
Same scenario and viewport (1280×1000): open
brand-mark.svg, drag over the button, comment, save.main)Before: the rectangle is drawn but the draft is labelled
file, and the saved comment lands in "Comments not placed in Vector". After: the draft is labelledregion, and the saved comment is a numbered marker on the picture with the Review panel listing it asregion.Related issues
None.
Checklist
bun run lint,bun run typecheck,bun run testbun run e2e, orbun run e2e:fullwhen touching agent behavior)SPEC.md/ top-level specs updated to reflect any boundary, contract, or behavior changeTesting
Run on the final tree (
a6ffe506, rebased onto1f8c01f5) after resolving thepanels/SPEC.mdconflict with #638 and applying the review fix:bun run lint→ clean (1349 files)bun run typecheck→ 20/21 turbo tasks green (turbo run typecheck --filter='!@thinkrail/desktop'). The@thinkrail/desktoptask could not complete locally becauseelectrobun preparehangs while a localelectrobun devis running (environmental, unrelated); CI's Lint & Typecheck job covers it.bun run test→ 21/21 turbo tasks greenbun run check:deps/check:boundaries/check:seams/check:spec-surface, plus the typography/colors/spacing/provider-glyph usage gates → OKbun run e2e→ all 8 shards passed (479 tests, 169s), including the new SVG region test