Skip to content

Add department co-lead position support#193

Merged
zunkelty merged 2 commits into
mainfrom
claude/department-co-lead-gnkdsp
Jul 8, 2026
Merged

Add department co-lead position support#193
zunkelty merged 2 commits into
mainfrom
claude/department-co-lead-gnkdsp

Conversation

@zunkelty

@zunkelty zunkelty commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Introduces a new department_co_lead organizational position that grants the same authority and permissions as a department head. A department can have multiple co-leads, enabling shared leadership responsibilities while maintaining a single head-of-department role.

Key Changes

  • Database Schema: Added department_co_lead to the organization_position enum type and updated uniqueness constraints on user_organization_position table to allow multiple co-leads per department while maintaining single head constraint
  • Authority Model:
    • Introduced departmentLeadPositions set containing both department_head and department_co_lead
    • Added isDepartmentLeadPosition() helper to identify both head and co-lead roles
    • Updated PositionAssignments interface to track departmentCoLeads as arrays (vs single departmentHeads)
  • Position Management UI: Extended admin settings page to display and manage department co-leads alongside heads, with validation preventing a person from being both head and co-lead of the same department
  • Permissions & Authority: Co-leads receive identical permissions to heads within their department scope (e.g., user.view_details, user.membership.propose)
  • Org Chart: Updated to display co-leads in a dedicated section below the department head, styled like regular members but with "Co-Lead of…" role label
  • Notifications: Updated department change notifications to include all department leads (head + co-leads) rather than just the head
  • System Groups: Co-leads are included in department-specific system groups alongside heads
  • Database Migration: Added migration 0055_wise_ozymandias.sql to implement schema changes

Implementation Details

  • Co-leads are stored as arrays in PositionAssignments.departmentCoLeads to support multiple holders per department
  • Validation ensures no duplicate co-leads and prevents head/co-lead conflicts
  • All permission checks use isDepartmentLeadPosition() to treat heads and co-leads identically
  • Org chart rendering separates co-leads from regular members for visual clarity while maintaining consistent styling
  • Department change workflows notify all leads (head + co-leads) with appropriate "joined" or "left" messaging based on their involvement

https://claude.ai/code/session_01L6qc2iSYybYuHkUW5hnep8

claude added 2 commits July 8, 2026 16:14
Departments can now have an optional co-head (co-lead) in addition to the
single required head. The co-head receives the same permissions as the head
and is included in the same workflows (member admission, transitions,
cancellations, system-group sync).

- Add `department_co_head` organization position with a per-department unique
  index (at most one co-head per department) and relaxed check constraint.
- Treat both head and co-head as department-lead positions in permission
  evaluation, recipient selection, system-group membership, and department
  syncing.
- Add co-head selection to the admin positions page (validating head and
  co-head are different members) with assignment notifications and audit log.
- Show the co-head in the org chart ("Co-Head of …") and member detail.
- Notify both head and co-head when a member joins/leaves their department.

The migration adds the enum value and commits it before use (matching the
existing pattern in migration 0033) so it applies cleanly to a fresh database.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L6qc2iSYybYuHkUW5hnep8
Generalize department co-leads from at most one to any number per
department (0..n), and rename the concept from "co-head" to "co-lead"
to match how the org refers to it.

- Rename the organization position `department_co_head` →
  `department_co_lead` and drop its per-department unique index so a
  department can have multiple co-leads. The head remains capped at one.
- Model co-leads as an array (`departmentCoLeads`) throughout the read,
  write, recipient-selection, and department-sync paths; every co-lead is
  synced onto the same department and included in the same approval and
  FYI workflows as the head.
- Admin positions page now supports adding/removing multiple co-leads per
  department, excluding already-chosen members and rejecting a member who
  is both head and co-lead.
- Org chart renders co-leads as member-style cards directly below the
  head with the subtitle "Co-Lead of <Department>", supporting departments
  that have co-leads but no head.

The migration commits the new enum value before use (matching migration
0033) so it applies cleanly to a fresh database.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L6qc2iSYybYuHkUW5hnep8
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@zunkelty, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5814d012-e095-43a9-a5c5-b3a3d6d7157e

📥 Commits

Reviewing files that changed from the base of the PR and between 8ab2778 and 03906ee.

📒 Files selected for processing (22)
  • drizzle/0055_wise_ozymandias.sql
  • drizzle/meta/0055_snapshot.json
  • drizzle/meta/_journal.json
  • src/app/(authenticated)/(app)/(default)/admin/people/[id]/change-department-action.ts
  • src/app/(authenticated)/(app)/(default)/admin/people/[id]/permissions-section.tsx
  • src/app/(authenticated)/(app)/(default)/admin/settings/positions/loading.tsx
  • src/app/(authenticated)/(app)/(default)/admin/settings/positions/page-client.tsx
  • src/app/(authenticated)/(app)/(default)/admin/settings/positions/update-positions-action.ts
  • src/app/(authenticated)/(app)/org-chart/dept-head-cell.tsx
  • src/app/(authenticated)/(app)/org-chart/dept-members-cell.tsx
  • src/db/authority.ts
  • src/db/people.ts
  • src/db/schema/authority.ts
  • src/lib/authority/assignments.ts
  • src/lib/authority/model.test.ts
  • src/lib/authority/model.ts
  • src/lib/groups/system-groups.test.ts
  • src/lib/groups/system-groups.ts
  • src/lib/org-chart.test.ts
  • src/lib/org-chart.ts
  • src/lib/permissions/evaluate.ts
  • src/lib/permissions/permissions.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/department-co-lead-gnkdsp

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.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@zunkelty
zunkelty merged commit d33547b into main Jul 8, 2026
4 checks passed
@zunkelty
zunkelty deleted the claude/department-co-lead-gnkdsp branch July 8, 2026 17:19
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.

2 participants