Skip to content

fix: Settings low-severity gaps (custom-instructions parity, last-member refusal, Disconnect loading, dead ?section=apps, MCP name validation) (#2091) - #2132

Merged
cursor[bot] merged 1 commit into
mainfrom
tale/xs705hg0qde0am4c2x32pnmnvx898chd
Jul 3, 2026
Merged

cursor[bot] merged 1 commit into
mainfrom
tale/xs705hg0qde0am4c2x32pnmnvx898chd

Conversation

@larryro

@larryro larryro commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Resolves #2091. Addresses each itemized low-severity settings gap.

[101] Custom-instructions illegal-char parity

personalization-settings.tsx now mirrors the backend rule (convex/user_preferences/mutations.ts): the client Zod schema canonicalizes CRLF/lone-CR → LF and rejects the same illegal characters + length cap, with the violation surfaced inline on the textarea (new i18n keys personalization.errors.tooLong / illegalChars). Reuses CUSTOM_INSTRUCTIONS_ILLEGAL_RE / CUSTOM_INSTRUCTIONS_MAX_CHARS from the shared constants (removed the duplicated local constant).

[102] Team-edit last-member silent refusal

team-member-checklist.tsx now disables the sole remaining member's checkbox and shows an explanatory hint (teams.lastMemberHint) instead of silently ignoring the click.

[104] Integration Disconnect loading state

use-integration-manage.ts exposes a real isSubmitting state that the disconnect flow drives; integration-panel.tsx keeps the ConfirmDialog open (showing its loading state) until the disconnect resolves.

[105] Dead ?section=apps param

integrations.tsx search schema now accepts only mcp-servers (the only value actually handled in beforeLoad); apps was never read.

[108] MCP server name slug + server-side validation

New shared convex/mcp_servers/constants.ts (MCP_SERVER_NAME_RE, validateMcpServerName). The client form drops the name.length > 1 carve-out (so single-char uppercase no longer slips through) and the create/update actions validate the slug and enforce per-org name uniqueness (new getIdByOrgAndName internal query); the create error surfaces in the toast.

Verification

  • bunx tsc --noEmit — clean
  • bunx oxlint (plain) on touched files — clean; oxfmt --check — clean
  • vitest server: mcp_servers/constants.test.ts (new), public_mutations.test.ts, lib/i18n/messages.test.ts — pass
  • vitest ui: mcp-server-form.test.tsx — pass

@larryro
larryro force-pushed the tale/xs705hg0qde0am4c2x32pnmnvx898chd branch from baf496e to 198bbba Compare June 24, 2026 20:50
@larryro

larryro commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Desk review — Settings low-severity gaps (#2091)

Verdict: NOT READY — one blocking change required (test coverage for the new server-side MCP validation/uniqueness logic). The five fixes are implemented correctly and CI is green; the gap is a missing-tests one, not a correctness one.

CI & tests

  • CI: green. gh pr checks — every check pass (Type check, Lint, Format, Unit, Knip, Storybook, all 16 Playwright shards, Smoke, Scan, Validate images, CodeQL); the only non-pass entries are skipping (fork-PR / docs-container jobs), none failing or pending.
  • Tests run locally (pass):
    • bunx vitest --run --project server convex/mcp_servers/constants.test.ts convex/mcp_servers/public_mutations.test.ts lib/i18n/messages.test.ts → 3 files, 38 tests pass
    • bunx vitest --run --config vitest.ui.config.ts app/features/settings/mcp-servers/ → 4 files, 31 tests pass (incl. mcp-server-form.test.tsx)
    • tsc --noEmit OOM'd in the sandbox; relying on CI's green Type check job.

What's correct (verified)

  • [101] Custom-instructions parity — client normalizeInstructions (personalization-settings.tsx) matches the backend (user_preferences/mutations.ts) character-for-character (\r\n→\n then lone \r→\n); same CUSTOM_INSTRUCTIONS_ILLEGAL_RE / CUSTOM_INSTRUCTIONS_MAX_CHARS (imported, not re-declared); empty-string handled identically; inline error wired through Textarea's real errorMessage prop (role="alert"). useMemo([t]) dep is correct.
  • [102] Last-member refusal — disableUncheck = isChecked && isLastMember correctly disables only the sole checked member while still allowing adding members; backend team_members/mutations.ts removeMember genuinely rejects removing the last member, so the comment is accurate; persistent <p> hint surfaces the constraint to screen readers.
  • [104] Disconnect loading — isSubmitting promoted to real useState; handleDisconnect toggles it in try/finally and swallows errors via toast, so .finally(() => setConfirmDisconnect(false)) is always safe; ConfirmDialog isLoading disables the confirm button (set synchronously before the first await), so double-submit is prevented. No other flow (connect/test/oauth) relied on the old permanently-false value — they use their own flags.
  • [105] Dead ?section=apps — repo-wide sweep found zero producers of section=apps; only mcp-servers is read in beforeLoad. z.literal('mcp-servers').optional() is behaviorally equivalent for the live path. Safe.
  • [108] MCP name validation — shared constants.ts (regex/max/validateMcpServerName) is the single source of truth for client + server; both trim before testing; by_org_name index exists in mcp_servers/schema.ts; ConvexError {code,message} surfaces via convexErrorMessage in the create toast; the duplicateId !== id own-name carve-out is logically correct.
  • i18n — personalization.errors.{tooLong,illegalChars} and settings.teams.lastMemberHint present in en/de/fr at matching paths; lib/i18n/messages.test.ts enforces locale parity in CI.

BLOCKING — required before merge

1. The new server-side MCP validation/uniqueness logic in convex/mcp_servers/public_mutations.ts (create + update actions) has zero test coverage.
convex/mcp_servers/public_mutations.test.ts is misnamed: it imports ./mutations and tests only the internal insert/update/remove/setStatus handlers — not the public actions. So none of the new branches are exercised:

  • create: rejects an invalid slug (assertValidMcpServerName throw);
  • create: rejects a duplicate (organizationId, name) (conflict ConvexError);
  • update: rejects an invalid slug on rename;
  • update: allows a no-op rename to the row's own name (the subtle duplicateId !== null && duplicateId !== id carve-out);
  • update: rejects a rename that collides with a different existing server;
  • update: not_found when the row is missing.

This is new error/edge logic with a data-integrity carve-out and no safety net. The repo already has a clean mock-ctx idiom for action handlers (convex/tasks/public_actions.test.ts, and the same idiom in this very file for the internal mutations), so add a describe('mcp_servers/public_mutations (actions)') block (or a correctly-scoped new file) covering the six branches above, mocking ctx.runQuery/ctx.runMutation to drive getIdByOrgAndName. The internal getIdByOrgAndName query has no test either — cover it or its behavior via the action tests.

Non-blocking (recommend, not required for this PR)

  • Token-budget parity gap (out of stated scope). The backend also enforces CUSTOM_INSTRUCTIONS_MAX_TOKENS (800 ≈ ~3200 Latin chars, below the 4000-char cap), which the client does not check — a 3200–4000-char value passes the client but the server rejects it as too_long, surfaced only as a toast, not inline. The PR description's "Mirror the backend rule" is therefore slightly overbroad. Consider a third .refine mirroring estimateTokens, or map the server too_long ConvexError to an inline field error.
  • Pre-existing IDOR (separate ticket, NOT this PR's job). create/update/remove/updateStatus authenticate via getAuthUserIdentity but never assert the caller is a member of the target org (create trusts args.organizationId; update derives org from the row but doesn't check membership). This exists on main unchanged and is unrelated to Improvement: Settings low-severity gaps (custom-instructions illegal-char parity, last-member silent refusal, Disconnect no loading state, dead ?section=apps param, MCP name slug/server validation) #2091 — file it separately; do not expand this PR for it.
  • TOCTOU on uniqueness. The check-then-insert spans two transactions in a 'use node' action with no DB-level unique constraint, so two concurrent creates with the same name can both succeed. Low impact; a one-line comment or moving the check+insert into a single internal mutation would close it.
  • Nits: the client form re-implements the validator branches instead of calling the shared validateMcpServerName; normalizeInstructions is duplicated client/server; the last-member hint shows even at 0 selected; update errors aren't surfaced via convexErrorMessage in mcp-server-panel.tsx (unlike create).

NOT READY — CHANGES REQUIRED: add the missing action-level tests for the new MCP create/update name-validation and per-org uniqueness logic (including the own-name-rename carve-out and the duplicate/invalid/not-found error branches) in convex/mcp_servers/public_mutations.ts, using the repo's existing mock-ctx idiom.

@larryro

larryro commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Desk Review — PR #2132 (issue #2091)

Branch: tale/xs705hg0qde0am4c2x32pnmnvx898chd
Verdict (one line): NOT READY — CHANGES REQUIRED. The five fixes are functionally correct and CI is green, but two of them ship with no tests in directories that are otherwise uniformly unit-tested, a newly-added hardcoded user-facing string violates the repo's i18n standard, and the create/update error-surfacing is inconsistent. A pre-existing critical authorization gap on the MCP write path is also surfaced below (out of this issue's scope — not a blocker for this PR, but must be tracked).

CI state — confirmed via gh pr checks

All required checks pass; none failing, none pending. Notable: Build platform ✅, Build convex ✅, Format ✅, Lint ✅, Knip ✅, Migrations ✅, all 16 Playwright (platform) shards ✅, Opengrep/Trivy clean. The only non-green entries are skipping (fork-PR-gated jobs), which is expected, not a failure.

Tests — exact command and result (run once by the reviewer)

cd services/platform && bunx vitest --run --project server mcp_servers → 36 passed (5 files), 0 failed (constants.test.ts, mutations.test.ts, public_mutations.test.ts, queries.test.ts, timeout.test.ts). The new [108] backend tests are meaningful (assert validation ordering, that no DB write occurs on reject, trim-on-insert, no-op self-rename vs collision). I did not re-run the full suite; CI's full run is green.

What is correct (verified across two review rounds)

  • [101] custom-instructions parity — normalizeInstructions (CRLF→LF) exactly mirrors the backend (user_preferences/mutations.ts); both refines import the same CUSTOM_INSTRUCTIONS_MAX_CHARS/CUSTOM_INSTRUCTIONS_ILLEGAL_RE from user_memories/constants, so no drift; empty-string carve-out matches; errorMessage is wired to the Textarea and re-validates onChange; useMemo([t]) dep is correct.
  • [102] last-member — isLastMember = size <= 1; sole checked member's checkbox is disabled with a title + standalone hint; teams.lastMemberHint present in en/de/fr; border/hover refactor preserves dividers. Backend still rejects last-member removal.
  • [104] disconnect loading — isSubmitting is now real useState, set true→false in try/finally; handleDisconnect swallows its own errors (toast) so the dialog's .finally(close) is always safe; no double-submit; busy correctly disables siblings without false spinners.
  • [105] dead ?section=apps — repo-wide grep finds no caller passing section: 'apps'; the mcp-servers redirect path is preserved; narrowing z.enum→z.literal('mcp-servers') changes behavior only for the dead value. Safe.
  • [108] MCP name validation — MCP_SERVER_NAME_RE is correct (single char ok, leading/trailing hyphen & uppercase rejected, no ReDoS); client carve-out removed; trim is consistent on every DB-bound path (only public_mutations calls mutations.insert/update); by_org_name index exists; create surfaces ConvexError messages via convexErrorMessage. Update-path name block is currently unreachable from the UI because handleUpdate does not send name — harmless backend defense, no legacy-name "bricking".

BLOCKING — changes required (each names file + condition)

  1. Tests missing for [104] disconnect loading state. integration-panel.tsx (changed) has no test, and no test references handleDisconnect/isSubmitting, yet its sibling dir has integration-card.test.tsx, integration-details.test.tsx, integrations.test.tsx. Add a component/hook test asserting: during an in-flight disconnect the ConfirmDialog shows its loading state and stays open until the promise resolves, then closes; and the disconnect button reflects isSubmitting.

  2. Tests missing for [102] last-member disable. team-member-checklist.tsx (changed) has no test, while its sibling dir has team-create-dialog.test.tsx, team-delete-dialog.test.tsx, team-row-actions.test.tsx, teams-table.test.tsx. Add a test asserting: with exactly one selected member that member's checkbox is disabled, the hint renders, and other members remain toggleable; with >1 selected, none are disabled.

  3. Newly-introduced hardcoded user-facing string. mcp-server-form.tsx:143 adds `Must be at most ${MCP_SERVER_NAME_MAX_LENGTH} characters` as a literal. AGENTS.md:215 requires all user-facing strings go through useT(). Route this (and ideally the adjacent pre-existing ' is required' at :141 and 'Must be lowercase alphanumeric with hyphens' at :145) through i18n keys — the same branch already added proper keys for personalization, so the inconsistency is glaring.

  4. Create/update error-surfacing inconsistency. The branch fixed mcp-servers.tsx (create) to surface the server's ConvexError message via convexErrorMessage(error, ''), but mcp-server-panel.tsx:113-117 (update) still has catch { toast({ title: t('error') }) }, swallowing the new invalid/conflict/not_found messages. Mirror the create-path pattern so update failures show the real reason. (Latent today because handleUpdate omits name, but it's an inconsistency the same fix introduced.)

