feat(web): workspaces, connect and status pages plus the full chat experience
- workspaces list + new-workspace flow (add -> ensure -> navigate), server context bar - connect: manual/pair-code redeem, QR scan with paste fallback, paired summary, disconnect - status: info/health/resources/models/devices/connection cards with 3s visible-only polling - chat: 3/2/1-column layout, session tree, virtualized stream, tool/thinking/todo/batch blocks, composer with queue chips and abort, subagents/todo/tasks panel, attention + diff review modals, history pagination merged with live entries - canonical reducer reused via @protocol alias (no duplicated types) - 63 vitest tests, typecheck + build green, zh/en parity at 411 keys
This commit is contained in:
1 parent
2e5d6d5006
commit
721661177c
61 files changed
+10931
-355
No files matched your search
@@ -0,0 +1,90 @@
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { beforeAll, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { setLanguage } from "@/lib/i18n";
|
||||
import { MessageStream } from "@/features/chat/message-stream";
|
||||
import { fullStreamSession } from "./chat-fixtures";
|
||||
|
||||
beforeAll(async () => {
|
||||
await setLanguage("en");
|
||||
});
|
||||
|
||||
function renderStream() {
|
||||
const session = fullStreamSession();
|
||||
const utils = render(
|
||||
<MessageStream
|
||||
session={session}
|
||||
entries={session.entries}
|
||||
hasMore={false}
|
||||
loadingOlder={false}
|
||||
error={null}
|
||||
onLoadOlder={vi.fn()}
|
||||
onRetry={vi.fn()}
|
||||
onOpenSubagent={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
return { ...utils, session };
|
||||
}
|
||||
|
||||
describe("chat message stream", () => {
|
||||
it("renders user, assistant, thinking, tool, todo, batch and error blocks from a snapshot", () => {
|
||||
renderStream();
|
||||
|
||||
expect(screen.getByText("Fix the auth bug")).toBeInTheDocument();
|
||||
expect(screen.getByText("Fix the auth bug").closest("article")).toHaveClass("msg--user");
|
||||
expect(screen.getByText("Looking at the auth path now.")).toBeInTheDocument();
|
||||
expect(screen.getByText("Check every caller before editing")).toBeInTheDocument();
|
||||
expect(screen.getByText("bash")).toBeInTheDocument();
|
||||
expect(screen.getByText("edit")).toBeInTheDocument();
|
||||
|
||||
expect(screen.getByText("Todo · 1/3")).toBeInTheDocument();
|
||||
expect(screen.getByText("Applying the fix")).toBeInTheDocument();
|
||||
expect(screen.getByText("Apply fix")).toBeInTheDocument();
|
||||
expect(screen.getByText("Batch dispatch · 2/3")).toBeInTheDocument();
|
||||
expect(screen.getByText("writer")).toBeInTheDocument();
|
||||
|
||||
expect(screen.getByText("agent aborted")).toBeInTheDocument();
|
||||
expect(screen.getByText("agent aborted").closest(".msg__error")).not.toBeNull();
|
||||
});
|
||||
|
||||
it("expands a tool card to show output and an edit diff", () => {
|
||||
renderStream();
|
||||
|
||||
const bashButton = screen.getByText("bash").closest("button");
|
||||
expect(bashButton).not.toBeNull();
|
||||
fireEvent.click(bashButton!);
|
||||
expect(screen.getByText(/a\.txt/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/"command": "ls -la"/)).toBeInTheDocument();
|
||||
|
||||
const editButton = screen.getByText("edit").closest("button");
|
||||
fireEvent.click(editButton!);
|
||||
expect(screen.getByText("permission denied")).toBeInTheDocument();
|
||||
expect(screen.getAllByText("src/auth.ts").length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("shows a streaming caret only for an unfinished assistant entry", () => {
|
||||
const session = fullStreamSession();
|
||||
session.entries = [
|
||||
{
|
||||
id: "a-live",
|
||||
role: "assistant",
|
||||
ts: Date.now(),
|
||||
done: false,
|
||||
blocks: [{ type: "text", text: "partial answer" }],
|
||||
},
|
||||
];
|
||||
render(
|
||||
<MessageStream
|
||||
session={session}
|
||||
entries={session.entries}
|
||||
hasMore={false}
|
||||
loadingOlder={false}
|
||||
error={null}
|
||||
onLoadOlder={vi.fn()}
|
||||
onRetry={vi.fn()}
|
||||
onOpenSubagent={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByText("partial answer")).toHaveClass("streaming");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user