Skip to content

feat: more information during screenrecord#180

Merged
gmegidish merged 1 commit intomainfrom
feat-more-information-during-screenrecord
Mar 2, 2026
Merged

feat: more information during screenrecord#180
gmegidish merged 1 commit intomainfrom
feat-more-information-during-screenrecord

Conversation

@gmegidish
Copy link
Member

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Mar 2, 2026

Walkthrough

This pull request extends the screen recording functionality with silent mode support and progress callbacks. A new Silent boolean field is added to ScreenRecordRequest via a command-line flag. The commands package introduces internal progress tracking that displays per-second updates and completion messages, with output suppressed when silent mode is enabled. In the devices package, a new ScreenRecordCallbacks struct enables progress reporting during downloads, with callbacks invoked at recording completion and during file transfer. The ScreenRecord method signature is updated to accept these callbacks, allowing downstream integrations to monitor recording and download progress.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No pull request description was provided by the author, so the description check cannot assess relation to the changeset. Add a pull request description explaining the purpose and scope of the changes, such as what information is now displayed during screenrecord and why.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: more information during screenrecord' directly relates to the main changeset, which adds progress output, callbacks, and a Silent flag to suppress/control output during screen recording.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-more-information-during-screenrecord

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
commands/screenrecord.go (1)

197-207: ⚠️ Potential issue | 🟡 Minor

Avoid “recording ended” messaging before capture error checks.

progress.recordingEnded() currently runs before err is evaluated, so a failed capture can still print “Screen recording ended, please wait while finalizing video”. That message is misleading on failure.

Suggested fix
-	progress.recordingEnded()
-
-	if req.StopChan == nil {
-		signal.Reset(syscall.SIGINT, syscall.SIGTERM)
-	}
-
-	tempFile.Close()
-
-	if err != nil {
-		return NewErrorResponse(fmt.Errorf("error during screen capture: %w", err))
-	}
+	if err != nil {
+		progress.stopTicker()
+		if !progress.silent {
+			fmt.Fprintln(os.Stderr)
+		}
+		if req.StopChan == nil {
+			signal.Reset(syscall.SIGINT, syscall.SIGTERM)
+		}
+		tempFile.Close()
+		return NewErrorResponse(fmt.Errorf("error during screen capture: %w", err))
+	}
+
+	progress.recordingEnded()
+	if req.StopChan == nil {
+		signal.Reset(syscall.SIGINT, syscall.SIGTERM)
+	}
+	tempFile.Close()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@commands/screenrecord.go` around lines 197 - 207, The
progress.recordingEnded() call is executed before checking err, causing a
misleading success message on failure; modify the flow in the function that
performs the capture so that you first handle the error (if err != nil return
NewErrorResponse(...)) and only after a successful capture call
progress.recordingEnded(); ensure tempFile.Close() and the
signal.Reset(req.StopChan == nil) logic still run as needed (use defer or
explicit close/reset) so resources and signal handlers are properly cleaned up
even on error; update references: progress.recordingEnded(), err,
tempFile.Close(), req.StopChan and signal.Reset to reflect this reordered logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@devices/remote.go`:
- Around line 303-305: The progress wrapper is being initialized with
resp.ContentLength directly (see the struct fields reader/total/onProgress),
which can be -1 for unknown lengths and results in negative totals; update the
initialization in both locations (the blocks around the reader: resp.Body,
total: resp.ContentLength, onProgress: onProgress and the similar block at lines
~415-417) to coerce non-positive ContentLength to 0 (e.g., total :=
resp.ContentLength; if total < 0 { total = 0 }) or otherwise handle unknown
length explicitly so downstream progress calculations never see a negative
total.

---

Outside diff comments:
In `@commands/screenrecord.go`:
- Around line 197-207: The progress.recordingEnded() call is executed before
checking err, causing a misleading success message on failure; modify the flow
in the function that performs the capture so that you first handle the error (if
err != nil return NewErrorResponse(...)) and only after a successful capture
call progress.recordingEnded(); ensure tempFile.Close() and the
signal.Reset(req.StopChan == nil) logic still run as needed (use defer or
explicit close/reset) so resources and signal handlers are properly cleaned up
even on error; update references: progress.recordingEnded(), err,
tempFile.Close(), req.StopChan and signal.Reset to reflect this reordered logic.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between fbf1cf6 and 18a9a04.

📒 Files selected for processing (3)
  • cli/screenrecord.go
  • commands/screenrecord.go
  • devices/remote.go

Comment on lines +303 to +305
reader: resp.Body,
total: resp.ContentLength,
onProgress: onProgress,
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Handle unknown content length to avoid negative progress totals.

When resp.ContentLength == -1, totalMB becomes negative and user-facing progress output can be incorrect.

Suggested fix
-	pr := &progressReader{
+	totalBytes := resp.ContentLength
+	if totalBytes < 0 {
+		totalBytes = 0
+	}
+	pr := &progressReader{
 		reader:     resp.Body,
-		total:      resp.ContentLength,
+		total:      totalBytes,
 		onProgress: onProgress,
 		deadline:   deadline,
 	}

Also applies to: 415-417

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@devices/remote.go` around lines 303 - 305, The progress wrapper is being
initialized with resp.ContentLength directly (see the struct fields
reader/total/onProgress), which can be -1 for unknown lengths and results in
negative totals; update the initialization in both locations (the blocks around
the reader: resp.Body, total: resp.ContentLength, onProgress: onProgress and the
similar block at lines ~415-417) to coerce non-positive ContentLength to 0
(e.g., total := resp.ContentLength; if total < 0 { total = 0 }) or otherwise
handle unknown length explicitly so downstream progress calculations never see a
negative total.

@gmegidish gmegidish merged commit ac7930b into main Mar 2, 2026
15 checks passed
@gmegidish gmegidish deleted the feat-more-information-during-screenrecord branch March 2, 2026 20:22
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.

1 participant