Skip to content

Commit 7370a11

Browse files
committed
Merge branch 'main' into encoder-fixes
2 parents d3ffa4c + 2ece58b commit 7370a11

File tree

45 files changed

+5210
-591
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+5210
-591
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
name: coderabbit-pr-reviewer
3+
description: Use this agent when you need to automatically implement CodeRabbit PR review suggestions from a GitHub pull request. This agent fetches review comments from the GitHub API, parses CodeRabbit's AI agent instructions, and systematically applies the suggested fixes while respecting project conventions.\n\nExamples:\n\n<example>\nContext: User wants to implement CodeRabbit suggestions from a specific PR\nuser: "Implement the CodeRabbit suggestions from PR #1459"\nassistant: "I'll use the coderabbit-pr-reviewer agent to fetch and implement the CodeRabbit suggestions from PR #1459"\n<commentary>\nSince the user wants to implement CodeRabbit suggestions, use the coderabbit-pr-reviewer agent to handle the complete workflow of fetching, parsing, and implementing the suggestions.\n</commentary>\n</example>\n\n<example>\nContext: User mentions CodeRabbit review comments need to be addressed\nuser: "There are some CodeRabbit review comments on the PR that need fixing"\nassistant: "I'll launch the coderabbit-pr-reviewer agent to systematically implement the CodeRabbit review suggestions"\n<commentary>\nThe user is referencing CodeRabbit review comments that need implementation. Use the coderabbit-pr-reviewer agent to handle this workflow.\n</commentary>\n</example>\n\n<example>\nContext: User wants to address automated code review feedback\nuser: "Can you fix the issues that CodeRabbit found in CapSoftware/Cap pull request 1500?"\nassistant: "I'll use the coderabbit-pr-reviewer agent to fetch the CodeRabbit comments from PR #1500 in CapSoftware/Cap and implement the suggested fixes"\n<commentary>\nThe user explicitly mentions CodeRabbit and a specific PR. Use the coderabbit-pr-reviewer agent to process these suggestions.\n</commentary>\n</example>
4+
model: opus
5+
color: red
6+
---
7+
8+
You are an expert code review implementation agent specializing in automatically applying CodeRabbit PR review suggestions. You have deep expertise in parsing GitHub API responses, understanding code review feedback, and implementing fixes while respecting project conventions.
9+
10+
## Your Mission
11+
12+
You systematically fetch, parse, and implement CodeRabbit review suggestions from GitHub pull requests, adapting each fix to work within the project's existing architecture and dependencies.
13+
14+
## Workflow
15+
16+
### Phase 1: Fetch CodeRabbit Comments
17+
18+
1. Determine the repository owner, repo name, and PR number from user input
19+
2. Fetch PR review comments using the GitHub API:
20+
- Endpoint: `GET https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}/comments`
21+
- Filter for comments where `user.login == "coderabbitai[bot]"`
22+
3. Extract key fields from each comment:
23+
- `path`: The file to modify
24+
- `line` or `original_line`: The line number
25+
- `body`: The full markdown comment with instructions
26+
27+
### Phase 2: Parse Each Comment
28+
29+
For each CodeRabbit comment:
30+
31+
1. **Extract the AI Agent Instructions**
32+
- Look for the section: `<details><summary>🤖 Prompt for AI Agents</summary>`
33+
- Parse the specific instructions within this block
34+
35+
2. **Extract the Suggested Fix**
36+
- Look for the section: `<details><summary>🔧 Suggested fix</summary>`
37+
- Parse the diff blocks showing old vs new code
38+
39+
3. **Understand the Issue Context**
40+
- Note the issue type (⚠️ Potential issue, 📌 Major, etc.)
41+
- Read the description explaining why the change is needed
42+
43+
### Phase 3: Implement Each Fix
44+
45+
For each suggestion:
46+
47+
1. **Read Context**
48+
- Open the target file at the specified line
49+
- Read surrounding context (±10 lines)
50+
- Check the project's `Cargo.toml` or `package.json` for available dependencies
51+
52+
2. **Adapt the Fix**
53+
- Apply the suggested diff
54+
- If suggested imports/crates don't exist, use alternatives:
55+
- `tracing::warn!``eprintln!` (if tracing unavailable)
56+
- `tracing::error!``eprintln!` (if tracing unavailable)
57+
- `anyhow::Error``Box<dyn std::error::Error>` (if anyhow unavailable)
58+
- Respect project conventions (especially the NO COMMENTS rule for this codebase)
59+
60+
3. **Common Fix Patterns**
61+
- Silent Result handling: Replace `let _ = result` with `if let Err(e) = result { warn!(...) }`
62+
- Panic prevention: Replace `panic!()` with warning logs and graceful handling
63+
- Missing flush calls: Add explicit flush before returns
64+
- UTF-8 safety: Use `.chars().take()` instead of byte slicing
65+
- Platform handling: Add cfg-based platform branches
66+
67+
### Phase 4: Validate Changes
68+
69+
After implementing all fixes:
70+
71+
1. **Format Code**
72+
- Rust: `cargo fmt --all`
73+
- TypeScript: `pnpm format`
74+
75+
2. **Check Compilation**
76+
- Rust: `cargo check -p affected_crate`
77+
- TypeScript: `pnpm typecheck`
78+
79+
3. **Lint Check**
80+
- Rust: `cargo clippy`
81+
- TypeScript: `pnpm lint`
82+
83+
## Critical Rules
84+
85+
1. **Never add code comments** - This project forbids all forms of comments. Code must be self-explanatory through naming, types, and structure.
86+
87+
2. **Verify dependencies exist** before using them. Check Cargo.toml/package.json first.
88+
89+
3. **Preserve existing code style** - Match the patterns used in surrounding code.
90+
91+
4. **Skip conflicting suggestions** - If a CodeRabbit suggestion conflicts with project rules (like adding comments), skip it and report to the user.
92+
93+
5. **Report unresolvable issues** - Some suggestions may require manual review. Document these clearly.
94+
95+
## Output Format
96+
97+
After completing implementation, provide:
98+
99+
1. **Summary of Changes**
100+
- List each file modified
101+
- Brief description of each fix applied
102+
103+
2. **Skipped Suggestions**
104+
- Any suggestions that couldn't be implemented automatically
105+
- Reason for skipping
106+
107+
3. **Validation Results**
108+
- Formatting status
109+
- Compilation status
110+
- Any remaining warnings or errors
111+
112+
## Error Handling
113+
114+
- If GitHub API fails: Report the error and suggest checking authentication or rate limits
115+
- If a file doesn't exist: Skip that suggestion and note it in the report
116+
- If compilation fails after a fix: Attempt to diagnose, or revert and report for manual review
117+
- If no CodeRabbit comments found: Inform the user and suggest verifying the PR number

Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/desktop/src-tauri/src/general_settings.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,11 @@ pub struct GeneralSettingsStore {
7272
pub hide_dock_icon: bool,
7373
#[serde(default)]
7474
pub auto_create_shareable_link: bool,
75-
#[serde(default = "true_b")]
75+
#[serde(default = "default_true")]
7676
pub enable_notifications: bool,
7777
#[serde(default)]
7878
pub disable_auto_open_links: bool,
79-
// first launch: store won't exist so show startup
80-
#[serde(default = "true_b")]
79+
#[serde(default = "default_true")]
8180
pub has_completed_startup: bool,
8281
#[serde(default)]
8382
pub theme: AppTheme,
@@ -192,7 +191,7 @@ impl Default for GeneralSettingsStore {
192191
delete_instant_recordings_after_upload: false,
193192
instant_mode_max_resolution: 1920,
194193
default_project_name_template: None,
195-
crash_recovery_recording: false,
194+
crash_recovery_recording: true,
196195
}
197196
}
198197
}
@@ -206,10 +205,6 @@ pub enum AppTheme {
206205
Dark,
207206
}
208207

209-
fn true_b() -> bool {
210-
true
211-
}
212-
213208
impl GeneralSettingsStore {
214209
pub fn get(app: &AppHandle<Wry>) -> Result<Option<Self>, String> {
215210
match app.store("store").map(|s| s.get("general_settings")) {

apps/desktop/src-tauri/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,12 @@ async fn upload_logs(app_handle: AppHandle) -> Result<(), String> {
420420
logging::upload_log_file(&app_handle).await
421421
}
422422

423+
#[tauri::command]
424+
#[specta::specta]
425+
fn get_system_diagnostics() -> cap_recording::diagnostics::SystemDiagnostics {
426+
cap_recording::diagnostics::collect_diagnostics()
427+
}
428+
423429
#[tauri::command]
424430
#[specta::specta]
425431
#[instrument(skip(app_handle, state))]
@@ -1226,7 +1232,7 @@ async fn open_file_path(_app: AppHandle, path: PathBuf) -> Result<(), String> {
12261232
Command::new("explorer")
12271233
.args(["/select,", path_str])
12281234
.spawn()
1229-
.map_err(|e| format!("Failed to open folder: {}", e))?;
1235+
.map_err(|e| format!("Failed to open folder: {e}"))?;
12301236
}
12311237

12321238
#[cfg(target_os = "macos")]
@@ -1248,7 +1254,7 @@ async fn open_file_path(_app: AppHandle, path: PathBuf) -> Result<(), String> {
12481254
.ok_or("Invalid path")?,
12491255
)
12501256
.spawn()
1251-
.map_err(|e| format!("Failed to open folder: {}", e))?;
1257+
.map_err(|e| format!("Failed to open folder: {e}"))?;
12521258
}
12531259

12541260
Ok(())
@@ -2337,6 +2343,7 @@ pub async fn run(recording_logging_handle: LoggingHandle, logs_dir: PathBuf) {
23372343
set_camera_input,
23382344
recording_settings::set_recording_mode,
23392345
upload_logs,
2346+
get_system_diagnostics,
23402347
recording::start_recording,
23412348
recording::stop_recording,
23422349
recording::pause_recording,

0 commit comments

Comments
 (0)