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
6 changes: 6 additions & 0 deletions apps/desktop/src/electron/ElectronMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ function normalizeContextMenuItems(source: readonly ContextMenuItem[]): ContextM
const normalizedItem: ContextMenuItem = {
id: sourceItem.id,
label: sourceItem.label,
...(typeof sourceItem.sublabel === "string" && sourceItem.sublabel.length > 0
? { sublabel: sourceItem.sublabel }
: {}),
destructive: sourceItem.destructive === true,
disabled: sourceItem.disabled === true,
...(sourceItem.separatorBefore === true ? { separatorBefore: true } : {}),
Expand Down Expand Up @@ -102,6 +105,9 @@ export const layer = Layer.sync(ElectronMenu, () => {
const itemOption: Electron.MenuItemConstructorOptions = {
label: item.label,
enabled: !item.disabled,
// Shown under the label on macOS 14.4 and later, and as the item's
// hover text on any Mac; other systems leave it out.
...(item.sublabel !== undefined ? { sublabel: item.sublabel, toolTip: item.sublabel } : {}),
};
if (item.children && item.children.length > 0) {
itemOption.submenu = buildTemplate(item.children, complete);
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/guide/topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ A project's lead chat is a thread set up to coordinate the project; see the lead
],
body: `Each project can have one lead chat: a thread you drop work into (a bug, a stack trace, a list of tasks). Its agent answers small questions itself and starts threads for new work. Those threads show under the lead in the sidebar and report back to it, and it tells you what finished and what needs you.

Any thread can be the lead. Use "Make this the lead chat" in a thread's menu (right-click its row, or click the title above the chat), or the command palette. The project's menu in the project picker has Open lead chat, or New lead chat, which starts a thread in the project folder and makes it the lead. "Go to lead chat" in the command palette opens it.
Any thread can be the lead. The first time a thread in a project with no lead starts threads of its own, a line under its tabs offers to make it the lead; close it and it doesn't come back for that project. Or use "Make this the lead chat" in a thread's menu (right-click its row, or click the title above the chat), or the command palette. The project's menu in the project picker has Open lead chat, or New lead chat, which starts a thread in the project folder and makes it the lead. "Go to lead chat" in the command palette opens it.

The lead can also pass a message to a thread you started by hand in the project. That is one-way: the thread works on it and answers there, not back in the lead, and it can't start threads of its own for it until you write there. The lead can't pass work into a room, a thread another thread still owns, or one you stopped. A pass never runs with more access than the lead had.

When an agent asks to start several threads, the card has a checkbox per thread, so you can start some and leave the rest; the agent is told which.

Only one thread leads a project; making another the lead replaces it. "Stop using as lead chat" turns it back into an ordinary thread, and the threads it started stay with it. Archiving or deleting the lead ends it. A lead can't move to another computer, and each computer keeps its own lead for a project.

The lead's row sits at the top of the sidebar with a crown, says Lead where the project name goes, and never wraps up on its own. {place:archived.autoArchive} leaves it alone, as it does a pinned thread. The chat shows a Lead chat label beside the title, or, once it has started threads, the family tabs with the lead first.
The lead's row sits at the top of the sidebar with a crown, says Lead where the project name goes, and never wraps up on its own. {place:archived.autoArchive} leaves it alone, as it does a pinned thread. The chat shows a Lead chat label beside the title, or, once it has started threads, the family tabs with the lead first. Hovering the label or the Lead tab, or tapping it, says what a lead does and offers Stop using as lead chat.

The Threads tab in the right sidebar shows the project's threads on every computer you can see, grouped as Needs you, Ready for review, Working, Landing, Idle and Done. Open it from the sidebar's list of panels or its + menu, on any thread of the project. A thread you wrapped up goes under Done (for 7 days, closed until you open it) unless its pull request is still open, which keeps it under Ready for review or Landing. Ready for review says what the pull request waits on, as the Pull requests page does. Click a row to open the thread, or right-click it for the thread's menu. The top line counts what needs you and what's working, with a Lead chat link when you're on another thread.

Expand Down
94 changes: 94 additions & 0 deletions apps/web/src/components/ChatView.sidebar.browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,100 @@ describe("ChatView (full app): sidebar", () => {
}
});

/**
* The open thread with one thread it started, on a computer that keeps a
* lead chat, and no lead yet (or `lead` as the lead).
*/
const mountFamily = async (lead: ThreadId | null) => {
window.localStorage.removeItem(
`threadlines:lead-chat-suggestion-dismissed:v1:${LOCAL_ENVIRONMENT_ID}:${PROJECT_ID}`,
);
const childId = "thread-lead-child" as ThreadId;
const withChild = addThreadToSnapshot(
createSnapshotForTargetUser({
targetMessageId: "msg-user-lead-family" as MessageId,
targetText: "lead family",
}),
childId,
);
const capabilities = { repositoryIdentity: true, projectLead: true };
return mountChatView({
viewport: DEFAULT_VIEWPORT,
snapshot: {
...withChild,
projects: withChild.projects.map((project) => ({ ...project, leadThreadId: lead })),
threads: withChild.threads.map((thread) =>
thread.id === childId
? { ...thread, title: "Fix tests", parentThreadId: THREAD_ID, attachedToParent: true }
: thread,
),
},
configureFixture: (nextFixture) => {
nextFixture.serverConfig = {
...nextFixture.serverConfig,
environment: { ...nextFixture.serverConfig.environment, capabilities },
};
nextFixture.welcome = {
...nextFixture.welcome,
environment: { ...nextFixture.welcome.environment, capabilities },
};
},
});
};
const leadSetsSent = () =>
wsRequests.flatMap((request) =>
request._tag === ORCHESTRATION_WS_METHODS.dispatchCommand &&
request.type === "project.lead.set"
? [request.threadId]
: [],
);

it("offers a thread running other threads as the lead, once, and says what a lead is", async () => {
const mounted = await mountFamily(null);
try {
const suggestion = page.getByTestId("lead-chat-suggestion");
await expect
.element(suggestion)
.toMatchTextContent(/This thread is running other threads\. Make it the lead chat/u);
await page.getByTestId("lead-chat-suggestion-make").click();
await vi.waitFor(() => expect(leadSetsSent()).toEqual([THREAD_ID]));
await expect.element(suggestion).not.toBeInTheDocument();

// Once it leads, its tab is the crown, and a press on it says what that means.
const [project] = toShellSnapshot(fixture.snapshot).projects;
rpcHarness.emitStreamValue(ORCHESTRATION_WS_METHODS.subscribeShell, {
kind: "project-upserted",
sequence: fixture.snapshot.snapshotSequence + 1,
project: { ...project!, leadThreadId: THREAD_ID },
});
const leadTab = page.getByRole("tab", { name: `Lead: ${THREAD_TITLE}` });
await expect.element(leadTab).toBeVisible();
await leadTab.click();
const card = page.getByTestId("lead-chat-card");
await expect.element(card).toMatchTextContent(/Drop work here\./u);
await card.getByTestId("lead-chat-card-stop").click();
await vi.waitFor(() => expect(leadSetsSent()).toEqual([THREAD_ID, null]));
} finally {
await mounted.cleanup();
}
});

it("keeps the lead suggestion away from a project once it is closed", async () => {
const mounted = await mountFamily(null);
try {
await page.getByTestId("lead-chat-suggestion-dismiss").click();
await expect.element(page.getByTestId("lead-chat-suggestion")).not.toBeInTheDocument();
expect(
window.localStorage.getItem(
`threadlines:lead-chat-suggestion-dismissed:v1:${LOCAL_ENVIRONMENT_ID}:${PROJECT_ID}`,
),
).toBe("true");
expect(leadSetsSent()).toEqual([]);
} finally {
await mounted.cleanup();
}
});

// The server says it made the thread a moment before this app hears of it,
// as a real one does: "New lead chat" must open it once it is here, and
// stay there (the thread page goes home for a thread it does not know).
Expand Down
25 changes: 18 additions & 7 deletions apps/web/src/components/chat/ChatHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { useComputerLabel } from "../sidebar/linkedComputers";
import { useTitleBarHeaderRef } from "../sidebar/titleBarSlot";
import { outsideOriginDescription } from "../../environments/outsideAgents/outsideAgents.logic";
import { OutsideOriginMark } from "../outsideAgents/AssistantMark";
import { LeadChatCard } from "./LeadChatHints";

export interface ForkHeaderContext {
readonly sourceThreadId: ThreadId;
Expand Down Expand Up @@ -428,13 +429,23 @@ export const ChatHeader = memo(function ChatHeader({
{parentContext ? (
<StartedByChip parent={parentContext} onOpen={onOpenParentThread} />
) : null}
{isLeadChat ? (
<span data-testid="lead-chat-chip" className={STARTED_BY_CHIP_CLASS}>
<span className="inline-flex min-w-0 items-center gap-1">
<CrownIcon aria-hidden="true" className="size-3 shrink-0" />
Lead chat
</span>
</span>
{isLeadChat && activeThreadRef !== null ? (
<LeadChatCard
threadRef={activeThreadRef}
renderTrigger={(showCard) => (
<button
type="button"
data-testid="lead-chat-chip"
className={STARTED_BY_CHIP_CLASS}
onClick={showCard}
>
<span className="inline-flex min-w-0 items-center gap-1">
<CrownIcon aria-hidden="true" className="size-3 shrink-0" />
Lead chat
</span>
</button>
)}
/>
) : null}
{outsideOrigin ? <OutsideOriginLabel origin={outsideOrigin} /> : null}
{activeProjectName && !isGitRepo && sourceControlAvailable && (
Expand Down
70 changes: 46 additions & 24 deletions apps/web/src/components/chat/FamilyTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { requestIdleThreadDetailPrewarm } from "../../environments/runtime/servi
import { cn } from "../../lib/utils";
import { buildThreadRouteParams } from "../../threadRoutes";
import { Menu, MenuItem, MenuPopup, MenuTrigger } from "../ui/menu";
import { LeadChatCard, LeadChatSuggestion } from "./LeadChatHints";
import {
type FamilyTab,
type FamilyTabs as FamilyTabsModel,
Expand Down Expand Up @@ -157,30 +158,44 @@ const FamilyTabRow = memo(function FamilyTabRow({
overflowPx: OVERFLOW_PX,
});

// The parent, open and not leading yet, may be offered as the lead (LeadChatSuggestion).
const parentTab = family.tabs[0];
const suggestLead =
parentTab !== undefined &&
parentTab.kind === "parent" &&
!parentTab.lead &&
parentTab.threadRef !== null &&
parentTab.key === family.openKey
? parentTab.threadRef
: null;

return (
<div
ref={rowRef}
role="tablist"
aria-label="This thread's family"
data-testid="family-tabs"
data-family-key={family.familyKey}
className={cn(
"flex min-w-0 shrink-0 items-center gap-0.5 border-b border-border px-3 py-1 sm:px-5",
isMobile && "overflow-x-auto [scrollbar-width:none]",
)}
>
{shown.map((tab) => (
<FamilyTabButton
key={tab.key}
tab={tab}
active={tab.key === family.openKey}
fill={!isMobile}
onOpen={onOpen}
buttonRef={tab.key === family.openKey ? openTabRef : undefined}
/>
))}
{hidden.length > 0 ? <FamilyTabOverflow hidden={hidden} onOpen={onOpen} /> : null}
</div>
<>
<div
ref={rowRef}
role="tablist"
aria-label="This thread's family"
data-testid="family-tabs"
data-family-key={family.familyKey}
className={cn(
"flex min-w-0 shrink-0 items-center gap-0.5 border-b border-border px-3 py-1 sm:px-5",
isMobile && "overflow-x-auto [scrollbar-width:none]",
)}
>
{shown.map((tab) => (
<FamilyTabButton
key={tab.key}
tab={tab}
active={tab.key === family.openKey}
fill={!isMobile}
onOpen={onOpen}
buttonRef={tab.key === family.openKey ? openTabRef : undefined}
/>
))}
{hidden.length > 0 ? <FamilyTabOverflow hidden={hidden} onOpen={onOpen} /> : null}
</div>
{suggestLead !== null ? <LeadChatSuggestion parentRef={suggestLead} /> : null}
</>
);
});

Expand Down Expand Up @@ -221,7 +236,7 @@ const FamilyTabButton = memo(function FamilyTabButton({
: tab.statusWord !== null
? `${tab.title}, ${tab.statusWord}`
: tab.title;
return (
const tabButton = (showLeadCard: (() => void) | null) => (
<button
ref={buttonRef}
type="button"
Expand All @@ -243,6 +258,8 @@ const FamilyTabButton = memo(function FamilyTabButton({
)}
onClick={() => {
if (tab.threadRef !== null && !active) onOpen(tab.threadRef);
// A press on the open lead's tab says what a lead is (a phone never hovers).
else if (active) showLeadCard?.();
}}
{...touchHold}
>
Expand All @@ -266,6 +283,11 @@ const FamilyTabButton = memo(function FamilyTabButton({
</span>
</button>
);
return tab.kind === "parent" && tab.lead && tab.threadRef !== null ? (
<LeadChatCard threadRef={tab.threadRef} renderTrigger={tabButton} />
) : (
tabButton(null)
);
});

/** "+N": the tabs that don't fit, with their status; amber while one needs the user. */
Expand Down
Loading
Loading