Non-blocking — must be tracked separately (do NOT silently drop)

  • PRE-EXISTING CRITICAL (authorization / IDOR). convex/mcp_servers/public_mutations.ts create/update/remove/updateStatus authorize only getAuthUserIdentity (authentication), never org membership — unlike the read path (queries.ts) which uses getOrganizationMember. Any authenticated user can create/modify/delete MCP servers in any org by passing/guessing ids, and the new getIdByOrgAndName adds a name-existence oracle on an attacker-supplied organizationId. Confirmed present in the base commit (ae7c7e278) — not introduced by this branch and outside Improvement: Settings low-severity gaps (custom-instructions illegal-char parity, last-member silent refusal, Disconnect no loading state, dead ?section=apps param, MCP name slug/server validation) #2091's "low-severity settings" scope, so it does not block this PR, but it should be filed and fixed (add getOrganizationMember(ctx, organizationId, authUser) before the lookups/writes).
  • TOCTOU on name uniqueness (low). Create/update check getIdByOrgAndName then insert across separate action calls; by_org_name is a plain (non-unique) index, so concurrent same-name creates can both pass. Best-effort only — add a code comment, or move the check into the transactional mutations.insert.
  • [101] token-budget parity (minor). Backend also enforces CUSTOM_INSTRUCTIONS_MAX_TOKENS = 800 (~3200 Latin chars), which the client does not mirror; a 3201–4000-char value passes client validation but is server-rejected as a generic toast (no inline feedback). Outside the issue's stated illegal-char-parity ask, but worth closing for full parity.
  • [102] minor: the old silent if (next.size <= 1) return prev guard remains in team-edit-dialog.tsx:90 as now-unreachable dead code — consider removing since the disabled checkbox + backend now enforce the invariant.

FINAL VERDICT: NOT READY — CHANGES REQUIRED. Blocking items: (1) add tests for the [104] disconnect loading state in integration-panel.tsx; (2) add tests for the [102] last-member disable in team-member-checklist.tsx; (3) route the hardcoded name-validation strings in mcp-server-form.tsx (notably :143) through useT(); (4) surface the server ConvexError message in the update error handler mcp-server-panel.tsx:113-117 to match the create path. The five fixes are otherwise correct and CI is green; this is tests + polish, not a redesign. Separately track the pre-existing critical MCP write-authorization (IDOR) gap.

@larryro

larryro commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

🔴 Desk review verdict: NOT READY — CHANGES REQUIRED

Desk review — NOT READY (1 blocking item)

Thorough review of all five fixes. CI is green (40+ checks pass) and the changed-area tests pass locally (vitest --project server convex/mcp_servers → 36 pass; the two new UI tests → 6 pass). One blocking regression, a couple of non-blocking notes.

🔴 Blocking — team-member-checklist.tsx: min-one-member constraint leaks into the create dialog

TeamMemberChecklist is shared by both team-edit-dialog.tsx and team-create-dialog.tsx, but the new constraint const isLastMember = selectedMemberIds.size <= 1 is applied unconditionally — the component gets no mode/context prop. It disables the sole selected member's checkbox and renders teams.lastMemberHint ("A team must keep at least one member. Delete the team instead…").

In the create dialog, 0 members is explicitly valid: team-create-dialog.tsx auto-adds the current user when none are selected (onSubmit, the memberIds.length === 0 branch), and the create hint says "If no one is selected, you will be added automatically." So the new behavior is wrong there:

  • With 0 selected (initial create state) isLastMember is true → the misleading "delete the team instead" hint shows before any team exists.
  • After checking exactly one member, its checkbox becomes disabled → the user can no longer return to 0 selected, contradicting the documented auto-add behavior.

Fix: gate the constraint to the edit context. Add a prop (e.g. enforceMinimumOne / mode) to TeamMemberChecklist; pass it only from team-edit-dialog.tsx; team-create-dialog.tsx must not enforce it. Extend team-member-checklist.test.tsx to cover both modes (assert the hint/disable is absent in create mode).

🟡 Non-blocking

  • Custom-instructions parity is partial. Client now mirrors length + illegal-char correctly, but the backend (user_preferences/mutations.ts) also enforces a token budget (CUSTOM_INSTRUCTIONS_MAX_TOKENS = 800) the client does not mirror — a value <4000 chars with no illegal chars but >800 tokens is still server-bounced with no inline feedback. Outside issue [101]'s stated illegal-char scope, but a residual gap.
  • MCP uniqueness TOCTOU. create/update check uniqueness via runQuery then runMutation in a non-transactional action against the non-unique by_org_name index; two concurrent same-name creates could both succeed. Low probability, inherent to Convex actions — acceptable but noted.
  • Redundant guard. team-edit-dialog.tsx:90 if (next.size <= 1) return prev is now dead (checkbox disabled) — harmless, could be removed.

