Skip to content

Consolidate mirrored agent-type/ide-type tables into shared modules - #849

Merged
selfcontained merged 1 commit into
mainfrom
tech-debt/shared-agent-ide-types
Jul 29, 2026
Merged

Consolidate mirrored agent-type/ide-type tables into shared modules#849
selfcontained merged 1 commit into
mainfrom
tech-debt/shared-agent-ide-types

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

What

Moves the agent-type and IDE-type constants/predicates that were duplicated verbatim across the server/web boundary into two new dependency-free shared modules:

  • apps/server/src/shared/agent-types.tsAGENT_TYPES, CLI_AGENT_TYPES, isAgentType, isCliAgentType, sanitizeEnabledAgentTypes
  • apps/server/src/shared/ide-types.tsIDE_TYPES, isIdeType, sanitizeEnabledIdes

apps/server/src/agent-type-settings.ts and ide-settings.ts keep their Pool-dependent getters and re-export the pure symbols, so no server importer changes. apps/web/src/lib/agent-types.ts and ide-types.ts re-export across the workspace boundary (same shape as media-file-types.ts from #844) and keep the web-only labels/helpers (AGENT_TYPE_LABELS, sortAgentTypes, isNestedReviewAgent, IDE_LABELS), so no web importer changes either.

Why it's tech debt

Adding an agent type today means editing two identical tables that have already started to drift in small ways (predicate signatures, comment wording). Same failure mode that produced the media file-type bugs fixed in #844.

Zero behavior change: only widening of isAgentType/isCliAgentType web signatures from (value: string) to (value: unknown), which is safe for all callers.

Validation

  • pnpm run check
  • pnpm run finalize:web
  • pnpm run test — 2362 server + 499 web + 60 passed ✅
  • pnpm run test:e2e — 174 passed, 12 skipped ✅

Queued next

Top of the tech-debt backlog: deduplicating the verbatim server↔web wire types (JobRecord/Job, TemplateRecord/Template, ReleaseJob), one file at a time.

🤖 Generated with Claude Code

AGENT_TYPES, CLI_AGENT_TYPES, and their predicates/sanitizers were
duplicated verbatim between apps/server/src/agent-type-settings.ts and
apps/web/src/lib/agent-types.ts; same for IDE_TYPES between
apps/server/src/ide-settings.ts and apps/web/src/lib/ide-types.ts.
Adding an agent type meant editing both copies.

Move the pure constants and predicates into dependency-free
apps/server/src/shared/agent-types.ts and shared/ide-types.ts,
following the media-file-types.ts shape from #844: the server settings
modules re-export so their importers are untouched, and the web lib
modules re-export across the workspace boundary so web importers keep
their "@/lib/..." specifiers. Pool-dependent getters stay on the
server; display labels and web-only helpers stay in web.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@selfcontained
selfcontained merged commit 0e79f2a into main Jul 29, 2026
1 check passed
@selfcontained
selfcontained deleted the tech-debt/shared-agent-ide-types branch July 29, 2026 09:12
selfcontained added a commit that referenced this pull request Aug 10, 2026
Completes the errorMessage sweep started server-side in #914. apps/web
carried a byte-identical reimplementation in jobs-helpers.tsx plus one
inline copy in markdown.tsx; both now route through the canonical
apps/server/src/shared/lib/error-message.ts.

Web imports a VALUE here, so it follows the #844/#849 shape: a new
dependency-free re-export module at apps/web/src/lib/errors.ts keeps call
sites on "@/lib/..." instead of reaching across the boundary directly.

Test coverage for the helper already exists in
apps/server/test/error-message.test.ts and is a strict superset of the
jobs-helpers.test.tsx block, which is dropped.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
selfcontained added a commit that referenced this pull request Aug 13, 2026
apps/server/src/shared/agent-types.ts has been the single source of truth for
the agent-type tables since PR #849, but three within-server hand-written
copies survived that consolidation. Point them all at the shared tables.

- agents/types.ts: the literal AgentType union becomes a re-export of the
  shared derived type (identical member set).
- shared/mcp/crud-tools.ts: JOB_AGENT_TYPES / TEMPLATE_AGENT_TYPES become
  aliases of CLI_AGENT_TYPES / AGENT_TYPES.
- shared/mcp/persona-interaction-tools.ts: LAUNCH_PERSONA_AGENT_TYPES /
  LaunchPersonaAgentType become aliases of CLI_AGENT_TYPES / CliAgentType.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
selfcontained added a commit that referenced this pull request Aug 15, 2026
The eight-colour brand palette existed in three places, with the hexes
duplicated a fourth time:

  1. apps/server/src/server/static-theme.ts — VALID_ICON_COLORS id tuple
  2. apps/web/src/hooks/use-icon-color.ts — ICON_COLORS id tuple, plus
     ICON_COLOR_OPTIONS re-listing the same hexes as `swatch`
  3. scripts/generate-icon-colors.ts — the same ids with primary/dark hexes

Adding a colour meant editing three files in two TS programs. All three now
derive from a new dependency-free apps/server/src/shared/icon-colors.ts
(the #844/#849 shared-module pattern), which holds the ids and both hex
channels in one ordered table.

Behaviour is unchanged: the tuple order (teal, blue, purple, red, orange,
amber, pink, cyan) is preserved exactly, so the Appearance settings swatch
order and the server's `iconColor must be one of: ...` error string are
byte-identical. Re-running the icon generator produces zero git diff.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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