feat(organizations): add organization slug URLs#4267
Conversation
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe Overview
Issue Details (click to expand)WARNING
Previously Flagged Item Verified Resolved
Files Reviewed (16 files changed since last review)
Fix these issues in Kilo Cloud Previous Review Summaries (10 snapshots, latest commit 5fc40e4)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 5fc40e4)Status: 2 Issues Found | Recommendation: Address before merge Executive SummaryThe new Overview
Issue Details (click to expand)WARNING
Previously Flagged Items — Verified ResolvedAll 6 previously open inline findings were re-verified against current
Files Reviewed (29 files changed since last review)
Fix these issues in Kilo Cloud Previous review (commit 471efa3)Status: No Issues Found | Recommendation: Merge Files Reviewed (4 files)
Previous review (commit 8b1e34c)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Fix these issues in Kilo Cloud Files Reviewed (5 files)
Previous review (commit 0b19c0f)Status: No Issues Found | Recommendation: Merge Files Reviewed (1 files)
Previous review (commit c4d933a)Status: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Previous review (commit 1b57afe)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Fix these issues in Kilo Cloud Files Reviewed (3 files)
Previous review (commit dbca7b2)Status: No Issues Found | Recommendation: Merge Files Reviewed (3 files)
Previous review (commit 389f44e)Status: No Issues Found | Recommendation: Merge Files Reviewed (136 files)
Previous review (commit 6553569)Status: No Issues Found | Recommendation: Merge Files Reviewed (16 files)
Previous review (commit 697bc03)Status: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Fix these issues in Kilo Cloud Files Reviewed (148 files)
Reviewed by claude-sonnet-5-20260630 · Input: 100 · Output: 38.1K · Cached: 7.1M Review guidance: REVIEW.md from base branch |
…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.
- packages/db/src/migrations/0178_mean_runaways.sql: replaced ADD CONSTRAINT ... UNIQUE with Drizzle-compatible CREATE UNIQUE INDEX.
- packages/db/src/migrations/0178_mean_runaways.sql: added the check constraint as NOT VALID, then VALIDATE CONSTRAINT.
- packages/db/src/schema.ts: changed slug: text().unique() to slug: text() plus explicit uniqueIndex('organizations_slug_unique').on(table.slug) so future Drizzle diffs preserve the index form.
Changed apps/web/src/routers/organizations/organization-router.ts to: - Remove the pre-update slug availability assertion from updateSlug. - Treat the DB unique constraint as the authoritative concurrency guard. - Catch Drizzle/Postgres 23505 errors, including wrapped cause errors. - Convert those errors into the existing friendly TRPCError CONFLICT with Requested slug is not available.
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
organizations.slugwith max-length and uniqueness constraints.slug ?? idand server routes can resolve either slug or UUID.organizationIdandorganization_idremain UUID contracts, and slug support is limited to route identifier boundaries./admin/backfillsthat processes up to 1,000 legacy organizations per run and can be clicked repeatedly until no rows remain.Verification
Visual Changes
N/A
Reviewer Notes
Please focus review on the route/API boundary: slugs should work as
/organizations/:identifieraliases, but backend/API payloads namedorganizationIdshould continue to require UUIDs. Also review the backfill flow and any remaining UUID-generated links that are intentionally compatible through canonical redirects.