mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 09:01:17 +00:00
fix: address PR #264 review issues
- Fix connectDesktopStream silently dropping RTCPeerConnection and rtcConfig options (client.ts) - Fix DesktopViewer useEffect dependency causing reconnect loop (store callbacks in refs) - Fix TOCTOU race condition in DesktopRecordingManager::start() (merge lock scope) - Fix incomplete cursor bounds check in composite_cursor_region (add right/bottom checks) - Add DesktopViewer to react-components.mdx documentation - Remove hardcoded visual styles from DesktopViewer (make unstyled by default per sdks/CLAUDE.md) - Export DesktopViewerClassNames type for consumer styling Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
f25a92aca8
commit
bdd7526de5
6 changed files with 101 additions and 79 deletions
|
|
@ -64,17 +64,13 @@ impl DesktopRecordingManager {
|
|||
|
||||
self.ensure_recordings_dir()?;
|
||||
|
||||
{
|
||||
let mut state = self.inner.lock().await;
|
||||
self.refresh_locked(&mut state).await?;
|
||||
if state.current_id.is_some() {
|
||||
return Err(SandboxError::Conflict {
|
||||
message: "a desktop recording is already active".to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let mut state = self.inner.lock().await;
|
||||
self.refresh_locked(&mut state).await?;
|
||||
if state.current_id.is_some() {
|
||||
return Err(SandboxError::Conflict {
|
||||
message: "a desktop recording is already active".to_string(),
|
||||
});
|
||||
}
|
||||
let id_num = state.next_id + 1;
|
||||
state.next_id = id_num;
|
||||
let id = format!("rec_{id_num}");
|
||||
|
|
|
|||
|
|
@ -2036,14 +2036,18 @@ impl DesktopRuntime {
|
|||
options: &DesktopScreenshotOptions,
|
||||
region_x: i32,
|
||||
region_y: i32,
|
||||
_region_width: u32,
|
||||
_region_height: u32,
|
||||
region_width: u32,
|
||||
region_height: u32,
|
||||
) -> Result<Vec<u8>, DesktopProblem> {
|
||||
let pos = self.mouse_position_locked(state, ready).await?;
|
||||
// Adjust cursor position relative to the region
|
||||
let cursor_x = pos.x - region_x;
|
||||
let cursor_y = pos.y - region_y;
|
||||
if cursor_x < 0 || cursor_y < 0 {
|
||||
if cursor_x < 0
|
||||
|| cursor_y < 0
|
||||
|| cursor_x >= region_width as i32
|
||||
|| cursor_y >= region_height as i32
|
||||
{
|
||||
// Cursor is outside the region, return screenshot as-is
|
||||
return Ok(screenshot_bytes);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue