evOo-local/apps/web/e2e/activity-list.spec.ts
Claude 311551da04
feat: land in the main conversation, led by the main bot
After onboarding the user ended up in a 1:1 chat with "Chief", and the
"Hauptthread" was a group the web client created and found by name. The
main bot had no conversation it actually led, and addressing another bot
there did nothing unless the user had added it as a member first.

Now the main conversation is a real place:

- bots.ensureMain creates or returns the main bot. Bootstrap and space
  navigation return `main` ({ botId, groupId, spaceId }) once the main
  bot exists; reading navigation never creates a bot.
- The main bot leads the main conversation and answers when nobody is
  addressed: message routing, follow-ups, reactions and clearing the
  thread fall back to the group's lead instead of its first member.
- Addressing a same-space bot that is not a member yet, by @Name or a
  mention chip, makes it join before the message is routed, so it
  answers in the conversation. Specialists from other spaces do not join.
- The main bot cannot be archived or deleted, the main conversation
  cannot be archived or deleted or have its members edited, and child
  bots never dissolve it. Renaming the main bot renames the conversation.
- Web: onboarding uses bots.ensureMain and finishes in the main
  conversation. The main conversation is the first sidebar entry in every
  space, shown with the main bot's avatar and name; from another space it
  switches back to the home space. The main bot is not listed again among
  the bots, its 1:1 thread stays reachable by URL. The client no longer
  creates or detects the "Hauptthread" by name, refetches a group when it
  changes, and shows the speaker of any of the user's bots in a group.
- Onboarding no longer resets the step when its bootstrap resolves after
  the user has already moved on, and new spaces open in the app instead
  of walking onboarding again.

Tests: group mention routing with a default responder, lead follow-ups,
child-bot guards, a journey for the main conversation (lead answers,
addressed bot joins, guards, rename), authorization for bots.ensureMain,
and an E2E spec that lands in the main conversation, gets an answer from
the lead, sees an addressed bot join, and reaches the conversation from
another space. Existing E2E specs start in the main bot's thread through
a helper or use the main conversation where that is what they test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MRtGG9ARfqqhma3t85Ro2u
2026-10-03 00:24:16 +00:00

101 lines
4.7 KiB
TypeScript

import { expect, type Page, test } from "@playwright/test";
import { captureScreenshot, completeOnboarding, signup } from "./helpers";
/** Activity rows sit above `[data-sidebar-group]` bots; match their aria-label. */
/** Activity rows only, not the sidebar's conversation entries for the same bot. */
function activityRow(page: Page, botName: string) {
return page.locator("aside").getByRole("button", {
name: new RegExp(`^${botName}, (?!1:1 conversation|main conversation)`),
});
}
async function captureActivitySidebar(
page: Page,
testInfo: Parameters<typeof captureScreenshot>[1],
name: string,
) {
const aside = page.locator("aside").first();
const toggle = page.getByRole("button", { name: "Activity", exact: true });
await toggle.scrollIntoViewIfNeeded();
// Keep the header (bell + Create) in frame with the Now/Recent list.
const box = await aside.boundingBox();
if (box) {
const screenshotPath = testInfo.outputPath(`${name}.png`);
await page.screenshot({
animations: "disabled",
caret: "hide",
path: screenshotPath,
clip: {
x: Math.max(0, box.x),
y: Math.max(0, box.y),
width: Math.min(box.width + 24, 360),
height: Math.min(Math.max(box.height, 420), 720),
},
});
await testInfo.attach(name, { contentType: "image/png", path: screenshotPath });
return;
}
await captureScreenshot(page, testInfo, name);
}
test("sidebar Now and Recent surface active and terminal runs", async ({ page }, testInfo) => {
const stamp = Date.now();
await signup(page, `activity-${stamp}@rakazo.test`, "password12", "Activity");
await completeOnboarding(page);
const aside = page.locator("aside").first();
const activityToggle = page.getByRole("button", { name: "Activity", exact: true });
await expect(activityToggle).toHaveAttribute("aria-pressed", "false");
await expect(activityToggle).toHaveAttribute("data-activity-mode", "off");
await expect(aside.getByText("Now", { exact: true })).toHaveCount(0);
await expect(aside.getByText("Recent", { exact: true })).toHaveCount(0);
await expect(aside.getByText("Loading activity…")).toHaveCount(0);
await expect(aside.locator("[data-sidebar-group]").getByText("Chief").first()).toBeVisible();
await captureActivitySidebar(page, testInfo, "57-activity-mode-off");
const composer = page.getByPlaceholder(/Message/);
await composer.fill("keep working until I stop you");
await page.keyboard.press("Enter");
await expect(page.getByRole("button", { name: "Stop", exact: true })).toBeVisible({
timeout: 30_000,
});
await activityToggle.click();
await expect(activityToggle).toHaveAttribute("aria-pressed", "true");
await expect(activityToggle).toHaveAttribute("data-activity-mode", "on");
// Remount ActivityList so the first poll sees the in-flight run (15s interval otherwise).
await page.reload();
await expect(activityToggle).toHaveAttribute("aria-pressed", "true");
await expect(activityToggle).toHaveAttribute("data-activity-mode", "on");
await expect(page.getByRole("button", { name: "Stop", exact: true })).toBeVisible({
timeout: 30_000,
});
await expect(page.getByText("Loading activity…")).toBeHidden({ timeout: 20_000 });
await expect(aside.getByText("Now", { exact: true })).toBeVisible({ timeout: 20_000 });
await expect(activityRow(page, "Chief")).toBeVisible();
await expect(activityRow(page, "Chief")).toContainText(/keep working|Running|Queued|Starting/i);
await captureActivitySidebar(page, testInfo, "58-activity-now");
await page.getByRole("button", { name: "Stop", exact: true }).click();
await expect(page.getByRole("button", { name: "Send" })).toBeVisible({ timeout: 30_000 });
await page.reload();
await expect(activityToggle).toHaveAttribute("aria-pressed", "true");
await expect(activityToggle).toHaveAttribute("data-activity-mode", "on");
await expect(page.getByText("Loading activity…")).toBeHidden({ timeout: 20_000 });
await expect(aside.getByText("Recent", { exact: true })).toBeVisible({ timeout: 20_000 });
await expect(activityRow(page, "Chief")).toBeVisible();
await expect(activityRow(page, "Chief")).toContainText(/Cancelled|keep working/i);
await expect(aside.getByText("Now", { exact: true })).toHaveCount(0);
await captureActivitySidebar(page, testInfo, "59-activity-recent");
await page.getByPlaceholder("Search").fill("Chief");
await expect(aside.getByText("Recent", { exact: true })).toHaveCount(0);
await expect(activityRow(page, "Chief")).toHaveCount(0);
await page.getByPlaceholder("Search").fill("");
await expect(aside.getByText("Recent", { exact: true })).toBeVisible({ timeout: 20_000 });
await expect(activityRow(page, "Chief")).toBeVisible();
});