Skip to content

Annotations and moving of client functions#56

Merged
christianhelp merged 4 commits intomainfrom
53-annotate-client-functions-for-clarity
Mar 1, 2026
Merged

Annotations and moving of client functions#56
christianhelp merged 4 commits intomainfrom
53-annotate-client-functions-for-clarity

Conversation

@christianhelp
Copy link
Contributor

@christianhelp christianhelp commented Feb 21, 2026

Satisfies

#53

Summary by CodeRabbit

  • New Features

    • Leave-team dialog now reflects private vs. public teams and accepts role information.
  • Documentation

    • Added comprehensive documentation/comments for auth and query helpers.
  • Chores

    • Reorganized internal utilities and query helpers; introduced lightweight query helpers and auth helpers (session/sign-out) to support app flows.

@christianhelp christianhelp linked an issue Feb 21, 2026 that may be closed by this pull request
@coderabbitai
Copy link

coderabbitai bot commented Feb 21, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 862fafd and 03a843d.

📒 Files selected for processing (1)
  • apps/web/src/lib/functions/queries.ts

📝 Walkthrough

Walkthrough

This PR moves many utility and query imports into @/lib/functions/*, adds JSDoc and new query/mutation clients (e.g., leaveTeamMutationClient, getUserQueryClient), introduces auth helpers in auth.ts, and extends LeaveTeamDialog props with isPrivate and role.

Changes

Cohort / File(s) Summary
UI components (cn import path update)
apps/web/src/components/ui/alert-dialog.tsx, apps/web/src/components/ui/alert.tsx, apps/web/src/components/ui/avatar.tsx, apps/web/src/components/ui/breadcrumb.tsx, apps/web/src/components/ui/button.tsx, apps/web/src/components/ui/dropdown-menu.tsx, apps/web/src/components/ui/input.tsx, apps/web/src/components/ui/menubar.tsx, apps/web/src/components/ui/navigation-menu.tsx, apps/web/src/components/ui/scroll-area.tsx, apps/web/src/components/ui/separator.tsx, apps/web/src/components/ui/sheet.tsx, apps/web/src/components/ui/sidebar.tsx, apps/web/src/components/ui/skeleton.tsx, apps/web/src/components/ui/switch.tsx, apps/web/src/components/ui/tooltip.tsx
Rewired imports to pull cn (and similar utilities) from @/lib/functions/utils instead of @/lib/utils. No behavioral or API changes.
Shared/nav components (utils & queries import update)
apps/web/src/components/shared/Navbar/UserButton.tsx, apps/web/src/components/shared/Navbar/navbar.tsx, apps/web/src/routes/index.tsx
Updated imports to use @/lib/functions/queries and @/lib/functions/utils (e.g., getUserQueryClient, getUserTeamsQueryClient, getInitials, shouldShowNavbar). No logic changes.
LeaveTeamDialog update
apps/web/src/components/shared/LeaveTeamDialog.tsx
Changed import for leaveTeamMutationClient to @/lib/functions/queries, added JSDoc, and extended public props with isPrivate: boolean and role: string (dialog can reflect private vs public teams).
Auth helpers added
apps/web/src/lib/functions/auth.ts
Added exported helpers with JSDoc: isPublicRoute(), isProtectedRoute(), getSession(), signOut(), and redirectIfSignedIn() for route/session flows.
Query clients & mutation updates
apps/web/src/lib/functions/queries.ts
Moved/adjusted imports, added JSDoc for clients, introduced pingServerQueryClient, getUserQueryClient, getUserTeamsQueryClient, renamed joinTeamMutationclientjoinTeamMutationClient, and documented/exported leaveTeamMutationClient.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • mjanderson1227

Poem

🐇
Paths hop to functions’ door,
Docs laid out across the floor,
Queries, auth, and team goodbye,
A rabbit cheers — code leaps high! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.58% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding annotations (JSDoc comments) to client functions and reorganizing them by moving imports from @/lib/queries to @/lib/functions/queries.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 53-annotate-client-functions-for-clarity

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@christianhelp christianhelp marked this pull request as ready for review February 21, 2026 21:37
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/web/src/components/shared/LeaveTeamDialog.tsx (2)

22-34: ⚠️ Potential issue | 🟡 Minor

role is declared in the props type but never destructured or used.

Callers are required to supply role (TypeScript will enforce it), but the value is silently discarded. Either destructure and use it, or remove it from the type until it's needed.

✏️ Proposed fix
 export function LeaveTeamDialog({
 	teamId: _unusedForNowTeamId,
 	teamName,
 	isPrivate,
+	role: _role,
 }: {
 	teamId: string;
 	teamName: string;
 	isPrivate: boolean;
 	role: string;
 	...
 })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/src/components/shared/LeaveTeamDialog.tsx` around lines 22 - 34, The
props type for LeaveTeamDialog declares role but the function signature
currently ignores it (teamId: _unusedForNowTeamId, teamName, isPrivate) causing
callers to pass a value that's discarded; either remove role from the props type
to stop forcing callers to provide it, or include role in the parameter
destructuring (e.g., add role to the parameter list) and use it where
appropriate (for example to conditionally render owner-specific warnings or
behavior in LeaveTeamDialog); update the props object shape accordingly so the
type and actual destructuring are consistent.

56-56: ⚠️ Potential issue | 🔴 Critical

AlertDialogAction fires no mutation — the "Leave Team" button is a no-op.

Both leaveTeamMutationClient and useMutation are imported but aliased as _unusedForNow* and are never wired up. Clicking "Leave Team" will close the dialog without calling the API, silently doing nothing to the user's team membership.

At minimum, the action should be disabled until the implementation is hooked up, to prevent user confusion:

🛡️ Proposed interim fix to make the incomplete state explicit
-<AlertDialogAction>Leave Team</AlertDialogAction>
+<AlertDialogAction disabled>Leave Team</AlertDialogAction>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/src/components/shared/LeaveTeamDialog.tsx` at line 56, The "Leave
Team" button (<AlertDialogAction>) is currently a no-op because the mutation
utilities (leaveTeamMutationClient and useMutation) were aliased as
_unusedForNow* and never invoked; either wire the real mutation or disable the
action until implemented. Fix by locating AlertDialogAction in LeaveTeamDialog
and either (A) hook up the leaveTeamMutationClient/useMutation: call the
mutation (e.g., leaveTeamMutationClient.mutate or useMutation(...).mutate) in
the button handler, pass the team/user id, and reflect loading/error states on
AlertDialogAction, or (B) if the API is not ready, disable AlertDialogAction
(set disabled when leaveTeamMutationClient/useMutation is not configured) and
show a tooltip or label indicating the action is not yet available; ensure
references to leaveTeamMutationClient, useMutation, and AlertDialogAction are
used so the compiler/runtime will surface any missing wiring.
🧹 Nitpick comments (1)
apps/web/src/lib/functions/auth.ts (1)

27-38: getSession and signOut are pass-through wrappers with no added behavior.

Both functions add an indirection layer without extra logic, error transformation, or abstraction. UserButton.tsx already calls authClient.signOut() directly. Consider whether these wrappers are actually needed as part of the public API, or if they'll cause callers to split between two call sites.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/src/lib/functions/auth.ts` around lines 27 - 38, The getSession and
signOut functions are simple pass-through wrappers (authClient.getSession and
authClient.signOut) that add no value and risk inconsistent call sites; either
remove these wrappers and update callers (e.g., UserButton.tsx and any other
usage) to call authClient.getSession()/authClient.signOut() directly, or if a
public API surface is desired, implement meaningful behavior inside
getSession/signOut (for example, normalize return types, centralize error
handling/logging, or add typings and documentation) so the indirection is
justified; locate the functions by name (getSession, signOut) in
apps/web/src/lib/functions/auth.ts and apply one of the two remediation
strategies consistently across the codebase.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/web/src/components/shared/LeaveTeamDialog.tsx`:
- Line 15: The import alias in the LeaveTeamDialog component is a concatenation
typo: the symbol currently reads
_unusedForNowleaveTeamMutationClientleaveTeamMutationClient; update the import
so the alias is the intended readable name (e.g.,
_unusedForNowLeaveTeamMutationClient) while still importing
leaveTeamMutationClient from "@/lib/functions/queries" so other references to
the alias remain correct (locate the import line that declares
leaveTeamMutationClient and replace the malformed alias with
_unusedForNowLeaveTeamMutationClient).

In `@apps/web/src/lib/functions/auth.ts`:
- Around line 10-12: isPublicRoute currently does an exact match
(PUBLIC_ROUTES.includes(pathname)) so variants like trailing slashes or
query/hash strings will fail; modify isPublicRoute to normalize the incoming
pathname (strip query and hash, collapse trailing slashes) before checking, or
use prefix matching for routes that should match subpaths. Specifically, create
a small normalization step inside isPublicRoute (e.g., remove anything after '?'
or '#', then remove trailing slashes) and then compare against PUBLIC_ROUTES (or
use startsWith against entries intended as prefixes) so '/sign-in/',
'/sign-in?x=1', and '/sign-in#foo' are recognized as public.

In `@apps/web/src/lib/functions/queries.ts`:
- Line 59: Rename the exported function joinTeamMutationclient to
joinTeamMutationClient to match the camelCase convention used by
leaveTeamMutationClient; update the function declaration/export name and any
local references/imports that use joinTeamMutationclient so they reference
joinTeamMutationClient instead, and run a quick repo-wide search to ensure no
remaining references to the old symbol remain.

---

Outside diff comments:
In `@apps/web/src/components/shared/LeaveTeamDialog.tsx`:
- Around line 22-34: The props type for LeaveTeamDialog declares role but the
function signature currently ignores it (teamId: _unusedForNowTeamId, teamName,
isPrivate) causing callers to pass a value that's discarded; either remove role
from the props type to stop forcing callers to provide it, or include role in
the parameter destructuring (e.g., add role to the parameter list) and use it
where appropriate (for example to conditionally render owner-specific warnings
or behavior in LeaveTeamDialog); update the props object shape accordingly so
the type and actual destructuring are consistent.
- Line 56: The "Leave Team" button (<AlertDialogAction>) is currently a no-op
because the mutation utilities (leaveTeamMutationClient and useMutation) were
aliased as _unusedForNow* and never invoked; either wire the real mutation or
disable the action until implemented. Fix by locating AlertDialogAction in
LeaveTeamDialog and either (A) hook up the leaveTeamMutationClient/useMutation:
call the mutation (e.g., leaveTeamMutationClient.mutate or
useMutation(...).mutate) in the button handler, pass the team/user id, and
reflect loading/error states on AlertDialogAction, or (B) if the API is not
ready, disable AlertDialogAction (set disabled when
leaveTeamMutationClient/useMutation is not configured) and show a tooltip or
label indicating the action is not yet available; ensure references to
leaveTeamMutationClient, useMutation, and AlertDialogAction are used so the
compiler/runtime will surface any missing wiring.

---

Nitpick comments:
In `@apps/web/src/lib/functions/auth.ts`:
- Around line 27-38: The getSession and signOut functions are simple
pass-through wrappers (authClient.getSession and authClient.signOut) that add no
value and risk inconsistent call sites; either remove these wrappers and update
callers (e.g., UserButton.tsx and any other usage) to call
authClient.getSession()/authClient.signOut() directly, or if a public API
surface is desired, implement meaningful behavior inside getSession/signOut (for
example, normalize return types, centralize error handling/logging, or add
typings and documentation) so the indirection is justified; locate the functions
by name (getSession, signOut) in apps/web/src/lib/functions/auth.ts and apply
one of the two remediation strategies consistently across the codebase.

@christianhelp christianhelp merged commit d39116e into main Mar 1, 2026
2 checks passed
@christianhelp christianhelp deleted the 53-annotate-client-functions-for-clarity branch March 1, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Annotate Client Functions for Clarity

1 participant