✅ Verified good

Disconnect loading state (real isSubmitting + dialog held open until await resolves); MCP name validation (shared validator, name.length>1 carve-out removed, update skips name when absent, per-org uniqueness + index present, error surfaced via convexErrorMessage); ?section=apps removal (zero references, router strips unknown values); all i18n keys present in en/de/fr.

@larryro

larryro commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Desk Review — PR #2132 (issue #2091)

Verdict: READY TO MERGE. All five itemized gaps are correctly closed; CI is fully green and the project's own tests pass.

Verification performed

  • Checked out tale/xs705hg0qde0am4c2x32pnmnvx898chd, bun install, ran the relevant suites:
    • bunx vitest --run --project server convex/mcp_servers/ → 5 files / 36 tests passed
    • bunx vitest --run --config vitest.ui.config.ts <team-member-checklist + integration-panel> → 2 files / 7 tests passed
  • gh pr checks → all required checks pass (Type check, Lint, Format, Knip, Build platform/convex, UI, Smoke, 16× Playwright shards, Opengrep, etc.); only Smoke test (fork PR) and Docs container test are skipping (expected, not failures).

Per-item confirmation

  • [101] custom-instructions parity — client .refine() mirrors the backend exactly: same CRLF/CR→LF normalization, same CUSTOM_INSTRUCTIONS_MAX_CHARS/CUSTOM_INSTRUCTIONS_ILLEGAL_RE (shared from convex/user_memories/constants), same empty-string carve-out; error wired to the Textarea, schema memo depends on [t]. ✅
  • [102] last-member feedback — enforceMinimumOne gates the disable+hint to the edit flow; create flow (0 selected) preserved. lastMemberHint present in en/de/fr; axe test passes. ✅
  • [104] Disconnect loading state — isSubmitting is now real useState, flipped true→false in try/finally on both success and error paths; feeds busy + the footer spinner; ConfirmDialog stays open via .finally(() => setConfirmDisconnect(false)) and confirm button is disabled in-flight. ✅
  • [105] dead ?section=apps — narrowed to z.literal('mcp-servers'); repo-wide search found no caller constructing section=apps, so no regression; mcp-servers redirect still works. ✅
  • [108] MCP name validation + uniqueness — name.length>1 carve-out removed; shared MCP_SERVER_NAME_RE/validateMcpServerName used client- and server-side; create/update actions trim, validate, and enforce per-org uniqueness via the new getIdByOrgAndName (by_org_name index), with correct self-exclusion on no-op rename and not_found/conflict/invalid codes surfaced to the toast. ✅

