evOo-local/apps/web/src/lib/project-empty-state.ts
cynarAI 23084b460b fix(web): + Starten for empty projects instead of fallback bot (#92)
* fix(web): show Starten for empty projects instead of fallback bot

When a project space had no group conversations, the sidebar fell back
to listing 1:1 bots (e.g. Chief from onboarding) under the project name.
Bootstrap also redirected /app to the first bot, making it look like an
existing conversation.

Only show project group chats in Projekte, render + Starten for empty
projects, and open the existing create flow (group or bot) on click.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): keep empty-project Starten view and route flows correctly

Rebased onto main. Guard the Hauptthread auto-redirect when the current
space is an empty project so the main Starten CTA stays visible. Split
project start into create-bot vs create-group flows (main vs sidebar) and
feed home-space bots into the group form when starting from a project.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(web): surface empty-project Starten on Projekte pillar

Route bare /app in empty projects to the Projekte view, keep /app on
stale bot/group URLs, and show the create-group side panel without an
active thread.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(e2e): scope RPC to selected space and tighten Starten specs

Pass x-rakazo-space-id from Playwright RPC helpers so archive/list hit
the active project space. Trim the group-create Starten test to the side
panel flow and navigate to /app after archiving the last bot.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* style(e2e): format empty-project-starten spec

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

* fix(e2e): remove project bots so empty spaces stay deletable

Archived bots still count as space content and hide the delete-space
menu. Use bots/remove in spaces.spec when the test needs a deletable
empty project space.

Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>
2026-09-25 20:54:06 +02:00

27 lines
1.1 KiB
TypeScript

import type { Group, Space } from "@rakazo/contracts";
export function isHauptthreadGroup(group: Pick<Group, "id" | "name">): boolean {
return group.name === "Hauptthread" || group.name === "Team Chat";
}
/** Project-scoped group chats in a space (excludes Hauptthread). */
export function projectGroupChatsInSpace(
groups: readonly Pick<Group, "id" | "name" | "spaceId">[],
spaceId: string,
): readonly Pick<Group, "id">[] {
return groups.filter((group) => group.spaceId === spaceId && !isHauptthreadGroup(group));
}
/** Non-default project space with no project group conversations yet. */
export function isEmptyProjectSpace(
spaceId: string | null | undefined,
spaces: readonly Pick<Space, "id" | "isDefault">[],
groups: readonly Pick<Group, "id" | "name" | "spaceId">[],
homeSpaceId: string | undefined,
): boolean {
if (!spaceId || !homeSpaceId || spaceId === homeSpaceId) return false;
const space = spaces.find((item) => item.id === spaceId);
if (!space || space.isDefault) return false;
return projectGroupChatsInSpace(groups, spaceId).length === 0;
}