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}
|
key={round.id}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex h-full min-w-0 flex-1 items-end justify-center rounded-sm",
|
"flex h-full min-w-0 flex-1 items-end justify-center rounded-sm",
|
||||||
|
bottomSheet && "relative",
|
||||||
"opacity-70 transition-opacity hover:opacity-100",
|
"opacity-70 transition-opacity hover:opacity-100",
|
||||||
index === 0 && "justify-start",
|
index === 0 && "justify-start",
|
||||||
normalizedRounds.length > 1
|
normalizedRounds.length > 1
|
||||||
@@ -347,7 +348,9 @@ export function ComposerUsagePopover({
|
|||||||
className={cn(
|
className={cn(
|
||||||
"flex w-full max-w-7 flex-col overflow-hidden rounded-t-[3px] bg-muted",
|
"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",
|
"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` }}
|
style={{ height: `${barHeight}px` }}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -37,6 +37,25 @@ async function openSheet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("Mobile context usage sheet", () => {
|
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 () => {
|
it("replaces the X with a keyboard-accessible drag handle", async () => {
|
||||||
const { user, handle, sheet, trigger } = await openSheet();
|
const { user, handle, sheet, trigger } = await openSheet();
|
||||||
expect(within(sheet).getAllByRole("button", { name: "Close" })).toEqual([handle]);
|
expect(within(sheet).getAllByRole("button", { name: "Close" })).toEqual([handle]);
|
||||||
|
|||||||
@@ -4,13 +4,21 @@ import path from "node:path";
|
|||||||
import { gunzipSync } from "node:zlib";
|
import { gunzipSync } from "node:zlib";
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import {
|
import webuiConfig, {
|
||||||
entryLazyFeatureImports,
|
entryLazyFeatureImports,
|
||||||
gzipWebuiAssets,
|
gzipWebuiAssets,
|
||||||
webuiManualChunk,
|
webuiManualChunk,
|
||||||
writeCompressedWebuiAssets,
|
writeCompressedWebuiAssets,
|
||||||
} from "../../vite.config";
|
} 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", () => {
|
describe("gzipWebuiAssets", () => {
|
||||||
it("compresses finalized files after Rollup writes the bundle", () => {
|
it("compresses finalized files after Rollup writes the bundle", () => {
|
||||||
const plugin = gzipWebuiAssets();
|
const plugin = gzipWebuiAssets();
|
||||||
|
|||||||
@@ -129,10 +129,10 @@ export default defineConfig(({ mode }) => {
|
|||||||
dedupe: ["react", "react-dom", "lucide-react", "react-i18next", "qrcode"],
|
dedupe: ["react", "react-dom", "lucide-react", "react-i18next", "qrcode"],
|
||||||
},
|
},
|
||||||
optimizeDeps: {
|
optimizeDeps: {
|
||||||
// Radix Dialog can rewrite its optimized chunk while a dev tab is open.
|
// Pre-bundle Dialog up front, including lazy settings/sheets. Excluding
|
||||||
// Syntax highlighting must remain pre-bundled because Refractor's core
|
// it splits its layer/focus state from optimized Popover and DropdownMenu,
|
||||||
// still uses CommonJS internally.
|
// so nested overlays can dismiss the wrong layer in development.
|
||||||
exclude: ["@radix-ui/react-dialog"],
|
include: ["@radix-ui/react-dialog"],
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
outDir: path.resolve(__dirname, "../nanobot/web/dist"),
|
outDir: path.resolve(__dirname, "../nanobot/web/dist"),
|
||||||
|
|||||||
Reference in new issue
Block a user