Skip to content

Implement DiscoveredProject and ProjectGroup models #97

@doomspork

Description

@doomspork

Context

Models for project discovery results and sidebar grouping. DiscoveredProject represents a found project with metadata. ProjectGroup groups projects by parent directory for sidebar display.

Ported from: Fig/Sources/Models/DiscoveredProject.swift, Fig/Sources/Models/ProjectGroup.swift

What to implement

File paths

  • fig-core/src/models/discovered_project.rs
  • fig-core/src/models/project_group.rs

Rust definitions

// discovered_project.rs
use chrono::{DateTime, Utc};

#[derive(Debug, Clone, PartialEq)]
pub struct DiscoveredProject {
    pub path: String,
    pub display_name: String,
    pub exists: bool,
    pub has_settings: bool,
    pub has_local_settings: bool,
    pub has_mcp_config: bool,
    pub last_modified: Option<DateTime<Utc>>,
}

impl DiscoveredProject {
    pub fn has_any_config(&self) -> bool {
        self.has_settings || self.has_local_settings || self.has_mcp_config
    }
}

// project_group.rs
use super::project_entry::ProjectEntry;

#[derive(Debug, Clone)]
pub struct ProjectGroup {
    pub parent_path: String,
    pub display_name: String,
    pub projects: Vec<ProjectEntry>,
}

impl ProjectGroup {
    /// Creates display name by abbreviating home directory with ~
    pub fn abbreviated_path(path: &str) -> String {
        if let Some(home) = dirs::home_dir() {
            if let Some(home_str) = home.to_str() {
                if path.starts_with(home_str) {
                    return format!("~{}", &path[home_str.len()..]);
                }
            }
        }
        path.to_string()
    }
}

Acceptance criteria

  • has_any_config() returns true when any config file exists
  • abbreviated_path replaces home directory with ~
  • Both types implement Debug and Clone

Test requirements

  • test_has_any_config_true — at least one config file
  • test_has_any_config_false — no config files
  • test_abbreviated_path — home dir replaced with ~
  • test_project_group_construction

Dependencies

Requires: #86, #90

Blocks

#97

Metadata

Metadata

Assignees

No one assigned

    Labels

    epic:project-explorerSidebar, project list, navigationepic:rust-migrationRust + Iced migration infrastructurephase:2Phase 2 — Editingpriority:highMust-have for MVPtype:migrationDirect port of existing Swift functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions