> ## Documentation Index
> Fetch the complete documentation index at: https://anvil.servicetitan.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Agentic Experience Shell

> Compose Carto components into a consistent shell for agentic experiences.

export const LiveCode = ({children, customHeight, clickToLoad, example, fullWidth, fullHeight, hideCodeInLiveCode, screenshot, screenshotOnly, showCode: showCodeProp}) => {
  const SCREENSHOTS_BASE = "https://servicetitan.github.io/anvil2-docs-live-code/screenshots";
  const STACKBLITZ_BASE = "https://stackblitz.com/github/servicetitan/anvil2-docs-live-code/tree/main/examples";
  const [showCodeBlock, setShowCodeBlock] = useState(showCodeProp ?? false);
  const [isLocalOverride, setIsLocalOverride] = useState(false);
  useEffect(() => {
    const examplePath = `/images/live-code-screenshots-tmp/${example}.png`;
    fetch(examplePath, {
      method: "HEAD"
    }).then(r => {
      if (r.ok) setIsLocalOverride(true);
    }).catch(() => {});
  }, [example]);
  const screenshotBase = isLocalOverride ? "/images/live-code-screenshots-tmp" : SCREENSHOTS_BASE;
  if (screenshotOnly) {
    return <Frame className="flex flex-col">
        <div className="flex dark:hidden" style={{
      justifyContent: "center",
      alignItems: "center",
      width: fullWidth ? "100%" : "50%",
      minHeight: fullHeight ? "284px" : undefined,
      background: "#FFFFFF"
    }}>
          <img srcset={`${screenshotBase}/${example}.png, ${screenshotBase}/${example}-2x.png 2x`} src={`${screenshotBase}/${example}.png`} alt={example} noZoom />
        </div>
        <div className="hidden dark:flex" style={{
      justifyContent: "center",
      alignItems: "center",
      width: fullWidth ? "100%" : "50%",
      minHeight: fullHeight ? "284px" : undefined,
      background: "#141414"
    }}>
          <img srcset={`${screenshotBase}/${example}-dark.png, ${screenshotBase}/${example}-dark-2x.png 2x`} src={`${screenshotBase}/${example}-dark.png`} alt={example} noZoom />
        </div>
      </Frame>;
  }
  if (screenshot) {
    return <Frame className="flex flex-col -mb-2">
        <div className="flex dark:hidden bg-white dark:bg-codeblock border border-gray-950/10 dark:border-white/10 dark:twoslash-dark rounded-2xl overflow-hidden" style={{
      justifyContent: "center",
      alignItems: "center",
      width: fullWidth ? "100%" : "50%",
      minHeight: fullHeight ? "284px" : undefined
    }}>
          <img srcset={`${screenshotBase}/${example}.png, ${screenshotBase}/${example}-2x.png 2x`} src={`${screenshotBase}/${example}.png`} alt={example} noZoom />
        </div>

        <div className="hidden dark:flex bg-white dark:bg-codeblock border border-gray-950/10 dark:border-white/10 dark:twoslash-dark rounded-2xl overflow-hidden" style={{
      background: "#141414",
      justifyContent: "center",
      alignItems: "center",
      width: fullWidth ? "100%" : "50%",
      minHeight: fullHeight ? "284px" : undefined
    }}>
          <img srcset={`${screenshotBase}/${example}-dark.png, ${screenshotBase}/${example}-dark-2x.png 2x`} src={`${screenshotBase}/${example}-dark.png`} alt={example} noZoom />
        </div>

        <div className="flex justify-end items-center text-xs py-2 px-1 gap-4">
          {!showCodeProp ? <button className="inline-flex justify-end items-center text-gray-700 dark:text-gray-50 hover:text-blue-500 dark:hover:text-blue-300 transition-colors group self-end gap-1 cursor-pointer" onClick={() => setShowCodeBlock(!showCodeBlock)} style={{
      appearance: "none"
    }}>
              <Icon icon="code" size="12px" className="group-hover:bg-blue-500 dark:group-hover:bg-blue-300" />
              <span>{showCodeBlock ? "Hide code" : "Show code"}</span>
            </button> : null}

          <a className="inline-flex justify-end items-center hover:text-blue-500 dark:hover:text-blue-300 transition-colors group self-end gap-1" href={`${STACKBLITZ_BASE}/${example}?file=src/App.tsx`} target="_blank" rel="noreferrer">
            <Icon icon="bolt" size="12px" className="group-hover:bg-blue-500 dark:group-hover:bg-blue-300" />
            <span>StackBlitz demo</span>
          </a>
        </div>

        <div className="grid transition-[grid-template-rows] duration-300 ease-in-out overflow-auto overflow-y-hidden overflow-x-auto" style={showCodeBlock ? {
      gridTemplateRows: "1fr"
    } : {
      gridTemplateRows: "0fr"
    }}>
          <div style={{
      minHeight: 0,
      overflowX: "auto",
      overflowY: "hidden",
      marginBlockStart: "-1.25rem",
      marginBlockEnd: "-1.5rem"
    }}>
            {children}
          </div>
        </div>
      </Frame>;
  } else {
    return <div style={{
      display: "flex",
      width: fullWidth ? "100%" : "50%",
      minHeight: customHeight ? customHeight : "316px",
      resize: "vertical",
      overflow: "auto"
    }}>
        <iframe title={example} style={{
      flex: 1,
      width: fullWidth ? "100%" : "50%",
      minHeight: customHeight ? customHeight : "316px"
    }} src={`${STACKBLITZ_BASE}/${example}?embed=1&hideNavigation=1&hideExplorer=1&terminalHeight=0&file=src/App.tsx${clickToLoad ? "&ctl=1" : ""}${hideCodeInLiveCode ? "&view=preview" : ""}`} allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking" sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts" />
      </div>;
  }
};

