Skip to content

The agent that grows with you

fix(desktop): allow project creation while browsing all profiles

brooklyn!2b6a5181a34b
diff --git a/apps/desktop/src/store/projects.ts b/apps/desktop/src/store/projects.ts
index 92cc823a9f3..8e2e2643731 100644
--- a/apps/desktop/src/store/projects.ts
+++ b/apps/desktop/src/store/projects.ts
@@ -319,10 +319,8 @@ function stillOnProjectsContext(context: ActiveProjectsContext): boolean {
return activeGateway() === context.gateway && projectProfile() === context.profile
}
-async function activeProjectsContext(): Promise<ActiveProjectsContext> {
- const profile = projectProfile()
-
- if (!profile) {
+async function activeProjectsContext(profile = projectProfile()): Promise<ActiveProjectsContext> {
+ if (!profile || profile === ALL_PROFILES) {
throw new Error('Projects are unavailable while viewing all profiles')
}
@@ -332,7 +330,7 @@ async function activeProjectsContext(): Promise<ActiveProjectsContext> {
gateway = await ensureActiveGatewayOpen()
}
- if (!gateway || gateway !== activeGateway() || profile !== projectProfile()) {
+ if (!gateway || gateway !== activeGateway() || profile !== normalizeProfileKey($activeGatewayProfile.get())) {
throw new Error('Active Hermes profile changed while connecting')
}
@@ -878,19 +876,27 @@ export async function createProject(input: CreateProjectInput): Promise<ProjectI
let res: { project: ProjectInfo | null }
try {
- res = await gatewayRequest<{ project: ProjectInfo | null }>(
+ // All profiles filters the sidebar, not the owner of a new project.
+ // Capture the live route so reconnecting cannot retarget the write.
+ const context = await activeProjectsContext(normalizeProfileKey($activeGatewayProfile.get()))
+
+ res = await gatewayRequestOn<{ project: ProjectInfo | null }>(
+ context.gateway,
'projects.create',
- projectParams({
- name: input.name,
- folders: input.folders ?? [],
- primary_path: input.primaryPath,
- slug: input.slug,
- description: input.description,
- icon: input.icon,
- color: input.color,
- board_slug: input.boardSlug,
- use: input.use ?? false
- })
+ projectParams(
+ {
+ name: input.name,
+ folders: input.folders ?? [],
+ primary_path: input.primaryPath,
+ slug: input.slug,
+ description: input.description,
+ icon: input.icon,
+ color: input.color,
+ board_slug: input.boardSlug,
+ use: input.use ?? false
+ },
+ context.profile
+ )
)
} catch (err) {
if (isMissingRpcMethod(err)) {