diff --git a/.agents/skills/add-block/SKILL.md b/.agents/skills/add-block/SKILL.md index 8b71d3c7b9f..d1b024cbcf2 100644 --- a/.agents/skills/add-block/SKILL.md +++ b/.agents/skills/add-block/SKILL.md @@ -626,7 +626,8 @@ Use `wandConfig` on fields that are hard to fill by hand — timestamps (`genera **Write operation ids and tool ids as string literals** in the `operation` dropdown `options` and `tools.access`, never through constants (`id: SEARCH`, `access: [SEARCH]`). `scripts/generate-docs.ts` reads them from source with regexes, so a constant parses as empty: the docs page loses its whole -Actions section and the integration catalog ships blank operation descriptions, with no check failing. +Actions section and the integration catalog ships blank operation descriptions. `generate:docs` now +fails on an id it can't read (in `tools.access` only, a spread of a same-file `const` string array is resolved). **Preferred:** Use tool names directly as dropdown option IDs to avoid switch cases: ```typescript diff --git a/.agents/skills/add-column-type/SKILL.md b/.agents/skills/add-column-type/SKILL.md index debc783f044..d0c0e702328 100644 --- a/.agents/skills/add-column-type/SKILL.md +++ b/.agents/skills/add-column-type/SKILL.md @@ -119,7 +119,7 @@ Prefer set-based SQL. When the transform genuinely needs JS (`currency`'s separa - **Import cycles.** `column-types/select.ts` imports `lib/table/select-values.ts`, so `select-values.ts` must **not** import the registry — that closes a cycle and fails at module init. Inside a type's own helper module the string literal is the implementation, not a config leak. - **The client-safe boundary.** `registry.ts` and everything it imports must stay free of `@sim/db`, `drizzle-orm`, and `next/server` — the tables grid imports it directly. A React icon is fine (it's a component *reference*, never called server-side). Only `registry.server.ts` may touch drizzle. - **Don't re-export the registry from `@/lib/table`.** Dozens of server modules import that barrel; routing this through it pulls `@sim/emcn/icons` into all of them. Deep-import `@/lib/table/column-types`. -- **`import.ts`'s `coerceValue` is a SECOND write path and is not opt-in.** Importing into a column of your type always hits it, and its `default` arm silently `String(value)`s — so a missing `case` stores text in a column whose `jsonbCast` is numeric, and then every filter and sort on that column errors in Postgres. Add a `case`, even though the switch compiles without one. (It is deliberately separate from the registry's `coerce`: an import wants an unparseable value to survive as its raw string so the row error can name it.) +- **`import.ts`'s `coerceValue` is a SECOND write path and is not opt-in.** Importing into a column of your type always hits it, and the switch is exhaustive (`colType satisfies never`), so a new type fails to compile until you add its `case`. Pick the arm deliberately: falling back to `String(value)` stores text in a column whose `jsonbCast` may be numeric, and then every filter and sort on that column errors in Postgres. (It is deliberately separate from the registry's `coerce`: an import wants an unparseable value to survive as its raw string so the row error can name it.) - **CSV inference** is an ordered heuristic in `import.ts`, deliberately not registry-driven. A new type is not inferred from a CSV unless you extend `inferColumnType` — usually you should not, since inference cannot supply configuration (an option set, a currency code). ## If your type owns metadata, read this diff --git a/.agents/skills/v2-api-conventions/SKILL.md b/.agents/skills/v2-api-conventions/SKILL.md index 68bee751466..e49c004271c 100644 --- a/.agents/skills/v2-api-conventions/SKILL.md +++ b/.agents/skills/v2-api-conventions/SKILL.md @@ -30,7 +30,7 @@ Each rule below guards a caller-visible failure: a non-integer `limit` reaching ## Rule 1 — the envelope is produced by helpers, never by hand -`v2Data`, `v2Error`, and the typed error helpers in `response.ts` (`v2ValidationError`, `v2RateLimitError`, `v2HttpError`, `v2InsufficientScope`, `v2HeadNoEffect`, `v2UploadDataPlaneError`) are the only things that build a v2 body. They also set `Cache-Control: private, no-store`, which every v2 response needs because every v2 response is authed per-caller data. +`v2Data`, `v2Error`, and the typed error helpers in `response.ts` (`v2ValidationError`, `v2RateLimitError`, `v2HttpError`, `v2InsufficientScope`, `v2HeadNoEffect`, `v2NoContent`, `v2UploadDataPlaneError`) are the only things that build a v2 body. They also set `Cache-Control: private, no-store`, which every v2 response needs because every v2 response is authed per-caller data. A route built with `defineV2JsonRoute` gets this for free: its `present` returns the *body shape* and the builder renders it. Never call `NextResponse.json` from a v2 route. diff --git a/.claude/rules/sim-settings-pages.md b/.claude/rules/sim-settings-pages.md index c39babca114..acc734b10a6 100644 --- a/.claude/rules/sim-settings-pages.md +++ b/.claude/rules/sim-settings-pages.md @@ -186,8 +186,7 @@ and — on activatable rows only — the hover band. Never hand-roll any of it, overlay. Prefer `href` when the destination is a route, so the row keeps prefetch, middle-click, and open-in-new-tab. Always pass `clickLabel` with either — the overlay holds no text, so it is the control's *only* accessible - name. The prop is optional in the type (nothing enforces it), so omitting it - ships a nameless button rather than failing the build. + name. The props type requires it whenever `onClick` or `href` is set. - `navigable` — appends the one canonical chevron. Set it on rows that open a detail page; leave it off when `onClick` acts in place (revealing a folder). Never import an arrow yourself: `lucide-react` and `@sim/emcn/icons` ship diff --git a/.cursor/rules/sim-settings-pages.mdc b/.cursor/rules/sim-settings-pages.mdc index aeb87b3325a..99ee74d0ffc 100644 --- a/.cursor/rules/sim-settings-pages.mdc +++ b/.cursor/rules/sim-settings-pages.mdc @@ -182,8 +182,7 @@ and — on activatable rows only — the hover band. Never hand-roll any of it, overlay. Prefer `href` when the destination is a route, so the row keeps prefetch, middle-click, and open-in-new-tab. Always pass `clickLabel` with either — the overlay holds no text, so it is the control's *only* accessible - name. The prop is optional in the type (nothing enforces it), so omitting it - ships a nameless button rather than failing the build. + name. The props type requires it whenever `onClick` or `href` is set. - `navigable` — appends the one canonical chevron. Set it on rows that open a detail page; leave it off when `onClick` acts in place (revealing a folder). Never import an arrow yourself: `lucide-react` and `@sim/emcn/icons` ship diff --git a/CLAUDE.md b/CLAUDE.md index 8988fd422ac..4d16aa02b52 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -63,7 +63,7 @@ Build order **Tools** → **Block** → **Icon** → optional **Trigger**, from - **Type coercions go in `tools.config.params`** (runs at execution), never `tools.config.tool` (runs at serialization, where `Number()` destroys `` references). - **Requests made for a workspace use `outboundFetch`** (`@/lib/core/network/outbound-fetch.server`), never the global `fetch` or another imported `fetch`, so an organization with a dedicated egress gateway keeps its static IPs; `check:organization-egress` enforces this, and a request that rightly goes direct (Sim's own infrastructure, an operator-local server) takes `// egress-direct: `. AWS SDK clients signing with customer credentials take `organizationAwsRequestHandler()`: no audit catches a missing one, so reviewers check it. - A surface listing integrations to a viewer reads `useIntegrationAccess`, never a raw catalog (`check:integration-access`). -- Table column types are registry entries in `apps/sim/lib/table/column-types/`; never add a per-type `case` elsewhere except the one documented import-path switch (`coerceValue` in `lib/table/import.ts`), which every new type extends: a missed arm fails silently. Use `/add-column-type`. +- Table column types are registry entries in `apps/sim/lib/table/column-types/`; never add a per-type `case` elsewhere except the one documented import-path switch (`coerceValue` in `lib/table/import.ts`), which every new type extends (its exhaustive `switch` fails to compile until it does). Use `/add-column-type`. ## How your work is checked diff --git a/apps/sim/app/api/v2/lib/response.ts b/apps/sim/app/api/v2/lib/response.ts index 0ea4d16c24b..2b83ec23dd1 100644 --- a/apps/sim/app/api/v2/lib/response.ts +++ b/apps/sim/app/api/v2/lib/response.ts @@ -165,6 +165,11 @@ export function v2HeadNoEffect(options: V2SuccessOptions = {}): NextResponse { return new NextResponse(null, { status: options.status ?? 200, headers: successHeaders(options) }) } +/** A bodiless `204 No Content` (+ rate-limit headers), for a write with nothing to return. */ +export function v2NoContent(options: Omit = {}): NextResponse { + return new NextResponse(null, { status: 204, headers: successHeaders(options) }) +} + /** `{ data }` (+ rate-limit headers). */ export function v2Data(data: T, options: V2SuccessOptions = {}): NextResponse { return NextResponse.json( diff --git a/apps/sim/app/api/v2/uploads/[uploadId]/parts/[partNumber]/route.ts b/apps/sim/app/api/v2/uploads/[uploadId]/parts/[partNumber]/route.ts index 324db24ea98..9a2b20aa1bd 100644 --- a/apps/sim/app/api/v2/uploads/[uploadId]/parts/[partNumber]/route.ts +++ b/apps/sim/app/api/v2/uploads/[uploadId]/parts/[partNumber]/route.ts @@ -1,5 +1,5 @@ import { createLogger } from '@sim/logger' -import { type NextRequest, NextResponse } from 'next/server' +import type { NextRequest, NextResponse } from 'next/server' import { localUploadPartContract } from '@/lib/api/contracts/upload-sessions' import { parseRequest } from '@/lib/api/server' import { V2_PARSE_DEFAULTS } from '@/lib/api/server/routes' @@ -18,6 +18,7 @@ import { v2CaughtOrchestrationError, v2Error, v2HttpError, + v2NoContent, v2UploadDataPlaneError, } from '@/app/api/v2/lib/response' @@ -116,7 +117,7 @@ export const PUT = withRouteHandler( error, }) } - return new NextResponse(null, { status: 204 }) + return v2NoContent() }, { typedErrorResponse: ({ error }) => v2HttpError(error), diff --git a/apps/sim/app/api/v2/uploads/[uploadId]/route.ts b/apps/sim/app/api/v2/uploads/[uploadId]/route.ts index e8ae73eb777..d328b7d81ec 100644 --- a/apps/sim/app/api/v2/uploads/[uploadId]/route.ts +++ b/apps/sim/app/api/v2/uploads/[uploadId]/route.ts @@ -1,5 +1,5 @@ import { createLogger } from '@sim/logger' -import { type NextRequest, NextResponse } from 'next/server' +import type { NextRequest, NextResponse } from 'next/server' import { localPutUploadContract } from '@/lib/api/contracts/upload-sessions' import { parseRequest } from '@/lib/api/server' import { V2_PARSE_DEFAULTS } from '@/lib/api/server/routes' @@ -10,7 +10,12 @@ import { getOwnedUploadSession, uploadSessionObjectMetadata, } from '@/lib/uploads/upload-session/service' -import { v2Error, v2HttpError, v2UploadDataPlaneError } from '@/app/api/v2/lib/response' +import { + v2Error, + v2HttpError, + v2NoContent, + v2UploadDataPlaneError, +} from '@/app/api/v2/lib/response' const logger = createLogger('LocalUpload') @@ -106,7 +111,7 @@ export const PUT = withRouteHandler( error, }) } - return new NextResponse(null, { status: 204 }) + return v2NoContent() }, { typedErrorResponse: ({ error }) => v2HttpError(error), diff --git a/apps/sim/app/workspace/[workspaceId]/settings/[section]/settings.tsx b/apps/sim/app/workspace/[workspaceId]/settings/[section]/settings.tsx index 601c43ed37e..abc687cf3d7 100644 --- a/apps/sim/app/workspace/[workspaceId]/settings/[section]/settings.tsx +++ b/apps/sim/app/workspace/[workspaceId]/settings/[section]/settings.tsx @@ -102,76 +102,128 @@ function SettingsPageContent({ section }: SettingsPageProps) { return ( - {effectiveSection === 'general' && } - {effectiveSection === 'desktop' && } - {effectiveSection === 'browser' && } - {effectiveSection === 'terminal' && } - {effectiveSection === 'secrets' && } - {effectiveSection === 'connected-accounts' && organizationId && ( + + + ) +} + +interface SettingsSectionBodyProps { + section: SettingsSection + organizationId: string | null + workspaceId: string + isHostOrganizationAdmin: boolean +} + +/** + * The one place a section id becomes its page. Exhaustive over {@link SettingsSection}: a new + * section fails compilation here until it renders something. + */ +function SettingsSectionBody({ + section, + organizationId, + workspaceId, + isHostOrganizationAdmin, +}: SettingsSectionBodyProps) { + switch (section) { + case 'general': + return + case 'desktop': + return + case 'browser': + return + case 'terminal': + return + case 'secrets': + return + case 'connected-accounts': + return organizationId ? ( - )} - {effectiveSection === 'access-control' && organizationId && ( + ) : null + case 'access-control': + return organizationId ? ( - )} - {effectiveSection === 'requests' && organizationId && ( + ) : null + case 'requests': + return organizationId ? ( - )} - {effectiveSection === 'custom-blocks' && } - {effectiveSection === 'audit-logs' && organizationId && ( - - )} - {effectiveSection === 'usage' && organizationId && ( + ) : null + case 'custom-blocks': + return + case 'audit-logs': + return organizationId ? : null + case 'usage': + return organizationId ? ( - )} - {effectiveSection === 'apikeys' && } - {billingEnabled && effectiveSection === 'billing' && ( + ) : null + case 'apikeys': + return + case 'billing': + return ( - )} - {effectiveSection === 'teammates' && } - {effectiveSection === 'organization' && organizationId && ( + ) + case 'teammates': + return + case 'organization': + return organizationId ? ( - )} - {effectiveSection === 'sso' && organizationId && } - {effectiveSection === 'data-retention' && organizationId && ( - - )} - {effectiveSection === 'data-drains' && organizationId && ( - - )} - {effectiveSection === 'security' && organizationId && ( + ) : null + case 'sso': + return organizationId ? : null + case 'data-retention': + return organizationId ? : null + case 'data-drains': + return organizationId ? : null + case 'security': + return organizationId ? ( - )} - {effectiveSection === 'byok' && } - {effectiveSection === 'sandboxes' && } - {effectiveSection === 'mcp' && } - {effectiveSection === 'forks' && } - {effectiveSection === 'custom-tools' && } - {effectiveSection === 'workflow-mcp-servers' && } - {effectiveSection === 'inbox' && } - {effectiveSection === 'recently-deleted' && } - {effectiveSection === 'self-host' && } - {effectiveSection === 'admin' && } - {effectiveSection === 'mothership' && } - - ) + ) : null + case 'byok': + return + case 'sandboxes': + return + case 'mcp': + return + case 'forks': + return + case 'custom-tools': + return + case 'workflow-mcp-servers': + return + case 'inbox': + return + case 'recently-deleted': + return + case 'self-host': + return + case 'admin': + return + case 'mothership': + return + default: + section satisfies never + return null + } } diff --git a/apps/sim/app/workspace/[workspaceId]/settings/components/settings-resource-row/settings-resource-row.tsx b/apps/sim/app/workspace/[workspaceId]/settings/components/settings-resource-row/settings-resource-row.tsx index 082e16dc3fb..6dd918b5f56 100644 --- a/apps/sim/app/workspace/[workspaceId]/settings/components/settings-resource-row/settings-resource-row.tsx +++ b/apps/sim/app/workspace/[workspaceId]/settings/components/settings-resource-row/settings-resource-row.tsx @@ -18,7 +18,7 @@ import { * tile/text chrome per consumer. The tile force-sizes any ``/`` it * contains to 20px, so callers pass their raw icon node without pre-sizing it. */ -interface SettingsResourceRowProps { +interface SettingsResourceRowBaseProps { /** * Icon node centered in the tile; a `` is normalized to 20px, an `` to * 20px (or the full tile when `iconFill`). Omit it for rows whose resource has no @@ -63,21 +63,6 @@ interface SettingsResourceRowProps { * edge into a dead zone. */ badge?: ReactNode - /** - * Makes the whole row activatable via a control with a stretched hit area. `trailing` - * stacks above it, so interactive trailing controls (menus, chips) keep - * working — never nest an interactive `trailing` inside a caller-supplied - * wrapper `