Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: reopen dismissed Deep Research plan dialogs (#10802)

Aziz Muminov11ada1012426
diff --git a/.github/workflows/studio-frontend-ci.yml b/.github/workflows/studio-frontend-ci.yml
index e0292a59855..b3a8423356f 100644
--- a/.github/workflows/studio-frontend-ci.yml
+++ b/.github/workflows/studio-frontend-ci.yml
@@ -22,6 +22,7 @@ on:
- 'tests/studio/playwright_composer_icons.py'
- 'tests/studio/playwright_chat_autoscroll.py'
- 'tests/studio/playwright_research_freeze.py'
+ - 'tests/studio/playwright_research_review.py'
- 'tests/studio/playwright_heavy_thread.py'
- 'tests/studio/probe_dismiss_guard.py'
- 'tests/studio/playwright_nonmodal_menus.py'
@@ -411,6 +412,10 @@ jobs:
working-directory: ${{ github.workspace }}
run: python3 tests/studio/playwright_research_freeze.py
+ - name: Browser smoke for reopening the research plan
+ working-directory: ${{ github.workspace }}
+ run: python3 tests/studio/playwright_research_review.py
+
# A gate, not a measurement. The released and streamdown variants are positive controls
# that MUST flicker: a run where neither collapses means the detector stopped seeing, not
# that the flicker stopped. Chromium only on a PR, the engine whose content-visibility
diff --git a/studio/frontend/smoke-research-review-main.tsx b/studio/frontend/smoke-research-review-main.tsx
new file mode 100644
index 00000000000..e9cce22701b
--- /dev/null
+++ b/studio/frontend/smoke-research-review-main.tsx
@@ -0,0 +1,115 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Real message and plan dialog; no backend or model required.
+import {
+ AssistantRuntimeProvider,
+ MessagePrimitive,
+ ThreadPrimitive,
+ useLocalRuntime,
+} from "@assistant-ui/react";
+import { createRoot } from "react-dom/client";
+/* eslint-disable no-restricted-imports -- Regression harness drives the real research UI/store. */
+import { ResearchActivityPanel } from "@/features/chat";
+import { ResearchMessage } from "@/features/chat/components/research-message";
+import {
+ ingestResearchUpdate,
+ useResearchRunStore,
+} from "@/features/chat/stores/research-run-store";
+import type { ResearchRun } from "@/features/chat/types/research";
+/* eslint-enable no-restricted-imports */
+import "./src/index.css";
+
+const run: ResearchRun = {
+ id: "review-run",
+ threadId: "review-thread",
+ userMessageId: "question",
+ assistantMessageId: "answer",
+ status: "awaiting_approval",
+ plan: {
+ title: "Research plan",
+ steps: [{ title: "Search", query: "topic" }],
+ },
+ planRevision: 1,
+ planHash: "plan-hash",
+ steps: [],
+ sources: [],
+ lastEventSeq: 0,
+ createdAt: 1,
+ updatedAt: 1,
+};
+ingestResearchUpdate(run);
+// Model the existing follower without starting a backend connection.
+useResearchRunStore.getState().setFollowing(run.id, true, "connected");
+useResearchRunStore.getState().openPanel(run.id);
+
+const adapter = {
+ async run() {
+ throw new Error("No model calls expected");
+ },
+};
+
+function Message() {
+ return (
+ <MessagePrimitive.Root data-testid="research-message">
+ <ResearchMessage />
+ </MessagePrimitive.Root>
+ );
+}
+
+function Harness() {
+ const runtime = useLocalRuntime(adapter, {
+ initialMessages: [
+ {
+ id: "answer",
+ role: "assistant",
+ content: [{ type: "text", text: "Research" }],
+ metadata: { custom: { researchRunId: run.id, researchRun: run } },
+ },
+ ],
+ });
+ const openRunId = useResearchRunStore((state) => state.openRunId);
+ return (
+ <AssistantRuntimeProvider runtime={runtime}>
+ <div style={{ display: "flex", height: "100vh", gap: 24 }}>
+ <ThreadPrimitive.Root>
+ <ThreadPrimitive.Messages
+ components={{ Message }}
+ />
+ </ThreadPrimitive.Root>
+ <div style={{ width: 420 }}>
+ {openRunId && (
+ <ResearchActivityPanel
+ runId={openRunId}
+ onClose={() => useResearchRunStore.getState().closePanel()}
+ />
+ )}
+ </div>
+ </div>
+ </AssistantRuntimeProvider>
+ );
+}
+
+Object.assign(window, {
+ __review: {
+ state: () => useResearchRunStore.getState(),
+ closePanel: () => useResearchRunStore.getState().closePanel(),
+ setError: () =>
+ useResearchRunStore
+ .getState()
+ .setConnectionError(run.id, "Existing connection error"),
+ setDraft: () => {
+ useResearchRunStore.getState().setPlanReviewEditing(run.id, true);
+ useResearchRunStore.getState().setPlanReviewDraft(run.id, {
+ title: "Unsaved edits",
+ steps: [{ title: "Edited step", query: "edited" }],
+ });
+ },
+ complete: () =>
+ ingestResearchUpdate({
+ ...run,
+ status: "completed",
+ report: "Finished report",
+ updatedAt: 2,
+ }),
+ },
+});
+createRoot(document.getElementById("root")!).render(<Harness />);
diff --git a/studio/frontend/smoke-research-review.html b/studio/frontend/smoke-research-review.html
new file mode 100644
index 00000000000..d60f0a8f258
--- /dev/null
+++ b/studio/frontend/smoke-research-review.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <title>Research plan review regression</title>
+ <script src="/crypto-boot.js"></script>
+ </head>
+ <body>
+ <div id="root"></div>
+ <script type="module" src="/smoke-research-review-main.tsx"></script>
+ </body>
+</html>
diff --git a/studio/frontend/src/features/chat/components/research-message.tsx b/studio/frontend/src/features/chat/components/research-message.tsx
index 5c580917084..646d64b47c2 100644
--- a/studio/frontend/src/features/chat/components/research-message.tsx
+++ b/studio/frontend/src/features/chat/components/research-message.tsx
@@ -18,6 +18,7 @@ import { type ReactElement, useEffect } from "react";
import {
ensureResearchRunFollowed,
ingestResearchUpdate,
+ openResearchRun,
runningResearchActivityTitle,
useResearchRunStore,
} from "../stores/research-run-store";
@@ -40,7 +41,6 @@ export function ResearchMessage(): ReactElement | null {
const messageId = useAuiState(({ message }) => message.id);
const runId = metadata.researchRunId ?? metadata.researchRun?.id ?? "";
const session = useResearchRunStore((state) => state.sessions[runId]);
- const openPanel = useResearchRunStore((state) => state.openPanel);
const initialRun = metadata.researchRun;
const ownsRun = researchReplyOwnsRun(
session?.run?.assistantMessageId,
@@ -107,7 +107,7 @@ export function ResearchMessage(): ReactElement | null {
<div className="min-w-0">
<button
type="button"
- onClick={() => openPanel(run.id)}
+ onClick={() => openResearchRun(run)}
className="mb-3 flex items-center gap-2 rounded-full text-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
>
<span className="flex size-5 items-center justify-center rounded-full bg-primary/10 text-primary">
@@ -191,7 +191,7 @@ export function ResearchMessage(): ReactElement | null {
size="sm"
variant={needsApproval ? "default" : "outline"}
className="mt-3"
- onClick={() => openPanel(run.id)}
+ onClick={() => openResearchRun(run)}
>
{needsApproval ? "Review plan" : "View activity"}
</Button>
diff --git a/studio/frontend/src/features/chat/stores/research-run-store.ts b/studio/frontend/src/features/chat/stores/research-run-store.ts
index 0b5907d3e45..11c70b121b6 100644
--- a/studio/frontend/src/features/chat/stores/research-run-store.ts
+++ b/studio/frontend/src/features/chat/stores/research-run-store.ts
@@ -958,6 +958,19 @@ export function beginExternalResearchFollow(
};
}
+/** Reopen a dismissed plan without changing an existing session or retrying its connection. */
+export function openResearchRun(run: ResearchRun): void {
+ if (!useResearchRunStore.getState().sessions[run.id]) {
+ ingestResearchUpdate(run);
+ }
+ const state = useResearchRunStore.getState();
+ if (state.sessions[run.id]?.run.status === "awaiting_approval") {
+ // The review state exists only after the plan arrives; otherwise this is a no-op.
+ state.setPlanReviewOpen(run.id, true);
+ }
+ state.openPanel(run.id);
+}
+
/** Yield the run each time the store applies something to it, until it settles or *signal*
* aborts. Independent of the event stream, so a slow consumer cannot stall ingestion. */
export async function* watchResearchRun(
diff --git a/studio/frontend/tests/research-open-run.test.ts b/studio/frontend/tests/research-open-run.test.ts
new file mode 100644
index 00000000000..32a0df9f898
--- /dev/null
+++ b/studio/frontend/tests/research-open-run.test.ts
@@ -0,0 +1,109 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+import assert from "node:assert/strict";
+import { register } from "node:module";
+import test from "node:test";
+import type { ResearchRun } from "../src/features/chat/types/research.ts";
+import {
+ installLocalStorageFake,
+ registerBundlerResolver,
+} from "./helpers/kit.ts";
+register("./helpers/vite-env-loader.mjs", import.meta.url);
+registerBundlerResolver();
+installLocalStorageFake();
+const {
+ ingestResearchUpdate,
+ openResearchRun,
+ resetResearchRunState,
+ useResearchRunStore,
+} = await import("../src/features/chat/stores/research-run-store.ts");
+
+const run: ResearchRun = {
+ id: "run",
+ threadId: "thread",
+ userMessageId: "user",
+ status: "awaiting_approval",
+ plan: { title: "Plan", steps: [{ title: "Search", query: "topic" }] },
+ planRevision: 1,
+ planHash: "hash",
+ steps: [],
+ sources: [],
+ createdAt: 1,
+ updatedAt: 1,
+ lastEventSeq: 0,
+};
+
+test("metadata-only awaiting-approval run is hydrated before its panel opens, without fetching", () => {
+ resetResearchRunState();
+ const originalFetch = globalThis.fetch;
+ let requests = 0;
+ globalThis.fetch = async () => {
+ requests++;
+ throw new Error("Unexpected request");
+ };
+ const observed: Array<string | undefined> = [];
+ const unsubscribe = useResearchRunStore.subscribe((state) => {
+ if (state.openRunId)
+ observed.push(state.sessions[state.openRunId]?.run.threadId);
+ });
+ try {
+ openResearchRun(run);
+ assert.deepEqual(observed, ["thread"]);
+ assert.equal(
+ useResearchRunStore.getState().planReviewByRunId.run.open,
+ true,
+ );
+ assert.equal(useResearchRunStore.getState().sessions.run.following, false);
+ assert.equal(requests, 0);
+ } finally {
+ unsubscribe();
+ globalThis.fetch = originalFetch;
+ resetResearchRunState();
+ }
+});
+
+test("reopening a dismissed plan preserves edits, session identity, error and follower state", () => {
+ resetResearchRunState();
+ ingestResearchUpdate(run);
+ const state = useResearchRunStore.getState();
+ state.setPlanReviewOpen(run.id, false);
+ state.setPlanReviewEditing(run.id, true);
+ state.setPlanReviewDraft(run.id, { title: "Unsaved", steps: [] });
+ state.setConnectionError(run.id, "Authentication failed");
+ const before = useResearchRunStore.getState();
+ openResearchRun(run);
+ const after = useResearchRunStore.getState();
+ assert.equal(after.sessions, before.sessions);
+ assert.equal(after.latestRunByThreadId, before.latestRunByThreadId);
+ assert.equal(after.claimedThreadIds, before.claimedThreadIds);
+ assert.deepEqual(after.planReviewByRunId.run, {
+ ...before.planReviewByRunId.run,
+ open: true,
+ });
+ assert.equal(after.openRunId, run.id);
+});
+
+for (const status of [
+ "planning",
+ "queued",
+ "running",
+ "paused",
+ "cancelling",
+ "cancelled",
+ "completed",
+ "failed",
+] as const) {
+ test(`opening ${status} activity preserves existing session and review state`, () => {
+ resetResearchRunState();
+ ingestResearchUpdate(run);
+ useResearchRunStore.getState().setPlanReviewOpen(run.id, false);
+ ingestResearchUpdate({ ...run, status, updatedAt: 2 });
+ const before = useResearchRunStore.getState();
+ // Stale message metadata must not replace the current session or reopen its old review.
+ openResearchRun(run);
+ const after = useResearchRunStore.getState();
+ assert.equal(after.sessions, before.sessions);
+ assert.equal(after.planReviewByRunId, before.planReviewByRunId);
+ assert.equal(after.openRunId, run.id);
+ });
+}
diff --git a/studio/frontend/tsconfig.app.json b/studio/frontend/tsconfig.app.json
index f3f3d9fbf82..5f64d4efa6b 100644
--- a/studio/frontend/tsconfig.app.json
+++ b/studio/frontend/tsconfig.app.json
@@ -35,6 +35,7 @@
"smoke-find-in-page-main.tsx",
"smoke-autoscroll-main.tsx",
"smoke-research-main.tsx",
+ "smoke-research-review-main.tsx",
"smoke-heavy-thread-main.tsx",
"smoke-thread-weight-main.tsx",
"smoke-settings-main.tsx",
diff --git a/tests/studio/playwright_research_review.py b/tests/studio/playwright_research_review.py
new file mode 100644
index 00000000000..20ee4326cc3
--- /dev/null
+++ b/tests/studio/playwright_research_review.py
@@ -0,0 +1,108 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""Reopen a dismissed research plan through the real message and activity panel.
+
+Run: python tests/studio/playwright_research_review.py
+Starts and stops Vite unless SMOKE_BASE_URL is supplied. SMOKE_PORT overrides
+the local port; SMOKE_BROWSER selects chromium (CI/default) or webkit.
+"""
+
+import os
+from urllib.parse import urlparse
+
+from playwright.sync_api import expect, sync_playwright
+
+from _playwright_robust import (
+ chromium_launch_args,
+ start_vite,
+ stop_process,
+ wait_for_smoke_page,
+)
+
+PORT = int(os.environ.get("SMOKE_PORT", "5184"))
+EXTERNAL = os.environ.get("SMOKE_BASE_URL", "").strip().rstrip("/")
+BASE = EXTERNAL or f"http://127.0.0.1:{PORT}"
+
+
+def check_review(page):
+ errors = []
+ requests = []
+ page.on("pageerror", lambda error: errors.append(str(error)))
+
+ def reject_api(route):
+ requests.append(route.request.url)
+ route.fulfill(status = 500, body = "Unexpected API request")
+
+ page.route(lambda url: urlparse(url).path.startswith("/api/"), reject_api)
+ page.goto(f"{BASE}/smoke-research-review.html")
+ dialog = page.get_by_role("dialog", name = "Review the research plan")
+ expect(dialog).to_be_visible(timeout = 30_000)
+ page.keyboard.press("Escape")
+ expect(dialog).to_be_hidden()
+ page.evaluate("() => { window.__review.setDraft(); window.__review.setError(); }")
+ before = page.evaluate("() => window.__review.state()")
+
+ # Scope to the message: the panel's own button already reopened on the base.
+ button = page.get_by_test_id("research-message").get_by_role(
+ "button", name = "Review plan", exact = True
+ )
+ button.click()
+ expect(dialog).to_be_visible()
+ after = page.evaluate("() => window.__review.state()")
+ assert after["sessions"] == before["sessions"], "Review changed connection/run state"
+ assert after["planReviewByRunId"]["review-run"] == {
+ **before["planReviewByRunId"]["review-run"],
+ "open": True,
+ }, "Review discarded the draft"
+
+ page.keyboard.press("Escape")
+ expect(dialog).to_be_hidden()
+ page.evaluate("() => window.__review.closePanel()")
+ button.click()
+ expect(dialog).to_be_visible()
+ page.keyboard.press("Escape")
+ expect(dialog).to_be_hidden()
+
+ page.evaluate("() => { window.__review.complete(); window.__review.closePanel(); }")
+ completed = page.evaluate("() => window.__review.state()")
+ page.get_by_test_id("research-message").get_by_role("button", name = "View activity").click()
+ viewed = page.evaluate("() => window.__review.state()")
+ assert viewed["openRunId"] == "review-run"
+ assert viewed["sessions"] == completed["sessions"]
+ assert viewed["planReviewByRunId"] == completed["planReviewByRunId"]
+ expect(dialog).to_have_count(0)
+ assert requests == [], f"Review made API requests: {requests}"
+ assert errors == [], f"Page errors: {errors}"
+
+
+def main():
+ proc = None
+ try:
+ if not EXTERNAL:
+ proc = start_vite(PORT)
+ wait_for_smoke_page(
+ f"{BASE}/smoke-research-review.html", "smoke-research-review-main.tsx", proc = proc
+ )
+ with sync_playwright() as pw:
+ name = os.environ.get("SMOKE_BROWSER", "chromium")
+ if name not in {"chromium", "webkit"}:
+ raise ValueError(f"Unsupported SMOKE_BROWSER: {name}")
+ browser_type = getattr(pw, name)
+ executable = os.environ.get("PW_EXECUTABLE")
+ browser = browser_type.launch(
+ args = chromium_launch_args() if name == "chromium" else [],
+ **({"executable_path": executable} if executable else {}),
+ )
+ try:
+ check_review(browser.new_page())
+ finally:
+ browser.close()
+ print("PASS: dismissed plan reopens; draft, connection and activity behavior preserved")
+ finally:
+ if proc is not None:
+ stop_process(proc)
+
+
+if __name__ == "__main__":
+ main()