diff --git a/.scratch/cheng-feedback-20261021/spec.md b/.scratch/cheng-feedback-20261021/spec.md new file mode 100644 index 00000000..119c7113 --- /dev/null +++ b/.scratch/cheng-feedback-20261021/spec.md @@ -0,0 +1,12 @@ +# Repair initial slicing and rework feedback +Status: resolved + +Base: local rework boundary repair 4d12d8cb, based on deployed fab5be57. + +- Initial slice quick conflicts must be visible and confirmable/cancellable by the same keys and buttons as annotation conflicts. Preserve pending, described and invalid records; no customer migration. +- Successful C split, drag and delete must survive save/reload and support same-session undo/redo, respecting the existing one-second acceptance window and stage boundaries. +- Live complete editor drafts update feedback immediately, preserving classification fields. Derived slice status alone must not clear opinions. +- Discarded slices retain evidence and a right-side opinion rail without an action editor. Explicit whole-action invalidation shows its impact. +- Review remains read-only; E remains annotation-only. No production mutation or deployment in this task. + +Evidence: [verification](../../docs/verification/cheng-feedback-20261021.md). diff --git a/docs/adr/0006-rework-emphasis-replaces-feedback-editor.md b/docs/adr/0006-rework-emphasis-replaces-feedback-editor.md index a5e5139a..575e2371 100644 --- a/docs/adr/0006-rework-emphasis-replaces-feedback-editor.md +++ b/docs/adr/0006-rework-emphasis-replaces-feedback-editor.md @@ -22,6 +22,14 @@ - 复审新增“本轮改动”清单,覆盖全部切片与动作,包括原先没有退回意见的位置。它比较本轮冻结基线与当前实际送检修订,展示净改动及前后内容;不使用客户端操作日志、不把自动保存草稿混入正式结果,不修改冻结基线和正式审查记录。标注员侧显示当前工作区的同一比较结果。 - 缺少旧基线快照或匹配的送检修订时显示“无法确认全部改动”,不以空数组推断全部删除或没有改动。无需数据库迁移;旧结构计数摘要和旧格式退回兼容路径保留。 +## 2026-10-21:实时草稿与派生状态比较修正 + +标注员侧强调层合入区间完整的编辑器草稿,保留分类与左右手等业务字段;未完成终点选择不参与比较,自动保存载荷的字段清洗不用于展示比较。撤回到原文恢复未修改状态。 + +切片 `annotationStatus` 是派生完成状态,单独变化不代表已按意见修改;旧记录省略用途与显式 keep 等价。名称、分类、边界、用途、舍弃原因及片内动作仍参与比较。灰态继续只表示已修改待复审,不替代正式判定。 + +选择舍弃切片时仍显示只读舍弃证据与返工意见栏;不提供直接修改归档动作的编辑器。上述均为展示修正,不迁移冻结基线、正式审查记录或客户工作区。 + ## 背景 B02 上线的返工模式给标注员两个新面板:意见列表上方的"处理反馈"文字编辑器(每条意见写回应,8 秒空闲自动保存)与"上下对比"面板。客户实测后提出三点不满: diff --git a/docs/adr/0007-inplace-slice-editing-replaces-reslice.md b/docs/adr/0007-inplace-slice-editing-replaces-reslice.md index 42032e2f..f0283141 100644 --- a/docs/adr/0007-inplace-slice-editing-replaces-reslice.md +++ b/docs/adr/0007-inplace-slice-editing-replaces-reslice.md @@ -25,6 +25,12 @@ - Enter 和按钮均等待权威保存结果;保存中禁用重复应用、处置选择及取消,错误在清单内显示并保留选择。响应丢失时通过原应用编号回读确认。成功后清理已合入保存的编辑器草稿,避免用旧几何覆盖新工作区。 - 不批量修改已保存、送检或交付数据;现有权限、阶段锁、历史数据恢复接口保持有效。 +## 2026-10-21:初始切片快捷冲突兼容 + +初始切片阶段保存、恢复的工作区可能已有连续待标注动作。切分、拖边和删除遇到这些动作时,与逐片标注阶段一样显示冲突清单,Enter/按钮确认或 Esc 取消;不再因阶段不为 annotate 静默取消。E 重设面板仍限定逐片标注,质检、验收、只读及后台处理阶段不开放编辑。 + +不按描述为空删除动作,也不批量改写历史草稿。既有自动补齐、空白动作、分类、舍弃证据与版本校验保持原义。成功操作按原子应用记录撤销,失败保留选择及明确错误;原有会话、阶段边界和一秒防重复规则保留。 + ## 背景 返修中要改切片结构只能"重新切片":清空全部动作标注、整单退回切片阶段,代价高且不可审计(旧文案"请先返回重新切片"即两把阶段锁的报错)。同时旧 D2 规则在拖动边界穿过动作时自动拆两段标"待核对"——该状态不在服务端白名单(pending/described/invalid)内,不处置则保存被堵死。本决策来自 24 项已拍板裁决(Q1:a–Q8:a、R2-Q1–Q8、R3-1–R3-4)。 diff --git a/docs/verification/cheng-feedback-20261021.md b/docs/verification/cheng-feedback-20261021.md new file mode 100644 index 00000000..9cd58a7c --- /dev/null +++ b/docs/verification/cheng-feedback-20261021.md @@ -0,0 +1,19 @@ +# Platform feedback repairs — 2026-10-21 + +Local branch `codex/rework-boundary-20261021`, based on deployed `fab5be57` plus local boundary repair `4d12d8cb`. No push, PR, cluster deployment or customer data writes. + +## Cause and compatibility + +Initial slicing can recover saved pending actions. The quick edit planner correctly detects action conflicts, but Workbench previously rendered and accepted those conflicts only in annotation phase and silently canceled them in slice phase. Thus attempted edits never entered history. Preserve all existing action records and make the stage contract consistent; keep the server's archive, CAS and restoration paths. No schema, workflow, formal decision or delivery format changes. + +Feedback previously omitted complete editor drafts and compared derived slice annotationStatus. It now includes those drafts while preserving display classification/handedness, excludes incomplete end selections, ignores derived slice status and normalizes implicit keep. Discarded slices retain evidence and the opinion rail in the right sidebar. Selecting whole-action invalidation explicitly warns that both sides are affected. + +## Regression evidence + +- Red before repair: `TestSlicePhaseBrowserReplica` failed `pending actions must show a visible conflict` (0 vs 1); the derived-status unit regression failed uncleared count (1 vs 2). +- `REWORK_BOUNDARY_BROWSER_TEST=1 go test ./internal/api -run '^TestSlicePhaseBrowserReplica$' -count=1 -v`: real AnnotationOperations page, real HTTP handlers, isolated MemoryStore and synthetic H.264 media. Covers empty control, saved pending actions and a newer owner-matched autosave draft over an empty confirmed workspace, C/Enter/save/undo/redo/reload, pending drag/delete undo/redo, actual draft editing and reversal, false-gray prevention, discarded evidence/opinions and sidebar geometry. +- `REWORK_BOUNDARY_BROWSER_TEST=1 go test ./internal/api -run '^TestReworkBoundaryBrowserReplica$' -count=1 -v`: existing discard-boundary, Enter/button, failure/retry, lost-response reconciliation, busy/cancel and persisted undo/redo scenarios remain passing. +- 66 targeted frontend tests and targeted Go slice application, restoration, rework and draft tests pass; TypeScript and web build pass. Production bundle boot has no runtime errors. +- Full frontend gate: 13 existing failures, all in the unchanged known baseline; no new failures. Four source-shape assertions were updated for the new phase contract while retaining review permission assertions. Baseline entries were not edited. + +Browser is local Edge/Chromium, not a claim of testing the customer's exact Chrome installation. No production browser/client acceptance or historical result repair is claimed. Old mistaken invalidation results require individual evidence review; they are not guessed or overwritten. Source diagnosis evidence remains under untracked `local-data/diagnostics/chengxiaoming-feedback-20261021/` in the working root. diff --git a/internal/api/slice_phase_browser_test.go b/internal/api/slice_phase_browser_test.go new file mode 100644 index 00000000..a60b92f0 --- /dev/null +++ b/internal/api/slice_phase_browser_test.go @@ -0,0 +1,154 @@ +package api + +import ( + "context" + "droboticflow/internal/config" + "fmt" + "net/http" + "net/http/httptest" + "os" + "os/exec" + "path/filepath" + "strings" + "testing" + "time" + + "droboticflow/internal/domain" + "droboticflow/internal/store" +) + +// Actual page -> actual HTTP handler -> isolated memory store. Neither a +// production endpoint nor the local snapshot database is reachable here. +func TestSlicePhaseBrowserReplica(t *testing.T) { + if os.Getenv("REWORK_BOUNDARY_BROWSER_TEST") != "1" { + t.Skip("local browser opt-in") + } + f := continuousFixture(t) + reason := dispositionFixturePayload(t, f) + if err := f.store.UpsertOrganizationPlugin(f.ctx, domain.OrganizationPluginRecord{OrganizationID: domain.DefaultOrganizationID, PluginID: "annotation-qa", Enabled: true, Config: defaultAnnotationPluginConfig()}); err != nil { + t.Fatal(err) + } + reset := func(status, shape string) error { + before := []domain.SliceSegment{{ID: "first", Start: 0, End: 10}} + item := f.item + item.ReviewRound = 0 + actions := []domain.AnnotationSegment{{ID: "pending-first", Start: 0, End: 10, Status: "pending"}} + if status == "empty" { + actions = []domain.AnnotationSegment{} + } + item.Subject.Payload = map[string]any{"sliceWorkflow": map[string]any{"status": "editing", "phase": "slice"}, "annotationWorkspace": map[string]any{"userId": f.annotator.ID, "savedAt": nowISO(), "sliceSegments": before, "segments": actions, "statuses": map[string]string{"first": "pending"}}} + if status == "draft" { + item.Subject.Payload["annotationDraft"] = map[string]any{"userId": f.annotator.ID, "savedAt": time.Now().Add(time.Second).UTC().Format(time.RFC3339Nano), "savedVersion": item.Version, "sliceSegments": before, "segments": actions, "statuses": map[string]string{"first": "pending"}} + item.Subject.Payload["annotationWorkspace"].(map[string]any)["segments"] = []domain.AnnotationSegment{} + } + + if shape == "two" { + before = []domain.SliceSegment{{ID: "first", Name: "测试切片", Start: 0, End: 0.2}, {ID: "second", Start: 0.2, End: 10}} + actions = []domain.AnnotationSegment{{ID: "a", Start: 0, End: 0.2, Status: "pending"}, {ID: "b", Start: 0.2, End: 10, Status: "pending"}} + item.Subject.Payload["annotationWorkspace"].(map[string]any)["sliceSegments"] = before + item.Subject.Payload["annotationWorkspace"].(map[string]any)["segments"] = actions + } + if shape == "rework" { + before = []domain.SliceSegment{{ID: "first", Name: "测试切片", Start: 0, End: 5, AnnotationStatus: "pending"}, {ID: "discard", Start: 5, End: 10, DeliveryDisposition: "discard", DiscardReason: "相机被遮挡", DiscardReasonLabelID: reason.ReasonLabelID, DiscardReasonVersion: reason.ReasonVersion}} + actions = []domain.AnnotationSegment{{ID: "a", Start: 0, End: 5, Status: "described", Description: "原描述"}} + item.ReviewRound = 1 + item.Subject.Payload["sliceWorkflow"] = map[string]any{"status": "completed", "phase": "annotate"} + item.Subject.Payload["annotationWorkspace"].(map[string]any)["sliceSegments"] = before + item.Subject.Payload["annotationWorkspace"].(map[string]any)["segments"] = actions + frozen := append([]domain.SliceSegment(nil), before...) + frozen[0].AnnotationStatus = "labeled" + if err := f.store.UpsertReworkBaseline(f.ctx, domain.ReworkBaselineRecord{ID: store.ReworkBaselineID(item.ID, 1), OrganizationID: item.OrganizationID, ProjectID: item.ProjectID, ItemID: item.ID, Round: 1, StageID: domain.FanyuV58StageAnnotationCombined, Slices: frozen, Actions: actions, Problems: []domain.ReviewProblem{{ID: "p-slice", Scope: "slice", SliceID: "first", Text: "核对切片"}, {ID: "p-action", Scope: "action", SliceID: "first", ActionID: "a", Text: "核对描述"}}}); err != nil { + return err + } + } + + return f.store.UpsertHumanItem(f.ctx, item) + } + root := t.TempDir() + f.task.SourceVideo = "/api/runs/" + f.task.RunID + "/artifacts/left-video/content" + f.task.RightSourceVideo = "/api/runs/" + f.task.RunID + "/artifacts/right-video/content" + f.task.NodeID = "human" + f.task.ArtifactID = "left-video" + f.task.RightArtifactID = "right-video" + f.task.SourceIsFullVideo = true + f.task.SourceDurationSeconds = 10 + f.task.CoverageEndSecond = 10 + pts := "timestamp_us\n" + for i := 0; i < 100; i++ { + pts += fmt.Sprintf("%d\n", 1000000+i*100000) + } + bindings := []domain.NodeInputBinding{} + for _, side := range []string{"left", "right"} { + video := filepath.Join(root, side+".mp4") + if out, err := exec.Command("ffmpeg", "-v", "error", "-y", "-f", "lavfi", "-i", "color=c=navy:s=160x90:r=10:d=10", "-c:v", "libx264", "-pix_fmt", "yuv420p", video).CombinedOutput(); err != nil { + t.Fatalf("video: %v: %s", err, out) + } + timestamps := filepath.Join(root, side+"_pts.csv") + if err := os.WriteFile(timestamps, []byte(pts), 0600); err != nil { + t.Fatal(err) + } + port := "fullLeftVideos" + if side == "right" { + port = "fullRightVideos" + } + bindings = append(bindings, domain.NodeInputBinding{TargetPortID: port, Artifacts: []domain.ExecutionArtifact{{ID: side + "-video", Name: side + ".mp4", Path: video, Data: map[string]any{"collectionId": "capture"}}}}, domain.NodeInputBinding{TargetPortID: side + "Timestamps", Artifacts: []domain.ExecutionArtifact{{ID: side + "-pts", Name: side + "_pts.csv", Path: timestamps, Data: map[string]any{"collectionId": "capture"}}}}) + } + imu := "timestamp_us,x,y,z,type\n" + for i := 0; i < 100; i++ { + stamp := 1000000 + i*100000 + imu += fmt.Sprintf("%d,1,2,3,accel\n%d,4,5,6,gyro\n", stamp, stamp) + } + imuPath := filepath.Join(root, "imu.csv") + if err := os.WriteFile(imuPath, []byte(imu), 0600); err != nil { + t.Fatal(err) + } + bindings = append(bindings, domain.NodeInputBinding{TargetPortID: "imu", Artifacts: []domain.ExecutionArtifact{{ID: "imu", Name: "imu.csv", Path: imuPath, Data: map[string]any{"collectionId": "capture"}}}}) + if err := f.store.UpsertRun(f.ctx, domain.RunRecord{ID: f.task.RunID, OrganizationID: f.task.OrganizationID, ProjectID: f.task.ProjectID, WorkflowID: f.task.WorkflowID, NodeExecutions: []domain.NodeExecutionRecord{{NodeID: f.task.NodeID, InputBindings: bindings}}}); err != nil { + t.Fatal(err) + } + if err := f.store.UpsertAnnotationTask(f.ctx, f.task); err != nil { + t.Fatal(err) + } + if err := reset("pending", ""); err != nil { + t.Fatal(err) + } + handler := NewHandlerWithConfig(f.store, nil, config.AppConfig{WorkspaceMountPath: root}) + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/api/auth/me" { + renderJSON(w, 200, map[string]any{"user": sanitizeUser(&f.annotator), "organization": domain.OrganizationRecord{ID: domain.DefaultOrganizationID, Status: domain.OrganizationStatusActive}}) + return + } + if r.URL.Path == "/__boundary/reset" { + if err := reset(r.URL.Query().Get("status"), r.URL.Query().Get("shape")); err != nil { + renderError(w, 500, err) + return + } + renderJSON(w, 200, map[string]any{"ok": true}) + return + } + if r.URL.Path == "/__boundary/state" { + item, _ := f.store.GetHumanItem(r.Context(), f.item.ID) + renderJSON(w, 200, item) + return + } + if r.Method != "GET" && r.Method != "HEAD" && !strings.HasSuffix(r.URL.Path, "/slice-edit-applications") && !strings.HasSuffix(r.URL.Path, "/slice-edit-restorations") && !strings.HasSuffix(r.URL.Path, "/drafts") { + renderJSON(w, 403, map[string]string{"error": "fixture write not permitted"}) + return + } + r.AddCookie(&http.Cookie{Name: csrfCookieName, Value: "boundary-local-csrf"}) + r.Header.Set(csrfHeaderName, "boundary-local-csrf") + r = r.WithContext(context.WithValue(r.Context(), authContextKey{}, &authenticatedPrincipal{User: f.annotator, Organization: domain.OrganizationRecord{ID: domain.DefaultOrganizationID, Status: domain.OrganizationStatusActive}})) + handler.ServeHTTP(w, r) + })) + defer server.Close() + ctx, cancel := context.WithTimeout(t.Context(), 3*time.Minute) + defer cancel() + cmd := exec.CommandContext(ctx, "node", "tests/browser/slice-phase-replica.mjs") + cmd.Dir = "../.." + cmd.Env = append(os.Environ(), "REWORK_BOUNDARY_API="+server.URL) + out, err := cmd.CombinedOutput() + t.Log(string(out)) + if err != nil { + t.Fatal(fmt.Errorf("browser: %w", err)) + } +} diff --git a/src/components/CaptureAnnotationWorkbench.tsx b/src/components/CaptureAnnotationWorkbench.tsx index c2620a55..e867c014 100644 --- a/src/components/CaptureAnnotationWorkbench.tsx +++ b/src/components/CaptureAnnotationWorkbench.tsx @@ -745,24 +745,26 @@ export function CaptureAnnotationWorkbench({ setDispositionError(""); } }, [selectedSlice?.id, dispositionOpen, dispositionDraft.sliceId]); - // 切片重设面板只在 annotate 相的可编辑工作台内存在;阶段流转/只读化时整体取消 - // (预览本就不落库,丢弃即回退)。不随 slices.length < 2 退出:面板内合并到单切片 - // 合法(拆分可再补回),守卫只在进入时拦。 + // E-panel belongs to annotation; quick structural edits are supported in + // both editing phases. Never silently cancel a slice-phase conflict. + const conflictPhaseAllowed = phase === "annotate" || (phase === "slice" && sliceEditConflictList?.source === "quick"); + const showSliceEditConflict = Boolean( + sliceEditConflictList && conflictPhaseAllowed && !readOnly && !isQualityReview && !mediaOnly, + ); useEffect(() => { - if ( - (sliceEditPanel || sliceEditConflictList) && - (phase !== "annotate" || readOnly || isQualityReview || mediaOnly) - ) { - // 票 05:快路径清单随阶段/只读化一并取消——页面回退拖动几何(或丢弃未落库 - // 改动),不留悬空待决结构。 - if (sliceEditConflictList?.source === "quick") onSliceEditQuickConflictCancel?.(); + const unavailable = readOnly || isQualityReview || mediaOnly; + if (sliceEditPanel && (phase !== "annotate" || unavailable)) { setSliceEditPanel(null); - setSliceEditConflictList(null); setSliceEditDiscardDraft(null); } + if (sliceEditConflictList && (!conflictPhaseAllowed || unavailable)) { + if (sliceEditConflictList.source === "quick") onSliceEditQuickConflictCancel?.(); + setSliceEditConflictList(null); + } }, [ sliceEditPanel, sliceEditConflictList, + conflictPhaseAllowed, phase, readOnly, isQualityReview, @@ -795,8 +797,7 @@ export function CaptureAnnotationWorkbench({ const playheadSliceIndex = sliceIndexAtPlayhead(slices, currentTime); const playheadSlice = playheadSliceIndex >= 0 ? slices[playheadSliceIndex] : null; const selectedDiscarded = selectedSlice.deliveryDisposition === "discard"; - const showDispositionPanel = - (phase === "slice" || readOnly || isQualityReview || dispositionOpen) && (selectedDiscarded || dispositionOpen); + const showDispositionPanel = selectedDiscarded || dispositionOpen; const canEditDisposition = phase === "slice" && !readOnly && !isQualityReview && !!onSliceDispositionChange; const sliceNameIssue = sliceDictionaryNameIssue( slices, @@ -3131,7 +3132,7 @@ export function CaptureAnnotationWorkbench({ // 冲突清单(票 04,R2-Q2):清单开着时全权接管——↑/↓ 条目、1/2/3 处置、 // Enter 按默认应用、Esc 取消整个待应用改动集;播放族 "pass" 放行给全局表 // (视频是参照物),J/K "locked" 给提示,其余键整体吞掉(面板键不生效)。 - if (sliceEditConflictList && phase === "annotate") { + if (sliceEditConflictList && showSliceEditConflict) { if (saving || quickConflictApplyingRef.current) { event.preventDefault(); return; @@ -3639,7 +3640,7 @@ export function CaptureAnnotationWorkbench({
- {sliceEditConflictList && phase === "annotate" ? ( + {sliceEditConflictList && showSliceEditConflict ? (+ 已选择将 {invalidating} 个动作整体判无效,包含新边界两侧;如需保留正常侧描述,请选择“截断”。应用后可撤销。 +
+ ) : null} {autoFollowHint ? (