From 83848c006f574d60544d040cf00ec8aa5d64c56b Mon Sep 17 00:00:00 2001 From: bRRRITSCOLD Date: Mon, 23 Nov 2026 16:20:15 -0700 Subject: [PATCH 1/4] feat(daemon): link a Repository by GitHub's id with what the client holds POST /v1/workspaces/{id}/links takes an optional id, url, private and archived. With an id the daemon links the Repository it keeps with that id, or stores it again from the body without asking GitHub, so Undo after an unlink that deleted the Repository works signed out. The client gains repositories::link and unlink. API_VERSION 25. Co-Authored-By: Claude Opus 5.5 --- crates/agentdeck-client/src/generated.rs | 80 +++++++++++- crates/agentdeck-client/src/repositories.rs | 67 +++++++++- crates/agentdeck-core/src/daemon.rs | 2 +- crates/agentdeck/src/commands.rs | 2 +- crates/agentdeckd/src/api/mod.rs | 2 +- crates/agentdeckd/src/api/repositories.rs | 39 +++++- crates/agentdeckd/src/db/repositories.rs | 18 +++ crates/agentdeckd/src/model.rs | 22 +++- crates/agentdeckd/tests/integration/prs.rs | 8 +- .../tests/integration/repositories.rs | 118 +++++++++++++++++- .../tests/integration/repositories_client.rs | 109 ++++++++++++++-- openapi.json | 30 ++++- 12 files changed, 462 insertions(+), 35 deletions(-) diff --git a/crates/agentdeck-client/src/generated.rs b/crates/agentdeck-client/src/generated.rs index 9b75af0..6c63c86 100644 --- a/crates/agentdeck-client/src/generated.rs +++ b/crates/agentdeck-client/src/generated.rs @@ -258,11 +258,23 @@ pub mod types { value.parse() } } - ///`POST /v1/workspaces/{id}/links`: the Repository to link. + ///`POST /v1/workspaces/{id}/links`: the Repository to link, by name, or by GitHub's id with what the client holds of it. #[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, PartialEq)] pub struct NewLink { - ///The Repository's `owner/name` (or its GitHub URL). One agentdeck doesn't know by that name is looked up on GitHub first. + ///Whether it is archived on GitHub, with `id`; false when absent. + #[serde(skip_serializing_if = "::std::option::Option::is_none")] + pub archived: ::std::option::Option, + ///GitHub's id for it, as the client last read it (Undo after an unlink sends it). The Repository agentdeck keeps with this id is linked, whatever its name now; one it no longer keeps is stored again from `repository`, `url`, `private` and `archived`, without asking GitHub, so this works signed out. + #[serde(skip_serializing_if = "::std::option::Option::is_none")] + pub id: ::std::option::Option, + ///Whether it is private, with `id`; false when absent. + #[serde(skip_serializing_if = "::std::option::Option::is_none")] + pub private: ::std::option::Option, + ///The Repository's `owner/name` (or its GitHub URL). Without `id`, one agentdeck doesn't know by that name is looked up on GitHub first. pub repository: agentdeck_core::RepositoryName, + ///Its GitHub page, with `id`; `https://github.com/` when absent. + #[serde(skip_serializing_if = "::std::option::Option::is_none")] + pub url: ::std::option::Option<::std::string::String>, } impl NewLink { pub fn builder() -> builder::NewLink { @@ -1598,17 +1610,61 @@ pub mod types { } #[derive(Clone, Debug)] pub struct NewLink { + archived: ::std::result::Result<::std::option::Option, ::std::string::String>, + id: ::std::result::Result< + ::std::option::Option, + ::std::string::String, + >, + private: ::std::result::Result<::std::option::Option, ::std::string::String>, repository: ::std::result::Result, + url: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, } impl ::std::default::Default for NewLink { fn default() -> Self { Self { + archived: Ok(Default::default()), + id: Ok(Default::default()), + private: Ok(Default::default()), repository: Err("no value supplied for repository".to_string()), + url: Ok(Default::default()), } } } impl NewLink { + pub fn archived(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.archived = value + .try_into() + .map_err(|e| format!("error converting supplied value for archived: {e}")); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {e}")); + self + } + pub fn private(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.private = value + .try_into() + .map_err(|e| format!("error converting supplied value for private: {e}")); + self + } pub fn repository(mut self, value: T) -> Self where T: ::std::convert::TryInto, @@ -1619,6 +1675,16 @@ pub mod types { .map_err(|e| format!("error converting supplied value for repository: {e}")); self } + pub fn url(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.url = value + .try_into() + .map_err(|e| format!("error converting supplied value for url: {e}")); + self + } } impl ::std::convert::TryFrom for super::NewLink { type Error = super::error::ConversionError; @@ -1626,14 +1692,22 @@ pub mod types { value: NewLink, ) -> ::std::result::Result { Ok(Self { + archived: value.archived?, + id: value.id?, + private: value.private?, repository: value.repository?, + url: value.url?, }) } } impl ::std::convert::From for NewLink { fn from(value: super::NewLink) -> Self { Self { + archived: Ok(value.archived), + id: Ok(value.id), + private: Ok(value.private), repository: Ok(value.repository), + url: Ok(value.url), } } } @@ -4294,7 +4368,7 @@ impl Client { } ///Links the Workspace to a Repository and answers the Repository with every Workspace that /// - ///links it. A Repository agentdeck doesn't know by that name is looked up on GitHub first and stored, as `GET /v1/repositories/resolve` does; one GitHub doesn't show the sign-in is 400 `unknown_repository` and nothing is linked. Linking a pair already linked changes nothing. A Workspace that doesn't exist is 404 `not_found`. Sends `changed` for the Repository, then the Workspace, when the Link is new. + ///links it. By name, a Repository agentdeck doesn't know by that name is looked up on GitHub first and stored, as `GET /v1/repositories/resolve` does; one GitHub doesn't show the sign-in is 400 `unknown_repository` and nothing is linked. With `id`, GitHub is never asked: the Repository kept with that id is linked, or, when none is, it is stored from what the client sent, so Undo after an unlink works signed out. Linking a pair already linked changes nothing. A Workspace that doesn't exist is 404 `not_found`. Sends `changed` for the Repository, then the Workspace, when the Link is new. /// ///Sends a `POST` request to `/v1/workspaces/{id}/links` /// diff --git a/crates/agentdeck-client/src/repositories.rs b/crates/agentdeck-client/src/repositories.rs index 68ac597..f637765 100644 --- a/crates/agentdeck-client/src/repositories.rs +++ b/crates/agentdeck-client/src/repositories.rs @@ -1,9 +1,11 @@ -//! Repositories as the GUI reads them (spec §4 `GET /v1/repositories`, §11 Notifications). +//! Repositories as the GUI reads them (spec §4 `GET /v1/repositories`, §11 Notifications), +//! and the Links a Repository group's `…` menu makes and takes away (spec §4 +//! `/v1/workspaces/{id}/links`, §11 Pull requests view). -use agentdeck_core::RepositoryName; +use agentdeck_core::{RepositoryId, RepositoryName, WorkspaceId}; use crate::error::OLDER_DAEMON; -use crate::types::{Repository, RepositoryLinks}; +use crate::types::{NewLink, Repository, RepositoryLinks}; use crate::{ApiError, Client}; /// Every Repository the daemon keeps, by name, each with the Workspaces linking it, archived @@ -34,3 +36,62 @@ pub async fn resolve(client: &Client, name: &RepositoryName) -> Result NewLink { + NewLink { + repository, + id: None, + url: None, + private: None, + archived: None, + } + } + + /// A link by GitHub's id, carrying what the client holds of `repository`: the daemon links + /// the Repository it keeps with that id, or stores it again from these, never asking GitHub. + pub fn held(repository: &Repository) -> NewLink { + NewLink { + repository: repository.name.clone(), + id: Some(repository.id), + url: Some(repository.url.clone()), + private: Some(repository.private), + archived: Some(repository.archived), + } + } +} + +/// Links `workspace` to `repository` by GitHub's id, as the client holds it (spec §4): the +/// Repository the daemon keeps with that id, or, when it no longer keeps one (an unlink took +/// it), one stored again from `repository`, without asking GitHub, so it works signed out. +/// Answers the Repository with every Workspace linking it now. +pub async fn link( + client: &Client, + workspace: WorkspaceId, + repository: &Repository, +) -> Result { + let linked = client + .link_create() + .id(workspace) + .body(NewLink::held(repository)) + .send() + .await?; + Ok(linked.into_inner()) +} + +/// Unlinks `workspace` from Repository `repository`. The daemon deletes the Repository when +/// nothing names it any more (spec §3); [`link`] brings it back. +pub async fn unlink( + client: &Client, + workspace: WorkspaceId, + repository: RepositoryId, +) -> Result<(), ApiError> { + client + .link_delete() + .id(workspace) + .repository(repository) + .send() + .await?; + Ok(()) +} diff --git a/crates/agentdeck-core/src/daemon.rs b/crates/agentdeck-core/src/daemon.rs index a81e8de..c59673a 100644 --- a/crates/agentdeck-core/src/daemon.rs +++ b/crates/agentdeck-core/src/daemon.rs @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize}; /// fails when `openapi.json` changes without a bump. /// /// `0` is every daemon from before it existed, whose `daemon.json` has no `api_version`. -pub const API_VERSION: u32 = 24; +pub const API_VERSION: u32 = 25; /// What `$XDG_RUNTIME_DIR/agentdeck/daemon.json` holds. The daemon writes it once it serves; /// the GUI and the CLI read it to reach the daemon. diff --git a/crates/agentdeck/src/commands.rs b/crates/agentdeck/src/commands.rs index 0a5c6b6..be9425e 100644 --- a/crates/agentdeck/src/commands.rs +++ b/crates/agentdeck/src/commands.rs @@ -302,7 +302,7 @@ async fn repo(client: &Client, command: RepoCommand) -> anyhow::Result { let linked = client .link_create() .id(id) - .body(NewLink { repository: repo }) + .body(NewLink::named(repo)) .send() .await .map_err(ApiError::from)?; diff --git a/crates/agentdeckd/src/api/mod.rs b/crates/agentdeckd/src/api/mod.rs index 146a6d1..eb7d1df 100644 --- a/crates/agentdeckd/src/api/mod.rs +++ b/crates/agentdeckd/src/api/mod.rs @@ -231,7 +231,7 @@ mod tests { /// `openapi.json`'s fingerprint when [`agentdeck_core::API_VERSION`] was last set, /// and that version. Clients tell an older daemon by its API version, so a route or /// field added without a bump would go unnoticed: they would call it and get a 404. - const FINGERPRINT_AT_API_VERSION: (u64, u32) = (0x58f3_6c55_a8cb_d039, 24); + const FINGERPRINT_AT_API_VERSION: (u64, u32) = (0x4933_5dbf_cf35_14c9, 25); /// FNV-1a: stable across Rust releases, unlike `DefaultHasher`. fn fingerprint(text: &str) -> u64 { diff --git a/crates/agentdeckd/src/api/repositories.rs b/crates/agentdeckd/src/api/repositories.rs index c69a63e..b32c892 100644 --- a/crates/agentdeckd/src/api/repositories.rs +++ b/crates/agentdeckd/src/api/repositories.rs @@ -81,10 +81,12 @@ pub(crate) async fn repository_resolve( } /// Links the Workspace to a Repository and answers the Repository with every Workspace that -/// links it. A Repository agentdeck doesn't know by that name is looked up on GitHub first -/// and stored, as `GET /v1/repositories/resolve` does; one GitHub doesn't show the sign-in is -/// 400 `unknown_repository` and nothing is linked. Linking a pair already linked changes -/// nothing. A Workspace that doesn't exist is 404 `not_found`. Sends `changed` for the +/// links it. By name, a Repository agentdeck doesn't know by that name is looked up on GitHub +/// first and stored, as `GET /v1/repositories/resolve` does; one GitHub doesn't show the +/// sign-in is 400 `unknown_repository` and nothing is linked. With `id`, GitHub is never +/// asked: the Repository kept with that id is linked, or, when none is, it is stored from what +/// the client sent, so Undo after an unlink works signed out. Linking a pair already linked +/// changes nothing. A Workspace that doesn't exist is 404 `not_found`. Sends `changed` for the /// Repository, then the Workspace, when the Link is new. #[endpoint { method = POST, path = "/v1/workspaces/{id}/links" }] pub(crate) async fn link_create( @@ -95,8 +97,28 @@ pub(crate) async fn link_create( ) -> Result, HttpError> { let context = rqctx.context(); let workspace = path.into_inner().id; - let name = body.into_inner().repository; + let NewLink { + repository: name, + id, + url, + private, + archived, + } = body.into_inner(); let db = &context.db; + if let Some(id) = id { + let held = RemoteRepository { + id, + url: url.unwrap_or_else(|| format!("https://github.com/{name}")), + name, + private: private.unwrap_or(false), + archived: archived.unwrap_or(false), + }; + let linked = db + .call(move |c| db::repositories::link_held(c, workspace, &held)) + .await?; + announce(context, workspace, &linked); + return Ok(HttpResponseOk(linked.repository)); + } let wanted = name.clone(); let known = db .call(move |c| { @@ -117,13 +139,18 @@ pub(crate) async fn link_create( .await? } }; + announce(context, workspace, &linked); + Ok(HttpResponseOk(linked.repository)) +} + +/// Sends `changed` for the Repository, then `workspace`, when `linked` changed anything. +fn announce(context: &ApiContext, workspace: WorkspaceId, linked: &db::repositories::Linked) { if linked.changed { context .events .changed(Entity::Repository, linked.repository.id); context.events.changed(Entity::Workspace, workspace); } - Ok(HttpResponseOk(linked.repository)) } /// A Link's path: the Workspace and the Repository it ties. diff --git a/crates/agentdeckd/src/db/repositories.rs b/crates/agentdeckd/src/db/repositories.rs index a53b3b7..3832f62 100644 --- a/crates/agentdeckd/src/db/repositories.rs +++ b/crates/agentdeckd/src/db/repositories.rs @@ -172,6 +172,24 @@ pub fn store_and_link( Ok(linked) } +/// Links Workspace `workspace` to Repository `held.id`: the one stored with that id, as it is, +/// or, when none is, `held` stored as the client holds it. One transaction. A Workspace that +/// doesn't exist is [`DbError::NotFound`], and nothing is stored. +pub fn link_held( + conn: &mut Connection, + workspace: WorkspaceId, + held: &RemoteRepository, +) -> Result { + let tx = conn.transaction()?; + if !super::exists(&tx, "workspaces", workspace)? { + return Err(DbError::NotFound("workspace")); + } + let stored = !is_known(&tx, held.id)? && store(&tx, held)?; + let linked = insert_link(&tx, workspace, held.id, stored)?; + tx.commit()?; + Ok(linked) +} + /// Adds the Link, unless it's there; `changed` is whether it was added or `stored` is. fn insert_link( conn: &Connection, diff --git a/crates/agentdeckd/src/model.rs b/crates/agentdeckd/src/model.rs index a188e84..d7ecc49 100644 --- a/crates/agentdeckd/src/model.rs +++ b/crates/agentdeckd/src/model.rs @@ -192,12 +192,28 @@ pub struct RepositoryFilter { pub workspace: Option, } -/// `POST /v1/workspaces/{id}/links`: the Repository to link. +/// `POST /v1/workspaces/{id}/links`: the Repository to link, by name, or by GitHub's id with +/// what the client holds of it. #[derive(Debug, Serialize, Deserialize, JsonSchema)] pub struct NewLink { - /// The Repository's `owner/name` (or its GitHub URL). One agentdeck doesn't know by that - /// name is looked up on GitHub first. + /// The Repository's `owner/name` (or its GitHub URL). Without `id`, one agentdeck doesn't + /// know by that name is looked up on GitHub first. pub repository: RepositoryName, + /// GitHub's id for it, as the client last read it (Undo after an unlink sends it). The + /// Repository agentdeck keeps with this id is linked, whatever its name now; one it no + /// longer keeps is stored again from `repository`, `url`, `private` and `archived`, + /// without asking GitHub, so this works signed out. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Its GitHub page, with `id`; `https://github.com/` when absent. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub url: Option, + /// Whether it is private, with `id`; false when absent. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub private: Option, + /// Whether it is archived on GitHub, with `id`; false when absent. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub archived: Option, } /// Whether the daemon has a GitHub token GitHub accepts (spec §8). diff --git a/crates/agentdeckd/tests/integration/prs.rs b/crates/agentdeckd/tests/integration/prs.rs index 7cc9071..1bafa55 100644 --- a/crates/agentdeckd/tests/integration/prs.rs +++ b/crates/agentdeckd/tests/integration/prs.rs @@ -1503,9 +1503,7 @@ mod get_v1_prs { .client .link_create() .id(web.id) - .body(NewLink { - repository: "acme/gadgets".parse().unwrap(), - }) + .body(NewLink::named("acme/gadgets".parse().unwrap())) .send() .await .expect("link"); @@ -2333,9 +2331,7 @@ mod finished { .into_inner(); (daemon.client.link_create()) .id(web.id) - .body(NewLink { - repository: "acme/widgets".parse().expect("a Repository"), - }) + .body(NewLink::named("acme/widgets".parse().expect("a Repository"))) .send() .await .expect("link"); diff --git a/crates/agentdeckd/tests/integration/repositories.rs b/crates/agentdeckd/tests/integration/repositories.rs index e49a35c..5de3d80 100644 --- a/crates/agentdeckd/tests/integration/repositories.rs +++ b/crates/agentdeckd/tests/integration/repositories.rs @@ -59,8 +59,18 @@ async fn link(client: &Client, workspace: WorkspaceId, repository: &str) -> Repo } fn new_link(repository: &str) -> NewLink { + NewLink::named(repository.parse().expect("a Repository")) +} + +/// A link by GitHub's id, with what the client holds of `repo` under `name`: as Undo after an +/// unlink sends it. +fn held_link(repo: RestRepo, name: &str) -> NewLink { NewLink { - repository: repository.parse().expect("a Repository"), + repository: name.parse().expect("a Repository"), + id: Some(RepositoryId::from(repo.id)), + url: Some(format!("https://github.com/{name}")), + private: Some(repo.private), + archived: Some(false), } } @@ -348,6 +358,112 @@ mod post_v1_workspaces_links { lookup.assert_calls(0); } + mod by_id { + use super::*; + + #[tokio::test] + async fn should_store_a_deleted_repository_again_from_what_the_client_holds_signed_out_200() + { + let daemon = TestDaemon::start().await; + let web = workspace(&daemon.client, "web").await; + let private = RestRepo { + private: true, + ..RestRepo::new(WIDGETS) + }; + (daemon.client.link_create()) + .id(web.id) + .body(held_link(private, WIDGETS)) + .send() + .await + .expect("the first link by id"); + unlink(&daemon.client, web.id, RepositoryId::from(private.id)).await; + assert_eq!(list(&daemon.client).await, [], "the unlink deleted it"); + let (_, by_name) = error_response( + (daemon.client.link_create()) + .id(web.id) + .body(new_link(WIDGETS)) + .send() + .await, + ); + assert_eq!(by_name.error_code.as_deref(), Some("not_signed_in")); + + let response = (daemon.client.link_create()) + .id(web.id) + .body(held_link(private, WIDGETS)) + .send() + .await + .expect("link by id again"); + + assert_eq!(response.status().as_u16(), 200); + let expected = listed(private, &[web.id]); + assert_eq!(response.into_inner(), expected); + assert_eq!(list(&daemon.client).await, [expected]); + } + + #[tokio::test] + async fn should_link_the_repository_it_keeps_by_that_id_under_its_name_now_200() { + let github = MockServer::start_async().await; + let daemon = synced(&github, &[Pr::open(7)]).await; + let web = workspace(&daemon.client, "web").await; + + let linked = (daemon.client.link_create()) + .id(web.id) + .body(held_link(RestRepo::new(WIDGETS), "acme/old-widgets")) + .send() + .await + .expect("link by id") + .into_inner(); + + assert_eq!(linked, listed(RestRepo::new(WIDGETS), &[web.id])); + } + + #[tokio::test] + async fn should_tell_websocket_clients_the_repository_then_the_workspace_changed_200() { + let daemon = TestDaemon::start().await; + let web = workspace(&daemon.client, "web").await; + let mut ws = Ws::connect(&daemon).await; + + (daemon.client.link_create()) + .id(web.id) + .body(held_link(RestRepo::new(WIDGETS), WIDGETS)) + .send() + .await + .expect("link by id"); + + assert_eq!( + next_link_change(&mut ws).await, + (Entity::Repository, repository_id(WIDGETS).to_string()) + ); + assert_eq!( + next_link_change(&mut ws).await, + (Entity::Workspace, web.id.to_string()) + ); + } + + #[tokio::test] + async fn should_answer_404_for_a_workspace_that_does_not_exist_and_store_nothing() { + let daemon = TestDaemon::start().await; + let gone = workspace(&daemon.client, "gone").await; + (daemon.client.workspace_delete()) + .id(gone.id) + .send() + .await + .expect("delete"); + + let (status, error) = error_response( + (daemon.client.link_create()) + .id(gone.id) + .body(held_link(RestRepo::new(WIDGETS), WIDGETS)) + .send() + .await, + ); + + assert_eq!(status, 404); + assert_eq!(error.error_code.as_deref(), Some("not_found")); + assert_eq!(list(&daemon.client).await, []); + } + } + #[tokio::test] async fn should_refuse_a_repository_github_cannot_see_and_link_nothing_400() { let github = MockServer::start_async().await; diff --git a/crates/agentdeckd/tests/integration/repositories_client.rs b/crates/agentdeckd/tests/integration/repositories_client.rs index 152810d..6370e11 100644 --- a/crates/agentdeckd/tests/integration/repositories_client.rs +++ b/crates/agentdeckd/tests/integration/repositories_client.rs @@ -1,10 +1,12 @@ //! `agentdeck_client::repositories`: the Repositories and the Workspaces linking each, as the -//! GUI reads them for the PR alert mute rule, against a real daemon with httpmock as GitHub. -//! The GUI's fake API answers the same way (spec §12). +//! GUI reads them for the PR alert mute rule, and the Links a Repository group's `…` menu makes +//! and takes away, against a real daemon with httpmock as GitHub. The GUI's fake API answers +//! the same way (spec §12). -use agentdeck_client::repositories::{list, resolve}; +use agentdeck_client::Client; +use agentdeck_client::repositories::{link, list, resolve, unlink}; use agentdeck_client::types::{NewLink, NewWorkspace, Repository}; -use agentdeck_core::RepositoryId; +use agentdeck_core::{RepositoryId, WorkspaceId}; use httpmock::MockServer; use crate::support::TestDaemon; @@ -42,9 +44,7 @@ mod list { .into_inner(); (daemon.client.link_create()) .id(web.id) - .body(NewLink { - repository: "acme/widgets".parse().expect("a Repository"), - }) + .body(NewLink::named("acme/widgets".parse().expect("a Repository"))) .send() .await .expect("link"); @@ -150,3 +150,98 @@ mod resolve { ); } } + +/// A Workspace named `name`, linking nothing. +async fn workspace(client: &Client, name: &str) -> WorkspaceId { + (client.workspace_create()) + .body(NewWorkspace { + name: name.into(), + link: Vec::new(), + }) + .send() + .await + .expect("create a workspace") + .into_inner() + .id +} + +/// `acme/widgets` as a client holds it, private. +fn widgets() -> Repository { + Repository { + id: RepositoryId::from(repository_id("acme/widgets")), + name: "acme/widgets".parse().unwrap(), + url: "https://github.com/acme/widgets".into(), + private: true, + archived: false, + } +} + +mod link { + use super::*; + + #[tokio::test] + async fn should_link_and_answer_the_repository_with_the_workspaces_linking_it() { + let daemon = TestDaemon::start().await; + let web = workspace(&daemon.client, "web").await; + + let linked = link(&daemon.client, web, &widgets()).await.expect("link"); + + assert_eq!((linked.id, linked.private), (widgets().id, true)); + assert_eq!(linked.workspaces, [web]); + } + + #[tokio::test] + async fn should_link_again_after_an_unlink_deleted_the_repository_signed_out() { + let daemon = TestDaemon::start().await; + let web = workspace(&daemon.client, "web").await; + link(&daemon.client, web, &widgets()).await.expect("link"); + unlink(&daemon.client, web, widgets().id) + .await + .expect("unlink"); + assert_eq!(list(&daemon.client).await.expect("list"), []); + + link(&daemon.client, web, &widgets()) + .await + .expect("link again"); + + let listed = list(&daemon.client).await.expect("list"); + let names: Vec<_> = (listed.iter()) + .map(|r| (r.name.to_string(), r.workspaces.clone())) + .collect(); + assert_eq!(names, [("acme/widgets".to_owned(), vec![web])]); + } +} + +mod unlink { + use super::*; + + #[tokio::test] + async fn should_unlink_and_keep_a_repository_another_workspace_links() { + let daemon = TestDaemon::start().await; + let (web, api) = ( + workspace(&daemon.client, "web").await, + workspace(&daemon.client, "api").await, + ); + link(&daemon.client, web, &widgets()).await.expect("link"); + link(&daemon.client, api, &widgets()).await.expect("link"); + + unlink(&daemon.client, web, widgets().id) + .await + .expect("unlink"); + + let listed = list(&daemon.client).await.expect("list"); + assert_eq!(listed[0].workspaces, [api]); + } + + #[tokio::test] + async fn should_fail_with_the_daemons_words_for_a_repository_it_does_not_link() { + let daemon = TestDaemon::start().await; + let web = workspace(&daemon.client, "web").await; + + let err = unlink(&daemon.client, web, widgets().id) + .await + .expect_err("a refusal"); + + assert_eq!(err.code.as_deref(), Some("not_found")); + } +} diff --git a/openapi.json b/openapi.json index 196aa7f..6c5608a 100644 --- a/openapi.json +++ b/openapi.json @@ -356,15 +356,39 @@ "description": "A tab's split tree. Every pane appears once; [`Layout::split`] keeps it that way." }, "NewLink": { - "description": "`POST /v1/workspaces/{id}/links`: the Repository to link.", + "description": "`POST /v1/workspaces/{id}/links`: the Repository to link, by name, or by GitHub's id with what the client holds of it.", "properties": { + "archived": { + "description": "Whether it is archived on GitHub, with `id`; false when absent.", + "nullable": true, + "type": "boolean" + }, + "id": { + "allOf": [ + { + "$ref": "#/components/schemas/RepositoryId" + } + ], + "description": "GitHub's id for it, as the client last read it (Undo after an unlink sends it). The Repository agentdeck keeps with this id is linked, whatever its name now; one it no longer keeps is stored again from `repository`, `url`, `private` and `archived`, without asking GitHub, so this works signed out.", + "nullable": true + }, + "private": { + "description": "Whether it is private, with `id`; false when absent.", + "nullable": true, + "type": "boolean" + }, "repository": { "allOf": [ { "$ref": "#/components/schemas/RepositoryName" } ], - "description": "The Repository's `owner/name` (or its GitHub URL). One agentdeck doesn't know by that name is looked up on GitHub first." + "description": "The Repository's `owner/name` (or its GitHub URL). Without `id`, one agentdeck doesn't know by that name is looked up on GitHub first." + }, + "url": { + "description": "Its GitHub page, with `id`; `https://github.com/` when absent.", + "nullable": true, + "type": "string" } }, "required": [ @@ -2444,7 +2468,7 @@ }, "/v1/workspaces/{id}/links": { "post": { - "description": "links it. A Repository agentdeck doesn't know by that name is looked up on GitHub first and stored, as `GET /v1/repositories/resolve` does; one GitHub doesn't show the sign-in is 400 `unknown_repository` and nothing is linked. Linking a pair already linked changes nothing. A Workspace that doesn't exist is 404 `not_found`. Sends `changed` for the Repository, then the Workspace, when the Link is new.", + "description": "links it. By name, a Repository agentdeck doesn't know by that name is looked up on GitHub first and stored, as `GET /v1/repositories/resolve` does; one GitHub doesn't show the sign-in is 400 `unknown_repository` and nothing is linked. With `id`, GitHub is never asked: the Repository kept with that id is linked, or, when none is, it is stored from what the client sent, so Undo after an unlink works signed out. Linking a pair already linked changes nothing. A Workspace that doesn't exist is 404 `not_found`. Sends `changed` for the Repository, then the Workspace, when the Link is new.", "operationId": "link_create", "parameters": [ { From 5ff27be1c46833adffcc3bbf50689a7bdf56b468 Mon Sep 17 00:00:00 2001 From: bRRRITSCOLD Date: Mon, 23 Nov 2026 16:26:57 -0700 Subject: [PATCH 2/4] feat(gui): link and unlink from a Repository group's menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each Repository group on both Pull requests views gets a … menu: Open on GitHub and Link to a workspace, a submenu of the unarchived Workspaces that don't link it, then New workspace, which opens New workspace with the Repository picked. A Workspace's Pull requests adds Unlink from this workspace. Both apply at once with a toast and Undo; Undo after an unlink links again by GitHub's id, so it works once the Repository is gone. Co-Authored-By: Claude Opus 5.5 --- crates/agentdeck-gui/src/api.rs | 117 +++- crates/agentdeck-gui/src/group_menu.rs | 503 ++++++++++++++++++ crates/agentdeck-gui/src/main.rs | 1 + crates/agentdeck-gui/src/new_workspace.rs | 16 +- crates/agentdeck-gui/src/open_pr.rs | 14 + crates/agentdeck-gui/src/pr_table.rs | 9 +- crates/agentdeck-gui/src/pull_requests.rs | 344 ++++++++++++ crates/agentdeck-gui/src/shell.rs | 76 ++- crates/agentdeck-gui/src/workspace.rs | 11 +- crates/agentdeckd/tests/integration/prs.rs | 4 +- .../tests/integration/repositories.rs | 2 +- .../tests/integration/repositories_client.rs | 4 +- 12 files changed, 1090 insertions(+), 11 deletions(-) create mode 100644 crates/agentdeck-gui/src/group_menu.rs diff --git a/crates/agentdeck-gui/src/api.rs b/crates/agentdeck-gui/src/api.rs index acb4331..14fd31c 100644 --- a/crates/agentdeck-gui/src/api.rs +++ b/crates/agentdeck-gui/src/api.rs @@ -10,7 +10,9 @@ use agentdeck_client::types::{ }; pub use agentdeck_client::workspaces::Change; use agentdeck_client::{ApiError, Client}; -use agentdeck_core::{PaneId, PrRef, RepositoryName, SplitDirection, TabId, WorkspaceId}; +use agentdeck_core::{ + PaneId, PrRef, RepositoryId, RepositoryName, SplitDirection, TabId, WorkspaceId, +}; use gpui::{App, Task}; use crate::new_agent::{Launch, Launched}; @@ -96,6 +98,26 @@ pub trait Api: Send + Sync { cx: &App, ) -> Task>; + /// Links `workspace` to `repository` by GitHub's id, as the view holds it (spec §4): the + /// Repository the daemon keeps with that id, or, when an unlink took it meanwhile, one + /// stored again from `repository` without asking GitHub, so Undo works signed out. + fn link_repository( + &self, + workspace: WorkspaceId, + repository: Repository, + cx: &App, + ) -> Task>; + + /// Unlinks `workspace` from Repository `repository`; the daemon deletes the Repository once + /// nothing names it (spec §3). A refusal is an [`ApiError`]; `not_found` means the + /// Workspace doesn't link it. + fn unlink_repository( + &self, + workspace: WorkspaceId, + repository: RepositoryId, + cx: &App, + ) -> Task>; + /// Mutes `workspace`'s notifications, or unmutes them. fn set_muted(&self, workspace: WorkspaceId, muted: bool, cx: &App) -> Task>; @@ -291,6 +313,32 @@ impl Api for Daemon { }) } + fn link_repository( + &self, + workspace: WorkspaceId, + repository: Repository, + cx: &App, + ) -> Task> { + let client = self.client.clone(); + runtime::spawn(cx, async move { + agentdeck_client::repositories::link(&client, workspace, &repository).await?; + Ok(()) + }) + } + + fn unlink_repository( + &self, + workspace: WorkspaceId, + repository: RepositoryId, + cx: &App, + ) -> Task> { + let client = self.client.clone(); + runtime::spawn(cx, async move { + agentdeck_client::repositories::unlink(&client, workspace, repository).await?; + Ok(()) + }) + } + fn set_muted(&self, workspace: WorkspaceId, muted: bool, cx: &App) -> Task> { let client = self.client.clone(); runtime::spawn(cx, async move { @@ -496,6 +544,15 @@ pub(crate) mod fake { } } + /// The daemon's `not_found` refusal, saying `message`. + fn not_found(message: &str) -> anyhow::Error { + ApiError { + message: message.to_owned(), + code: Some("not_found".into()), + } + .into() + } + /// Answers every read with what it holds now, and counts the snapshot reads. Writes /// change what it holds, as the daemon would, but broadcast nothing. #[derive(Default)] @@ -532,6 +589,10 @@ pub(crate) mod fake { pub muted: Mutex>, /// The edits asked for: the workspace and what to change, in order. pub edits: Mutex>, + /// The links asked for by GitHub's id: the workspace and the Repository, in order. + pub links: Mutex>, + /// The unlinks asked for: the workspace and the Repository, in order. + pub unlinks: Mutex>, /// The Repositories GitHub shows, by `owner/name` in lower case: what a typed name /// resolves to and what linking a Repository the snapshot doesn't hold finds. github_repositories: Mutex>, @@ -1084,6 +1145,60 @@ pub(crate) mod fake { Task::ready(self.github(&name)) } + fn link_repository( + &self, + workspace: WorkspaceId, + repository: Repository, + _cx: &App, + ) -> Task> { + self.links + .lock() + .unwrap() + .push((workspace, repository.clone())); + if let Some(err) = self.failure() { + return Task::ready(Err(err)); + } + let mut snapshot = self.snapshot.lock().unwrap(); + if !snapshot.workspaces.iter().any(|w| w.id == workspace) { + return Task::ready(Err(not_found("workspace not found"))); + } + if !(snapshot.repositories.iter()).any(|r| r.id == repository.id) { + snapshot.repositories.push(RepositoryLinks { + id: repository.id, + name: repository.name, + url: repository.url, + private: repository.private, + archived: repository.archived, + unreachable: false, + workspaces: Vec::new(), + }); + (snapshot.repositories).sort_by_key(|r| r.name.to_string().to_lowercase()); + } + let held = (snapshot.repositories.iter_mut()).find(|r| r.id == repository.id); + if let Some(held) = held.filter(|r| !r.workspaces.contains(&workspace)) { + held.workspaces.push(workspace); + } + Task::ready(Ok(())) + } + + fn unlink_repository( + &self, + workspace: WorkspaceId, + repository: agentdeck_core::RepositoryId, + _cx: &App, + ) -> Task> { + self.unlinks.lock().unwrap().push((workspace, repository)); + if let Some(err) = self.failure() { + return Task::ready(Err(err)); + } + let linked = (self.snapshot.lock().unwrap().repositories.iter()) + .any(|r| r.id == repository && r.workspaces.contains(&workspace)); + if !linked { + return Task::ready(Err(not_found("link not found"))); + } + Task::ready(self.relink(workspace, &[], &[repository])) + } + fn set_muted( &self, workspace: WorkspaceId, diff --git a/crates/agentdeck-gui/src/group_menu.rs b/crates/agentdeck-gui/src/group_menu.rs new file mode 100644 index 0000000..9115ab4 --- /dev/null +++ b/crates/agentdeck-gui/src/group_menu.rs @@ -0,0 +1,503 @@ +//! A Repository group's `…` menu (spec §11, Pull requests view → Group menu), Penpot +//! "Screens · Main" → "Pull requests · group menu", "· group menu · no workspace to link", +//! "Pull requests · linked", "Workspace · Pull requests · group menu" and "Workspace · Pull +//! requests · unlinked": **Open on GitHub**, **Link to a workspace** and, on a Workspace's Pull +//! requests, **Unlink from this workspace**. +//! +//! Link to a workspace is a submenu of the Workspaces that aren't archived and don't link the +//! Repository, in the sidebar's order, then **New workspace**, which opens New workspace with +//! the Repository already picked ([`NewWorkspaceLinking`]); with no Workspace to offer, New +//! workspace is its only item. +//! +//! Linking and unlinking apply at once, with a toast that offers Undo, as archiving does. Undo +//! links again by GitHub's id with what the view held of the Repository +//! ([`Api::link_repository`]), so it works even when the unlink deleted the Repository, signed +//! out included. Nothing here waits for the view: a toast's Undo outlives it. + +use std::rc::Rc; +use std::sync::Arc; + +use agentdeck_client::types::Repository; +use agentdeck_core::{PrState, RepositoryId}; +use brrritscold_core_gpui::{ + Button, ButtonSize, ButtonVariant, DropdownMenu, DropdownMenuAlign, DropdownMenuContent, + DropdownMenuItem, DropdownMenuSeparator, DropdownMenuSubContent, DropdownMenuSubTrigger, + IconName, +}; +use gpui::{ + AnyElement, App, InteractiveElement as _, IntoElement, ParentElement as _, SharedString, Task, + Window, div, +}; + +use crate::api::Api; +use crate::notice::{Notice, NoticeAction}; +use crate::overview::Snapshot; +use crate::pr_table::Linker; +use crate::pull_requests::Scope; +use crate::workspace::failed; + +/// A group's **New workspace** asks for New workspace with this Repository already picked. +#[derive(Debug, Clone, PartialEq)] +pub struct NewWorkspaceLinking(pub Repository); + +/// One entry of a group's `…` menu. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum GroupEntry { + /// **Open on GitHub**: the Repository's page. + OpenOnGitHub, + /// **Link to a workspace**: a submenu of these Workspaces, then New workspace. + LinkToWorkspace(Vec), + /// A line between the entries. + Separator, + /// **Unlink from this workspace**, on a Workspace's Pull requests. + Unlink, +} + +/// The `…` menu of `repository`'s group on a list over `scope`, top to bottom: Open on GitHub, +/// Link to a workspace with the Workspaces it offers (not archived, not linking `repository`, +/// in the sidebar's order), then, on a Workspace's Pull requests, a separator and Unlink from +/// this workspace. +pub fn entries(snapshot: &Snapshot, scope: Scope, repository: RepositoryId) -> Vec { + let eligible = (snapshot.workspaces.iter()) + .filter(|w| w.archived_at.is_none() && !snapshot.links(w.id, repository)) + .map(|w| Linker { + id: w.id, + name: w.name.clone().into(), + }) + .collect(); + let mut entries = vec![ + GroupEntry::OpenOnGitHub, + GroupEntry::LinkToWorkspace(eligible), + ]; + if let Scope::Workspace(_) = scope { + entries.extend([GroupEntry::Separator, GroupEntry::Unlink]); + } + entries +} + +/// Repository `repository` as `snapshot` holds it: what a link by GitHub's id carries, so +/// Undo can bring it back once an unlink deleted it. +pub fn held(snapshot: &Snapshot, repository: RepositoryId) -> Option { + let linked = (snapshot.repositories.iter()) + .find(|r| r.id == repository) + .map(|r| Repository { + id: r.id, + name: r.name.clone(), + url: r.url.clone(), + private: r.private, + archived: r.archived, + }); + linked.or_else(|| { + (snapshot.prs.iter()) + .find(|pr| pr.repository.id == repository) + .map(|pr| pr.repository.clone()) + }) +} + +/// How many of `repository`'s PRs are open, counted as the sidebar counts them: drafts in, +/// Unreachable and Finished ones out. +pub fn open_prs(snapshot: &Snapshot, repository: RepositoryId) -> usize { + (snapshot.prs.iter()) + .filter(|pr| pr.repository.id == repository) + .filter(|pr| pr.state == PrState::Open && !pr.unreachable && !pr.finished) + .count() +} + +/// The toast after a link: "Linked owner/name to ". +pub fn linked_title(repository: &str, workspace: &str) -> String { + format!("Linked {repository} to {workspace}") +} + +/// The toast after an unlink: its title, "Unlinked owner/name from ", and what it +/// says of the Repository's `open` PRs: they no longer show here, and, when no other Workspace +/// links it (`elsewhere` false), where they are now. With no open PR it says only the title. +pub fn unlinked( + repository: &str, + workspace: &str, + open: usize, + elsewhere: bool, +) -> (String, Option) { + let title = format!("Unlinked {repository} from {workspace}"); + let description = match open { + 0 => None, + 1 => Some("Its 1 open PR no longer shows here.".to_owned()), + n => Some(format!("Its {n} open PRs no longer show here.")), + }; + let description = description.map(|gone| match (elsewhere, open) { + (true, _) => gone, + (false, 1) => { + format!("{gone} It's in the Pull requests view, under Not in a workspace.") + } + (false, _) => { + format!("{gone} They're in the Pull requests view, under Not in a workspace.") + } + }); + (title, description) +} + +/// What the menu acts on: the Repository, as the view holds it, the list's scope and what it +/// needs to say about an unlink. +#[derive(Clone)] +pub struct Target { + /// The Repository. + pub repository: Repository, + /// The Workspace whose Pull requests it is on, if any. + pub workspace: Option, + /// Its open PRs, as the sidebar counts them. + pub open: usize, + /// Whether a Workspace other than `workspace` links it, archived ones aside. + pub elsewhere: bool, +} + +/// What New workspace does: asks the window for New workspace with the Repository picked. +pub type OnNewWorkspace = Rc; + +/// The group's `…` menu of `entries` over `target`, opening 4px below its ghost icon-xs +/// trigger with their right edges lined up, as a row's does. Tests find it as +/// `group menu `. +pub fn menu( + entries: Vec, + target: Target, + api: Arc, + on_new_workspace: OnNewWorkspace, +) -> AnyElement { + let key = target.repository.name.to_string(); + let content = + entries + .into_iter() + .fold(DropdownMenuContent::new(), |content, entry| match entry { + GroupEntry::OpenOnGitHub => { + let url = target.repository.url.clone(); + content.item(DropdownMenuItem::new("Open on GitHub").on_click( + move |_, window, cx| crate::open_pr::open_repository(&url, window, cx), + )) + } + GroupEntry::LinkToWorkspace(eligible) => { + let sub = eligible + .iter() + .fold(DropdownMenuSubContent::new(), |sub, w| { + let (api, repository, workspace) = + (api.clone(), target.repository.clone(), w.clone()); + sub.item(DropdownMenuItem::new(w.name.clone()).on_click( + move |_, window, cx| { + link( + api.clone(), + workspace.clone(), + repository.clone(), + window, + cx, + ); + }, + )) + }); + let sub = match eligible.is_empty() { + true => sub, + false => sub.separator(DropdownMenuSeparator::new()), + }; + let (repository, on_new) = + (target.repository.clone(), on_new_workspace.clone()); + let sub = sub.item( + DropdownMenuItem::new("New workspace") + .on_click(move |_, window, cx| on_new(repository.clone(), window, cx)), + ); + content.sub(DropdownMenuSubTrigger::new("Link to a workspace"), sub) + } + GroupEntry::Separator => content.separator(DropdownMenuSeparator::new()), + GroupEntry::Unlink => { + let (api, target) = (api.clone(), target.clone()); + content.item( + DropdownMenuItem::new("Unlink from this workspace").on_click( + move |_, window, cx| unlink(api.clone(), target.clone(), window, cx), + ), + ) + } + }); + let selector = key.clone(); + div() + .debug_selector(move || format!("group menu {selector}")) + .child( + // Penpot "Pull requests · group menu" ends it on the trigger's right edge. + DropdownMenu::new(SharedString::from(format!("group-menu-{key}"))) + .align(DropdownMenuAlign::End) + .trigger( + Button::new(SharedString::from(format!("group-menu-trigger-{key}"))) + .variant(ButtonVariant::Ghost) + .size(ButtonSize::IconXs) + .icon(IconName::Ellipsis), + ) + .content(content), + ) + .into_any_element() +} + +/// Links `workspace` to `repository` at once and toasts it, with an Undo that unlinks it. +pub fn link( + api: Arc, + workspace: Linker, + repository: Repository, + window: &mut Window, + cx: &mut App, +) { + let linking = api.link_repository(workspace.id, repository.clone(), cx); + after(linking, window, cx, move |done, window, cx| { + let name = repository.name.to_string(); + match done { + Ok(()) => { + let undo = NoticeAction::new("Undo", { + let (workspace, id) = (workspace.clone(), repository.id); + move |window, cx| { + let unlinking = api.unlink_repository(workspace.id, id, cx); + let what = format!("Couldn't unlink {name} from {}", workspace.name); + quietly(unlinking, what, window, cx); + } + }); + Notice::new(linked_title(&repository.name.to_string(), &workspace.name)) + .action(undo) + .show(window, cx); + } + Err(err) => failed( + format!("Couldn't link {name} to {}", workspace.name), + &err, + window, + cx, + ), + } + }); +} + +/// Unlinks the Workspace whose Pull requests `target` is on from its Repository at once, and +/// toasts it with an Undo that links it again by GitHub's id. +pub fn unlink(api: Arc, target: Target, window: &mut Window, cx: &mut App) { + let Some(workspace) = target.workspace.clone() else { + return; + }; + let unlinking = api.unlink_repository(workspace.id, target.repository.id, cx); + after(unlinking, window, cx, move |done, window, cx| { + let name = target.repository.name.to_string(); + match done { + Ok(()) => { + let undo = NoticeAction::new("Undo", { + let (workspace, repository) = (workspace.clone(), target.repository.clone()); + move |window, cx| { + let linking = api.link_repository(workspace.id, repository.clone(), cx); + let what = format!("Couldn't link {name} to {}", workspace.name); + quietly(linking, what, window, cx); + } + }); + let (title, description) = unlinked( + &target.repository.name.to_string(), + &workspace.name, + target.open, + target.elsewhere, + ); + let notice = Notice::new(title).action(undo); + match description { + Some(description) => notice.description(description), + None => notice, + } + .show(window, cx); + } + Err(err) => failed( + format!("Couldn't unlink {name} from {}", workspace.name), + &err, + window, + cx, + ), + } + }); +} + +/// Runs `then` in `window` once `task` is done. +fn after( + task: Task>, + window: &mut Window, + cx: &mut App, + then: impl FnOnce(anyhow::Result<()>, &mut Window, &mut App) + 'static, +) { + window + .spawn(cx, async move |cx| { + let done = task.await; + let _ = cx.update(|window, cx| then(done, window, cx)); + }) + .detach(); +} + +/// An Undo's write: no toast once done, one titled `what` with why if it fails. +fn quietly(task: Task>, what: String, window: &mut Window, cx: &mut App) { + after(task, window, cx, move |done, window, cx| { + if let Err(err) = done { + failed(what, &err, window, cx); + } + }); +} + +#[cfg(test)] +mod tests { + use agentdeck_client::types::{PullRequest, Workspace}; + + use super::*; + use crate::overview::fixtures::{id, links, pull_request, repository_id, workspace}; + + /// Workspaces `a` (1), `b` (2) and `old` (3, archived); widgets linked by `a` and `old`, + /// with two open PRs, a draft, an Unreachable, a Finished and a merged one. + fn snapshot() -> Snapshot { + let old = Workspace { + archived_at: Some("2026-11-13T00:00:00Z".into()), + ..workspace(3, "old") + }; + let pr = |n, change: fn(&mut PullRequest)| { + let mut pr = pull_request(n, "acme/widgets"); + change(&mut pr); + pr + }; + Snapshot { + workspaces: vec![workspace(1, "a"), workspace(2, "b"), old], + repositories: vec![links("acme/widgets", &[id(1), id(3)])], + prs: vec![ + pr(1, |_| {}), + pr(2, |pr| pr.draft = true), + pr(3, |pr| pr.unreachable = true), + pr(4, |pr| pr.finished = true), + pr(5, |pr| pr.state = PrState::Merged), + pull_request(6, "acme/gadgets"), + ], + ..Snapshot::default() + } + } + + fn widgets() -> RepositoryId { + repository_id("acme/widgets") + } + + fn offered(entries: &[GroupEntry]) -> Vec { + let Some(GroupEntry::LinkToWorkspace(eligible)) = entries.get(1) else { + panic!("Link to a workspace comes second: {entries:?}"); + }; + eligible.iter().map(|w| w.name.to_string()).collect() + } + + mod entries { + use super::*; + + #[test] + fn should_offer_open_on_github_and_link_to_a_workspace_on_the_pull_requests_view() { + let entries = entries(&snapshot(), Scope::All, widgets()); + + assert_eq!(entries[0], GroupEntry::OpenOnGitHub); + assert_eq!(entries.len(), 2); + } + + #[test] + fn should_add_unlink_after_a_separator_on_a_workspaces_pull_requests() { + let entries = entries(&snapshot(), Scope::Workspace(id(1)), widgets()); + + assert_eq!(entries[2..], [GroupEntry::Separator, GroupEntry::Unlink]); + } + + #[test] + fn should_leave_out_archived_workspaces_and_those_linking_it() { + let entries = entries(&snapshot(), Scope::All, widgets()); + + assert_eq!(offered(&entries), ["b"]); + } + + #[test] + fn should_offer_every_live_workspace_in_the_sidebars_order_for_one_linked_nowhere() { + let gadgets = repository_id("acme/gadgets"); + + assert_eq!( + offered(&entries(&snapshot(), Scope::All, gadgets)), + ["a", "b"] + ); + } + + #[test] + fn should_offer_none_when_every_live_workspace_links_it() { + let mut snapshot = snapshot(); + snapshot.repositories[0].workspaces.push(id(2)); + + assert!(offered(&entries(&snapshot, Scope::All, widgets())).is_empty()); + } + } + + mod held { + use super::*; + + #[test] + fn should_hold_a_linked_repository_as_last_read() { + let held = held(&snapshot(), widgets()).expect("held"); + + assert_eq!(held.url, "https://github.com/acme/widgets"); + assert_eq!(held.name.to_string(), "acme/widgets"); + } + + #[test] + fn should_hold_one_known_only_by_its_prs_from_them() { + let gadgets = repository_id("acme/gadgets"); + + assert_eq!( + held(&snapshot(), gadgets).map(|r| r.id), + Some(repository_id("acme/gadgets")) + ); + } + } + + mod open_prs { + use super::*; + + #[test] + fn should_count_open_prs_drafts_in_unreachable_and_finished_out() { + assert_eq!(open_prs(&snapshot(), widgets()), 2); + } + } + + mod unlinked { + use super::*; + + #[test] + fn should_say_its_prs_no_longer_show_here_while_another_workspace_links_it() { + assert_eq!( + unlinked("acme/widgets", "agentdeck", 3, true), + ( + "Unlinked acme/widgets from agentdeck".to_owned(), + Some("Its 3 open PRs no longer show here.".to_owned()) + ) + ); + } + + #[test] + fn should_add_where_they_are_when_no_other_workspace_links_it() { + assert_eq!( + unlinked("acme/widgets", "agentdeck", 3, false).1.as_deref(), + Some( + "Its 3 open PRs no longer show here. They're in the Pull requests view, \ + under Not in a workspace." + ) + ); + } + + #[test] + fn should_speak_of_one_open_pr_in_the_singular() { + assert_eq!( + unlinked("acme/widgets", "agentdeck", 1, false).1.as_deref(), + Some( + "Its 1 open PR no longer shows here. It's in the Pull requests view, \ + under Not in a workspace." + ) + ); + } + + #[test] + fn should_say_only_the_title_with_no_open_pr() { + assert_eq!(unlinked("acme/widgets", "agentdeck", 0, false).1, None); + } + } + + #[test] + fn should_title_a_link_with_the_repository_and_the_workspace() { + assert_eq!( + linked_title("acme/widgets", "agentdeck"), + "Linked acme/widgets to agentdeck" + ); + } +} diff --git a/crates/agentdeck-gui/src/main.rs b/crates/agentdeck-gui/src/main.rs index a43f6b2..b48ceff 100644 --- a/crates/agentdeck-gui/src/main.rs +++ b/crates/agentdeck-gui/src/main.rs @@ -11,6 +11,7 @@ mod delete_workspace; mod edit_workspace; mod frame; mod github; +mod group_menu; mod gui_state; mod keymap; mod link_picker; diff --git a/crates/agentdeck-gui/src/new_workspace.rs b/crates/agentdeck-gui/src/new_workspace.rs index cb128ab..33793b8 100644 --- a/crates/agentdeck-gui/src/new_workspace.rs +++ b/crates/agentdeck-gui/src/new_workspace.rs @@ -25,7 +25,7 @@ use gpui::{ use gpui_base::input::InputEvent; use crate::api::Api; -use crate::link_picker::{LinkPicker, Offer}; +use crate::link_picker::{Choice, LinkPicker, Offer}; use crate::workspace::failed; /// The dialog's description, under its title. @@ -94,6 +94,20 @@ impl NewWorkspaceDialog { cx.notify(); } + /// Opens it as [`open`](Self::open) does, with `picked` already in its Repositories, to + /// link: a Repository group's New workspace. + pub fn open_linking( + &mut self, + offer: Offer, + picked: Choice, + window: &mut Window, + cx: &mut Context, + ) { + self.open(offer, window, cx); + self.picker + .update(cx, |picker, cx| picker.pick(picked, window, cx)); + } + /// Whether it is open. #[cfg(test)] pub fn is_open(&self) -> bool { diff --git a/crates/agentdeck-gui/src/open_pr.rs b/crates/agentdeck-gui/src/open_pr.rs index 8e85a5d..0258276 100644 --- a/crates/agentdeck-gui/src/open_pr.rs +++ b/crates/agentdeck-gui/src/open_pr.rs @@ -39,6 +39,20 @@ pub fn open(url: &str, window: &mut Window, cx: &mut App) { open::open_url(url, "Couldn't open the PR", window, cx); } +/// Opens `url`, a Repository's GitHub page (a group's Open on GitHub), as [`open()`] opens a +/// PR's: refused unless [`openable`]; a toast "Couldn't open the repository" when the handler +/// can't start. +pub fn open_repository(url: &str, window: &mut Window, cx: &mut App) { + if !openable(url) { + tracing::debug!( + url, + "refused to open a Repository link that isn't a GitHub https URL" + ); + return; + } + open::open_url(url, "Couldn't open the repository", window, cx); +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/agentdeck-gui/src/pr_table.rs b/crates/agentdeck-gui/src/pr_table.rs index 2c9de15..dea6d44 100644 --- a/crates/agentdeck-gui/src/pr_table.rs +++ b/crates/agentdeck-gui/src/pr_table.rs @@ -111,8 +111,9 @@ pub type OnWorkspace = Rc; /// its checkbox, then, `space.2` after it in sm `muted-foreground`, who links the Repository: /// each Workspace in `workspaces` by name, `·` apart, a link to its Pull requests that runs /// `on_workspace` (underlined on hover, as a PR's reference), or [`NOT_IN_A_WORKSPACE`] with -/// none. `key` names it: tests find it as `group `, its workspaces as -/// `group workspaces ` and each one's link as `workspace link `. +/// none, then, pushed right into the rows' `Menu` column, its `menu`. `key` names it: tests +/// find it as `group `, its workspaces as `group workspaces ` and each one's link as +/// `workspace link `. #[allow(clippy::too_many_arguments)] pub fn group_header( key: SharedString, @@ -123,6 +124,7 @@ pub fn group_header( workspaces: &[Linker], on_toggle: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, on_workspace: OnWorkspace, + menu: Option, cx: &App, ) -> AnyElement { let s = cx.theme().semantic(); @@ -130,6 +132,7 @@ pub fn group_header( let names = div() .debug_selector(move || format!("group workspaces {selector}")) .flex() + .flex_1() .min_w_0() .text_size(font_size::SM) .text_color(s.muted_foreground); @@ -168,6 +171,8 @@ pub fn group_header( key, label, count, collapsed, select, on_toggle, cx, )) .child(names) + // Penpot `Group`: its `Menu` sits where the rows' does, `space.2` in from the right. + .children(menu.map(|menu| div().flex_none().pr(space::S2).child(menu))) .into_any_element() } diff --git a/crates/agentdeck-gui/src/pull_requests.rs b/crates/agentdeck-gui/src/pull_requests.rs index 61b638b..f981bda 100644 --- a/crates/agentdeck-gui/src/pull_requests.rs +++ b/crates/agentdeck-gui/src/pull_requests.rs @@ -29,6 +29,11 @@ //! reference after asking ([`ClosePrs`]); a PR that didn't close stays picked, marked with why. //! Select is disabled while there is no PR to show. //! +//! A group's `…` menu ([`group_menu`]) opens it on GitHub and links its Repository to a +//! Workspace, or, on a Workspace's Pull requests, unlinks it, each at once with an Undo; its +//! New workspace asks the window for New workspace with the Repository picked +//! ([`NewWorkspaceLinking`]). +//! //! A Workspace's Pull requests has no sync controls: its header ends in Select, Show finished //! and **Edit workspace**. With no Repository linked it says so, with **Link repository**, //! which opens Edit workspace with its "Link a repository…" picker focused. @@ -65,6 +70,7 @@ use gpui::{ use crate::api::Api; use crate::close_prs::{self, ClosePrs, Target}; +use crate::group_menu::{self, NewWorkspaceLinking}; use crate::gui_state; use crate::open_pr; use crate::overview::Snapshot; @@ -348,6 +354,7 @@ pub struct PullRequestsView { impl EventEmitter for PullRequestsView {} impl EventEmitter for PullRequestsView {} impl EventEmitter for PullRequestsView {} +impl EventEmitter for PullRequestsView {} impl PullRequestsView { /// A view of the PRs in `scope` that syncs and closes PRs through `api`; it shows nothing @@ -616,6 +623,7 @@ impl PullRequestsView { let on_workspace: pr_table::OnWorkspace = Rc::new(move |workspace, _, cx| { let _ = this.update(cx, |_, cx| cx.emit(OpenWorkspace(workspace))); }); + let menu = self.group_menu(repository, cx); pr_table::group_header( name.clone(), label.clone(), @@ -625,6 +633,7 @@ impl PullRequestsView { workspaces, cx.listener(move |this, _, _, cx| this.toggle(repository, cx)), on_workspace, + menu, cx, ) } @@ -685,6 +694,36 @@ impl PullRequestsView { table::spaced(item) } + /// `repository`'s group `…` menu ([`group_menu`]), over the Repository as last read. + fn group_menu(&self, repository: RepositoryId, cx: &mut Context) -> Option { + let held = group_menu::held(&self.snapshot, repository)?; + let workspace = match self.scope { + Scope::All => None, + Scope::Workspace(id) => Some(Linker { + id, + name: self.workspace_name().unwrap_or_default(), + }), + }; + let elsewhere = (self.snapshot.linking(repository).iter()) + .any(|w| workspace.as_ref().is_none_or(|ws| ws.id != w.id)); + let target = group_menu::Target { + repository: held, + workspace, + open: group_menu::open_prs(&self.snapshot, repository), + elsewhere, + }; + let this = cx.entity().downgrade(); + let on_new_workspace: group_menu::OnNewWorkspace = Rc::new(move |repository, _, cx| { + let _ = this.update(cx, |_, cx| cx.emit(NewWorkspaceLinking(repository))); + }); + Some(group_menu::menu( + group_menu::entries(&self.snapshot, self.scope, repository), + target, + self.api.clone(), + on_new_workspace, + )) + } + /// Penpot `Header`: heading and description, a spacer, Select (disabled with no PR to /// show), Show finished, when PRs last synced, "Sync now", `space.3` apart. The heading and /// description take what the rest leave, the description wrapping, so the header fits the @@ -1253,6 +1292,311 @@ mod tests { asked } + /// A Repository group's `…` menu (spec §11): what it offers, and the Links it makes and + /// takes away at once, each with a toast and Undo. + mod group_menu { + use super::*; + use crate::group_menu::NewWorkspaceLinking; + + /// Opens `repository`'s group `…` menu and presses `keys`. + fn press(repository: &str, keys: &str, cx: &mut VisualTestContext) { + click(format!("group menu {repository}"), cx); + cx.update(|window, cx| window.draw(cx).clear(cx)); + cx.simulate_keystrokes(keys); + cx.run_until_parked(); + cx.update(|window, cx| window.draw(cx).clear(cx)); + } + + /// The menu's 4px padding, then a 32px row per item before it and half of its own; + /// a separator before it adds its 9px. + fn row_y(n: usize, separated: bool) -> gpui::Pixels { + let separator = if separated { 9. } else { 0. }; + px(4. + 32. * (n - 1) as f32 + separator + 16.) + } + + /// Opens `repository`'s Link to a workspace submenu by hovering its trigger, the + /// menu's second item, and clicks the submenu's `n`th item, after the separator when + /// `separated`. + fn pick_in_submenu( + repository: &str, + n: usize, + separated: bool, + cx: &mut VisualTestContext, + ) { + click(format!("group menu {repository}"), cx); + let menu = bounds("dropdown-menu-content".into(), cx); + let trigger = point(menu.center().x, menu.top() + row_y(2, false)); + cx.simulate_mouse_move(trigger, None, Modifiers::default()); + let submenu = bounds("dropdown-menu-sub-content".into(), cx); + let item = point(submenu.center().x, submenu.top() + row_y(n, separated)); + cx.simulate_click(item, Modifiers::default()); + cx.run_until_parked(); + } + + fn last_notice(cx: &mut VisualTestContext) -> crate::notice::Notice { + cx.update(|_, cx| crate::notice::shown(cx).last().cloned().expect("a toast")) + } + + fn undo(cx: &mut VisualTestContext) { + let undo = last_notice(cx).action.expect("an Undo"); + assert_eq!(undo.label, "Undo"); + cx.update(|window, cx| undo.run(window, cx)); + cx.run_until_parked(); + } + + /// The Workspaces linking `repo` in the fake daemon now. + fn linking(harness: &Harness, repo: &str) -> Option> { + let snapshot = harness.api.snapshot_now(); + (snapshot.repositories.iter()) + .find(|r| r.id == repository_id(repo)) + .map(|r| r.workspaces.clone()) + } + + /// Whether the window was asked for New workspace, and with which Repository. + fn asked_new_workspace( + harness: &Harness, + cx: &mut VisualTestContext, + ) -> Rc>> { + let asked = Rc::new(RefCell::new(Vec::new())); + let seen = asked.clone(); + let subscription = cx.update(|_, cx| { + cx.subscribe(&harness.view, move |_, NewWorkspaceLinking(r), _| { + seen.borrow_mut().push(r.name.to_string()); + }) + }); + std::mem::forget(subscription); + asked + } + + #[gpui::test] + fn should_show_a_menu_on_every_group_of_both_views(cx: &mut TestAppContext) { + let (_harness, cx) = Harness::open(linked(), cx); + for repository in ["acme/widgets", "acme/apples", "acme/gadgets", "acme/zebra"] { + assert!( + shows(format!("group menu {repository}"), cx), + "{repository}" + ); + } + let row = bounds("pr menu acme/widgets#3".into(), cx); + let group = bounds("group menu acme/widgets".into(), cx); + assert_eq!(group.right(), row.right(), "in the rows' Menu column"); + } + + #[gpui::test] + fn should_show_a_menu_on_a_workspaces_groups_those_with_no_prs_included( + cx: &mut TestAppContext, + ) { + let (_harness, cx) = Harness::open_in(a(), linked(), cx); + + assert!(shows("group menu acme/widgets".into(), cx)); + assert!(shows("group menu acme/tools".into(), cx)); + } + + #[gpui::test] + fn should_open_the_repository_on_github_from_its_first_item(cx: &mut TestAppContext) { + let (_harness, cx) = Harness::open(linked(), cx); + let opener = cx.update(|_, cx| crate::terminal::open::fake::install(cx)); + + press("acme/gadgets", "down enter", cx); + + assert_eq!( + *opener.started.lock().unwrap(), + [[ + "xdg-open".to_owned(), + "https://github.com/acme/gadgets".to_owned() + ]] + ); + } + + mod link_to_a_workspace { + use super::*; + + #[gpui::test] + fn should_link_the_workspace_picked_at_once_with_a_toast(cx: &mut TestAppContext) { + let (harness, cx) = Harness::open(linked(), cx); + + // gadgets: old links it, but is archived, so a then b are offered. + pick_in_submenu("acme/gadgets", 2, false, cx); + + let links = harness.api.links.lock().unwrap().clone(); + assert_eq!(links.len(), 1); + assert_eq!(links[0].0, id(2)); + assert_eq!(links[0].1.id, repository_id("acme/gadgets")); + let notice = last_notice(cx); + assert_eq!(notice.title, "Linked acme/gadgets to b"); + assert_eq!(notice.description, None); + } + + #[gpui::test] + fn should_unlink_it_again_on_undo(cx: &mut TestAppContext) { + let (harness, cx) = Harness::open(linked(), cx); + pick_in_submenu("acme/gadgets", 1, false, cx); + assert_eq!(linking(&harness, "acme/gadgets"), Some(vec![id(3), id(1)])); + + undo(cx); + + assert_eq!( + *harness.api.unlinks.lock().unwrap(), + [(id(1), repository_id("acme/gadgets"))] + ); + assert_eq!(linking(&harness, "acme/gadgets"), Some(vec![id(3)])); + } + + #[gpui::test] + fn should_offer_the_workspaces_that_do_not_link_it_then_new_workspace( + cx: &mut TestAppContext, + ) { + let (harness, cx) = Harness::open(linked(), cx); + let asked = asked_new_workspace(&harness, cx); + + // apples: linked by none, so a and b, a separator, then New workspace. + pick_in_submenu("acme/apples", 3, true, cx); + + assert_eq!(*asked.borrow(), ["acme/apples"]); + assert!(harness.api.links.lock().unwrap().is_empty()); + } + + #[gpui::test] + fn should_offer_only_new_workspace_when_every_workspace_links_it( + cx: &mut TestAppContext, + ) { + let (harness, cx) = Harness::open(linked(), cx); + let asked = asked_new_workspace(&harness, cx); + + // widgets: a and b link it, and old is archived. + pick_in_submenu("acme/widgets", 1, false, cx); + + assert_eq!(*asked.borrow(), ["acme/widgets"]); + assert!(harness.api.links.lock().unwrap().is_empty()); + } + + #[gpui::test] + fn should_toast_why_a_link_failed(cx: &mut TestAppContext) { + let (harness, cx) = Harness::open(linked(), cx); + harness.api.fail_next("the daemon went away"); + + pick_in_submenu("acme/gadgets", 1, false, cx); + + let notice = last_notice(cx); + assert_eq!(notice.title, "Couldn't link acme/gadgets to a"); + assert!(notice.action.is_none()); + } + } + + mod unlink_from_this_workspace { + use super::*; + + /// `linked()` with one open PR in tools, which only `a` links. + fn tools_with_a_pr() -> Snapshot { + let mut snapshot = linked(); + snapshot.prs.push(pull_request(5, "acme/tools")); + snapshot + } + + /// Unlinks `repository` from `a` with the menu's last item. + fn unlink(repository: &str, cx: &mut VisualTestContext) { + press(repository, "down down down enter", cx); + } + + #[gpui::test] + fn should_unlink_at_once_saying_its_prs_no_longer_show_here(cx: &mut TestAppContext) { + let (harness, cx) = Harness::open_in(a(), linked(), cx); + + unlink("acme/widgets", cx); + + assert_eq!( + *harness.api.unlinks.lock().unwrap(), + [(id(1), repository_id("acme/widgets"))] + ); + assert_eq!(linking(&harness, "acme/widgets"), Some(vec![id(2)])); + let notice = last_notice(cx); + assert_eq!(notice.title, "Unlinked acme/widgets from a"); + assert_eq!( + notice.description.as_deref(), + Some("Its 1 open PR no longer shows here.") + ); + } + + #[gpui::test] + fn should_say_where_its_prs_are_when_no_other_workspace_links_it( + cx: &mut TestAppContext, + ) { + let (_harness, cx) = Harness::open_in(a(), tools_with_a_pr(), cx); + + unlink("acme/tools", cx); + + let notice = last_notice(cx); + assert_eq!(notice.title, "Unlinked acme/tools from a"); + assert_eq!( + notice.description.as_deref(), + Some( + "Its 1 open PR no longer shows here. It's in the Pull requests view, \ + under Not in a workspace." + ) + ); + } + + #[gpui::test] + fn should_link_it_again_on_undo(cx: &mut TestAppContext) { + let (harness, cx) = Harness::open_in(a(), linked(), cx); + unlink("acme/widgets", cx); + + undo(cx); + + assert_eq!(linking(&harness, "acme/widgets"), Some(vec![id(2), id(1)])); + } + + #[gpui::test] + fn should_link_it_again_on_undo_once_the_unlink_deleted_the_repository( + cx: &mut TestAppContext, + ) { + let (harness, cx) = Harness::open_in(a(), linked(), cx); + // tools: only a links it and it has no PRs, so the unlink deletes it. + unlink("acme/tools", cx); + assert_eq!(linking(&harness, "acme/tools"), None); + assert_eq!(last_notice(cx).description, None, "no open PRs to speak of"); + + undo(cx); + + let links = harness.api.links.lock().unwrap().clone(); + assert_eq!(links.len(), 1); + let (workspace, held) = &links[0]; + assert_eq!(*workspace, id(1)); + assert_eq!( + (held.id, held.name.to_string(), held.url.as_str()), + ( + repository_id("acme/tools"), + "acme/tools".to_owned(), + "https://github.com/acme/tools" + ) + ); + assert_eq!(linking(&harness, "acme/tools"), Some(vec![id(1)])); + } + + #[gpui::test] + fn should_toast_why_an_unlink_failed(cx: &mut TestAppContext) { + let (harness, cx) = Harness::open_in(a(), linked(), cx); + harness.api.fail_next("the daemon went away"); + + unlink("acme/widgets", cx); + + let notice = last_notice(cx); + assert_eq!(notice.title, "Couldn't unlink acme/widgets from a"); + assert_eq!(linking(&harness, "acme/widgets"), Some(vec![id(1), id(2)])); + } + + #[gpui::test] + fn should_not_be_offered_on_the_pull_requests_view(cx: &mut TestAppContext) { + let (harness, cx) = Harness::open(linked(), cx); + + // Its last item there is Link to a workspace, which only opens its submenu. + press("acme/widgets", "down down down enter", cx); + + assert!(harness.api.unlinks.lock().unwrap().is_empty()); + } + } + } + mod linked { use super::*; diff --git a/crates/agentdeck-gui/src/shell.rs b/crates/agentdeck-gui/src/shell.rs index 86cca35..c8190d5 100644 --- a/crates/agentdeck-gui/src/shell.rs +++ b/crates/agentdeck-gui/src/shell.rs @@ -35,6 +35,7 @@ use std::rc::Rc; use std::sync::Arc; use agentdeck_client::ApiError; +use agentdeck_client::types::Repository; use agentdeck_core::{PaneId, WorkspaceId}; use agentdeck_notify::Notifier; use brrritscold_core_gpui::{ @@ -59,9 +60,10 @@ use crate::connection::{Connection, Status}; use crate::delete_workspace::{DeleteEvent, DeleteTarget, DeleteWorkspaceDialog}; use crate::edit_workspace::{EditTarget, EditWorkspaceDialog, Saved}; use crate::frame; +use crate::group_menu::NewWorkspaceLinking; use crate::gui_state::{self, Side}; use crate::keymap::ToggleSide; -use crate::link_picker::Offer; +use crate::link_picker::{Choice, Offer}; use crate::new_agent::{self, Launched, NewAgent, NewAgentDialog, Target, home_folder}; use crate::new_workspace::{Created, NewWorkspaceDialog}; use crate::notice::{self, Notice, NoticeAction}; @@ -436,6 +438,13 @@ impl Shell { shell.open_workspace_prs(*id, window, cx); }, ), + cx.subscribe_in( + &pull_requests, + window, + |shell, _, NewWorkspaceLinking(repository), window, cx| { + shell.new_workspace_linking(repository, window, cx); + }, + ), // Show the agent's workspace and tab, and focus it: it may be asking // about trust. cx.subscribe_in( @@ -557,6 +566,13 @@ impl Shell { shell.open_workspace_prs(*id, window, cx); }, ), + cx.subscribe_in( + &view, + window, + |shell, _, NewWorkspaceLinking(repository), window, cx| { + shell.new_workspace_linking(repository, window, cx); + }, + ), cx.subscribe(&view, |shell, _, _: &OpenSettings, cx| { shell.open_settings(cx) }), @@ -855,6 +871,28 @@ impl Shell { }); } + /// Opens New workspace with `repository` already picked to link: a group's New workspace. + fn new_workspace_linking( + &mut self, + repository: &Repository, + window: &mut Window, + cx: &mut Context, + ) { + let (Some(sidebar), Some(dialog)) = (&self.sidebar, &self.new_workspace) else { + return; + }; + let offer = Offer::read(sidebar.read(cx).snapshot(), None); + let picked = Choice { + id: repository.id, + name: repository.name.clone(), + private: repository.private, + unreachable: false, + }; + dialog.update(cx, |dialog, cx| { + dialog.open_linking(offer, picked, window, cx) + }); + } + /// Opens the Delete workspace dialog on the selected workspace. fn delete_workspace(&mut self, window: &mut Window, cx: &mut Context) { let (Some(sidebar), Some(dialog), Some(Selection::Workspace(selected))) = @@ -1935,6 +1973,42 @@ mod tests { assert!(shows("pick acme/widgets", cx)); } + #[gpui::test] + fn should_open_new_workspace_with_the_repository_picked_from_a_groups_menu( + cx: &mut TestAppContext, + ) { + use crate::link_picker::Staged; + + let (harness, cx) = open(cx); + cx.update(|window, _| window.activate_window()); + click_side(&harness, Side::PullRequests, cx); + click(&harness, "group menu acme/widgets", cx); + let menu = cx.debug_bounds("dropdown-menu-content").expect("it opens"); + // The menu's 4px padding, then its second 32px row: Link to a workspace. + let trigger = gpui::point(menu.center().x, menu.top() + gpui::px(4. + 32. + 16.)); + cx.simulate_mouse_move(trigger, None, gpui::Modifiers::default()); + harness.settle(cx); + let submenu = cx + .debug_bounds("dropdown-menu-sub-content") + .expect("it opens"); + + // docs, the separator, then New workspace. + let y = submenu.top() + gpui::px(4. + 32. + 9. + 16.); + harness.click(gpui::point(submenu.center().x, y), cx); + + let dialog = harness + .shell + .read_with(cx, |shell, _| shell.new_workspace.clone().unwrap()); + assert!(dialog.read_with(cx, |d, _| d.is_open())); + let picker = dialog.read_with(cx, |d, _| d.picker().clone()); + let rows: Vec<(String, Staged)> = picker.read_with(cx, |p, _| { + (p.rows().iter()) + .map(|r| (r.repository.name.to_string(), r.staged)) + .collect() + }); + assert_eq!(rows, [("acme/widgets".to_owned(), Staged::Linking)]); + } + #[gpui::test] fn should_hide_the_switch_on_an_archived_workspace(cx: &mut TestAppContext) { let (harness, cx) = open(cx); diff --git a/crates/agentdeck-gui/src/workspace.rs b/crates/agentdeck-gui/src/workspace.rs index 4ee913e..ffb20a2 100644 --- a/crates/agentdeck-gui/src/workspace.rs +++ b/crates/agentdeck-gui/src/workspace.rs @@ -4,8 +4,8 @@ //! tab's split tree, a [`PaneView`] at each leaf; or its Pull requests (Penpot "Workspace · //! Pull requests"), a [`PullRequestsView`] over the Repositories it links. Each workspace opens //! on the side it showed last, remembered in the GUI's own state ([`gui_state`]); a new one -//! opens on its Panes. Its Pull requests' asks, to open another Workspace's Pull requests or -//! Settings, go on to the window. +//! opens on its Panes. Its Pull requests' asks, to open another Workspace's Pull requests, +//! Settings or New workspace with a Repository picked, go on to the window. //! //! It reads the workspace's tabs and panes when it opens and again whenever the daemon reports //! a tab or pane `changed`. Each shown pane keeps its view, and so its @@ -54,6 +54,7 @@ use gpui_base::actions::Confirm; use crate::api::{Api, PaneAt, Split, WorkspacePanes}; use crate::connection::{Connection, DaemonEvent}; +use crate::group_menu::NewWorkspaceLinking; use crate::gui_state::{self, Side}; use crate::keymap::{ self, ClosePane, NewTab, NextPane, NextTab, PreviousPane, PreviousTab, SelectTab, SplitDown, @@ -126,11 +127,12 @@ pub struct WorkspaceView { pull_requests: Entity, _events: Subscription, /// Passes its Pull requests' asks on to the window. - _pull_requests: [Subscription; 2], + _pull_requests: [Subscription; 3], } impl EventEmitter for WorkspaceView {} impl EventEmitter for WorkspaceView {} +impl EventEmitter for WorkspaceView {} impl WorkspaceView { /// `workspace`, headed by `top_bar`, read through `api` and attached over `connection`'s @@ -167,6 +169,9 @@ impl WorkspaceView { cx.emit(*ask) }), cx.subscribe(&pull_requests, |_, _, ask: &OpenSettings, cx| cx.emit(*ask)), + cx.subscribe(&pull_requests, |_, _, ask: &NewWorkspaceLinking, cx| { + cx.emit(ask.clone()); + }), ]; let mut view = WorkspaceView { workspace, diff --git a/crates/agentdeckd/tests/integration/prs.rs b/crates/agentdeckd/tests/integration/prs.rs index 1bafa55..1c77bf6 100644 --- a/crates/agentdeckd/tests/integration/prs.rs +++ b/crates/agentdeckd/tests/integration/prs.rs @@ -2331,7 +2331,9 @@ mod finished { .into_inner(); (daemon.client.link_create()) .id(web.id) - .body(NewLink::named("acme/widgets".parse().expect("a Repository"))) + .body(NewLink::named( + "acme/widgets".parse().expect("a Repository"), + )) .send() .await .expect("link"); diff --git a/crates/agentdeckd/tests/integration/repositories.rs b/crates/agentdeckd/tests/integration/repositories.rs index 5de3d80..94ec6a2 100644 --- a/crates/agentdeckd/tests/integration/repositories.rs +++ b/crates/agentdeckd/tests/integration/repositories.rs @@ -363,7 +363,7 @@ mod post_v1_workspaces_links { #[tokio::test] async fn should_store_a_deleted_repository_again_from_what_the_client_holds_signed_out_200() - { + { let daemon = TestDaemon::start().await; let web = workspace(&daemon.client, "web").await; let private = RestRepo { diff --git a/crates/agentdeckd/tests/integration/repositories_client.rs b/crates/agentdeckd/tests/integration/repositories_client.rs index 6370e11..2293a3a 100644 --- a/crates/agentdeckd/tests/integration/repositories_client.rs +++ b/crates/agentdeckd/tests/integration/repositories_client.rs @@ -44,7 +44,9 @@ mod list { .into_inner(); (daemon.client.link_create()) .id(web.id) - .body(NewLink::named("acme/widgets".parse().expect("a Repository"))) + .body(NewLink::named( + "acme/widgets".parse().expect("a Repository"), + )) .send() .await .expect("link"); From aef68603ef318eae5e494f68ff7676214c723bd8 Mon Sep 17 00:00:00 2001 From: bRRRITSCOLD Date: Mon, 23 Nov 2026 16:27:52 -0700 Subject: [PATCH 3/4] docs(spec): the group menu's Link and Unlink, and linking by GitHub's id Co-Authored-By: Claude Opus 5.5 --- docs/spec.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/spec.md b/docs/spec.md index 14882e3..cb5cbb3 100644 --- a/docs/spec.md +++ b/docs/spec.md @@ -128,6 +128,8 @@ v1.1 adds `channels`, `channel_members` and `messages` in their own migration. Every pane in a response (`POST` and `GET` on `/v1/panes`) carries `hosted_agent`: `claude` or `codex` while a shell pane hosts that agent (§3, §7), else null. It came with `API_VERSION` 6. Every pane also carries `folder`, its current folder (§3, §6), an absolute path; it came with `API_VERSION` 18. +`API_VERSION` 25 let `POST /v1/workspaces/{id}/links` link a Repository by GitHub's id (§11 Pull requests view, Group menu): it takes `id`, `url`, `private` and `archived` beside `repository`, and with `id` it never asks GitHub. An older daemon ignores them and looks the name up, so Undo after an unlink that deleted the Repository fails there while signed out; the GUI's Restart banner (§2) comes first. + `API_VERSION` 24 let a Workspace's create and update carry its Links (§11 Edit workspace and New workspace): `POST /v1/workspaces` takes `link`, and `PATCH /v1/workspaces/{id}` takes `link` and `unlink`, beside `name` and `muted`. An older daemon ignores both fields, so the GUI's Restart banner (§2) comes first. `API_VERSION` 23 took the Workspace's folder away (§3): every Workspace lost `dir` and `dir_owned`, `POST /v1/workspaces` its `dir` (an older client's is ignored, and makes no folder), and the dirty report route (`GET /v1/workspaces/{id}/dirty`) and `DELETE /v1/workspaces/{id}`'s `force` went (an older client's `force` is ignored). An older CLI's `ws rm` without `--force` deletes at once. @@ -142,7 +144,7 @@ Every pane in a response (`POST` and `GET` on `/v1/panes`) carries `hosted_agent | `DELETE /v1/workspaces/{id}` | deletes the Workspace with its tabs and panes, stopping their processes as a pane's `DELETE` does. Its Links go, and each Repository it linked that nothing names now (§3). It touches no folder: a Workspace has none, and its Panes' folders are the user's. Sends `changed` for each Repository it linked, then the workspace | | `GET /v1/repositories?workspace=` | every Repository agentdeck keeps (§3), each a `RepositoryLinks`: `{ id, name, url, private, archived, unreachable, workspaces }`, GitHub's id, `owner/name`, its page, whether it is private and archived as GitHub last said, whether the GitHub sign-in can no longer see it, and the ids of the Workspaces that link it, oldest first, archived ones included (empty for one kept only for its PRs). Ordered by name ignoring case, then id. `workspace` (an id) keeps only the Repositories that Workspace links; one that doesn't exist is `unknown_workspace`. It came with `API_VERSION` 19 | | `GET /v1/repositories/resolve?repository=` | look a typed Repository up on GitHub (§8): `repository` is `owner/name` or its GitHub URL (text that names none is dropshot's own 400). Answers the `Repository` (`{ id, name, url, private, archived }`) as GitHub shows it now, an old name finding a renamed one under its new name. Stores no new Repository; a known one takes GitHub's name, URL, private and archived (a `changed` event when they differ). `400 unknown_repository` when GitHub doesn't show it, `409 not_signed_in`, `502 github_error`. It came with `API_VERSION` 19 | -| `POST /v1/workspaces/{id}/links`, `DELETE /v1/workspaces/{id}/links/{repository}` | link the Workspace to a Repository, and unlink it. POST `{ repository: "owner/name" }` (or its GitHub URL) finds a Repository agentdeck keeps by its name now, ignoring case, without asking GitHub; one it doesn't is resolved first, as above, and stored with the Link, so one GitHub doesn't show is `400 unknown_repository` and links nothing (`409 not_signed_in` and `502 github_error` as above). Linking a pair already linked changes nothing. It answers 200 with the `RepositoryLinks`. DELETE names the Repository by its id and answers 204; the Repository goes too when no other Link names it and no stored PR belongs to it (§3). Both are `404 not_found` for a Workspace that doesn't exist, DELETE also for a Repository the Workspace doesn't link. Each sends `changed` for the Repository, then the Workspace, when a Link was added or removed. They came with `API_VERSION` 19 | +| `POST /v1/workspaces/{id}/links`, `DELETE /v1/workspaces/{id}/links/{repository}` | link the Workspace to a Repository, and unlink it. POST `{ repository: "owner/name" }` (or its GitHub URL) finds a Repository agentdeck keeps by its name now, ignoring case, without asking GitHub; one it doesn't is resolved first, as above, and stored with the Link, so one GitHub doesn't show is `400 unknown_repository` and links nothing (`409 not_signed_in` and `502 github_error` as above). POST `{ repository, id, url?, private?, archived? }` links by GitHub's `id` instead, as a client holds the Repository (the GUI always does, so a group's Link and an unlink's Undo work signed out): the Repository agentdeck keeps with that id is linked as it is, whatever its name now, and one it no longer keeps (an unlink deleted it, §3) is stored again from the body, `url` defaulting to `https://github.com/` and `private` and `archived` to false, never asking GitHub; PR sync corrects what GitHub says differently. Linking a pair already linked changes nothing. It answers 200 with the `RepositoryLinks`. DELETE names the Repository by its id and answers 204; the Repository goes too when no other Link names it and no stored PR belongs to it (§3). Both are `404 not_found` for a Workspace that doesn't exist, DELETE also for a Repository the Workspace doesn't link. Each sends `changed` for the Repository, then the Workspace, when a Link was added or removed. They came with `API_VERSION` 19, linking by `id` with 25 | | `GET/POST /v1/workspaces/{id}/tabs`, `PATCH/DELETE /v1/tabs/{id}` | tabs and their layout tree, listed in `position` order | | `POST /v1/panes` | spawn: `{tab_id, kind, agent?, argv?, cwd}`; see §6. `cwd` must be an existing absolute dir (`invalid_dir`); a shell without `argv` runs `$SHELL`, else `/bin/sh`; a program that can't start is `invalid_argv`. An agent pane names its `agent` and a shell names none (`unsupported_kind`); `other` needs `argv`, `claude` and `codex` take none (`invalid_argv`). The PTY starts at 80×24. The client places the pane in the tab's `layout` | | `GET /v1/panes/{id}`, `DELETE /v1/panes/{id}` | read (live title, state, exit code and `hosted_agent` while the process runs in this daemon, and `folder`, read again as it answers: a pane that moved is saved there first and gets `changed`, §6); kill (SIGHUP to its process group and the foreground one, then SIGKILL after 3 s) and delete. Deleting a tab or workspace kills its panes too | @@ -426,11 +428,14 @@ Built on `brrritscold-core-gpui` (`init`, `Root`, theme preference, toasts). Scr - **Appearance:** Theme, a Select of System / Dark / Light, its trigger as wide as its value and chevron (about 96px for "System"), not the section's 480px, "System follows your desktop's light or dark setting." Picking one applies it at once and saves it with `PATCH /v1/settings`; a failed save puts the saved theme back and toasts why. - **Terminal:** "Open file paths with", an input holding `terminal.file_opener`, "Ctrl+click a file path in a pane to run this. {path} is the file and {line} its line, when the path has one (src/main.rs:42). For example: code -g {path}:{line}". It saves as the days field does: Enter or leaving the field. A blank command ("Enter a command, such as xdg-open {path}."), an unclosed quote ("Close the quote in the command.") or one with no `{path}` ("Pass {path} to the command, as in code -g {path}:{line}.") shows the field's error and isn't saved, as does the daemon's `invalid_setting`. Any other failure toasts why. - **General**, last (Penpot "Settings" → `General`): "Ask before quitting while agents run", a horizontal Field with a Switch holding `gui.confirm_quit`, described "Agents keep running in the background after agentdeck quits. Off, Quit and the close button quit at once." Flipping it shows the new value at once and saves it with `PATCH /v1/settings`; a failed save puts the saved value back and toasts "Couldn't save Ask before quitting" with why. -- **Pull requests view** (Penpot "Screens · Main" → "Pull requests", "· row menu", "· row menu · unreachable PR", "· unreachable PR", "· logged out", "· empty", "· show finished", "· highlighted row", "· select"): every pull request PR sync keeps that is open on GitHub and not Finished, each under its **Repository** (`GET /v1/prs?finished=true`, §4, read with the sidebar's other reads and again on each `changed`), and the Finished ones too while Show finished is on. +- **Pull requests view** (Penpot "Screens · Main" → "Pull requests", "· row menu", "· row menu · unreachable PR", "· unreachable PR", "· logged out", "· empty", "· show finished", "· highlighted row", "· select", "· group menu", "· group menu · no workspace to link", "· linked"): every pull request PR sync keeps that is open on GitHub and not Finished, each under its **Repository** (`GET /v1/prs?finished=true`, §4, read with the sidebar's other reads and again on each `changed`), and the Finished ones too while Show finished is on. - **Header:** "Pull requests" (xl medium) over two sm `muted-foreground` lines with no gap between them: "Your open PRs, by repository." ("Your open and finished PRs, by repository." while Show finished is on), then the age cutoff from `GET /v1/prs/status` (§8): "PRs not updated in the last N days are left out; change that in Settings." ("1 day" for 1), or "Every open PR syncs." for `0`, its "Settings" a link (`primary`, underlined on hover, as core-gpui's link button) that opens Settings at its GitHub section; until the status is read only the first line shows. Then, pushed right, **Select** (Select mode, below), **Show finished** (a Switch and its Label, `space.2` apart), when PRs last synced (sm `muted-foreground`: "Synced 2 min ago", "Syncing… 100 of 271 PRs", "Syncing details…", "Sync failed", "Not synced yet", or "Not signed in" while `logged_out`, a running sync showing first) and an outline **Sync now**, which runs a full sync (§8), reads "Syncing…" until the daemon says more, is disabled until it answers, and has the sidebar read again once it ends, since a sync that changes nothing broadcasts nothing; a failure toasts "Couldn't sync PRs" with why. The heading and description take what the rest leave, the description wrapping, so the header fits the narrowest window (Window, above). - **Logged out** (Penpot "Pull requests · logged out", "· logged out · synced before"): while `GET /v1/prs/status` says `logged_out`, a default alert with the `Info` icon sits between the header and the list, over the empty state too: "Not signed in to GitHub, so PRs don't sync.", or, once a sync ran as a login (`synced_as`, §8), "Synced as . Sign in to refresh.", the stored PRs still listed as last synced, with an **Open Settings** link (as the description's "Settings" link) that opens Settings at its GitHub section. It goes once a token works again. - **Show finished** shows Finished PRs (§8) in their Repositories' groups and counts, and hides them again when turned off. It is remembered across restarts in the GUI state (Window, above). - **Groups:** one per Repository with a PR to show, by GitHub's Repository id; a Repository with none shows no group. Linked Repositories come first, then those Not in a workspace, each alphabetical by the Repository's name without its owner (ignoring case, then by owner). A group's header is Penpot's `GroupHeader` (a chevron, the name in sm medium, a `secondary` badge counting its PRs) followed, `space.2` after it, by who links it (sm `muted-foreground`): each Workspace linking the Repository by name, in the sidebar's order, " · " between them, each a link (underlined on hover, as a PR's reference) to that Workspace's Pull requests (Workspace view, above); or "Not in a workspace" while none does. Archived Workspaces link nothing (`GET /v1/repositories`, §4): they are absent from the headers and the order, so a Repository linked only by them reads Not in a workspace. Two Repositories with the same name read `owner/name` instead. A click on the `GroupHeader` collapses the group, or opens it, and the collapsed groups are remembered across restarts in the GUI state (Window, above), apart from each Workspace's Pull requests'. Its PRs go by number. + - **Group menu** (Penpot "Pull requests · group menu", "· group menu · no workspace to link"): each group header ends, pushed right into the rows' `…` column, in a ghost icon-xs `…` opening 4px below it with their right edges lined up, as a row's does: **Open on GitHub**, which opens the Repository's GitHub page (Opening PRs, below; a handler that can't start toasts "Couldn't open the repository"), and **Link to a workspace**, a submenu (opening on the menu's left when the window has no room on its right) of the Workspaces that aren't archived and don't link the Repository, by name in the sidebar's order, then a separator and **New workspace**; with no Workspace to offer, New workspace is its only item. Archived Workspaces are never offered: unarchive one first. A Workspace's Pull requests adds a separator and **Unlink from this workspace** (Workspace's Pull requests, below). + - **Linking** applies at once, with no dialog: it links by GitHub's id with the Repository as last read (`POST /v1/workspaces/{id}/links` with `id`, §4), so it never asks GitHub, and toasts "Linked owner/name to " with **Undo**, which unlinks it again (Penpot "Pull requests · linked"). The group's header names the Workspace once the daemon's `changed` is read, and a Repository that was Not in a workspace moves up among the linked ones. A failure toasts "Couldn't link owner/name to " with why. + - **New workspace** opens the new workspace dialog (Dialogs, below) with the Repository already picked in its Repositories, staged to link. - **Columns** (Penpot `Columns`, xs medium `muted-foreground`): the state icon's 16px slot, Title, PR (140), the draft badge's 52px slot, Checks (80), Review (128) and the 24px `…` slot, `space.3` apart, padded `space.2`; the title takes what's left, down to 160px, wrapping. In Select mode a 16px column for the checkboxes comes first. The table fits the narrowest window whole, in Select mode too, so no column drops. - **Rows:** Penpot `TaskRow` (`wide`) without its status picker: the PR's state icon (14px, PR state under Colours, below: `GitPullRequest` in `foreground`, `GitPullRequestDraft` in `muted-foreground` while a draft, and on a Finished row GitHub's state: `GitMerge` in `merged`, `GitPullRequestClosed` in `destructive`, or the open icon for one past the age cutoff), its title (sm `foreground`), its reference as its number (`#63`, sm `muted-foreground`), an outline "draft" badge while a draft, its checks (core-gpui's `Checks` with its word) and review (Colours, below), and its `…` menu. Only the reference is a link: underlined on hover, a click opens the PR on GitHub (Opening PRs, below), in Select mode too. A click anywhere else on the row does nothing, except toggle it in Select mode (below). - **Row menu** (a ghost icon-xs `…`, opening 4px below it with their right edges lined up): **Open on GitHub**; **Copy PR details**, which puts the PR's three lines on the clipboard (below) and toasts "Copied PR details", with no shortcut, since the table has no keyboard row focus to aim one; then, while the PR is stored `open` and reachable, Finished or not, a separator and **Close PR** in `destructive`, which opens the Close PRs confirm dialog for that PR, closes it by reference and toasts (Closing PRs, below). A closed PR is Finished, so it leaves the list once its `changed` is read, unless Show finished is on. @@ -451,13 +456,14 @@ Built on `brrritscold-core-gpui` (`init`, `Root`, theme preference, toasts). Scr - **Unreachable** PRs (§8, Penpot "Pull requests · unreachable PR") are listed as last synced, the whole row at half opacity, with a tooltip above the title ("Your GitHub sign-in can't see this PR. It's shown as it was last synced."). They are left out of the sidebar's count, and their menu has Open on GitHub and Copy PR details but no Close PR. - **Empty:** with no PR to show, the header and the banner as above, then "No open PRs. PRs you open on GitHub show here." (sm `muted-foreground`, padded `space.2` across) in place of the columns and the list, with Select disabled (Penpot "Pull requests · empty"). - It draws only the rows in view, and redraws "Synced …" every 30 s. -- **A Workspace's Pull requests** (Penpot "Screens · Main" → "Workspace · Pull requests", "Workspace · no repositories"): a workspace's Pull requests side, the Pull requests view's list over the Repositories the workspace links, with the same groups, order, rows, row menu, Select mode, Show finished, Unreachable rows and logged-out banner, which sits above it too. +- **A Workspace's Pull requests** (Penpot "Screens · Main" → "Workspace · Pull requests", "Workspace · no repositories", "Workspace · Pull requests · group menu", "· unlinked", "· unlinked · not in a workspace"): a workspace's Pull requests side, the Pull requests view's list over the Repositories the workspace links, with the same groups, order, rows, row menu, group menu, Select mode, Show finished, Unreachable rows and logged-out banner, which sits above it too. + - **Unlink from this workspace**, last in a group's menu after a separator, applies at once, with no dialog (`DELETE /v1/workspaces/{id}/links/{repository}`, §4): the group leaves once the daemon's `changed` is read. The toast "Unlinked owner/name from " says "Its N open PRs no longer show here." ("Its 1 open PR no longer shows here."), N counted as the sidebar counts (§11 Sidebar), and adds "They're in the Pull requests view, under Not in a workspace." ("It's …" for one) when no other Workspace that isn't archived links the Repository; with no open PR it says only the title. Its **Undo** links the Repository again by GitHub's id with what the view held of it (`id`, name, `url`, `private`, `archived`), so it works even when the unlink deleted the Repository (§3), signed out included. A failure toasts "Couldn't unlink owner/name from " with why; a failed Undo, "Couldn't link …" or "Couldn't unlink …". - **Header:** no heading, since the top bar names the workspace: two sm `muted-foreground` lines, "Your open PRs from the repositories links." ("Your open and finished PRs …" while Show finished is on) over "Link or unlink repositories in Edit workspace.", then, pushed right, **Select**, **Show finished** and an outline **Edit workspace**, which opens the edit workspace dialog as the `…` menu's does. It has no sync controls. - **Groups:** every Repository the workspace links shows a group, PRs or none, collapsed or open apart from the Pull requests view's, remembered per Repository for each workspace (GUI state, above). A linked Repository with no PR to show reads "No open PRs" (sm `muted-foreground`, padded `space.2` across, a row's height) under its header. - **No Repositories:** a workspace linking none shows only its header, reading "No repositories linked yet. Link one to see its PRs here." over "They stay in Pull requests too.", with an outline **Link repository** in place of Select, Show finished and Edit workspace; it opens the edit workspace dialog with its "Link a repository…" picker focused and its list open (Dialogs, below). - A PR alert's click still lands on the Pull requests view, and only the Pull requests view withdraws PR alerts. - **Table width:** the Pull requests table fits its columns to the width instead of scrolling sideways: every row ends in a 24px column for its `…` menu and, in Select mode, starts with a 16px one for its checkbox, and the title column takes what's left, down to 160px, its text wrapping. No column drops: the window's least width fits the table whole in Select mode (Window, above). Only below that layout would the table scroll sideways. -- **Opening PRs:** a PR's GitHub page opens in the default browser at its stored `url` (§3), from a Pull requests view row's reference or its Open on GitHub (above). +- **Opening PRs:** a PR's GitHub page opens in the default browser at its stored `url` (§3), from a Pull requests view row's reference or its Open on GitHub (above); a Repository's, from its group menu's Open on GitHub. - **Opener:** the OS's handler, started as a pane's file links start theirs (`terminal.file_opener`'s default, `xdg-open`, with the URL as its one argument and no shell), so a handler that can't start is seen. It never runs the user's `terminal.file_opener`. - **Safety:** only a `url` whose scheme is `https` and whose host is `github.com` (no user, no port) opens. Anything else is refused silently with a debug log line, as a pane's link with another scheme is, so a stored value can't make a click run another handler. - **Failure:** when the handler can't start, a toast "Couldn't open the PR" with why (`xdg-open: `). @@ -471,7 +477,7 @@ Built on `brrritscold-core-gpui` (`init`, `Root`, theme preference, toasts). Scr - **Enter runs the primary action, Escape cancels, in every dialog**: these, Close pane's, Paste token, the sign-in dialog, Close PRs' confirm and Quit. Enter does nothing the primary button couldn't: while it is disabled, or the form can't go ahead, the dialog stays open. A focused select takes Enter first, to open or to pick. A focused button doesn't yet: Enter runs the primary action there too ([#335](https://github.com/bRRRITSCOLD/agentdeck/issues/335)); Space clicks it. - Enter in a dialog's single-line field does what its primary button does, and only that: when the form can't go ahead, or the daemon refuses it, the dialog stays open. - **New agent** (Penpot "Screens · Dialogs" → "New agent", "New agent · folder open") offers a Folder select, each folder once and labelled by its path with `~` for the home folder: first where a new pane starts (Workspace view, above: the focused pane's current folder, else `~`), preset; then the current folder of each other pane in the workspace, in tab and layout order, as the view last read them; then `~`. Its description reads "Where the focused pane is, another pane's folder, or your home folder." A workspace not shown (none of its panes read) offers `~` alone. There is no typed path or folder browser; `agentdeck agent new --cwd` starts one anywhere. The agent starts with no prompt (§6). - - **New workspace** (Penpot "Screens · Dialogs" → "New workspace", "New workspace · picker") is titled "New workspace", with "An area of work, such as one product, for any number of repos and agents.", and holds a Field, "Name" ("Names the sidebar entry."), then, `space.4` below, the optional **Repositories** with the "Link a repository…" picker (below): a workspace has no folder. Picked Repositories show as rows with their `×` and are linked by the create itself, `POST /v1/workspaces` `{ name, link }`. Enter in the name creates. A blank name ("Give the workspace a name.") or the daemon's `invalid_name` shows under the name field, a Repository the daemon can't link (`unknown_repository`, `not_signed_in`) under the picker, and nothing is made; any other failure toasts "Couldn't make the workspace". Once made it closes. + - **New workspace** (Penpot "Screens · Dialogs" → "New workspace", "New workspace · picker") is titled "New workspace", with "An area of work, such as one product, for any number of repos and agents.", and holds a Field, "Name" ("Names the sidebar entry."), then, `space.4` below, the optional **Repositories** with the "Link a repository…" picker (below): a workspace has no folder. Picked Repositories show as rows with their `×` and are linked by the create itself, `POST /v1/workspaces` `{ name, link }`. Opened from a Repository group's New workspace (Pull requests view, Group menu), it holds that Repository as a picked row already. Enter in the name creates. A blank name ("Give the workspace a name.") or the daemon's `invalid_name` shows under the name field, a Repository the daemon can't link (`unknown_repository`, `not_signed_in`) under the picker, and nothing is made; any other failure toasts "Couldn't make the workspace". Once made it closes. - **Edit workspace** (Penpot "Screens · Dialogs" → "Edit workspace", "Edit workspace · error" for a blank name, "Edit workspace · unlinked", "· picker", "· typed repo", "· GitHub can't see it" and "· signed out") is titled "Edit ", with "Its pull requests come from the repositories it links.". It holds (Penpot `agentdeck/EditWorkspaceForm`) the "Name" field, which opens holding the name, selected and focused, its error under it, then the **Repositories** the workspace links and the "Link a repository…" picker (below), `space.4` apart. Opened from the no-Repositories state's **Link repository** (`LinkRepository`), the picker takes the keyboard instead, its list open. The footer is Cancel and **Save**; Save is disabled while the name is blank, while nothing changed (the name, trimmed, as it was and nothing staged) and while a typed Repository is being looked up, and Enter in the name does the same. Links and unlinks are staged until Save, which applies them with the name in one request, `PATCH /v1/workspaces/{id}` `{ name?, link, unlink }` (the name only when it changed), and closes; the changes come back through `changed` to the sidebar, the views and the dialogs that list workspaces. Cancel and Escape discard what was staged, and there is no confirm dialog. The slug stays as it is, so running panes are unaffected and the CLI still finds the workspace by its old slug; nothing on disk changes. Two workspaces may share a name. A blank name shows "Give the workspace a name." under the field as soon as it is blank, its input `aria-invalid`; the daemon's `invalid_name` shows there too and keeps the dialog open. A Repository the daemon can't link (`unknown_repository`, `not_signed_in`, `invalid_links`) shows its message under the picker and keeps the dialog open, with nothing applied. Any other failure keeps it open and toasts "Couldn't save " with why. An archived workspace can be edited too. - **Repositories** (Penpot `agentdeck/LinkedRepository` rows, `agentdeck/LinkPickerList`, `agentdeck/PickerItem`; an app-local composition, since core-gpui's Combobox draws text-only items): a "Repositories" Label, then a row per Repository the workspace links, by name ignoring case, `space.2` apart from the label, note and field. A row (h-8, `space.2` gaps, sm) is a 14px lucide `Lock` in `muted-foreground` for a private Repository (page-local `agentdeck/icon/Lock` in Penpot until the library has it), its `owner/name` in `foreground`, an outline "Unreachable" Badge while the GitHub sign-in can't see it, then, pushed right, a ghost icon-xs `X`, Unlink. Unlink crosses the row out (`muted-foreground`, line-through) and swaps its `X` for a link xs **Undo**, which puts it back; a picked row's `X` just drops it. Under the rows a sm `muted-foreground` note counts the open PRs the staged unlinks take out of the workspace, counted as its sidebar count is (drafts in, Unreachable and Finished out): "2 open PRs will leave this workspace", "1 open PR will leave this workspace", omitted at 0. Then the picker, an Input with the placeholder "Link a repository…", whose list opens 6px below it, as wide, while it has the keyboard or is typed into, and closes on Escape, a click outside or a pick. The list, drawn as core-gpui's `ComboboxContent`, holds **From your pull requests** (a Combobox label over the Repositories of your kept PRs, Finished ones' included, by name, each row with the lock when private), leaving out every Repository the dialog's rows hold and Unreachable ones; typing filters it locally, by name ignoring case, a pasted GitHub URL by the name it holds. Text that parses as `owner/name` or a GitHub URL and names no listed or linked Repository adds a "Link owner/name" row (lucide `Plus`), which asks GitHub (`GET /v1/repositories/resolve`; it reads "Looking up owner/name…" meanwhile) and, once GitHub shows it, stages it as a row under the name GitHub gives; if GitHub can't see it, the list closes and the daemon's "GitHub can't see owner/name. Check the name or your token's access." shows under the field, the field `aria-invalid`, until the next keystroke. Nothing matching reads "No repositories match.". After a separator the list ends in "Not listed? Type owner/name or paste its URL.", or, signed out (PR status reads the token logged out), "Sign in to GitHub to find more repositories." with no typed row: only Repositories agentdeck keeps can be picked. Enter in the field picks the list's first row. All your repositories (`/user/repos`) is tracked in [#371](https://github.com/bRRRITSCOLD/agentdeck/issues/371) and Suggested in [#373](https://github.com/bRRRITSCOLD/agentdeck/issues/373). - **Delete workspace** is titled "Delete ?", with "This can't be undone. Archive it instead to keep its panes and linked Repositories." Deleting touches no folder, so there is nothing on disk to warn about. @@ -525,8 +531,8 @@ Built on `brrritscold-core-gpui` (`init`, `Root`, theme preference, toasts). Scr | Tier | Where | What | |---|---|---| -| unit | `agentdeck-core`, GUI views (`#[gpui::test]`), daemon pure parts | rules with recorded output (the Copy PR details text among them, one PR's and several joined by a blank line), layout tree, snapshot encode/decode round-trip, env allowlist, `openapi.json` staleness; GUI views over a fake API and a fake notifier, asserting what a user sees (the Pull requests view's groups and their order, collapse and Show finished kept in the GUI state file, Finished rows hidden until Show finished and showing GitHub's state, the row's link and menu, Sync now, the banner, the empty state, Unreachable rows; Select mode: entering and leaving it, picking by row click, group checkbox (folded too) and select-all, which rows can be picked (open and reachable, Finished-but-open included; not merged, closed or Unreachable), the bar's count and order, Copy PR details joined in the list's order, Close PRs asking then closing by reference, a PR that didn't close kept picked and marked with why, a closed PR shown closed at once, "Closing N of M…", and Select disabled on the empty view; the header and the table fitting the narrowest window in Select mode, and that window's minimum fitting the narrowest PR table in Select mode; the sidebar's entries and counts, Finished PRs left out, no Inbox or Tasks entry, each Workspace's count over its linked Repositories, none on an archived row, the no-Workspaces hint and its New workspace, Pull requests the fallback selection; linked groups first, then Not in a workspace, each alphabetical, a group's header naming its linking Workspaces as links that open their Pull requests, Archived Workspaces absent from headers and order; a Workspace's side switch with its count, `secondary-shift-p`, each Workspace's side remembered across a restart and opened from its sidebar row, a new one on its Panes; a Workspace's Pull requests: only its linked Repositories, "No open PRs", Select, Show finished and Edit workspace with no sync controls, the banner, collapse kept apart from the Pull requests view's, the no-Repositories state whose Link repository opens Edit workspace with its picker focused and open; Edit workspace and New workspace: the linked rows with their Unlink, lock and Unreachable badge, staging until Save (one request with the name, applied to the fake, none before), Save enabled by a staged change alone, Undo, the leaving note and its singular and its absence at 0, Cancel discarding what was staged, a refusal under the picker keeping the dialog open, an archived workspace linked, the picker's From your pull requests (no linked, picked or Unreachable Repository; the lock), local filtering ignoring case and by a pasted URL, picking (the field cleared), Enter picking the first row, the typed row only for an unlisted name, GitHub showing it (staged under GitHub's name, private kept) or not ("GitHub can't see …" under the field, the list closed, cleared by typing), signed out (no typed row, "Sign in to GitHub to find more repositories."), and New workspace linking what was picked on create; the picker's offer read from a snapshot (linked ones, Unreachable included; your PRs' reachable Repositories; open PRs counted as the sidebar does; signed out only while the token is logged out); the archived screen with no switch; a pane notifying while its workspace shows its Pull requests; New workspace's Name field and optional picker; New agent's Folder select (where a new pane starts first, the other panes' folders, then `~`, each once) and a new pane starting in `~` in a workspace with none; the Delete workspace dialog's lines (its Repositories unlinked, its running panes stopped, each left out at 0); the archive toast; the top bar's name, centred, before its side switch; a Pane alert's body, " · ", and the pane header's parts; PR alerts over the fake notifier: each trigger, only PRs you authored, one alert per PR replaced on a new change, a click landing on the row with its group opened, a Finished row shown with Show finished left off, scrolled to and highlighted until the highlight fades, "N PRs changed" opening the view, an alert withdrawn once the view shows, and the mute rule with every linking Workspace muted, one unmuted, only Archived muted ones, and none); the PR alert mute rule and the GitHub remote parser (https, ssh and scp-like URLs, for Suggestions) in `agentdeck-core` | -| integration | `agentdeckd/tests/integration` | temp `$XDG_*` dirs, a real daemon on a random port, a real client; PTYs run `sh`, which moves a pane with `cd` (read through `/proc`) or `printf`s an OSC 7, so a pane's current folder, its `changed` and its restore folder are tested without a shell that reports one; GitHub is httpmock (`AGENTDECK_GITHUB_API`, `AGENTDECK_GITHUB_REST_API` and `AGENTDECK_GITHUB_OAUTH`: GraphQL with `closePullRequest`, REST's `GET /repos/{owner}/{repo}` for Repository lookups and Links, and the device flow's code and token endpoints); `gh` is a stub script on `PATH`, and so are `claude` and `codex`, which read input as their TUIs do, and exit on a submitted `/exit` so a shell pane's hosted agent can leave (raw, bracketed paste on, a read that is a lone `\r` submits, any other read is a paste); the keyring is an in-memory fake store (`AGENTDECK_KEYRING=memory`; without it the harness's daemon has no session bus, so no keyring). The `agentdeck_client` helpers the GUI's real API calls (`panes`, `settings`, `prs`, `repositories`, `workspaces`) are tested here through the real client (`*_client`), each new operation of the GUI's fake API with a test of the same call in the same PR, so the fake can't drift from the daemon; `prs::list` also lists none from a daemon older than `GET /v1/prs`, and lists Finished PRs, marked; `repositories::list` lists each Repository with the Workspaces linking it, Archived ones included, and none from a daemon older than `GET /v1/repositories`; `repositories::resolve` answers the Repository GitHub shows for a typed URL and fails with the daemon's "GitHub can't see …"; `workspaces::create` makes a Workspace linking what was picked, or nothing, and `workspaces::update` renames, links and unlinks together, or changes nothing, failing with the daemon's words. The Workspace routes' Links are tested here too: create linking a Repository agentdeck keeps (no GitHub call) and one GitHub resolves, nothing made when GitHub can't see one; update renaming, linking and unlinking in one request (an unreferenced Repository gone), nothing changed when a link fails or the name is blank, `invalid_links`, unlinking one it doesn't link changing nothing, an archived Workspace linked, and `changed` for each Repository then the workspace. PR sync's Finished PRs are tested here too: Finished on merge, on close (from GitHub and from agentdeck) and past the cutoff, no longer Finished once GitHub shows a PR open again, deleted with their unreferenced Repositories after the window (`AGENTDECK_PR_FINISHED_SECS=0`), and Unreachable PRs kept with no window. PRs are kept by Repository and number: a renamed Repository's PR and one of another Repository that took the old name are two PRs. Workspaces without folders are tested here too: creating one makes nothing on disk and its JSON has no folder, an older client's `dir` and `force` are ignored, the dirty report route is gone (dropshot's own 404), deleting one unlinks its Repositories (a Repository nothing else names goes) and stops its panes but leaves every folder on disk (its panes' folders and an old scratch folder), the first pane of a workspace with none opens in `~` through `panes::new_shell_tab`, and `0002` drops the folder columns from a database at `0001`, keeping each Workspace and its Links. The fresh start is tested here too: a fresh data dir gets the migrations' schema (no `tasks`, `comments` or `instructions`; `pull_requests` keyed by `(repository_id, number)` with nothing unique on a name), a current database survives a restart, and a database with a `tasks` table, its last writes still in its WAL, is moved aside with its WAL and SHM files (the moved one still reads), logged, never over an earlier one, with scratch folders left alone, and the daemon starts empty | +| unit | `agentdeck-core`, GUI views (`#[gpui::test]`), daemon pure parts | rules with recorded output (the Copy PR details text among them, one PR's and several joined by a blank line), layout tree, snapshot encode/decode round-trip, env allowlist, `openapi.json` staleness; GUI views over a fake API and a fake notifier, asserting what a user sees (the Pull requests view's groups and their order, collapse and Show finished kept in the GUI state file, Finished rows hidden until Show finished and showing GitHub's state, the row's link and menu, Sync now, the banner, the empty state, Unreachable rows; Select mode: entering and leaving it, picking by row click, group checkbox (folded too) and select-all, which rows can be picked (open and reachable, Finished-but-open included; not merged, closed or Unreachable), the bar's count and order, Copy PR details joined in the list's order, Close PRs asking then closing by reference, a PR that didn't close kept picked and marked with why, a closed PR shown closed at once, "Closing N of M…", and Select disabled on the empty view; the header and the table fitting the narrowest window in Select mode, and that window's minimum fitting the narrowest PR table in Select mode; the sidebar's entries and counts, Finished PRs left out, no Inbox or Tasks entry, each Workspace's count over its linked Repositories, none on an archived row, the no-Workspaces hint and its New workspace, Pull requests the fallback selection; linked groups first, then Not in a workspace, each alphabetical, a group's header naming its linking Workspaces as links that open their Pull requests, Archived Workspaces absent from headers and order; the group `…` menu on every group of both views, in the rows' `…` column: Open on GitHub opening the Repository's page, Link to a workspace offering the Workspaces that aren't archived and don't link it in the sidebar's order then New workspace, New workspace alone when none is eligible, New workspace opening the dialog with the Repository picked, a link applied at once by GitHub's id with "Linked owner/name to " and an Undo that unlinks, Unlink from this workspace only on a Workspace's Pull requests, applied at once with "Unlinked owner/name from " and its open PRs (singular, plural, none, and where they went when no other Workspace links it), its Undo linking again by id once the unlink deleted the Repository, and failures toasted; a Workspace's side switch with its count, `secondary-shift-p`, each Workspace's side remembered across a restart and opened from its sidebar row, a new one on its Panes; a Workspace's Pull requests: only its linked Repositories, "No open PRs", Select, Show finished and Edit workspace with no sync controls, the banner, collapse kept apart from the Pull requests view's, the no-Repositories state whose Link repository opens Edit workspace with its picker focused and open; Edit workspace and New workspace: the linked rows with their Unlink, lock and Unreachable badge, staging until Save (one request with the name, applied to the fake, none before), Save enabled by a staged change alone, Undo, the leaving note and its singular and its absence at 0, Cancel discarding what was staged, a refusal under the picker keeping the dialog open, an archived workspace linked, the picker's From your pull requests (no linked, picked or Unreachable Repository; the lock), local filtering ignoring case and by a pasted URL, picking (the field cleared), Enter picking the first row, the typed row only for an unlisted name, GitHub showing it (staged under GitHub's name, private kept) or not ("GitHub can't see …" under the field, the list closed, cleared by typing), signed out (no typed row, "Sign in to GitHub to find more repositories."), and New workspace linking what was picked on create; the picker's offer read from a snapshot (linked ones, Unreachable included; your PRs' reachable Repositories; open PRs counted as the sidebar does; signed out only while the token is logged out); the archived screen with no switch; a pane notifying while its workspace shows its Pull requests; New workspace's Name field and optional picker; New agent's Folder select (where a new pane starts first, the other panes' folders, then `~`, each once) and a new pane starting in `~` in a workspace with none; the Delete workspace dialog's lines (its Repositories unlinked, its running panes stopped, each left out at 0); the archive toast; the top bar's name, centred, before its side switch; a Pane alert's body, " · ", and the pane header's parts; PR alerts over the fake notifier: each trigger, only PRs you authored, one alert per PR replaced on a new change, a click landing on the row with its group opened, a Finished row shown with Show finished left off, scrolled to and highlighted until the highlight fades, "N PRs changed" opening the view, an alert withdrawn once the view shows, and the mute rule with every linking Workspace muted, one unmuted, only Archived muted ones, and none); the PR alert mute rule and the GitHub remote parser (https, ssh and scp-like URLs, for Suggestions) in `agentdeck-core` | +| integration | `agentdeckd/tests/integration` | temp `$XDG_*` dirs, a real daemon on a random port, a real client; PTYs run `sh`, which moves a pane with `cd` (read through `/proc`) or `printf`s an OSC 7, so a pane's current folder, its `changed` and its restore folder are tested without a shell that reports one; GitHub is httpmock (`AGENTDECK_GITHUB_API`, `AGENTDECK_GITHUB_REST_API` and `AGENTDECK_GITHUB_OAUTH`: GraphQL with `closePullRequest`, REST's `GET /repos/{owner}/{repo}` for Repository lookups and Links, and the device flow's code and token endpoints); `gh` is a stub script on `PATH`, and so are `claude` and `codex`, which read input as their TUIs do, and exit on a submitted `/exit` so a shell pane's hosted agent can leave (raw, bracketed paste on, a read that is a lone `\r` submits, any other read is a paste); the keyring is an in-memory fake store (`AGENTDECK_KEYRING=memory`; without it the harness's daemon has no session bus, so no keyring). The `agentdeck_client` helpers the GUI's real API calls (`panes`, `settings`, `prs`, `repositories`, `workspaces`) are tested here through the real client (`*_client`), each new operation of the GUI's fake API with a test of the same call in the same PR, so the fake can't drift from the daemon; `prs::list` also lists none from a daemon older than `GET /v1/prs`, and lists Finished PRs, marked; `repositories::list` lists each Repository with the Workspaces linking it, Archived ones included, and none from a daemon older than `GET /v1/repositories`; `repositories::resolve` answers the Repository GitHub shows for a typed URL and fails with the daemon's "GitHub can't see …"; `repositories::link` links by GitHub's id and links again, signed out, once an unlink deleted the Repository, and `repositories::unlink` keeps one another Workspace links and fails with the daemon's `not_found` for one the Workspace doesn't link; `workspaces::create` makes a Workspace linking what was picked, or nothing, and `workspaces::update` renames, links and unlinks together, or changes nothing, failing with the daemon's words. The Workspace routes' Links are tested here too: create linking a Repository agentdeck keeps (no GitHub call) and one GitHub resolves, nothing made when GitHub can't see one; update renaming, linking and unlinking in one request (an unreferenced Repository gone), nothing changed when a link fails or the name is blank, `invalid_links`, unlinking one it doesn't link changing nothing, an archived Workspace linked, and `changed` for each Repository then the workspace. The link route's link by GitHub's `id` is tested here too: a Repository an unlink deleted stored again from the body signed out (no GitHub, where a link by name is `not_signed_in`), the Repository kept with that id linked under its name now, `changed` for the Repository then the workspace, and `404 not_found` storing nothing for a Workspace that doesn't exist. PR sync's Finished PRs are tested here too: Finished on merge, on close (from GitHub and from agentdeck) and past the cutoff, no longer Finished once GitHub shows a PR open again, deleted with their unreferenced Repositories after the window (`AGENTDECK_PR_FINISHED_SECS=0`), and Unreachable PRs kept with no window. PRs are kept by Repository and number: a renamed Repository's PR and one of another Repository that took the old name are two PRs. Workspaces without folders are tested here too: creating one makes nothing on disk and its JSON has no folder, an older client's `dir` and `force` are ignored, the dirty report route is gone (dropshot's own 404), deleting one unlinks its Repositories (a Repository nothing else names goes) and stops its panes but leaves every folder on disk (its panes' folders and an old scratch folder), the first pane of a workspace with none opens in `~` through `panes::new_shell_tab`, and `0002` drops the folder columns from a database at `0001`, keeping each Workspace and its Links. The fresh start is tested here too: a fresh data dir gets the migrations' schema (no `tasks`, `comments` or `instructions`; `pull_requests` keyed by `(repository_id, number)` with nothing unique on a name), a current database survives a restart, and a database with a `tasks` table, its last writes still in its WAL, is moved aside with its WAL and SHM files (the moved one still reads), logged, never over an earlier one, with scratch folders left alone, and the daemon starts empty | | integration | `mod integration_tests` in `agentdeckd/src` | a crate-private part over a real dependency, which `tests/integration` can't reach since the daemon is a binary: a `Pane` over a real PTY running `sh` reads as exited only once its exit is recorded. The integration nextest profile runs these modules; the unit one skips them | | integration | `agentdeckd/tests/integration` (keyring) | the keyring store against a real Secret Service: `gnome-keyring-daemon`, unlocked, on a private `dbus-daemon` session bus the test starts, as `agentdeck-notify`'s test does, which CI installs with `script/install-linux-deps.sh`. It saves, finds, replaces and deletes the token and client ID entries, and finds none with no Secret Service. It is the fake store's contract test: the same cases run against the fake, and a fake lands with a test of the real call in the same PR | | integration | `agentdeck/tests/integration` | the real `agentdeck` binary in temp `$XDG_*` dirs, starting the real daemon itself, with GitHub on httpmock, GraphQL and REST, for `pr ls` (by Repository and by workspace), `pr close`, `repo ls|link|unlink` and `ws new|ls|rename|rm` (no folder made or removed, `ws ls`' REPOSITORIES in text and `--json`, `ws rm` unlinking, no `--dir`, `--repo` or `--force`); a long-lived client (the test binary re-run as a child, connecting through `agentdeck_client::daemon`, as the GUI does) for reaping and restarting the daemon it started; panes run `sh`, never a real agent CLI | From f0e13d882947763958eea568b32b409964a239e7 Mon Sep 17 00:00:00 2001 From: bRRRITSCOLD Date: Mon, 23 Nov 2026 16:29:21 -0700 Subject: [PATCH 4/4] docs(gui): keep the toast titles' placeholders out of rustdoc's HTML Co-Authored-By: Claude Opus 5.5 --- crates/agentdeck-gui/src/group_menu.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/agentdeck-gui/src/group_menu.rs b/crates/agentdeck-gui/src/group_menu.rs index 9115ab4..8b5ae58 100644 --- a/crates/agentdeck-gui/src/group_menu.rs +++ b/crates/agentdeck-gui/src/group_menu.rs @@ -103,12 +103,12 @@ pub fn open_prs(snapshot: &Snapshot, repository: RepositoryId) -> usize { .count() } -/// The toast after a link: "Linked owner/name to ". +/// The toast after a link: `Linked owner/name to `. pub fn linked_title(repository: &str, workspace: &str) -> String { format!("Linked {repository} to {workspace}") } -/// The toast after an unlink: its title, "Unlinked owner/name from ", and what it +/// The toast after an unlink: its title, `Unlinked owner/name from `, and what it /// says of the Repository's `open` PRs: they no longer show here, and, when no other Workspace /// links it (`elsewhere` false), where they are now. With no open PR it says only the title. pub fn unlinked(