Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/desktop/src/settings/DesktopClientSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const clientSettings: ClientSettings = {
providerModelPreferences: {},
suppressCrossProviderSwitchWarning: false,
sidebarGrouping: "none",
generalChatsPlacement: "page",
inboxSort: "recent",
inboxCustomOrder: [],
inboxGroupOrder: [],
Expand Down
3 changes: 3 additions & 0 deletions apps/server/src/guide/topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const GUIDE_TOPICS: ReadonlyArray<GuideTopic> = [
"wrap",
"archive",
"restart",
"general chats",
],
body: `A thread is one conversation with an agent in a project. Threads are listed in the sidebar; one that needs you, finished or failed says so there. In a narrow window the sidebar floats over the thread instead of sitting beside it: the sidebar button at the top left, or Cmd+B (Ctrl+B on Windows and Linux), opens it, and picking a thread or clicking the thread puts it away. A thread you scrolled up in opens where you left it when you come back, until Threadlines reloads; one that finished, failed or needs you since then opens at the end.

Expand All @@ -63,6 +64,8 @@ When Claude or Codex asks multiple-choice questions, a card takes the place of t

When a thread is done it wraps up and moves to the Wrapped shelf at the bottom of the sidebar; {place:threads.whenDone} says when that happens on its own. An agent coming back later (a check-back) doesn't keep a thread out of Wrapped: the thread returns to the list when the agent does. Old threads can be archived for you: {place:archived.cleanup}.

General Chats are chats with an agent that aren't tied to a project. By default they have their own page in the left bar, with a New chat button over the list. With {place:threads.generalChats} set to Section in Threads, that button leaves the left bar and the chats sit in a General chats section at the bottom of the thread list, under Wrapped: its header opens and closes it and has its own New chat button, and the Threads button counts what the chats need and are doing. Old General Chats links then open Threads with the section open. Each device keeps its own choice.

When Threadlines quits, updates or crashes while an agent works on something the user asked for, the agent picks it back up when Threadlines starts again: the chat gets a message marked "Sent after a restart" telling the agent to check before repeating anything. A turn waiting on an approval or a question, or one another thread, a scheduled task or an outside agent started, stops with a note instead, as does a turn restarts cut off three times in five minutes. {place:threads.continueAfterRestart} turns this off.`,
},
{
Expand Down
20 changes: 17 additions & 3 deletions apps/web/src/components/AppSidebarLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useAppHistory } from "../appHistory";
import { useCommandPaletteStore } from "../commandPaletteStore";
import { isKnownEnvironment } from "../environments/runtime";
import { useHandleNewThread } from "../hooks/useHandleNewThread";
import { getClientSettings } from "../hooks/useSettings";
import { resolveShortcutCommand } from "../keybindings";
import { startNewThreadFromContext } from "../lib/chatThreadActions";
import { isTerminalFocused } from "../lib/terminalFocus";
Expand All @@ -26,6 +27,12 @@ import { selectThreadTerminalState, useTerminalStateStore } from "../terminalSta
import { buildThreadRouteParams } from "../threadRoutes";
import { selectSidebarListShown, useUiStateStore } from "../uiStateStore";
import ThreadSidebar from "./Sidebar";
import {
consumeSidebarListReveal,
requestGeneralChatsReveal,
useGeneralChatsInThreads,
} from "./chats/generalChatsPlacement";
import { GeneralChatsRevealer } from "./chats/GeneralChatsRevealer";
import { AppTitleBar } from "./sidebar/AppTitleBar";
import { TitleBarSlotContext } from "./sidebar/titleBarSlot";
import { destinationHasList } from "./sidebar/destinationLists";
Expand Down Expand Up @@ -144,7 +151,9 @@ function AppShellCommands({ hasList }: { readonly hasList: boolean }) {
void navigate({ to: "/terminals" });
return;
case "open-general-chats":
void navigate({ to: "/chats" });
// Read when the item fires; the menu subscription stays put.
if (getClientSettings().generalChatsPlacement === "threads") requestGeneralChatsReveal();
else void navigate({ to: "/chats" });
return;
case "open-usage":
void navigate({ to: "/usage" });
Expand Down Expand Up @@ -295,18 +304,22 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
const listFloats = useUiStateStore((store) => store.sidebarListFloats);
const setSidebarListShown = useUiStateStore((store) => store.setSidebarListShown);
const selectedDestination = useSelectedDestination();
const generalChatsInThreads = useGeneralChatsInThreads();
const hasList = destinationHasList(selectedDestination);
const isMobile = useIsMobile();
const panelRef = useRef<HTMLDivElement>(null);
useSidebarListFloats(panelRef, isMobile);
// A floating list gets out of the way of whatever page opens next.
// A floating list gets out of the way of whatever page opens next, unless
// the change was asked to show it (opening the chats' section in Threads,
// GeneralChatsRevealer).
const pathname = useLocation({ select: (location) => location.pathname });
const shownPathname = useRef(pathname);
useEffect(() => {
if (shownPathname.current === pathname) return;
shownPathname.current = pathname;
const state = useUiStateStore.getState();
if (state.sidebarListFloats) state.setSidebarListShown(false);
if (consumeSidebarListReveal(pathname)) state.setSidebarListShown(true);
else if (state.sidebarListFloats) state.setSidebarListShown(false);
}, [pathname]);
usePageCrossFade(panelRef, selectedDestination);
// Dialogs and other window-wide layers center over the page beside the list.
Expand Down Expand Up @@ -354,6 +367,7 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
style={sidebarStyle}
>
<AppShellCommands hasList={hasList} />
{generalChatsInThreads ? <GeneralChatsRevealer /> : null}
<AppTitleBar slotRef={setTitleBarSlot} />
<div className="flex min-h-0 flex-1">
<NavigationRail />
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/ChatView.browser-harness.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3482,6 +3482,7 @@ export function registerChatViewSuiteHooks(): void {
inboxProjectScopeKeys: [],
collapsedInboxGroups: {},
inboxWrappedOpen: false,
inboxGeneralChatsOpen: true,
sidebarListOpen: true,
});
useTerminalStateStore.persist.clearStorage();
Expand Down
166 changes: 165 additions & 1 deletion apps/web/src/components/ChatView.shell.browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import * as Effect from "effect/Effect";
import { page, userEvent } from "vite-plus/test/browser";
import { describe, expect, it, vi } from "vite-plus/test";

