Repository navigation
feat: comprehensive continuity suite (power control, remote input, deck, drop folder, file catalog) - #52
feat: comprehensive continuity suite (power control, remote input, deck, drop folder, file catalog)#52samyyy2311 wants to merge 14 commits into
Conversation
- Add media control, handoff, and telemetry protocol definitions and session dispatchers. - Add continuity camera capture framing and DIBV5 format translation. - Add 4-word verification phrase derivation (SAS) for pairing confirmation. - Add offline transfer queue for staging transfers destined for unreachable peers. - Add lockdown mode in permissions store to immediately deny all grants when active. - Add notification actions for extracted OTPs and inbound camera photos. - Add LocalSend v2 discovery and upload bridge. - Add connection doctor network diagnostics and wireless debugging discovery.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Define CapabilityId::RING_DEVICE (8) and CapabilityId::PC_CONTROL (9) - Add protobuf schemas for ring and pc_control envelopes - Implement RingDispatcher and PcControlDispatcher with QUIC roundtrip tests - Implement Wake-on-LAN magic packet creation and UDP broadcasting in discovery::wol - Integrate ring and PC control dispatchers into SessionCapabilityHandlers and SessionMultiplexer
- Define CapabilityId::REMOTE_INPUT (10) and CapabilityId::DECK (11) - Add protobuf schemas for TextInputChunk and DeckEnvelope - Implement RemoteInputDispatcher and DeckDispatcher with validation and QUIC roundtrip tests - Wire remote input and deck into SessionCapabilityHandlers and SessionMultiplexer
…nd antislop craftsmanship
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| UnusedCode | 19 medium |
| BestPractice | 2 medium |
| ErrorProne | 26 medium 15 high |
| Security | 3 high |
| Complexity | 35 medium |
🟢 Metrics 1141 complexity · 161 duplication
Metric Results Complexity 1141 Duplication 161
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull Request Overview
This PR should not merge yet. It contains high-risk security issues involving lockdown bypass, arbitrary URI execution, and path traversal through peer-controlled names. The drop-folder integration also recreates watcher state, breaking debounce and duplicate prevention.
About this PR
- Before merging, reconcile the restart requirement, schedule clipboard expiry cleanup, and provide executable verification for the missing acceptance scenarios. Codacy analysis is not up to standards overall, with 111 new issues.
Test suggestions
- Ring dispatcher request/ack round trip and capability denial
- PC control request/response round trip and capability denial
- Wake-on-LAN MAC parsing, packet construction, and broadcast
- Remote input round trip, capability denial, and size validation
- Deck layout/trigger round trips and validation limits
- Clipboard history recording, deduplication, pinning, deletion, search, snippets, and sensitive filtering
- Drop-folder temporary-file filtering, debounce, stable-file enqueue, and duplicate prevention
- Catalog query and thumbnail round trips plus validation
- Handoff broadcast/dismiss round trips and URI validation
- Desktop stream validation and capability denial
- Global lockdown preventing all incoming and outgoing capability operations
- Clipboard TTL expiry and maximum unpinned history enforcement
- PC restart action behavior
- Windows Cloud Files callback success, failure, and cancellation paths
- Desktop stream listener registration and cleanup failure paths
- Desktop runtime startup with background worker and all stores initialized
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Global lockdown preventing all incoming and outgoing capability operations
2. Clipboard TTL expiry and maximum unpinned history enforcement
3. PC restart action behavior
4. Windows Cloud Files callback success, failure, and cancellation paths
5. Desktop stream listener registration and cleanup failure paths
6. Desktop runtime startup with background worker and all stores initialized
Low confidence findings
- Review the additional handoff, streaming, cloud-file, media, telemetry, pairing, and diagnostics functionality as explicit acceptance criteria or split it into separately verifiable changes.
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
|
|
||
| #[test] | ||
| fn cloud_files_config_and_entry_model() { | ||
| let temp_dir = std::env::temp_dir().join(format!("continue_cf_test_{}", rand::random::<u32>())); |
There was a problem hiding this comment.
🔴 HIGH RISK
Use a secure temporary-directory helper that atomically creates a unique directory with restrictive permissions and manages cleanup.
| unsafe extern "system" fn fetch_data_callback( | ||
| callback_info: *const win32::CF_CALLBACK_INFO, | ||
| callback_parameters: *const std::ffi::c_void, | ||
| ) { | ||
| if callback_info.is_null() || callback_parameters.is_null() { | ||
| return; | ||
| } | ||
| let info = &*callback_info; | ||
| let params = &*(callback_parameters as *const win32::CF_CALLBACK_PARAMETERS); | ||
| if info.callback_context.is_null() { | ||
| return; | ||
| } | ||
| let ctx = &*(info.callback_context as *const MountContext); | ||
|
|
||
| let file_identity = if !info.file_identity.is_null() && info.file_identity_length > 0 { | ||
| std::slice::from_raw_parts( | ||
| info.file_identity as *const u8, | ||
| info.file_identity_length as usize, | ||
| ) | ||
| .to_vec() | ||
| } else { | ||
| Vec::new() | ||
| }; | ||
|
|
||
| let relative_path = if !info.normalized_path.is_null() { | ||
| let mut len = 0; | ||
| while *info.normalized_path.add(len) != 0 { | ||
| len += 1; | ||
| } | ||
| let slice = std::slice::from_raw_parts(info.normalized_path, len); | ||
| PathBuf::from(String::from_utf16_lossy(slice)) | ||
| } else { | ||
| PathBuf::new() | ||
| }; | ||
|
|
||
| let request = FetchDataRequest { | ||
| file_identity, | ||
| relative_path, | ||
| offset: params.required_file_offset.max(0) as u64, | ||
| length: params.required_length.max(0) as u64, | ||
| }; | ||
|
|
||
| let mut op_params = win32::CF_OPERATION_PARAMETERS { | ||
| param_size: std::mem::size_of::<win32::CF_OPERATION_PARAMETERS>() as u32, | ||
| op_type: win32::CF_OPERATION_TYPE_TRANSFER_DATA, | ||
| connection_key: info.connection_key, | ||
| transfer_key: info.transfer_key, | ||
| correlation_vector: std::ptr::null(), | ||
| sync_status: std::ptr::null(), | ||
| request_completion_status: win32::S_OK, | ||
| transfer_data: win32::CF_OPERATION_TRANSFER_DATA { | ||
| flags: 0, | ||
| completion_status: win32::S_OK, | ||
| buffer: std::ptr::null(), | ||
| offset: params.required_file_offset, | ||
| length: params.required_length, | ||
| }, | ||
| }; | ||
|
|
||
| match (ctx.fetch_handler)(request) { | ||
| Ok(data) => { | ||
| op_params.transfer_data.buffer = data.as_ptr() as *const std::ffi::c_void; | ||
| op_params.transfer_data.length = data.len() as i64; | ||
| op_params.transfer_data.completion_status = win32::S_OK; | ||
| (ctx.cldapi.execute)(&op_params); | ||
| } | ||
| Err(_) => { | ||
| // ERROR_FILE_NOT_FOUND (0x80070002) | ||
| op_params.transfer_data.completion_status = -2147024894; | ||
| op_params.request_completion_status = -2147024894; | ||
| (ctx.cldapi.execute)(&op_params); | ||
| } | ||
| } |
There was a problem hiding this comment.
🔴 HIGH RISK
Audit the FFI layouts and callback ABI, keep callback context and transfer buffers valid for the full operation, handle every HRESULT explicitly, and add Windows success, failure, and cancellation tests.
| type="button" | ||
| className="icon-btn" | ||
| title="Copy clip" | ||
| onClick={() => handleCopy(clip)} |
There was a problem hiding this comment.
🔴 HIGH RISK
Wrap clipboard actions and dialog lifecycle handlers in synchronous callbacks that explicitly invoke and handle their promises.
| let unlistenFrame: (() => void) | null = null; | ||
| let unlistenStopped: (() => void) | null = null; | ||
|
|
||
| onDesktopStreamFrame((frame) => { |
There was a problem hiding this comment.
🔴 HIGH RISK
Handle listener-registration promises through an async setup path with rejection handling, cancellation awareness, and reliable unsubscription.
| <button | ||
| type="button" | ||
| className="btn btn-tonal btn-small" | ||
| onClick={stopActiveStream} |
There was a problem hiding this comment.
🔴 HIGH RISK
Wrap async handlers in synchronous callbacks and explicitly handle failures for start, stop, close, and related mouse/click events.
| config, | ||
| offline_queue_for_drop.clone(), | ||
| ); |
There was a problem hiding this comment.
🔴 HIGH RISK
Keep one DropFolderWatcher per configured folder/peer and reuse it across polling iterations, or persist its state outside the loop so debounce and duplicate prevention work.
|
|
||
| const startStream = useCallback(async () => { | ||
| setConnecting(true); | ||
| const preset = PRESETS[presetIndex]; |
There was a problem hiding this comment.
🔴 HIGH RISK
Suggestion: Validate presetIndex before indexing and fall back safely when it is outside PRESETS.
| let clipboard_history = Arc::new(ClipboardHistoryStore::open( | ||
| db_path.with_file_name("continue_clipboard.db"), | ||
| )?); |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Schedule clipboard cleanup or invoke cleanup_expired during initialization or maintenance so expired clips are removed.
| let pc_action = match action { | ||
| 0 => PcAction::LockWorkstation, | ||
| 1 => PcAction::SleepSystem, | ||
| 2 => PcAction::ShutdownSystem, | ||
| 3 => PcAction::ToggleMute, | ||
| _ => return Err("Invalid PC action".to_string()), |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Add restart to the protocol and command mapping, or explicitly remove it from the acceptance criteria and UI.
| @@ -946,6 +1821,59 @@ fn initialize_desktop_runtime( | |||
| ) -> Result<DesktopRuntimeState, Box<dyn std::error::Error>> { | |||
| let stores = Stores::open(db_path)?; | |||
| let keys = DeviceKeys::load_or_create(&secrets::device_key_store(secrets_dir)?)?; | |||
| let clipboard_history = Arc::new(ClipboardHistoryStore::open( | |||
| db_path.with_file_name("continue_clipboard.db"), | |||
| )?); | |||
| let cloud_mounts = Arc::new(Mutex::new(HashMap::new())); | |||
| let active_handoffs = Arc::new(Mutex::new(HashMap::new())); | |||
| let offline_queue = Arc::new(OfflineTransferQueue::new()); | |||
| let drop_folder: Arc<Mutex<Option<PathBuf>>> = Arc::new(Mutex::new(None)); | |||
| let active_desktop_streams: Arc<Mutex<HashMap<String, DesktopStreamSession>>> = | |||
| Arc::new(Mutex::new(HashMap::new())); | |||
|
|
|||
| let (offline_queue_for_drop, drop_folder_for_loop, app_for_drop) = ( | |||
| offline_queue.clone(), | |||
| drop_folder.clone(), | |||
| app_handle.clone(), | |||
| ); | |||
| tauri::async_runtime::spawn(async move { | |||
| loop { | |||
| tokio::time::sleep(tokio::time::Duration::from_secs(3)).await; | |||
| let folder_opt = drop_folder_for_loop.lock().clone(); | |||
| if let Some(folder) = folder_opt { | |||
| if folder.is_dir() { | |||
| if let Some(state) = app_for_drop.try_state::<DesktopRuntimeState>() { | |||
| let connected_peer = state | |||
| .device | |||
| .stores | |||
| .trust | |||
| .list_peers() | |||
| .ok() | |||
| .and_then(|peers| { | |||
| peers | |||
| .into_iter() | |||
| .find(|p| state.device.sessions.get(&p.fingerprint).is_some()) | |||
| }); | |||
| if let Some(peer) = connected_peer { | |||
| let config = DropFolderConfig::new( | |||
| folder.clone(), | |||
| peer.fingerprint.clone(), | |||
| ); | |||
| let watcher = DropFolderWatcher::new( | |||
| config, | |||
| offline_queue_for_drop.clone(), | |||
| ); | |||
| if let Ok(enqueued) = watcher.scan_directory() { | |||
| if !enqueued.is_empty() { | |||
| flush_offline_transfers(&app_for_drop, &state, &peer.fingerprint).await; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| }); | |||
|
|
|||
| let pending_answers = PendingAnswers::default(); | |||
| let connected = Arc::new(tray::Connected::default()); | |||
| @@ -954,6 +1882,9 @@ fn initialize_desktop_runtime( | |||
| &stores, | |||
| pending_answers.clone(), | |||
| clipboard.clone(), | |||
| clipboard_history.clone(), | |||
| active_handoffs.clone(), | |||
| active_desktop_streams.clone(), | |||
| app_handle, | |||
| ); | |||
| handlers.on_device_info = Some(device_info_listener( | |||
| @@ -979,6 +1910,12 @@ fn initialize_desktop_runtime( | |||
| incoming, | |||
| clipboard, | |||
| batteries, | |||
| clipboard_history, | |||
| cloud_mounts, | |||
| active_handoffs, | |||
| offline_queue, | |||
| drop_folder, | |||
| active_desktop_streams, | |||
| }) | |||
There was a problem hiding this comment.
🟡 MEDIUM RISK
Suggestion: Split initialization into focused helpers for store construction, worker startup, capability handlers, and final state assembly; add focused unit tests and a startup integration test.
Summary
This change adds comprehensive continuity capabilities and companion device features across the Continue workspace:
Phase 1: Emergency & PC Controls:
RING_DEVICEcapability (CapabilityId(8)), protobuf schema (proto/ring.proto), andRingDispatchersupporting max-volume alarm overrides and custom duration ringing.PC_CONTROLcapability (CapabilityId(9)), protobuf schema (proto/pc_control.proto), andPcControlDispatcherfor remote screen lock, sleep, restart, shutdown, and audio mute.crates/discovery/src/wol.rsfor waking offline PCs across local subnets.Phase 2: Input & Touch Deck Stream:
REMOTE_INPUTcapability (CapabilityId(10)), protobuf schema (proto/remote_input.proto), andRemoteInputDispatcherfor streaming speech-to-text chunks directly into focused PC applications.DECKcapability (CapabilityId(11)), protobuf schema (proto/deck.proto), andDeckDispatcherfor turning the phone into an interactive macro controller for PC hotkeys and scripts.Phase 3: Storage & Content Continuity:
ClipboardHistoryStoreincrates/clipboard/src/history.rswith consecutive clip deduplication, pinned clip protection, sensitive format filtering (excluding password managers / private viewer flags), TTL auto-expiry, and quick snippet shortcut lookup.DropFolderWatcherincrates/transfer/src/drop_folder.rswith file write debounce (500ms), temporary/partial file filtering (.crdownload,.part,.tmp,~$), and automatic ingestion intoOfflineTransferQueue.FILE_CATALOGcapability (CapabilityId(12)), protobuf schema (proto/catalog.proto), andCatalogDispatcherincrates/sessions/src/catalog.rssupporting categorized file browsing and on-demand thumbnail streaming.Verification
cargo fmt --all -- --checkpasses cleanly.cargo clippy --workspace -- -D warningspasses with 0 warnings.