Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Thread tabs: the tabs take the pill's place in the header row, on the sidebar buttons' centre line

milind-soni5faf88b3a894
diff --git a/DESIGN.md b/DESIGN.md
index d6a267882f..d1221dfd23 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -46,8 +46,8 @@ where they belong instead of adding new places.
pinned message) is fine: it opens a menu and is gone when there is nothing
to show. One exception: **New thread** (a plus, also ⌘T) sits at the end of the
header in both modes, because starting a thread is an everyday action people
- look for at the top. With Thread tabs on, the plus and the open thread's name
- move to the tab strip above the chat, which is not a header button.
+ look for at the top. With Thread tabs on, the bot's threads take the pill's
+ place in the header as tabs, with the plus at their end.
- **No count badges and no "needs you" summaries** above the sidebar list or
in the header. A status mark on the row it belongs to is fine.
- **Settings for one bot live in its bot panel.** App-wide settings live in
diff --git a/src/components/ChatHeadPill.tsx b/src/components/ChatHeadPill.tsx
index 43c0bba38a..438df00b60 100644
--- a/src/components/ChatHeadPill.tsx
+++ b/src/components/ChatHeadPill.tsx
@@ -6,7 +6,6 @@ import { cn } from "@/lib/cn";
import { t } from "@/lib/i18n";
import type { Bot } from "@/state/store"; import { useStoreSelector } from "@/state/store-select";
import { awayFromMainThread } from "@/state/thread-navigation";
-import { useThreadTabsShown } from "./ThreadTabStrip";
import { BotAvatar } from "./Avatar";
import { ELEVATED_FLOAT, ELEVATED_HOVER } from "./elevated";
import { sidebarBotActivityTasks } from "./SidebarBotActivity";
@@ -33,9 +32,8 @@ function privacyLabelOf(privacy: ChatHeadPrivacy): string | null {
/** Simple mode's whole chat header: the bot's face and name in one pill, which opens and closes the bot panel. Away from
* the bot's main conversation it also names the one on screen. A dot says another of the bot's conversations needs a
* look; a team chat says who can read it with one quiet glyph. */
-export function ChatHeadPill({ bot, avatar, privacy, onToggle, tabsAbove = false }: {
+export function ChatHeadPill({ bot, avatar, privacy, onToggle }: {
bot: Bot;
- tabsAbove?: boolean;
avatar: Pick<ComponentProps<typeof BotAvatar>, "state" | "motion" | "motionKey" | "animated">;
privacy: ChatHeadPrivacy;
onToggle: () => void;
@@ -49,7 +47,6 @@ export function ChatHeadPill({ bot, avatar, privacy, onToggle, tabsAbove = false
const conversation = !awayFromMainThread(bot, false) ? (privacy?.kind === "shared" ? t("task.sharedChat") : null)
: !title || title === UNTITLED ? t("task.untitledChat") : localizedTaskTitle(title);
const label = t("chat.openProfileAria", { name: bot.name });
- const tabsName = useThreadTabsShown(bot.id) && tabsAbove;
return (
<button
type="button"
@@ -66,8 +63,8 @@ export function ChatHeadPill({ bot, avatar, privacy, onToggle, tabsAbove = false
<span dir="auto" className="min-w-0 truncate text-[14px] font-medium leading-5">{bot.name}</span>
{conversation && (
<>
- <ChevronRight size={12} aria-hidden="true" className={cn("shrink-0 text-ink-tertiary", tabsName && "md:hidden")} />
- <span data-chathead-conversation dir="auto" className={cn(tabsName && "md:hidden", "min-w-0 max-w-[180px] truncate text-[14px] font-medium leading-5 text-ink-secondary")}>{conversation}</span>
+ <ChevronRight size={12} aria-hidden="true" className="shrink-0 text-ink-tertiary" />
+ <span data-chathead-conversation dir="auto" className="min-w-0 max-w-[180px] truncate text-[14px] font-medium leading-5 text-ink-secondary">{conversation}</span>
</>
)}
{privacyLabel && (
diff --git a/src/components/ChatView.tsx b/src/components/ChatView.tsx
index 71f53add06..8c4a1a972b 100644
--- a/src/components/ChatView.tsx
+++ b/src/components/ChatView.tsx
@@ -88,7 +88,7 @@ import { ScreenFrame } from "./ScreenFrame";
import { CompactionChip, DigestChip } from "./DigestChip";
import { RenameTitle } from "./RenameTitle"; import { ChatHeadRole, chiefOfStaffBadge } from "./BotRole";
import { BotActivityPicker } from "./TaskPicker"; import { ChatHeadPill } from "./ChatHeadPill"; import { HeaderShare } from "./bot-access/HeaderShare"; import { ThreadPresenceFaces } from "./TeamPresence"; import { useStoreRef } from "@/state/store-ref"; import { sameFields, useStoreDispatch, useStoreSelector } from "@/state/store-select"; import { sameDrawnBots } from "@/lib/drawn-bots"; import { ChatActivityControls, chatActivityMessages, useChatActivity } from "./ChatActivity";
-import { ELEVATED_FLOAT, ELEVATED_HOVER } from "./elevated"; import { NewThreadHeaderButton } from "./NewThreadHeaderButton"; import { ThreadTabStrip } from "./ThreadTabStrip";
+import { ELEVATED_FLOAT, ELEVATED_HOVER } from "./elevated"; import { NewThreadHeaderButton } from "./NewThreadHeaderButton"; import { HeaderThreadTabs, useThreadTabsShown } from "./HeaderThreadTabs";
import { ModelPicker } from "./ModelPicker"; import { useFailedTurnFix } from "./FailedTurnFix";
import { ChatHeaderMenu, ChatMoreMenu } from "./ChatMoreMenu"; import { TeamOwnHelperHeader, TeamPrivateFirstLine, TeamPrivateHeader, TeamSharedHeader } from "./TeamPrivateChatsLine"; import { ownChatStarted } from "@/state/team-chats"; import { isNewChatThread } from "@/state/new-chat";
import { useChatFindRequests, useChatFindShortcut } from "@/lib/chat-find";
@@ -757,7 +757,7 @@ export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = fal
const advanced = useAdvancedMode(), activity = useChatActivity(), skillBurger = useFeature("skillBurger");
const phone = useMediaQuery(PHONE_LAYOUT);
const phoneMenu = phone && !remoteClient;
- const simpleHead = !advanced && !remoteClient;
+ const simpleHead = !advanced && !remoteClient, headTabs = useThreadTabsShown(bot.id) && !inForkPanel;
const canWrite = useCanWriteIn(bot.threadId, bot.yourAccess), mayWrite = canWrite !== false;
const computerStarting = computerStartLine(state.computerStart, bot.name); useScreensWhile(Boolean(computerStarting));
@@ -920,12 +920,12 @@ export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = fal
return (
<ThreadLinkContext value={threadLink}>
<main data-look="chat" className="relative flex h-full min-w-0 flex-1 flex-col bg-app">
- <ChatBackdrop /><CallOverlay bot={bot} />{!inForkPanel && <ThreadTabStrip bot={bot} />}
+ <ChatBackdrop /><CallOverlay bot={bot} />
<GlassScrollFrame className="flex-1 [--glass-tint:var(--color-app)]">
{/* z-[25]: above the room set-up card (z-20), below the CallOverlay (z-30). */}
<GlassBar edge="top" fade={!remoteClient} data-chathead-float={simpleHead ? "" : undefined} className="z-[25]">
<div
- {...headerDragProps} data-look="chat-header"
+ {...headerDragProps} data-look="chat-header" data-chathead-tabs={headTabs ? (simpleHead ? "simple" : "advanced") : undefined}
className={cn(
// A container query never matches the container itself, so the row that wraps is the child below.
"@container/chathead",
@@ -933,10 +933,10 @@ export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = fal
)}
>
<div data-chathead-row className={cn("flex items-center justify-between", phone ? "gap-2" : "@max-[30rem]/chathead:flex-wrap @max-[30rem]/chathead:gap-y-1 @min-[30rem]/chathead:grid @min-[30rem]/chathead:grid-cols-[minmax(0,1fr)_minmax(0,auto)_minmax(max-content,1fr)]")}>{advanced && !inForkPanel && <ChatActivityControls key={bot.threadId} activity={activity} botId={bot.id} style={headerNoDragStyle} />}
- <div data-chathead-identity className={cn("flex min-w-0 items-center gap-2", phone ? "flex-1" : "@max-[30rem]/chathead:basis-full @min-[30rem]/chathead:col-start-2 @min-[30rem]/chathead:justify-self-center", simpleHead && phone && "justify-center")} style={headerNoDragStyle}>
+ <div data-chathead-identity className={cn("flex min-w-0 items-center gap-2", phone ? "flex-1" : "@max-[30rem]/chathead:basis-full @min-[30rem]/chathead:col-start-2 @min-[30rem]/chathead:justify-self-center", simpleHead && phone && "justify-center")} style={headerNoDragStyle}>{headTabs && <HeaderThreadTabs bot={bot} />}
{simpleHead ? (
<ChatHeadPill
- bot={bot} tabsAbove={!inForkPanel}
+ bot={bot}
avatar={{ state: stateForBot({ ...bot, messages }), motion: headerMotion, motionKey: mascotMotion?.nonce ?? 0, animated: headerAnimated }}
privacy={privateChat ? { kind: "private" } : ownHelper ? { kind: "ownHelper" } : sharedChat && team ? { kind: "shared", team: team.name, onlyPeopleAdded: bot.onlyPeopleAdded, sharedWith: currentTask?.sharedWith?.name } : null}
onToggle={() => dispatch({ type: "toggleSettings", open: !state.settingsOpen })}
@@ -1069,7 +1069,7 @@ export const ChatView = memo(function ChatView({ bot: profile, inForkPanel = fal
<div
ref={scrollRef}
- className="glass-scroller h-full overflow-x-hidden overflow-y-auto overscroll-y-contain px-4 [overflow-anchor:none]" data-top-fade={simpleHead ? "" : undefined}
+ className="glass-scroller h-full overflow-x-hidden overflow-y-auto overscroll-y-contain px-4 [overflow-anchor:none]" data-top-fade={simpleHead && !headTabs ? "" : undefined}
// Simple mode's composer sits on plain canvas, so a row scrolled into view stops clear of it.
style={advanced ? undefined : { scrollPaddingBottom: composerDock.pad }}
{...scrollHandlers}
diff --git a/src/components/ThreadTabStrip.dom.test.ts b/src/components/HeaderThreadTabs.dom.test.ts
similarity index 97%
rename from src/components/ThreadTabStrip.dom.test.ts
rename to src/components/HeaderThreadTabs.dom.test.ts
index ec7e26a8a8..bc6cfc53e0 100644
--- a/src/components/ThreadTabStrip.dom.test.ts
+++ b/src/components/HeaderThreadTabs.dom.test.ts
@@ -11,7 +11,7 @@ const store = vi.hoisted(() => ({ state: { bots: [] as unknown[], newChat: null
vi.mock("@/lib/use-feature", () => ({ useFeature: (name: string) => name === "threadTabs" && feature.on }));
vi.mock("@/state/store-select", () => ({ useStoreDispatch: () => dispatch, useStoreSelector: (select: (state: unknown) => unknown) => select(store.state) }));
-import { ThreadTabStrip } from "./ThreadTabStrip";
+import { HeaderThreadTabs } from "./HeaderThreadTabs";
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
@@ -25,7 +25,7 @@ const FIVE = [
let root: Root | null = null;
const render = (bot: Bot) => {
root = createRoot(document.body.appendChild(document.createElement("div")));
- act(() => root!.render(createElement(ThreadTabStrip, { bot })));
+ act(() => root!.render(createElement(HeaderThreadTabs, { bot })));
};
const tabs = () => [...document.querySelectorAll<HTMLElement>('[role="tab"]')];
const tab = (title: string) => tabs().find((element) => element.textContent?.includes(title))!;
diff --git a/src/components/ThreadTabStrip.tsx b/src/components/HeaderThreadTabs.tsx
similarity index 89%
rename from src/components/ThreadTabStrip.tsx
rename to src/components/HeaderThreadTabs.tsx
index aa6c69c6fc..7e3eb4bef2 100644
--- a/src/components/ThreadTabStrip.tsx
+++ b/src/components/HeaderThreadTabs.tsx
@@ -7,26 +7,26 @@ import { localizedTaskTitle } from "@/lib/task-title";
import { useFeature } from "@/lib/use-feature";
import type { Bot } from "@/state/store";
import { useStoreDispatch, useStoreSelector } from "@/state/store-select";
-import { useCaptionChrome, useDesktopCapabilities, windowFramed } from "./DesktopCapabilities";
+import { BotAvatar } from "./Avatar";
import { reducedMotion } from "./MenuMotion";
import { botShowsTabs, neighbourOf, openTabId, showsTabs, threadTabs, type ThreadTab } from "./thread-tabs";
import { useTabMotion } from "./thread-tab-motion";
import { UndoToast, useUndoToast } from "./UndoToast";
-const TAB = "thread-tab group/tab relative flex h-7 min-w-24 max-w-42 shrink items-center rounded-t-xl ps-3 pe-1 text-[13px] leading-[18px] outline-none transition-colors duration-[120ms] focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus motion-reduce:transition-none";
+const TAB = "thread-tab group/tab relative flex h-9 min-w-24 max-w-42 shrink items-center rounded-t-xl ps-3 pe-1 text-[13px] leading-[18px] outline-none transition-colors duration-[120ms] focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus motion-reduce:transition-none";
const CLOSE = "pointer-events-none ms-1 flex size-5 shrink-0 items-center justify-center rounded-full text-ink-tertiary opacity-0 transition-opacity duration-[120ms] hover:bg-ink/[0.08] hover:text-ink group-hover/tab:pointer-events-auto group-hover/tab:opacity-100 group-focus-within/tab:pointer-events-auto group-focus-within/tab:opacity-100 touch:pointer-events-auto touch:opacity-100 motion-reduce:transition-none";
const FADE = 24;
-/** Whether the strip shows for this bot: the chat header then leaves New thread and the open thread's name to it, in
- * windows wide enough for the strip. */
+/** Whether the chat header shows this bot's threads as tabs in place of its pill and New thread, in windows wide enough
+ * for them. */
export function useThreadTabsShown(botId: string): boolean {
const on = useFeature("threadTabs");
const shown = useStoreSelector((state) => botShowsTabs(state.bots.find((bot) => bot.id === botId), state.newChat));
return on && shown;
}
-/** A bot's threads as tabs above its chat, once Thread tabs is on and the bot has two threads or more. */
-export function ThreadTabStrip({ bot }: { bot: Bot }) {
+/** A bot's threads as tabs in the chat header, once Thread tabs is on and the bot has two threads or more. */
+export function HeaderThreadTabs({ bot }: { bot: Bot }) {
const on = useFeature("threadTabs");
const tabs = useMemo(() => threadTabs(bot), [bot.id, bot.threadId, bot.switchingTo, bot.mainThreadId, bot.tasks, bot.busy]);
if (!on || !showsTabs(tabs)) return null;
@@ -45,9 +45,7 @@ function edgeFade(element: HTMLElement): string | undefined {
function Strip({ bot, tabs }: { bot: Bot; tabs: ThreadTab[] }) {
const dispatch = useStoreDispatch();
- const { dragProps } = useCaptionChrome();
- const { capabilities } = useDesktopCapabilities();
- const underCaptionButtons = capabilities.windowChrome === "win-caption" && !windowFramed(capabilities);
+ const panelOpen = useStoreSelector((state) => state.settingsOpen);
const scroller = useRef<HTMLDivElement>(null);
const { shown, entering } = useTabMotion(tabs, scroller);
const active = openTabId(bot);
@@ -136,10 +134,15 @@ function Strip({ bot, tabs }: { bot: Bot; tabs: ThreadTab[] }) {
};
return (
- <div data-thread-tabs={bot.id} {...dragProps} className={cn("thread-strip relative z-[1] flex h-9 shrink-0 items-end max-md:hidden", underCaptionButtons && "pe-36")}>
+ <div data-thread-tabs={bot.id} className="flex h-9 min-w-0 flex-1 items-center max-md:hidden">
+ <button type="button" data-thread-tabs-bot aria-label={t("chat.openProfileAria", { name: bot.name })} title={t("chat.openBotPanel")} aria-expanded={panelOpen}
+ onClick={() => dispatch({ type: "toggleSettings", open: !panelOpen })}
+ className="flex size-7 shrink-0 items-center justify-center rounded-full transition-colors duration-[120ms] hover:bg-ink/[0.06] active:bg-ink/[0.08] motion-reduce:transition-none">
+ <BotAvatar bot={bot} size={16} />
+ </button>
<div ref={scroller} role="tablist" aria-label={t("task.namedList", { name: bot.name })} onKeyDown={onKey} onScroll={measure} onWheel={scrollSideways}
style={{ maskImage: fade, WebkitMaskImage: fade }}
- className="flex min-w-0 items-end overflow-x-auto overflow-y-hidden px-3 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
+ className="flex h-9 min-w-0 items-end overflow-x-auto overflow-y-hidden px-3 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
{shown.map((tab) => {
const selected = tab.threadId === active && !tab.leaving;
const title = tab.draft ? t("task.newShort") : localizedTaskTitle(tab.title);
diff --git a/src/components/NewThreadHeaderButton.tsx b/src/components/NewThreadHeaderButton.tsx
index e9faaa6437..5fede89f35 100644
--- a/src/components/NewThreadHeaderButton.tsx
+++ b/src/components/NewThreadHeaderButton.tsx
@@ -2,7 +2,7 @@ import { Plus } from "lucide-react";
import { t } from "@/lib/i18n";
import { cn } from "@/lib/cn";
import { useStoreDispatch } from "@/state/store-select";
-import { useThreadTabsShown } from "./ThreadTabStrip";
+import { useThreadTabsShown } from "./HeaderThreadTabs";
export function NewThreadHeaderButton({ botId }: { botId: string }) {
const dispatch = useStoreDispatch();
diff --git a/src/styles.css b/src/styles.css
index 9b7887de05..1923030b66 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -3898,9 +3898,18 @@ button:disabled.bg-danger {
.burger-fold > ol { overflow: hidden auto; }
@media (prefers-reduced-motion: reduce) { .burger-fold { transition: none; } }
:root[data-reduced-motion="true"] .burger-fold { transition: none; }
-/* Thread tabs: the strip is the chat's ground with a touch of ink, and the open tab is the chat's own ground, so it runs into the chat below, and its foot curves out into the
- strip on both sides. Separators sit between closed tabs only, and give way under the pointer. */
-.thread-strip { background-color: color-mix(in srgb, var(--color-ink) 4%, var(--color-app)); }
+/* Thread tabs: from tablet width up, the chat header becomes one band in the chat's ground with a touch of ink, whose
+ tabs replace the pill and stand on its bottom edge; the open tab is the chat's own ground, so it runs into the chat
+ below, and its foot curves out into the band on both sides. Separators sit between closed tabs only. */
+@media (min-width: 768px) {
+ [data-chathead-tabs] { background-color: color-mix(in srgb, var(--color-ink) 4%, var(--color-app)); padding-top: 12px; padding-bottom: 0; }
+ [data-chathead-tabs="advanced"] { padding-top: 6px; }
+ [data-chathead-tabs] [data-chathead-row] { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; }
+ [data-chathead-tabs] [data-chathead-identity] { grid-column: 2; justify-self: stretch; align-self: stretch; -webkit-app-region: drag !important; }
+ [data-chathead-tabs] [data-chathead-identity] > :not([data-thread-tabs], [data-chathead-status]) { display: none; }
+ [data-chathead-tabs="advanced"] [data-chathead-identity] { margin-inline-start: 8px; }
+ [data-chathead-tabs] [data-chathead-controls] { grid-column: 3; margin-inline-start: 8px; }
+}
.thread-tab[aria-selected="true"] { background: var(--color-app); }
.thread-tab[aria-selected="true"]::before,
.thread-tab[aria-selected="true"]::after {