Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(frontend): tour demo auto-play, sidebar upsell card, and logged-out marketplace shell (#13515)

Ubbe89d0e626d7fd
diff --git a/autogpt_platform/frontend/src/app/(platform)/PlatformChrome/PlatformChrome.tsx b/autogpt_platform/frontend/src/app/(platform)/PlatformChrome/PlatformChrome.tsx
index 0590040481..1b873a111c 100644
--- a/autogpt_platform/frontend/src/app/(platform)/PlatformChrome/PlatformChrome.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/PlatformChrome/PlatformChrome.tsx
@@ -2,6 +2,7 @@
import { CSSProperties, ReactNode } from "react";
+import { TourSidebar } from "@/app/(public)/tour/chat/components/TourSidebar/TourSidebar";
import { AppSidebar } from "@/components/layout/AppSidebar/AppSidebar";
import { Navbar } from "@/components/layout/Navbar/Navbar";
import { TopUpPromptProvider } from "@/components/layout/TopUpPrompt/TopUpPromptProvider";
@@ -23,7 +24,7 @@ interface Props {
}
export function PlatformChrome({ children }: Props) {
- const { showNewLayout } = usePlatformChrome();
+ const { showNewLayout, showTourSidebar } = usePlatformChrome();
const content = (
<TopUpPromptProvider>
@@ -31,6 +32,22 @@ export function PlatformChrome({ children }: Props) {
</TopUpPromptProvider>
);
+ // Logged-out marketplace visitors browse with the tour demo sidebar as an
+ // upsell — clicking a demo session takes them into /tour/chat.
+ if (showTourSidebar) {
+ return (
+ <SidebarProvider style={{ "--sidebar-width": "19rem" } as CSSProperties}>
+ <TourSidebar variant="marketplace" />
+ <SidebarInset className="bg-[#f9f9f9]">
+ <div className="flex shrink-0 items-center px-4 pt-4 md:hidden">
+ <SidebarTrigger />
+ </div>
+ <section className="flex-1">{content}</section>
+ </SidebarInset>
+ </SidebarProvider>
+ );
+ }
+
if (showNewLayout) {
return (
<SidebarProvider style={{ "--sidebar-width": "19rem" } as CSSProperties}>
diff --git a/autogpt_platform/frontend/src/app/(platform)/PlatformChrome/__tests__/PlatformChrome.test.tsx b/autogpt_platform/frontend/src/app/(platform)/PlatformChrome/__tests__/PlatformChrome.test.tsx
index aadb7efd7e..815e72828e 100644
--- a/autogpt_platform/frontend/src/app/(platform)/PlatformChrome/__tests__/PlatformChrome.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/PlatformChrome/__tests__/PlatformChrome.test.tsx
@@ -1,12 +1,39 @@
-import { render, screen, waitFor } from "@/tests/integrations/test-utils";
+import {
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from "@/tests/integrations/test-utils";
import type { ReactNode } from "react";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { useTourStore } from "@/app/(public)/tour/chat/tourStore";
import { PlatformChrome } from "../PlatformChrome";
const showNewLayoutMock = vi.fn<() => boolean>(() => false);
+const showTourSidebarMock = vi.fn<() => boolean>(() => false);
vi.mock("../usePlatformChrome", () => ({
- usePlatformChrome: () => ({ showNewLayout: showNewLayoutMock() }),
+ usePlatformChrome: () => ({
+ showNewLayout: showNewLayoutMock(),
+ showTourSidebar: showTourSidebarMock(),
+ }),
+}));
+
+// Mirrors the global setup-nextjs-mocks shape, but with a stable push spy so
+// the tour sidebar's navigation can be asserted.
+const { pushMock } = vi.hoisted(() => ({ pushMock: vi.fn() }));
+vi.mock("next/navigation", () => ({
+ useRouter: () => ({
+ push: pushMock,
+ replace: vi.fn(),
+ prefetch: vi.fn(),
+ back: vi.fn(),
+ forward: vi.fn(),
+ refresh: vi.fn(),
+ }),
+ usePathname: () => "/marketplace",
+ useSearchParams: () => new URLSearchParams(),
+ useParams: () => ({}),
}));
vi.mock("@/components/layout/AppSidebar/AppSidebar", () => ({
@@ -40,6 +67,7 @@ afterEach(() => {
describe("PlatformChrome", () => {
beforeEach(() => {
showNewLayoutMock.mockReturnValue(false);
+ showTourSidebarMock.mockReturnValue(false);
});
it("renders the classic Navbar shell when the new layout is off", () => {
@@ -69,4 +97,24 @@ describe("PlatformChrome", () => {
expect(screen.queryByTestId("navbar")).toBeNull();
expect(screen.getByTestId("child")).toBeDefined();
});
+
+ it("renders the tour upsell sidebar shell when showTourSidebar is on", async () => {
+ showTourSidebarMock.mockReturnValue(true);
+ render(
+ <PlatformChrome>
+ <div data-testid="child">content</div>
+ </PlatformChrome>,
+ );
+
+ expect(screen.getByText("Try Autopilot")).toBeDefined();
+ expect(screen.getByText(/Ready to build your own/i)).toBeDefined();
+ expect(screen.queryByTestId("navbar")).toBeNull();
+ expect(screen.queryByTestId("app-sidebar")).toBeNull();
+ expect(screen.getByTestId("child")).toBeDefined();
+
+ // Clicking a demo session stores the scenario and navigates to the tour.
+ fireEvent.click(screen.getByRole("button", { name: "Daily brief" }));
+ expect(useTourStore.getState().activeScenarioId).toBe("daily-brief");
+ expect(pushMock).toHaveBeenCalledWith("/tour/chat");
+ });
});
diff --git a/autogpt_platform/frontend/src/app/(platform)/PlatformChrome/__tests__/usePlatformChrome.test.ts b/autogpt_platform/frontend/src/app/(platform)/PlatformChrome/__tests__/usePlatformChrome.test.ts
index 65a8be7934..7ed8b4547f 100644
--- a/autogpt_platform/frontend/src/app/(platform)/PlatformChrome/__tests__/usePlatformChrome.test.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/PlatformChrome/__tests__/usePlatformChrome.test.ts
@@ -8,6 +8,14 @@ vi.mock("next/navigation", () => ({
usePathname: () => pathnameMock(),
}));
+const supabaseMock = vi.fn(() => ({
+ isLoggedIn: true,
+ isUserLoading: false,
+}));
+vi.mock("@/lib/supabase/hooks/useSupabase", () => ({
+ useSupabase: () => supabaseMock(),
+}));
+
const flagMock = vi.fn<(flag: string) => boolean>(() => true);
vi.mock("@/services/feature-flags/use-get-flag", async (importOriginal) => {
const actual =
@@ -24,6 +32,7 @@ describe("usePlatformChrome", () => {
beforeEach(() => {
pathnameMock.mockReturnValue("/marketplace");
flagMock.mockReturnValue(true);
+ supabaseMock.mockReturnValue({ isLoggedIn: true, isUserLoading: false });
});
it("enables the new layout after mount when the flag is on and route is allowed", async () => {
@@ -85,4 +94,42 @@ describe("usePlatformChrome", () => {
expect(flagMock).toHaveBeenCalledWith("autogpt-new-layout");
});
});
+
+ it("shows the tour sidebar for logged-out marketplace visitors", async () => {
+ supabaseMock.mockReturnValue({ isLoggedIn: false, isUserLoading: false });
+ const { result } = renderHook(() => usePlatformChrome());
+
+ await waitFor(() => {
+ expect(result.current.showTourSidebar).toBe(true);
+ });
+ expect(result.current.showNewLayout).toBe(false);
+ });
+
+ it("keeps the tour sidebar hidden while the session check is in flight", async () => {
+ supabaseMock.mockReturnValue({ isLoggedIn: false, isUserLoading: true });
+ const { result } = renderHook(() => usePlatformChrome());
+
+ await waitFor(() => {
+ expect(result.current.showTourSidebar).toBe(false);
+ });
+ });
+
+ it("keeps the tour sidebar hidden for logged-in marketplace visitors", async () => {
+ const { result } = renderHook(() => usePlatformChrome());
+
+ await waitFor(() => {
+ expect(result.current.showTourSidebar).toBe(false);
+ expect(result.current.showNewLayout).toBe(true);
+ });
+ });
+
+ it("keeps the tour sidebar off non-marketplace routes when logged out", async () => {
+ supabaseMock.mockReturnValue({ isLoggedIn: false, isUserLoading: false });
+ pathnameMock.mockReturnValue("/library");
+ const { result } = renderHook(() => usePlatformChrome());
+
+ await waitFor(() => {
+ expect(result.current.showTourSidebar).toBe(false);
+ });
+ });
});
diff --git a/autogpt_platform/frontend/src/app/(platform)/PlatformChrome/usePlatformChrome.ts b/autogpt_platform/frontend/src/app/(platform)/PlatformChrome/usePlatformChrome.ts
index c78bfd677e..c544025b7c 100644
--- a/autogpt_platform/frontend/src/app/(platform)/PlatformChrome/usePlatformChrome.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/PlatformChrome/usePlatformChrome.ts
@@ -1,6 +1,7 @@
import { usePathname } from "next/navigation";
import { useEffect, useState } from "react";
+import { useSupabase } from "@/lib/supabase/hooks/useSupabase";
import { Flag, useGetFlag } from "@/services/feature-flags/use-get-flag";
// Routes that must stay outside the new top-level sidebar layout. Login,
@@ -18,6 +19,9 @@ const NEW_LAYOUT_EXCLUDED_PREFIXES = [
export function usePlatformChrome() {
const pathname = usePathname();
const isNewLayoutEnabled = useGetFlag(Flag.AUTOGPT_NEW_LAYOUT);
+ // Also initializes the auth store — required here because the tour shell
+ // replaces the Navbar, which is what normally kicks off the session check.
+ const { isLoggedIn, isUserLoading } = useSupabase();
// The LaunchDarkly flag is client-side data that can resolve differently on
// the server vs the client's first render. Switching the whole layout shell
@@ -32,7 +36,18 @@ export function usePlatformChrome() {
return pathname === prefix || pathname.startsWith(`${prefix}/`);
});
+ const isMarketplaceRoute =
+ pathname === "/marketplace" ||
+ Boolean(pathname?.startsWith("/marketplace/"));
+
+ // Logged-out marketplace visitors get the tour demo sidebar as an upsell.
+ // Waits for the session check so it never flashes at logged-in users.
+ const showTourSidebar =
+ isMounted && isMarketplaceRoute && !isUserLoading && !isLoggedIn;
+
return {
- showNewLayout: isMounted && isNewLayoutEnabled && !isExcludedRoute,
+ showNewLayout:
+ isMounted && isNewLayoutEnabled && !isExcludedRoute && !showTourSidebar,
+ showTourSidebar,
};
}
diff --git a/autogpt_platform/frontend/src/app/(public)/tour/chat/TourChatHost.tsx b/autogpt_platform/frontend/src/app/(public)/tour/chat/TourChatHost.tsx
index 3d698a580e..852f338e15 100644
--- a/autogpt_platform/frontend/src/app/(public)/tour/chat/TourChatHost.tsx
+++ b/autogpt_platform/frontend/src/app/(public)/tour/chat/TourChatHost.tsx
@@ -8,20 +8,20 @@ interface Props {
sessionId: string;
script: TourScript;
onComplete?: () => void;
- onReset?: () => void;
+ completionNotice?: string;
}
export function TourChatHost({
sessionId,
script,
onComplete,
- onReset,
+ completionNotice,
}: Props) {
const chat = useTourCopilot({
sessionId,
script,
onComplete: onComplete ?? (() => {}),
- onReset,
+ completionNotice,
});
return <TourChatContainer chat={chat} />;
diff --git a/autogpt_platform/frontend/src/app/(public)/tour/chat/TourCopilot.tsx b/autogpt_platform/frontend/src/app/(public)/tour/chat/TourCopilot.tsx
index 40042e87d3..ec638dce20 100644
--- a/autogpt_platform/frontend/src/app/(public)/tour/chat/TourCopilot.tsx
+++ b/autogpt_platform/frontend/src/app/(public)/tour/chat/TourCopilot.tsx
@@ -5,6 +5,7 @@ import { useIsMobile } from "@/app/(platform)/copilot/useIsMobile";
import { DotDistortionShader } from "@/components/ui/dot-distortion-shader";
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
import { useMountEffect } from "@/hooks/useMountEffect";
+import { cn } from "@/lib/utils";
import dynamic from "next/dynamic";
import { CSSProperties } from "react";
import { TourChatHost } from "./TourChatHost";
@@ -35,11 +36,13 @@ function TourBackdrop() {
export function TourCopilot() {
const activeScenarioId = useTourStore((s) => s.activeScenarioId);
+ const runId = useTourStore((s) => s.runId);
+ const setDemoComplete = useTourStore((s) => s.setDemoComplete);
const scenario = getTourScenario(activeScenarioId);
const isMobile = useIsMobile();
const openArtifact = useCopilotUIStore((s) => s.openArtifact);
- const clearArtifactPreview = useCopilotUIStore((s) => s.clearArtifactPreview);
const closeArtifactPanel = useCopilotUIStore((s) => s.closeArtifactPanel);
+ const isArtifactOpen = useCopilotUIStore((s) => s.artifactPanel.isOpen);
// The tour shares the copilot UI store but must never leak panel state
// into the real /copilot: opens skip the localStorage write
@@ -49,18 +52,26 @@ export function TourCopilot() {
});
const chatColumn = (
- <div className="relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
+ // The chat fades back once the artifact panel opens so the visitor's
+ // attention lands on the payoff.
+ <div
+ className={cn(
+ "relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden transition-opacity duration-700",
+ isArtifactOpen && "opacity-50",
+ )}
+ >
<TourBackdrop />
<div className="relative z-10 flex min-h-0 flex-1 flex-col">
<div className="h-4 shrink-0" />
<TourChatHost
- key={scenario.id}
+ key={`${scenario.id}-${runId}`}
sessionId={scenario.id}
script={scenario.script}
- onComplete={() =>
- openArtifact(buildTourArtifactRef(scenario), { persist: false })
- }
- onReset={clearArtifactPreview}
+ completionNotice={`Your **"${scenario.completionArtifact.filename}"** will appear in a moment on the right side.`}
+ onComplete={() => {
+ setDemoComplete();
+ openArtifact(buildTourArtifactRef(scenario), { persist: false });
+ }}
/>
</div>
</div>
diff --git a/autogpt_platform/frontend/src/app/(public)/tour/chat/__tests__/app-shell.test.tsx b/autogpt_platform/frontend/src/app/(public)/tour/chat/__tests__/app-shell.test.tsx
index 9d96f39ffb..1b373a8403 100644
--- a/autogpt_platform/frontend/src/app/(public)/tour/chat/__tests__/app-shell.test.tsx
+++ b/autogpt_platform/frontend/src/app/(public)/tour/chat/__tests__/app-shell.test.tsx
@@ -41,13 +41,11 @@ function getSendBar() {
const ADVANCE_STEP_MS = 200;
// Longest turn is ~7.7s of parts — including the 5s fake run — plus the 3s
// hold before the demo completes.
-const ADVANCE_TOTAL_MS = 13000;
+const ADVANCE_TOTAL_MS = 16000;
-// The prompt bar is prefilled and locked — the visitor only presses Enter to
-// send. Timers advance in small chunks so effects that register new timers
+// Timers advance in small chunks so effects that register new timers
// mid-stream get picked up (see main.test.tsx for the full rationale).
-async function pressEnterToSend() {
- fireEvent.keyDown(getSendBar(), { key: "Enter" });
+async function advanceThroughTurn() {
for (
let elapsed = 0;
elapsed < ADVANCE_TOTAL_MS;
@@ -59,11 +57,20 @@ async function pressEnterToSend() {
}
}
+// Later turns prefill the prompt bar — the visitor presses Enter to send.
+async function pressEnterToSend() {
+ fireEvent.keyDown(getSendBar(), { key: "Enter" });
+ await advanceThroughTurn();
+}
+
describe("Tour chat app shell", () => {
beforeEach(() => {
vi.useFakeTimers();
// Both stores are module-level state — reset between tests.
- useTourStore.setState({ activeScenarioId: DEFAULT_SCENARIO_ID });
+ useTourStore.setState({
+ activeScenarioId: DEFAULT_SCENARIO_ID,
+ isDemoComplete: false,
+ });
useCopilotUIStore.getState().clearArtifactPreview();
});
@@ -87,6 +94,10 @@ describe("Tour chat app shell", () => {
expect(screen.getByRole("button", { name: label })).toBeDefined();
}
+ // The upsell card is always visible in the sidebar footer.
+ expect(screen.getByText(/Ready to build your own/i)).toBeDefined();
+ expect(screen.getByText(/Start with Pro for \$42\.50\/mo/i)).toBeDefined();
+
// Marketplace is the only live navigation target.
const marketplace = screen.getByRole("link", { name: "Marketplace" });
expect(marketplace.getAttribute("href")).toBe("/marketplace");
@@ -100,9 +111,9 @@ describe("Tour chat app shell", () => {
render(<TourChatPage />);
fireEvent.click(screen.getByRole("button", { name: "Daily brief" }));
- await act(async () => {
- await vi.advanceTimersByTimeAsync(0);
- });
+ // The switched-to scenario auto-plays its first turn — its prompt shows up
+ // as the auto-sent user message.
+ await advanceThroughTurn();
expect(
screen.getByText(/pull my unread emails and calendar/i),
@@ -135,7 +146,19 @@ describe("Tour chat app shell", () => {
});
vi.useFakeTimers();
- await pressEnterToSend();
+ // The demo mounted under real timers, so its auto-start timeout is a real
+ // timer that fake-timer advancing can't reach (and it may have already
+ // fired during the findByText wait). Toggling the scenario remounts
+ // TourChatHost under fake timers, giving a deterministic fresh demo.
+ act(() => {
+ useTourStore.setState({ activeScenarioId: "daily-brief" });
+ });
+ act(() => {
+ useTourStore.setState({ activeScenarioId: DEFAULT_SCENARIO_ID });
+ });
+
+ // First turn auto-plays; the second is sent from the prefilled bar.
+ await advanceThroughTurn();
await pressEnterToSend();
expect(useCopilotUIStore.getState().artifactPanel.activeArtifact?.id).toBe(
diff --git a/autogpt_platform/frontend/src/app/(public)/tour/chat/__tests__/main.test.tsx b/autogpt_platform/frontend/src/app/(public)/tour/chat/__tests__/main.test.tsx
index 2e12199969..c096f6df17 100644
--- a/autogpt_platform/frontend/src/app/(public)/tour/chat/__tests__/main.test.tsx
+++ b/autogpt_platform/frontend/src/app/(public)/tour/chat/__tests__/main.test.tsx
@@ -24,17 +24,15 @@ function getSendBar() {
const ADVANCE_STEP_MS = 200;
// Longest turn is ~7.7s of parts — including the 5s fake run — plus the 3s
// hold before the final turn flips to the upsell.
-const ADVANCE_TOTAL_MS = 13000;
-
-// The prompt bar is prefilled and locked — the visitor only presses Enter to send.
-async function pressEnterToSend() {
- fireEvent.keyDown(getSendBar(), { key: "Enter" });
- // TourStreamingText mounts mid-stream (from a setTimeout callback) and
- // registers its own setInterval — a timer created by an effect that fires
- // *during* an in-flight advanceTimersByTimeAsync call is never picked up
- // by that same call. Advancing in small chunks, each in its own act(),
- // gives React a chance to flush the mount effect and register the new
- // interval before the next chunk advances past it.
+const ADVANCE_TOTAL_MS = 16000;
+
+// TourStreamingText mounts mid-stream (from a setTimeout callback) and
+// registers its own setInterval — a timer created by an effect that fires
+// *during* an in-flight advanceTimersByTimeAsync call is never picked up
+// by that same call. Advancing in small chunks, each in its own act(),
+// gives React a chance to flush the mount effect and register the new
+// interval before the next chunk advances past it.
+async function advanceThroughTurn() {
for (
let elapsed = 0;
elapsed < ADVANCE_TOTAL_MS;
@@ -46,11 +44,21 @@ async function pressEnterToSend() {
}
}
+// The prompt bar is prefilled and locked — pressing Enter sends it immediately
+// instead of waiting for the auto-start.
+async function pressEnterToSend() {
+ fireEvent.keyDown(getSendBar(), { key: "Enter" });
+ await advanceThroughTurn();
+}
+
describe("Tour chat scripted demo", () => {
beforeEach(() => {
vi.useFakeTimers();
// The scenario store is module-level state — reset between tests.
- useTourStore.setState({ activeScenarioId: DEFAULT_SCENARIO_ID });
+ useTourStore.setState({
+ activeScenarioId: DEFAULT_SCENARIO_ID,
+ isDemoComplete: false,
+ });
});
afterEach(() => {
@@ -58,17 +66,55 @@ describe("Tour chat scripted demo", () => {
vi.useRealTimers();
});
- test("plays the competitor watch demo through to the payoff and upsell", async () => {
+ test("auto-types the first prompt into the bar and sends it on its own", async () => {
render(<TourChatPage />);
- // 1. The prompt bar is prefilled with the flagship scenario's prompt.
+ // The bar starts empty.
+ expect(screen.queryByText(/email me when the price changes/i)).toBeNull();
+ expect(screen.queryByRole("button", { name: /^Send:/i })).toBeNull();
+
+ // After a beat the first prompt starts typing itself into the bar.
+ await act(async () => {
+ await vi.advanceTimersByTimeAsync(1200);
+ });
+ expect(getSendBar()).toBeDefined();
+
+ // Once typed it sends itself and the scripted turn streams in.
+ await advanceThroughTurn();
+
+ // The auto-sent user message is now in the transcript. getByText throws on
+ // multiple matches, so this also guards against the turn double-firing.
+ expect(screen.getByText(/email me when the price changes/i)).toBeDefined();
+ expect(screen.getByText(/break that down/i)).toBeDefined();
+
+ // Only now does the second turn's prompt prefill, ready to send.
+ expect(screen.getByText(/build and run it for me/i)).toBeDefined();
expect(getSendBar()).toBeDefined();
- expect(
- screen.getByText(/Watch a competitor's pricing page/i),
- ).toBeDefined();
+ });
- // 2. Pressing Enter streams in the scripted plan turn.
- await pressEnterToSend();
+ test("clicking the active sidebar session restarts the demo with an empty bar", async () => {
+ render(<TourChatPage />);
+
+ // Let the first turn auto-play so the second turn's prompt prefills.
+ await advanceThroughTurn();
+ expect(getSendBar()).toBeDefined();
+
+ fireEvent.click(screen.getByRole("button", { name: "Competitor watch" }));
+ await act(async () => {
+ await vi.advanceTimersByTimeAsync(0);
+ });
+
+ // Fresh run: transcript cleared and the bar empty/disabled again while
+ // the first turn re-plays on its own.
+ expect(screen.queryByRole("button", { name: /^Send:/i })).toBeNull();
+ expect(screen.queryByText(/break that down/i)).toBeNull();
+ });
+
+ test("plays the competitor watch demo through to the payoff and upsell", async () => {
+ render(<TourChatPage />);
+
+ // 1. The first turn auto-plays and streams in the scripted plan turn.
+ await advanceThroughTurn();
expect(screen.getByText(/break that down/i)).toBeDefined();
expect(
@@ -78,7 +124,7 @@ describe("Tour chat scripted demo", () => {
// The prompt bar now prefills the second turn's prompt.
expect(screen.getByText(/build and run it for me/i)).toBeDefined();
- // 3. Pressing Enter again builds the agent and shows the payoff artifact.
+ // 2. Pressing Enter builds the agent and shows the payoff artifact.
await pressEnterToSend();
// Agent card: block chain chips + schedule row, no raw JSON.
@@ -95,10 +141,21 @@ describe("Tour chat scripted demo", () => {
expect(screen.getByText("$59/mo")).toBeDefined();
expect(screen.getByText("+20.4%")).toBeDefined();
- // Upsell: Pro-first CTA with self-host secondary.
+ // The closing line points the visitor at the artifact panel, with the
+ // filename bolded (its own <strong> node, hence the split assertions).
+ expect(screen.getByText('"competitor-pricing-report.md"')).toBeDefined();
+ expect(
+ screen.getByText(/will appear in a moment on the right side/i),
+ ).toBeDefined();
+
+ // The sidebar upsell card stays visible; no bottom banner takes over.
expect(screen.getByText(/Ready to build your own/i)).toBeDefined();
- expect(screen.getByText(/Start with Pro — \$42\.50\/mo/i)).toBeDefined();
+ expect(screen.getByText(/Start with Pro for \$42\.50\/mo/i)).toBeDefined();
expect(screen.getByText(/Self-host free/i)).toBeDefined();
+ expect(screen.queryByText(/Replay demo/i)).toBeNull();
+
+ // Completion flips the store flag that turns on the card's animations.
+ expect(useTourStore.getState().isDemoComplete).toBe(true);
});
test("scenario chips switch the demo path", async () => {
@@ -118,9 +175,19 @@ describe("Tour chat scripted demo", () => {
await vi.advanceTimersByTimeAsync(0);
});
- // The prompt bar now prefills the selected scenario's opening prompt.
+ // The bar stays empty while the selected scenario's first turn auto-plays.
+ expect(
+ screen.queryByText(/pull my unread emails and calendar/i),
+ ).toBeNull();
+
+ // The newly selected scenario auto-plays its first turn too.
+ await advanceThroughTurn();
+
expect(
screen.getByText(/pull my unread emails and calendar/i),
).toBeDefined();
+ expect(
+ screen.getByText(/Love it\. Here's how I'll set that up/i),
+ ).toBeDefined();
});
});
diff --git a/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourAgentCard/TourAgentCard.tsx b/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourAgentCard/TourAgentCard.tsx
index dad4d62469..0a5b1eaff5 100644
--- a/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourAgentCard/TourAgentCard.tsx
+++ b/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourAgentCard/TourAgentCard.tsx
@@ -1,4 +1,5 @@
import { Text } from "@/components/atoms/Text/Text";
+import { cn } from "@/lib/utils";
import {
ArrowRightIcon,
CheckCircleIcon,
@@ -20,7 +21,13 @@ export function TourAgentCard({ agent, runCompleted }: Props) {
<Text variant="large-medium" className="text-zinc-900">
{agent.name}
</Text>
- <span className="flex shrink-0 items-center gap-2 rounded-full bg-emerald-100 px-3 py-1.5 text-sm font-semibold text-emerald-700">
+ <span
+ className={cn(
+ "relative isolate flex shrink-0 items-center gap-2 rounded-full bg-emerald-100 px-3 py-1.5 text-sm font-semibold text-emerald-700",
+ !runCompleted &&
+ "shadow-[0_0_14px_-2px_rgba(16,185,129,0.65),0_0_28px_-4px_rgba(16,185,129,0.5)] ring-1 ring-emerald-300/70",
+ )}
+ >
{runCompleted ? (
<>
<CheckCircleIcon className="size-4 shrink-0" weight="fill" />
@@ -28,6 +35,11 @@ export function TourAgentCard({ agent, runCompleted }: Props) {
</>
) : (
<>
+ {/* Breathing halo behind the badge while the run is live. */}
+ <span
+ aria-hidden="true"
+ className="absolute -inset-1.5 -z-10 animate-pulse rounded-full bg-emerald-400/50 blur-md"
+ />
<span className="relative flex size-2 shrink-0">
<span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-500 opacity-75" />
<span className="relative inline-flex size-2 rounded-full bg-emerald-500" />
diff --git a/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourChatContainer/TourChatContainer.tsx b/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourChatContainer/TourChatContainer.tsx
index e89dd91a35..1835948b07 100644
--- a/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourChatContainer/TourChatContainer.tsx
+++ b/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourChatContainer/TourChatContainer.tsx
@@ -1,6 +1,5 @@
"use client";
-import { cn } from "@/lib/utils";
import { LightningIcon } from "@phosphor-icons/react";
import type { useTourCopilot } from "../../useTourCopilot";
import { TourMessageList } from "../TourMessageList/TourMessageList";
@@ -22,23 +21,14 @@ export function TourChatContainer({ chat }: Props) {
messages={chat.messages}
isStreaming={chat.isStreaming}
/>
- <div
- className={cn(
- "relative px-3 pb-2 pt-2",
- // The upsell renders as a fixed bottom banner once the demo is
- // exhausted — pad so the hint line isn't hidden underneath it.
- chat.isExhausted && "pb-24",
- )}
- >
+ <div className="relative px-3 pb-2 pt-2">
<TourPromptBar
- key={chat.turnIndex}
+ key={`${chat.turnIndex}:${chat.currentUserPrompt ?? ""}`}
prompt={chat.currentUserPrompt}
isStreaming={chat.isStreaming}
- isExhausted={chat.isExhausted}
onSend={() =>
chat.currentUserPrompt && chat.onSend(chat.currentUserPrompt)
}
- onReplay={chat.reset}
/>
<p className="mt-2 flex items-center justify-center gap-1 text-sm text-zinc-400">
<LightningIcon className="size-3.5 shrink-0" weight="fill" />
diff --git a/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourMessageList/TourStreamingText.tsx b/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourMessageList/TourStreamingText.tsx
index ccde1ac33e..4180e465fe 100644
--- a/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourMessageList/TourStreamingText.tsx
+++ b/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourMessageList/TourStreamingText.tsx
@@ -1,36 +1,43 @@
"use client";
-import { useMountEffect } from "@/hooks/useMountEffect";
-import { useRef, useState } from "react";
+import { Fragment } from "react";
+import { useTextReveal } from "../../useTextReveal";
-const CHARS_PER_TICK = 2;
-const TICK_MS = 16;
+interface Segment {
+ text: string;
+ bold: boolean;
+}
+
+/** Minimal inline markup: "**chunk**" renders as bold while it reveals. */
+function parseBoldSegments(text: string): Segment[] {
+ return text
+ .split("**")
+ .map((chunk, index) => ({ text: chunk, bold: index % 2 === 1 }))
+ .filter((segment) => segment.text.length > 0);
+}
-/** Reveals the scripted text character by character, like a live LLM stream.
- * The revealed text stays a single text node so test matchers and copy/paste
- * see the full sentence once the reveal completes. */
+/** Reveals the scripted text character by character, like a live LLM stream. */
export function TourStreamingText({ text }: { text: string }) {
- // Code points, not UTF-16 units — slicing mid-surrogate would briefly
- // render a broken glyph for emoji like 🎉.
- const chars = useRef(Array.from(text));
- const [visibleCount, setVisibleCount] = useState(0);
+ const segments = parseBoldSegments(text);
+ const plainText = segments.map((segment) => segment.text).join("");
+ const { visibleText, isDone } = useTextReveal(plainText);
- useMountEffect(() => {
- const id = setInterval(() => {
- setVisibleCount((count) => {
- const next = Math.min(count + CHARS_PER_TICK, chars.current.length);
- if (next >= chars.current.length) clearInterval(id);
- return next;
- });
- }, TICK_MS);
- return () => clearInterval(id);
+ let remaining = Array.from(visibleText).length;
+ const revealed = segments.map((segment, index) => {
+ const chars = Array.from(segment.text);
+ const visible = chars.slice(0, Math.max(0, remaining)).join("");
+ remaining -= chars.length;
+ if (!visible) return null;
+ return segment.bold ? (
+ <strong key={index}>{visible}</strong>
+ ) : (
+ <Fragment key={index}>{visible}</Fragment>
+ );
});
- const isDone = visibleCount >= chars.current.length;
-
return (
<p>
- {chars.current.slice(0, visibleCount).join("")}
+ {revealed}
{!isDone && (
<span className="ml-0.5 inline-block h-4 w-2 animate-pulse rounded-sm bg-zinc-300 align-middle" />
)}
diff --git a/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourPromptBar/TourPromptBar.tsx b/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourPromptBar/TourPromptBar.tsx
index 1f39db12a7..2a9a3a7c56 100644
--- a/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourPromptBar/TourPromptBar.tsx
+++ b/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourPromptBar/TourPromptBar.tsx
@@ -4,37 +4,31 @@ import { useMountEffect } from "@/hooks/useMountEffect";
import { cn } from "@/lib/utils";
import { ArrowUpIcon } from "@phosphor-icons/react";
import { useRef } from "react";
-import { TourUpsellBanner } from "../TourUpsellBanner/TourUpsellBanner";
+import { useTextReveal } from "../../useTextReveal";
interface Props {
prompt: string | null;
isStreaming: boolean;
- isExhausted: boolean;
onSend: () => void;
- onReplay: () => void;
}
-export function TourPromptBar({
- prompt,
- isStreaming,
- isExhausted,
- onSend,
- onReplay,
-}: Props) {
+export function TourPromptBar({ prompt, isStreaming, onSend }: Props) {
const ref = useRef<HTMLDivElement>(null);
+ // The parent re-keys this component per turn, so the reveal restarts
+ // whenever a new prompt prefills — it types itself in like the transcript.
+ const { visibleText, isDone: isTyped } = useTextReveal(prompt ?? "");
+ // No prompt means the turn plays itself (auto-started first turn) or the
+ // demo is over — the bar sits empty and disabled either way.
+ const isDisabled = isStreaming || !prompt;
// The parent re-keys this component whenever the prefilled prompt changes, so
// focusing on mount keeps the box ready for the visitor to just press Enter.
useMountEffect(() => {
- if (!isStreaming && !isExhausted) ref.current?.focus();
+ if (!isDisabled) ref.current?.focus();
});
- if (isExhausted) {
- return <TourUpsellBanner onReplay={onReplay} />;
- }
-
function send() {
- if (!isStreaming) onSend();
+ if (!isDisabled) onSend();
}
function handleKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {
@@ -50,28 +44,35 @@ export function TourPromptBar({
<div
ref={ref}
role="button"
- tabIndex={0}
- aria-label={prompt ? `Send: ${prompt}` : "Send message"}
- aria-disabled={isStreaming}
+ tabIndex={isDisabled ? -1 : 0}
+ aria-label={prompt ? `Send: ${prompt}` : "Autopilot is working"}
+ aria-disabled={isDisabled}
onKeyDown={handleKeyDown}
onClick={send}
className={cn(
"flex cursor-pointer items-center gap-3 rounded-xl border border-zinc-200 bg-white px-5 py-3.5 shadow-[0_2px_8px_rgba(0,0,0,0.04),0_0_32px_-4px_rgba(99,102,241,0.4)] outline-none transition-shadow focus-visible:border-zinc-300 focus-visible:shadow-[0_2px_8px_rgba(0,0,0,0.04),0_0_44px_-2px_rgba(99,102,241,0.55)]",
- isStreaming && "cursor-default opacity-60",
+ isDisabled && "cursor-default opacity-60",
)}
>
- <span className="flex-1 truncate text-base text-zinc-700">{prompt}</span>
- <span className="hidden shrink-0 items-center gap-1 text-xs text-zinc-400 sm:flex">
- Press
- <kbd className="rounded border border-zinc-200 bg-zinc-50 px-1.5 py-0.5 font-sans text-[0.7rem] text-zinc-500">
- Enter
- </kbd>
+ <span className="min-h-6 flex-1 truncate text-base text-zinc-700">
+ {visibleText}
+ {prompt && !isTyped && (
+ <span className="ml-0.5 inline-block h-4 w-2 animate-pulse rounded-sm bg-zinc-300 align-middle" />
+ )}
</span>
+ {!isDisabled && isTyped && (
+ <span className="hidden shrink-0 items-center gap-1 text-xs text-zinc-400 sm:flex">
+ Press
+ <kbd className="rounded border border-zinc-200 bg-zinc-50 px-1.5 py-0.5 font-sans text-[0.7rem] text-zinc-500">
+ Enter
+ </kbd>
+ </span>
+ )}
<span
aria-hidden="true"
className={cn(
"flex size-10 shrink-0 items-center justify-center rounded-full text-white transition-colors",
- isStreaming ? "bg-zinc-200" : "bg-zinc-800",
+ isDisabled ? "bg-zinc-200" : "bg-zinc-800",
)}
>
<ArrowUpIcon className="size-4" weight="bold" />
diff --git a/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourSidebar/TourSidebar.tsx b/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourSidebar/TourSidebar.tsx
index 802f113637..87672414ba 100644
--- a/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourSidebar/TourSidebar.tsx
+++ b/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourSidebar/TourSidebar.tsx
@@ -13,6 +13,7 @@ import {
import {
Sidebar,
SidebarContent,
+ SidebarFooter,
SidebarGroup,
SidebarGroupContent,
SidebarGroupLabel,
@@ -33,9 +34,11 @@ import {
} from "@phosphor-icons/react";
import { motion, useReducedMotion } from "framer-motion";
import Link from "next/link";
+import { useRouter } from "next/navigation";
import { tourScenarios } from "../../script/tourScenarios";
import { useTourStore } from "../../tourStore";
import { TourSidebarHeader } from "./components/TourSidebarHeader";
+import { TourUpsellCard } from "./components/TourUpsellCard";
// Visual clone of the logged-in AppSidebar for the public tour demo. Only
// Marketplace navigates; every other destination needs an account, so those
@@ -63,7 +66,8 @@ function DisabledMenuItem({
);
}
-function TourSessionsMenu() {
+function TourSessionsMenu({ variant }: { variant: TourSidebarVariant }) {
+ const router = useRouter();
const activeScenarioId = useTourStore((s) => s.activeScenarioId);
const setActiveScenario = useTourStore((s) => s.setActiveScenario);
const clearArtifactPreview = useCopilotUIStore((s) => s.clearArtifactPreview);
@@ -71,6 +75,7 @@ function TourSessionsMenu() {
function selectScenario(id: string) {
clearArtifactPreview();
setActiveScenario(id);
+ if (variant === "marketplace") router.push("/tour/chat");
}
return (
@@ -78,7 +83,7 @@ function TourSessionsMenu() {
{tourScenarios.map((scenario) => (
<SidebarMenuItem key={scenario.id}>
<SidebarMenuButton
- isActive={scenario.id === activeScenarioId}
+ isActive={variant === "tour" && scenario.id === activeScenarioId}
tooltip={scenario.label}
onClick={() => selectScenario(scenario.id)}
className="font-normal data-[active=true]:!bg-zinc-200 data-[active=true]:font-normal hover:!bg-zinc-200"
@@ -92,7 +97,16 @@ function TourSessionsMenu() {
);
}
-export function TourSidebar() {
+type TourSidebarVariant = "tour" | "marketplace";
+
+interface Props {
+ /** "marketplace" renders the sidebar as a logged-out upsell shell: the
+ * sessions group is honestly labelled a demo and clicking one navigates
+ * into /tour/chat instead of switching in place. */
+ variant?: TourSidebarVariant;
+}
+
+export function TourSidebar({ variant = "tour" }: Props) {
const reduceMotion = useReducedMotion();
const itemVariants = getSidebarItemVariants(!!reduceMotion);
@@ -182,16 +196,20 @@ export function TourSidebar() {
>
<SidebarGroup className="py-1">
<SidebarGroupLabel className="text-[13px] font-medium">
- Recent chats
+ {variant === "marketplace" ? "Try Autopilot" : "Recent chats"}
</SidebarGroupLabel>
<SidebarGroupContent>
- <TourSessionsMenu />
+ <TourSessionsMenu variant={variant} />
</SidebarGroupContent>
</SidebarGroup>
</motion.div>
</motion.div>
</SidebarContent>
+ <SidebarFooter className="p-3 group-data-[collapsible=icon]:hidden">
+ <TourUpsellCard />
+ </SidebarFooter>
+
<SidebarRail />
</Sidebar>
);
diff --git a/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourSidebar/components/TourUpsellCard.tsx b/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourSidebar/components/TourUpsellCard.tsx
new file mode 100644
index 0000000000..dd576cf0e4
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourSidebar/components/TourUpsellCard.tsx
@@ -0,0 +1,94 @@
+"use client";
+
+import { Button } from "@/components/atoms/Button/Button";
+import { Text } from "@/components/atoms/Text/Text";
+import { cn } from "@/lib/utils";
+import { GithubLogoIcon, SparkleIcon } from "@phosphor-icons/react";
+import { useTourStore } from "../../../tourStore";
+
+const PRICING_URL = "https://agpt.co/pricing";
+const GITHUB_URL = "https://github.com/Significant-Gravitas/AutoGPT";
+
+export function TourUpsellCard() {
+ // The glow and moving effects (spinning border, shine sweep, pulsing
+ // sparkle) would fight the streaming transcript for attention, so the card
+ // sits quiet and only lights up once the demo has played through.
+ const isDemoComplete = useTourStore((s) => s.isDemoComplete);
+
+ return (
+ // Border: a p-px shell whose backdrop is a plain hairline while the demo
+ // runs and an oversized spinning conic gradient once it completes (same
+ // trick as PlanCard's badge).
+ <div
+ className={cn(
+ "relative rounded-xl p-px",
+ isDemoComplete
+ ? "shadow-[0_0_20px_-4px_rgba(139,92,246,0.45),0_0_44px_-8px_rgba(139,92,246,0.4)]"
+ : "shadow-sm",
+ )}
+ >
+ <span
+ aria-hidden="true"
+ className="absolute inset-0 overflow-hidden rounded-xl"
+ >
+ <span
+ className={cn(
+ "absolute -inset-[150%]",
+ isDemoComplete
+ ? "animate-[spin_6s_linear_infinite] bg-[conic-gradient(from_0deg,#ede9fe,#c4b5fd,#8b5cf6,#ede9fe,#ddd6fe,#a78bfa,#ede9fe)]"
+ : "bg-zinc-200/80",
+ )}
+ />
+ </span>
+
+ <div className="relative flex flex-col rounded-[11px] bg-white p-4">
+ <div className="flex items-center gap-1.5">
+ <SparkleIcon
+ size={14}
+ weight="fill"
+ className={cn(
+ "shrink-0 text-violet-600",
+ isDemoComplete && "animate-pulse",
+ )}
+ />
+ <Text variant="body-medium" className="text-zinc-900">
+ Ready to build your own?
+ </Text>
+ </div>
+ <Text variant="small" className="mt-1 text-zinc-500">
+ Spin up agents like this in minutes, hosted for you or on your own
+ infrastructure.
+ </Text>
+ <Button
+ as="NextLink"
+ href={PRICING_URL}
+ target="_blank"
+ rel="noopener noreferrer"
+ variant="primary"
+ size="small"
+ className="relative mt-3 w-full overflow-hidden shadow-[0_0_20px_-6px_rgba(124,58,237,0.6)] transition-shadow hover:shadow-[0_0_28px_-4px_rgba(124,58,237,0.75)]"
+ >
+ {isDemoComplete && (
+ <span
+ aria-hidden="true"
+ className="pointer-events-none absolute inset-y-0 left-0 w-1/3 -skew-x-12 animate-[progress-bar_2.6s_ease-in-out_infinite] bg-gradient-to-r from-transparent via-white/40 to-transparent"
+ />
+ )}
+ Start with Pro for $42.50/mo
+ </Button>
+ <Button
+ as="NextLink"
+ href={GITHUB_URL}
+ target="_blank"
+ rel="noopener noreferrer"
+ variant="ghost"
+ size="small"
+ className="mt-1.5 w-full text-zinc-600"
+ leftIcon={<GithubLogoIcon className="h-4 w-4" />}
+ >
+ Self-host free
+ </Button>
+ </div>
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourUpsellBanner/TourUpsellBanner.tsx b/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourUpsellBanner/TourUpsellBanner.tsx
deleted file mode 100644
index 0d3b5fee98..0000000000
--- a/autogpt_platform/frontend/src/app/(public)/tour/chat/components/TourUpsellBanner/TourUpsellBanner.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-"use client";
-
-import { Button } from "@/components/atoms/Button/Button";
-import { Text } from "@/components/atoms/Text/Text";
-import {
- ArrowCounterClockwiseIcon,
- GithubLogoIcon,
- SparkleIcon,
-} from "@phosphor-icons/react";
-
-interface Props {
- onReplay: () => void;
-}
-
-export function TourUpsellBanner({ onReplay }: Props) {
- return (
- <div className="fixed inset-x-0 bottom-0 z-50 border-t border-zinc-200 bg-white shadow-[0_-2px_8px_rgba(0,0,0,0.04),0_0_32px_-4px_rgba(99,102,241,0.4)] duration-500 animate-in fade-in slide-in-from-bottom-2">
- <div className="flex flex-col gap-3 px-4 py-3 sm:flex-row sm:items-center sm:gap-4 sm:px-6">
- <div className="flex items-start gap-3">
- <SparkleIcon
- size={22}
- weight="fill"
- className="mt-0.5 shrink-0 text-violet-600"
- />
- <div className="flex flex-col">
- <Text variant="large-medium" className="text-zinc-900">
- Ready to build your own?
- </Text>
- <Text variant="body" className="text-zinc-600">
- Spin up agents like this in minutes — hosted for you, or on your
- own infrastructure.
- </Text>
- </div>
- </div>
-
- <div className="flex flex-col gap-2 sm:ml-auto sm:flex-row sm:items-center sm:gap-3">
- <Button
- variant="ghost"
- size="small"
- leftIcon={<ArrowCounterClockwiseIcon className="h-4 w-4" />}
- onClick={onReplay}
- >
- Replay demo
- </Button>
- <Button
- as="NextLink"
- href="https://github.com/Significant-Gravitas/AutoGPT"
- target="_blank"
- rel="noopener noreferrer"
- variant="secondary"
- size="small"
- leftIcon={<GithubLogoIcon className="h-4 w-4" />}
- >
- Self-host free
- </Button>
- <Button
- as="NextLink"
- href="https://agpt.co/pricing"
- target="_blank"
- rel="noopener noreferrer"
- variant="primary"
- size="small"
- className="shadow-[0_0_24px_-4px_rgba(124,58,237,0.7)] transition-shadow hover:shadow-[0_0_32px_-2px_rgba(124,58,237,0.85)]"
- >
- Start with Pro — $42.50/mo
- </Button>
- </div>
- </div>
- </div>
- );
-}
diff --git a/autogpt_platform/frontend/src/app/(public)/tour/chat/helpers.ts b/autogpt_platform/frontend/src/app/(public)/tour/chat/helpers.ts
index 56d5296df6..4ea1c7e87a 100644
--- a/autogpt_platform/frontend/src/app/(public)/tour/chat/helpers.ts
+++ b/autogpt_platform/frontend/src/app/(public)/tour/chat/helpers.ts
@@ -25,3 +25,14 @@ export function appendPartToLastMessage(
next[next.length - 1] = { ...last, parts: [...last.parts, part] };
return next;
}
+
+export const REVEAL_CHARS_PER_TICK = 2;
+export const REVEAL_TICK_MS = 16;
+
+/** How long TourStreamingText takes to type out a text part — the turn isn't
+ * visually over when its last part commits, but when this reveal finishes. */
+export function textRevealDurationMs(text: string) {
+ return (
+ Math.ceil(Array.from(text).length / REVEAL_CHARS_PER_TICK) * REVEAL_TICK_MS
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(public)/tour/chat/tourStore.ts b/autogpt_platform/frontend/src/app/(public)/tour/chat/tourStore.ts
index 1ba1f7278c..6257dd7dc2 100644
--- a/autogpt_platform/frontend/src/app/(public)/tour/chat/tourStore.ts
+++ b/autogpt_platform/frontend/src/app/(public)/tour/chat/tourStore.ts
@@ -3,10 +3,25 @@ import { DEFAULT_SCENARIO_ID } from "./script/tourScenarios";
interface TourState {
activeScenarioId: string;
+ /** Bumped on every sidebar selection — re-keys the demo so clicking a
+ * scenario (even the already-active one) always restarts it fresh. */
+ runId: number;
+ /** True once the active demo has played through — the sidebar upsell card
+ * saves its attention-grabbing animations for this moment. */
+ isDemoComplete: boolean;
setActiveScenario: (id: string) => void;
+ setDemoComplete: () => void;
}
export const useTourStore = create<TourState>((set) => ({
activeScenarioId: DEFAULT_SCENARIO_ID,
- setActiveScenario: (id) => set({ activeScenarioId: id }),
+ runId: 0,
+ isDemoComplete: false,
+ setActiveScenario: (id) =>
+ set((state) => ({
+ activeScenarioId: id,
+ runId: state.runId + 1,
+ isDemoComplete: false,
+ })),
+ setDemoComplete: () => set({ isDemoComplete: true }),
}));
diff --git a/autogpt_platform/frontend/src/app/(public)/tour/chat/useTextReveal.ts b/autogpt_platform/frontend/src/app/(public)/tour/chat/useTextReveal.ts
new file mode 100644
index 0000000000..e0a1400168
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(public)/tour/chat/useTextReveal.ts
@@ -0,0 +1,33 @@
+"use client";
+
+import { useMountEffect } from "@/hooks/useMountEffect";
+import { useRef, useState } from "react";
+import { REVEAL_CHARS_PER_TICK, REVEAL_TICK_MS } from "./helpers";
+
+/** Types `text` out character by character, like a live LLM stream. Callers
+ * re-key their component to restart the reveal for a new text. */
+export function useTextReveal(text: string) {
+ // Code points, not UTF-16 units — slicing mid-surrogate would briefly
+ // render a broken glyph for emoji like 🎉.
+ const chars = useRef(Array.from(text));
+ const [visibleCount, setVisibleCount] = useState(0);
+
+ useMountEffect(() => {
+ const id = setInterval(() => {
+ setVisibleCount((count) => {
+ const next = Math.min(
+ count + REVEAL_CHARS_PER_TICK,
+ chars.current.length,
+ );
+ if (next >= chars.current.length) clearInterval(id);
+ return next;
+ });
+ }, REVEAL_TICK_MS);
+ return () => clearInterval(id);
+ });
+
+ return {
+ visibleText: chars.current.slice(0, visibleCount).join(""),
+ isDone: visibleCount >= chars.current.length,
+ };
+}
diff --git a/autogpt_platform/frontend/src/app/(public)/tour/chat/useTourCopilot.ts b/autogpt_platform/frontend/src/app/(public)/tour/chat/useTourCopilot.ts
index 61c4196b01..eeb46f19a9 100644
--- a/autogpt_platform/frontend/src/app/(public)/tour/chat/useTourCopilot.ts
+++ b/autogpt_platform/frontend/src/app/(public)/tour/chat/useTourCopilot.ts
@@ -2,40 +2,59 @@
import { useMountEffect } from "@/hooks/useMountEffect";
import { useRef, useState } from "react";
-import { appendPartToLastMessage } from "./helpers";
+import { appendPartToLastMessage, textRevealDurationMs } from "./helpers";
import type { TourMessage, TourScript } from "./script/types";
type TourStatus = "ready" | "streaming";
-const TURN_SETTLE_MS = 300;
+/** Beat after the turn's last text finishes revealing before the next prompt
+ * prefills — keeps the visitor's attention on the transcript, not the bar. */
+const TURN_SETTLE_MS = 1500;
/** Hold after the final part streams in before the demo flips to the upsell
* card — gives the visitor time to take in the payoff artifact. */
const FINAL_TURN_SETTLE_MS = 3000;
+/** Beat before the first prompt starts typing itself into the bar. */
+const AUTO_START_DELAY_MS = 1000;
+/** Pause between the auto-typed prompt finishing and its "Enter press". */
+const AUTO_SEND_DELAY_MS = 600;
+/** Beat after the final turn's last part before the artifact heads-up types in. */
+const COMPLETION_NOTICE_DELAY_MS = 600;
interface Args {
sessionId: string;
script: TourScript;
onComplete: () => void;
- onReset?: () => void;
+ /** Extra closing line for the final turn, pointing at the artifact panel
+ * that is about to open (e.g. "Your report.md will appear on the right"). */
+ completionNotice?: string;
}
export function useTourCopilot({
sessionId,
script,
onComplete,
- onReset,
+ completionNotice,
}: Args) {
const [messages, setMessages] = useState<TourMessage[]>([]);
const [status, setStatus] = useState<TourStatus>("ready");
+ const [isAutoPromptVisible, setIsAutoPromptVisible] = useState(false);
const stepIndex = useRef(0);
const timers = useRef<ReturnType<typeof setTimeout>[]>([]);
const messagesRef = useRef<TourMessage[]>([]);
+ // onSend runs from setTimeout callbacks (auto-start), so it must read status
+ // through a ref — the closure's `status` is stale by the time a timer fires.
+ const statusRef = useRef<TourStatus>("ready");
function commit(next: TourMessage[]) {
messagesRef.current = next;
setMessages(next);
}
+ function transition(next: TourStatus) {
+ statusRef.current = next;
+ setStatus(next);
+ }
+
function clearTimers() {
timers.current.forEach(clearTimeout);
timers.current = [];
@@ -43,7 +62,10 @@ export function useTourCopilot({
function onSend(text: string) {
const turn = script[stepIndex.current];
- if (status !== "ready" || !turn) return;
+ if (statusRef.current !== "ready" || !turn) return;
+
+ // A manual send cancels the pending auto-start so the turn can't fire twice.
+ clearTimers();
commit([
...messagesRef.current,
@@ -54,9 +76,12 @@ export function useTourCopilot({
},
{ id: turn.assistantMessageId, role: "assistant", parts: [] },
]);
- setStatus("streaming");
+ transition("streaming");
let elapsed = 0;
+ // Text parts keep typing themselves out after they commit, so the turn is
+ // only visually over once the slowest reveal finishes — not at last commit.
+ let visualEnd = 0;
turn.steps.forEach((step) => {
elapsed += step.delayMs;
timers.current.push(
@@ -64,40 +89,80 @@ export function useTourCopilot({
commit(appendPartToLastMessage(messagesRef.current, step.part));
}, elapsed),
);
+ const revealMs =
+ step.part.type === "text" ? textRevealDurationMs(step.part.text) : 0;
+ visualEnd = Math.max(visualEnd, elapsed + revealMs);
});
const isFinalTurn = stepIndex.current === script.length - 1;
+ if (isFinalTurn && completionNotice) {
+ const noticeAt = visualEnd + COMPLETION_NOTICE_DELAY_MS;
+ timers.current.push(
+ setTimeout(() => {
+ commit(
+ appendPartToLastMessage(messagesRef.current, {
+ type: "text",
+ text: completionNotice,
+ }),
+ );
+ }, noticeAt),
+ );
+ visualEnd = noticeAt + textRevealDurationMs(completionNotice);
+ }
timers.current.push(
setTimeout(
() => {
- setStatus("ready");
+ transition("ready");
stepIndex.current += 1;
if (stepIndex.current >= script.length) onComplete();
},
- elapsed + (isFinalTurn ? FINAL_TURN_SETTLE_MS : TURN_SETTLE_MS),
+ visualEnd + (isFinalTurn ? FINAL_TURN_SETTLE_MS : TURN_SETTLE_MS),
),
);
}
- function reset() {
- clearTimers();
- stepIndex.current = 0;
- commit([]);
- setStatus("ready");
- onReset?.();
+ // First turn plays itself like a real interaction: after a beat the prompt
+ // types into the bar (the reveal runs in TourPromptBar at a shared speed, so
+ // its end time is known here), then it "presses Enter" on its own.
+ function scheduleAutoStart() {
+ const firstTurn = script[0];
+ if (!firstTurn) return;
+ timers.current.push(
+ setTimeout(() => setIsAutoPromptVisible(true), AUTO_START_DELAY_MS),
+ );
+ timers.current.push(
+ setTimeout(
+ () => onSend(firstTurn.userPrompt),
+ AUTO_START_DELAY_MS +
+ textRevealDurationMs(firstTurn.userPrompt) +
+ AUTO_SEND_DELAY_MS,
+ ),
+ );
}
- useMountEffect(() => clearTimers);
+ // TourChatHost is keyed by scenario id, so a scenario switch remounts this
+ // hook — each fresh mount auto-plays its first turn (pressing Enter still
+ // works and just skips the wait).
+ useMountEffect(() => {
+ scheduleAutoStart();
+ return clearTimers;
+ });
const currentTurn = script[stepIndex.current];
+ // Turn 0's prompt is only in the bar while it auto-types; it clears on send
+ // and the next turn's prompt prefills once the round finishes.
+ const currentUserPrompt =
+ stepIndex.current === 0
+ ? status === "ready" && isAutoPromptVisible
+ ? (currentTurn?.userPrompt ?? null)
+ : null
+ : (currentTurn?.userPrompt ?? null);
return {
messages,
onSend,
- reset,
turnIndex: stepIndex.current,
- currentUserPrompt: currentTurn?.userPrompt ?? null,
+ currentUserPrompt,
isStreaming: status === "streaming",
- isExhausted: stepIndex.current >= script.length,
};
}