Non-blocking observations (suggested follow-ups, not merge blockers)

  1. team-edit-dialog.tsx handleToggleMember still contains if (next.size <= 1) return prev — now redundant since the sole member's checkbox is disabled. Harmless, but could be removed for clarity.
  2. integration-panel.test.tsx mocks useIntegrationManage, so the real hook's handleDisconnect try/finally is only covered indirectly. A small direct hook test would close the gap; the change is mechanical and type-checked.
  3. [101] mirrors length + illegal-char rules but not the backend's separate CUSTOM_INSTRUCTIONS_MAX_TOKENS budget — out of scope for this issue (which scoped [101] to illegal-char parity), pre-existing.

None of the above affects correctness, so this does not block merge.

@larryro
larryro force-pushed the tale/xs705hg0qde0am4c2x32pnmnvx898chd branch from 5345ca8 to 6f4a710 Compare July 1, 2026 06:37

@larryro larryro left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Desk Review — PR #2132 · fix: Settings low-severity gaps (#2091)

VERDICT: READY TO MERGE. All five itemized gaps ([101], [102], [104], [105], [108]) are implemented correctly, minimally, and per the issue's stated remedy. CI is green and the project's own tests pass. Everything below the per-item section is a non-blocking observation or optional follow-up — none is a required change.

Reviewed by cloning the repo, checking out the head ref tale/xs705hg0qde0am4c2x32pnmnvx898chd, and reviewing the whole implementation around each changed line (not just the diff) in two rounds: breadth review across correctness/robustness/elegance/tests/boundaries, then independent re-verification of every load-bearing conclusion.

CI state — GREEN (confirmed via gh pr checks 2132)

Every required check passes: Type check, Lint, Format, Knip, Lint commits, Unit, UI, Migrations, Opengrep, Smoke test, Analyze (javascript-typescript + python), Build (platform/convex/db/controller/proxy/sandbox…), Storybook, all 16 Playwright (platform) shards + Playwright (web) + Playwright (docs), Validate images, Scan platform. The only non-pass rows are conditional skips (Trivy, Docs/Web container tests, fork-PR-only jobs) — no failures, nothing pending. mergeStateStatus: CLEAN, mergeable: MERGEABLE.

Tests run locally on the branch

  • Backend (server project): bunx vitest --run --project server mcp_servers messages → 10 files, 82 tests passed. (Re-run --project server mcp_servers → 7 files, 45 passed.)
  • UI (components): bunx vitest --run --config vitest.ui.config.ts team-member-checklist integration-panel mcp-server-form → 3 files, 15 tests passed.
  • i18n parity (enforce mode): 23/23 passed — de and fr match en's keyset exactly; no missing/extra keys.