The agentic experience shell provides the persistent structure around a conversation. It defines navigation, presentation, and supporting workspaces without prescribing the content inside the conversation.

## Shell Options

The agent experience takes place in a shell with two shapes: the floating shell, and the fullscreen dialog shell experience.

### Floating shell

<LiveCode example="carto-patterns-agentic-experience-shell-window-full-page" screenshot fullWidth>
  ```tsx lines theme={null}
  import { useState } from "react";
  import {
    AppHeader,
    CartoTheme,
    ChatHistory,
    ChatLayout,
    PromptBar,
    TabbedLayout,
    Text,
    Window,
    useAppSurface,
    type ChatHistoryItem,
    type TabbedLayoutTab,
  } from "@servicetitan/carto-react-kit";
  import {
    IconGrip,
    IconInbox,
    IconMaximize2,
    IconMinimize2,
    IconPanelLeft,
    IconPanelRight,
    IconX,
  } from "@servicetitan/carto-react-kit/icons";
  import * as cartoTokens from "@servicetitan/carto-react-kit/tokens";
  import "@servicetitan/carto-react-kit/styles.css";

  const { primitive } =
    cartoTokens as unknown as typeof import("@servicetitan/carto-tokens/vanilla-extract");

  const historyItems: ChatHistoryItem[] = [
    { id: "current", label: "Current conversation", subtitle: "Just now" },
    { id: "previous", label: "Previous conversation", subtitle: "Yesterday" },
  ];

  const artifactTabs: TabbedLayoutTab[] = [
    {
      key: "preview",
      label: "Preview",
      content: <Text text="Generated artifact" />,
    },
  ];

  function WindowHeader() {
    const {
      close,
      dragHandleProps,
      isFullscreen,
      toggleArtifact,
      toggleRail,
      toggleSize,
    } = useAppSurface();

    return (
      <AppHeader
        title="Title of conversation"
        leadingActions={
          isFullscreen
            ? [
                {
                  id: "rail",
                  icon: <IconPanelLeft />,
                  label: "Toggle chat history",
                  onPress: toggleRail,
                },
              ]
            : [
                {
                  id: "drag",
                  icon: <IconGrip />,
                  label: "Move window",
                  dragHandleProps,
                },
              ]
        }
        trailingActions={[
          ...(isFullscreen
            ? [
                {
                  id: "artifact",
                  icon: <IconPanelRight />,
                  label: "Toggle artifact panel",
                  onPress: toggleArtifact,
                },
              ]
            : []),
          {
            id: "inbox",
            icon: <IconInbox />,
            label: "Inbox",
            onPress: () => {},
          },
          {
            id: "size",
            icon: isFullscreen ? <IconMinimize2 /> : <IconMaximize2 />,
            label: isFullscreen ? "Restore" : "Maximize",
            onPress: toggleSize,
          },
          {
            id: "close",
            icon: <IconX />,
            label: "Close",
            onPress: close,
          },
        ]}
      />
    );
  }

  function App() {
    const [prompt, setPrompt] = useState("");

    return (
      <CartoTheme>
        <div
          style={{
            position: "fixed",
            inset: 0,
            overflow: "hidden",
            background: primitive.color.neutral["20"],
          }}
        >
          <Window
            header={<WindowHeader />}
            rail={
              <ChatHistory
                items={historyItems}
                defaultSelectedKeys={["current"]}
              />
            }
            chat={
              <ChatLayout
                conversation={
                  <div style={{ padding: 16 }}>
                    <Text text="Conversation content" />
                  </div>
                }
                prompt={
                  <PromptBar
                    value={prompt}
                    onChange={setPrompt}
                    placeholder="Ask anything…"
                  />
                }
              />
            }
            artifact={<TabbedLayout tabs={artifactTabs} />}
          />
        </div>
      </CartoTheme>
    );
  }

  export default App;
  ```
