From de6ef8e64b2ca6b3aa90e14a18ce5fce26f21d3d Mon Sep 17 00:00:00 2001 From: que01 Date: Mon, 7 Sep 2026 15:23:03 +0800 Subject: [PATCH] feat(junction): add stage2 object selection scope controls --- .../check.jsonl | 2 + .../design.md | 7 +++ .../implement.jsonl | 4 ++ .../implement.md | 6 +++ .../prd.md | 44 +++++++++++++++++++ .../task.json | 26 +++++++++++ workbench/client/src/App.tsx | 14 ++++++ .../client/src/junction/JunctionWorkspace.tsx | 33 +++++++++++--- 8 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 .trellis/tasks/09-07-junctiontools-stage2-selection-overrides/check.jsonl create mode 100644 .trellis/tasks/09-07-junctiontools-stage2-selection-overrides/design.md create mode 100644 .trellis/tasks/09-07-junctiontools-stage2-selection-overrides/implement.jsonl create mode 100644 .trellis/tasks/09-07-junctiontools-stage2-selection-overrides/implement.md create mode 100644 .trellis/tasks/09-07-junctiontools-stage2-selection-overrides/prd.md create mode 100644 .trellis/tasks/09-07-junctiontools-stage2-selection-overrides/task.json diff --git a/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/check.jsonl b/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/check.jsonl new file mode 100644 index 0000000..1a7d9e5 --- /dev/null +++ b/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/check.jsonl @@ -0,0 +1,2 @@ +{"file":".trellis/spec/frontend/direct-edit-client.md","reason":"Verify shared edit protocol and reset semantics."} +{"file":".trellis/spec/frontend/quality-guidelines.md","reason":"Run client checks and preserve component boundaries."} diff --git a/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/design.md b/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/design.md new file mode 100644 index 0000000..083dedf --- /dev/null +++ b/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/design.md @@ -0,0 +1,7 @@ +# 技术设计 + +`JunctionWorkspace` 持有路口级选择键,`App` 仍是组合根,现有 `EditSession` 继续拥有约束、预览和撤销历史。新增的选择适配器只把设施/诊断/handle 映射到结构对象键,不复制几何或保存协议。 + +作用域覆盖使用现有 handle 的 `constraintId` 和 `affects` 集合:全局操作选择同类 handle 组,局部操作只发送当前对象 handle;恢复全局调用现有 `onReset`,由 EditSession 记录禁用约束。UI 显示继承来源,不另建一套 draft。 + +所有新状态都必须兼容旧 state 缺失结构字段;旧路口继续使用现有参数面板。 diff --git a/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/implement.jsonl b/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/implement.jsonl new file mode 100644 index 0000000..0fbbd4a --- /dev/null +++ b/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/implement.jsonl @@ -0,0 +1,4 @@ +{"file":".trellis/spec/frontend/direct-edit-client.md","reason":"Reuse EditSession, handle and preview ownership."} +{"file":".trellis/spec/frontend/state-management.md","reason":"Follow state ownership and selection update patterns."} +{"file":".trellis/spec/frontend/component-guidelines.md","reason":"Keep JunctionWorkspace composition and controls consistent."} +{"file":".trellis/spec/guides/cross-layer-thinking-guide.md","reason":"Avoid duplicating compiler-owned object identity."} diff --git a/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/implement.md b/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/implement.md new file mode 100644 index 0000000..2e3308f --- /dev/null +++ b/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/implement.md @@ -0,0 +1,6 @@ +# 实施清单 + +1. 建立对象选择键与结构对象到设施/handle/诊断的归一化工具。 +2. 将 `JunctionWorkspace` 的设施选择、诊断定位和参数高亮统一到 `selectedObjectKey`。 +3. 为当前对象参数增加全局继承、局部调整和恢复全局控件,复用现有 EditSession 回调。 +4. 增加选择与覆盖交互单测,运行完整前后端质量门禁。 diff --git a/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/prd.md b/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/prd.md new file mode 100644 index 0000000..3a28135 --- /dev/null +++ b/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/prd.md @@ -0,0 +1,44 @@ +# JunctionTools Stage 2 选择与作用域覆盖 + +## Goal + +TBD. + +## Requirements + +- TBD + +## Acceptance Criteria + +- [ ] TBD + +## Notes + +- Keep `prd.md` focused on requirements, constraints, and acceptance criteria. +- Lightweight tasks can remain PRD-only. +- For complex tasks, add `design.md` for technical design and `implement.md` for execution planning before `task.py start`. +# JunctionTools Stage 2:对象选择与作用域覆盖 + +## 目标 + +让路口对象在列表、地图设施、手柄和诊断之间共享唯一选择键,并让稳定的 direct-edit 参数明确显示全局继承或局部覆盖状态。 + +## 范围 + +- 增加 `selectedObjectKey` 状态,列表/设施/诊断定位统一写入它。 +- 对道路臂、角部、横道和停止线显示当前对象的参数归属。 +- 提供“使用全局值 / 单独调整 / 恢复全局值”交互;局部调整只作用于当前对象。 +- 保持现有预览、撤销/重做、重置对象、放弃草稿和版本冲突协议。 + +## 非范围 + +- 不实现新的几何算法或高级设施。 +- 不根据客户端节点数量推断路口形态。 +- 不把 warning/blocking 标准诊断变成新的保存门禁。 + +## 验收标准 + +1. 列表、地图设施和诊断定位使用同一个 `selectedObjectKey`,切换对象不会残留旧表单。 +2. 未单独调整的对象显示全局继承;局部修改只影响当前对象,并能恢复全局。 +3. 当前对象重置与放弃全部草稿行为保持现有语义,预览请求仍经过同一 EditSession。 +4. 单测覆盖选择归一化、作用域切换和恢复全局;客户端类型检查、单测、构建、格式检查及后端回归通过。 diff --git a/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/task.json b/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/task.json new file mode 100644 index 0000000..74a346e --- /dev/null +++ b/.trellis/tasks/09-07-junctiontools-stage2-selection-overrides/task.json @@ -0,0 +1,26 @@ +{ + "id": "junctiontools-stage2-selection-overrides", + "name": "junctiontools-stage2-selection-overrides", + "title": "JunctionTools Stage 2 选择与作用域覆盖", + "description": "", + "status": "in_progress", + "dev_type": null, + "scope": null, + "package": null, + "priority": "P2", + "creator": "dingkang", + "assignee": "dingkang", + "createdAt": "2026-09-07", + "completedAt": null, + "branch": null, + "base_branch": "main", + "worktree_path": null, + "commit": null, + "pr_url": null, + "subtasks": [], + "children": [], + "parent": null, + "relatedFiles": [], + "notes": "", + "meta": {} +} \ No newline at end of file diff --git a/workbench/client/src/App.tsx b/workbench/client/src/App.tsx index d00f6fb..ec17dd7 100644 --- a/workbench/client/src/App.tsx +++ b/workbench/client/src/App.tsx @@ -94,6 +94,7 @@ function App() { const [status, setStatus] = useState('正在加载工作台...'); const [filter, setFilter] = useState<'all' | 'candidates' | 'other'>('all'); const [marking, setMarking] = useState | null>(null); + const [selectedObjectKey, setSelectedObjectKey] = useState(null); const [junctionRoute, setJunctionRoute] = useState(() => { if (typeof window === 'undefined') return null; const match = window.location.pathname.match(/^\/junction\/(node|cluster)\/([^/]+)$/); @@ -900,6 +901,14 @@ function App() { }; const handleFeature = (properties: Record) => { setMarking(properties); + const objectKey = properties.signal_uid + ? `signal:${String(properties.signal_uid)}` + : properties.crossing_node_id + ? `${properties.provenance === 'stop-line' ? 'stop-line' : 'crossing'}:${String(properties.crossing_node_id)}` + : properties.road_id + ? `road-arm:${String(properties.road_id)}` + : null; + setSelectedObjectKey(objectKey); // A crosswalk is six features but one editable thing; a stop line is one. // `provenance` picks which, and therefore which layer holds its siblings — // the two share `crossing_node_id`, so keying on that alone would merge a @@ -1156,6 +1165,8 @@ function App() { dirty={Boolean(junctionSession.dirty || signalDirty)} state={state} diagnostics={junctionDiagnostics} + selectedObjectKey={selectedObjectKey} + onSelectObject={(key) => setSelectedObjectKey(key)} facilitySummary={junctionFacilitySummary} onClose={closeJunction} onEnableComplex={ @@ -1236,6 +1247,9 @@ function App() { onSignalStatus={setStatus} onUpdateSignal={updateSignal} onSelectFacility={(facility) => { + setSelectedObjectKey( + `${facility.kind === 'crosswalk' ? 'crossing' : facility.kind}:${facility.id.split(':').slice(1).join(':')}`, + ); const source = facility.kind === 'crosswalk' ? state.layers.crosswalks diff --git a/workbench/client/src/junction/JunctionWorkspace.tsx b/workbench/client/src/junction/JunctionWorkspace.tsx index 0651245..288854f 100644 --- a/workbench/client/src/junction/JunctionWorkspace.tsx +++ b/workbench/client/src/junction/JunctionWorkspace.tsx @@ -17,6 +17,8 @@ interface Props { session: JunctionSession; dirty?: boolean; diagnostics?: Array<{ id: string; message: string; rule: string; severity?: string }>; + selectedObjectKey?: string | null; + onSelectObject?: (key: string) => void; facilitySummary?: { crosswalks: number; stopLines: number; signals: number }; state?: WorkbenchState; onClose: () => void; @@ -59,6 +61,8 @@ export function JunctionWorkspace({ onUpdateComplexNodes, onCandidateMarkersChange, diagnostics = [], + selectedObjectKey = null, + onSelectObject, facilitySummary = { crosswalks: 0, stopLines: 0, signals: 0 }, state, handles = [], @@ -228,7 +232,24 @@ export function JunctionWorkspace({

道路臂
-
{structure.arms.map((arm) => arm.label).join('、') || '无'}
+
+ {structure.arms.length ? ( + + {structure.arms.map((arm) => ( + + ))} + + ) : ( + '无' + )} +
角部
{structure.corners.length ? structure.corners.map((corner) => corner.label).join('、') : '无'}
设施
@@ -242,10 +263,12 @@ export function JunctionWorkspace({
    {standardDiagnostics.map((item) => (
  • - - {item.severity === 'pass' ? '通过' : item.severity === 'warning' ? '警告' : '阻塞'} - {' '} - {item.message} +
  • ))}