Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion apps/desktop/src/renderer/lib/auth-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@ export function getJwt(): string | null {
export const authClient = createAuthClient({
baseURL: env.NEXT_PUBLIC_API_URL,
plugins: [
organizationClient(),
organizationClient({
teams: { enabled: true },
schema: {
team: {
additionalFields: {
slug: { type: "string", input: true, required: true },
},
},
},
}),
customSessionClient<typeof auth>(),
stripeClient({ subscription: true }),
apiKeyClient(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import type {
SelectSubscription,
SelectTask,
SelectTaskStatus,
SelectTeam,
SelectTeamMember,
SelectUser,
SelectV2Client,
SelectV2Host,
Expand Down Expand Up @@ -119,6 +121,8 @@ export interface OrgCollections {
members: Collection<SelectMember>;
users: Collection<SelectUser>;
invitations: Collection<SelectInvitation>;
teams: Collection<SelectTeam>;
teamMembers: Collection<SelectTeamMember>;
agentCommands: Collection<SelectAgentCommand>;
integrationConnections: Collection<IntegrationConnectionDisplay>;
subscriptions: Collection<SelectSubscription>;
Expand Down Expand Up @@ -472,6 +476,38 @@ function createOrgCollections(organizationId: string): OrgCollections {
}),
);

const teams = createPersistedElectricCollection(
electricCollectionOptions<SelectTeam>({
id: `teams-${organizationId}`,
shapeOptions: {
url: electricUrl,
params: {
table: "auth.teams",
organizationId,
},
headers: electricHeaders,
columnMapper,
},
getKey: (item) => item.id,
}),
);

const teamMembers = createPersistedElectricCollection(
electricCollectionOptions<SelectTeamMember>({
id: `team-members-${organizationId}`,
shapeOptions: {
url: electricUrl,
params: {
table: "auth.team_members",
organizationId,
},
headers: electricHeaders,
columnMapper,
},
getKey: (item) => item.id,
}),
);
Comment on lines +479 to +509
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Fix collection id to match the established naming pattern.

The teamMembers collection id uses team-members-${organizationId} (with hyphen), but the pattern throughout this file is to preserve table name underscores in collection ids. For consistency with existing collections like task_statuses, v2_hosts, and automation_runs, the id should be team_members-${organizationId}.

♻️ Proposed fix
 	const teamMembers = createPersistedElectricCollection(
 		electricCollectionOptions<SelectTeamMember>({
-			id: `team-members-${organizationId}`,
+			id: `team_members-${organizationId}`,
 			shapeOptions: {
 				url: electricUrl,
 				params: {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const teams = createPersistedElectricCollection(
electricCollectionOptions<SelectTeam>({
id: `teams-${organizationId}`,
shapeOptions: {
url: electricUrl,
params: {
table: "auth.teams",
organizationId,
},
headers: electricHeaders,
columnMapper,
},
getKey: (item) => item.id,
}),
);
const teamMembers = createPersistedElectricCollection(
electricCollectionOptions<SelectTeamMember>({
id: `team-members-${organizationId}`,
shapeOptions: {
url: electricUrl,
params: {
table: "auth.team_members",
organizationId,
},
headers: electricHeaders,
columnMapper,
},
getKey: (item) => item.id,
}),
);
const teams = createPersistedElectricCollection(
electricCollectionOptions<SelectTeam>({
id: `teams-${organizationId}`,
shapeOptions: {
url: electricUrl,
params: {
table: "auth.teams",
organizationId,
},
headers: electricHeaders,
columnMapper,
},
getKey: (item) => item.id,
}),
);
const teamMembers = createPersistedElectricCollection(
electricCollectionOptions<SelectTeamMember>({
id: `team_members-${organizationId}`,
shapeOptions: {
url: electricUrl,
params: {
table: "auth.team_members",
organizationId,
},
headers: electricHeaders,
columnMapper,
},
getKey: (item) => item.id,
}),
);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/desktop/src/renderer/routes/_authenticated/providers/CollectionsProvider/collections.ts`
around lines 479 - 509, The teamMembers collection id uses a hyphenated name but
should preserve the table underscore to match existing naming conventions;
update the id passed into electricCollectionOptions for the
createPersistedElectricCollection call that constructs teamMembers (look for the
teamMembers variable and its electricCollectionOptions call) to use
`team_members-${organizationId}` instead of `team-members-${organizationId}` so
the collection id matches the table naming pattern.


const agentCommands = createPersistedElectricCollection(
electricCollectionOptions<SelectAgentCommand>({
id: `agent_commands-${organizationId}`,
Expand Down Expand Up @@ -708,6 +744,8 @@ function createOrgCollections(organizationId: string): OrgCollections {
members,
users,
invitations,
teams,
teamMembers,
agentCommands,
integrationConnections,
subscriptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
HiOutlineShieldCheck,
HiOutlineSparkles,
HiOutlineUser,
HiOutlineUserGroup,
} from "react-icons/hi2";
import { LuBrain, LuGitBranch, LuKeyboard } from "react-icons/lu";
import { useIsV2CloudEnabled } from "renderer/hooks/useIsV2CloudEnabled";
Expand All @@ -32,6 +33,7 @@ interface GeneralSettingsProps {
type SettingsRoute =
| "/settings/account"
| "/settings/organization"
| "/settings/teams"
| "/settings/appearance"
| "/settings/ringtones"
| "/settings/keyboard"
Expand Down Expand Up @@ -143,6 +145,12 @@ const SECTION_GROUPS: SectionGroup[] = [
label: "Organization",
icon: <HiOutlineBuildingOffice2 className="h-4 w-4" />,
},
{
id: "/settings/teams",
section: "teams",
label: "Teams",
icon: <HiOutlineUserGroup className="h-4 w-4" />,
},
{
id: "/settings/projects",
section: "project",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { electronTrpc } from "renderer/lib/electron-trpc";
import {
type SettingsSection,
useSetSettingsSearchQuery,
useSettingsOriginRoute,
useSettingsSearchQuery,
} from "renderer/stores/settings-state";
import { NavigationControls } from "../_dashboard/components/NavigationControls";
import { SearchResultsBanner } from "./components/SearchResultsBanner";
import { SettingsSidebar } from "./components/SettingsSidebar";
import {
Expand All @@ -35,6 +35,7 @@ const SECTION_ORDER: SettingsSection[] = [
"links",
"models",
"organization",
"teams",
"integrations",
"billing",
"apikeys",
Expand All @@ -46,6 +47,7 @@ const SECTION_ORDER: SettingsSection[] = [
function getSectionFromPath(pathname: string): SettingsSection | null {
if (pathname.includes("/settings/account")) return "account";
if (pathname.includes("/settings/organization")) return "organization";
if (pathname.includes("/settings/teams")) return "teams";
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
if (pathname.includes("/settings/appearance")) return "appearance";
Comment thread
coderabbitai[bot] marked this conversation as resolved.
if (pathname.includes("/settings/ringtones")) return "ringtones";
if (pathname.includes("/settings/keyboard")) return "keyboard";
Expand All @@ -68,6 +70,8 @@ function getPathFromSection(section: SettingsSection): string {
return "/settings/account";
case "organization":
return "/settings/organization";
case "teams":
return "/settings/teams";
case "appearance":
return "/settings/appearance";
case "ringtones":
Expand Down Expand Up @@ -102,7 +106,6 @@ function SettingsLayout() {
const isMac = platform === undefined || platform === "darwin";
const searchQuery = useSettingsSearchQuery();
const setSearchQuery = useSetSettingsSearchQuery();
const originRoute = useSettingsOriginRoute();
const location = useLocation();
const navigate = useNavigate();
const normalizedSearchQuery = searchQuery.trim();
Expand Down Expand Up @@ -137,11 +140,17 @@ function SettingsLayout() {
"escape",
(event) => {
if (document.querySelector('[data-state="open"]')) return;
const segments = location.pathname.split("/").filter(Boolean);
// Peel one segment, but only if we're deeper than a top-of-section
// route like /settings/teams. Esc at the top is a no-op so users don't
// get yanked out of settings unexpectedly.
if (segments.length <= 2) return;
event.preventDefault();
navigate({ to: originRoute });
const parent = `/${segments.slice(0, -1).join("/")}`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Parent-path Escape navigation loops on /settings/project/$projectId/cloud/secrets because the parent route auto-redirects back to secrets.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/desktop/src/renderer/routes/_authenticated/settings/layout.tsx, line 148:

<comment>Parent-path Escape navigation loops on `/settings/project/$projectId/cloud/secrets` because the parent route auto-redirects back to secrets.</comment>

<file context>
@@ -137,11 +139,17 @@ function SettingsLayout() {
+			if (segments.length <= 2) return;
 			event.preventDefault();
-			navigate({ to: originRoute });
+			const parent = `/${segments.slice(0, -1).join("/")}`;
+			navigate({ to: parent });
 		},
</file context>

navigate({ to: parent });
},
{ enableOnFormTags: false, enableOnContentEditable: false },
[navigate, originRoute],
[navigate, location.pathname],
);

const usesInnerSidebar =
Expand All @@ -152,11 +161,13 @@ function SettingsLayout() {
return (
<div className="flex flex-col h-screen w-screen bg-tertiary">
<div
className="drag h-8 w-full bg-tertiary"
className="drag flex h-12 w-full items-center gap-1.5 bg-tertiary"
style={{
paddingLeft: isMac ? "88px" : "16px",
paddingLeft: isMac ? "96px" : "8px",
}}
/>
>
<NavigationControls />
</div>

<div className="flex flex-1 overflow-hidden">
<SettingsSidebar />
Expand Down
Loading
Loading