mirror of
https://github.com/baserow/baserow.git
synced 2026-12-05 00:38:35 +00:00
* feat(assistant): stop Kuma background runs cleanly Wire product Stop to durable cancellation, including before stream metadata arrives. Wait for active tools to drain and keep the items they finished on both background and existing streaming paths. Cover stopping state and retained work. Part of #6346 * Add the background Kuma replies changelog entry One entry for the whole stack, so it lands with the last PR. * fix(assistant): keep completed shared tool work when stopped * fix(assistant): honor Stop before tool dispatch and navigation * fix(assistant): check Stop through the lease renewal before tool calls The check read the run's idle connection, so a dropped connection failed the reply. * fix(assistant): keep docs search working after a dropped connection * refactor(assistant): one isStopping rule for Kuma's panel and run events
90 lines
2.6 KiB
TypeScript
90 lines
2.6 KiB
TypeScript
import { BrowserContext, expect, Locator, Page } from "@playwright/test";
|
|
|
|
/** Kuma's panel in the right sidebar of a workspace page. */
|
|
export class KumaPanel {
|
|
readonly page: Page;
|
|
readonly panel: Locator;
|
|
|
|
constructor(page: Page) {
|
|
this.page = page;
|
|
this.panel = page.locator(".assistant");
|
|
}
|
|
|
|
/** A new tab on `url`, whose panel opens by itself because another tab left it open. */
|
|
static async inNewTab(
|
|
context: BrowserContext,
|
|
url: string
|
|
): Promise<KumaPanel> {
|
|
const kuma = new KumaPanel(await context.newPage());
|
|
await kuma.page.goto(url);
|
|
await expect(kuma.panel).toBeVisible();
|
|
return kuma;
|
|
}
|
|
|
|
/** A copy of `page` with its sessionStorage, as the browser's "Duplicate tab" makes one. */
|
|
static async inDuplicateOf(page: Page): Promise<KumaPanel> {
|
|
const [duplicate] = await Promise.all([
|
|
page.waitForEvent("popup"),
|
|
page.evaluate(() => {
|
|
window.open(window.location.href);
|
|
}),
|
|
]);
|
|
const kuma = new KumaPanel(duplicate);
|
|
await expect(kuma.panel).toBeVisible();
|
|
return kuma;
|
|
}
|
|
|
|
/** Opens the panel of a page that starts with it closed, as the configured storage state leaves it. */
|
|
async open(): Promise<void> {
|
|
await expect(this.panel).toBeHidden();
|
|
await this.page.locator(".tree__link", { hasText: "Kuma AI" }).click();
|
|
await expect(this.panel).toBeVisible();
|
|
}
|
|
|
|
async send(message: string): Promise<void> {
|
|
const input = this.panel.locator(".assistant__input-textarea");
|
|
await input.fill(message);
|
|
await input.press("Enter");
|
|
}
|
|
|
|
/** The chat's AI messages, the answer still being written included. */
|
|
answers(): Locator {
|
|
return this.panel.locator(
|
|
".chat-message:not(.chat-message--own) .chat-markdown"
|
|
);
|
|
}
|
|
|
|
lastAnswer(): Locator {
|
|
return this.answers().last();
|
|
}
|
|
|
|
async expectIdle(): Promise<void> {
|
|
await expect(
|
|
this.panel.locator(".assistant__input-status")
|
|
).not.toHaveClass(/is-running/, { timeout: 60_000 });
|
|
}
|
|
|
|
/** What the panel says Kuma is doing, above the input. */
|
|
status(): Locator {
|
|
return this.panel.locator(".assistant__status-message");
|
|
}
|
|
|
|
async stop(): Promise<void> {
|
|
await this.panel.locator(".assistant__send-button--is-running").click();
|
|
}
|
|
|
|
/** The note under the last AI message when its run stopped or failed. */
|
|
lastRunOutcome(): Locator {
|
|
return this.panel
|
|
.locator(
|
|
".chat-message:not(.chat-message--own) .assistant__message-run-outcome"
|
|
)
|
|
.last();
|
|
}
|
|
|
|
async openLatestChat(): Promise<void> {
|
|
await this.panel.getByTitle("Chat History").click();
|
|
await this.page.locator(".select__item-link:visible").first().click();
|
|
}
|
|
}
|