Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: restore team entry in unified builds (#7767)

Louis Beaumonta746cc6154ed
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-team-summary.test.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-team-summary.test.tsx
index e8a4cc4eb..1c6f00663 100644
--- a/apps/screenpipe-app-tauri/lib/hooks/use-team-summary.test.tsx
+++ b/apps/screenpipe-app-tauri/lib/hooks/use-team-summary.test.tsx
@@ -14,6 +14,7 @@ afterEach(() => {
vi.unstubAllGlobals();
vi.useRealTimers();
});
+
describe("passive team identity", () => {
it("uses membership identity independently of plan and never creates invites", async () => {
const fetcher = vi
@@ -63,6 +64,7 @@ describe("passive team identity", () => {
it("does not read personal teams for enterprise, hidden, or signed-out states", () => {
const fetcher = vi.fn();
vi.stubGlobal("fetch", fetcher);
+ Object.assign(build, { isEnterprise: true });
const enterprise = renderHook(() =>
useTeamSummary({ ...base, enterprise: true, orgName: "Northstar" }),
);
@@ -74,6 +76,7 @@ describe("passive team identity", () => {
useTeamSummary({ ...base, enabled: false }),
);
expect(hidden.result.current).toBeUndefined();
+ Object.assign(build, { isEnterprise: false });
const signedOut = renderHook(() =>
useTeamSummary({ ...base, token: null }),
);
@@ -134,29 +137,28 @@ describe("passive team identity", () => {
unmount();
});
});
-
-describe("Enterprise app visibility", () => {
+describe("Unified app team visibility", () => {
it.each([
- { isEnterprise: true, resolved: true, error: false },
{ isEnterprise: false, resolved: false, error: false },
{ isEnterprise: false, resolved: false, error: true },
- ])("hides the shared Chat/Workflows entry and skips lookup for %j", (status) => {
+ ])("waits for the build check before showing a signed-out consumer entry %j", (status) => {
Object.assign(build, status);
const fetcher = vi.fn();
vi.stubGlobal("fetch", fetcher);
- const { result } = renderHook(() => useTeamSummary(base));
+ const { result } = renderHook(() => useTeamSummary({ ...base, token: null }));
expect(result.current).toBeUndefined();
expect(fetcher).not.toHaveBeenCalled();
});
- it("removes a previously resolved team when the build is Enterprise", async () => {
+
+ it("keeps a resolved B2C team when build status changes to Enterprise", async () => {
const fetcher = vi.fn().mockResolvedValue(reply({ id: "studio", name: "Studio" }));
vi.stubGlobal("fetch", fetcher);
const { result, rerender } = renderHook(() => useTeamSummary(base));
await waitFor(() => expect(result.current?.label).toBe("Studio"));
Object.assign(build, { isEnterprise: true });
rerender();
- expect(result.current).toBeUndefined();
+ expect(result.current?.label).toBe("Studio");
act(() => window.dispatchEvent(new Event("focus")));
- expect(fetcher).toHaveBeenCalledOnce();
+ await waitFor(() => expect(fetcher).toHaveBeenCalledTimes(2));
});
});
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-team-summary.ts b/apps/screenpipe-app-tauri/lib/hooks/use-team-summary.ts
index 5384fcd72..9c9485a91 100644
--- a/apps/screenpipe-app-tauri/lib/hooks/use-team-summary.ts
+++ b/apps/screenpipe-app-tauri/lib/hooks/use-team-summary.ts
@@ -28,14 +28,19 @@ export function useTeamSummary({
orgName?: string | null;
}): TeamEntry | undefined {
const build = useEnterpriseBuildStatus();
- const consumerBuild = build.resolved && !build.error && !build.isEnterprise;
+ // Unified builds can serve both account types. Enterprise accounts use the
+ // organization member page; signed-in consumer accounts keep their B2C flow.
+ const canUseConsumerTeamFlow =
+ build.resolved &&
+ !build.error &&
+ (!build.isEnterprise || (!enterprise && Boolean(token)));
const [result, setResult] = useState<{
token: string;
team: Summary;
role?: string;
} | null>(null);
useEffect(() => {
- if (!consumerBuild || !enabled || enterprise || !token) return;
+ if (!canUseConsumerTeamFlow || !enabled || enterprise || !token) return;
let disposed = false;
let controller: AbortController | undefined;
let timer: ReturnType<typeof setTimeout> | undefined;
@@ -85,9 +90,9 @@ export function useTeamSummary({
clearTimeout(timer);
window.removeEventListener("focus", onFocus);
};
- }, [token, enabled, enterprise, consumerBuild]);
+ }, [token, enabled, enterprise, canUseConsumerTeamFlow]);
- if (!consumerBuild || !enabled) return undefined;
+ if (!enabled) return undefined;
if (enterprise)
return {
label: orgName?.trim() || "Your organization",
@@ -97,6 +102,7 @@ export function useTeamSummary({
"https://screenpipe.com",
),
};
+ if (!canUseConsumerTeamFlow) return undefined;
if (!token)
return { label: "Invite your team", href: teamPage, kind: "signed-out" };
if (!result || result.token !== token)
diff --git a/docs/pr-assets/unified-team-sidebar/after-detail.png b/docs/pr-assets/unified-team-sidebar/after-detail.png
new file mode 100644
index 000000000..b18d7b261
Binary files /dev/null and b/docs/pr-assets/unified-team-sidebar/after-detail.png differ
diff --git a/docs/pr-assets/unified-team-sidebar/after-popover.png b/docs/pr-assets/unified-team-sidebar/after-popover.png
new file mode 100644
index 000000000..692f1721b
Binary files /dev/null and b/docs/pr-assets/unified-team-sidebar/after-popover.png differ
diff --git a/docs/pr-assets/unified-team-sidebar/after.png b/docs/pr-assets/unified-team-sidebar/after.png
new file mode 100644
index 000000000..2f863aab5
Binary files /dev/null and b/docs/pr-assets/unified-team-sidebar/after.png differ
diff --git a/docs/pr-assets/unified-team-sidebar/before-detail.png b/docs/pr-assets/unified-team-sidebar/before-detail.png
new file mode 100644
index 000000000..52380db42
Binary files /dev/null and b/docs/pr-assets/unified-team-sidebar/before-detail.png differ
diff --git a/docs/pr-assets/unified-team-sidebar/before.png b/docs/pr-assets/unified-team-sidebar/before.png
new file mode 100644
index 000000000..c9dcf54cd
Binary files /dev/null and b/docs/pr-assets/unified-team-sidebar/before.png differ
diff --git a/docs/pr-assets/unified-team-sidebar/invite-menu-detail.png b/docs/pr-assets/unified-team-sidebar/invite-menu-detail.png
new file mode 100644
index 000000000..0c02e4d9b
Binary files /dev/null and b/docs/pr-assets/unified-team-sidebar/invite-menu-detail.png differ