Skip to content

feat: add share logs support#58

Draft
geekflyer wants to merge 2 commits into
mainfrom
cursor/share-logs-feature-ea31
Draft

feat: add share logs support#58
geekflyer wants to merge 2 commits into
mainfrom
cursor/share-logs-feature-ea31

Conversation

@geekflyer
Copy link
Copy Markdown
Owner

Summary

  • add Android support-dialog log sharing that exports a bounded ClipRelay logcat snapshot with app/device diagnostics into the system share sheet
  • add macOS menu-bar log sharing that exports recent org.cliprelay unified logs plus device context via the native sharing picker
  • add focused Android test coverage for the exported log filename/content format
Open in Web Open in Cursor 

Co-authored-by: Christian Theilemann <geekflyer@users.noreply.github.com>
Comment on lines +43 to +53
do {
try process.run()
process.waitUntilExit()
} catch {
return "Unable to capture unified logs: \(error.localizedDescription)"
}

let output = String(data: stdout.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)?
.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
let errorOutput = String(data: stderr.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)?
.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: Classic pipe deadlock — waitUntilExit() is called before reading from the pipes. If log show --last 24h produces more output than the pipe buffer (~64KB on macOS), the subprocess blocks trying to write, waitUntilExit() blocks waiting for the subprocess, and neither ever completes.

The Android side gets this right (readText() before waitFor()). The fix here is to read the pipe data before waiting:

Suggested change
do {
try process.run()
process.waitUntilExit()
} catch {
return "Unable to capture unified logs: \(error.localizedDescription)"
}
let output = String(data: stdout.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)?
.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
let errorOutput = String(data: stderr.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)?
.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
do {
try process.run()
} catch {
return "Unable to capture unified logs: \(error.localizedDescription)"
}
let output = String(data: stdout.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)?
.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
let errorOutput = String(data: stderr.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)?
.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
process.waitUntilExit()

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 11, 2026

Review: Share Logs feature

Nice, clean feature addition across both platforms. The code is well-structured — good use of runCatching/Result for error handling, proper FileProvider setup on Android, and the SupportLinks.diagnosticsContext() extraction is a nice DRY improvement.

One bug to fix:

macOS LogShareExporter.swift — pipe deadlock: waitUntilExit() is called before reading pipe data. If log show --last 24h fills the pipe buffer (~64KB), the process and the caller will deadlock. See inline comment with a suggested fix.

Everything else looks good — the Android captureLogcat correctly reads before waiting, the test coverage is solid, and the UI integration is clean on both platforms.

Co-authored-by: Christian Theilemann <geekflyer@users.noreply.github.com>
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.

2 participants