Skip to content

feat: add script to check for title case - #21484

Merged
jaaydenh merged 74 commits into
mainfrom
jaaydenh/sentence-case
Nov 18, 2026
Merged

jaaydenh merged 74 commits into
mainfrom
jaaydenh/sentence-case

Conversation

@jaaydenh

@jaaydenh jaaydenh commented Jan 12, 2026 •

Copy link
Copy Markdown
Collaborator

Historically, much of the UI used title case. This PR adds a lint check that reports title case UI text so it can be converted to sentence case, and converts the existing text.

  • site/scripts/check-sentence-case.mjs runs as pnpm lint:sentence-case and is part of pnpm lint. It reads JSX text and string/template literals from the TypeScript AST and skips literals that are code rather than UI text (imports, types, property names, tagged templates, values of JSX attributes that are not displayed such as className or style, and operands of ===/case comparisons). JSX text across inline elements and conditional JSX is checked as one phrase. --fix lowercases the reported words. The checker is a heuristic: it is not meant to model every code shape, so use a sentence-case-expect comment where it guesses wrong.
  • Proper nouns (Coder products, role names, third-party products, protocols, font names) live in PROPER_NOUNS. For other deliberate exceptions, a sentence-case-expect comment on the line above suppresses the report and fails when that line no longer needs it.
  • Existing UI text is converted to sentence case, and tests that assert on it are updated.
  • Deployment option lookups (useDeploymentOptions) now use CLI flags instead of display names, so they do not depend on UI wording.

Performance

pnpm lint:sentence-case takes 1.6 s and is 2% to 4.5% of pnpm lint. Measured on 82317c9 in a dev workspace (Xeon Platinum 8375C, 16 vCPUs, Node 22.23.4, TypeScript 6.0.2, warm file cache). CI buffers the output of the lint steps, so its log has no per-step times to compare against.

Measurement (20 runs) Result
Wall time 1.64 s mean, 0.03 s standard deviation, 1.62 s to 1.71 s
CPU time 3.0 s
Peak memory (RSS) 154 MB, of which 116 MB is Node with typescript loaded
Input 1,301 of the 2,199 .ts and .tsx files in site/src (the rest are excluded), 210,684 lines, 6.1 MB
Throughput About 130,000 lines per second
Time per file 0.5 ms median, 3 ms at the 95th percentile, 76 ms maximum (src/api/api.ts, 121 KB)

Each step of pnpm lint, median wall time of 5 runs:

Step Wall time
lint:check (Biome) 0.96 s
lint:oxlint 0.32 s
lint:types (tsc) 5.8 s with its incremental cache, 45 s without
lint:circular-deps 5.7 s
lint:compiler 15.6 s
lint:sentence-case 1.6 s
knip 6.6 s
All of pnpm lint 37 s with the tsc cache, 76 s without
Where the time goes, scaling, and limits

Phases of one run, from in-process timers. The split between parsing and checking is approximate.

Phase Time Share
Node startup 0.03 s 2%
Load the typescript module 0.32 s 20%
Find and read the files 0.04 s 2%
Parse (ts.createSourceFile) 0.83 s 52%
Check logic 0.38 s 24%

Scaling, from synthetic inputs passed to checkSource (median of 3 to 5 warm runs):

  • Clean input is linear in size: 0.2 ms to 0.35 ms per KB for one file from 54 KB to 7 MB. 100,000 string literals take 0.3 s, 100,000 sibling JSX elements take 0.8 s, and JSX nested 800 levels deep takes 10 ms.
  • Conditional JSX stays bounded by the 64-variant cap: 1 to 48 conditional children in one element take at most 3.4 ms.
  • Reporting and fixing add no measurable time. On the merge base with main (378 reports in 175 files), a check, --fix, and a second --fix each take 1.6 s to 1.7 s.
  • The 21 unit tests run in about 30 ms, 1.7 s including Vitest startup.

Two limits, neither reachable with the current source:

  • Time is quadratic in the reports for one file, because the fixed text is rebuilt once per report. A 3.5 MB file takes 0.7 s clean and 18.0 s with 12,800 reports. The most reports in one file on the merge base is 16.
  • One JSX element with more than about 120,000 text phrases fails with RangeError: Maximum call stack size exceeded, because the phrases are spread into push.

