-
Notifications
You must be signed in to change notification settings - Fork 1.1k
misc bug fixes I'm tired pls help #1480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
20 files reviewed, 2 comments
| createEffect(() => { | ||
| if (isDragging()) { | ||
| window.addEventListener("mousemove", handleMouseMove); | ||
| window.addEventListener("mouseup", handleMouseUp); | ||
| } | ||
| onCleanup(() => { | ||
| window.removeEventListener("mousemove", handleMouseMove); | ||
| window.removeEventListener("mouseup", handleMouseUp); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: event listeners added conditionally but removed unconditionally in cleanup, causing listeners to remain attached after dragging stops
when isDragging() becomes false, cleanup runs and removes listeners, but they were only added when dragging was true, so on subsequent drags the effect runs again but doesn't re-add listeners
| createEffect(() => { | |
| if (isDragging()) { | |
| window.addEventListener("mousemove", handleMouseMove); | |
| window.addEventListener("mouseup", handleMouseUp); | |
| } | |
| onCleanup(() => { | |
| window.removeEventListener("mousemove", handleMouseMove); | |
| window.removeEventListener("mouseup", handleMouseUp); | |
| }); | |
| createEffect(() => { | |
| if (isDragging()) { | |
| window.addEventListener("mousemove", handleMouseMove); | |
| window.addEventListener("mouseup", handleMouseUp); | |
| onCleanup(() => { | |
| window.removeEventListener("mousemove", handleMouseMove); | |
| window.removeEventListener("mouseup", handleMouseUp); | |
| }); | |
| } | |
| }); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/routes/screenshot-editor/Preview.tsx
Line: 156:164
Comment:
**logic:** event listeners added conditionally but removed unconditionally in cleanup, causing listeners to remain attached after dragging stops
when `isDragging()` becomes `false`, cleanup runs and removes listeners, but they were only added when dragging was `true`, so on subsequent drags the effect runs again but doesn't re-add listeners
```suggestion
createEffect(() => {
if (isDragging()) {
window.addEventListener("mousemove", handleMouseMove);
window.addEventListener("mouseup", handleMouseUp);
onCleanup(() => {
window.removeEventListener("mousemove", handleMouseMove);
window.removeEventListener("mouseup", handleMouseUp);
});
}
});
```
How can I resolve this? If you propose a fix, please make it concise.Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Greptile Summary
This PR implements several bug fixes and improvements across the desktop application:
Active Word Highlight Toggle: Added a new setting to enable/disable word-by-word caption highlighting. When disabled, captions render with full highlight color instead of progressive word timing. This addresses accuracy issues with word timing in the initial caption implementation.
Windows Audio Playback Improvements: Implemented a pre-rendered audio buffer system specifically for Windows to address audio-video sync issues. The entire audio is rendered upfront and stored in memory, with different sync thresholds and buffer sizes compared to other platforms.
Screenshot Editor Enhancements:
original.pngfrom.capdirectories with fallback to base pathDefault Background Change: Changed default project background from wallpaper to solid white color
Logging Cleanup: Removed excessive debug and trace logging from rendering, decoding, and background layers
Issues Found:
hasReceivedWebSocketFrameflag is never mutatedConfidence Score: 3/5
apps/desktop/src/routes/screenshot-editor/context.tsxandapps/desktop/src/routes/screenshot-editor/Preview.tsxfor the identified logic bugs, andcrates/editor/src/audio.rsandcrates/editor/src/playback.rsfor the Windows audio memory usageImportant Files Changed
set_playhead_smoothmethod and chunked rendering for Windows.capdirectories withoriginal.pngfile support; improved image loading logic with better error handlingactive_word_highlightfield toCaptionSettingswith default value offalseSequence Diagram
sequenceDiagram participant User participant UI as Desktop UI (SolidJS) participant Tauri as Tauri Backend (Rust) participant Audio as Audio System participant Render as Rendering Engine participant Caption as Caption System Note over User,Caption: Active Word Highlight Feature User->>UI: Toggle "Active Word Highlight" UI->>Tauri: saveCaptions with activeWordHighlight setting Tauri->>Tauri: Serialize setting to JSON Tauri->>Render: Update caption settings Render->>Caption: Check active_word_highlight flag alt active_word_highlight enabled Caption->>Caption: Render word-by-word with timing else active_word_highlight disabled Caption->>Caption: Render full text with highlight color end Note over User,Caption: Screenshot Editor Improvements User->>UI: Open screenshot in .cap directory UI->>UI: Check if path ends with .cap UI->>UI: Try loading original.png alt original.png exists UI->>UI: Load original.png else fallback needed UI->>UI: Load from base path end UI->>UI: Set originalImageSize User->>UI: Pan/drag canvas UI->>UI: Update pan state with mouse events Note over User,Caption: Windows Audio Playback User->>Tauri: Start video playback Tauri->>Audio: Initialize audio with duration alt Windows platform Audio->>Audio: Pre-render entire audio buffer Audio->>Audio: Create PrerenderedAudioBuffer Audio->>Audio: Render all segments upfront Audio->>Audio: Store samples in memory loop Audio callback Audio->>Audio: Copy from pre-rendered buffer Audio->>Audio: Check video playhead sync alt Jump > 0.5s (hard seek) Audio->>Audio: set_playhead (clear buffer) else Drift > 0.2s Audio->>Audio: set_playhead_smooth (keep buffer) end end else Other platforms loop Audio callback Audio->>Audio: Render chunks on-demand Audio->>Audio: Dynamic latency correction end end