Skip to content

feat: add previous companies information#132

Merged
nikilok merged 3 commits into
mainfrom
feat/previous-companies
May 29, 2026
Merged

feat: add previous companies information#132
nikilok merged 3 commits into
mainfrom
feat/previous-companies

Conversation

@nikilok
Copy link
Copy Markdown
Owner

@nikilok nikilok commented May 28, 2026

image image

Summary by CodeRabbit

  • New Features
    • Company pages now show a visual name-history timeline and integrate former names into the About summary.
    • Company profiles include previous names in their data so the UI and structured data can present historic names.
    • Structured data for companies may include an alternate name for improved external indexing.
    • Name formatting improved to better capitalize mixed alphanumeric segments.

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
learn-tanstack-start Ready Ready Preview, Comment May 28, 2026 11:28pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Warning

Review limit reached

@nikilok, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 55 minutes and 52 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: bfea80de-53aa-4f8a-b029-7823c09d41d7

📥 Commits

Reviewing files that changed from the base of the PR and between 1724a42 and c356723.

📒 Files selected for processing (2)
  • apps/web/src/components/NameHistory.tsx
  • apps/web/src/utils.ts
📝 Walkthrough

Walkthrough

Adds previous company names to the Companies House API output, introduces a NameHistory React component to render a timeline of former names, and integrates formatted, deduplicated former-name text plus alternateName into the company detail page and JSON‑LD; titleCase capitalization is adjusted.

Changes

Company Name History Timeline

Layer / File(s) Summary
API data extraction
apps/web/src/api/companiesHouse.ts
The getCompanyProfile response includes previousNames derived from profile.previous_company_names, defaulting to [].
NameHistory timeline component
apps/web/src/components/NameHistory.tsx
New NameHistory component renders the current company name as an h1 and, when previousNames exist, displays them in a vertical ordered timeline with connecting visuals; previous names are formatted with titleCase and list keys use ${name}-${index}.
Company detail page integration
apps/web/src/routes/company.$id.$slug.tsx
Page imports NameHistory, adds Intl.ListFormat and normalizeName, prefers profile.company_name for legalName, computes displayName, filters/deduplicates formerNames, conditionally appends "also registered as …" and "previously known as …" sentences, and passes displayName to AddressMap.
Utilities: titleCase and JSON‑LD
apps/web/src/utils.ts, apps/web/src/utils/jsonld.ts
titleCase now uppercases the first alphabetic character following optional leading digits within words; CompanyJsonLdInput gains optional alternateName and organization() conditionally sets alternateName in the generated JSON‑LD.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hop through names both new and old,

Former titles told in ribboned gold,
A timeline stitched with care and cheer,
Now every past name whispers near,
Hooray — the company’s history is clear!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding support for displaying a company's previous names throughout the application.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/previous-companies

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/web/src/utils.ts (1)

1-115: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Pipeline failure: Format check failed.

The CI pipeline reports formatting issues in this file. You must run bun format (or the equivalent formatter command) to fix the formatting before this PR can be merged.

