perf(ci): speed up full WebUI regression gates (#6684)
* perf(ci): speed up full WebUI regression gates * perf(ci): balance browser shards with measured hosted timings
This commit is contained in:
1 parent
e91906bc3a
commit
7782095a85
21 files changed
+821
-346
No files matched your search
+80
-16
@@ -301,7 +301,7 @@ jobs:
|
||||
retention-days: 7
|
||||
|
||||
webui_checks:
|
||||
name: WebUI checks and build
|
||||
name: WebUI static checks
|
||||
needs: changes
|
||||
if: needs.changes.outputs.webui_required == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
@@ -331,6 +331,10 @@ jobs:
|
||||
working-directory: webui
|
||||
run: bun run test:imports
|
||||
|
||||
- name: Test CI shard planning and failure gates
|
||||
working-directory: webui
|
||||
run: bun run test:ci
|
||||
|
||||
- name: Lint WebUI
|
||||
working-directory: webui
|
||||
run: bun run lint
|
||||
@@ -339,20 +343,69 @@ jobs:
|
||||
working-directory: webui
|
||||
run: bun run typecheck
|
||||
|
||||
- name: Test WebUI
|
||||
- name: Type check browser tests and fixtures
|
||||
working-directory: webui
|
||||
run: bun run test:coverage
|
||||
run: bun run typecheck:browser
|
||||
|
||||
- name: Build WebUI
|
||||
webui_build:
|
||||
name: WebUI production build
|
||||
needs: changes
|
||||
if: needs.changes.outputs.webui_required == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: 1.3.13
|
||||
- name: Install WebUI dependencies
|
||||
working-directory: webui
|
||||
run: bun install --frozen-lockfile
|
||||
- name: Type check production sources and build WebUI
|
||||
working-directory: webui
|
||||
run: bun run build
|
||||
|
||||
webui_unit:
|
||||
name: WebUI unit and coverage
|
||||
needs: changes
|
||||
if: needs.changes.outputs.webui_required == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: 1.3.13
|
||||
- name: Install WebUI dependencies
|
||||
working-directory: webui
|
||||
run: bun install --frozen-lockfile
|
||||
# Vitest 2's Istanbul blob merge can mark an unhit inner branch covered
|
||||
# using another shard's outer range. Keep the original full V8 coverage gate.
|
||||
- name: Run all unit tests with original coverage thresholds
|
||||
working-directory: webui
|
||||
run: bun run test:coverage --reporter=default --reporter=json --outputFile.json=test-results/unit/results.json
|
||||
- name: Retain unit and coverage results
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: webui-unit-coverage
|
||||
path: |
|
||||
webui/test-results/unit/results.json
|
||||
webui/coverage/coverage-summary.json
|
||||
if-no-files-found: error
|
||||
overwrite: true
|
||||
retention-days: 7
|
||||
|
||||
webui_browser:
|
||||
name: WebUI browser
|
||||
name: WebUI browser (${{ matrix.shard }}/4)
|
||||
needs: changes
|
||||
if: needs.changes.outputs.webui_required == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 25
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
shard: [1, 2, 3, 4]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -370,33 +423,44 @@ jobs:
|
||||
working-directory: webui
|
||||
run: bun x playwright install --with-deps chromium
|
||||
|
||||
- name: Test browser layout and history motion
|
||||
- name: Test full-suite browser shard with real layout and motion
|
||||
working-directory: webui
|
||||
run: bun run test:browser --trace=retain-on-failure
|
||||
run: bun run test:browser:shard --shard=${{ matrix.shard }}/4
|
||||
|
||||
- name: Retain browser failure details
|
||||
if: failure()
|
||||
- name: Retain browser timings and failure details
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: browser-failures
|
||||
name: browser-results-${{ matrix.shard }}
|
||||
path: |
|
||||
webui/test-results/browser/results-*.json
|
||||
webui/test-results/browser/**/trace.zip
|
||||
webui/test-results/browser/**/test-failed-*.png
|
||||
webui/test-results/browser/**/error-context.md
|
||||
if-no-files-found: error
|
||||
overwrite: true
|
||||
retention-days: 7
|
||||
|
||||
webui:
|
||||
needs: [changes, webui_checks, webui_browser]
|
||||
needs: [changes, webui_checks, webui_build, webui_unit, webui_browser]
|
||||
if: always() && needs.changes.outputs.webui_required == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 1
|
||||
|
||||
steps:
|
||||
- name: Require both WebUI jobs to pass
|
||||
- name: Require every full-suite WebUI lane to pass
|
||||
env:
|
||||
CHECKS_RESULT: ${{ needs.webui_checks.result }}
|
||||
BROWSER_RESULT: ${{ needs.webui_browser.result }}
|
||||
run: test "$CHECKS_RESULT" = success && test "$BROWSER_RESULT" = success
|
||||
CHECK_RESULTS: ${{ toJSON(needs) }}
|
||||
run: |
|
||||
python - <<'PY'
|
||||
import json
|
||||
import os
|
||||
|
||||
failed = {name: job["result"] for name, job in json.loads(os.environ["CHECK_RESULTS"]).items()
|
||||
if job["result"] != "success"}
|
||||
if failed:
|
||||
raise SystemExit(f"WebUI checks did not all pass: {failed}")
|
||||
PY
|
||||
|
||||
tui:
|
||||
needs: changes
|
||||
@@ -582,7 +646,7 @@ jobs:
|
||||
|
||||
required:
|
||||
name: CI required
|
||||
needs: [changes, test, windows_process, windows_installers, webui_checks, webui_browser, webui, tui, docker, native]
|
||||
needs: [changes, test, windows_process, windows_installers, webui_checks, webui_build, webui_unit, webui_browser, webui, tui, docker, native]
|
||||
if: always()
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 2
|
||||
|
||||
+4
-2
@@ -16,8 +16,10 @@ def check_results(needs: dict, event: str) -> list[str]:
|
||||
return [f"Invalid or missing selection: {domain}"]
|
||||
selected[domain] = value == "true"
|
||||
jobs = {"test": selected["python"], "windows_process": selected["python"],
|
||||
"webui_checks": selected["webui"], "webui_browser": selected["webui"],
|
||||
"webui": selected["webui"], "tui": selected["tui"], "docker": selected["docker"],
|
||||
"webui_checks": selected["webui"], "webui_build": selected["webui"],
|
||||
"webui_unit": selected["webui"],
|
||||
"webui_browser": selected["webui"], "webui": selected["webui"],
|
||||
"tui": selected["tui"], "docker": selected["docker"],
|
||||
"native": selected["native"] and event != "push",
|
||||
"windows_installers": selected["python"] and selected["native"] and event != "push"}
|
||||
errors = []
|
||||
|
||||
@@ -10,7 +10,8 @@ def results(*domains):
|
||||
for domain in ("python", "webui", "tui", "docker", "native")
|
||||
}},
|
||||
**{job: {"result": "skipped"} for job in (
|
||||
"test", "windows_process", "windows_installers", "webui_checks", "webui_browser", "webui", "tui", "docker", "native",
|
||||
"test", "windows_process", "windows_installers", "webui_checks", "webui_build",
|
||||
"webui_unit", "webui_browser", "webui", "tui", "docker", "native",
|
||||
)},
|
||||
}
|
||||
|
||||
@@ -20,12 +21,14 @@ def test_documentation_needs_no_product_jobs():
|
||||
|
||||
|
||||
@pytest.mark.parametrize("result", ["failure", "cancelled", "skipped"])
|
||||
def test_selected_job_must_succeed(result):
|
||||
@pytest.mark.parametrize("job", ["webui_checks", "webui_build", "webui_unit", "webui_browser", "webui"])
|
||||
def test_selected_webui_job_must_succeed(job, result):
|
||||
needs = results("webui")
|
||||
for job in ("webui_checks", "webui_browser", "webui"):
|
||||
needs[job]["result"] = "success"
|
||||
needs["webui_browser"]["result"] = result
|
||||
assert check_results(needs, "pull_request")
|
||||
for name in ("webui_checks", "webui_build", "webui_unit", "webui_browser", "webui"):
|
||||
needs[name]["result"] = "success"
|
||||
assert check_results(needs, "pull_request") == []
|
||||
needs[job]["result"] = result
|
||||
assert check_results(needs, "pull_request") == [f"{job}: required, got {result}"]
|
||||
|
||||
|
||||
def test_native_runs_on_high_risk_pr_but_not_main_push():
|
||||
|
||||
@@ -84,3 +84,28 @@ def test_windows_gateway_stop_checks_run_serially_without_losing_coverage():
|
||||
assert len(steps) == 1
|
||||
assert steps[0]["if"] == "runner.os == 'Windows'"
|
||||
assert "-n" not in steps[0]["run"].split()
|
||||
|
||||
|
||||
def test_webui_full_suite_lanes_run_in_parallel_and_are_all_required():
|
||||
jobs = workflow("ci.yml")["jobs"]
|
||||
lanes = {"webui_checks", "webui_build", "webui_unit", "webui_browser"}
|
||||
assert set(jobs["webui"]["needs"]) == {"changes", *lanes}
|
||||
assert lanes <= set(jobs["required"]["needs"])
|
||||
for name in lanes:
|
||||
assert jobs[name]["needs"] == "changes"
|
||||
strategy = jobs["webui_browser"]["strategy"]
|
||||
assert strategy["fail-fast"] == "false"
|
||||
assert strategy["matrix"]["shard"] == ["1", "2", "3", "4"]
|
||||
|
||||
|
||||
def test_webui_coverage_runs_the_full_suite_and_retains_native_reports():
|
||||
steps = workflow("ci.yml")["jobs"]["webui_unit"]["steps"]
|
||||
run = next(step for step in steps if step.get("name") == "Run all unit tests with original coverage thresholds")
|
||||
assert run["run"] == (
|
||||
"bun run test:coverage --reporter=default --reporter=json "
|
||||
"--outputFile.json=test-results/unit/results.json"
|
||||
)
|
||||
upload = next(step for step in steps if step.get("uses") == "actions/upload-artifact@v4")
|
||||
assert upload["if"] == "always()"
|
||||
assert "webui/coverage/coverage-summary.json" in upload["with"]["path"].splitlines()
|
||||
assert upload["with"]["if-no-files-found"] == "error"
|
||||
@@ -140,6 +140,14 @@ bun run build
|
||||
|
||||
`lint` runs ESLint; `typecheck` checks application and unit-test TypeScript, including channel-owned frontend code and tests; `test` runs Vitest; `test:browser` typechecks and runs Chromium tests with the real components and stylesheet to check tall-dialog reachability and completed-history motion without a gateway; `build` checks production TypeScript and produces the production bundle. Keep tests near the changed behavior and exercise settings save/reload in the browser. Browser-only preferences stay in the frontend; persistent configuration and security policy belong to the Python gateway. When changing that boundary, also run the relevant Python tests from [CONTRIBUTING.md](../CONTRIBUTING.md).
|
||||
|
||||
### CI shards
|
||||
|
||||
CI runs the full selected suite. Static checks, production build, full unit coverage, and four browser shards run independently; every lane must pass. Unit coverage uses the original full-suite configuration and thresholds. Browser shards verify their executed test identities against full discovery. Test isolation, real browser motion, timeouts, and zero retries are unchanged.
|
||||
|
||||
To reproduce the coverage gate, run `bun run test:coverage` from `webui/`. For a browser shard, run `bun run typecheck:browser` and then `bun run test:browser:shard --shard=1/4` (repeat with indices 2–4 for the full suite). Use separate checkouts and `NANOBOT_BROWSER_TEST_PORT` values when running browser shards concurrently: each invocation owns its Vite server and clears the browser output directory. JSON results, coverage summaries, and browser failure details are uploaded as CI artifacts.
|
||||
|
||||
`test-timings.json` contains per-file browser millisecond weights and their source run. It affects balancing, not selection: every newly discovered test is included even before it has a timing. When refreshing the weights from CI's browser JSON artifacts, sum result durations per file and update the source run and commit together. The ordinary unsharded commands above remain available for local development.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
- [`agent-chat-ui`](https://github.com/langchain-ai/agent-chat-ui) for UI and interaction inspiration across the chat surface.
|
||||
@@ -144,6 +144,8 @@ test("the elapsed label keeps a compact gap before the collapsed activity", asyn
|
||||
test("the working label stays in place when activity is expanded and collapsed", async ({ page }) => {
|
||||
for (const width of [960, 360]) {
|
||||
await page.setViewportSize({ width, height: 740 });
|
||||
// The responsive action row changes height; measure after that resize commits.
|
||||
await expect(page.locator("[data-message-mobile-actions]")).toHaveCount(width < 768 ? 1 : 0);
|
||||
const toggle = page.getByRole("button", { name: /处理中/ });
|
||||
const labelPosition = () => toggle.evaluate((button) => {
|
||||
const label = button.querySelector("[data-sheen-text]")!;
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import { AppsCatalogSettings, DEFAULT_CUSTOM_MCP_FORM } from "@/components/settings/system/AppsSettings";
|
||||
import type { McpPresetInfo } from "@/lib/types";
|
||||
|
||||
const parameters = new URLSearchParams(location.search);
|
||||
const unbrandedPlugin: McpPresetInfo = {
|
||||
name: "plugin-nanobot-workflows", display_name: "Nanobot Workflows", category: "Workflow",
|
||||
description: "Engineering workflows", docs_url: "", requires: "Project files", note: "", connection_summary: "",
|
||||
transport: "stdio", install_supported: false, installed: true, configured: true,
|
||||
enabled: true, available: true, status: "enabled", required_fields: [], source: "agent-plugin",
|
||||
};
|
||||
|
||||
export function AppsFixture() {
|
||||
const noop = () => {};
|
||||
const managing = parameters.has("manage");
|
||||
const connectionLayout = parameters.has("connection-layout");
|
||||
const [connecting, setConnecting] = useState(false);
|
||||
const [actions, setActions] = useState<unknown[]>([]);
|
||||
const presets: McpPresetInfo[] = connectionLayout ? [
|
||||
{
|
||||
name: "linear", display_name: "Linear", category: "productivity", description: "Manage issues and projects",
|
||||
docs_url: "", transport: "streamableHttp", auth: "oauth", requires: "Linear account", note: "",
|
||||
install_supported: true, installed: parameters.has("runtime"), configured: parameters.has("runtime"),
|
||||
available: true, status: parameters.has("runtime") ? "configured" : "not_installed",
|
||||
required_fields: [], connection_summary: "", source: "preset",
|
||||
brand_color: "#5E6AD2", runtime_status: parameters.has("runtime") ? "connecting" : undefined,
|
||||
},
|
||||
...["Notion", "GitHub", "Xmind"].map((name): McpPresetInfo => ({
|
||||
name: name.toLowerCase(), display_name: name, category: "productivity", description: `Connect your ${name} workspace`,
|
||||
docs_url: "", transport: "streamableHttp", auth: "oauth", requires: "", note: "",
|
||||
install_supported: true, installed: false, configured: false, available: true,
|
||||
status: "not_installed", required_fields: [], connection_summary: "", source: "preset",
|
||||
})),
|
||||
] : managing ? [{
|
||||
name: "design", display_name: "Design MCP", category: "design", description: "Read design context",
|
||||
docs_url: "", transport: "streamableHttp", auth: "oauth", requires: "", note: "",
|
||||
install_supported: true, installed: false, configured: false, available: true,
|
||||
status: "not_installed", required_fields: [], connection_summary: "https://design.example/mcp", source: "preset",
|
||||
}] : [
|
||||
unbrandedPlugin,
|
||||
{ ...unbrandedPlugin, name: "test-mcp", display_name: "Test MCP", source: "builtin", logo_url: "/missing-app-icon.svg" },
|
||||
{ ...unbrandedPlugin, name: "brand-example", display_name: "Brand Example", source: "builtin", brand_color: "#5E6AD2" },
|
||||
];
|
||||
return <main className="mx-auto max-w-4xl p-6" style={connectionLayout ? { maxWidth: 800 } : undefined}><AppsCatalogSettings
|
||||
cliApps={{ apps: [], installed_count: 0 }}
|
||||
mcpPresets={{ presets, installed_count: connectionLayout ? Number(parameters.has("runtime")) : managing ? 0 : 3 }}
|
||||
cliAppsLoading={false} mcpPresetsLoading={false} query="" filter={managing || connectionLayout ? "mcp" : "ready"}
|
||||
cliActionKey={null} mcpActionKey={null}
|
||||
mcpOAuthFlow={connecting ? { flow_id: "fixture", name: "linear", status: "authorization_required", expires_in: 300 } : null}
|
||||
mcpOAuthPopupBlocked={false}
|
||||
mcpOAuthCallbackUrl="" mcpOAuthCompleting={false} mcpOAuthCallbackError={null}
|
||||
cliMessage={null} cliError={null} cliFocusName={null} mcpMessage={null} mcpError={null}
|
||||
mcpFieldValues={{}} customMcpForm={DEFAULT_CUSTOM_MCP_FORM} mcpConfigImport=""
|
||||
showBrandLogos={parameters.get("logos") !== "hidden"} requiresRestartPending={false}
|
||||
onQueryChange={noop} onFilterChange={noop} onCliAction={noop}
|
||||
onMcpAction={(action, name, values) => setActions((prev) => [...prev, { action, name, values }])}
|
||||
onMcpOAuthConnect={(name, reset, values) => {
|
||||
setActions((prev) => [...prev, { action: "oauth", name, reset, values }]);
|
||||
if (connectionLayout) setConnecting(true);
|
||||
}}
|
||||
onMcpOAuthCancel={() => setConnecting(false)} onMcpOAuthOpen={noop}
|
||||
onMcpOAuthCallbackUrlChange={noop} onMcpOAuthComplete={noop} onDismissStatus={noop}
|
||||
onBackToChat={noop} onMcpFieldChange={noop} onCustomMcpFormChange={noop}
|
||||
onMcpConfigImportChange={noop} onSaveCustomMcp={noop} onImportMcpConfig={noop}
|
||||
onMcpToolsChange={noop}
|
||||
/>{managing && <output data-testid="mcp-actions">{JSON.stringify(actions)}</output>}</main>;
|
||||
}
|
||||
+202
-319
@@ -1,332 +1,215 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import type { ReactElement } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { createPortal } from "react-dom";
|
||||
import { MessageBubble } from "@/components/MessageBubble";
|
||||
import { AppsCatalogSettings, DEFAULT_CUSTOM_MCP_FORM } from "@/components/settings/system/AppsSettings";
|
||||
import { ThreadMessages } from "@/components/thread/ThreadMessages";
|
||||
import { ThreadViewport } from "@/components/thread/ThreadViewport";
|
||||
import { PaneWorkbench } from "@/components/workbench/PaneWorkbench";
|
||||
import { usePromptHistory } from "@/hooks/usePromptHistory";
|
||||
import { ClientProvider } from "@/providers/ClientProvider";
|
||||
import { NanobotClient } from "@/lib/nanobot-client";
|
||||
import { fetchWebuiThread } from "@/lib/api";
|
||||
import { projectThreadEvents } from "@/lib/thread-event-projection";
|
||||
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
|
||||
|
||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { SettingsIcon } from "@/components/icons/product-icons";
|
||||
import { initializeI18n, setAppLanguage } from "@/i18n";
|
||||
import { normalizeLocale } from "@/i18n/config";
|
||||
import type { McpPresetInfo, UIMessage } from "@/lib/types";
|
||||
import { SkeletonFixture } from "./skeleton-fixture";
|
||||
import { installToolsCatalogPreviewApi, ToolsCatalogFixture } from "./tools-catalog-fixture";
|
||||
import { installSkeletonPreviewApi, SkeletonAdditionsFixture } from "./skeleton-additions-fixture";
|
||||
import { NewChatSkeletonFixture } from "./new-chat-skeleton-fixture";
|
||||
import "../src/globals.css";
|
||||
import { DiagramFixture } from "./diagram-fixture";
|
||||
import { TypographyFixture } from "./typography-fixture";
|
||||
import { CodeWrappingFixture } from "./code-wrapping-fixture";
|
||||
import { InlineReferencesFixture } from "./inline-references-fixture";
|
||||
import { InlineFileReferenceFixture } from "./inline-file-reference-fixture";
|
||||
import { HistoryBoundaryFixture } from "./history-boundary-fixture";
|
||||
import { installHistoryBoundaryPreviewApi } from "./history-boundary-preview";
|
||||
import { ChatFailureFixture } from "./chat-failure-fixture";
|
||||
import { ThreadLoadingFixture } from "./thread-loading-fixture";
|
||||
import { AnswerOrderFixture } from "./answer-order-fixture";
|
||||
import { SidebarActivityFixture } from "./sidebar-activity-fixture";
|
||||
import { ActivityLogosFixture } from "./activity-logos-fixture";
|
||||
import { ActivityWheelFixture } from "./activity-wheel-fixture";
|
||||
import { ExecSessionFixture } from "./exec-session-fixture";
|
||||
import { HistoryHydrationFixture } from "./history-hydration-fixture";
|
||||
import { IdleCompactionFixture, installIdleCompactionApi } from "./idle-compaction-fixture";
|
||||
import { FileEditPathFixture } from "./file-edit-path-fixture";
|
||||
import { FileDiffFixture } from "./file-diff-fixture";
|
||||
import { CodeHighlightingFixture } from "./code-highlighting-fixture";
|
||||
import { QueuedGuidanceFixture } from "./queued-guidance-fixture";
|
||||
import { WorkspaceAlignmentFixture } from "./workspace-alignment-fixture";
|
||||
import { ComposerActionFixture } from "./composer-action-fixture";
|
||||
import { MobileChatLayoutFixture } from "./mobile-chat-layout-fixture";
|
||||
import { ThemeToggleFixture } from "./theme-toggle-fixture";
|
||||
import { DisplayMathFixture } from "./display-math-fixture";
|
||||
import { MarkdownDollarRefsFixture } from "./markdown-dollar-refs-fixture";
|
||||
import { AttachmentLayoutFixture } from "./attachment-layout-fixture";
|
||||
import { LoadedSessionSearchFixture } from "./loaded-session-search-fixture";
|
||||
import { AppearanceFixture } from "./appearance-fixture";
|
||||
import { ContinuityFixture } from "./continuity-fixture";
|
||||
import { installSessionTransitionPreviewApi, SessionTransitionFixture } from "./session-transition-fixture";
|
||||
import { installSubagentDockApi, SubagentDockFixture } from "./subagent-dock-fixture";
|
||||
|
||||
const history: UIMessage[] = [
|
||||
{ id: "question", role: "user", content: "Earlier question", createdAt: 1_700_000_000_000 },
|
||||
{ id: "answer", role: "assistant", content: "Earlier answer", createdAt: 1_700_000_001_000 },
|
||||
];
|
||||
const trace: UIMessage = {
|
||||
id: "trace", role: "tool", kind: "trace", content: "Earlier tool call", createdAt: 1_700_000_002_000,
|
||||
};
|
||||
|
||||
function HistoryFixture() {
|
||||
const [open, setOpen] = useState(false);
|
||||
return <main>
|
||||
<button onClick={() => setOpen(!open)}>{open ? "Close history" : "Reopen history"}</button>
|
||||
<section aria-label="Persisted history">
|
||||
{open && <>
|
||||
<ThreadMessages messages={history} isStreaming={false} />
|
||||
<MessageBubble message={trace} />
|
||||
</>}
|
||||
</section>
|
||||
</main>;
|
||||
}
|
||||
|
||||
function TallDialogFixture({ placement }: { placement: "center" | "bottom" }) {
|
||||
return <main aria-label="Background content" style={{ height: 240, overflowY: "auto" }}>
|
||||
<div style={{ minHeight: 1800 }}><Dialog>
|
||||
<DialogTrigger asChild><button>Open tall dialog</button></DialogTrigger>
|
||||
<DialogContent placement={placement}>
|
||||
<DialogTitle>Tall dialog</DialogTitle>
|
||||
<DialogDescription>All controls must remain reachable in a short viewport.</DialogDescription>
|
||||
{Array.from({ length: 30 }, (_, index) => <label key={index}>
|
||||
Field {index + 1}<input aria-label={`Field ${index + 1}`} style={{ display: "block", height: 40 }} />
|
||||
</label>)}
|
||||
<DialogClose asChild><button>Save tall dialog</button></DialogClose>
|
||||
</DialogContent>
|
||||
</Dialog></div>
|
||||
</main>;
|
||||
}
|
||||
|
||||
function SessionMessagesFixture() {
|
||||
const messages: UIMessage[] = [
|
||||
{ id: "own-input", role: "user", content: "Please review the update.", createdAt: 1 },
|
||||
{
|
||||
id: "session-message:short", role: "user", content: "Looks good.", createdAt: 2,
|
||||
sessionMessage: { message_id: "short", session: { id: "handle_0123456789abcdef0123456789abcdef", name: "mira" } },
|
||||
},
|
||||
{
|
||||
id: "session-message:long", role: "user", createdAt: 3,
|
||||
content: "**Review notes**\n\n- Keep the layout left-aligned.\n- Preserve Markdown and links.\n\n```ts\nconst message = \"" + "long-path/".repeat(30) + "\";\n```\n\n[Release notes](https://example.com/release-notes)",
|
||||
sessionMessage: { message_id: "long", session: { id: "handle_fedcba9876543210fedcba9876543210", name: "nori" } },
|
||||
},
|
||||
{ id: "reply", role: "assistant", content: "Thanks, I will keep those details.", createdAt: 4 },
|
||||
];
|
||||
return <main className="mx-auto max-w-3xl px-6 py-8" aria-label="Session messages">
|
||||
<ThreadMessages messages={messages} isStreaming={false} />
|
||||
</main>;
|
||||
}
|
||||
|
||||
const parameters = new URLSearchParams(location.search);
|
||||
const fixtureCase = parameters.get("case");
|
||||
const historyPreview = parameters.get("preview");
|
||||
if (parameters.get("case") === "history-boundary"
|
||||
&& (historyPreview === "slow" || historyPreview === "fast" || historyPreview === "pages" || historyPreview === "error")) {
|
||||
installHistoryBoundaryPreviewApi(historyPreview);
|
||||
|
||||
async function withClient(fixture: ReactElement, webuiCapabilities?: string[]) {
|
||||
const [{ ClientProvider }, { NanobotClient }] = await Promise.all([
|
||||
import("@/providers/ClientProvider"),
|
||||
import("@/lib/nanobot-client"),
|
||||
]);
|
||||
const client = new NanobotClient({ url: "ws://127.0.0.1:8765", reconnect: false });
|
||||
return <ClientProvider client={client} token="fixture" webuiCapabilities={webuiCapabilities}>{fixture}</ClientProvider>;
|
||||
}
|
||||
const railClient = new NanobotClient({ url: "ws://127.0.0.1:8765", reconnect: false });
|
||||
const railHistory: UIMessage[] = Array.from({ length: 5 }, (_, index) => [
|
||||
{ id: `u${1995 + index}`, role: "user" as const, content: `Question ${1995 + index}`, createdAt: index + 1 },
|
||||
{ id: `a${1995 + index}`, role: "assistant" as const, content: parameters.has("focus-links") && index === 4
|
||||
? Array.from({ length: 45 }, (_, i) => `[Reference ${i}](https://example.test/ref${i})`).join("\n")
|
||||
: "A synthetic answer.\n\n".repeat(8), createdAt: index + 1 },
|
||||
]).flat();
|
||||
function RailFixture() {
|
||||
const [messages, setMessages] = useState(parameters.has("real") ? [] : railHistory);
|
||||
const [version, setVersion] = useState(1);
|
||||
const [streaming, setStreaming] = useState(false);
|
||||
useEffect(() => {
|
||||
if (!parameters.has("real")) return;
|
||||
const controller = new AbortController();
|
||||
void fetchWebuiThread("fixture", "websocket:rail", { limit: 40, signal: controller.signal }).then((page) => {
|
||||
if (page && !controller.signal.aborted) setMessages(projectThreadEvents(page.events));
|
||||
});
|
||||
return () => controller.abort();
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
if (!streaming) return;
|
||||
let count = 0;
|
||||
const user: UIMessage = { id: "stream-user", role: "user", content: "Streaming question", createdAt: Date.now() };
|
||||
const timer = window.setInterval(() => {
|
||||
count++;
|
||||
setMessages((current) => [...current.filter((message) => message.id !== "stream-user" && message.id !== "stream-answer"), user,
|
||||
{ id: "stream-answer", role: "assistant", content: "Streaming text. ".repeat(count), createdAt: user.createdAt + 1, isStreaming: count < 120 }]);
|
||||
if (count === 120) setStreaming(false);
|
||||
}, 16);
|
||||
return () => window.clearInterval(timer);
|
||||
}, [streaming]);
|
||||
const navigation = usePromptHistory(messages.length ? "websocket:rail" : null, version, messages);
|
||||
const composer = <div style={{ height: parameters.has("tall-composer") ? 240 : 100, border: "1px solid #ddd", borderRadius: 20, padding: 20 }}>Message nanobot</div>;
|
||||
const viewport = (external: boolean, navigationFrame?: HTMLElement | null) => <ThreadViewport
|
||||
messages={messages} isStreaming={streaming} conversationKey="websocket:rail"
|
||||
navigation={parameters.has("short") ? undefined : navigation}
|
||||
navigationFrame={navigationFrame} composer={external ? null : composer} />;
|
||||
return <main style={{ height: "100vh", display: "flex", flexDirection: "column" }}>
|
||||
{parameters.has("real") && <div>
|
||||
<button onClick={() => setVersion((value) => value + 1)}>Refresh index</button>
|
||||
<button onClick={() => setStreaming(true)} disabled={streaming}>{streaming ? "Streaming" : "Simulate stream"}</button>
|
||||
</div>}
|
||||
{parameters.has("workbench") ? <PaneWorkbench
|
||||
panes={parameters.has("focus-links")
|
||||
? [{ key: "rail", title: "Rail conversation" }, { key: "other", title: "Other conversation" }]
|
||||
: [{ key: "rail", title: "Rail conversation" }]} activePaneKey="rail" layout="columns" showLayoutControl={false}
|
||||
onActivatePane={() => {}} onAddPane={() => {}} onLayoutChange={() => {}} onPaneOrderChange={() => {}}
|
||||
renderPane={(_pane, context) => <>
|
||||
{viewport(context.composerPortalTarget !== undefined, context.navigationFrame)}
|
||||
{context.composerPortalTarget && createPortal(composer, context.composerPortalTarget)}
|
||||
</>}
|
||||
/> : viewport(false)}
|
||||
</main>;
|
||||
|
||||
// Load and install only the selected scene's mocks before i18n and React mount.
|
||||
async function loadFixture() {
|
||||
switch (fixtureCase) {
|
||||
case "session-transition": {
|
||||
const { installSessionTransitionPreviewApi, SessionTransitionFixture } = await import("./session-transition-fixture");
|
||||
if (parameters.has("preview")) installSessionTransitionPreviewApi();
|
||||
if (parameters.has("narrow")) {
|
||||
const widePreview = new URL(location.href);
|
||||
widePreview.searchParams.delete("narrow");
|
||||
return <iframe title="Narrow goal preview" src={widePreview.href} style={{ display: "block", margin: "0 auto", height: "100dvh", width: "100%", maxWidth: 390, border: 0 }} />;
|
||||
}
|
||||
return <SessionTransitionFixture />;
|
||||
}
|
||||
case "continuity": {
|
||||
const { ContinuityFixture } = await import("./continuity-fixture");
|
||||
return <ContinuityFixture />;
|
||||
}
|
||||
case "appearance": {
|
||||
const { AppearanceFixture } = await import("./appearance-fixture");
|
||||
return <AppearanceFixture />;
|
||||
}
|
||||
case "loaded-session-search": {
|
||||
const { LoadedSessionSearchFixture } = await import("./loaded-session-search-fixture");
|
||||
return <LoadedSessionSearchFixture />;
|
||||
}
|
||||
case "subagent-dock": {
|
||||
const { installSubagentDockApi, SubagentDockFixture } = await import("./subagent-dock-fixture");
|
||||
installSubagentDockApi();
|
||||
return <SubagentDockFixture parameters={parameters} />;
|
||||
}
|
||||
case "attachments": {
|
||||
const { AttachmentLayoutFixture } = await import("./attachment-layout-fixture");
|
||||
return <AttachmentLayoutFixture />;
|
||||
}
|
||||
case "theme-toggle": {
|
||||
const { ThemeToggleFixture } = await import("./theme-toggle-fixture");
|
||||
return withClient(<ThemeToggleFixture />);
|
||||
}
|
||||
case "mobile-chat-layout": {
|
||||
const { MobileChatLayoutFixture } = await import("./mobile-chat-layout-fixture");
|
||||
return withClient(<MobileChatLayoutFixture parameters={parameters} />);
|
||||
}
|
||||
case "composer-action": {
|
||||
const { ComposerActionFixture } = await import("./composer-action-fixture");
|
||||
return <ComposerActionFixture parameters={parameters} />;
|
||||
}
|
||||
case "workspace-alignment": {
|
||||
const { WorkspaceAlignmentFixture } = await import("./workspace-alignment-fixture");
|
||||
return <WorkspaceAlignmentFixture parameters={parameters} />;
|
||||
}
|
||||
case "queued-guidance": {
|
||||
const { QueuedGuidanceFixture } = await import("./queued-guidance-fixture");
|
||||
return <QueuedGuidanceFixture />;
|
||||
}
|
||||
case "code-highlighting": {
|
||||
const { CodeHighlightingFixture } = await import("./code-highlighting-fixture");
|
||||
return <CodeHighlightingFixture />;
|
||||
}
|
||||
case "file-diff": {
|
||||
const { FileDiffFixture } = await import("./file-diff-fixture");
|
||||
return <FileDiffFixture />;
|
||||
}
|
||||
case "file-edit-path": {
|
||||
const { FileEditPathFixture } = await import("./file-edit-path-fixture");
|
||||
return <FileEditPathFixture />;
|
||||
}
|
||||
case "answer-order": {
|
||||
const { AnswerOrderFixture } = await import("./answer-order-fixture");
|
||||
return <AnswerOrderFixture />;
|
||||
}
|
||||
case "activity-logos": {
|
||||
const { ActivityLogosFixture } = await import("./activity-logos-fixture");
|
||||
return <ActivityLogosFixture parameters={parameters} />;
|
||||
}
|
||||
case "activity-wheel": {
|
||||
const { ActivityWheelFixture } = await import("./activity-wheel-fixture");
|
||||
return <ActivityWheelFixture />;
|
||||
}
|
||||
case "exec-session": {
|
||||
const { ExecSessionFixture } = await import("./exec-session-fixture");
|
||||
return <ExecSessionFixture />;
|
||||
}
|
||||
case "sidebar-activity": {
|
||||
const { SidebarActivityFixture } = await import("./sidebar-activity-fixture");
|
||||
return <SidebarActivityFixture />;
|
||||
}
|
||||
case "chat-failure": {
|
||||
const { ChatFailureFixture } = await import("./chat-failure-fixture");
|
||||
return <ChatFailureFixture parameters={parameters} />;
|
||||
}
|
||||
case "display-math": {
|
||||
const { DisplayMathFixture } = await import("./display-math-fixture");
|
||||
return <DisplayMathFixture />;
|
||||
}
|
||||
case "markdown-dollar-refs": {
|
||||
const { MarkdownDollarRefsFixture } = await import("./markdown-dollar-refs-fixture");
|
||||
return <MarkdownDollarRefsFixture />;
|
||||
}
|
||||
case "code-wrapping": {
|
||||
const { CodeWrappingFixture } = await import("./code-wrapping-fixture");
|
||||
return <CodeWrappingFixture />;
|
||||
}
|
||||
case "typography": {
|
||||
const { TypographyFixture } = await import("./typography-fixture");
|
||||
return withClient(<TypographyFixture />);
|
||||
}
|
||||
case "inline-references": {
|
||||
const { InlineReferencesFixture } = await import("./inline-references-fixture");
|
||||
return withClient(<InlineReferencesFixture />);
|
||||
}
|
||||
case "inline-file-reference": {
|
||||
const { InlineFileReferenceFixture } = await import("./inline-file-reference-fixture");
|
||||
return <InlineFileReferenceFixture />;
|
||||
}
|
||||
case "idle-compaction": {
|
||||
const { IdleCompactionFixture, installIdleCompactionApi } = await import("./idle-compaction-fixture");
|
||||
installIdleCompactionApi();
|
||||
return <IdleCompactionFixture />;
|
||||
}
|
||||
case "history-hydration": {
|
||||
const { HistoryHydrationFixture } = await import("./history-hydration-fixture");
|
||||
return <HistoryHydrationFixture />;
|
||||
}
|
||||
case "history-boundary": {
|
||||
const { HistoryBoundaryFixture } = await import("./history-boundary-fixture");
|
||||
if (historyPreview === "slow" || historyPreview === "fast" || historyPreview === "pages" || historyPreview === "error") {
|
||||
const { installHistoryBoundaryPreviewApi } = await import("./history-boundary-preview");
|
||||
installHistoryBoundaryPreviewApi(historyPreview);
|
||||
}
|
||||
return withClient(<HistoryBoundaryFixture local={parameters.has("local")} navigate={parameters.has("navigate")} tasks={parameters.has("tasks")} />, ["webui.prompt-navigation.v1"]);
|
||||
}
|
||||
case "diagrams": {
|
||||
const { DiagramFixture } = await import("./diagram-fixture");
|
||||
return <DiagramFixture parameters={parameters} />;
|
||||
}
|
||||
case "thread-loading": {
|
||||
const { ThreadLoadingFixture } = await import("./thread-loading-fixture");
|
||||
return withClient(<ThreadLoadingFixture />);
|
||||
}
|
||||
case "new-chat-skeleton": {
|
||||
const { NewChatSkeletonFixture } = await import("./new-chat-skeleton-fixture");
|
||||
return withClient(<NewChatSkeletonFixture />);
|
||||
}
|
||||
case "skeleton-additions": {
|
||||
const { installSkeletonPreviewApi, SkeletonAdditionsFixture } = await import("./skeleton-additions-fixture");
|
||||
installSkeletonPreviewApi();
|
||||
return withClient(<SkeletonAdditionsFixture />, parameters.has("sandboxSettings") ? ["webui.sandbox-settings.v1"] : []);
|
||||
}
|
||||
case "skeleton": {
|
||||
const { SkeletonFixture } = await import("./skeleton-fixture");
|
||||
return withClient(<SkeletonFixture surface={parameters.get("surface") ?? "skills"} loading={parameters.has("loading")} />);
|
||||
}
|
||||
case "tools-catalog": {
|
||||
const { installToolsCatalogPreviewApi, ToolsCatalogFixture } = await import("./tools-catalog-fixture");
|
||||
installToolsCatalogPreviewApi();
|
||||
return withClient(<ToolsCatalogFixture />);
|
||||
}
|
||||
case "apps": {
|
||||
const { AppsFixture } = await import("./apps-fixture");
|
||||
return withClient(<AppsFixture />);
|
||||
}
|
||||
case "rail": {
|
||||
const { RailFixture } = await import("./rail-fixture");
|
||||
return withClient(<RailFixture />, ["webui.prompt-navigation.v1"]);
|
||||
}
|
||||
case "settings-icon": {
|
||||
const [{ Button }, { SettingsIcon }] = await Promise.all([
|
||||
import("@/components/ui/button"),
|
||||
import("@/components/icons/product-icons"),
|
||||
]);
|
||||
return <Button variant="icon" size="icon" aria-label="Settings"><SettingsIcon className="h-4 w-4" /></Button>;
|
||||
}
|
||||
case "session-messages": {
|
||||
const { SessionMessagesFixture } = await import("./history-fixture");
|
||||
return <SessionMessagesFixture />;
|
||||
}
|
||||
case "history": {
|
||||
const { HistoryFixture } = await import("./history-fixture");
|
||||
return <HistoryFixture />;
|
||||
}
|
||||
default: {
|
||||
const { TallDialogFixture } = await import("./tall-dialog-fixture");
|
||||
return <TallDialogFixture placement={parameters.get("placement") === "bottom" ? "bottom" : "center"} />;
|
||||
}
|
||||
}
|
||||
}
|
||||
const unbrandedPlugin: McpPresetInfo = {
|
||||
name: "plugin-nanobot-workflows", display_name: "Nanobot Workflows", category: "Workflow",
|
||||
description: "Engineering workflows", docs_url: "", requires: "Project files", note: "", connection_summary: "",
|
||||
transport: "stdio", install_supported: false, installed: true, configured: true,
|
||||
enabled: true, available: true, status: "enabled", required_fields: [], source: "agent-plugin",
|
||||
};
|
||||
function AppsFixture() {
|
||||
const noop = () => {};
|
||||
const managing = parameters.has("manage");
|
||||
const connectionLayout = parameters.has("connection-layout");
|
||||
const [connecting, setConnecting] = useState(false);
|
||||
const [actions, setActions] = useState<unknown[]>([]);
|
||||
const presets: McpPresetInfo[] = connectionLayout ? [
|
||||
{
|
||||
name: "linear", display_name: "Linear", category: "productivity", description: "Manage issues and projects",
|
||||
docs_url: "", transport: "streamableHttp", auth: "oauth", requires: "Linear account", note: "",
|
||||
install_supported: true, installed: parameters.has("runtime"), configured: parameters.has("runtime"),
|
||||
available: true, status: parameters.has("runtime") ? "configured" : "not_installed",
|
||||
required_fields: [], connection_summary: "", source: "preset",
|
||||
brand_color: "#5E6AD2", runtime_status: parameters.has("runtime") ? "connecting" : undefined,
|
||||
},
|
||||
...["Notion", "GitHub", "Xmind"].map((name): McpPresetInfo => ({
|
||||
name: name.toLowerCase(), display_name: name, category: "productivity", description: `Connect your ${name} workspace`,
|
||||
docs_url: "", transport: "streamableHttp", auth: "oauth", requires: "", note: "",
|
||||
install_supported: true, installed: false, configured: false, available: true,
|
||||
status: "not_installed", required_fields: [], connection_summary: "", source: "preset",
|
||||
})),
|
||||
] : managing ? [{
|
||||
name: "design", display_name: "Design MCP", category: "design", description: "Read design context",
|
||||
docs_url: "", transport: "streamableHttp", auth: "oauth", requires: "", note: "",
|
||||
install_supported: true, installed: false, configured: false, available: true,
|
||||
status: "not_installed", required_fields: [], connection_summary: "https://design.example/mcp", source: "preset",
|
||||
}] : [
|
||||
unbrandedPlugin,
|
||||
{ ...unbrandedPlugin, name: "test-mcp", display_name: "Test MCP", source: "builtin", logo_url: "/missing-app-icon.svg" },
|
||||
{ ...unbrandedPlugin, name: "brand-example", display_name: "Brand Example", source: "builtin", brand_color: "#5E6AD2" },
|
||||
];
|
||||
return <main className="mx-auto max-w-4xl p-6" style={connectionLayout ? { maxWidth: 800 } : undefined}><AppsCatalogSettings
|
||||
cliApps={{ apps: [], installed_count: 0 }}
|
||||
mcpPresets={{ presets, installed_count: connectionLayout ? Number(parameters.has("runtime")) : managing ? 0 : 3 }}
|
||||
cliAppsLoading={false} mcpPresetsLoading={false} query="" filter={managing || connectionLayout ? "mcp" : "ready"}
|
||||
cliActionKey={null} mcpActionKey={null}
|
||||
mcpOAuthFlow={connecting ? { flow_id: "fixture", name: "linear", status: "authorization_required", expires_in: 300 } : null}
|
||||
mcpOAuthPopupBlocked={false}
|
||||
mcpOAuthCallbackUrl="" mcpOAuthCompleting={false} mcpOAuthCallbackError={null}
|
||||
cliMessage={null} cliError={null} cliFocusName={null} mcpMessage={null} mcpError={null}
|
||||
mcpFieldValues={{}} customMcpForm={DEFAULT_CUSTOM_MCP_FORM} mcpConfigImport=""
|
||||
showBrandLogos={parameters.get("logos") !== "hidden"} requiresRestartPending={false}
|
||||
onQueryChange={noop} onFilterChange={noop} onCliAction={noop}
|
||||
onMcpAction={(action, name, values) => setActions((prev) => [...prev, { action, name, values }])}
|
||||
onMcpOAuthConnect={(name, reset, values) => {
|
||||
setActions((prev) => [...prev, { action: "oauth", name, reset, values }]);
|
||||
if (connectionLayout) setConnecting(true);
|
||||
}}
|
||||
onMcpOAuthCancel={() => setConnecting(false)} onMcpOAuthOpen={noop}
|
||||
onMcpOAuthCallbackUrlChange={noop} onMcpOAuthComplete={noop} onDismissStatus={noop}
|
||||
onBackToChat={noop} onMcpFieldChange={noop} onCustomMcpFormChange={noop}
|
||||
onMcpConfigImportChange={noop} onSaveCustomMcp={noop} onImportMcpConfig={noop}
|
||||
onMcpToolsChange={noop}
|
||||
/>{managing && <output data-testid="mcp-actions">{JSON.stringify(actions)}</output>}</main>;
|
||||
}
|
||||
if (parameters.get("case") === "skeleton-additions") installSkeletonPreviewApi();
|
||||
if (parameters.get("case") === "tools-catalog") installToolsCatalogPreviewApi();
|
||||
if (parameters.get("case") === "idle-compaction") installIdleCompactionApi();
|
||||
if (parameters.get("case") === "subagent-dock") installSubagentDockApi();
|
||||
if (parameters.get("case") === "session-transition" && parameters.has("preview")) installSessionTransitionPreviewApi();
|
||||
|
||||
const fixture = await loadFixture();
|
||||
await initializeI18n();
|
||||
if (parameters.get("case") === "activity-wheel") await setAppLanguage("zh-CN");
|
||||
if ((["appearance", "session-transition"].includes(parameters.get("case") ?? "") || historyPreview) && parameters.has("lang")) {
|
||||
if (fixtureCase === "activity-wheel") await setAppLanguage("zh-CN");
|
||||
if ((["appearance", "session-transition"].includes(fixtureCase ?? "") || historyPreview) && parameters.has("lang")) {
|
||||
await setAppLanguage(normalizeLocale(parameters.get("lang")));
|
||||
}
|
||||
const widePreview = new URL(location.href);
|
||||
widePreview.searchParams.delete("narrow");
|
||||
createRoot(document.getElementById("root")!).render(<TooltipProvider>
|
||||
{parameters.get("case") === "session-transition" && parameters.has("narrow")
|
||||
? <iframe title="Narrow goal preview" src={widePreview.href} style={{ display: "block", margin: "0 auto", height: "100dvh", width: "100%", maxWidth: 390, border: 0 }} />
|
||||
: parameters.get("case") === "session-transition"
|
||||
? <SessionTransitionFixture />
|
||||
: parameters.get("case") === "continuity"
|
||||
? <ContinuityFixture />
|
||||
: parameters.get("case") === "appearance"
|
||||
? <AppearanceFixture />
|
||||
: parameters.get("case") === "loaded-session-search"
|
||||
? <LoadedSessionSearchFixture />
|
||||
: parameters.get("case") === "subagent-dock"
|
||||
? <SubagentDockFixture parameters={parameters} />
|
||||
: parameters.get("case") === "attachments"
|
||||
? <AttachmentLayoutFixture />
|
||||
: parameters.get("case") === "theme-toggle"
|
||||
? <ClientProvider client={railClient} token="fixture"><ThemeToggleFixture /></ClientProvider>
|
||||
: parameters.get("case") === "mobile-chat-layout"
|
||||
? <ClientProvider client={railClient} token="fixture"><MobileChatLayoutFixture parameters={parameters} /></ClientProvider>
|
||||
: parameters.get("case") === "composer-action"
|
||||
? <ComposerActionFixture parameters={parameters} />
|
||||
: parameters.get("case") === "workspace-alignment"
|
||||
? <WorkspaceAlignmentFixture parameters={parameters} />
|
||||
: parameters.get("case") === "queued-guidance"
|
||||
? <QueuedGuidanceFixture />
|
||||
: parameters.get("case") === "code-highlighting"
|
||||
? <CodeHighlightingFixture />
|
||||
: parameters.get("case") === "file-diff"
|
||||
? <FileDiffFixture />
|
||||
: parameters.get("case") === "file-edit-path"
|
||||
? <FileEditPathFixture />
|
||||
: parameters.get("case") === "answer-order"
|
||||
? <AnswerOrderFixture />
|
||||
: parameters.get("case") === "activity-logos"
|
||||
? <ActivityLogosFixture parameters={parameters} />
|
||||
: parameters.get("case") === "activity-wheel"
|
||||
? <ActivityWheelFixture />
|
||||
: parameters.get("case") === "exec-session"
|
||||
? <ExecSessionFixture />
|
||||
: parameters.get("case") === "sidebar-activity"
|
||||
? <SidebarActivityFixture />
|
||||
: parameters.get("case") === "chat-failure"
|
||||
? <ChatFailureFixture parameters={parameters} />
|
||||
: parameters.get("case") === "display-math"
|
||||
? <DisplayMathFixture />
|
||||
: parameters.get("case") === "markdown-dollar-refs"
|
||||
? <MarkdownDollarRefsFixture />
|
||||
: parameters.get("case") === "code-wrapping"
|
||||
? <CodeWrappingFixture />
|
||||
: parameters.get("case") === "typography"
|
||||
? <ClientProvider client={railClient} token="fixture"><TypographyFixture /></ClientProvider>
|
||||
: parameters.get("case") === "inline-references"
|
||||
? <ClientProvider client={railClient} token="fixture"><InlineReferencesFixture /></ClientProvider>
|
||||
: parameters.get("case") === "inline-file-reference"
|
||||
? <InlineFileReferenceFixture />
|
||||
: parameters.get("case") === "idle-compaction"
|
||||
? <IdleCompactionFixture />
|
||||
: parameters.get("case") === "history-hydration"
|
||||
? <HistoryHydrationFixture />
|
||||
: parameters.get("case") === "history-boundary"
|
||||
? <ClientProvider client={railClient} token="fixture" webuiCapabilities={["webui.prompt-navigation.v1"]}><HistoryBoundaryFixture local={parameters.has("local")} navigate={parameters.has("navigate")} tasks={parameters.has("tasks")} /></ClientProvider>
|
||||
: parameters.get("case") === "diagrams"
|
||||
? <DiagramFixture parameters={parameters} />
|
||||
: parameters.get("case") === "thread-loading"
|
||||
? <ClientProvider client={railClient} token="fixture"><ThreadLoadingFixture /></ClientProvider>
|
||||
: parameters.get("case") === "new-chat-skeleton"
|
||||
? <ClientProvider client={railClient} token="fixture"><NewChatSkeletonFixture /></ClientProvider>
|
||||
: parameters.get("case") === "skeleton-additions"
|
||||
? <ClientProvider client={railClient} token="fixture" webuiCapabilities={parameters.has("sandboxSettings") ? ["webui.sandbox-settings.v1"] : []}><SkeletonAdditionsFixture /></ClientProvider>
|
||||
: parameters.get("case") === "skeleton"
|
||||
? <ClientProvider client={railClient} token="fixture"><SkeletonFixture surface={parameters.get("surface") ?? "skills"} loading={parameters.has("loading")} /></ClientProvider>
|
||||
: parameters.get("case") === "tools-catalog"
|
||||
? <ClientProvider client={railClient} token="fixture"><ToolsCatalogFixture /></ClientProvider>
|
||||
: parameters.get("case") === "apps"
|
||||
? <ClientProvider client={railClient} token="fixture"><AppsFixture /></ClientProvider>
|
||||
: parameters.get("case") === "rail"
|
||||
? <ClientProvider client={railClient} token="fixture" webuiCapabilities={["webui.prompt-navigation.v1"]}><RailFixture /></ClientProvider>
|
||||
: parameters.get("case") === "settings-icon"
|
||||
? <Button variant="icon" size="icon" aria-label="Settings"><SettingsIcon className="h-4 w-4" /></Button>
|
||||
: parameters.get("case") === "session-messages"
|
||||
? <SessionMessagesFixture />
|
||||
: parameters.get("case") === "history"
|
||||
? <HistoryFixture />
|
||||
: <TallDialogFixture placement={parameters.get("placement") === "bottom" ? "bottom" : "center"} />}
|
||||
</TooltipProvider>);
|
||||
createRoot(document.getElementById("root")!).render(<TooltipProvider>{fixture}</TooltipProvider>);
|
||||
@@ -0,0 +1,45 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import { MessageBubble } from "@/components/MessageBubble";
|
||||
import { ThreadMessages } from "@/components/thread/ThreadMessages";
|
||||
import type { UIMessage } from "@/lib/types";
|
||||
|
||||
const history: UIMessage[] = [
|
||||
{ id: "question", role: "user", content: "Earlier question", createdAt: 1_700_000_000_000 },
|
||||
{ id: "answer", role: "assistant", content: "Earlier answer", createdAt: 1_700_000_001_000 },
|
||||
];
|
||||
const trace: UIMessage = {
|
||||
id: "trace", role: "tool", kind: "trace", content: "Earlier tool call", createdAt: 1_700_000_002_000,
|
||||
};
|
||||
|
||||
export function HistoryFixture() {
|
||||
const [open, setOpen] = useState(false);
|
||||
return <main>
|
||||
<button onClick={() => setOpen(!open)}>{open ? "Close history" : "Reopen history"}</button>
|
||||
<section aria-label="Persisted history">
|
||||
{open && <>
|
||||
<ThreadMessages messages={history} isStreaming={false} />
|
||||
<MessageBubble message={trace} />
|
||||
</>}
|
||||
</section>
|
||||
</main>;
|
||||
}
|
||||
|
||||
export function SessionMessagesFixture() {
|
||||
const messages: UIMessage[] = [
|
||||
{ id: "own-input", role: "user", content: "Please review the update.", createdAt: 1 },
|
||||
{
|
||||
id: "session-message:short", role: "user", content: "Looks good.", createdAt: 2,
|
||||
sessionMessage: { message_id: "short", session: { id: "handle_0123456789abcdef0123456789abcdef", name: "mira" } },
|
||||
},
|
||||
{
|
||||
id: "session-message:long", role: "user", createdAt: 3,
|
||||
content: "**Review notes**\n\n- Keep the layout left-aligned.\n- Preserve Markdown and links.\n\n```ts\nconst message = \"" + "long-path/".repeat(30) + "\";\n```\n\n[Release notes](https://example.com/release-notes)",
|
||||
sessionMessage: { message_id: "long", session: { id: "handle_fedcba9876543210fedcba9876543210", name: "nori" } },
|
||||
},
|
||||
{ id: "reply", role: "assistant", content: "Thanks, I will keep those details.", createdAt: 4 },
|
||||
];
|
||||
return <main className="mx-auto max-w-3xl px-6 py-8" aria-label="Session messages">
|
||||
<ThreadMessages messages={messages} isStreaming={false} />
|
||||
</main>;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
|
||||
import { ThreadViewport } from "@/components/thread/ThreadViewport";
|
||||
import { PaneWorkbench } from "@/components/workbench/PaneWorkbench";
|
||||
import { usePromptHistory } from "@/hooks/usePromptHistory";
|
||||
import { fetchWebuiThread } from "@/lib/api";
|
||||
import { projectThreadEvents } from "@/lib/thread-event-projection";
|
||||
import type { UIMessage } from "@/lib/types";
|
||||
|
||||
const parameters = new URLSearchParams(location.search);
|
||||
const railHistory: UIMessage[] = Array.from({ length: 5 }, (_, index) => [
|
||||
{ id: `u${1995 + index}`, role: "user" as const, content: `Question ${1995 + index}`, createdAt: index + 1 },
|
||||
{ id: `a${1995 + index}`, role: "assistant" as const, content: parameters.has("focus-links") && index === 4
|
||||
? Array.from({ length: 45 }, (_, i) => `[Reference ${i}](https://example.test/ref${i})`).join("\n")
|
||||
: "A synthetic answer.\n\n".repeat(8), createdAt: index + 1 },
|
||||
]).flat();
|
||||
|
||||
export function RailFixture() {
|
||||
const [messages, setMessages] = useState(parameters.has("real") ? [] : railHistory);
|
||||
const [version, setVersion] = useState(1);
|
||||
const [streaming, setStreaming] = useState(false);
|
||||
useEffect(() => {
|
||||
if (!parameters.has("real")) return;
|
||||
const controller = new AbortController();
|
||||
void fetchWebuiThread("fixture", "websocket:rail", { limit: 40, signal: controller.signal }).then((page) => {
|
||||
if (page && !controller.signal.aborted) setMessages(projectThreadEvents(page.events));
|
||||
});
|
||||
return () => controller.abort();
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
if (!streaming) return;
|
||||
let count = 0;
|
||||
const user: UIMessage = { id: "stream-user", role: "user", content: "Streaming question", createdAt: Date.now() };
|
||||
const timer = window.setInterval(() => {
|
||||
count++;
|
||||
setMessages((current) => [...current.filter((message) => message.id !== "stream-user" && message.id !== "stream-answer"), user,
|
||||
{ id: "stream-answer", role: "assistant", content: "Streaming text. ".repeat(count), createdAt: user.createdAt + 1, isStreaming: count < 120 }]);
|
||||
if (count === 120) setStreaming(false);
|
||||
}, 16);
|
||||
return () => window.clearInterval(timer);
|
||||
}, [streaming]);
|
||||
const navigation = usePromptHistory(messages.length ? "websocket:rail" : null, version, messages);
|
||||
const composer = <div style={{ height: parameters.has("tall-composer") ? 240 : 100, border: "1px solid #ddd", borderRadius: 20, padding: 20 }}>Message nanobot</div>;
|
||||
const viewport = (external: boolean, navigationFrame?: HTMLElement | null) => <ThreadViewport
|
||||
messages={messages} isStreaming={streaming} conversationKey="websocket:rail"
|
||||
navigation={parameters.has("short") ? undefined : navigation}
|
||||
navigationFrame={navigationFrame} composer={external ? null : composer} />;
|
||||
return <main style={{ height: "100vh", display: "flex", flexDirection: "column" }}>
|
||||
{parameters.has("real") && <div>
|
||||
<button onClick={() => setVersion((value) => value + 1)}>Refresh index</button>
|
||||
<button onClick={() => setStreaming(true)} disabled={streaming}>{streaming ? "Streaming" : "Simulate stream"}</button>
|
||||
</div>}
|
||||
{parameters.has("workbench") ? <PaneWorkbench
|
||||
panes={parameters.has("focus-links")
|
||||
? [{ key: "rail", title: "Rail conversation" }, { key: "other", title: "Other conversation" }]
|
||||
: [{ key: "rail", title: "Rail conversation" }]} activePaneKey="rail" layout="columns" showLayoutControl={false}
|
||||
onActivatePane={() => {}} onAddPane={() => {}} onLayoutChange={() => {}} onPaneOrderChange={() => {}}
|
||||
renderPane={(_pane, context) => <>
|
||||
{viewport(context.composerPortalTarget !== undefined, context.navigationFrame)}
|
||||
{context.composerPortalTarget && createPortal(composer, context.composerPortalTarget)}
|
||||
</>}
|
||||
/> : viewport(false)}
|
||||
</main>;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
|
||||
|
||||
export function TallDialogFixture({ placement }: { placement: "center" | "bottom" }) {
|
||||
return <main aria-label="Background content" style={{ height: 240, overflowY: "auto" }}>
|
||||
<div style={{ minHeight: 1800 }}><Dialog>
|
||||
<DialogTrigger asChild><button>Open tall dialog</button></DialogTrigger>
|
||||
<DialogContent placement={placement}>
|
||||
<DialogTitle>Tall dialog</DialogTitle>
|
||||
<DialogDescription>All controls must remain reachable in a short viewport.</DialogDescription>
|
||||
{Array.from({ length: 30 }, (_, index) => <label key={index}>
|
||||
Field {index + 1}<input aria-label={`Field ${index + 1}`} style={{ display: "block", height: 40 }} />
|
||||
</label>)}
|
||||
<DialogClose asChild><button>Save tall dialog</button></DialogClose>
|
||||
</DialogContent>
|
||||
</Dialog></div>
|
||||
</main>;
|
||||
}
|
||||
@@ -13,7 +13,7 @@ export default tseslint.config(
|
||||
js.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
{
|
||||
files: ["scripts/check_client_import_boundaries*.mjs"],
|
||||
files: ["scripts/check_client_import_boundaries*.mjs", "webui/scripts/**/*.mjs"],
|
||||
languageOptions: {
|
||||
globals: { ...globals.node, Bun: "readonly" },
|
||||
},
|
||||
|
||||
+5
-2
@@ -9,13 +9,16 @@
|
||||
"build": "tsc -p tsconfig.build.json && vite build",
|
||||
"preview": "vite preview",
|
||||
"typecheck": "tsc -p tsconfig.json",
|
||||
"typecheck:browser": "tsc -p tsconfig.browser.json",
|
||||
"test": "vitest run",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
"test:ci": "bun test scripts/*.test.mjs",
|
||||
"test:watch": "vitest",
|
||||
"test:browser": "tsc -p tsconfig.browser.json && playwright test",
|
||||
"test:browser": "bun run typecheck:browser && playwright test",
|
||||
"test:browser:shard": "bun scripts/run-browser-shard.mjs",
|
||||
"check:imports": "bun ../scripts/check_client_import_boundaries.mjs --project webui",
|
||||
"test:imports": "bun test ../scripts/check_client_import_boundaries.test.mjs",
|
||||
"lint": "cd .. && eslint --config webui/eslint.config.js webui/src webui/browser \"nanobot/channels/*/webui/**/*.{ts,tsx}\" \"nanobot/channels/*/tests/webui/**/*.{ts,tsx}\" \"scripts/check_client_import_boundaries*.mjs\" --max-warnings 0"
|
||||
"lint": "cd .. && eslint --config webui/eslint.config.js webui/src webui/browser \"nanobot/channels/*/webui/**/*.{ts,tsx}\" \"nanobot/channels/*/tests/webui/**/*.{ts,tsx}\" \"scripts/check_client_import_boundaries*.mjs\" \"webui/scripts/**/*.mjs\" --max-warnings 0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pierre/diffs": "1.6.4",
|
||||
|
||||
@@ -6,6 +6,7 @@ const port = Number(process.env.NANOBOT_BROWSER_TEST_PORT ?? 4178);
|
||||
export default defineConfig({
|
||||
testDir: "./browser",
|
||||
fullyParallel: false,
|
||||
forbidOnly: !!process.env.CI,
|
||||
workers: process.env.CI ? Math.min(3, availableParallelism()) : 2,
|
||||
retries: 0,
|
||||
timeout: 30_000,
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import path from "node:path";
|
||||
|
||||
// Use native discovery and execution reports so test-list filtering cannot turn
|
||||
// a nonempty planned shard into a successful empty or incomplete execution.
|
||||
export function browserTests(report, root) {
|
||||
const tests = [];
|
||||
function visit(suite) {
|
||||
for (const spec of suite.specs ?? []) {
|
||||
const file = path.relative(root, path.resolve(report.config.rootDir, spec.file)).replaceAll("\\", "/");
|
||||
for (const test of spec.tests) {
|
||||
tests.push({ file, id: `${spec.id}:${test.projectId}` });
|
||||
}
|
||||
}
|
||||
suite.suites?.forEach(visit);
|
||||
}
|
||||
report.suites.forEach(visit);
|
||||
return tests;
|
||||
}
|
||||
|
||||
export function verifyBrowserShard(report, expected, root) {
|
||||
const actual = browserTests(report, root).map((test) => test.id).sort();
|
||||
const wanted = expected.map((test) => test.id).sort();
|
||||
if (actual.join("\n") !== wanted.join("\n")) {
|
||||
throw new Error("Browser shard execution differs from full Playwright discovery");
|
||||
}
|
||||
console.log(`Verified all ${wanted.length} planned browser tests executed exactly once`);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import path from "node:path";
|
||||
import { browserTests, verifyBrowserShard } from "./browser-report.mjs";
|
||||
|
||||
const root = path.resolve("webui-fixture");
|
||||
const spec = (id, file) => ({ id, file, tests: [{ projectId: "chromium" }] });
|
||||
function report(specs) {
|
||||
return { config: { rootDir: path.join(root, "browser") }, suites: [{ suites: [{ specs }] }] };
|
||||
}
|
||||
|
||||
const specs = [spec("first", "nested/first.spec.ts"), spec("second", "second.spec.ts")];
|
||||
const expected = [
|
||||
{ file: "browser/nested/first.spec.ts", id: "first:chromium" },
|
||||
{ file: "browser/second.spec.ts", id: "second:chromium" },
|
||||
];
|
||||
|
||||
test("native nested reports retain file and project identities in discovery and execution", () => {
|
||||
expect(browserTests(report(specs), root)).toEqual(expected);
|
||||
expect(() => verifyBrowserShard(report([...specs].reverse()), expected, root)).not.toThrow();
|
||||
});
|
||||
|
||||
test("an empty or partially filtered browser shard cannot pass", () => {
|
||||
expect(() => verifyBrowserShard(report([]), expected, root)).toThrow("differs");
|
||||
expect(() => verifyBrowserShard(report(specs.slice(0, 1)), expected, root)).toThrow("differs");
|
||||
});
|
||||
|
||||
test("running a test twice cannot replace another planned test", () => {
|
||||
expect(() => verifyBrowserShard(report([specs[0], specs[0]]), expected, root)).toThrow("differs");
|
||||
});
|
||||
@@ -0,0 +1,77 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { parseArgs } from "node:util";
|
||||
import { loadDurations, partitionFiles } from "./test-shards.mjs";
|
||||
import { browserTests, verifyBrowserShard } from "./browser-report.mjs";
|
||||
|
||||
const cli = path.resolve("node_modules/@playwright/test/cli.js");
|
||||
|
||||
function collectFiles() {
|
||||
const env = { ...process.env };
|
||||
delete env.PLAYWRIGHT_JSON_OUTPUT_NAME;
|
||||
delete env.PLAYWRIGHT_JSON_OUTPUT_DIR;
|
||||
const collected = spawnSync("node", [cli, "test", "--list", "--reporter=json"], {
|
||||
env,
|
||||
encoding: "utf8",
|
||||
maxBuffer: 20 * 1024 * 1024,
|
||||
});
|
||||
if (collected.error) throw collected.error;
|
||||
if (collected.status !== 0) {
|
||||
process.stderr.write(collected.stderr);
|
||||
process.stderr.write(collected.stdout);
|
||||
throw new Error("Playwright test discovery failed");
|
||||
}
|
||||
const report = JSON.parse(collected.stdout);
|
||||
const tests = browserTests(report, process.cwd());
|
||||
return { rootDir: report.config.rootDir, files: [...new Set(tests.map((test) => test.file))], tests };
|
||||
}
|
||||
|
||||
const { values } = parseArgs({
|
||||
options: {
|
||||
shard: { type: "string" },
|
||||
list: { type: "boolean", default: false },
|
||||
trace: { type: "string", default: "retain-on-failure" },
|
||||
},
|
||||
});
|
||||
const match = /^([1-9]\d*)\/([1-9]\d*)$/.exec(values.shard ?? "");
|
||||
if (!match) throw new Error("Use --shard=index/count, for example --shard=1/4");
|
||||
const [, indexText, countText] = match;
|
||||
const index = Number(indexText);
|
||||
const count = Number(countText);
|
||||
if (index > count) throw new Error("Shard index exceeds shard count");
|
||||
|
||||
const { rootDir, files, tests } = collectFiles();
|
||||
const shards = partitionFiles(files, count, loadDurations());
|
||||
const selected = shards[index - 1];
|
||||
if (!selected.length) throw new Error("Browser shard is empty");
|
||||
if (values.list) {
|
||||
console.log(JSON.stringify({ shard: index, count, files: selected }, null, 2));
|
||||
} else {
|
||||
const directory = mkdtempSync(path.join(tmpdir(), "nanobot-browser-shard-"));
|
||||
try {
|
||||
const list = path.join(directory, "tests.txt");
|
||||
writeFileSync(list, selected.map((file) => path.relative(rootDir, path.resolve(file)).replaceAll("\\", "/")).join("\n"));
|
||||
console.log(`Browser shard ${index}/${count}: ${selected.length}/${files.length} files`);
|
||||
const reportFile = path.resolve(`test-results/browser/results-${index}-of-${count}.json`);
|
||||
rmSync(reportFile, { force: true });
|
||||
const result = spawnSync("node", [
|
||||
cli, "test", `--test-list=${list}`, `--trace=${values.trace}`, "--reporter=list,json",
|
||||
], {
|
||||
stdio: "inherit",
|
||||
env: {
|
||||
...process.env,
|
||||
PLAYWRIGHT_JSON_OUTPUT_NAME: reportFile,
|
||||
},
|
||||
});
|
||||
if (result.error) throw result.error;
|
||||
process.exitCode = result.status ?? 1;
|
||||
if (result.status === 0) {
|
||||
const selectedFiles = new Set(selected);
|
||||
verifyBrowserShard(JSON.parse(readFileSync(reportFile, "utf8")), tests.filter((test) => selectedFiles.has(test.file)), process.cwd());
|
||||
}
|
||||
} finally {
|
||||
rmSync(directory, { recursive: true });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
const timingsFile = new URL("../test-timings.json", import.meta.url);
|
||||
|
||||
/**
|
||||
* Assign every discovered file exactly once using longest-processing-time first.
|
||||
* Equal durations use path order; equal loads use file count, then shard index.
|
||||
* @param {Array<string>} files Normalized paths relative to webui/.
|
||||
* @param {number} count
|
||||
* @param {Record<string, number>} durations Durations in milliseconds.
|
||||
* @returns {Array<Array<string>>}
|
||||
*/
|
||||
export function partitionFiles(files, count, durations) {
|
||||
if (!Number.isInteger(count) || count < 1) {
|
||||
throw new Error("Shard count must be a positive integer");
|
||||
}
|
||||
if (new Set(files).size !== files.length) {
|
||||
throw new Error("Discovered test files contain duplicates");
|
||||
}
|
||||
const weight = (file) => {
|
||||
// New files are never selected out by a stale timing manifest.
|
||||
const duration = Object.hasOwn(durations, file) ? durations[file] : 1;
|
||||
if (!Number.isFinite(duration) || duration < 0) {
|
||||
throw new Error(`Invalid test duration for ${file}`);
|
||||
}
|
||||
return duration;
|
||||
};
|
||||
const ordered = files.map((file) => ({ file, duration: weight(file) })).sort((a, b) =>
|
||||
b.duration - a.duration || (a.file < b.file ? -1 : a.file > b.file ? 1 : 0),
|
||||
);
|
||||
const shards = Array.from({ length: count }, () => []);
|
||||
const loads = Array(count).fill(0);
|
||||
for (const { file, duration } of ordered) {
|
||||
let selected = 0;
|
||||
for (let index = 1; index < count; index += 1) {
|
||||
if (loads[index] < loads[selected]
|
||||
|| (loads[index] === loads[selected] && shards[index].length < shards[selected].length)) {
|
||||
selected = index;
|
||||
}
|
||||
}
|
||||
shards[selected].push(file);
|
||||
loads[selected] += duration;
|
||||
}
|
||||
return shards;
|
||||
}
|
||||
|
||||
/** @returns {Record<string, number>} */
|
||||
export function loadDurations() {
|
||||
return JSON.parse(readFileSync(timingsFile, "utf8")).browser;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { partitionFiles } from "./test-shards.mjs";
|
||||
|
||||
const files = ["browser/a.spec.ts", "browser/b.spec.ts", "browser/c.spec.ts", "browser/nested/d.spec.ts"];
|
||||
const durations = { [files[0]]: 9, [files[1]]: 8, [files[2]]: 7, [files[3]]: 6 };
|
||||
|
||||
test("LPT balances measured durations without changing the inputs", () => {
|
||||
const input = Object.freeze([...files]);
|
||||
expect(partitionFiles(input, 2, Object.freeze(durations))).toEqual([
|
||||
[files[0], files[3]], [files[1], files[2]],
|
||||
]);
|
||||
expect(input).toEqual(files);
|
||||
});
|
||||
|
||||
test("equal loads and durations are deterministic across discovery order", () => {
|
||||
const input = ["e", "b", "d", "a", "c"];
|
||||
expect(partitionFiles(input, 2, {})).toEqual([["a", "c", "e"], ["b", "d"]]);
|
||||
expect(partitionFiles([...input].reverse(), 2, {})).toEqual(partitionFiles(input, 2, {}));
|
||||
expect(partitionFiles(input, 2, Object.fromEntries(input.map((file) => [file, 0]))))
|
||||
.toEqual([["a", "c", "e"], ["b", "d"]]);
|
||||
});
|
||||
|
||||
test("stale timings cannot omit newly discovered tests", () => {
|
||||
const discovered = [...files, "browser/new.spec.ts", "browser/nested/new.spec.ts"];
|
||||
const shards = partitionFiles(discovered, 3, { ...durations, "browser/deleted.spec.ts": 100_000 });
|
||||
expect(shards.flat().sort()).toEqual([...discovered].sort());
|
||||
expect(new Set(shards.flat()).size).toBe(discovered.length);
|
||||
expect(partitionFiles([], 2, {})).toEqual([[], []]);
|
||||
});
|
||||
|
||||
test("invalid counts and duplicate discovery fail explicitly", () => {
|
||||
expect(() => partitionFiles(files, 0, durations)).toThrow("positive integer");
|
||||
expect(() => partitionFiles([files[0], files[0]], 2, {})).toThrow("duplicates");
|
||||
});
|
||||
@@ -50,6 +50,8 @@ export function AttachmentCard({ name, description, children, action, invalid =
|
||||
</PopoverTrigger>
|
||||
<PopoverContent side="top" aria-label={name}
|
||||
onOpenAutoFocus={(event) => event.preventDefault()}
|
||||
// Focus stays on the trigger; delayed restoration must not steal the next Tab.
|
||||
onCloseAutoFocus={(event) => event.preventDefault()}
|
||||
className="w-max max-w-[min(20rem,calc(100vw-2rem))] break-words px-3 py-1.5 text-caption">
|
||||
{details}
|
||||
</PopoverContent>
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"source": "https://github.com/HKUDS/nanobot/actions/runs/43913643900",
|
||||
"commit": "691108c90fbfda390ed49bd08bdc7e0a41bd78cd",
|
||||
"browser": {
|
||||
"browser/about-layout.spec.ts": 15061,
|
||||
"browser/activity-logos.spec.ts": 9382,
|
||||
"browser/activity-wheel.spec.ts": 18858,
|
||||
"browser/answer-order.spec.ts": 52328,
|
||||
"browser/appearance.spec.ts": 29707,
|
||||
"browser/apps-connection-layout.spec.ts": 17311,
|
||||
"browser/apps-icons.spec.ts": 5772,
|
||||
"browser/attachment-layout.spec.ts": 30172,
|
||||
"browser/chat-failure.spec.ts": 64525,
|
||||
"browser/code-highlighting.spec.ts": 13705,
|
||||
"browser/code-wrapping.spec.ts": 12966,
|
||||
"browser/compaction-reasons.spec.ts": 32209,
|
||||
"browser/composer-action.spec.ts": 30622,
|
||||
"browser/composer-attachments.spec.ts": 23787,
|
||||
"browser/composer-layout.spec.ts": 29591,
|
||||
"browser/composer-surface.spec.ts": 5066,
|
||||
"browser/context-graph.spec.ts": 22421,
|
||||
"browser/continuity.spec.ts": 7000,
|
||||
"browser/diagrams.spec.ts": 23359,
|
||||
"browser/display-math.spec.ts": 4828,
|
||||
"browser/exec-session.spec.ts": 3154,
|
||||
"browser/file-diff.spec.ts": 60705,
|
||||
"browser/file-edit-path.spec.ts": 5710,
|
||||
"browser/gallery-language.spec.ts": 54431,
|
||||
"browser/goal-island-background.spec.ts": 7799,
|
||||
"browser/history-boundary.spec.ts": 121145,
|
||||
"browser/history-hydration.spec.ts": 49088,
|
||||
"browser/hover-hint-presence.spec.ts": 13183,
|
||||
"browser/idle-compaction.spec.ts": 18279,
|
||||
"browser/inline-file-reference.spec.ts": 3091,
|
||||
"browser/inline-references.spec.ts": 26132,
|
||||
"browser/layout.spec.ts": 4871,
|
||||
"browser/loaded-session-search.spec.ts": 2342,
|
||||
"browser/locale-startup.spec.ts": 2693,
|
||||
"browser/markdown-dollar-refs.spec.ts": 3237,
|
||||
"browser/mcp-management.spec.ts": 4141,
|
||||
"browser/mobile-chat-layout.spec.ts": 14892,
|
||||
"browser/new-chat-skeleton.spec.ts": 58253,
|
||||
"browser/overlay-focus.spec.ts": 32030,
|
||||
"browser/pairing-refresh.spec.ts": 4949,
|
||||
"browser/preset-summary.spec.ts": 6650,
|
||||
"browser/product-icons.spec.ts": 2414,
|
||||
"browser/prompt-rail.spec.ts": 11147,
|
||||
"browser/provider-parameters.spec.ts": 9376,
|
||||
"browser/queued-guidance.spec.ts": 9712,
|
||||
"browser/session-messages.spec.ts": 8450,
|
||||
"browser/session-transition.spec.ts": 81360,
|
||||
"browser/sidebar-activity.spec.ts": 6060,
|
||||
"browser/sidebar-brand-theme.spec.ts": 7475,
|
||||
"browser/skeleton-additions.spec.ts": 103459,
|
||||
"browser/skeleton-layout.spec.ts": 85583,
|
||||
"browser/skills-marketplace-identity.spec.ts": 23658,
|
||||
"browser/startup-shell.spec.ts": 4026,
|
||||
"browser/subagent-dock.spec.ts": 111086,
|
||||
"browser/theme-invitation.spec.ts": 5714,
|
||||
"browser/theme-toggle.spec.ts": 38920,
|
||||
"browser/thread-autoscroll.spec.ts": 3786,
|
||||
"browser/thread-loading.spec.ts": 13945,
|
||||
"browser/thread-prompt-anchor.spec.ts": 27621,
|
||||
"browser/tools-catalog.spec.ts": 1704,
|
||||
"browser/typography.spec.ts": 21504,
|
||||
"browser/workspace-access-focus.spec.ts": 7324,
|
||||
"browser/workspace-access-hint.spec.ts": 44187,
|
||||
"browser/workspace-alignment.spec.ts": 14690
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user