Skip to content

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

Threads: Ctrl+Tab switches a bot's threads; pinned threads stay under the bot; the sidebar's Pinned threads box goes (#7314)

Milind Soni7090651c88f0
diff --git a/src/App.tsx b/src/App.tsx
index c0b4488c4a..838c27cfa9 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -74,6 +74,7 @@ import { engineReady } from "@/components/EngineLibrary";
import { CommandPalette } from "@/components/CommandPalette";
import { t } from "@/lib/i18n";
import { botCycleStep, shouldOpenKeyboardShortcuts } from "@/lib/keyboard-shortcuts";
+import { useThreadCycleKeys } from "@/components/thread-cycle";
import { effectiveLanguage, useLanguageChoice, usePageLanguage } from "@/lib/language-preference";
import { botUnreadCount, showBrowserUnread } from "@/lib/bot-unread";
import { phonePairingSettingsAction, takePhonePairingRequest } from "@/lib/phone-pairing"; import { useConnectLink } from "@/lib/use-connect-link";
@@ -280,6 +281,7 @@ function Shell({ viewer }: { viewer: WelcomeViewer | null }) {
return () => window.removeEventListener("keydown", onKey);
}, [state.bots, state.selectedId, state.shortcutsOpen, showThreads, dispatch]);
+ useThreadCycleKeys();
useReadShownChatOnFocus();
useEffect(() => {
if (window.ogb?.setUnreadCount) window.ogb.setUnreadCount(unreadCount);
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index d7930f4bd1..ebe9cd63a5 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -22,7 +22,7 @@ import { copyText } from "@/lib/copy-text";
import type { LocaleKey } from "@/locales";
import { ConfirmDialog } from "./ConfirmDialog";
import { BulkSelectFilters, ThreadListFooter, deleteThreadsInBulk, retitleThreadsInBulk, useBulkSelect } from "./BulkSelectBar";
-import { SidebarThreadLabels, ThreadFoldChevron, useRowUnfolded } from "./SidebarThreadLabels";
+import { SidebarThreadLabels, ThreadFoldChevron, useFillOnLabel } from "./SidebarThreadLabels";
import { RoomMark, StackedMauses } from "./StackedMauses";
import { LocalComputerAutoWarning } from "./LocalComputerAutoWarning";
import { nextRename } from "@/lib/rename";
@@ -46,7 +46,6 @@ import {
BOTS_SECTION_ID,
CHANNELS_SECTION_ID,
PINNED_SECTION_ID,
- PINNED_THREADS_SECTION_ID,
TOOLS_SECTION_ID,
UNREAD_SECTION_ID,
partitionSidebarBots,
@@ -87,7 +86,7 @@ import { isSidebarToggle } from "@/lib/keyboard-shortcuts";
import { SidebarRailSeparator, SimpleRailFooter } from "./SidebarSimpleRail";
import { useShowThreads } from "@/lib/thread-preferences";
import { useBotUnread, useUnreadHold } from "./unread-notice";
-import { attentionHasRunningWork, attentionJumpAction, attentionUnpinAction, crossBotAttentionThreads, crossBotPinnedThreads, hasCrossBotRunningWork, runningRoutineRun, SidebarBotActivity, sidebarBotActivityTasks, sidebarBotStatus } from "./SidebarBotActivity";
+import { attentionHasRunningWork, attentionJumpAction, crossBotAttentionThreads, hasCrossBotRunningWork, runningRoutineRun, SidebarBotActivity, sidebarBotActivityTasks, sidebarBotStatus } from "./SidebarBotActivity";
import { SidebarNoBots, SidebarTileGrid } from "./SidebarTiles";
import { BotContextMenu } from "./SidebarBotMenu";
export { BotContextMenu };
@@ -95,7 +94,6 @@ import { AvatarActivityDot, AvatarCornerDot, RowDot, RowStatusText, rowSelectedS
import { SidebarAttentionPanel } from "./SidebarAttentionPanel";
-import { SidebarPinnedThreadsPanel } from "./SidebarPinnedThreadsPanel";
import { useLiveMedia } from "@/lib/live-call-media";
import { LiveCallPill, liveBadgeFor } from "./LiveCallPill";
import { ShortcutHint } from "./ShortcutHint";
@@ -711,7 +709,7 @@ export const BotListItem = memo(function BotListItem(props: BotRowProps) {
const iconOnly = density === "icons";
const expanded = showThreads && !iconOnly && threadsOpen && hasThreadList;
useEffect(() => { if (iconOnly) setRenaming(false); }, [iconOnly]);
- const simpleRow = !advanced && !showThreads && density === "comfortable", unfolded = useRowUnfolded(bot, props.drafting) && simpleRow, rowSelected = selected && !unfolded;
+ const simpleRow = !advanced && !showThreads && density === "comfortable", fillOnLabel = useFillOnLabel(bot, props.drafting) && simpleRow, rowSelected = selected && !fillOnLabel;
const simpleList = !advanced && !iconOnly;
const railTile = iconOnly && !advanced;
const avatarSize = iconOnly ? (railTile ? 36 : 44) : showThreads ? 32 : simpleRow ? 36 : 44;
@@ -1124,7 +1122,6 @@ export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons =
const archivedEntry = remoteClient ? undefined : { count: archivedBots.length, open: () => setArchivedBotsOpen(true) };
const showAttention = (advanced && inboxSupport === "no") || (attentionPinned && density !== "icons");
const attention = showAttention ? crossBotAttentionThreads(state.bots, state.pendingQueued, undefined, state.groups) : [];
- const pinnedThreads = crossBotPinnedThreads(state.bots, state.groups, state.pendingQueued);
const pendingBotUndo = teamFeedback?.restoreBot;
const botRow = (bot: Bot) => botRowProps(state, dispatch, bot, { density, query: q, onMenu: setMenu, renameRequest: renameRequest?.botId === bot.id ? renameRequest.nonce : 0, ...drops.row(bot.id) });
const railSearch = () => {
@@ -1343,15 +1340,6 @@ export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons =
/>
)}
- {density !== "icons" && (
- <SidebarPinnedThreadsPanel
- entries={pinnedThreads}
- onJump={(entry) => dispatch(attentionJumpAction(entry))}
- onUnpin={(entry) => dispatch(attentionUnpinAction(entry))}
- collapsed={sectionCollapsed(PINNED_THREADS_SECTION_ID)}
- onToggle={layoutInteractive ? () => toggleSection(PINNED_THREADS_SECTION_ID) : undefined}
- />
- )}
{tiles && <SidebarTileGrid primary={primary} pinned={pinnedBots} row={botRow} corner={corner} />}
{simpleDesk && !tiles && <SidebarNoBots />}
</GlassBar>
diff --git a/src/components/SidebarBotActivity.tsx b/src/components/SidebarBotActivity.tsx
index d1dca614b5..a6fe695ffd 100644
--- a/src/components/SidebarBotActivity.tsx
+++ b/src/components/SidebarBotActivity.tsx
@@ -1,10 +1,10 @@
-import { BellDot, CircleAlert, Clock3, Loader2, Pin, PinOff, type LucideIcon } from "lucide-react";
+import { BellDot, CircleAlert, Clock3, Loader2, Pin, type LucideIcon } from "lucide-react";
import type { Dispatch } from "react";
import type { Action, AppState, Bot, Group, Task } from "@/state/store";
import { cn } from "@/lib/cn";
import { roomThreadSpeakerId, roomThreadWorking } from "@/lib/room-threads";
import { t } from "@/lib/i18n";
-import { isArchived, orderedSidebarThreads, orderedThreadList, threadRecency, threadUpdatedLabel } from "./SidebarThreadRow";
+import { isArchived, orderedSidebarThreads, orderedThreadList } from "./SidebarThreadRow";
import type { SidebarDensity } from "@/lib/sidebar-preferences";
import { localizedTaskTitle } from "@/lib/task-title";
import { endedOnFailure } from "@/lib/mascot";
@@ -214,36 +214,6 @@ export function AttentionThreadRows({ entries, onJump, inset = false, unreadDot
</>;
}
-export function PinnedThreadRows({ entries, now, onJump, onUnpin }: { entries: AttentionThread[]; now: number; onJump: (entry: AttentionThread) => void; onUnpin: (entry: AttentionThread) => void }) {
- return <>
- {entries.map((entry) => {
- const name = attentionOwnerName(entry);
- const status = attentionRowStatus(entry.task);
- const updated = threadUpdatedLabel(threadRecency(entry.task), now);
- const byline = status.active ? `${name} · ${status.label}` : updated ? `${name} · ${updated}` : name;
- const label = t("sidebar.pinnedThreads.item", { title: entry.task.title, name: byline });
- const unpinLabel = t("sidebar.bot.unpin");
- const key = `${entry.kind}-${entry.kind === "bot" ? entry.botId : entry.groupId}-${entry.task.threadId}`;
- const Icon = status.active ? status.Icon : Pin;
- return <div key={key} className="group/pinned flex w-full items-center">
- <button type="button" aria-label={label} title={label}
- onClick={() => onJump(entry)}
- className="flex min-w-0 flex-1 items-center gap-2.5 px-3.5 py-2 text-left text-[13px] text-ink hover:bg-menu-hover">
- <Icon size={15} aria-hidden="true" className={cn("shrink-0", status.active ? status.colorClass : "text-ink-secondary")} />
- <span className="min-w-0 flex-1">
- <span className="block truncate">{entry.task.title}</span>
- <span className="block truncate text-[12px] leading-4 text-ink-secondary">{byline}</span>
- </span>
- </button>
- <button type="button" aria-label={unpinLabel} title={unpinLabel} onClick={() => onUnpin(entry)}
- className="mr-2 flex size-6 shrink-0 items-center justify-center rounded text-ink-secondary opacity-0 hover:bg-raised hover:text-ink focus-visible:opacity-100 group-hover/pinned:opacity-100 max-md:opacity-70 touch:opacity-70">
- <PinOff size={13} aria-hidden="true" />
- </button>
- </div>;
- })}
- </>;
-}
-
/** runsOnly: the open thread tree already lists the rest, so only a running routine's row is added. */
export function SidebarBotActivity({ bot, rowThreadId, density, pendingQueued, dispatch, waitingOnly = false, runsOnly = false }: { bot: Bot; rowThreadId: string; density: SidebarDensity; pendingQueued: AppState["pendingQueued"]; dispatch: Dispatch<Action>; waitingOnly?: boolean; runsOnly?: boolean }) {
const others = runsOnly ? [] : (waitingOnly ? threadsWaitingOnPerson : threadsWhenTreeHidden)(bot, pendingQueued);
diff --git a/src/components/SidebarPinnedThreadsPanel.test.ts b/src/components/SidebarPinnedThreadsPanel.test.ts
deleted file mode 100644
index 41d5426603..0000000000
--- a/src/components/SidebarPinnedThreadsPanel.test.ts
+++ /dev/null
@@ -1,138 +0,0 @@
-import { Children, createElement, isValidElement, type MouseEvent, type ReactElement, type ReactNode } from "react";
-import { renderToStaticMarkup } from "react-dom/server";
-import { describe, expect, it, vi } from "vitest";
-
-import { t } from "@/lib/i18n";
-import { PinnedThreadRows, type AttentionThread } from "./SidebarBotActivity";
-import { SidebarPinnedThreadsPanel } from "./SidebarPinnedThreadsPanel";
-
-const entry: AttentionThread = {
- kind: "bot",
- botId: "atlas",
- botName: "Atlas",
- task: { threadId: "pinned-1", title: "Quarterly plan", createdAt: 1, queued: false },
-};
-
-type ElementProps = { children?: ReactNode; onClick?: (event: MouseEvent) => void; [key: string]: unknown };
-function findElement(tree: ReactNode, attribute: string, value: string): ReactElement<ElementProps> | undefined {
- for (const child of Children.toArray(tree)) {
- if (!isValidElement<ElementProps>(child)) continue;
- if (child.props[attribute] === value) return child;
- const found = findElement(child.props.children, attribute, value);
- if (found) return found;
- }
-}
-
-function renderPanel(
- entries: AttentionThread[] = [entry],
- options: { collapsed?: boolean; onToggle?: () => void; onUnpin?: (entry: AttentionThread) => void } = {},
-) {
- let tree: ReactNode;
- const onJump = vi.fn();
- const onToggle = options.onToggle ?? vi.fn();
- const onUnpin = options.onUnpin ?? vi.fn();
- function Capture() {
- tree = SidebarPinnedThreadsPanel({
- entries,
- now: 1,
- onJump,
- collapsed: options.collapsed ?? false,
- onToggle,
- onUnpin,
- });
- return tree;
- }
- const markup = renderToStaticMarkup(createElement(Capture));
- return { markup, tree: () => tree as ReactNode, onJump, onToggle, onUnpin };
-}
-
-function renderRows(entries: AttentionThread[]) {
- let tree: ReactNode;
- const onJump = vi.fn();
- const onUnpin = vi.fn();
- function Capture() {
- tree = PinnedThreadRows({ entries, now: 1, onJump, onUnpin });
- return tree;
- }
- const markup = renderToStaticMarkup(createElement(Capture));
- return { markup, tree: () => tree as ReactNode, onJump, onUnpin };
-}
-
-describe("pinned threads panel", () => {
- it("renders nothing when there is no pinned thread", () => {
- const { markup } = renderPanel([]);
- expect(markup).toBe("");
- });
-
- it("renders the pinned rows under the Pinned threads name", () => {
- const { markup } = renderPanel();
- expect(markup).toContain(t("sidebar.pinnedThreads.title"));
- expect(markup).toContain("Quarterly plan");
- expect(markup).toContain("Atlas");
- expect(markup).toContain('data-testid="sidebar-pinned-threads-panel"');
- });
-
- it("hides the rows but keeps the header when collapsed", () => {
- const { markup } = renderPanel([entry], { collapsed: true });
- expect(markup).toContain(t("sidebar.pinnedThreads.title"));
- expect(markup).not.toContain("Quarterly plan");
- const label = t("sidebar.section.expand", { name: t("sidebar.pinnedThreads.title") });
- expect(markup).toContain('aria-label="' + label + '"');
- expect(markup).toContain('aria-expanded="false"');
- });
-
- it("toggles from the collapse/expand control", () => {
- const { tree, onToggle } = renderPanel([entry], { collapsed: false });
- const label = t("sidebar.section.collapse", { name: t("sidebar.pinnedThreads.title") });
- findElement(tree(), "aria-label", label)!.props.onClick!({} as MouseEvent);
- expect(onToggle).toHaveBeenCalledOnce();
- });
-
- it("disables collapse when search prevents layout changes", () => {
- const markup = renderToStaticMarkup(createElement(SidebarPinnedThreadsPanel, {
- entries: [entry], now: 1, onUnpin: vi.fn(), onJump: vi.fn(), collapsed: false,
- }));
- expect(markup).toMatch(/<button[^>]+disabled=""[^>]+aria-expanded="true"/);
- expect(markup).toContain("Quarterly plan");
- });
-
-});
-
-describe("pinned thread rows", () => {
- it("shows the plain Pin icon and a time byline for an idle pinned thread", () => {
- const { markup } = renderRows([entry]);
- expect(markup).toContain("lucide-pin ");
- expect(markup).not.toContain("lucide-circle-alert");
- expect(markup).not.toContain("lucide-loader");
- expect(markup).toContain("Atlas · just now");
- });
-
- it("shows the live status icon and word for an actively working pinned thread", () => {
- const working: AttentionThread = {
- kind: "bot", botId: "atlas", botName: "Atlas",
- task: { threadId: "pinned-2", title: "Build report", createdAt: 1, queued: false, busy: true, activity: "working" },
- };
- const { markup } = renderRows([working]);
- expect(markup).toContain("lucide-loader");
- expect(markup).not.toContain("lucide-pin ");
- expect(markup).toContain("Atlas · " + t("chat.activity.working"));
- });
-
- it("shows the waiting icon and word for a pinned thread waiting on the person", () => {
- const waiting: AttentionThread = {
- kind: "bot", botId: "atlas", botName: "Atlas",
- task: { threadId: "pinned-3", title: "Needs approval", createdAt: 1, queued: false, activity: "waiting-on-you" },
- };
- const { markup } = renderRows([waiting]);
- expect(markup).toContain("lucide-circle-alert");
- expect(markup).toContain("Atlas · " + t("task.waiting"));
- });
-
- it("calls onUnpin for the row's own entry, not onJump, from the per-row unpin button", () => {
- const { tree, onUnpin, onJump } = renderRows([entry]);
- const label = t("sidebar.bot.unpin");
- findElement(tree(), "aria-label", label)!.props.onClick!({} as MouseEvent);
- expect(onUnpin).toHaveBeenCalledWith(entry);
- expect(onJump).not.toHaveBeenCalled();
- });
-});
diff --git a/src/components/SidebarPinnedThreadsPanel.tsx b/src/components/SidebarPinnedThreadsPanel.tsx
deleted file mode 100644
index 4361a391df..0000000000
--- a/src/components/SidebarPinnedThreadsPanel.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import { ChevronDown, ChevronRight, Pin } from "lucide-react";
-import { t } from "@/lib/i18n";
-import { PinnedThreadRows, type AttentionThread } from "./SidebarBotActivity";
-import { useRelativeNow } from "./SidebarThreadRow";
-
-type PanelProps = {
- entries: AttentionThread[];
- now?: number;
- onJump: (entry: AttentionThread) => void;
- onUnpin: (entry: AttentionThread) => void;
- collapsed: boolean;
- onToggle?: () => void;
-};
-
-function PinnedThreadsBody({ entries, now, onJump, onUnpin, collapsed, onToggle }: PanelProps & { now: number }) {
- const Chevron = collapsed ? ChevronRight : ChevronDown;
- return (
- <section
- data-testid="sidebar-pinned-threads-panel"
- aria-label={t("sidebar.pinnedThreads.title")}
- className="mx-2 mb-2 overflow-hidden rounded-lg border border-hairline/40 bg-inset/30"
- >
- <div className="flex items-center gap-1.5 px-2.5 pb-1 pt-1.5 text-[12px] font-medium text-ink-secondary">
- <button
- type="button"
- onClick={onToggle}
- disabled={!onToggle}
- aria-expanded={!collapsed}
- aria-label={t(collapsed ? "sidebar.section.expand" : "sidebar.section.collapse", { name: t("sidebar.pinnedThreads.title") })}
- className="flex size-5 shrink-0 items-center justify-center rounded text-ink-secondary hover:bg-raised hover:text-ink"
- >
- <Chevron size={12} aria-hidden="true" />
- </button>
- <Pin size={12} aria-hidden="true" className="shrink-0" />
- <span className="min-w-0 flex-1 truncate">{t("sidebar.pinnedThreads.title")}</span>
- <span className="text-[12px] font-normal tabular-nums">{entries.length}</span>
- </div>
- {!collapsed && (
- <div className="max-h-56 overflow-y-auto">
- <PinnedThreadRows entries={entries} now={now} onJump={onJump} onUnpin={onUnpin} />
- </div>
- )}
- </section>
- );
-}
-
-function LivePinnedThreadsPanel(props: Omit<PanelProps, "now">) {
- return <PinnedThreadsBody {...props} now={useRelativeNow()} />;
-}
-
-export function SidebarPinnedThreadsPanel({ now, ...props }: PanelProps) {
- if (props.entries.length === 0) return null;
- if (now !== undefined) return PinnedThreadsBody({ ...props, now });
- return <LivePinnedThreadsPanel {...props} />;
-}
diff --git a/src/components/SidebarThreadLabels.pins.dom.test.ts b/src/components/SidebarThreadLabels.pins.dom.test.ts
new file mode 100644
index 0000000000..140a333320
--- /dev/null
+++ b/src/components/SidebarThreadLabels.pins.dom.test.ts
@@ -0,0 +1,30 @@
+// @vitest-environment happy-dom
+import { act, createElement } from "react";
+import { createRoot, type Root } from "react-dom/client";
+import { afterEach, beforeEach, expect, it, vi } from "vitest";
+import type { Bot, Task } from "@/state/store";
+import { SidebarThreadLabels } from "./SidebarThreadLabels";
+
+let container: HTMLDivElement, root: Root;
+beforeEach(() => {
+ vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
+ vi.useFakeTimers();
+ container = document.createElement("div"); document.body.append(container); root = createRoot(container);
+});
+afterEach(async () => { await act(async () => root.unmount()); container.remove(); vi.useRealTimers(); vi.unstubAllGlobals(); });
+
+const thread = (threadId: string, extra: Partial<Task> = {}): Task => ({ threadId, title: threadId, createdAt: 1, updatedAt: 1, ...extra });
+const bot = (pinned: boolean) => ({ id: "counsel", name: "Counsel", threadId: "main", messages: [], tasks: [thread("main"), thread("weekly", { pinned: pinned || undefined }), thread("once")] }) as unknown as Bot;
+const show = (pinned: boolean) => act(async () => root.render(createElement(SidebarThreadLabels, { bot: bot(pinned), selected: false, rowThreadId: "main", pendingQueued: {}, dispatch: () => {} })));
+const row = () => container.querySelector('[data-thread-label="weekly"]');
+
+it("keeps a pinned thread under its folded bot, marked, and folds it away with the fold motion once unpinned", async () => {
+ await show(true);
+ expect(row()?.textContent).toContain("weekly");
+ expect(row()?.querySelector('[aria-label="Pinned"]')).not.toBeNull();
+ expect(container.querySelector('[data-thread-label="once"]')).toBeNull();
+ await show(false);
+ expect(row()?.className).toContain("animate-pop-out");
+ await act(async () => { vi.advanceTimersByTime(250); });
+ expect(row()).toBeNull();
+});
diff --git a/src/components/SidebarThreadLabels.tsx b/src/components/SidebarThreadLabels.tsx
index 3c207907e0..a827f8c20d 100644
--- a/src/components/SidebarThreadLabels.tsx
+++ b/src/components/SidebarThreadLabels.tsx
@@ -1,5 +1,5 @@
import { useLayoutEffect, useRef, useState, type Dispatch, type KeyboardEvent as ReactKeyboardEvent } from "react";
-import { ChevronRight, Clock3, Loader2, Plus, X } from "lucide-react";
+import { ChevronRight, Clock3, Loader2, Pin, Plus, X } from "lucide-react";
import { cn } from "@/lib/cn";
import { t } from "@/lib/i18n";
import { nextRename } from "@/lib/rename";
@@ -7,7 +7,7 @@ import { localizedTaskTitle } from "@/lib/task-title";
import { setThreadsUnfolded, useThreadsUnfolded } from "@/lib/thread-fold-preferences";
import type { Action, AppState, Bot } from "@/state/store";
import { botOpensTo } from "@/state/thread-navigation";
-import { canUnfold, threadLabels, type LabelRow } from "./sidebar-thread-labels";
+import { canUnfold, openThreadPinned, threadLabels, type LabelRow } from "./sidebar-thread-labels";
import { isWorking } from "./SidebarThreadRow";
import { showAllConversations } from "./bot-panel/Conversations";
import { reducedMotion } from "./MenuMotion";
@@ -26,6 +26,7 @@ const STAGGER_STEPS = 3;
const YIELDS = "group-hover/label:[mask-image:linear-gradient(to_left,transparent_20px,black_36px)] rtl:group-hover/label:[mask-image:linear-gradient(to_right,transparent_20px,black_36px)]";
type FoldBot = Pick<Bot, "id" | "name" | "tasks">;
+type FillBot = FoldBot & Pick<Bot, "threadId" | "switchingTo">;
export const threadLabelsId = (botId: string) => `thread-labels-${botId}`;
@@ -46,10 +47,10 @@ export function ThreadFoldChevron({ bot, dispatch }: { bot: FoldBot; dispatch: D
);
}
-/** Whether one of the bot's unfolded rows carries the selected fill instead of its row: not while its blank New thread
- * chat (`drafting`) is open, which has no row of its own yet. */
-export function useRowUnfolded(bot: FoldBot, drafting = false): boolean {
- return useThreadsUnfolded(bot.id) && canUnfold(bot) && !drafting;
+/** Whether one of the rows under the bot carries the selected fill instead of its row (it is unfolded, or the open thread
+ * is pinned): not while its blank New thread chat (`drafting`) is open, which has no row of its own yet. */
+export function useFillOnLabel(bot: FillBot, drafting = false): boolean {
+ return ((useThreadsUnfolded(bot.id) && canUnfold(bot)) || openThreadPinned(bot)) && !drafting;
}
function StatusMark({ row }: { row: LabelRow }) {
@@ -76,17 +77,21 @@ export function SidebarThreadLabels({ bot, selected, drafting = false, rowThread
const [focusAt, setFocusAt] = useState<number | null>(null);
const finishing = useRef(false);
const tree = useRef<HTMLDivElement>(null);
- // Folding plays the unfold backwards: the rows that go fade out in place before the list shortens.
+ // Folding plays the unfold backwards: the rows that go fade out in place before the list shortens. So does a row
+ // that leaves because it was unpinned.
const shown = useRef({ unfolded, rows, more });
const [leaving, setLeaving] = useState<{ rows: LabelRow[]; gone: ReadonlySet<string>; more: number } | null>(null);
+ const pins = rows.filter((row) => row.pinned).map((row) => row.task.threadId).join("\n");
useLayoutEffect(() => {
const was = shown.current;
- if (!was.unfolded || unfolded || reducedMotion()) { setLeaving(null); return; }
const kept = new Set(rows.map((row) => row.task.threadId));
- setLeaving({ rows: was.rows, gone: new Set(was.rows.filter((row) => !kept.has(row.task.threadId)).map((row) => row.task.threadId)), more: was.more });
+ const folding = was.unfolded && !unfolded;
+ const gone = was.rows.filter((row) => !kept.has(row.task.threadId) && (folding || row.pinned));
+ if (!gone.length || reducedMotion()) { setLeaving(null); return; }
+ setLeaving({ rows: was.rows, gone: new Set(gone.map((row) => row.task.threadId)), more: was.more });
const timer = window.setTimeout(() => setLeaving(null), FOLD_MS);
return () => window.clearTimeout(timer);
- }, [unfolded]);
+ }, [unfolded, pins]);
useLayoutEffect(() => { shown.current = { unfolded, rows, more }; });
if (!rows.length && !more && !runningMore && !toast && !leaving) return null;
@@ -168,9 +173,14 @@ export function SidebarThreadLabels({ bot, selected, drafting = false, rowThread
}}
className="-ms-1.5 h-7 min-w-0 flex-1 rounded-md border border-focus bg-transparent px-1.5 text-[13px] text-ink outline-none" />
) : <>
- <span dir="auto" className={cn("min-w-0 flex-1 truncate", hideable(row) && YIELDS)}>{title}</span>
+ <span className={cn("flex min-w-0 flex-1 items-center gap-1.5", hideable(row) && YIELDS)}>
+ <span dir="auto" className="min-w-0 truncate">{title}</span>
+ {row.pinned && <Pin size={10} role="img" aria-label={t("task.pinned")} className="shrink-0 text-ink-tertiary" />}
+ </span>
{row.task.threadId === bot.mainThreadId && <MainThreadMark />}
- <span className={cn("flex shrink-0 items-center", hideable(row) && "transition-opacity duration-[120ms] group-hover/label:opacity-0 motion-reduce:transition-none")}><StatusMark row={row} /></span>
+ <span className={cn("flex shrink-0 items-center", hideable(row) && "transition-opacity duration-[120ms] group-hover/label:opacity-0 motion-reduce:transition-none")}>
+ <StatusMark row={row} />
+ </span>
{hideable(row) && (
<button type="button" tabIndex={-1} aria-label={t("sidebar.threads.hide", { title })} title={t("sidebar.threads.hideShort")}
onClick={(event) => { event.stopPropagation(); hide(row); }}
diff --git a/src/components/sidebar-thread-labels.test.ts b/src/components/sidebar-thread-labels.test.ts
index ec046cea1d..05375f6b14 100644
--- a/src/components/sidebar-thread-labels.test.ts
+++ b/src/components/sidebar-thread-labels.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import type { Task } from "@/state/store";
-import { canUnfold, threadLabels } from "./sidebar-thread-labels";
+import { canUnfold, openThreadPinned, threadLabels } from "./sidebar-thread-labels";
const DAY = 24 * 60 * 60 * 1000;
const NOW = 100 * DAY;
@@ -69,4 +69,43 @@ describe("a bot's threads under its sidebar row", () => {
expect(folded.rows).toHaveLength(3);
expect(folded.runningMore).toBe(2);
});
+
+ it("folded, keeps the pinned threads listed first, above running ones, each once", () => {
+ const working = { busy: true, activity: "working" as const };
+ const tasks = [thread("main", 1), thread("lease", 2, working), thread("weekly", 40, { pinned: true, lastThreadOrderAt: NOW - 40 * DAY }),
+ thread("brief", 30, { pinned: true, ...working, lastThreadOrderAt: NOW - 5 * DAY }), thread("once", 3)];
+ const folded = threadLabels(bot(tasks), {}, { unfolded: false, rowThreadId: "main", now: NOW });
+ expect(ids(folded)).toEqual(["brief", "weekly", "lease"]);
+ expect(folded.rows.map((row) => row.pinned)).toEqual([true, true, false]);
+ expect(folded.rows[0]!.status).toBe("working");
+ });
+
+ it("unpinned, a quiet thread folds away again", () => {
+ const tasks = [thread("main", 1), thread("weekly", 40, { pinned: true }), thread("once", 3)];
+ expect(ids(threadLabels(bot(tasks), {}, { unfolded: false, rowThreadId: "main", now: NOW }))).toEqual(["weekly"]);
+ const unpinned = tasks.map((task) => task.threadId === "weekly" ? { ...task, pinned: undefined } : task);
+ expect(ids(threadLabels(bot(unpinned), {}, { unfolded: false, rowThreadId: "main", now: NOW }))).toEqual([]);
+ });
+
+ it("keeps the open pinned thread listed, where it carries the selected fill", () => {
+ const tasks = [thread("main", 1), thread("weekly", 40, { pinned: true })];
+ const folded = threadLabels(bot(tasks, "weekly"), {}, { unfolded: false, current: "weekly", rowThreadId: "weekly", now: NOW });
+ expect(ids(folded)).toEqual(["weekly"]);
+ expect(folded.rows[0]!.current).toBe(true);
+ expect(openThreadPinned(bot(tasks, "weekly"))).toBe(true);
+ expect(openThreadPinned(bot(tasks, "main"))).toBe(false);
+ });
+
+ it("unfolded, lists pins beyond the four active ones and leaves them out of the count", () => {
+ const tasks = [thread("main", 1), thread("a", 1), thread("b", 2), thread("c", 3), thread("d", 4), thread("old", 30, { pinned: true })];
+ const open = threadLabels(bot(tasks), {}, { unfolded: true, rowThreadId: "main", now: NOW });
+ expect(ids(open)).toEqual(["old", "main", "a", "b", "c"]);
+ expect(open.more).toBe(1);
+ });
+
+ it("lists no pin for a bot whose only open thread it is, nor an archived or snoozed pin", () => {
+ expect(ids(threadLabels(bot([thread("main", 1, { pinned: true })]), {}, { unfolded: false, rowThreadId: "main", now: NOW }))).toEqual([]);
+ const tasks = [thread("main", 1), thread("gone", 2, { pinned: true, archivedAt: 5 }), thread("later", 2, { pinned: true, snoozedUntil: 0 })];
+ expect(ids(threadLabels(bot(tasks), {}, { unfolded: false, rowThreadId: "main", now: NOW }))).toEqual([]);
+ });
});
diff --git a/src/components/sidebar-thread-labels.ts b/src/components/sidebar-thread-labels.ts
index 701a94c4df..5e8c9ac809 100644
--- a/src/components/sidebar-thread-labels.ts
+++ b/src/components/sidebar-thread-labels.ts
@@ -1,7 +1,7 @@
import type { Bot, Task } from "@/state/store";
import { botOpensTo } from "@/state/thread-navigation";
import { runningRoutineRuns, sidebarBotActivityTasks } from "./SidebarBotActivity";
-import { isArchived, isSnoozed, isWorking, threadRecency } from "./SidebarThreadRow";
+import { isArchived, isSnoozed, isWorking, orderedThreadList, threadRecency } from "./SidebarThreadRow";
export const ACTIVE_DAYS = 7;
export const ACTIVE_LIMIT = 4;
@@ -10,7 +10,7 @@ const DAY_MS = 24 * 60 * 60 * 1000;
export type LabelStatus = "waiting" | "working" | "teammate" | "queued" | "unread" | null;
export type LabelTask = Task & { queued?: boolean };
-export interface LabelRow { task: LabelTask; status: LabelStatus; current: boolean; main: boolean }
+export interface LabelRow { task: LabelTask; status: LabelStatus; current: boolean; main: boolean; pinned: boolean }
export interface ThreadLabels { rows: LabelRow[]; more: number; runningMore: number }
type LabelBot = Pick<Bot, "threadId"> & Partial<Pick<Bot, "mainThreadId" | "tasks" | "busy" | "activity" | "unread" | "waitingForTeammates">>;
@@ -24,6 +24,16 @@ const ownOpen = (bot: Pick<LabelBot, "tasks" | "mainThreadId">) => (bot.tasks ??
/** Only a bot with more than one thread of the person's own has anything to unfold. */
export const canUnfold = (bot: Pick<LabelBot, "tasks" | "mainThreadId">): boolean => ownOpen(bot).length > 1;
+/** A bot whose only open thread is the pinned one lists none: its row is that thread. */
+export function pinnedThreads(bot: Pick<LabelBot, "tasks" | "mainThreadId">): Task[] {
+ const pinned = (bot.tasks ?? []).filter((task) => task.pinned === true && !task.routineRunId && !isArchived(task) && !isSnoozed(task));
+ if (!pinned.length || new Set([...ownOpen(bot), ...pinned].map((task) => task.threadId)).size < 2) return [];
+ return orderedThreadList(pinned);
+}
+
+export const openThreadPinned = (bot: Pick<Bot, "threadId" | "switchingTo" | "tasks" | "mainThreadId">): boolean =>
+ pinnedThreads(bot).some((task) => task.threadId === (bot.switchingTo ?? bot.threadId));
+
export function labelStatus(task: LabelTask): LabelStatus {
if (task.activity === "waiting-on-you") return "waiting";
if (isWorking(task)) return "working";
@@ -46,10 +56,10 @@ function capRunning(tasks: LabelTask[]): { kept: LabelTask[]; runningMore: numbe
}
/**
- * The rows under a bot in Simple mode's sidebar. Folded: its threads that are working, wait on the person or have an
- * unread reply, except the one its row opens. Unfolded: also its active threads of the person's own (the open one, its
- * main thread, any still going, and those used in the last week), at most `ACTIVE_LIMIT`, and how many more the bot
- * panel lists.
+ * The rows under a bot in Simple mode's sidebar. Its pinned threads come first, folded or not. Folded: then its threads
+ * that are working, wait on the person or have an unread reply, except the one its row opens. Unfolded: also its active
+ * threads of the person's own (the open one, its main thread, any still going, and those used in the last week), at
+ * most `ACTIVE_LIMIT`, and how many more the bot panel lists.
*/
export function threadLabels(
bot: LabelBot,
@@ -58,20 +68,23 @@ export function threadLabels(
): ThreadLabels {
const main = botOpensTo(bot, false);
const attention: LabelTask[] = [...sidebarBotActivityTasks(bot as Bot, queued), ...runningRoutineRuns(bot as Bot)];
- const row = (task: LabelTask): LabelRow => ({ task, status: labelStatus(task), current: task.threadId === current, main: task.threadId === main });
+ const pins = pinnedThreads(bot).map((task) => ({ ...task, queued: Boolean(queued[task.threadId]?.length) }));
+ const pinIds = new Set(pins.map((task) => task.threadId));
+ const row = (task: LabelTask): LabelRow => ({ task, status: labelStatus(task), current: task.threadId === current, main: task.threadId === main, pinned: pinIds.has(task.threadId) });
+ const unpinned = (task: LabelTask) => !pinIds.has(task.threadId);
if (!unfolded) {
- const { kept, runningMore } = capRunning(attention.filter((task) => task.threadId !== rowThreadId));
- return { rows: kept.map(row), more: 0, runningMore };
+ const { kept, runningMore } = capRunning(attention.filter((task) => task.threadId !== rowThreadId && unpinned(task)));
+ return { rows: [...pins, ...kept].map(row), more: 0, runningMore };
}
const own = ownOpen(bot).map((task) => ({ ...task, queued: Boolean(queued[task.threadId]?.length) }));
const recent = (task: LabelTask) => now - threadRecency(task) < ACTIVE_DAYS * DAY_MS;
const anchored = (task: LabelTask) => task.threadId === current || task.threadId === bot.mainThreadId;
- const active = own.filter((task) => anchored(task) || labelStatus(task) !== null || recent(task))
+ const active = own.filter((task) => unpinned(task) && (anchored(task) || labelStatus(task) !== null || recent(task)))
.sort((a, b) => Number(b.threadId === bot.mainThreadId) - Number(a.threadId === bot.mainThreadId) || threadRecency(b) - threadRecency(a));
const others = active.filter((task) => !anchored(task)).slice(0, Math.max(0, ACTIVE_LIMIT - active.filter(anchored).length));
const shown = active.filter((task) => anchored(task) || others.includes(task));
const listed = new Set(shown.map((task) => task.threadId));
- const { kept, runningMore } = capRunning([...shown, ...attention.filter((task) => !listed.has(task.threadId))]);
- const rows = new Set(kept.map((task) => task.threadId));
- return { rows: kept.map(row), more: own.filter((task) => !rows.has(task.threadId)).length, runningMore };
+ const { kept, runningMore } = capRunning([...shown, ...attention.filter((task) => !listed.has(task.threadId) && unpinned(task))]);
+ const rows = new Set([...pinIds, ...kept.map((task) => task.threadId)]);
+ return { rows: [...pins, ...kept].map(row), more: own.filter((task) => !rows.has(task.threadId)).length, runningMore };
}
diff --git a/src/components/thread-cycle.dom.test.ts b/src/components/thread-cycle.dom.test.ts
new file mode 100644
index 0000000000..037b5ed073
--- /dev/null
+++ b/src/components/thread-cycle.dom.test.ts
@@ -0,0 +1,61 @@
+// @vitest-environment happy-dom
+import { act, createElement } from "react";
+import { createRoot, type Root } from "react-dom/client";
+import { afterEach, beforeEach, expect, it, vi } from "vitest";
+import { initialState, StoreContext, type Action, type AppState, type Bot, type Task } from "@/state/store";
+import { useThreadCycleKeys } from "./thread-cycle";
+
+let container: HTMLDivElement, root: Root;
+beforeEach(() => {
+ vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
+ container = document.createElement("div"); document.body.append(container); root = createRoot(container);
+});
+afterEach(async () => { await act(async () => root.unmount()); container.remove(); vi.unstubAllGlobals(); });
+
+const thread = (threadId: string, at: number, extra: Partial<Task> = {}): Task => ({ threadId, title: threadId, createdAt: at, lastThreadOrderAt: at, ...extra });
+const bot = (threadId: string) => ({ id: "scout", name: "Scout", threadId, messages: [], tasks: [thread("a", 3), thread("b", 2), thread("c", 1)] }) as unknown as Bot;
+
+function Host() {
+ useThreadCycleKeys();
+ return createElement("div", null,
+ createElement("textarea", { "data-composer": "", onKeyDown: (event: KeyboardEvent) => { if (event.key === "Tab") event.preventDefault(); } }),
+ createElement("div", { role: "dialog" }, createElement("button", { "data-in-dialog": "" })));
+}
+
+async function show(threadId: string, state: Partial<AppState> = {}) {
+ const dispatch = vi.fn<(action: Action) => void>();
+ const value = { state: { ...initialState, bots: [bot(threadId)], selectedId: "scout", activeView: "chat" as const, ...state }, dispatch, flushBotPatches: async () => null, refreshInstances: async () => {}, refreshModels: async () => {} };
+ await act(async () => root.render(createElement(StoreContext.Provider, { value }, createElement(Host))));
+ return dispatch;
+}
+
+const press = (target: EventTarget, init: KeyboardEventInit) => {
+ const event = new KeyboardEvent("keydown", { key: "Tab", ctrlKey: true, bubbles: true, cancelable: true, ...init });
+ target.dispatchEvent(event);
+ return event;
+};
+
+it("Ctrl+Tab opens the next thread and Ctrl+Shift+Tab the previous, wrapping", async () => {
+ let dispatch = await show("c");
+ const forward = press(document.body, {});
+ expect(forward.defaultPrevented).toBe(true);
+ expect(dispatch).toHaveBeenLastCalledWith({ type: "switchTask", botId: "scout", threadId: "a" });
+ dispatch = await show("a");
+ press(document.body, { shiftKey: true });
+ expect(dispatch).toHaveBeenLastCalledWith({ type: "switchTask", botId: "scout", threadId: "c" });
+});
+
+it("leaves the key to a composing input method, a field that took it and a dialog, and skips a held key's repeats", async () => {
+ const dispatch = await show("a");
+ press(document.body, { isComposing: true });
+ press(container.querySelector("[data-composer]")!, {});
+ press(container.querySelector("[data-in-dialog]")!, {});
+ press(document.body, { repeat: true });
+ expect(dispatch).not.toHaveBeenCalled();
+});
+
+it("does nothing away from a bot's chat", async () => {
+ const dispatch = await show("a", { activeView: "routines" });
+ press(document.body, {});
+ expect(dispatch).not.toHaveBeenCalled();
+});
diff --git a/src/components/thread-cycle.test.ts b/src/components/thread-cycle.test.ts
new file mode 100644
index 0000000000..5b37d2c5e6
--- /dev/null
+++ b/src/components/thread-cycle.test.ts
@@ -0,0 +1,57 @@
+import { describe, expect, it } from "vitest";
+import type { Task } from "@/state/store";
+import { threadCycleStep } from "@/lib/keyboard-shortcuts";
+import { newChatThreadId } from "@/state/new-chat";
+import { nextCycleThread, threadCycleOrder } from "./thread-cycle";
+import { threadTabs } from "./thread-tabs";
+
+const thread = (threadId: string, at: number, extra: Partial<Task> = {}): Task => ({ threadId, title: threadId, createdAt: at, lastThreadOrderAt: at, ...extra });
+const key = (extra: Partial<KeyboardEvent> = {}) =>
+ ({ key: "Tab", ctrlKey: true, metaKey: false, altKey: false, shiftKey: false, defaultPrevented: false, isComposing: false, keyCode: 9, target: null, ...extra }) as KeyboardEvent;
+
+describe("Ctrl+Tab through a bot's threads", () => {
+ it("steps forward on Ctrl+Tab and back on Ctrl+Shift+Tab", () => {
+ expect(threadCycleStep(key())).toBe(1);
+ expect(threadCycleStep(key({ shiftKey: true }))).toBe(-1);
+ });
+
+ it("leaves other chords, a composing input method, a key a field took, and dialogs alone", () => {
+ expect(threadCycleStep(key({ ctrlKey: false }))).toBeNull();
+ expect(threadCycleStep(key({ metaKey: true }))).toBeNull();
+ expect(threadCycleStep(key({ altKey: true }))).toBeNull();
+ expect(threadCycleStep(key({ key: "t" }))).toBeNull();
+ expect(threadCycleStep(key({ isComposing: true }))).toBeNull();
+ expect(threadCycleStep(key({ keyCode: 229 }))).toBeNull();
+ expect(threadCycleStep(key({ defaultPrevented: true }))).toBeNull();
+ });
+
+ it("goes in the header tabs' order, pinned first, skipping archived, snoozed, closed, routine and bot-opened threads", () => {
+ const tasks = [thread("main", 1), thread("new", 9), thread("pin", 2, { pinned: true }), thread("mid", 5), thread("gone", 8, { archivedAt: 1 }),
+ thread("later", 8, { snoozedUntil: 0 }), thread("done", 8, { closedBy: { botId: "x", name: "X", at: 1 } }), thread("run", 8, { routineRunId: "r" }),
+ thread("helper", 8, { openedBy: { botId: "x", name: "X", at: 1 } })];
+ const bot = { id: "b", threadId: "main", tasks };
+ expect(threadCycleOrder(bot)).toEqual(threadTabs(bot).map((tab) => tab.threadId));
+ expect(threadCycleOrder(bot)).toEqual(["pin", "new", "mid", "main"]);
+ });
+
+ it("leaves out the blank New thread chat's tab", () => {
+ const bot = { id: "b", threadId: newChatThreadId("b"), tasks: [thread("a", 2), thread("p", 1, { pinned: true })] };
+ expect(threadTabs(bot).some((tab) => tab.draft)).toBe(true);
+ expect(threadCycleOrder(bot)).toEqual(["p", "a"]);
+ });
+
+ it("wraps at either end", () => {
+ const order = ["a", "b", "c"];
+ expect(nextCycleThread(order, "a", 1)).toBe("b");
+ expect(nextCycleThread(order, "c", 1)).toBe("a");
+ expect(nextCycleThread(order, "a", -1)).toBe("c");
+ expect(nextCycleThread(order, "b", -1)).toBe("a");
+ });
+
+ it("from a thread outside the order lands on the first or the last, and does nothing with one thread", () => {
+ expect(nextCycleThread(["a", "b"], "x", 1)).toBe("a");
+ expect(nextCycleThread(["a", "b"], "x", -1)).toBe("b");
+ expect(nextCycleThread(["a"], "a", 1)).toBeNull();
+ expect(nextCycleThread([], "a", 1)).toBeNull();
+ });
+});
diff --git a/src/components/thread-cycle.ts b/src/components/thread-cycle.ts
new file mode 100644
index 0000000000..8d6a6a5fcd
--- /dev/null
+++ b/src/components/thread-cycle.ts
@@ -0,0 +1,46 @@
+import { useEffect } from "react";
+import { threadCycleStep } from "@/lib/keyboard-shortcuts";
+import { newChatThreadId } from "@/state/new-chat";
+import type { AppState } from "@/state/store";
+import { useStoreDispatch, useStoreSelector } from "@/state/store-select";
+import { openTabId, threadTabs, type TabsBot } from "./thread-tabs";
+
+interface CycleTarget { botId: string; open: string; order: string[] }
+
+export const threadCycleOrder = (bot: TabsBot): string[] => threadTabs(bot).filter((tab) => !tab.draft).map((tab) => tab.threadId);
+
+export function nextCycleThread(order: readonly string[], open: string, step: 1 | -1): string | null {
+ const at = order.indexOf(open);
+ if (at < 0) return order[step > 0 ? 0 : order.length - 1] ?? null;
+ if (order.length < 2) return null;
+ return order[(at + step + order.length) % order.length]!;
+}
+
+function cycleTarget(state: AppState): CycleTarget | null {
+ if (state.activeView !== "chat" || state.shortcutsOpen) return null;
+ const bot = state.bots.find((candidate) => candidate.id === state.selectedId && !candidate.hidden);
+ if (!bot) return null;
+ const open = state.newChat?.botId === bot.id ? newChatThreadId(bot.id) : openTabId(bot);
+ return { botId: bot.id, open, order: threadCycleOrder(bot) };
+}
+
+const sameTarget = (a: CycleTarget | null, b: CycleTarget | null) =>
+ a === b || (a !== null && b !== null && a.botId === b.botId && a.open === b.open && a.order.join("\n") === b.order.join("\n"));
+
+export function useThreadCycleKeys(): void {
+ const dispatch = useStoreDispatch();
+ const target = useStoreSelector(cycleTarget, sameTarget);
+ useEffect(() => {
+ if (!target) return;
+ const onKey = (event: KeyboardEvent) => {
+ const step = threadCycleStep(event);
+ if (step === null) return;
+ event.preventDefault();
+ if (event.repeat) return;
+ const next = nextCycleThread(target.order, target.open, step);
+ if (next && next !== target.open) dispatch({ type: "switchTask", botId: target.botId, threadId: next });
+ };
+ window.addEventListener("keydown", onKey);
+ return () => window.removeEventListener("keydown", onKey);
+ }, [target, dispatch]);
+}
diff --git a/src/lib/keyboard-shortcuts.ts b/src/lib/keyboard-shortcuts.ts
index d4bc0f13f9..c081b2459a 100644
--- a/src/lib/keyboard-shortcuts.ts
+++ b/src/lib/keyboard-shortcuts.ts
@@ -54,6 +54,12 @@ export const SHORTCUT_GROUPS: readonly ShortcutGroup[] = [
macKeys: ["⌘", "⇧", "[ / ]"],
winKeys: ["Ctrl", "Shift", "[ / ]"],
},
+ {
+ id: "switch-thread",
+ description: "Switch to the bot's next / previous thread",
+ macKeys: ["⌃", "Tab / ⇧Tab"],
+ winKeys: ["Ctrl", "Tab / Shift+Tab"],
+ },
{
id: "find-conversation",
description: "Find in conversation",
@@ -198,6 +204,14 @@ export function botCycleStep(event: Pick<KeyboardEvent, "key">): 1 | -1 | null {
return null;
}
+/** Ctrl on macOS too: ⌘Tab belongs to the system. keyCode 229 is a composing key in browsers that leave isComposing unset. */
+export function threadCycleStep(event: Pick<KeyboardEvent, "key" | "ctrlKey" | "metaKey" | "altKey" | "shiftKey" | "defaultPrevented" | "isComposing" | "keyCode" | "target">): 1 | -1 | null {
+ if (event.key !== "Tab" || !event.ctrlKey || event.metaKey || event.altKey || event.defaultPrevented || event.isComposing || event.keyCode === 229) return null;
+ const target = event.target;
+ if (typeof Element !== "undefined" && target instanceof Element && target.closest("dialog, [role=dialog], [role=alertdialog]")) return null;
+ return event.shiftKey ? -1 : 1;
+}
+
/**
* ⌘D on macOS, Ctrl+D elsewhere. Ctrl+D on macOS stays the text field's delete-forward key. The physical key counts only
* when the layout types no Latin letter there (Russian), not when it types another one (Dvorak).
diff --git a/src/lib/sidebar-layout.ts b/src/lib/sidebar-layout.ts
index 55731b150f..e585589217 100644
--- a/src/lib/sidebar-layout.ts
+++ b/src/lib/sidebar-layout.ts
@@ -12,7 +12,6 @@ export const CHANNELS_SECTION_ID = "builtin:channels";
export const BOT_CHATS_SECTION_ID = "builtin:bot-chats";
export const BOTS_SECTION_ID = "builtin:bots";
export const ATTENTION_SECTION_ID = "builtin:attention";
-export const PINNED_THREADS_SECTION_ID = "builtin:pinned-threads";
export const TOOLS_SECTION_ID = "builtin:tools";
const USER_SECTION_PREFIX = "section:";
diff --git a/src/locales/en.json b/src/locales/en.json
index 116fdc079a..293b0f0101 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -9211,6 +9211,7 @@
"shortcuts.new-thread": "Start a new thread with the selected bot",
"shortcuts.jump-bot": "Jump to bot 1–9 in the roster",
"shortcuts.switch-bot": "Switch to previous / next bot",
+ "shortcuts.switch-thread": "Switch to the bot's next / previous thread",
"shortcuts.find-conversation": "Find in conversation",
"shortcuts.send-message": "Send message",
"shortcuts.new-line": "Insert new line without sending",
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index 9eb3ab17e6..cdadd9256a 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -9143,6 +9143,7 @@
"shortcuts.new-thread": "Iniciar uma nova conversa com o bot selecionado",
"shortcuts.jump-bot": "Ir para o bot 1–9 da lista",
"shortcuts.switch-bot": "Ir para o bot anterior / seguinte",
+ "shortcuts.switch-thread": "Ir para a conversa seguinte / anterior do bot",
"shortcuts.find-conversation": "Buscar na conversa",
"shortcuts.send-message": "Enviar mensagem",
"shortcuts.new-line": "Inserir uma nova linha sem enviar",