* feat(app): command center tabs, recent workspaces, and agents in workspace search
The command center gets All · Workspaces · Files · Actions tabs under the search
field. Tab and Shift+Tab rotate them on web, a tab keeps the query and starts at
its top, and Backspace on an empty field returns to All. ⌘P opens on Files in
place of the Files scope chip.
All leads with the three most recent workspaces other than the open one. Agent
rows are gone: an agent's title now finds its workspace, which shows the agent on
a third line and opens that agent's tab.
The selection now follows the first result until the user moves it, so rows that
load above it do not leave it on the row below.
* feat(app): archived workspaces in command center search
A query in All or Workspaces now also finds archived workspaces through
agent history, appended after the active matches. Archived rows show the
archive time and an Archived badge, and open the workspace's latest agent
where it can be unarchived. Hosts without history search contribute
nothing. History's archived badge moves into a shared ArchivedBadge.
* fix(app): put the command center divider between the field and the tabs
The tabs belong to the results, not the search field, so the rule now
separates the field from the tab bar. The tab-rotation test also pins the
list's top, since the tabs no longer live inside the header it measured.
* fix(app): rank agent matches by quality, keep background workspaces out of Recent, explain Files off-workspace
- Score each agent together with its workspace's title and subtitle, so a
query split across them ("payments login") finds the row, and pick the
workspace's own match only when it is as good as its best agent match.
Across workspaces, match quality now ranks before own-versus-agent.
- Carry the workspace's background flag through the project summary and
leave background workspaces out of Recent workspaces, as the sidebar
does. A query still finds them.
- The Files tab outside a workspace says "Open a workspace to search
files" instead of "No matches".
* fix(app): settle command center selection, name agents only for loose matches, drop Files off-workspace
- Name a workspace's agent only when the workspace's own text does not match
contiguously and the agent does; a change-request hit is always an own match.
- Follow the first row only until every source for the query and tab has
loaded, then keep the selection by ID so reorders do not move it.
- Projects stay loading until an online host's workspaces have arrived; the
agent directory reports ready first.
- Outside a workspace there is no Files tab and All lists no files; the All
placeholder names only what the available tabs search.
- The unqueried Workspaces list follows the sidebar's Show background setting.
* fix(app): keep Projects loading honest, rank own-name matches by their agents too, refresh archived search after archive
- The command center waits for online hosts' workspaces itself instead of
through useProjects. useProjects held isLoading until workspaces
hydrated, but a failed workspace request never hydrates, so the
Projects screen could spin forever.
- A workspace that matches on its own name is ranked by the better of
that match and its agents', so typing into an agent title shared with
another workspace no longer drops it below that workspace and back.
- Archiving a workspace marks agent history stale. Archived search reused
a cached page that still listed the agents as active, so a workspace
archived in the last 30 seconds matched in neither list.
* fix(app): decide command center agent matches by match class
One rule now picks both what a workspace row shows and how it ranks. A
match falls in a class: every word at a word boundary, a word inside a
word, or scattered/misspelled. A row names its agent only when the agent
matches in a closer class than the workspace's own text, never on a
change-request hit. Rows rank by class, then own text ahead of an agent,
then score, then recency.
The previous rules chose the ranking candidate and the displayed
candidate separately, so each fix moved the edge case: positional tier
gaps named agents mid-word, and ranking by a hidden agent let a mid-word
name outrank a word-boundary one with nothing on screen to explain it.
* style(app): format command center workspace search import
* fix(app): settle archived search when no history host is reachable
With no searchable host online, the history query is disabled under a new
key, and keepPreviousData kept serving the old key's rows as placeholder
data. Archived search read that as still waiting for results, so the
command center selection never settled and followed every re-rank.
Previous results now stand in only while the query can run.
351 lines
14 KiB
TypeScript
351 lines
14 KiB
TypeScript
import { execFileSync } from "node:child_process";
|
|
import { expect } from "@playwright/test";
|
|
import { test } from "../support/fixtures";
|
|
import { gotoAppShell } from "../support/helpers/app";
|
|
import { createIdleAgent } from "../support/helpers/archive-tab";
|
|
import { expectAgentTabActive } from "../support/helpers/launcher";
|
|
import {
|
|
commandCenterSection,
|
|
expectCommandCenterTab,
|
|
openCommandCenter,
|
|
selectCommandCenterTab,
|
|
} from "../support/helpers/command-center";
|
|
import { addOfflineHostAndReload } from "../support/helpers/hosts";
|
|
import { expectAppRoute } from "../support/helpers/route-assertions";
|
|
import { seedWorkspace } from "../support/helpers/seed-client";
|
|
import { getServerId } from "../support/helpers/server-id";
|
|
import { seedRunningMockAgentWorkspace, openAgentRoute } from "../support/helpers/mock-agent";
|
|
import { buildHostWorkspaceRoute } from "@/utils/host-routes";
|
|
|
|
const PRIMARY_HOST_LABEL = "Primary Host";
|
|
const SECONDARY_HOST_ID = "host-command-center-workspaces-secondary";
|
|
const WORKSPACE_TITLE = "Payments Refactor";
|
|
const WORKSPACE_BRANCH = "feature/cmd-k-workspaces";
|
|
const AGENT_TITLE = "Fix checkout retries";
|
|
|
|
test.describe("Command center workspaces", () => {
|
|
test.describe.configure({ timeout: 180_000 });
|
|
|
|
test("workspace results overlay live status", async ({ page }) => {
|
|
const workspace = await seedRunningMockAgentWorkspace({
|
|
repoPrefix: "command-center-status-",
|
|
title: "Review checkout retries",
|
|
model: "five-minute-stream",
|
|
initialPrompt: "Keep working on checkout retries",
|
|
});
|
|
try {
|
|
await openAgentRoute(page, workspace);
|
|
await expectAgentTabActive(page, workspace.agentId);
|
|
const panel = await openCommandCenter(page);
|
|
// Recent workspaces leaves out the open one; the Workspaces tab lists every workspace.
|
|
await selectCommandCenterTab(panel, "Workspaces");
|
|
const row = panel.getByTestId(
|
|
`command-center-workspace-${getServerId()}:${workspace.workspaceId}`,
|
|
);
|
|
await expect(row.getByRole("progressbar", { name: "Agent running" })).toBeVisible();
|
|
await workspace.client.cancelAgent(workspace.agentId);
|
|
await expect(row.getByRole("progressbar")).toHaveCount(0);
|
|
} finally {
|
|
await workspace.cleanup();
|
|
}
|
|
});
|
|
|
|
test("workspace results show their title, host, and branch and open the workspace", async ({
|
|
page,
|
|
}) => {
|
|
const seeded = await seedWorkspace({
|
|
repoPrefix: "command-center-workspace-",
|
|
title: WORKSPACE_TITLE,
|
|
});
|
|
|
|
try {
|
|
execFileSync("git", ["checkout", "-b", WORKSPACE_BRANCH], {
|
|
cwd: seeded.repoPath,
|
|
stdio: "ignore",
|
|
});
|
|
const refreshed = await seeded.client.checkoutRefresh(seeded.repoPath);
|
|
if (!refreshed.success) {
|
|
throw new Error(`Failed to refresh checkout: ${JSON.stringify(refreshed.error)}`);
|
|
}
|
|
const agent = await createIdleAgent(seeded.client, {
|
|
cwd: seeded.repoPath,
|
|
workspaceId: seeded.workspaceId,
|
|
title: AGENT_TITLE,
|
|
});
|
|
|
|
await gotoAppShell(page);
|
|
await addOfflineHostAndReload(page, {
|
|
serverId: SECONDARY_HOST_ID,
|
|
label: "Secondary Host",
|
|
primaryLabel: PRIMARY_HOST_LABEL,
|
|
});
|
|
|
|
const panel = await openCommandCenter(page);
|
|
await selectCommandCenterTab(panel, "Workspaces");
|
|
const row = panel.getByTestId(
|
|
`command-center-workspace-${getServerId()}:${seeded.workspaceId}`,
|
|
);
|
|
const agentLine = row.getByTestId("command-center-workspace-agent");
|
|
await expect(row).toBeVisible({ timeout: 30_000 });
|
|
await expect(row).toContainText(WORKSPACE_TITLE);
|
|
await expect(row).toContainText(WORKSPACE_BRANCH);
|
|
|
|
// The subtitle disambiguates by project: host · project · branch (multi-host).
|
|
const subtitle = row.getByTestId("command-center-workspace-subtitle");
|
|
await expect(subtitle).toContainText(PRIMARY_HOST_LABEL);
|
|
await expect(subtitle).toContainText(seeded.projectDisplayName);
|
|
await expect(subtitle).toContainText(WORKSPACE_BRANCH);
|
|
await expect(agentLine).toHaveCount(0);
|
|
|
|
await test.step("a workspace matches on its own fields", async () => {
|
|
const input = panel.getByTestId("command-center-input");
|
|
for (const query of [
|
|
PRIMARY_HOST_LABEL,
|
|
WORKSPACE_BRANCH,
|
|
WORKSPACE_TITLE,
|
|
seeded.projectDisplayName,
|
|
]) {
|
|
await input.fill(query);
|
|
await expect(row).toBeVisible();
|
|
await expect(agentLine).toHaveCount(0);
|
|
}
|
|
// `cwd` is never shown, so it must never match.
|
|
await input.fill(seeded.repoPath);
|
|
await expect(row).not.toBeVisible();
|
|
});
|
|
|
|
await test.step("an agent title finds its workspace and names the agent", async () => {
|
|
await panel.getByTestId("command-center-input").fill(AGENT_TITLE);
|
|
await expect(agentLine).toHaveText(AGENT_TITLE);
|
|
await expect(panel.getByText("Agents", { exact: true })).toHaveCount(0);
|
|
await page.keyboard.press("Enter");
|
|
await expectAgentTabActive(page, agent.id);
|
|
});
|
|
|
|
await test.step("a workspace match opens the workspace", async () => {
|
|
const searchAgain = await openCommandCenter(page);
|
|
await expectCommandCenterTab(searchAgain, "All");
|
|
await searchAgain.getByTestId("command-center-input").fill(WORKSPACE_TITLE);
|
|
await page.keyboard.press("Enter");
|
|
await expectAppRoute(page, buildHostWorkspaceRoute(getServerId(), seeded.workspaceId), {
|
|
timeout: 30_000,
|
|
});
|
|
});
|
|
} finally {
|
|
await seeded.cleanup();
|
|
}
|
|
});
|
|
|
|
test("All leads with the three most recent workspaces other than the open one", async ({
|
|
page,
|
|
}) => {
|
|
const older = [];
|
|
for (const title of ["Recent oldest", "Recent third", "Recent second", "Recent newest"]) {
|
|
older.push(await seedWorkspace({ repoPrefix: "command-center-recent-", title }));
|
|
}
|
|
const current = await seedWorkspace({
|
|
repoPrefix: "command-center-recent-",
|
|
title: "Open one",
|
|
});
|
|
try {
|
|
await page.goto(buildHostWorkspaceRoute(getServerId(), current.workspaceId));
|
|
const panel = await openCommandCenter(page);
|
|
await expectCommandCenterTab(panel, "All");
|
|
await expect(commandCenterSection(panel, "Recent workspaces")).toBeVisible();
|
|
const rowOf = (workspaceId: string) =>
|
|
panel.getByTestId(`command-center-workspace-${getServerId()}:${workspaceId}`);
|
|
|
|
await expect(rowOf(older[3].workspaceId)).toBeVisible({ timeout: 30_000 });
|
|
await expect(rowOf(older[2].workspaceId)).toBeVisible();
|
|
await expect(rowOf(older[1].workspaceId)).toBeVisible();
|
|
await expect(rowOf(older[0].workspaceId)).toHaveCount(0);
|
|
await expect(rowOf(current.workspaceId)).toHaveCount(0);
|
|
await expect(commandCenterSection(panel, "Workspaces")).toHaveCount(0);
|
|
|
|
// The newest recent workspace is selected, so Enter goes straight back to it.
|
|
await page.keyboard.press("Enter");
|
|
await expectAppRoute(page, buildHostWorkspaceRoute(getServerId(), older[3].workspaceId), {
|
|
timeout: 30_000,
|
|
});
|
|
} finally {
|
|
for (const seeded of [current, ...older]) await seeded.cleanup();
|
|
}
|
|
});
|
|
|
|
test("archived workspaces follow active matches and open where they can be unarchived", async ({
|
|
page,
|
|
}) => {
|
|
const active = await seedWorkspace({
|
|
repoPrefix: "command-center-archived-active-",
|
|
title: "Billing dashboard",
|
|
});
|
|
const archived = await seedWorkspace({
|
|
repoPrefix: "command-center-archived-",
|
|
title: "Billing cleanup",
|
|
});
|
|
try {
|
|
await createIdleAgent(archived.client, {
|
|
cwd: archived.repoPath,
|
|
workspaceId: archived.workspaceId,
|
|
title: "Audit invoice totals",
|
|
});
|
|
expect((await archived.client.archiveWorkspace(archived.workspaceId)).error).toBeNull();
|
|
await gotoAppShell(page);
|
|
const panel = await openCommandCenter(page);
|
|
const input = panel.getByTestId("command-center-input");
|
|
const activeRow = panel.getByTestId(
|
|
`command-center-workspace-${getServerId()}:${active.workspaceId}`,
|
|
);
|
|
const archivedRow = panel.getByTestId(
|
|
`command-center-workspace-${getServerId()}:${archived.workspaceId}`,
|
|
);
|
|
|
|
await test.step("an empty query never lists archived workspaces", async () => {
|
|
await selectCommandCenterTab(panel, "Workspaces");
|
|
await expect(activeRow).toBeVisible({ timeout: 30_000 });
|
|
await expect(archivedRow).toHaveCount(0);
|
|
});
|
|
|
|
await test.step("a query lists the archived workspace after the active one", async () => {
|
|
await input.fill("billing");
|
|
await expect(archivedRow).toBeVisible({ timeout: 30_000 });
|
|
await expect(archivedRow).toContainText("Archived");
|
|
await expect(activeRow).not.toContainText("Archived");
|
|
const activeTop = (await activeRow.boundingBox())?.y ?? Number.NaN;
|
|
const archivedTop = (await archivedRow.boundingBox())?.y ?? Number.NaN;
|
|
expect(archivedTop).toBeGreaterThan(activeTop);
|
|
});
|
|
|
|
await test.step("an agent title finds the archived workspace on All", async () => {
|
|
// Opened from the app shell, outside any workspace.
|
|
await selectCommandCenterTab(panel, "All", { workspaceOpen: false });
|
|
await input.fill("invoice totals");
|
|
await expect(archivedRow.getByTestId("command-center-workspace-agent")).toHaveText(
|
|
"Audit invoice totals",
|
|
{ timeout: 30_000 },
|
|
);
|
|
await expect(activeRow).toHaveCount(0);
|
|
});
|
|
|
|
await test.step("opening it lands where the workspace can be unarchived", async () => {
|
|
await page.keyboard.press("Enter");
|
|
await expect(page.getByText("Workspace archived", { exact: true })).toBeVisible({
|
|
timeout: 30_000,
|
|
});
|
|
await expect(page.getByRole("button", { name: "Unarchive", exact: true })).toBeVisible();
|
|
});
|
|
} finally {
|
|
await active.cleanup();
|
|
await archived.cleanup();
|
|
}
|
|
});
|
|
|
|
test("single-host workspace subtitle omits the host and shows project · branch", async ({
|
|
page,
|
|
}) => {
|
|
const seeded = await seedWorkspace({
|
|
repoPrefix: "command-center-workspace-single-",
|
|
title: WORKSPACE_TITLE,
|
|
});
|
|
|
|
try {
|
|
execFileSync("git", ["checkout", "-b", WORKSPACE_BRANCH], {
|
|
cwd: seeded.repoPath,
|
|
stdio: "ignore",
|
|
});
|
|
const refreshed = await seeded.client.checkoutRefresh(seeded.repoPath);
|
|
if (!refreshed.success) {
|
|
throw new Error(`Failed to refresh checkout: ${JSON.stringify(refreshed.error)}`);
|
|
}
|
|
|
|
// No secondary host: with a single host, the host label is gated away.
|
|
await gotoAppShell(page);
|
|
|
|
const panel = await openCommandCenter(page);
|
|
const row = panel.getByTestId(
|
|
`command-center-workspace-${getServerId()}:${seeded.workspaceId}`,
|
|
);
|
|
await expect(row).toBeVisible({ timeout: 30_000 });
|
|
|
|
const subtitle = row.getByTestId("command-center-workspace-subtitle");
|
|
await expect(subtitle).toHaveText(`${seeded.projectDisplayName} · ${WORKSPACE_BRANCH}`);
|
|
} finally {
|
|
await seeded.cleanup();
|
|
}
|
|
});
|
|
});
|
|
|
|
test.describe("Compact sidebar inspection", () => {
|
|
test.use({ viewport: { width: 390, height: 844 } });
|
|
|
|
async function openSidebar(page: import("@playwright/test").Page) {
|
|
await page.getByRole("button", { name: "Open menu", exact: true }).click();
|
|
await expect(page.getByTestId("sidebar-search")).toBeVisible();
|
|
}
|
|
|
|
async function expectSidebarPreserved(page: import("@playwright/test").Page) {
|
|
await expect(page.getByRole("button", { name: "Close menu", exact: true })).toHaveAttribute(
|
|
"aria-expanded",
|
|
"true",
|
|
);
|
|
await expect(page.getByTestId("sidebar-search")).toBeVisible();
|
|
}
|
|
|
|
test("canceling Search retains the compact sidebar", async ({ page }) => {
|
|
await gotoAppShell(page);
|
|
await openSidebar(page);
|
|
await openCommandCenter(page);
|
|
await page.keyboard.press("Escape");
|
|
await expect(page.getByTestId("command-center-panel")).not.toBeVisible();
|
|
await expectSidebarPreserved(page);
|
|
});
|
|
test("canceling Import session retains the compact sidebar", async ({ page }) => {
|
|
await gotoAppShell(page);
|
|
await openSidebar(page);
|
|
await page
|
|
.getByTestId("sidebar-project-empty-state")
|
|
.getByRole("button", { name: "Import session", exact: true })
|
|
.click();
|
|
await expect(page.getByTestId("import-session-sheet")).toBeVisible();
|
|
await page.getByRole("button", { name: "Close", exact: true }).click();
|
|
await expect(page.getByTestId("import-session-sheet")).not.toBeVisible();
|
|
await expectSidebarPreserved(page);
|
|
});
|
|
|
|
test("Search reveals the same workspace and a selected root agent", async ({ page }) => {
|
|
const seeded = await seedWorkspace({
|
|
repoPrefix: "compact-search-destination-",
|
|
title: "Compact destination",
|
|
});
|
|
try {
|
|
await createIdleAgent(seeded.client, {
|
|
cwd: seeded.repoPath,
|
|
workspaceId: seeded.workspaceId,
|
|
title: "Compact root agent",
|
|
});
|
|
await page.goto(buildHostWorkspaceRoute(getServerId(), seeded.workspaceId));
|
|
await openSidebar(page);
|
|
const search = await openCommandCenter(page);
|
|
await search.getByTestId("command-center-input").fill("Compact destination");
|
|
await search
|
|
.getByTestId(`command-center-workspace-${getServerId()}:${seeded.workspaceId}`)
|
|
.click();
|
|
await expect(page.getByRole("button", { name: "Open menu", exact: true })).toBeVisible();
|
|
await expectAppRoute(page, buildHostWorkspaceRoute(getServerId(), seeded.workspaceId));
|
|
await openSidebar(page);
|
|
const agentSearch = await openCommandCenter(page);
|
|
await agentSearch.getByTestId("command-center-input").fill("Compact root agent");
|
|
await agentSearch
|
|
.getByTestId(`command-center-workspace-${getServerId()}:${seeded.workspaceId}`)
|
|
.getByTestId("command-center-workspace-agent")
|
|
.click();
|
|
await expect(page.getByRole("button", { name: "Open menu", exact: true })).toBeVisible();
|
|
await expect(
|
|
page.getByRole("textbox", { name: "Message agent...", exact: true }),
|
|
).toBeVisible();
|
|
} finally {
|
|
await seeded.cleanup();
|
|
}
|
|
});
|
|
});
|