Skip to content

Commit e4095d8

Browse files
committed
fix(desktop): scope connections to Projects
Signed-off-by: KC <[email protected]>
1 parent d8907c1 commit e4095d8

9 files changed

Lines changed: 31 additions & 18 deletions

File tree

‎desktop/src-tauri/src/managed_agents/project_connections.rs‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ pub(super) fn lock_project_connections() -> MutexGuard<'static, ()> {
4949
pub struct ProjectConnectionScope {
5050
pub relay_url: String,
5151
pub operator_pubkey: String,
52-
/// Canonical NIP-34 repository coordinate (`30617:<owner>:<d-tag>`).
53-
pub repo_address: String,
52+
/// Canonical NIP-MP Project coordinate (`30621:<owner>:<d-tag>`).
53+
///
54+
/// Legacy one-repository Projects use their NIP-34 repository coordinate
55+
/// (`30617:<owner>:<d-tag>`).
56+
pub project_address: String,
5457
}
5558

5659
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
@@ -241,11 +244,11 @@ pub(super) fn canonical_project_scope(
241244
{
242245
return Err("Buzz could not verify who owns these connections.".to_string());
243246
}
244-
let mut parts = scope.repo_address.splitn(3, ':');
247+
let mut parts = scope.project_address.splitn(3, ':');
245248
let kind = parts.next();
246249
let owner = parts.next();
247250
let d_tag = parts.next();
248-
if kind != Some("30617")
251+
if !matches!(kind, Some("30617") | Some("30621"))
249252
|| !owner.is_some_and(|value| {
250253
value.len() == 64 && value.bytes().all(|byte| byte.is_ascii_hexdigit())
251254
})
@@ -261,8 +264,9 @@ pub(super) fn canonical_project_scope(
261264
Ok(ProjectConnectionScope {
262265
relay_url,
263266
operator_pubkey: scope.operator_pubkey.to_ascii_lowercase(),
264-
repo_address: format!(
265-
"30617:{}:{}",
267+
project_address: format!(
268+
"{}:{}:{}",
269+
kind.unwrap_or_default(),
266270
owner.unwrap_or_default().to_ascii_lowercase(),
267271
d_tag.unwrap_or_default()
268272
),

‎desktop/src-tauri/src/managed_agents/project_connections/probe.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ mod tests {
389389
project_scope: ProjectConnectionScope {
390390
relay_url: "ws://127.0.0.1:3000".to_string(),
391391
operator_pubkey: "a".repeat(64),
392-
repo_address: format!("30617:{}:portable-agents", "a".repeat(64)),
392+
project_address: format!("30621:{}:portable-agents", "a".repeat(64)),
393393
},
394394
name: "Synthetic analytics".to_string(),
395395
provider: "Buzz test fixture".to_string(),
@@ -438,7 +438,7 @@ mod tests {
438438
project_scope: ProjectConnectionScope {
439439
relay_url: "ws://127.0.0.1:3000".to_string(),
440440
operator_pubkey: "a".repeat(64),
441-
repo_address: format!("30617:{}:portable-agents", "a".repeat(64)),
441+
project_address: format!("30621:{}:portable-agents", "a".repeat(64)),
442442
},
443443
name: "Test".to_string(),
444444
provider: "Fixture".to_string(),

‎desktop/src-tauri/src/managed_agents/project_connections/tests.rs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ fn scope() -> ProjectConnectionScope {
44
ProjectConnectionScope {
55
relay_url: "ws://127.0.0.1:3000".to_string(),
66
operator_pubkey: "b".repeat(64),
7-
repo_address: format!("30617:{}:portable-agents", "a".repeat(64)),
7+
project_address: format!("30621:{}:portable-agents", "a".repeat(64)),
88
}
99
}
1010

@@ -39,11 +39,15 @@ fn project_scope_requires_canonical_relay_identity_and_coordinate() {
3939
localhost.relay_url = "ws://localhost:3000".to_string();
4040
assert_eq!(canonical_project_scope(&localhost).unwrap(), scope());
4141
let mut invalid = scope();
42-
invalid.repo_address = "local-project-id".to_string();
42+
invalid.project_address = "local-project-id".to_string();
4343
assert!(canonical_project_scope(&invalid).is_err());
4444
let mut invalid = scope();
4545
invalid.operator_pubkey = "not-a-key".to_string();
4646
assert!(canonical_project_scope(&invalid).is_err());
47+
48+
let mut legacy = scope();
49+
legacy.project_address = format!("30617:{}:portable-agents", "a".repeat(64));
50+
assert_eq!(canonical_project_scope(&legacy).unwrap(), legacy);
4751
}
4852

4953
#[test]
@@ -102,7 +106,7 @@ fn connection_lookup_cannot_cross_project_boundaries() {
102106
assert!(find_connection(&store, &connection.project_scope, &connection.id).is_ok());
103107

104108
let mut other_project = connection.project_scope;
105-
other_project.repo_address = format!("30617:{}:other-project", "a".repeat(64));
109+
other_project.project_address = format!("30621:{}:other-project", "a".repeat(64));
106110
assert!(find_connection(&store, &other_project, &connection.id).is_err());
107111
}
108112

‎desktop/src-tauri/src/managed_agents/project_connections/transactions.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ mod tests {
8888
project_scope: ProjectConnectionScope {
8989
relay_url: "ws://127.0.0.1:3000".to_string(),
9090
operator_pubkey: "a".repeat(64),
91-
repo_address: format!("30617:{}:portable-agents", "a".repeat(64)),
91+
project_address: format!("30621:{}:portable-agents", "a".repeat(64)),
9292
},
9393
name: "Test".to_string(),
9494
provider: "Fixture".to_string(),

‎desktop/src/features/projects/projectConnectionHooks.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const projectConnectionsQueryKey = (
1717
"project-connections",
1818
projectScope?.relayUrl ?? "",
1919
projectScope?.operatorPubkey ?? "",
20-
projectScope?.repoAddress ?? "",
20+
projectScope?.projectAddress ?? "",
2121
] as const;
2222

2323
export function useProjectConnectionsQuery(

‎desktop/src/features/projects/ui/ProjectWorkspaceTabs.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ export function WorkspaceTabs({
204204
? {
205205
relayUrl: activeCommunity.relayUrl,
206206
operatorPubkey: identityQuery.data.pubkey,
207-
repoAddress: project.repoAddress,
207+
// Legacy Projects are one repository. NIP-MP Projects pass their
208+
// own address here once the multi-repository model lands.
209+
projectAddress: project.repoAddress,
208210
}
209211
: null;
210212
const localCheckoutSnapshot = localSnapshot?.snapshot ?? null;
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
export type ProjectConnectionScope = {
22
relayUrl: string;
33
operatorPubkey: string;
4-
/** Durable NIP-34 repository coordinate. Local Project.id is never persisted. */
5-
repoAddress: string;
4+
/**
5+
* Durable NIP-MP Project coordinate. Legacy one-repository Projects use their
6+
* NIP-34 repository coordinate.
7+
*/
8+
projectAddress: string;
69
};

‎desktop/src/testing/e2eBridge.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2975,7 +2975,7 @@ function projectConnectionScopesEqual(
29752975
return (
29762976
left.relayUrl === right.relayUrl &&
29772977
left.operatorPubkey === right.operatorPubkey &&
2978-
left.repoAddress === right.repoAddress
2978+
left.projectAddress === right.projectAddress
29792979
);
29802980
}
29812981

‎desktop/tests/e2e/project-connections-screenshots.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const DEFAULT_MOCK_PUBKEY = "deadbeef".repeat(8);
99
const PROJECT_SCOPE = {
1010
relayUrl: "ws://localhost:3000",
1111
operatorPubkey: DEFAULT_MOCK_PUBKEY,
12-
repoAddress: `30617:${DEFAULT_MOCK_PUBKEY}:buzz`,
12+
projectAddress: `30617:${DEFAULT_MOCK_PUBKEY}:buzz`,
1313
};
1414

1515
async function capture(page: Page, subject: Locator, filename: string) {

0 commit comments

Comments
 (0)