Files
PaperClipAI/ui/src/lib/external-objects.ts
T
0b01593602 build(deps): bump lucide-react from 0.577.0 to 1.32.0 (#11885)
Bumps
[lucide-react](https://github.com/lucide-icons/lucide/tree/HEAD/packages/lucide-react)
from 0.577.0 to 1.32.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/lucide-icons/lucide/releases">lucide-react's
releases</a>.</em></p>
<blockquote>
<h2>Version 1.32.0</h2>
<h2>What's Changed</h2>
<ul>
<li>feat(icons): added <code>car-battery</code> icon by <a
href="https://github.com/andreynaz4renko"><code>@​andreynaz4renko</code></a>
in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4088">lucide-icons/lucide#4088</a></li>
<li>fix(categories): fixes emoji.json by <a
href="https://github.com/karsa-mistmere"><code>@​karsa-mistmere</code></a>
in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4697">lucide-icons/lucide#4697</a></li>
<li>chore(deps): bump vue from 3.5.40 to 3.5.41 in the vue-deps group
across 1 directory by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4695">lucide-icons/lucide#4695</a></li>
<li>chore(dev): upgrade ESLint to latest compatible stack (v10) by <a
href="https://github.com/ericfennis"><code>@​ericfennis</code></a> with
<a href="https://github.com/Copilot"><code>@​Copilot</code></a> in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4378">lucide-icons/lucide#4378</a></li>
<li>feat(icons): add square-text by <a
href="https://github.com/samuelalake"><code>@​samuelalake</code></a> in
<a
href="https://redirect.github.com/lucide-icons/lucide/pull/4609">lucide-icons/lucide#4609</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/andreynaz4renko"><code>@​andreynaz4renko</code></a>
made their first contribution in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4088">lucide-icons/lucide#4088</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/lucide-icons/lucide/compare/1.31.0...1.32.0">https://github.com/lucide-icons/lucide/compare/1.31.0...1.32.0</a></p>
<h2>Version 1.31.0</h2>
<h2>What's Changed</h2>
<ul>
<li>feat(icons): added <code>mail-badge</code> icon by <a
href="https://github.com/lazerg"><code>@​lazerg</code></a> in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4638">lucide-icons/lucide#4638</a></li>
<li>feat(icons): add angle by <a
href="https://github.com/samuelalake"><code>@​samuelalake</code></a> in
<a
href="https://redirect.github.com/lucide-icons/lucide/pull/4545">lucide-icons/lucide#4545</a></li>
<li>feat(icons): added <code>eject</code> icon by <a
href="https://github.com/ThibautMarechal"><code>@​ThibautMarechal</code></a>
in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4043">lucide-icons/lucide#4043</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/lazerg"><code>@​lazerg</code></a> made
their first contribution in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4638">lucide-icons/lucide#4638</a></li>
<li><a
href="https://github.com/ThibautMarechal"><code>@​ThibautMarechal</code></a>
made their first contribution in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4043">lucide-icons/lucide#4043</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/lucide-icons/lucide/compare/1.30.0...1.31.0">https://github.com/lucide-icons/lucide/compare/1.30.0...1.31.0</a></p>
<h2>Version 1.30.0</h2>
<h2>What's Changed</h2>
<ul>
<li>chore(icons): refine &amp; rename various emoji icons by <a
href="https://github.com/karsa-mistmere"><code>@​karsa-mistmere</code></a>
in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4606">lucide-icons/lucide#4606</a></li>
<li>fix(scripts): removed toBeRemovedInVersion from all scripts and
tools by <a
href="https://github.com/karsa-mistmere"><code>@​karsa-mistmere</code></a>
in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4674">lucide-icons/lucide#4674</a></li>
<li>feat(icons): added <code>audio-lines-x</code> icon by <a
href="https://github.com/karsa-mistmere"><code>@​karsa-mistmere</code></a>
in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4590">lucide-icons/lucide#4590</a></li>
<li>feat(lab): added <code>chinese-character</code> icon to lab by <a
href="https://github.com/congemcd"><code>@​congemcd</code></a> in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4212">lucide-icons/lucide#4212</a></li>
<li>test(packages): updates unit test snapshots with
face-slightly-smiling by <a
href="https://github.com/karsa-mistmere"><code>@​karsa-mistmere</code></a>
in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4676">lucide-icons/lucide#4676</a></li>
<li>ci(dev): fix post-release job by downloading lucide-font artifact by
name by <a
href="https://github.com/ericfennis"><code>@​ericfennis</code></a> with
<a href="https://github.com/Copilot"><code>@​Copilot</code></a> in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4675">lucide-icons/lucide#4675</a></li>
<li>feat(icons): add shield-lock icon by <a
href="https://github.com/Caisere"><code>@​Caisere</code></a> in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/3508">lucide-icons/lucide#3508</a></li>
<li>ci(security): Pin sha actions by <a
href="https://github.com/jguddas"><code>@​jguddas</code></a> in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4678">lucide-icons/lucide#4678</a></li>
<li>feat(icons): added <code>broom</code> icon by <a
href="https://github.com/karsa-mistmere"><code>@​karsa-mistmere</code></a>
in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4683">lucide-icons/lucide#4683</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/congemcd"><code>@​congemcd</code></a>
made their first contribution in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4212">lucide-icons/lucide#4212</a></li>
<li><a href="https://github.com/Caisere"><code>@​Caisere</code></a> made
their first contribution in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/3508">lucide-icons/lucide#3508</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/lucide-icons/lucide/compare/1.29.0...1.30.0">https://github.com/lucide-icons/lucide/compare/1.29.0...1.30.0</a></p>
<h2>Version 1.29.0</h2>
<h2>What's Changed</h2>
<ul>
<li>fix(<code>@​lucide/lab</code>): Fix lab build by <a
href="https://github.com/ericfennis"><code>@​ericfennis</code></a> in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4618">lucide-icons/lucide#4618</a></li>
<li>feat(copilot): remove incorrect spaces clause from copilot
instructions by <a
href="https://github.com/karsa-mistmere"><code>@​karsa-mistmere</code></a>
in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4623">lucide-icons/lucide#4623</a></li>
<li>feat(docs): remove Super and Noodle from showcase by <a
href="https://github.com/karsa-mistmere"><code>@​karsa-mistmere</code></a>
in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4626">lucide-icons/lucide#4626</a></li>
<li>chore(deps-dev): bump <code>@​angular/platform-server</code> from
21.2.18 to 21.2.19 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4629">lucide-icons/lucide#4629</a></li>
<li>ci(security): improve security with adding permissions by <a
href="https://github.com/ericfennis"><code>@​ericfennis</code></a> in <a
href="https://redirect.github.com/lucide-icons/lucide/pull/4619">lucide-icons/lucide#4619</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/lucide-icons/lucide/commit/75b55160aa9edd7095dfed1a6e3d88e66fb2b153"><code>75b5516</code></a>
chore(dev): upgrade ESLint to latest compatible stack (v10) (<a
href="https://github.com/lucide-icons/lucide/tree/HEAD/packages/lucide-react/issues/4378">#4378</a>)</li>
<li><a
href="https://github.com/lucide-icons/lucide/commit/0f8d48b266e7af1e2bab49ff12ab6ec0795ed204"><code>0f8d48b</code></a>
test(packages): updates unit test snapshots with face-slightly-smiling
(<a
href="https://github.com/lucide-icons/lucide/tree/HEAD/packages/lucide-react/issues/4676">#4676</a>)</li>
<li><a
href="https://github.com/lucide-icons/lucide/commit/f229f83f0c42f46befeac3cfd8ef7aaa82a71325"><code>f229f83</code></a>
chore(depedencies): Update dependencies (<a
href="https://github.com/lucide-icons/lucide/tree/HEAD/packages/lucide-react/issues/4553">#4553</a>)</li>
<li><a
href="https://github.com/lucide-icons/lucide/commit/5ff536e1391335e4f7dc38d244c1bc458b9443e2"><code>5ff536e</code></a>
ci(release.yml): Fix workflow and remove <code>version</code> scripts in
package scripts...</li>
<li><a
href="https://github.com/lucide-icons/lucide/commit/07c885e6c1f9952965ba388b7fd2bb7c4d416a67"><code>07c885e</code></a>
fix(docs): fix zephyr-cloud URL in readmes</li>
<li><a
href="https://github.com/lucide-icons/lucide/commit/50d8af5a1012e188f3d71ac8f1fc0fba1aab5357"><code>50d8af5</code></a>
docs(readme): Update readme files (<a
href="https://github.com/lucide-icons/lucide/tree/HEAD/packages/lucide-react/issues/4320">#4320</a>)</li>
<li><a
href="https://github.com/lucide-icons/lucide/commit/653e44b83293567ff24dcb90ca1094a9cf0a042a"><code>653e44b</code></a>
feat(packages): use .mjs for ESM bundles (<a
href="https://github.com/lucide-icons/lucide/tree/HEAD/packages/lucide-react/issues/4285">#4285</a>)</li>
<li><a
href="https://github.com/lucide-icons/lucide/commit/7623e23f787fe78e5075a613fd22da2cecbb9b1b"><code>7623e23</code></a>
feat(docs): add Zephyr Cloud to Hero Backers tier &amp; rework
updateSponsors scr...</li>
<li><a
href="https://github.com/lucide-icons/lucide/commit/dada0a82970d3733d1d716e2089591c538272a39"><code>dada0a8</code></a>
fix(lucide-react): Fix dynamic imports (<a
href="https://github.com/lucide-icons/lucide/tree/HEAD/packages/lucide-react/issues/4210">#4210</a>)</li>
<li><a
href="https://github.com/lucide-icons/lucide/commit/a6e648a66ff470c2255d3666765fd73cfcc185ff"><code>a6e648a</code></a>
fix(lucide-react): correct client directives in RSC files (<a
href="https://github.com/lucide-icons/lucide/tree/HEAD/packages/lucide-react/issues/4189">#4189</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/lucide-icons/lucide/commits/1.32.0/packages/lucide-react">compare
view</a></li>
</ul>
</details>
<br />

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Priya Raman <priya@paperclip.ing>
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-08-25 10:54:14 -07:00

267 lines
7.9 KiB
TypeScript

import {
AlertCircle,
AlertOctagon,
Archive,
CheckCircle2,
Circle,
CircleDashed,
CircleDot,
Clock,
CloudOff,
GitMerge,
GitPullRequest,
KeyRound,
Loader2,
XCircle,
type LucideIcon,
} from "lucide-react";
import { GithubIcon } from "@/components/icons/github-icon";
import type {
ExternalObjectLivenessState,
ExternalObjectStatusCategory,
ExternalObjectStatusTone,
ExternalObjectSummary,
ExternalObjectSummaryItem,
} from "@paperclipai/shared";
/**
* Lucide icon for each status category. The mapping is host-owned per the
* Phase 1B security review — providers never inject inline React.
*/
export const externalObjectCategoryIcon: Record<string, LucideIcon> = {
unknown: CircleDashed,
open: CircleDot,
waiting: Clock,
running: Loader2,
succeeded: CheckCircle2,
failed: XCircle,
blocked: AlertOctagon,
closed: Circle,
archived: Archive,
auth_required: KeyRound,
unreachable: CloudOff,
};
export const externalObjectCategoryIconDefault: LucideIcon = CircleDashed;
export function externalObjectIconForCategory(category: string): LucideIcon {
return externalObjectCategoryIcon[category] ?? externalObjectCategoryIconDefault;
}
const EXTERNAL_OBJECT_ICON_KEYS: Record<string, LucideIcon> = {
archive: Archive,
check: CheckCircle2,
"check-circle": CheckCircle2,
circle: Circle,
"circle-dot": CircleDot,
clock: Clock,
github: GithubIcon,
"git-merge": GitMerge,
"git-pull-request": GitPullRequest,
key: KeyRound,
loader: Loader2,
"x-circle": XCircle,
};
export function externalObjectIconForKey(iconKey: string | null | undefined): LucideIcon | null {
if (!iconKey) return null;
return EXTERNAL_OBJECT_ICON_KEYS[iconKey] ?? null;
}
export function externalObjectIconForLiveness(liveness: string): LucideIcon | null {
if (liveness === "auth_required") return KeyRound;
if (liveness === "unreachable") return CloudOff;
return null;
}
const CATEGORY_LABELS: Record<string, string> = {
unknown: "Not yet resolved",
open: "Open",
waiting: "Waiting",
running: "Running",
succeeded: "Succeeded",
failed: "Failed",
blocked: "Blocked",
closed: "Closed",
archived: "Archived",
auth_required: "Authorization required",
unreachable: "Unreachable",
};
export function externalObjectCategoryLabel(category: string): string {
return CATEGORY_LABELS[category] ?? category.replace(/_/g, " ");
}
const LIVENESS_LABELS: Record<string, string> = {
unknown: "Not yet refreshed",
fresh: "Fresh",
stale: "Stale",
auth_required: "Requires auth",
unreachable: "Unreachable",
};
export function externalObjectLivenessLabel(liveness: string): string {
return LIVENESS_LABELS[liveness] ?? liveness.replace(/_/g, " ");
}
export function externalObjectDisplayStatusLabel(input: {
providerKey: string | null | undefined;
objectType: string | null | undefined;
statusCategory: string;
liveness: string;
statusLabel?: string | null;
}): string {
const trimmedStatusLabel = input.statusLabel?.trim();
if (trimmedStatusLabel) return trimmedStatusLabel;
const isGenericUrl = input.providerKey === "url" && input.objectType === "link";
const hasKnownObjectType = Boolean(input.providerKey && input.objectType);
if (input.statusCategory === "unknown" && hasKnownObjectType && !isGenericUrl) {
if (input.liveness === "fresh") return "Status unavailable";
return externalObjectLivenessLabel(input.liveness);
}
return externalObjectCategoryLabel(input.statusCategory);
}
/**
* Higher number = more attention-worthy. The rollups in §5 sort by tone first.
* Mirrors `externalObjectStatusToneSeverity` in `status-colors.ts`.
*/
const TONE_SEVERITY: Record<string, number> = {
muted: 0,
neutral: 1,
success: 2,
info: 3,
warning: 4,
danger: 5,
};
export function externalObjectToneSeverity(tone: string | null | undefined): number {
if (!tone) return 0;
return TONE_SEVERITY[tone] ?? 0;
}
const CATEGORY_TONE_FALLBACK: Record<string, ExternalObjectStatusTone> = {
unknown: "muted",
open: "info",
waiting: "warning",
running: "info",
succeeded: "success",
failed: "danger",
blocked: "danger",
closed: "muted",
archived: "muted",
auth_required: "warning",
unreachable: "danger",
};
export function externalObjectFallbackTone(
category: ExternalObjectStatusCategory,
): ExternalObjectStatusTone {
return CATEGORY_TONE_FALLBACK[category] ?? "neutral";
}
const PROVIDER_LABELS: Record<string, string> = {
github: "GitHub",
github_pull_request: "GitHub",
github_issue: "GitHub",
hubspot: "HubSpot",
linear: "Linear",
jira: "Jira",
notion: "Notion",
asana: "Asana",
};
export function externalObjectProviderLabel(providerKey: string | null | undefined): string {
if (!providerKey) return "External";
const lookup = PROVIDER_LABELS[providerKey];
if (lookup) return lookup;
return providerKey
.split(/[._-]/)
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
.join(" ");
}
const OBJECT_TYPE_LABELS: Record<string, string> = {
pull_request: "pull request",
issue: "issue",
deployment: "deployment",
workflow_run: "workflow run",
ticket: "ticket",
lead: "lead",
url_link: "URL",
};
export function externalObjectTypeLabel(objectType: string | null | undefined): string {
if (!objectType) return "object";
return OBJECT_TYPE_LABELS[objectType] ?? objectType.replace(/_/g, " ");
}
export function externalObjectDisplayLabel(
providerKey: string | null | undefined,
objectType: string | null | undefined,
displayKey?: string | null,
): string {
const trimmedDisplayKey = displayKey?.trim();
if (trimmedDisplayKey) return trimmedDisplayKey;
if (providerKey === "url" && objectType === "link") return "URL";
return `${externalObjectProviderLabel(providerKey)} ${externalObjectTypeLabel(objectType)}`;
}
/**
* Sort summary items by severity-first ordering: danger → warning → info →
* success → muted/neutral. Within a tone, items keep their incoming order so
* server-side ordering (e.g. most recent change first) is preserved.
*/
export function sortExternalObjectsBySeverity<T extends ExternalObjectSummaryItem>(
items: readonly T[],
): T[] {
return [...items]
.map((item, index) => ({ item, index }))
.sort((a, b) => {
const aTone = externalObjectToneSeverity(a.item.statusTone);
const bTone = externalObjectToneSeverity(b.item.statusTone);
if (aTone !== bTone) return bTone - aTone;
return a.index - b.index;
})
.map(({ item }) => item);
}
/**
* Compute the dominant tone in a summary — used by sidebar / list rollups.
* Falls back to `null` when no objects are present or every tone is `muted`.
*/
export function dominantExternalObjectTone(
summary: Pick<ExternalObjectSummary, "highestSeverity" | "objects"> | null | undefined,
): ExternalObjectStatusTone | null {
if (!summary) return null;
const tone = summary.highestSeverity;
if (!tone) return null;
if (externalObjectToneSeverity(tone) <= TONE_SEVERITY.muted) return null;
return tone;
}
/**
* For the sidebar / list rollup we want the count of objects matching the
* dominant severity (e.g. "3 failed PRs"), not the global total. Returns 0
* whenever the dominant tone is muted so callers can render based on the
* count without double-checking the rollup-hide rule.
*/
export function externalObjectDominantCount(
summary: Pick<ExternalObjectSummary, "highestSeverity" | "objects"> | null | undefined,
): number {
if (!summary) return 0;
const tone = dominantExternalObjectTone(summary);
if (!tone) return 0;
return summary.objects.filter((object) => object.statusTone === tone).length;
}
/**
* Reduced motion support — match `prefers-reduced-motion: reduce` so the
* spinning Loader2 stays static when requested. Hooks consume this via React
* to react to runtime changes; non-hook callers can use the helper directly.
*/
export function prefersReducedMotion(): boolean {
if (typeof window === "undefined" || !window.matchMedia) return false;
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
}