import { DEFAULT_CLIENT_SETTINGS } from "@threadlines/contracts/settings";

import { CLIENT_SETTINGS_STORAGE_KEY } from "../clientPersistenceStorage";
import { useComposerDraftStore } from "../composerDraftStore";
import { isMacPlatform } from "../lib/utils";
import { useOptimisticThreadMessagesStore } from "../optimisticThreadMessages";
Expand Down Expand Up @@ -1091,6 +1094,90 @@ describe("ChatView (full app): app shell", () => {
}
});

it("shows a floating list with the chats' section open when the old General Chats address leads to Threads", async () => {
localStorage.setItem(
CLIENT_SETTINGS_STORAGE_KEY,
JSON.stringify({ ...DEFAULT_CLIENT_SETTINGS, generalChatsPlacement: "threads" }),
);
useUiStateStore.setState({ inboxGeneralChatsOpen: false });
const mounted = await mountChatView({
viewport: { ...DEFAULT_VIEWPORT, name: "list-floats-chats", width: 800 },
snapshot: createSnapshotForTargetUser({
targetMessageId: "msg-user-list-floats-chats" as MessageId,
targetText: "list floats chats",
}),
});

try {
const list = await waitForElement(
() =>
document.querySelector<HTMLElement>('[data-testid="app-panel"] > [data-slot="sidebar"]'),
"Unable to find the list beside the rail.",
);
await vi.waitFor(() => expect(list.dataset.state).toBe("collapsed"));
const threadPath = mounted.router.state.location.pathname;
// From another page, as the command palette or the desktop menu would go.
await mounted.router.navigate({ to: "/fleet" });
await waitForURL(mounted.router, (pathname) => pathname === "/fleet", "Fleet should open.");
await mounted.router.navigate({ to: "/chats" });
await waitForURL(
mounted.router,
(pathname) => pathname === threadPath,
"The old General Chats address should go where the Threads button does.",
);
// Both page changes (to the old address, then on to Threads) leave it showing.
await nextFrames(5);
expect(list.dataset.state).toBe("expanded");
await expect
.element(page.getByTestId("inbox-chats-toggle"))
.toHaveAttribute("aria-expanded", "true");
// The next page change puts the floating list away as usual.
await mounted.router.navigate({ to: "/fleet" });
await vi.waitFor(() => expect(list.dataset.state).toBe("collapsed"));
} finally {
localStorage.removeItem(CLIENT_SETTINGS_STORAGE_KEY);
await mounted.cleanup();
}
});

it("keeps a floating list showing when the app opens on the old General Chats address", async () => {
localStorage.setItem(
CLIENT_SETTINGS_STORAGE_KEY,
JSON.stringify({ ...DEFAULT_CLIENT_SETTINGS, generalChatsPlacement: "threads" }),
);
useUiStateStore.setState({ inboxGeneralChatsOpen: false });
const mounted = await mountChatView({
viewport: { ...DEFAULT_VIEWPORT, name: "list-floats-chats-launch", width: 800 },
initialPath: "/chats",
snapshot: createSnapshotForTargetUser({
targetMessageId: "msg-user-list-floats-chats-launch" as MessageId,
targetText: "list floats chats launch",
}),
});

try {
// Home, then on to where the launch lands: the list stays out through both.
await waitForURL(
mounted.router,
(pathname) => pathname !== "/chats" && pathname !== "/",
"The launch should land in work.",
);
const list = await waitForElement(
() =>
document.querySelector<HTMLElement>('[data-testid="app-panel"] > [data-slot="sidebar"]'),
"Unable to find the list beside the rail.",
);
await nextFrames(5);
expect(list.dataset.state).toBe("expanded");
await expect
.element(page.getByTestId("inbox-chats-toggle"))
.toHaveAttribute("aria-expanded", "true");
} finally {
localStorage.removeItem(CLIENT_SETTINGS_STORAGE_KEY);
await mounted.cleanup();
}
});

it("folds the app's name away, then gives the thread's header its own row, as the title row runs out of room", async () => {
const root = document.documentElement;
root.classList.add("electron", "wco");
Expand Down Expand Up @@ -1769,7 +1856,14 @@ describe("ChatView (full app): app shell", () => {
// A finger can't hover for the tooltip: each icon says its name.
await expect
.element(page.getByTestId("sidebar-destination-row"))
.toMatchTextContent(/Threads.*Chats.*Settings/);
.toMatchTextContent(/Threads.*Chats.*Shells.*Settings/);
// Every destination fits the phone's width, Settings last.
const row = document.querySelector<HTMLElement>('[data-testid="sidebar-destination-row"]')!;
expect(row.scrollWidth).toBeLessThanOrEqual(row.clientWidth);
const settingsButton = row.querySelector<HTMLElement>('[data-testid="rail-settings"]')!;
expect(settingsButton.getBoundingClientRect().right).toBeLessThanOrEqual(
row.getBoundingClientRect().right,
);
// The page shows a thumb's width beside the sheet: a strip to tap it shut.
const sheet = document.querySelector<HTMLElement>(
'[data-slot="sidebar"][data-mobile="true"]',
Expand All @@ -1795,6 +1889,76 @@ describe("ChatView (full app): app shell", () => {
}
});

it("on a phone with the chats in Threads, opens the sheet on them from the old page's address", async () => {
const chatId = "thread-phone-chat-section" as ThreadId;
const base = addThreadToSnapshot(
createSnapshotForTargetUser({
targetMessageId: "msg-user-phone-chat-section" as MessageId,
targetText: "phone chat section",
}),
chatId,
);
localStorage.setItem(
CLIENT_SETTINGS_STORAGE_KEY,
JSON.stringify({ ...DEFAULT_CLIENT_SETTINGS, generalChatsPlacement: "threads" }),
);
useUiStateStore.setState({ inboxGeneralChatsOpen: false });
const mounted = await mountChatView({
viewport: PHONE_VIEWPORT,
snapshot: {
...base,
projects: [
...base.projects,
{
id: GENERAL_CHATS_PROJECT_ID,
kind: "general-chat" as const,
title: "General Chats",
workspaceRoot: "/repo/general-chats",
defaultModelSelection: null,
scripts: [],
createdAt: NOW_ISO,
updatedAt: NOW_ISO,
deletedAt: null,
},
],
threads: base.threads.map((thread) =>
thread.id === chatId
? { ...thread, projectId: GENERAL_CHATS_PROJECT_ID, title: "Pocket question" }
: thread,
),
},
});

try {
await mounted.router.navigate({ to: "/chats" });
await waitForURL(
mounted.router,
(pathname) => pathname !== "/chats",
"The old General Chats address should open Threads.",
);
// The sheet opens on the thread list, with no Chats icon and the section open.
await expect
.element(page.getByTestId("sidebar-destination-row"))
.toMatchTextContent(/Threads.*Settings/);
expect(document.querySelector('[data-testid="rail-chats"]')).toBeNull();
await expect
.element(page.getByTestId("inbox-chats-toggle"))
.toHaveAttribute("aria-expanded", "true");
await expect.element(page.getByTestId(`thread-row-${THREAD_ID}`)).toBeVisible();

await page.getByTestId("chats-list-row").filter({ hasText: "Pocket question" }).click();
await waitForURL(
mounted.router,
(pathname) => pathname.endsWith(`/${chatId}`),
"A chat in the sheet should open that chat.",
);
await expect.element(page.getByTestId("sidebar-destination-row")).not.toBeInTheDocument();
} finally {
localStorage.removeItem(CLIENT_SETTINGS_STORAGE_KEY);
await mounted.cleanup();
}
});

it("navigates phone settings through the full-page section index", async () => {
const mounted = await mountChatView({
viewport: PHONE_VIEWPORT,
Expand Down
Loading
Loading