Per-item verdicts

[101] Custom-instructions illegal-char parity — CORRECT.
personalization-settings.tsx now imports CUSTOM_INSTRUCTIONS_ILLEGAL_RE / CUSTOM_INSTRUCTIONS_MAX_CHARS from the shared convex/user_memories/constants.ts (dropping the duplicated local 4000) and adds two Zod .refine()s: normalized-length ≤ 4000, and the illegal-char set with an empty-string carve-out. normalizeInstructions (CRLF→LF then lone-CR→LF) is byte-identical to the backend (user_preferences/mutations.ts:29-31). Verified client verdict == backend verdict across empty / embedded-LF (allowed) / CRLF / lone-CR / 4000 (accept) / 4001 (reject) / <tag> / backtick / tab \x09 / bell \x07 (all reject). Uses .refine not .transform, so the stored/submitted value and dirty tracking are untouched; the error surfaces inline via the Textarea errorMessage prop (prop exists, renders in a role="alert").

[102] Team-edit last-member silent refusal — CORRECT.
team-member-checklist.tsx gains enforceMinimumOne; the edit dialog passes it, the create dialog does not (create still permits 0 selected → current user auto-added). When exactly one member is selected, that member's Checkbox is disabled (Radix suppresses onCheckedChange) with a cursor-not-allowed label + title, and an explanatory settings.teams.lastMemberHint is shown. size <= 1 correctly mirrors the backend rejection at team_members/mutations.ts (throws when member page.length <= 1).

[104] Integration Disconnect loading state — CORRECT.
use-integration-manage.ts replaces const isSubmitting = false with real useState, set true at the start of handleDisconnect and false in a finally (symmetric on success and error; errors are caught → destructive toast, so the promise never rejects). integration-panel.tsx keeps the ConfirmDialog open (isLoading={manage.isSubmitting}) until handleDisconnect().finally(() => setConfirmDisconnect(false)) settles, then closes on both outcomes; the previously-dead footer spinner is now activated. Verified the confirm button is gated by isSubmitting/isLoading — not the busy aggregate — so feeding isSubmitting into busy (line 306) causes no deadlock; busy only disables the sheet's own footer/Delete buttons during the in-flight disconnect, which is the intended behavior.

[105] Dead ?section=apps param — CORRECT.
integrations.tsx narrows section to z.literal('mcp-servers').optional(). Confirmed beforeLoad only ever read 'mcp-servers', an 'apps' handler never existed in history, and a monorepo-wide search finds zero producers of ?section=apps (no in-app navigation emits section other than the redirect target). ?section=mcp-servers deep links still validate and redirect. This matches the issue's sanctioned remedy ("drop 'apps' from the enum").

[108] MCP server name slug + server-side validation — CORRECT.
New shared convex/mcp_servers/constants.ts (MCP_SERVER_NAME_RE = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/, MCP_SERVER_NAME_MAX_LENGTH = 64, validateMcpServerName) is imported by both the client form and the server actions, so validation cannot drift. The client form drops the name.length > 1 carve-out (single lowercase now correctly passes; single uppercase now correctly fails) and validates the trimmed value. Server create/update actions trim + validate + enforce per-org uniqueness via the new getIdByOrgAndName internal query (uses the existing by_org_name index on ['organizationId','name']). update derives the org scope from the server-side existing row (not client input) and excludes the row's own id (duplicateId !== id), so a no-op self-rename is allowed. ConvexError messages surface in the toast via convexErrorMessage. i18n keys nameTooLong ({max}) / nameInvalid added to all three locales; the old nameFormat key is cleanly removed (no orphan). Tests are revert-sensitive (duplicate-conflict, 'A' → invalid_format, self-rename-allowed, cross-server-collision).