@jaaydenh jaaydenh self-assigned this Jan 12, 2026
@jaaydenh jaaydenh changed the title feat: add script to check for sentence case feat: add script to check for title case Jan 12, 2026
@jaaydenh
jaaydenh marked this pull request as ready for review January 12, 2026 20:37
@jaaydenh
jaaydenh requested review from aslilac and jakehwll January 12, 2026 20:38

@aslilac aslilac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I like the idea, and have been pushing for sentence case for my entire tenure, but this script is pretty janky

Comment on lines +1 to +2
// scripts/check-sentence-case.js
//

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// scripts/check-sentence-case.js
//

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done. The script moved to site/scripts/check-sentence-case.mjs (next to check-compiler.mjs), and the stale filename header is gone. It now opens with a doc comment that describes what it checks and how to use it.

Comment on lines +70 to +81
// Geographic names (countries, territories, regions)
"British Indian Ocean Territory",
"Central African Republic",
"French Southern Territories",
"Northern Mariana Islands",
"Papua New Guinea",
"South Sandwich Islands",
"Syrian Arab Republic",
"United Arab Emirates",
"United States Minor Outlying Islands",
"New York City",
"Former Yugoslav Republic",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

how often are any of these used in the product?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not often enough to keep. The country names only appeared in countriesGenerated.ts, which is excluded as generated code, so I removed the geographic list entirely. PROPER_NOUNS now only holds names that show up in UI text: Coder products and role names, third-party products, protocol names, and the fonts listed in the terminal font picker.

]);

