fix(editor): clamp captions and hide keyboard segments past trim boundary#1726
fix(editor): clamp captions and hide keyboard segments past trim boundary#1726MinitJain wants to merge 5 commits intoCapSoftware:mainfrom
Conversation
…dary Closes CapSoftware#1725 Related to CapSoftware#1689 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| const keyboardSegments = createMemo(() => | ||
| (project.timeline?.keyboardSegments ?? []).filter( | ||
| (s) => s.start < totalDuration(), | ||
| ), | ||
| ); |
There was a problem hiding this comment.
Keyboard segments crossing the trim boundary not visually clamped
KeyboardTrack filters out segments where start >= totalDuration(), but keyboard segments whose start < totalDuration() and end > totalDuration() are rendered with their full unclamped width via the segment={segment} prop on SegmentRoot. This means they can visually overflow past the trim boundary, inconsistent with how CaptionsTrack clamps its segments. If a keyboard segment straddles the trim point, consider passing a clamped end to SegmentRoot the same way captions does:
segment={{ start: segment.start, end: Math.min(segment.end, totalDuration()) }}
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/routes/editor/Timeline/KeyboardTrack.tsx
Line: 35-39
Comment:
**Keyboard segments crossing the trim boundary not visually clamped**
`KeyboardTrack` filters out segments where `start >= totalDuration()`, but keyboard segments whose `start < totalDuration()` and `end > totalDuration()` are rendered with their full unclamped width via the `segment={segment}` prop on `SegmentRoot`. This means they can visually overflow past the trim boundary, inconsistent with how `CaptionsTrack` clamps its segments. If a keyboard segment straddles the trim point, consider passing a clamped `end` to `SegmentRoot` the same way captions does:
```
segment={{ start: segment.start, end: Math.min(segment.end, totalDuration()) }}
```
How can I resolve this? If you propose a fix, please make it concise.Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hey @richiemcilroy fixed captions and keyboard segments overflowing past the trim boundary. |
…cessibility in debug builds On macOS Sequoia, CGPreflightScreenCaptureAccess() always returns false for ad-hoc signed or unsigned binaries regardless of System Settings, making it impossible to test locally without a Developer ID certificate. Adding a debug_assertions early return for ScreenRecording and Accessibility allows contributors to run and test the app locally without being blocked by the permissions screen. Camera and microphone are unaffected as they prompt correctly without a signed binary. Fixes CapSoftware#1722 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…board segments segmentWidth used the original unclamped segment.end while SegmentRoot rendered the clamped visual width, causing split clicks to land at wrong positions for segments crossing the trim boundary. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The Clippy failures are not caused by this PR. The error is in |
Summary
How it works
CaptionsTrack:
SegmentRootreceives a clampedendvalue —Math.min(segment.end, totalDuration())— so the rendered bar width stops at the trim point. The underlying segment data is unchanged, so drag interactions are unaffected.KeyboardTrack: Segments are filtered with
s.start < totalDuration()so keypresses that occur after the trim point are not rendered.Test plan
Closes #1725
Related to #1689
🤖 Generated with Claude Code
Greptile Summary
This PR visually clamps caption segments at the trim boundary and hides keyboard/caption segments that start at or after the trim point, fixing overflow into the empty region beyond the clip. One defect was found in the split-mode interaction for
CaptionsTrack.segmentWidth()reads the original unclampedsegment.end, butSegmentRootrenders the element using the clamped width. Clicks in the visual element are scaled against the wrong duration, so splits land at incorrect positions — up to a factor of 2× off for segments that span the trim boundary.Confidence Score: 4/5
Safe to merge after fixing the split-time calculation for visually clamped caption segments.
One P1 defect: the
segmentWidthlocal inCaptionsTrackuses the original unclamped end whileSegmentRootrenders the clamped width, causing split-mode clicks to map to wrong positions on segments that cross the trim boundary. The fix is a one-liner. All other changes are correct.apps/desktop/src/routes/editor/Timeline/CaptionsTrack.tsx — line 164,
segmentWidthdefinition used in split handler.Important Files Changed
segmentWidthlocal used in split-mode click handling still reads the original unclampedsegment.end, producing incorrect split times for visually clamped segments.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[captionSegments / keyboardSegments] -->|filter: s.start < totalDuration| B[Filtered visible segments] B --> C{Segment crosses trim boundary?} C -->|Yes - CaptionsTrack| D["SegmentRoot receives clamped end\n= Math.min(end, totalDuration)"] C -->|No| E[SegmentRoot receives original segment] C -->|Yes - KeyboardTrack| F["SegmentRoot receives original segment\n⚠️ may overflow trim visually"] D --> G[Visual width = clamped duration] E --> H[Visual width = full duration] G --> I{Split mode click?} I -->|segmentWidth uses original end| J[❌ Wrong split time calculated] I -->|segmentWidth uses clamped end| K[✅ Correct split time]Comments Outside Diff (1)
apps/desktop/src/routes/editor/Timeline/CaptionsTrack.tsx, line 164-184 (link)segmentWidth()uses the original unclampedsegment.end, butrect.widthreflects the clamped visual width passed toSegmentRoot. For a segment spanning, say, seconds 5–15 withtotalDuration() = 10,rect.widthcorresponds to 5 s of visual space whilesegmentWidth()returns 10 — so clicking at 50% of the visual element producessplitTime = 5, which maps to the trim boundary rather than the midpoint of the visible portion. Any click past the visual midpoint maps to a split time beyond the trim.Fix
segmentWidthto reflect the rendered width:Prompt To Fix With AI
Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "fix(editor): clamp captions and hide key..." | Re-trigger Greptile
(5/5) You can turn off certain types of comments like style here!