Non-blocking observations (optional follow-ups — NOT required to merge)

  1. [101] residual token-budget parity gap (out of this item's scope). The backend additionally rejects estimateTokens(normalized) > 800 (CUSTOM_INSTRUCTIONS_MAX_TOKENS), which the client does not mirror. Because ~4 chars/token (Latin) and ~1.5 chars/token (CJK), a value that is ≤ 4000 chars and legal can still exceed 800 tokens (roughly > 3200 Latin chars, or > ~1200 CJK chars), passing client validation but getting bounced server-side into a generic toast. Issue #2091 [101] names only the illegal-char rule + identical CRLF normalization (delivered), so this is not blocking — but a third .refine importing estimateTokens/CUSTOM_INSTRUCTIONS_MAX_TOKENS would complete the inline-feedback goal. (The raw-length character counter also displays un-normalized length — cosmetic.)

  2. [108] uniqueness check is best-effort (TOCTOU). The dup-check is a runQuery in the Node action followed by a separate runMutation insert/patch; Convex has no unique-index constraint, so two concurrent same-name creates could both pass and both insert. Extremely unlikely for admin-only settings (double-click / two admins), and worst case is a duplicate row, not a crash. Consider moving the check into the transactional internal insert/update mutation in a follow-up to make it atomic.

  3. [108] pre-existing org-membership gap (not introduced by this PR). create/update/remove/updateStatus verify authentication (getAuthUserIdentity) but not org membership; create trusts the client-provided organizationId. Verified this is unchanged from main (no membership line was added or removed here) and it cannot be fixed within these Node actions (no ctx.db). Worth a separate authorization-hardening task (add a membership check inside the internal mutations); out of scope for this PR.

  4. [102] minor polish. (a) The now-redundant silent guard if (next.size <= 1) return prev; in team-edit-dialog.tsx:90 is unreachable via the UI (checkbox disabled) — either drop it or comment it as a defensive backstop. (b) The standalone hint renders whenever size <= 1, so in the degenerate case of 0 selected (transient during load, or a sole member who left the org and no longer renders a row) the hint can show with nothing disabled. (c) The disabled-reason is conveyed only via title (not aria-describedby), and the axe test doesn't cover the enforceMinimumOne branch.

  5. [105] behavioral nuance. A hand-crafted ?section=apps URL (which nothing produces) now hits the router's error boundary instead of silently rendering, because validateSearch throws on invalid search repo-wide. Unreachable in practice; z.literal('mcp-servers').optional().catch(undefined) would make stray values degrade silently if desired.

  6. Test nice-to-haves (none merge-blocking). No client test for the [101] Zod refines (the security-relevant backend rule is well-covered in user_preferences/mutations.test.ts, so it can't silently regress); no test for update with name === undefined (skip-guard); no direct test for getIdByOrgAndName.


READY TO MERGE

- personalization [101]: client Zod schema mirrors the backend illegal-char
  + length rule (CRLF/lone-CR normalized to LF identically), surfaced inline
  on the textarea via new personalization.errors.{tooLong,illegalChars} keys.
- teams [102]: disable + hint the sole-member checkbox instead of silently
  refusing to uncheck it; gated to the edit flow so create is unaffected.
- integrations [104]: real isSubmitting drives the Disconnect loading state
  and keeps the ConfirmDialog open until the action resolves.
- integrations route [105]: drop the dead ?section=apps search param.
- mcp servers [108]: shared name slug validation (MCP_SERVER_NAME_RE) +
  per-org uniqueness on create/update; drop the name.length>1 client
  carve-out; removed the now-orphaned mcpServers.form.validation.nameFormat
  i18n key (superseded by nameInvalid).

Closes #2091
@cursor
cursor Bot force-pushed the tale/xs705hg0qde0am4c2x32pnmnvx898chd branch from 6f4a710 to 2fb7377 Compare July 3, 2026 13:59
@cursor
cursor Bot merged commit 150fd5e into main Jul 3, 2026
26 of 31 checks passed
@cursor
cursor Bot deleted the tale/xs705hg0qde0am4c2x32pnmnvx898chd branch July 3, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant