feat: improve how the issue command handles issue #6

open
opened by dunkirk.sh targeting main

This patch fixes tangled-cli issue list to properly deserialize issue records by making optional fields (createdAt, $type, owner, issueId) optional in the Issue struct, adds a --state filter to show only open or closed issues by querying issue state records and filtering client-side, and formats repository display as readable "handle/name" (e.g., "dunkirk.sh/thistle") instead of AT-URIs while using a cache to avoid repeated API calls for the same repository.

Changed files
+39 -2
crates
tangled-api
+2 -2
crates/tangled-api/src/lib.rs
···
pub use client::TangledClient;
pub use client::{
-
CreateRepoOptions, DefaultBranch, Issue, IssueRecord, Language, Languages, Pull, PullRecord,
-
RepoRecord, Repository, Secret,
+
CreateRepoOptions, DefaultBranch, Issue, IssueRecord, IssueState, Language, Languages, Pull,
+
PullRecord, RepoRecord, Repository, Secret,
};
+37
crates/tangled-api/src/client.rs
···
Err(anyhow!("repo not found for owner/name"))
}
+
pub async fn get_repo_by_rkey(
+
&self,
+
did: &str,
+
rkey: &str,
+
bearer: Option<&str>,
+
) -> Result<Repository> {
+
#[derive(Deserialize)]
+
struct GetRes {
+
value: Repository,
+
}
+
let params = [
+
("repo", did.to_string()),
+
("collection", "sh.tangled.repo".to_string()),
+
("rkey", rkey.to_string()),
+
];
+
let res: GetRes = self
+
.get_json("com.atproto.repo.getRecord", &params, bearer)
+
.await?;
+
Ok(res.value)
+
}
+
+
pub async fn resolve_did_to_handle(
+
&self,
+
did: &str,
+
bearer: Option<&str>,
+
) -> Result<String> {
+
#[derive(Deserialize)]
+
struct Res {
+
handle: String,
+
}
+
let params = [("repo", did.to_string())];
+
let res: Res = self
+
.get_json("com.atproto.repo.describeRepo", &params, bearer)
+
.await?;
+
Ok(res.handle)
+
}
+
pub async fn delete_repo(
&self,
did: &str,