History

fix(web): label compact agents action

t3-code[bot] committed 3 months ago

Commit 6bd7bdb1 parent 4cd17fd2 files · +23 −5Browse files

Unified · Split

2 files
  1. apps/web/src/components/chat/AgentSpawnCtaRow.test.ts +10 −1
  2. apps/web/src/components/chat/MessagesTimeline.tsx +13 −4
apps/web/src/components/chat/AgentSpawnCtaRow.test.ts+10−1
@@ -1,6 +1,10 @@
11 import { describe, expect, it } from "vite-plus/test";
22
3−import { AGENT_SPAWN_CTA_CLASS_NAME, AGENT_SPAWN_CTA_TRIGGER_CLASS_NAME } from "./MessagesTimeline";
3+import {
4+ AGENT_SPAWN_CTA_CLASS_NAME,
5+ AGENT_SPAWN_CTA_TRIGGER_CLASS_NAME,
6+ resolveAgentSpawnActionLabel,
7+} from "./MessagesTimeline";
48
59 describe("AgentSpawnCtaRow", () => {
610 it("uses the changed-files card shell", () => {
@@ -15,4 +19,9 @@ describe("AgentSpawnCtaRow", () => { · 8 unmodified lines
1519 expect(AGENT_SPAWN_CTA_TRIGGER_CLASS_NAME).toContain("flex-1");
1620 expect(AGENT_SPAWN_CTA_TRIGGER_CLASS_NAME).toContain("rounded-lg");
1721 });
22+
23+ it("names the agents action when its visible label is hidden", () => {
24+ expect(resolveAgentSpawnActionLabel(true)).toBe("Open agents");
25+ expect(resolveAgentSpawnActionLabel(false)).toBe("View agents");
26+ });
1827 });
apps/web/src/components/chat/MessagesTimeline.tsx+13−4
@@ -2130,6 +2130,9 @@ export const AGENT_SPAWN_CTA_CLASS_NAME = · 2129 unmodified lines
21302130 export const AGENT_SPAWN_CTA_TRIGGER_CLASS_NAME =
21312131 "group flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden rounded-lg px-1 py-1.5 text-left transition-colors hover:bg-accent/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";
21322132
2133+export const resolveAgentSpawnActionLabel = (live: boolean) =>
2134+ live ? "Open agents" : "View agents";
2135+
21332136 const AgentSpawnCtaRow = memo(function AgentSpawnCtaRow(props: { workEntry: TimelineWorkEntry }) {
21342137 const { workEntry } = props;
21352138 const { agentPanelModel, onOpenAgents } = use(TimelineRowCtx);
@@ -2194,6 +2197,8 @@ const AgentSpawnCtaRow = memo(function AgentSpawnCtaRow(props: { workEntry: Time · 58 unmodified lines
21942197 ? `${failed} failed`
21952198 : "✓ completed";
21962199
2200+ const actionLabel = resolveAgentSpawnActionLabel(live);
2201+
21972202 return (
21982203 <div className={AGENT_SPAWN_CTA_CLASS_NAME}>
21992204 <div className="flex items-center justify-between gap-2 rounded-xl px-1">
@@ -2217,11 +2222,15 @@ const AgentSpawnCtaRow = memo(function AgentSpawnCtaRow(props: { workEntry: Time · 17 unmodified lines
22172222 {totalTokens > 0 ? ` · Σ ${formatSubagentTokenCount(totalTokens)}` : ""}
22182223 </span>
22192224 </button>
2220− <Button type="button" size="xs" variant="outline" onClick={onOpenAgents}>
2225+ <Button
2226+ type="button"
2227+ size="xs"
2228+ variant="outline"
2229+ aria-label={actionLabel}
2230+ onClick={onOpenAgents}
2231+ >
22212232 <BotIcon className="size-3" />
2222− <span className="hidden @[24rem]/agent-spawn:inline">
2223− {live ? "Open agents" : "View agents"}
2224− </span>
2233+ <span className="hidden @[24rem]/agent-spawn:inline">{actionLabel}</span>
22252234 </Button>
22262235 </div>
22272236 </div>