Skip to content

Commit fc05872

Browse files
committed
refactor(chat): simplify handoff styling
1 parent 40fe7dc commit fc05872

3 files changed

Lines changed: 2 additions & 67 deletions

File tree

‎apps/web/src/components/chat/MessagesTimeline.test.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,6 @@ describe("MessagesTimeline", () => {
890890
expect(markup).toContain("Claude Fable 5");
891891
expect(markup).not.toContain("Full conversation context");
892892
expect(markup).not.toContain("·");
893-
expect(markup).toContain("--provider-icon-average-color-light:#d97757");
894893

895894
// Items persisted before models were stamped recover them from the
896895
// projection runs: the handoff's run is the target, the newest earlier

‎apps/web/src/components/chat/V2LifecycleRow.tsx‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ import {
2222

2323
import { getProviderInstanceEntry } from "../../providerInstances";
2424
import { formatShortTimestamp } from "../../timestampFormat";
25-
import {
26-
PROVIDER_ICON_BY_PROVIDER,
27-
getProviderIconAverageColorStyle,
28-
getTriggerDisplayModelName,
29-
} from "./providerIconUtils";
25+
import { PROVIDER_ICON_BY_PROVIDER, getTriggerDisplayModelName } from "./providerIconUtils";
3026
import { TimelineSystemDivider } from "./TimelineSystemDivider";
3127

3228
const LIFECYCLE_TYPES = new Set<OrchestrationV2TurnItem["type"]>([
@@ -342,8 +338,6 @@ function HandoffEndpoint(props: {
342338
}) {
343339
const entry = getProviderInstanceEntry(props.providers, props.instanceId);
344340
const Icon = entry === undefined ? null : (PROVIDER_ICON_BY_PROVIDER[entry.driverKind] ?? null);
345-
const colorStyle =
346-
entry === undefined ? undefined : getProviderIconAverageColorStyle(entry.driverKind);
347341
const model = props.model?.trim();
348342
const providerModel =
349343
model === undefined || model.length === 0
@@ -358,12 +352,7 @@ function HandoffEndpoint(props: {
358352
return (
359353
<span className="inline-flex min-w-0 items-center gap-1">
360354
{Icon === null ? null : <Icon aria-hidden="true" className="size-3 shrink-0" />}
361-
<span
362-
className="max-w-40 truncate text-[var(--provider-icon-average-color-light)] dark:text-[var(--provider-icon-average-color-dark)]"
363-
style={colorStyle}
364-
>
365-
{label}
366-
</span>
355+
<span className="max-w-40 truncate">{label}</span>
367356
</span>
368357
);
369358
}

‎apps/web/src/components/chat/providerIconUtils.ts‎

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { ProviderDriverKind } from "@t3tools/contracts";
2-
import type { CSSProperties } from "react";
32
import { ClaudeAI, CursorIcon, GrokIcon, Icon, OpenAI, OpenCodeIcon } from "../Icons";
43
import { PROVIDER_OPTIONS } from "../../session-logic";
54

@@ -11,58 +10,6 @@ export const PROVIDER_ICON_BY_PROVIDER: Partial<Record<ProviderDriverKind, Icon>
1110
[ProviderDriverKind.make("grok")]: GrokIcon,
1211
};
1312

14-
type ProviderIconAverageColor = {
15-
readonly light: string;
16-
readonly dark: string;
17-
};
18-
19-
function averageHexColors(colors: ReadonlyArray<string>): string {
20-
const channels = colors.reduce<[number, number, number]>(
21-
(sum, color) => {
22-
const value = color.slice(1);
23-
return [
24-
sum[0] + Number.parseInt(value.slice(0, 2), 16),
25-
sum[1] + Number.parseInt(value.slice(2, 4), 16),
26-
sum[2] + Number.parseInt(value.slice(4, 6), 16),
27-
];
28-
},
29-
[0, 0, 0],
30-
);
31-
return `#${channels
32-
.map((channel) =>
33-
Math.round(channel / colors.length)
34-
.toString(16)
35-
.padStart(2, "0"),
36-
)
37-
.join("")}`;
38-
}
39-
40-
/** Average of the fill colors used by each provider SVG in Icons.tsx. */
41-
const PROVIDER_ICON_AVERAGE_COLOR_BY_PROVIDER: Partial<
42-
Record<ProviderDriverKind, ProviderIconAverageColor>
43-
> = {
44-
[ProviderDriverKind.make("codex")]: { light: "#000000", dark: "#ffffff" },
45-
[ProviderDriverKind.make("claudeAgent")]: { light: "#d97757", dark: "#d97757" },
46-
[ProviderDriverKind.make("cursor")]: { light: "#26251e", dark: "#edecec" },
47-
[ProviderDriverKind.make("grok")]: { light: "#0f0f0f", dark: "#f5f5f5" },
48-
[ProviderDriverKind.make("opencode")]: {
49-
light: averageHexColors(["#cfcecd", "#211e1e"]),
50-
dark: averageHexColors(["#4b4646", "#f1ecec"]),
51-
},
52-
};
53-
54-
export function getProviderIconAverageColorStyle(
55-
driverKind: ProviderDriverKind,
56-
): CSSProperties | undefined {
57-
const color = PROVIDER_ICON_AVERAGE_COLOR_BY_PROVIDER[driverKind];
58-
return color === undefined
59-
? undefined
60-
: ({
61-
"--provider-icon-average-color-light": color.light,
62-
"--provider-icon-average-color-dark": color.dark,
63-
} as CSSProperties);
64-
}
65-
6613
function isAvailableProviderOption(option: (typeof PROVIDER_OPTIONS)[number]): option is {
6714
value: ProviderDriverKind;
6815
label: string;

0 commit comments

Comments
 (0)