#!/bin/bash
# Run the formatter to fix the formatting issues
bun format
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/src/utils.ts` around lines 1 - 115, The file fails CI due to
formatting; run the project formatter (bun format) to reformat this file and
commit the changes so the pipeline passes. Locate the utilities in this
diff—functions like titleCase, slugify, formatAddress, dlog, formatLocation, and
formatDate—and run `bun format` (or your repo's configured formatter) to
automatically fix spacing/linebreaks, then review and stage the reformatted file
and push the commit.
🧹 Nitpick comments (1)
apps/web/src/routes/company.$id.$slug.tsx (1)

103-114: ⚡ Quick win

Consider extracting the displayName/registeredAs computation logic.

The head() function (lines 103-114) and the CompanyDetail component (lines 220-229) both implement similar logic to compute the display name and determine whether the HMRC name differs from the Companies House name. Extracting this into a shared helper would reduce duplication and ensure consistency.

♻️ Proposed refactor to extract shared logic
+// Compute display name and alternate registration, preferring Companies House over HMRC.
+function computeDisplayNames(
+  hmrcName: string,
+  companiesHouseName?: string | null,
+) {
+  const displayName = companiesHouseName
+    ? titleCase(companiesHouseName)
+    : titleCase(hmrcName);
+  const currentKey = normalizeName(companiesHouseName ?? hmrcName);
+  const alsoRegisteredAs =
+    normalizeName(hmrcName) !== currentKey ? titleCase(hmrcName) : null;
+  return { displayName, alsoRegisteredAs, currentKey };
+}
+
 export const Route = createFileRoute('/company/$id/$slug')({

Then use it in both locations:

 head: ({ match }) => {
   // ...
-  const name = loaderData
-    ? titleCase(
-        loaderData.profile?.company_name ??
-          loaderData.sponsor.organisationName,
-      )
-    : 'Company Details';
-  const registeredAs =
-    loaderData &&
-    normalizeName(loaderData.sponsor.organisationName) !== normalizeName(name)
-      ? titleCase(loaderData.sponsor.organisationName)
-      : '';
+  const { displayName: name, alsoRegisteredAs: registeredAs } = loaderData
+    ? computeDisplayNames(
+        loaderData.sponsor.organisationName,
+        loaderData.profile?.company_name,
+      )
+    : { displayName: 'Company Details', alsoRegisteredAs: null };
 function CompanyDetail() {
   // ...
-  const hmrcName = titleCase(sponsor.organisationName);
-  const displayName = profile?.company_name
-    ? titleCase(profile.company_name)
-    : hmrcName;
-  const currentKey = normalizeName(
-    profile?.company_name ?? sponsor.organisationName,
-  );
-  const alsoRegisteredAs =
-    normalizeName(sponsor.organisationName) !== currentKey ? hmrcName : null;
+  const { displayName, alsoRegisteredAs, currentKey } = computeDisplayNames(
+    sponsor.organisationName,
+    profile?.company_name,
+  );

Also applies to: 220-229

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/src/routes/company`.$id.$slug.tsx around lines 103 - 114, The
display-name/registered-as logic is duplicated in head() and CompanyDetail;
extract it into a single exported helper (e.g., getCompanyDisplayNames or
computeDisplayNames) that accepts loaderData and returns { displayName,
registeredAs } using normalizeName and titleCase, preserve the current fallback
('Company Details') behavior, and update head() and the CompanyDetail component
to call this helper instead of duplicating the logic; ensure the helper has
correct typing/exports so both modules can import it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@apps/web/src/utils.ts`:
- Around line 1-115: The file fails CI due to formatting; run the project
formatter (bun format) to reformat this file and commit the changes so the
pipeline passes. Locate the utilities in this diff—functions like titleCase,
slugify, formatAddress, dlog, formatLocation, and formatDate—and run `bun
format` (or your repo's configured formatter) to automatically fix
spacing/linebreaks, then review and stage the reformatted file and push the
commit.

---

Nitpick comments:
In `@apps/web/src/routes/company`.$id.$slug.tsx:
- Around line 103-114: The display-name/registered-as logic is duplicated in
head() and CompanyDetail; extract it into a single exported helper (e.g.,
getCompanyDisplayNames or computeDisplayNames) that accepts loaderData and
returns { displayName, registeredAs } using normalizeName and titleCase,
preserve the current fallback ('Company Details') behavior, and update head()
and the CompanyDetail component to call this helper instead of duplicating the
logic; ensure the helper has correct typing/exports so both modules can import
it.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c7b81020-98b1-407b-a7c3-d2dacd60bd0b

📥 Commits

Reviewing files that changed from the base of the PR and between ad56080 and 1724a42.

📒 Files selected for processing (5)
  • apps/web/src/api/companiesHouse.ts
  • apps/web/src/components/NameHistory.tsx
  • apps/web/src/routes/company.$id.$slug.tsx
  • apps/web/src/utils.ts
  • apps/web/src/utils/jsonld.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/web/src/api/companiesHouse.ts
  • apps/web/src/components/NameHistory.tsx

@nikilok nikilok merged commit 55e3452 into main May 29, 2026
5 checks passed
@nikilok nikilok deleted the feat/previous-companies branch May 29, 2026 00:07
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