// Words that should NOT be capitalized in title case (unless first word).
const MINOR_WORDS = new Set([

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this necessary if the goal is to not capitalize words?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not necessary, removed. The check now reports any regular capitalized word that follows the first word of a phrase, so "Sign In To Coder" is caught without a special list of minor words.

// Matches: "Title Case", "ACRONYM Title Case", "Title ACRONYM Case"
// Word types: [A-Z][a-z]+ (Title) or [A-Z]{2,} (ACRONYM)
const TITLE_CASE_PATTERN =
/(?:^|>|\s)((?:[A-Z]{2,}\s+)?[A-Z][a-z]+(?:\s+(?:[A-Z][a-z]+|[A-Z]{2,}))+)(?:\s|<|$|[.!?])/g;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would consider myself pretty familiar with regex but this is nightmarish. I can't even begin to tell myself what this is actually doing, which is not a good sign.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, it's gone. Text now comes from the TypeScript AST (JSX text plus string and template literals), which also lets the check skip literals that are code rather than UI text: imports, types, property names, and operands of ===/case comparisons. Detection splits the text on whitespace and walks the words; there is no title case regex anymore. site/scripts/check-sentence-case.test.mjs covers the cases.


const newLines = lines.map((line, idx) => {
// Skip lines with ignore comment.
if (line.includes(IGNORE_COMMENT)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ignore comments are bad. "expect" (like @ts-expect-error) comments are better.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Switched to sentence-case-expect. It applies to the next line, and the check fails when that line has nothing to report, so stale exceptions surface the same way an unused @ts-expect-error does. There are two in the tree today, both with a reason: the "Startup Script" log source name that coderd assigns (an API value compared in AgentRow.tsx), and a board column name inside an LLM prompt. Skipping equality and case operands also let me drop the earlier toLowerCase() workarounds for notification group names.

if (allIssues.length > 0) {
if (fix) {
console.info(
`\x1b[32m✓ Fixed ${allIssues.length} sentence case issue(s):\x1b[0m\n`,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

inlining escape codes without attempting to check if the output is actually even a tty (as opposed to a file or CI feed) is pretty unfortunate.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Dropped the colors entirely. Output is now plain path:line:col: message lines like check-compiler.mjs, so it reads the same in a terminal, a file, or CI logs.

@github-actions github-actions Bot added the stale This issue is like stale bread. label Jan 21, 2026
@github-actions github-actions Bot closed this Jan 25, 2026
@jaaydenh jaaydenh reopened this Jan 27, 2026
@github-actions github-actions Bot removed the stale This issue is like stale bread. label Jan 28, 2026
@github-actions github-actions Bot added the stale This issue is like stale bread. label Feb 4, 2026
@jaaydenh jaaydenh removed the stale This issue is like stale bread. label Feb 4, 2026
@github-actions github-actions Bot added the stale This issue is like stale bread. label Feb 12, 2026
@github-actions github-actions Bot closed this Feb 15, 2026
@jaaydenh jaaydenh reopened this May 27, 2026
@github-actions github-actions Bot removed the stale This issue is like stale bread. label May 28, 2026
Move the checker to site/scripts/check-sentence-case.mjs next to
check-compiler.mjs and address review feedback:

- Read text from the TypeScript AST (JSX text plus string and template
  literals) instead of matching quotes with regexes. Literals that are
  code rather than UI text are skipped: imports, types, property names,
  and operands of equality checks or case clauses.
- Detect title case by walking words instead of a large regex, which
  also removes the MINOR_WORDS list.
- Replace ignore comments with "sentence-case-expect" comments that fail
  when the next line has nothing to report.
- Print plain output without ANSI escapes.
- Trim PROPER_NOUNS to names that appear in UI text.
- Add unit tests.

Re-run the conversion on current main, keep API values such as the
"Startup Script" log source name unchanged, and update tests that
assert on the converted text.
@jaaydenh
jaaydenh requested a review from a team as a code owner October 3, 2026 10:46

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 84137a2576

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread site/scripts/check-sentence-case.mjs Resolved
Comment thread site/scripts/check-sentence-case.mjs Resolved
Comment thread site/scripts/check-sentence-case.mjs Resolved
@jaaydenh

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf0d13c094

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread site/scripts/check-sentence-case.mjs Resolved
@jaaydenh

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6182df0eb4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread site/scripts/check-sentence-case.mjs Resolved
@jaaydenh

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d097cb878c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread site/scripts/check-sentence-case.mjs Resolved
Comment thread site/scripts/check-sentence-case.mjs Resolved
@jaaydenh

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: abd853c7b9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread site/scripts/check-sentence-case.mjs Resolved
Restore check-sentence-case.mjs and its tests from 6c77cb7. The
later rounds grew the script from 691 to 1773 lines to handle code
shapes that do not occur in this codebase; the 691-line version reports
the same set of issues on the current tree once "Web Terminal" and
"Workspace Proxy" are proper nouns. The UI copy and docs fixes from
those rounds stay.
@jaaydenh

Copy link
Copy Markdown
Collaborator Author

Scope reset: check-sentence-case.mjs and its tests are back to the 691-line version from 6c77cb7, plus "Web Terminal" and "Workspace Proxy" in PROPER_NOUNS. The review rounds after that commit grew the script to 1,773 lines to handle code patterns that don't occur in this codebase. On the current tree, the smaller version reports the same issues. The UI copy and docs fixes from those rounds stay.

The checker is a heuristic. For shapes it misreads, use a sentence-case-expect comment rather than more special cases in the script.

"Agent hours" is the casing the license pages already use, so the
capacity callout and the Coder Agents docs now match it.
Values of JSX attributes such as className, style, or href are code, so
the sentence case checker now skips them and --fix cannot rewrite them.
Display attributes (title, label, aria-label, and props named like
confirmText) are still checked, and so are strings in event handlers.
The "Agent Hours" proper noun is dropped in favor of "Agent hours".
Earlier edits renamed labels ("Create Template" to "New template") and
changed wording or formatting. Keep only the casing change for each.
"Agent Hours" is a named license allowance, so the license cards, the
capacity callout, their stories, and the Coder Agents docs now spell it
with a capital H, and the sentence case checker accepts only that form.
@DanielleMaywood

Copy link
Copy Markdown
Collaborator

Can your agent provide benchmarks on the performance of this script in the description?

The sentence case check compared every proper noun with every word of
every text. Key the nouns by their first word so a word is compared
only with the nouns that can start at it.
The terminal preview added on main shows a Go sample in a template
literal, and the check reported the function names in its comments. An
expect comment could only cover the line below it, so it could not be
used for text inside a multi-line literal. A comment above the literal
now applies to the whole literal.
@jaaydenh

Copy link
Copy Markdown
Collaborator Author

Can your agent provide benchmarks on the performance of this script in the description?

Updated

This branch had an error being deployed

1 failed and 1 inactive deployments
main — 99830e98 Deployed Nov 18, 2026 by jaaydenh via cla #259145
docs-preview — 99830e98 Deployed Nov 18, 2026 by jaaydenh via cleanup #200
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants