Skip to content

feat(organizations): add organization slug URLs#4267

Open
evanjacobson wants to merge 34 commits into
mainfrom
feat/org-slugs
Open

feat(organizations): add organization slug URLs#4267
evanjacobson wants to merge 34 commits into
mainfrom
feat/org-slugs

Conversation

@evanjacobson

@evanjacobson evanjacobson commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Organization URLs were tied to opaque UUIDs, which made shared links hard to read and manage. This adds slug-backed organization URLs so organization pages can use human-readable identifiers while legacy UUID URLs continue to resolve and canonicalize safely.

The implementation follows the existing organization routing, page-context, and admin patterns: route identifiers are resolved at the boundary, downstream authorization/business logic still receives UUIDs, and migration cleanup is handled through admin tooling rather than ad hoc scripts.

Key details
  • Adds a persisted nullable organizations.slug with max-length and uniqueness constraints.
  • Adds shared route helpers so generated organization links prefer slug ?? id and server routes can resolve either slug or UUID.
  • Updates organization-scoped pages, sidebars, payment returns, integrations, Cloud/KiloClaw flows, and related UI links to use route identifiers where URLs are user-facing.
  • Keeps API/data contracts unchanged: organizationId and organization_id remain UUID contracts, and slug support is limited to route identifier boundaries.
  • Adds an admin backfill task at /admin/backfills that processes up to 1,000 legacy organizations per run and can be clicked repeatedly until no rows remain.
  • Includes an audit doc covering slug-aware route surfaces, UUID-only API contracts, compatible UUID links, and follow-up areas.

Verification

  • Manually tested and demoed the slug URL behavior shown in the Loom.

Visual Changes

N/A

Reviewer Notes

Please focus review on the route/API boundary: slugs should work as /organizations/:identifier aliases, but backend/API payloads named organizationId should continue to require UUIDs. Also review the backfill flow and any remaining UUID-generated links that are intentionally compatible through canonical redirects.

Comment thread apps/web/src/lib/cloud-agent-sdk/schemas.ts Outdated
Comment thread apps/web/src/components/cloud-agent-next/ChatSidebar.tsx Outdated
Comment thread apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • apps/web/src/app/api/integrations/gitlab/connect/route.test.ts
  • apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts
  • apps/web/src/lib/organizations/organization-route-utils.test.ts
  • apps/web/src/lib/organizations/organization-route-utils.ts
Previous Review Summaries (8 snapshots, latest commit 8b1e34c)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 8b1e34c)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts 66 Unauthenticated legacy GitLab OAuth requests now preserve raw organizationId values in the sign-in callback path, which can strand users on an unresolved org route after login
apps/web/src/lib/organizations/organization-route-utils.ts 10 isValidOrganizationRouteIdentifier() now rejects trailing-hyphen slugs that the persisted organization slug schema still allows, causing org-scoped pages and APIs to 400 for those organizations

Fix these issues in Kilo Cloud

Files Reviewed (5 files)
  • apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts - 1 issue
  • apps/web/src/lib/organizations/organization-auth.test.ts - 0 issues
  • apps/web/src/lib/organizations/organization-auth.ts - 0 issues
  • apps/web/src/lib/organizations/organization-route-utils.ts - 1 issue
  • apps/web/src/lib/user/server.ts - 0 issues

Previous review (commit 0b19c0f)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 files)
  • apps/web/src/lib/integrations/oauth/common.ts

Previous review (commit c4d933a)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • apps/web/src/app/api/integrations/linear/connect/route.test.ts
  • apps/web/src/lib/integrations/oauth/common.ts

Previous review (commit 1b57afe)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/integrations/oauth/common.ts 209 Invalid organizationId values now redirect to /organizations/<raw>/..., regressing the prior generic OAuth failure fallback

Fix these issues in Kilo Cloud

Files Reviewed (3 files)
  • apps/web/src/app/api/integrations/linear/connect/route.test.ts - 0 issues
  • apps/web/src/lib/email.ts - 0 issues
  • apps/web/src/lib/integrations/oauth/common.ts - 1 issue

Previous review (commit dbca7b2)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • apps/storybook/src/mockData/organizations.ts
  • apps/storybook/stories/OrganizationSwitcher.stories.tsx
  • apps/storybook/stories/Sidebar.stories.tsx

Previous review (commit 389f44e)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (136 files)
  • apps/extension/**
  • apps/web/src/app/**
  • apps/web/src/components/**
  • apps/web/src/hooks/**
  • apps/web/src/lib/**
  • apps/web/src/routers/**
  • packages/db/**
  • docs/organization-slug-url-api-audit.md
  • pnpm-lock.yaml
  • pnpm-workspace.yaml

Previous review (commit 6553569)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (16 files)
  • apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminDashboard.tsx
  • apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminHierarchyManagement.tsx
  • apps/web/src/app/admin/components/OrganizationAdmin/OrganizationAdminWebhooks.tsx
  • apps/web/src/app/admin/components/OrganizationTableBody.tsx
  • apps/web/src/app/admin/organizations/[id]/page.tsx
  • apps/web/src/app/admin/organizations/[id]/webhooks/[triggerId]/page.tsx
  • apps/web/src/app/admin/organizations/[id]/webhooks/page.tsx
  • apps/web/src/app/admin/webhooks/AdminWebhookTriggerDetails.tsx
  • apps/web/src/components/admin-omnibox/AdminOmnibox.tsx
  • apps/web/src/components/cloud-agent-next/ChatSidebar.tsx
  • apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx
  • apps/web/src/components/organizations/OrganizationInfoCard.tsx
  • apps/web/src/lib/cloud-agent-sdk/schemas.test.ts
  • apps/web/src/lib/cloud-agent-sdk/schemas.ts
  • apps/web/src/routers/organizations/organization-admin-router.test.ts
  • apps/web/src/routers/organizations/organization-admin-router.ts

Previous review (commit 697bc03)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/cloud-agent-sdk/schemas.ts 161 Tightened session event schema now disagrees with the current producer contract and can silently drop events
apps/web/src/components/cloud-agent-next/ChatSidebar.tsx 360 Sidebar navigation keeps a stale slug path after organization slug edits
apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx 911 Session creation redirect can target an outdated slug path

Fix these issues in Kilo Cloud

Files Reviewed (148 files)
  • apps/web/src/lib/cloud-agent-sdk/schemas.ts - 1 issue
  • apps/web/src/components/cloud-agent-next/ChatSidebar.tsx - 1 issue
  • apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx - 1 issue
  • 145 additional changed files reviewed with no findings

Reviewed by gpt-5.4-20260305 · Input: 78.6K · Output: 9K · Cached: 625.2K

Review guidance: REVIEW.md from base branch main

…r the post-create router.push, so an open tab could redirect to a stale slug after organization slug changes.

Fixed apps/web/src/components/cloud-agent-next/NewSessionPanel.tsx:911 to build the post-create redirect from stable organizationId.
…ionId: z.string().nullable(), while web had narrowed it to UUID and skips failed parses.

Changed:
- apps/web/src/lib/cloud-agent-sdk/schemas.ts:161 restores sessionEventV2RowSchema.organizationId to z.string().nullable().
- apps/web/src/lib/cloud-agent-sdk/schemas.ts:202 restores sessionDeletedPayloadSchema.organizationId to z.string().nullable().
- apps/web/src/lib/cloud-agent-sdk/schemas.test.ts:21 adds regression coverage for non-UUID org IDs in session.created.
- apps/web/src/lib/cloud-agent-sdk/schemas.test.ts:30 adds regression coverage for non-UUID org IDs in session.deleted.
Comment thread apps/web/src/lib/integrations/oauth/common.ts Outdated
Comment thread apps/web/src/lib/integrations/oauth/platforms/gitlab-connect.ts Outdated
Comment thread apps/web/src/lib/organizations/organization-route-utils.ts Outdated
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.

1 participant