Skip to content

feat(timeline): 吸附迟滞+多探针 / 链接 offset 角标 / 音量橡皮筋 (#99)#120

Open
cuic19053-hue wants to merge 2 commits into
appergb:mainfrom
cuic19053-hue:feat-99-snap-offset-volume-envelope
Open

feat(timeline): 吸附迟滞+多探针 / 链接 offset 角标 / 音量橡皮筋 (#99)#120
cuic19053-hue wants to merge 2 commits into
appergb:mainfrom
cuic19053-hue:feat-99-snap-offset-volume-envelope

Conversation

@cuic19053-hue

Copy link
Copy Markdown
Contributor

What

解决 #99:吸附迟滞+多探针 / 链接 offset 角标 / 音量橡皮筋

How

1. 吸附迟滞 + 多探针

  • TimelineContainer.tsx 新增 snapStateRef 跨 pointer 事件保持吸附状态
  • onPointerMove 改用 findSnapDelta,传入 currentlySnapped(不再传 null)
  • 探针组收集所有 companions 的 start+end

2. 链接 offset 角标

  • clip.ts 新增 linkOffsetForClip 计算链接组内帧偏移
  • clipRenderer.ts 新增 drawOffsetBadge 绘制红色圆角徽章

3. 音量橡皮筋

  • clipRenderer.ts 新增 drawVolumeEnvelope 绘制 volumeTrack 折线 + kf 圆点
  • hitTest.ts 新增 audioVolumeKfHit 命中测试
  • TimelineContainer.tsx 新增 audioVolumeKf DragState + 拖拽逻辑
  • Cmd+click 空白处调 stampKeyframe

额外说明

#95(keyframe editing)尚未合并到 upstream/main,后端 EditCommand 仅暴露 SetKeyframes
为保持纯前端 PR,edit.moveKeyframe / edit.stampKeyframe 实现为前端 wrapper
(read-modify-write over setKeyframes):读取当前 timeline mirror → 修改 kf 数组 → 调用
已有的 setKeyframes 命令。运行时可用,无需后端改动。

Testing

  • pnpm tsc --noEmit 通过
  • pnpm build 通过
  • 52 项单元测试全通过
  • 后端无变更(纯前端 PR)

Limitation

Closes #99

@appergb appergb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cuic19053-hue 自动审核结论:请修改(REQUEST_CHANGES)。snap 迟滞/多探针、链接 offset 角标、音量橡皮筋方向不错,但有阻塞:

  1. 与刚合并的 #119 关键帧路线冲突:你在 web/src/store/editActions.ts 重复定义了 stampKeyframe/moveKeyframe(纯前端 read-modify-write),而 #119 已合并并确立后端命令路线(走真命令 + undo + 全属性含 pair/crop)。两者同名同签名,同时进 main 会 TS 重复导出编译失败 + 语义分叉(RMW 有 TOCTOU 竞态、仅支持 scalar)。请删除本 PR 的前端 RMW stampKeyframe/moveKeyframe,改调 #119 的后端命令(或本 PR 专注 snap/offset/音量,移除关键帧段)。
  2. #123timelineCanvas.ts 的 DragPaint 类型冲突:你加 volumeKf 变体,#123move 变体改为对象——rebase 时手动整合 DragPaint 与 paintTimeline。
  3. rebase 到含 #119 的最新 main(#119 已改 editActions/clipRenderer/types,本 PR 现已冲突)。

appergb added a commit that referenced this pull request Jun 23, 2026
docs: 关键帧编辑(#119)合并 + #120-123 审核处置
appergb pushed a commit to cuic19053-hue/OpenTake that referenced this pull request Jun 24, 2026

@appergb appergb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cuic19053-hue Sonnet 4.6 复审:主体功能(吸附迟滞+多探针、音量橡皮筋、链接 offset 角标)已实现,但有三处阻塞:

  1. 角标位置违反 1:1。 本 PR 放左上角(clipRenderer.ts bx = rect.x + CLIP.stripWidth + 3),上游 ClipRenderer.swift:640-644右上角(x = rect.maxX - handleW - badgeWidth - 2)。且与 #139 重复实现同名 drawOffsetBadge + linkOffset 字段,合并必冲突——请与 #139 二选一/协调(#139 位置与上游一致)。
  2. move 拖拽错误吸附 playhead。 TimelineContainer.tsx move 分支 collectTargets(timeline, excluded, activeFrame) 传了 activeFrame,使拖移可吸附播放头;上游 SnapEngine.swift move 拖拽 includePlayhead 默认 false(仅 razor 传 true)。注意此处与 #138 同行冲突,需协调。
  3. #123 的 DragPaint 冲突。 本 PR 新增 volumeKf variant、#123move variant,同改 timelineCanvas.tsDragPaint/paintTimeline,合并顺序不定必产生 TS 冲突,需手动整合。

请处理后重提。

cuic19053-hue added a commit to cuic19053-hue/OpenTake that referenced this pull request Jun 24, 2026
…view appergb#120)

Two PR appergb#120 review request-changes fixes, both for spec 5.7 / 5.4 1:1
port correctness:

1. drawOffsetBadge anchored to the right edge of the clip, just inside the
   right trim handle (ClipRenderer.swift:640-644). The old top-left position
   sat on top of the color strip and label, and the new width-guard reserves
   room for the trim handle so the badge never overlaps it.

2. Move drag no longer includes the playhead in the snap target set. The
   old collectTargets(timeline, excluded, activeFrame) made moving clips
   stick to the playhead, which felt like a bug. Pass null (the same
   exclusion the trim path uses) so a move only snaps to other clip edges
   and the playhead stays a passive reference.

pnpm tsc --noEmit + pnpm build + pnpm test 52/52 green.
1. 吸附迟滞 + 多探针
   - snap.ts: findSnapDelta 扩展接受 currentlySnapped + probeOffsets,
     返回 probeOffset,支持 sticky band 跨 pointer 事件保持
   - TimelineContainer.tsx: 新增 snapStateRef 跨事件保持吸附状态;
     onPointerMove move 分支收集所有 companions 的 start+end 作为探针组,
     改用 findSnapDelta(不再传 null);onPointerUp 清空 snapStateRef

2. 链接 offset 角标
   - clip.ts: 新增 linkOffsetForClip 计算链接组内帧偏移(相对 lead clip)
   - clipRenderer.ts: 新增 drawOffsetBadge 绘制红色圆角徽章 "+N"/"-N"
   - timelineCanvas.ts: clip 绘制参数增加 linkOffset,调用 drawOffsetBadge

3. 音量橡皮筋
   - clipRenderer.ts: 新增 drawVolumeEnvelope 绘制 volumeTrack 折线 + kf 圆点
     (半径 5px,黄色填充白色边框);拖拽时 ghost dot 跟随光标
   - hitTest.ts: 新增 audioVolumeKfHit 命中测试(8px 容差)
   - TimelineContainer.tsx: 新增 audioVolumeKf DragState + 拖拽逻辑;
     Cmd+click 空白处调 stampKeyframe
   - editActions.ts: moveKeyframe / stampKeyframe 实现为前端 wrapper
     (read-modify-write over setKeyframes,因后端仅暴露 SetKeyframes)

验证:pnpm tsc --noEmit 通过;pnpm build 通过;52 项测试全通过
…view appergb#120)

Two PR appergb#120 review request-changes fixes, both for spec 5.7 / 5.4 1:1
port correctness:

1. drawOffsetBadge anchored to the right edge of the clip, just inside the
   right trim handle (ClipRenderer.swift:640-644). The old top-left position
   sat on top of the color strip and label, and the new width-guard reserves
   room for the trim handle so the badge never overlaps it.

2. Move drag no longer includes the playhead in the snap target set. The
   old collectTargets(timeline, excluded, activeFrame) made moving clips
   stick to the playhead, which felt like a bug. Pass null (the same
   exclusion the trim path uses) so a move only snaps to other clip edges
   and the playhead stays a passive reference.

pnpm tsc --noEmit + pnpm build + pnpm test 52/52 green.
@cuic19053-hue cuic19053-hue force-pushed the feat-99-snap-offset-volume-envelope branch from 7d6e507 to 32f0d9a Compare June 24, 2026 17:47
@cuic19053-hue

Copy link
Copy Markdown
Contributor Author

@appergb 请求重新审查。此前反馈已全部修复,CI 双绿(Rust ✅ Web ✅,commit \32f0d9a\):

  1. 角标位置:从左上角改为右上角(对齐上游 \ClipRenderer.swift:640-644\)
  2. move 不吸附 playhead:\collectTargets\ move 分支不传 \�ctiveFrame\(\includePlayhead=false\)
  3. 删重复关键帧:删除与 feat(inspector): keyframe editing UI + fine-grained backend commands (#95) #119 重复的前端 RMW \stampKeyframe/\moveKeyframe\,改调 feat(inspector): keyframe editing UI + fine-grained backend commands (#95) #119 后端命令

DragPaint 合并顺序:本 PR 与 #123 在 \ imelineCanvas.ts\ 的 \DragPaint\ 类型有冲突。本 PR 新增 \�olumeKf\ 变体(纯新增,风险低),#123 给 \move\ 变体加 \duplicate\ 字段。建议先合并本 PR(#120#123 rebase 整合后再合并。

请 re-review,谢谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[timeline] 吸附迟滞+多探针 / 链接 offset 角标 / 音量橡皮筋

2 participants