</LiveCode>

### Fullscreen shell

<LiveCode example="carto-patterns-agentic-experience-shell-fullscreen-full-page" screenshot fullWidth>
  ```tsx lines theme={null}
  import { useState } from "react";
  import {
    AppHeader,
    CartoTheme,
    ChatHistory,
    ChatLayout,
    PromptBar,
    TabbedLayout,
    Text,
    Window,
    useAppSurface,
    type ChatHistoryItem,
    type TabbedLayoutTab,
  } from "@servicetitan/carto-react-kit";
  import {
    IconMinimize2,
    IconPanelLeft,
    IconPanelRight,
    IconX,
  } from "@servicetitan/carto-react-kit/icons";
  import "@servicetitan/carto-react-kit/styles.css";

  const historyItems: ChatHistoryItem[] = [
    { id: "current", label: "Current conversation", subtitle: "Just now" },
    { id: "previous", label: "Previous conversation", subtitle: "Yesterday" },
  ];

  const artifactTabs: TabbedLayoutTab[] = [
    {
      key: "preview",
      label: "Preview",
      content: <Text text="Generated artifact" />,
    },
  ];

  function WindowHeader() {
    const { close, toggleArtifact, toggleRail, toggleSize } = useAppSurface();

    return (
      <AppHeader
        title="Title of conversation"
        leadingActions={[
          {
            id: "history",
            icon: <IconPanelLeft />,
            label: "Toggle chat history",
            onPress: toggleRail,
          },
        ]}
        trailingActions={[
          {
            id: "artifact",
            icon: <IconPanelRight />,
            label: "Toggle artifact panel",
            onPress: toggleArtifact,
          },
          {
            id: "restore",
            icon: <IconMinimize2 />,
            label: "Restore",
            onPress: toggleSize,
          },
          {
            id: "close",
            icon: <IconX />,
            label: "Close",
            onPress: close,
          },
        ]}
      />
    );
  }

  function App() {
    const [prompt, setPrompt] = useState("");

    return (
      <CartoTheme>
        <div style={{ position: "fixed", inset: 0, background: "#e9ecf1" }}>
          <Window
            defaultState="fullscreen"
            header={<WindowHeader />}
            rail={
              <ChatHistory
                items={historyItems}
                defaultSelectedKeys={["current"]}
              />
            }
            chat={
              <ChatLayout
                prompt={
                  <PromptBar
                    value={prompt}
                    onChange={setPrompt}
                    placeholder="Ask anything…"
                  />
                }
              />
            }
            artifact={<TabbedLayout tabs={artifactTabs} />}
          />
        </div>
      </CartoTheme>
    );
  }

  export default App;
  ```
