fix: keep underscores and hyphens inside words in description previews

Merged
BU
4d ago
+13-1

What does this PR do?

On the Resources page, the Description column of both the Workspace and the Resource Types tables removes every _, -, *, #, | and [ from the text, including the ones inside words. On a fresh install the built-in types already show it: the ai_instruction row reads "an aiinstruction at f/billing/AGENTS" and ai_review_instruction reads "an aireviewinstruction". A user description such as "Read-only replica for the e2e_tests suite" is shown as "Readonly replica for the e2etests suite", and "Rotated 2026-11-15, see f/ops/rotate_keys" as "Rotated 20261115, see f/ops/rotatekeys".

removeMarkdown in utils.ts (only used by these two columns and their title tooltips) deleted those characters wherever they occur. This PR still deletes *, #, | and [ everywhere, and deletes _ and - only where they are not between two letters or digits (in any script), so markup is still stripped and identifiers, dates and hyphenated words stay as written: one changed line plus a comment, and a unit test.

Reproduced on main at 31b45b4 (CE v1.875.0).

flowchart TD
    A[Description contains ai_instruction or read-only] --> B{Description column on the Resources page}
    B -->|Before| C[Shows aiinstruction and readonly]
    B -->|After| D[Shows the words as written]

Narrated recording, before then after (sound on):

https://github.com/user-attachments/assets/36d10441-f33c-4f96-a170-e6b96dea231f

The recording is the real app (frontend dev server from this checkout against the main backend image). Waits on page loads are shortened; nothing else is edited.

Edge cases and unchanged behaviour checked

All checked in the running app, on this branch:

  • A name with several underscores (ai_review_instruction) stays whole.
  • A date and a path (2026-11-15, f/ops/rotate_keys) are left alone.
  • Unchanged: markdown markers are still removed (# Billing, - **Stripe** key, _test mode_ shows as "Billing Stripe key, test mode").
  • Unchanged: a plain description is shown as before.
  • Unchanged: opening a resource type still renders its full markdown description.

Checks run

  • npx vitest run src/lib/utils.test.ts: 96 passed. The new removeMarkdown test fails on main ("an aiinstruction for readonly use") and passes here.
  • npm run lint (oxlint): passes.
  • prettier --check on the changed files: passes.
  • The second commit (asterisks inside words, accented letters) follows the review comments and is covered by the unit test only; the recording was made on the first commit and shows the same results for its inputs.
  • Not run: npm run check (svelte-check needs about 8 GB here) and npm run check:fast (no bun on this machine). The function's signature is unchanged.

Related issue

None filed. Found on the Resource Types tab of a fresh instance.

AI assistance (Claude Code) was used to find, fix and record this. I reproduced and verified it in the running app.

šŸ¤– Generated with Claude Code