fix(webui): harden mobile context sheet interactions
This commit is contained in:
1 parent
aa799cec9f
commit
08b130cdd1
4 files changed
+36
-6
No files matched your search
@@ -328,6 +328,7 @@ export function ComposerUsagePopover({
|
||||
key={round.id}
|
||||
className={cn(
|
||||
"flex h-full min-w-0 flex-1 items-end justify-center rounded-sm",
|
||||
bottomSheet && "relative",
|
||||
"opacity-70 transition-opacity hover:opacity-100",
|
||||
index === 0 && "justify-start",
|
||||
normalizedRounds.length > 1
|
||||
@@ -347,7 +348,9 @@ export function ComposerUsagePopover({
|
||||
className={cn(
|
||||
"flex w-full max-w-7 flex-col overflow-hidden rounded-t-[3px] bg-muted",
|
||||
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
||||
bottomSheet && "data-[state=open]:ring-2 data-[state=open]:ring-foreground/20",
|
||||
// Let touch users hit the entire column, even when a
|
||||
// round's proportional bar is less than a pixel high.
|
||||
bottomSheet && "before:absolute before:inset-0 before:content-[''] data-[state=open]:ring-2 data-[state=open]:ring-foreground/20",
|
||||
)}
|
||||
style={{ height: `${barHeight}px` }}
|
||||
>
|
||||
|
||||
@@ -37,6 +37,25 @@ async function openSheet() {
|
||||
}
|
||||
|
||||
describe("Mobile context usage sheet", () => {
|
||||
it("keeps tiny rounds tappable without exaggerating their visual token usage", async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<ComposerUsagePopover bottomSheet context={null} rounds={[
|
||||
{ id: "small", timestamp: 0, inputTokens: 1000 },
|
||||
{ id: "large", timestamp: 60000, inputTokens: 500000 },
|
||||
]} />);
|
||||
await user.click(screen.getByTestId("composer-context-usage"));
|
||||
const [small, large] = screen.getAllByTestId("round-usage-bar");
|
||||
for (const bar of [small, large]) {
|
||||
expect(bar.parentElement).toHaveClass("relative", "h-full", "flex-1");
|
||||
expect(bar).toHaveClass("before:absolute", "before:inset-0");
|
||||
}
|
||||
expect(small).toHaveStyle({ height: "0.216px" });
|
||||
expect(large).toHaveStyle({ height: "108px" });
|
||||
await user.pointer([{ keys: "[TouchA>]", target: small }, { keys: "[/TouchA]", target: small }]);
|
||||
expect(within(screen.getByRole("dialog", { name: "Context usage" })).getByRole("dialog"))
|
||||
.toHaveTextContent("1,000");
|
||||
});
|
||||
|
||||
it("replaces the X with a keyboard-accessible drag handle", async () => {
|
||||
const { user, handle, sheet, trigger } = await openSheet();
|
||||
expect(within(sheet).getAllByRole("button", { name: "Close" })).toEqual([handle]);
|
||||
|
||||
@@ -4,13 +4,21 @@ import path from "node:path";
|
||||
import { gunzipSync } from "node:zlib";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
import webuiConfig, {
|
||||
entryLazyFeatureImports,
|
||||
gzipWebuiAssets,
|
||||
webuiManualChunk,
|
||||
writeCompressedWebuiAssets,
|
||||
} from "../../vite.config";
|
||||
|
||||
describe("development overlay dependencies", () => {
|
||||
it("pre-bundles Dialog so sheets share layer and focus state with popovers", () => {
|
||||
const config = webuiConfig({ command: "serve", mode: "test" });
|
||||
expect(config.optimizeDeps?.include).toContain("@radix-ui/react-dialog");
|
||||
expect(config.optimizeDeps?.exclude ?? []).not.toContain("@radix-ui/react-dialog");
|
||||
});
|
||||
});
|
||||
|
||||
describe("gzipWebuiAssets", () => {
|
||||
it("compresses finalized files after Rollup writes the bundle", () => {
|
||||
const plugin = gzipWebuiAssets();
|
||||
|
||||
@@ -129,10 +129,10 @@ export default defineConfig(({ mode }) => {
|
||||
dedupe: ["react", "react-dom", "lucide-react", "react-i18next", "qrcode"],
|
||||
},
|
||||
optimizeDeps: {
|
||||
// Radix Dialog can rewrite its optimized chunk while a dev tab is open.
|
||||
// Syntax highlighting must remain pre-bundled because Refractor's core
|
||||
// still uses CommonJS internally.
|
||||
exclude: ["@radix-ui/react-dialog"],
|
||||
// Pre-bundle Dialog up front, including lazy settings/sheets. Excluding
|
||||
// it splits its layer/focus state from optimized Popover and DropdownMenu,
|
||||
// so nested overlays can dismiss the wrong layer in development.
|
||||
include: ["@radix-ui/react-dialog"],
|
||||
},
|
||||
build: {
|
||||
outDir: path.resolve(__dirname, "../nanobot/web/dist"),
|
||||
|
||||
Reference in new issue
Block a user