Skip to content

Consolidate web errorMessage onto the shared helper - #926

Merged
selfcontained merged 1 commit into
mainfrom
agt_a8ccbe18628a/job-debt-collector-d1f46be8
Aug 10, 2026
Merged

Consolidate web errorMessage onto the shared helper#926
selfcontained merged 1 commit into
mainfrom
agt_a8ccbe18628a/job-debt-collector-d1f46be8

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

What

Completes the errorMessage regression sweep started server-side in #914. apps/web had its own copy of the helper plus one inline ternary; both now use the canonical apps/server/src/shared/lib/error-message.ts.

  • Deleted the byte-identical reimplementation errorMessage in apps/web/src/components/app/jobs-helpers.tsx and re-pointed its four importers (jobs-add-dialog, jobs-detail-pane, jobs-prompt-tab, jobs-settings-tab).
  • Replaced the inline err instanceof Error ? err.message : String(err) in apps/web/src/components/ui/markdown.tsx:211 (mermaid render error path).
  • Addedapps/web/src/lib/errors.ts, a thin re-export of the shared helper.
  • Dropped the errorMessage describe block from jobs-helpers.test.tsxapps/server/test/error-message.test.ts already covers a strict superset (adds Error subclasses and null).

Net −19 lines. Zero behavior change: both removed expressions were byte-equivalent to the helper body.

Why this shape

Web imports a value here, not a type, so per the #844/#849 pattern it needs a dependency-free source module — shared/lib/error-message.ts qualifies (zero imports). The new @/lib/errors re-export keeps web call sites on @/lib/... instead of reaching across the apps/server boundary directly, matching lib/agent-types.ts, lib/ide-types.ts, and lib/media-upload.ts. finalize:web confirms the value import bundles cleanly.

Deliberately NOT swept

A grep for instanceof Error across apps/web/src returns 29 non-test sites. Only the 2 above were byte-equivalent; the other 27 carry distinct fallbacks and must keep them. Enumerated so a future run doesn't re-litigate:

  • Custom fallback strings (22): "Failed to load jobs.", "Failed to save.", "Failed to send test.", "Failed to save browser notifications.", "Failed to load/save IDE settings.", "Failed to create agent.", "Couldn't load branches.", "Failed to save cross-repo messaging setting.", "Upload failed", "Failed to load personalities.", "Failed to set active personality.", "Failed to delete.", "Failed to save prompt delivery setting.", "Failed to load/save agent type settings.", "Failed to check for updates", "Failed to start assisted update", "Session connection failed." — plus "Failed to load release info" / `Failed to promote ${tag}`.
  • undefined fallback (2): session-settings-dialog.tsx:61, agent-card-header.tsx:80 — a toast description that is deliberately omitted for non-Errors.
  • null fallback (1): persona-launcher.tsx:183.
  • Message is transformed, not just extracted (4): cleanError(err.message) in release-admin.tsx ×2 and use-release-updates.ts ×2; `Couldn't start update: ${err.message}` in release-available-toast.tsx:154.

Validation

pnpm run check, pnpm run finalize:web, web vitest (732 passed / 56 files), pnpm run test:e2e (178 passed, 12 skipped) — all green. Server unit tests not run: no backend files changed.

Next run

Queued: formatDate name collision — three identically-named one-line wrappers over @/lib/format with three different behaviors (activity-chart-utils.ts:3, release-utils.ts:24, jobs-helpers.ts:43).

🤖 Generated with Claude Code

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
selfcontained merged commit 228dfeb into mainAug 10, 2026
1 check passed
@selfcontained
selfcontained deleted the agt_a8ccbe18628a/job-debt-collector-d1f46be8 branch August 10, 2026 09:09
Sign up for freeto 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

@selfcontained