← back to derio-net__vscode-launchpad

Function bodies 82 total

All specs Real LLM only Function bodies
tray_workspace_deserializes_from_api_json function · rust · L406-L420 (15 LOC)
src-tauri/src/tray.rs
    fn tray_workspace_deserializes_from_api_json() {
        let json = r#"[
            {"id": "ws-1", "name": "my-project", "path": "/home/user/my-project", "type": "local", "lastAccessed": "2026-03-09T10:00:00Z"},
            {"id": "ws-2", "name": "other-project", "path": "/home/user/other", "type": "ssh-remote", "lastAccessed": "2026-03-08T10:00:00Z"}
        ]"#;

        let workspaces: Vec<TrayWorkspace> = serde_json::from_str(json).unwrap();
        assert_eq!(workspaces.len(), 2);
        assert_eq!(workspaces[0].id, "ws-1");
        assert_eq!(workspaces[0].name, "my-project");
        assert_eq!(workspaces[0].path, "/home/user/my-project");
        assert_eq!(workspaces[0].workspace_type, "local");
        assert_eq!(workspaces[0].last_accessed, "2026-03-09T10:00:00Z");
        assert_eq!(workspaces[1].workspace_type, "ssh-remote");
    }
tray_workspace_deserializes_with_extra_fields function · rust · L423-L430 (8 LOC)
src-tauri/src/tray.rs
    fn tray_workspace_deserializes_with_extra_fields() {
        // The API returns more fields than TrayWorkspace needs — verify it ignores extras
        let json = r#"{"id": "abc123", "name": "proj", "path": "/p", "lastAccessed": "2026-01-01T00:00:00Z", "type": "local", "size": 1024}"#;
        let ws: TrayWorkspace = serde_json::from_str(json).unwrap();
        assert_eq!(ws.id, "abc123");
        assert_eq!(ws.name, "proj");
        assert_eq!(ws.workspace_type, "local");
    }
tray_workspace_type_defaults_when_missing function · rust · L433-L437 (5 LOC)
src-tauri/src/tray.rs
    fn tray_workspace_type_defaults_when_missing() {
        let json = r#"{"id": "ws-1", "name": "proj", "path": "/p", "lastAccessed": "2026-01-01T00:00:00Z"}"#;
        let ws: TrayWorkspace = serde_json::from_str(json).unwrap();
        assert_eq!(ws.workspace_type, "");
    }
workspaces_sort_by_last_accessed_descending function · rust · L440-L452 (13 LOC)
src-tauri/src/tray.rs
    fn workspaces_sort_by_last_accessed_descending() {
        let mut workspaces = vec![
            TrayWorkspace { id: "1".into(), name: "old".into(), path: "/old".into(), workspace_type: "local".into(), last_accessed: "2026-01-01T00:00:00Z".into() },
            TrayWorkspace { id: "2".into(), name: "newest".into(), path: "/new".into(), workspace_type: "local".into(), last_accessed: "2026-03-09T00:00:00Z".into() },
            TrayWorkspace { id: "3".into(), name: "mid".into(), path: "/mid".into(), workspace_type: "local".into(), last_accessed: "2026-02-01T00:00:00Z".into() },
        ];

        workspaces.sort_by(|a, b| b.last_accessed.cmp(&a.last_accessed));

        assert_eq!(workspaces[0].name, "newest");
        assert_eq!(workspaces[1].name, "mid");
        assert_eq!(workspaces[2].name, "old");
    }
workspaces_limited_to_ten function · rust · L455-L467 (13 LOC)
src-tauri/src/tray.rs
    fn workspaces_limited_to_ten() {
        let workspaces: Vec<TrayWorkspace> = (0..15).map(|i| TrayWorkspace {
            id: format!("ws-{}", i),
            name: format!("project-{}", i),
            path: format!("/path/{}", i),
            workspace_type: "local".into(),
            last_accessed: format!("2026-03-{:02}T00:00:00Z", i + 1),
        }).collect();

        let shown: Vec<_> = workspaces.iter().take(10).collect();
        assert_eq!(shown.len(), 10);
        assert_eq!(workspaces.len(), 15);
    }
