style(teacher): make the retry action a playful sticker

This commit is contained in:
鲨鱼辣椒
2026-09-28 15:38:20 +08:00
parent a7124fb53a
commit cb48f604dd
7 changed files with 52 additions and 7 deletions

View File

@@ -10,6 +10,13 @@ const samples: Record<string, unknown> = {
const scenario = new URLSearchParams(location.search).get('kind') ?? 'ideas';
let current: TeacherTopic = { schemaVersion: 1, revision: 1, id: 'discussion-fixture', accountId: 'fixture', projectId: 'fixture', sourceConversationId: 'project', definition, version: 1, createdAt: 'now', updatedAt: 'now', requests: Array.from({ length: 8 }, (_, i) => ({ id: `r${i}`, text: i === 7 ? '我还没想好,我们边聊边想。' : '我希望这个游戏更有意思。', references: [], createdAt: 'now', sourceCursor: { workerGeneration: 0, seq: i }, sourceCapturedAt: 'now', includedSourceMessageIds: [], omittedMessages: 0, status: 'completed', response: i === 7 ? '可以,我们先把已经想到的放在一起。哪里还不确定,就留着继续聊。' : '先从你最在意的一个小地方开始想。', ...(i === 7 ? { suggestedQuestions: ['有什么好玩的想法?'] } : {}) })), ...(samples[scenario] ? { discussion: { id: 'tool', revision: 1, status: 'active', content: structuredClone(samples[scenario]) } } : {}) };
const stream = Object.assign(new EventTarget(), { close() {}, onerror: null, onopen: null });
if (scenario === 'retry') {
const status = new URLSearchParams(location.search).get('status') === 'cancelled' ? 'cancelled' : 'failed';
current.requests = [{
...current.requests[0], text: '给我一点提示', intent: 'suggestions', status, response: '',
...(status === 'failed' ? { error: '这次没连上,我们可以再试一次。' } : {}),
}];
}
if (scenario === 'rich-text') {
current.requests = [{
...current.requests[0], text: '帮我看看项目和最近的讨论',

View File

@@ -21,6 +21,31 @@ test.beforeAll(async () => {
await server.listen(); url = server.resolvedUrls!.local[0];
});
test.afterAll(async () => { await server?.close(); });
test('retry stickers stay readable and preserve drafts in a 319px consultation', async ({ page }) => {
await page.setViewportSize({ width: 1180, height: 800 });
await page.addInitScript(() => localStorage.clear());
for (const status of ['failed', 'cancelled']) {
await page.goto(`${url}?kind=retry&status=${status}&width=319`);
const panel = page.getByTestId('teacher-chat-panel');
const retry = page.getByRole('button', { name: '继续看看👀', exact: true });
await expect(retry).toBeEnabled();
await expect(retry).toHaveText('继续看看👀');
expect(await retry.evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true);
const [panelBounds, retryBounds] = await Promise.all([panel.boundingBox(), retry.boundingBox()]);
expect(retryBounds!.x).toBeGreaterThanOrEqual(panelBounds!.x);
expect(retryBounds!.x + retryBounds!.width).toBeLessThanOrEqual(panelBounds!.x + panelBounds!.width);
await panel.screenshot({ path: test.info().outputPath(`retry-${status}-319.png`) });
const input = page.getByRole('textbox', { name: '向智能体提问' });
await input.fill('我还有一点自己的想法');
await retry.click();
await expect(page.getByText('我们可以先从一个小地方开始。')).toBeVisible();
await expect(input).toHaveValue('我还有一点自己的想法');
expect(await page.evaluate(() => (window as unknown as { __teacherReplyInputs: unknown[] }).__teacherReplyInputs)).toEqual([
{ requestId: expect.any(String), text: '给我一点提示', intent: 'suggestions', references: [], sourceConversationId: 'source' },
]);
}
});
for (const width of [319, 508]) {
test(`empty-composer hint stays lightweight and keeps the send position stable at ${width}px`, async ({ page }) => {
await page.setViewportSize({ width: 1180, height: 800 });