"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(frontend): welcome quick actions keep a real selected state
shadowinlifeaba968dbc0ef
diff --git a/frontend/src/components/chat/WelcomeScreen.tsx b/frontend/src/components/chat/WelcomeScreen.tsxindex e18c4e350..b4dc8f226 100644--- a/frontend/src/components/chat/WelcomeScreen.tsx+++ b/frontend/src/components/chat/WelcomeScreen.tsx@@ -240,6 +240,7 @@ export function WelcomeScreen({ onExample }: Props) {const [greetingKey] = useState(() => pickGreetingKey());const [isExamplesOpen, setIsExamplesOpen] = useState(false);const [activeCategory, setActiveCategory] = useState(0);+ const [activeAction, setActiveAction] = useState<string | null>(null);const examplesTriggerRef = useRef<HTMLButtonElement>(null);return (@@ -262,21 +263,28 @@ export function WelcomeScreen({ onExample }: Props) {role="group"aria-label={t("welcome.quickActions" as any)}>- {QUICK_ACTIONS.map((action, index) => (- <button- key={action.titleKey}- type="button"- onClick={() => onExample(t(action.promptKey as any))}- className={- index === 0- ? "inline-flex items-center gap-2 rounded-full border border-primary/30 bg-primary/[0.08] px-4 py-2 text-sm text-primary transition-colors hover:border-primary/50 hover:bg-primary/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40"- : "inline-flex items-center gap-2 rounded-full border border-border/60 bg-card px-4 py-2 text-sm transition-colors hover:border-primary/40 hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40"- }- >- {action.icon}- <span>{t(action.titleKey as any)}</span>- </button>- ))}+ {QUICK_ACTIONS.map((action) => {+ const isActive = action.titleKey === activeAction;+ return (+ <button+ key={action.titleKey}+ type="button"+ aria-pressed={isActive}+ onClick={() => {+ setActiveAction(action.titleKey);+ onExample(t(action.promptKey as any));+ }}+ className={+ isActive+ ? "inline-flex items-center gap-2 rounded-full border border-primary/30 bg-primary/[0.08] px-4 py-2 text-sm text-primary transition-colors hover:border-primary/50 hover:bg-primary/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40"+ : "inline-flex items-center gap-2 rounded-full border border-border/60 bg-card px-4 py-2 text-sm transition-colors hover:border-primary/40 hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40"+ }+ >+ {action.icon}+ <span>{t(action.titleKey as any)}</span>+ </button>+ );+ })}</div><buttondiff --git a/frontend/src/components/chat/__tests__/WelcomeScreen.test.tsx b/frontend/src/components/chat/__tests__/WelcomeScreen.test.tsxindex 4ee1cf571..2783fd8ff 100644--- a/frontend/src/components/chat/__tests__/WelcomeScreen.test.tsx+++ b/frontend/src/components/chat/__tests__/WelcomeScreen.test.tsx@@ -100,6 +100,36 @@ describe("WelcomeScreen", () => {expect(onExample).toHaveBeenCalledTimes(4);});+ it("marks the clicked quick action as selected and moves the selection", async () => {+ const user = userEvent.setup();+ render(<WelcomeScreen onExample={onExample} />);++ const quickActions = screen.getByRole("group", { name: "Quick actions" });+ const buttons = within(quickActions).getAllByRole("button");+ for (const button of buttons) {+ expect(button).toHaveAttribute("aria-pressed", "false");+ expect(button).not.toHaveClass("text-primary");+ }++ const committee = within(quickActions).getByRole("button", {+ name: "Buy or sell? Let a committee debate",+ });+ await user.click(committee);+ expect(committee).toHaveAttribute("aria-pressed", "true");+ expect(committee).toHaveClass("text-primary");+ expect(onExample).toHaveBeenCalledTimes(1);++ const valuation = within(quickActions).getByRole("button", {+ name: "Check if a stock is expensive",+ });+ await user.click(valuation);+ expect(committee).toHaveAttribute("aria-pressed", "false");+ expect(committee).not.toHaveClass("text-primary");+ expect(valuation).toHaveAttribute("aria-pressed", "true");+ expect(valuation).toHaveClass("text-primary");+ expect(onExample).toHaveBeenCalledTimes(2);+ });+it("reveals eight category tabs and switches example cards from the disclosure", async () => {const user = userEvent.setup();render(<WelcomeScreen onExample={onExample} />);