type_emoji_maps_all_known_types function · rust · L472-L478 (7 LOC)
src-tauri/src/tray.rs
    fn type_emoji_maps_all_known_types() {
        assert_eq!(type_emoji("local"), "🔵");
        assert_eq!(type_emoji("ssh-remote"), "🟣");
        assert_eq!(type_emoji("dev-container"), "🟢");
        assert_eq!(type_emoji("attached-container"), "🟡");
        assert_eq!(type_emoji("remote"), "🩷");
    }
type_emoji_unknown_and_empty_fallback function · rust · L481-L484 (4 LOC)
src-tauri/src/tray.rs
    fn type_emoji_unknown_and_empty_fallback() {
        assert_eq!(type_emoji(""), "⚪");
        assert_eq!(type_emoji("something-new"), "⚪");
    }
Same scanner, your repo: https://repobility.com — Repobility
is_remote_type_identifies_remote_types function · rust · L489-L494 (6 LOC)
src-tauri/src/tray.rs
    fn is_remote_type_identifies_remote_types() {
        assert!(is_remote_type("ssh-remote"));
        assert!(is_remote_type("dev-container"));
        assert!(is_remote_type("attached-container"));
        assert!(is_remote_type("remote"));
    }
is_remote_type_rejects_local_and_unknown function · rust · L497-L501 (5 LOC)
src-tauri/src/tray.rs
    fn is_remote_type_rejects_local_and_unknown() {
        assert!(!is_remote_type("local"));
        assert!(!is_remote_type(""));
        assert!(!is_remote_type("unknown"));
    }
workspace_label_valid_local function · rust · L506-L516 (11 LOC)
src-tauri/src/tray.rs
    fn workspace_label_valid_local() {
        let emoji = type_emoji("local");
        let is_valid = true;
        let name = "my-project";
        let label = if is_valid {
            format!("{} {}", emoji, name)
        } else {
            format!("{} ✗ {}", emoji, name)
        };
        assert_eq!(label, "🔵 my-project");
    }
workspace_label_invalid_local function · rust · L519-L529 (11 LOC)
src-tauri/src/tray.rs
    fn workspace_label_invalid_local() {
        let emoji = type_emoji("local");
        let is_valid = false;
        let name = "deleted-project";
        let label = if is_valid {
            format!("{} {}", emoji, name)
        } else {
            format!("{} ✗ {}", emoji, name)
        };
        assert_eq!(label, "🔵 ✗ deleted-project");
    }
workspace_label_remote_always_valid_even_if_validation_says_false function · rust · L532-L538 (7 LOC)
src-tauri/src/tray.rs
    fn workspace_label_remote_always_valid_even_if_validation_says_false() {
        // Remote workspaces should never show as invalid
        let ws_type = "ssh-remote";
        let validation_says_invalid = false;
        let is_valid = is_remote_type(ws_type) || validation_says_invalid;
        assert!(is_valid, "Remote workspaces must always be treated as valid");
    }
workspace_label_valid_when_no_validity_data function · rust · L541-L546 (6 LOC)
src-tauri/src/tray.rs
    fn workspace_label_valid_when_no_validity_data() {
        // When validity map is empty (API failure fallback), workspaces default to valid
        let validity: HashMap<String, bool> = HashMap::new();
        let is_valid = validity.get("/some/path").copied().unwrap_or(true);
        assert!(is_valid, "Missing validity data should default to valid");
    }
validate_response_parsing function · rust · L551-L578 (28 LOC)
src-tauri/src/tray.rs
    fn validate_response_parsing() {
        // Simulate the JSON response from /api/validate-paths
        let response_json = r#"{"results": {"ws-1": true, "ws-2": false, "ws-3": true}}"#;

        #[derive(Deserialize)]
        struct ValidateResponse {
            results: HashMap<String, bool>,
        }
        let parsed: ValidateResponse = serde_json::from_str(response_json).unwrap();

        // Convert id-keyed results to path-keyed
        let workspaces = vec![
            TrayWorkspace { id: "ws-1".into(), name: "proj1".into(), path: "/path/1".into(), workspace_type: "local".into(), last_accessed: "".into() },
            TrayWorkspace { id: "ws-2".into(), name: "proj2".into(), path: "/path/2".into(), workspace_type: "local".into(), last_accessed: "".into() },
            TrayWorkspace { id: "ws-3".into(), name: "proj3".into(), path: "/path/3".into(), workspace_type: "ssh-remote".into(), last_accessed: "".into() },
        ];

        let mut path_validity = HashMap::new()
convert_local_path_to_vscode_uri function · rust · L583-L599 (17 LOC)
src-tauri/src/tray.rs
    fn convert_local_path_to_vscode_uri() {
        let uri = convert_to_vscode_uri("/Users/dev/my-project", "local");
        assert_eq!(uri, "vscode://file/Users/dev/my-project");
    }

    #[test]
    fn convert_local_file_uri_to_vscode_uri() {
        // Raw path from API may have file:// prefix
        let uri = convert_to_vscode_uri("file:///Users/dev/my-project", "local");
        assert_eq!(uri, "vscode://file/Users/dev/my-project");
    }

    #[test]
    fn convert_local_path_with_spaces() {
        let uri = convert_to_vscode_uri("/Users/dev/my project", "local");
        assert_eq!(uri, "vscode://file/Users/dev/my%20project");
    }
Methodology: Repobility · https://repobility.com/research/state-of-ai-code-2026/
convert_local_file_uri_to_vscode_uri function · rust · L589-L593 (5 LOC)
src-tauri/src/tray.rs
    fn convert_local_file_uri_to_vscode_uri() {
        // Raw path from API may have file:// prefix
        let uri = convert_to_vscode_uri("file:///Users/dev/my-project", "local");
        assert_eq!(uri, "vscode://file/Users/dev/my-project");
    }
convert_local_path_with_spaces function · rust · L596-L640 (45 LOC)
src-tauri/src/tray.rs
    fn convert_local_path_with_spaces() {
        let uri = convert_to_vscode_uri("/Users/dev/my project", "local");
        assert_eq!(uri, "vscode://file/Users/dev/my%20project");
    }

    #[test]
    fn convert_local_path_with_encoded_spaces() {
        // API may return percent-encoded paths
        let uri = convert_to_vscode_uri("file:///Users/dev/my%20project", "local");
        assert_eq!(uri, "vscode://file/Users/dev/my%20project");
    }

    #[test]
    fn convert_ssh_remote_uri() {
        let uri = convert_to_vscode_uri(
            "vscode-remote://ssh-remote+myhost/home/user/project",
            "ssh-remote",
        );
        assert_eq!(uri, "vscode://vscode-remote/ssh-remote+myhost/home/user/project");
    }

    #[test]
    fn convert_dev_container_uri() {
        let uri = convert_to_vscode_uri(
            "vscode-remote://dev-container+abc123/workspace",
            "dev-container",
        );
        assert_eq!(uri, "vscode://vscode-remote/dev-container+abc123
convert_local_path_with_encoded_spaces function · rust · L602-L606 (5 LOC)
src-tauri/src/tray.rs
    fn convert_local_path_with_encoded_spaces() {
        // API may return percent-encoded paths
        let uri = convert_to_vscode_uri("file:///Users/dev/my%20project", "local");
        assert_eq!(uri, "vscode://file/Users/dev/my%20project");
    }
convert_ssh_remote_uri function · rust · L609-L615 (7 LOC)
src-tauri/src/tray.rs
    fn convert_ssh_remote_uri() {
        let uri = convert_to_vscode_uri(
            "vscode-remote://ssh-remote+myhost/home/user/project",
            "ssh-remote",
        );
        assert_eq!(uri, "vscode://vscode-remote/ssh-remote+myhost/home/user/project");
    }
convert_dev_container_uri function · rust · L618-L624 (7 LOC)
src-tauri/src/tray.rs
    fn convert_dev_container_uri() {
        let uri = convert_to_vscode_uri(
            "vscode-remote://dev-container+abc123/workspace",
            "dev-container",
        );
        assert_eq!(uri, "vscode://vscode-remote/dev-container+abc123/workspace");
    }
convert_attached_container_uri function · rust · L627-L633 (7 LOC)
src-tauri/src/tray.rs
    fn convert_attached_container_uri() {
        let uri = convert_to_vscode_uri(
            "vscode-remote://attached-container+abc/workspace",
            "attached-container",
        );
        assert_eq!(uri, "vscode://vscode-remote/attached-container+abc/workspace");
    }
convert_unknown_type_treated_as_local function · rust · L636-L654 (19 LOC)
src-tauri/src/tray.rs
    fn convert_unknown_type_treated_as_local() {
        // Unknown or empty type should be treated as local
        let uri = convert_to_vscode_uri("/some/path", "");
        assert_eq!(uri, "vscode://file/some/path");
    }

    #[test]
    fn raw_path_without_conversion_opens_finder_not_vscode() {
        // This test documents the bug: a raw filesystem path passed to open_url
        // would open Finder (macOS) instead of VS Code.
        // The raw path does NOT start with vscode://, so the OS opens it as a file.
        let raw_path = "file:///Users/dev/my-project";
        assert!(!raw_path.starts_with("vscode://"),
            "Raw API paths don't have vscode:// scheme — they open in Finder, not VS Code");

        let converted = convert_to_vscode_uri(raw_path, "local");
        assert!(converted.starts_with("vscode://"),
            "Converted URI must use vscode:// scheme to open in VS Code");
    }
from_window function · rust · L17-L32 (16 LOC)
src-tauri/src/window_state.rs
    pub fn from_window(window: &WebviewWindow) -> Option<Self> {
        let scale_factor = window.scale_factor().ok()?;
        let size = window.inner_size().ok()?;
        let position = window.outer_position().ok()?;

        let logical_size: LogicalSize<u32> = size.to_logical(scale_factor);
        let logical_pos: LogicalPosition<i32> = position.to_logical(scale_factor);

        Some(Self {
            width: logical_size.width,
            height: logical_size.height,
            x: logical_pos.x,
            y: logical_pos.y,
            maximized: window.is_maximized().unwrap_or(false),
        })
    }
Want fix-PRs on findings? Install Repobility's GitHub App · github.com/apps/repobility-bot
get_state_path function · rust · L34-L40 (7 LOC)
src-tauri/src/window_state.rs
fn get_state_path(app: &AppHandle) -> PathBuf {
    app.path()
        .app_config_dir()
        .unwrap_or_else(|_| std::env::temp_dir())
        .join(WINDOW_STATE_FILE)
}
save_window_state function · rust · L41-L50 (10 LOC)
src-tauri/src/window_state.rs
pub fn save_window_state(app: &AppHandle, window: &WebviewWindow) {
    if let Some(state) = WindowState::from_window(window) {
        let state_path = get_state_path(app);

        if let Ok(json) = serde_json::to_string_pretty(&state) {
            let _ = std::fs::write(&state_path, json);
        }
    }
}
restore_window_state function · rust · L51-L89 (39 LOC)
src-tauri/src/window_state.rs
pub fn restore_window_state(app: &AppHandle, window: &WebviewWindow) {
    let state_path = get_state_path(app);

    if let Ok(content) = std::fs::read_to_string(&state_path) {
        if let Ok(state) = serde_json::from_str::<WindowState>(&content) {
            // Check if window position is valid (not off-screen)
            let monitors = window.available_monitors().unwrap_or_default();
            let mut is_valid_position = false;

            for monitor in monitors {
                let monitor_pos = monitor.position();
                let monitor_size = monitor.size();

                // Check if window is at least partially visible on this monitor
                if (state.x as i32) < (monitor_pos.x + monitor_size.width as i32)
                    && (state.x as i32 + state.width as i32) > monitor_pos.x
                    && (state.y as i32) < (monitor_pos.y + monitor_size.height as i32)
                    && (state.y as i32 + state.height as i32) > monitor_pos.y
       
decodeHexHost function · javascript · L8-L26 (19 LOC)
src/utils/workspaceUtils.js
export function decodeHexHost(hexString) {
  let decoded = '';
  for (let i = 0; i < hexString.length; i += 2) {
    const byte = parseInt(hexString.substring(i, i + 2), 16);
    if (isNaN(byte)) {
      throw new Error('Invalid hex character at position ' + i);
    }
    decoded += String.fromCharCode(byte);
  }
  const parsed = JSON.parse(decoded);
  if (!parsed.hostName || typeof parsed.hostName !== 'string') {
    throw new Error('Missing or invalid hostName in decoded JSON');
  }
  return {
    hostName: parsed.hostName,
    ...(parsed.user && { user: parsed.user }),
    ...(parsed.port !== undefined && { port: parsed.port }),
  };
}
formatConnectionInfo function · javascript · L34-L44 (11 LOC)
src/utils/workspaceUtils.js
export function formatConnectionInfo({ hostName, user, port }) {
  let result = '';
  if (user) {
    result += user + '@';
  }
  result += hostName;
  if (port !== undefined) {
    result += ':' + port;
  }
  return result;
}
extractConnectionInfo function · javascript · L55-L72 (18 LOC)
src/utils/workspaceUtils.js
export function extractConnectionInfo(workspace) {
  const rawHost = _extractRawHost(workspace);
  if (!rawHost) {
    return { display: '' };
  }

  // Detect hex-encoded JSON: always starts with 7b22 (hex for '{"')
  if (rawHost.startsWith('7b22')) {
    try {
      const info = decodeHexHost(rawHost);
      return { display: formatConnectionInfo(info), raw: rawHost };
    } catch {
      return { display: '\u26a0 decode error', error: true, raw: rawHost };
    }
  }

  return { display: rawHost };
}
_extractRawHost function · javascript · L78-L101 (24 LOC)
src/utils/workspaceUtils.js
function _extractRawHost(workspace) {
  const path = workspace.path;
  const type = workspace.type;

  // Handle any URI with @ssh-remote%2B (e.g., attached-container on remote host)
  const remoteMatch = path.match(/@ssh-remote%2B([^/]+)/);
  if (remoteMatch) {
    return decodeURIComponent(remoteMatch[1]);
  }

  if (type === 'ssh-remote' && path.includes('ssh-remote')) {
    // Handle URL-encoded format: vscode-remote://ssh-remote%2Bhost/path
    const encodedMatch = path.match(/ssh-remote%2B([^/]+)/);
    if (encodedMatch) {
      return decodeURIComponent(encodedMatch[1]);
    }
    // Handle vscode://vscode-remote/ssh-remote+host@/path format
    const match = path.match(/ssh-remote\+([^@/]+)/);
    if (match) {
      return match[1];
    }
  }
  return '';
}
extractSSHHost function · javascript · L106-L108 (3 LOC)
src/utils/workspaceUtils.js
export function extractSSHHost(workspace) {
  return extractConnectionInfo(workspace).display;
}
All rows scored by the Repobility analyzer (https://repobility.com)
extractWorkspacePath function · javascript · L116-L154 (39 LOC)
src/utils/workspaceUtils.js
export function extractWorkspacePath(workspace) {
  const path = workspace.path;
  const type = workspace.type;

  if (type === 'local') {
    let cleanPath = path;
    if (cleanPath.startsWith('file://')) {
      cleanPath = cleanPath.substring(7);
    }
    try {
      return decodeURIComponent(cleanPath);
    } catch (e) {
      return cleanPath;
    }
  } else if (type === 'ssh-remote') {
    const encodedMatch = path.match(/ssh-remote%2B[^/]+(.+)$/);
    if (encodedMatch) {
      return encodedMatch[1];
    }
    const match = path.match(/ssh-remote\+[^@/]+@?(.+)$/);
    if (match) {
      return match[1];
    }
    return path;
  } else if (type === 'dev-container' || type === 'attached-container') {
    // For containers on remote SSH hosts: extract path after @ssh-remote%2B<host>
    const remoteMatch = path.match(/@ssh-remote%2B[^/]+(\/.*)/);
    if (remoteMatch) {
      return remoteMatch[1];
    }
    // For local containers, try to extract the path portion (+ may be literal
‹ prevpage 2 / 2