Skip to content

perf: server side render settings/organizations/general #20833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

retrogtx
Copy link
Contributor

@retrogtx retrogtx commented Apr 23, 2025

What does this PR do?

  • Moved data fetching logic from client-side hooks (useQuery, useSession) in the LegacyPage component (packages/.../general.tsx) to the server component Page (apps/web/.../general/page.tsx).
  • Implemented server-side data fetching in Page.tsx using the tRPC caller (appRouter.createCaller) to retrieve user and organization details.
  • Passed the fetched data (currentOrg, isAdminOrOwner, localeProp) down as props to the LegacyPage component.
    Removed redundant client-side data fetching hooks and related logic from the LegacyPage component.
Screen.Recording.2025-04-24.at.10.54.39.AM.mov

Summary by mrge

Moved organization general settings data fetching from the client to the server for faster page loads and better security.

  • Refactors
    • Server component now fetches user and organization data and passes it as props.
    • Removed client-side data fetching and related hooks from the settings page.

Copy link

vercel bot commented Apr 23, 2025

@retrogtx is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Apr 23, 2025
@graphite-app graphite-app bot requested a review from a team April 23, 2025 05:15
@keithwillcode keithwillcode added the community-interns The team responsible for reviewing, testing and shipping low/medium community PRs label Apr 23, 2025
@dosubot dosubot bot added organizations area: organizations, orgs performance area: performance, page load, slow, slow endpoints, loading screen, unresponsive labels Apr 23, 2025
@retrogtx retrogtx marked this pull request as draft April 23, 2025 05:17
@retrogtx retrogtx changed the title perf: Server-render organization general settings page perf: server-render organization general settings page Apr 23, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

mrge found 3 issues across 2 files. View them in mrge.io

const ctx = await createContextInner({ session, locale: session.user.locale ?? "en" });
const caller = appRouter.createCaller(ctx);

const user = await caller.viewer.me.get();
Copy link
Contributor

Choose a reason for hiding this comment

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

Sequential API calls can be parallelized for better performance

Copy link
Contributor Author

Choose a reason for hiding this comment

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

damn you're right

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

mrge reviewed 2 files and found no issues. Review this PR in mrge.io.

@@ -45,43 +42,22 @@ interface GeneralViewProps {
localeProp: string;
}

const OrgGeneralView = () => {
interface OrgGeneralViewProps {
currentOrg: NonNullable<RouterOutputs["viewer"]["organizations"]["listCurrent"]>;
Copy link
Contributor

Choose a reason for hiding this comment

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

NonNullable - love it

@github-actions github-actions bot marked this pull request as draft April 23, 2025 14:05
@retrogtx retrogtx marked this pull request as ready for review April 24, 2025 04:10
@retrogtx retrogtx requested a review from hbjORbj April 24, 2025 04:10
@dosubot dosubot bot added the foundation label Apr 24, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

mrge found 1 issue across 2 files. View it in mrge.io

@github-actions github-actions bot marked this pull request as draft April 24, 2025 14:02
… unused components

- Simplified the loading component import path.
- Merged functionality from the deleted main-page into the general page for better organization.
- Enhanced the page with server-side session handling and data fetching.
- Removed obsolete skeleton and main-page files to streamline the codebase.
…page and header

- Eliminated the Suspense component from the organization settings page and SettingsHeader to simplify rendering.
- Streamlined the code by directly rendering child components without fallback loading states.
@retrogtx retrogtx requested a review from hbjORbj April 25, 2025 05:01
@retrogtx retrogtx marked this pull request as ready for review April 25, 2025 05:01
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

mrge found 4 issues across 5 files. View them in mrge.io


export function SkeletonLoader() {
const { t } = useLocale();
return (
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing aria-busy="true" attribute on the container element for better accessibility during loading states.

const { t } = useLocale();
return (
<SettingsHeader title={t("general")} description={t("general_description")} borderInShellHeader={true}>
<div className="space-y-8 rounded-md border border-neutral-200 bg-white p-6 dark:border-neutral-700 dark:bg-neutral-900">
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing role="status" attribute on the container for accessibility.

@github-actions github-actions bot marked this pull request as draft April 27, 2025 11:54
@retrogtx retrogtx marked this pull request as ready for review April 27, 2025 12:19
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

mrge found 1 issue across 5 files. View it in mrge.io

@retrogtx retrogtx requested a review from hbjORbj April 29, 2025 04:54
Copy link
Contributor

This PR is being marked as stale due to inactivity.

@github-actions github-actions bot added the Stale label May 14, 2025
@hbjORbj
Copy link
Contributor

hbjORbj commented May 26, 2025

@retrogtx Sorry for the delay! I will review tmrrow! please resolve conflicts btw!

@github-actions github-actions bot removed the Stale label May 27, 2025
Copy link
Contributor

@hbjORbj hbjORbj left a comment

Choose a reason for hiding this comment

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

A few pointers:

  1. I see that you have a skeleton UI for license key container as well. Is this needed? To my understanding, if license isn't there, user gets routed to /enterprise, anyways. So it is better to not have a skeleton UI for license key container to prevent a layout shift. Let me know if I am missing something here.

  2. We are fetching the entire user object to get the locale only.
    Rather, let's use:

  const locale = (await getLocale(buildLegacyRequest(await headers(), await cookies()))) ?? "en";
  1. You need to create actions.ts and use revalidatePath to invalidate orgs data in this RSC whenever needed.

e.g., Search for how revalidateEventTypeEditPage is used throughout the codebase

@hbjORbj hbjORbj marked this pull request as draft May 27, 2025 19:13
}

const isAdminOrOwner = checkAdminOrOwner(session.user.org?.role);
const localeProp = user?.locale ?? "en";
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this available from session.user? please check that and if not, use getLocale function as I mentioned above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Created by Linear-GitHub Sync community-interns The team responsible for reviewing, testing and shipping low/medium community PRs foundation organizations area: organizations, orgs performance area: performance, page load, slow, slow endpoints, loading screen, unresponsive 💻 refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants