[v2] Connection endpoints: colliding derived ids and no public endpoint/port-owner API
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- backend-api-design, databases
Hướng nghiên cứu
Start with packages/graph/src/store/connection/ConnectionState.ts and ConnectionList.getOrCreateConnection to trace derived IDs and connection reuse. Then inspect the port and connection store APIs and their tests. Done means adding documented, tested endpoint and port-owner APIs and deterministic IDs that distinguish anchor connections across blocks and keep port-only IDs stable; the acceptance criteria also call for follow-up package limitations to be lifted.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
TConnection has two addressing modes:
- Block-based:
sourceBlockId/targetBlockId, optionallysourceAnchorId/targetAnchorId. Core resolves these to ports:"<blockId>_output"/"<blockId>_input"for block points,"<blockId>/<anchorId>"for anchors. - Port-based:
sourcePortId/targetPortId.
Core has two gaps around these modes. Because of them, the extracted packages (#396) cannot treat both modes the same way.
1. Derived connection ids collide
ConnectionState.getConnectionId (packages/graph/src/store/connection/ConnectionState.ts, getConnectionId) builds the id of a connection that has no explicit id:
if (hasId(connection.sourceAnchorId) && hasId(connection.targetAnchorId)) {
return [connection.sourceAnchorId, connection.targetAnchorId].join(":"); // no block ids
}
return [connection.sourceBlockId, connection.targetBlockId].join(":");
ConnectionList.getOrCreateConnection then reuses whatever state already has that id and calls updateConnection on it.
- Anchor connections: two connections between different blocks that use the same anchor names get the same id (
"out:in"). The second one rewires the first instead of creating a new connection. This happens routinely after duplicating blocks (#408 had to give every copy an explicit id to avoid it). - Parallel block connections: they collapse into one (
"a:b"). - Port-only connections: they get a random id, so they cannot be addressed deterministically.
2. No public API to resolve endpoints
Given a ConnectionState or a PortState, there is no public, serializable way to get:
- the resolved source and target port ids together with the owning block id and anchor id, regardless of which mode the connection was declared in;
- the block that owns a port.
PortState.owner/componentis a view component, not store data, and it is absent until the view exists. - a connection by its endpoints (store lookup).
Impact
@gravity-ui/graph-layered,@gravity-ui/graph-elk: port-only connections are skipped and documented as unsupported, because there is no port → block resolution. Anchor endpoints are not taken into account in layout.@gravity-ui/graph-duplicate-block: port-based connections are copied only when the port id can be derived from block or anchor ids, and copies need explicit ids (see 1).@gravity-ui/graph-connection-editing: decides between block and port mode by comparing port ids withcreateBlockPointPortId/createAnchorPortId, and dedupes custom-port connections by scanning$connectionsMap.@gravity-ui/graph-playwright: cannot find connections by endpoints or reliably tell apart connections between the same blocks on different anchors. Related: #409.
Proposal (to be refined)
- Deterministic derived ids that include block ids for anchor connections, e.g.
"<sourceBlockId>/<sourceAnchorId>:<targetBlockId>/<targetAnchorId>", and that are stable for port-based connections, e.g. built from the port ids. This is a breaking change for consumers that rely on today's derived ids; it needs a migration note. ConnectionState.getEndpoints(): a serializable{ source: { portId, blockId?, anchorId? }, target: { … } }, available without the view.- Port owner as store data: a public port → owner block/anchor helper, e.g.
connectionsList.getPortOwner(portId)or owner info onPortState. connectionsList.findByEndpoints(...), accepting either mode.
Acceptance criteria
- Unit tests:
- two anchor connections with the same anchor names on different blocks stay distinct;
- parallel connections behave as documented;
- port-only connections get a stable id.
- The endpoint and owner APIs work for block, anchor and custom ports, are covered by tests for each mode separately, and are documented.
- Follow-ups listed for the packages above: lift the documented port-only limitations where the new API makes it possible.
- Ngôn ngữ chính
- TypeScript
- Star
- 145
- Fork
- 12
- Merge trung bình
- 1 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 43
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của gravity-ui/graph
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
gravity-ui/graph#457 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
gravity-ui/graph#455 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
gravity-ui/graph#456 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
gravity-ui/graph#431 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Graph root is not a containing block for absolutely positioned layersCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
gravity-ui/graph#414 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của gravity-ui/graph
Issue tương tự
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
openclaw/openclaw#199885 · 2 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
feature needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
BoardGamesEmpire/board-games-empire-backend#1306 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
sequant-io/sequant#1689 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100