</LiveCode>

Both shells are available to a user. Implementors can default which experience a user lands on, but cannot prevent the user from switching to the other.

#### Feature Options

| Capability     | Window Shell | Fullscreen Shell |
| -------------- | ------------ | ---------------- |
| Artifact panel | Unavailable  | Available        |
| Chat history   | Available    | Available        |
| New chat       | Available    | Available        |

#### When to default to which shell?

| Presentation     | Use when                                             |
| ---------------- | ---------------------------------------------------- |
| Window Shell     | Context from the underlying page remains important   |
| Fullscreen Shell | The workflow requires dedicated focus or an artifact |

## Supporting content

Supporting content can appear in the App Shell’s artifact panel. The content inside that panel can use a Tabbed Layout when users need access to multiple related views.

### Panel

<LiveCode example="carto-patterns-agentic-experience-shell-panel-full-page" screenshot fullWidth>
  ```tsx lines theme={null}
  import { useState } from "react";
  import {
    AppHeader,
    CartoTheme,
    ChatHistory,
    ChatLayout,
    PromptBar,
    Text,
    Window,
    useAppSurface,
    type ChatHistoryItem,
  } from "@servicetitan/carto-react-kit";
  import {
    IconMinimize2,
    IconPanelLeft,
    IconPanelRight,
    IconX,
  } from "@servicetitan/carto-react-kit/icons";
  import "@servicetitan/carto-react-kit/styles.css";

  const historyItems: ChatHistoryItem[] = [
    { id: "current", label: "Current conversation", subtitle: "Just now" },
    { id: "previous", label: "Previous conversation", subtitle: "Yesterday" },
  ];

  function WindowHeader() {
    const { close, toggleArtifact, toggleRail, toggleSize } = useAppSurface();

    return (
      <AppHeader
        title="Title of conversation"
        leadingActions={[
          {
            id: "history",
            icon: <IconPanelLeft />,
            label: "Toggle chat history",
            onPress: toggleRail,
          },
        ]}
        trailingActions={[
          {
            id: "artifact",
            icon: <IconPanelRight />,
            label: "Toggle artifact panel",
            onPress: toggleArtifact,
          },
          {
            id: "restore",
            icon: <IconMinimize2 />,
            label: "Restore",
            onPress: toggleSize,
          },
          {
            id: "close",
            icon: <IconX />,
            label: "Close",
            onPress: close,
          },
        ]}
      />
    );
  }

  function App() {
    const [prompt, setPrompt] = useState("");

    return (
      <CartoTheme>
        <Window
          defaultState="fullscreen"
          header={<WindowHeader />}
          rail={
            <ChatHistory items={historyItems} defaultSelectedKeys={["current"]} />
          }
          chat={
            <ChatLayout
              prompt={
                <PromptBar
                  value={prompt}
                  onChange={setPrompt}
                  placeholder="Ask anything…"
                />
              }
            />
          }
          artifact={
            <div style={{ height: "100%", padding: 16 }}>
              <Text text="Supporting content" />
            </div>
          }
        />
      </CartoTheme>
    );
  }

  export default App;
  ```
</LiveCode>

### Tabbed layout

<LiveCode example="carto-patterns-agentic-experience-shell-tabbed-layout-full-page" screenshot fullWidth>
  ```tsx lines theme={null}
  import { useState } from "react";
  import {
    AppHeader,
    CartoTheme,
    ChatHistory,
    ChatLayout,
    PromptBar,
    TabbedLayout,
    Text,
    Window,
    useAppSurface,
    type ChatHistoryItem,
    type TabbedLayoutTab,
  } from "@servicetitan/carto-react-kit";
  import {
    IconMinimize2,
    IconPanelLeft,
    IconPanelRight,
    IconX,
  } from "@servicetitan/carto-react-kit/icons";
  import "@servicetitan/carto-react-kit/styles.css";

  const historyItems: ChatHistoryItem[] = [
    { id: "current", label: "Current conversation", subtitle: "Just now" },
    { id: "previous", label: "Previous conversation", subtitle: "Yesterday" },
  ];

  const artifactTabs: TabbedLayoutTab[] = [
    {
      key: "preview",
      label: "Preview",
      content: <Text text="Generated artifact" />,
    },
    {
      key: "details",
      label: "Details",
      content: <Text text="Artifact details" />,
    },
  ];

  function WindowHeader() {
    const { close, toggleArtifact, toggleRail, toggleSize } = useAppSurface();

    return (
      <AppHeader
        title="Title of conversation"
        leadingActions={[
          {
            id: "history",
            icon: <IconPanelLeft />,
            label: "Toggle chat history",
            onPress: toggleRail,
          },
        ]}
        trailingActions={[
          {
            id: "artifact",
            icon: <IconPanelRight />,
            label: "Toggle artifact panel",
            onPress: toggleArtifact,
          },
          {
            id: "restore",
            icon: <IconMinimize2 />,
            label: "Restore",
            onPress: toggleSize,
          },
          {
            id: "close",
            icon: <IconX />,
            label: "Close",
            onPress: close,
          },
        ]}
      />
    );
  }

  function App() {
    const [prompt, setPrompt] = useState("");

    return (
      <CartoTheme>
        <Window
          defaultState="fullscreen"
          header={<WindowHeader />}
          rail={
            <ChatHistory items={historyItems} defaultSelectedKeys={["current"]} />
          }
          chat={
            <ChatLayout
              prompt={
                <PromptBar
                  value={prompt}
                  onChange={setPrompt}
                  placeholder="Ask anything…"
                />
              }
            />
          }
          artifact={<TabbedLayout tabs={artifactTabs} />}
        />
      </CartoTheme>
    );
  }

  export default App;
  ```
</LiveCode>

## Dos and Don'ts for Agentic Experience Shell

| Guidance | Practice                                                                                                       |
| -------- | -------------------------------------------------------------------------------------------------------------- |
| Do       | Use an artifact panel when a workflow benefits from dedicated space to view and interact with related content. |
| Don't    | Place an artifact panel in the floating shell.                                                                 |
| Don't    | Modify the left rail with content other than chat history.                                                     |
| Don't    | Change the floating shell's default location.                                                                  |

## Related components

* [App Header](/docs/kits/ai-kit/components/app-header/design) — Identifies the experience and provides shell-level actions
* [App Shell](/docs/kits/ai-kit/components/app-shell/design) — Arranges the header, history rail, conversation, and supporting panel
* [Chat History](/docs/kits/ai-kit/components/chat-history/design) — Provides access to previous conversations
* [Chat Layout](/docs/kits/ai-kit/components/chat-layout/design) — Defines the conversation region
* [Tabbed Layout](/docs/kits/ai-kit/components/tabbed-layout/design) — Organizes multiple related views within the supporting workspace
* [Window](/docs/kits/ai-kit/components/window/design) — Presents the shell as a floating or fullscreen experience

## Related patterns

* [Chat Layout](/docs/kits/ai-kit/patterns/chat-layout) — For the layout of chat messages within the shell.
