fix(webui): tighten mobile chat layout and soften transcript edges
This commit is contained in:
1 parent
ce885fa31e
commit
8af2d396ab
10 files changed
+183
-26
No files matched your search
@@ -59,11 +59,13 @@ export function ComposerUsagePopover({
|
||||
context,
|
||||
rounds,
|
||||
showLabel = false,
|
||||
compactLabel = false,
|
||||
bottomSheet = false,
|
||||
}: {
|
||||
context: ComposerContextUsage | null;
|
||||
rounds: readonly ComposerRoundUsage[];
|
||||
showLabel?: boolean;
|
||||
compactLabel?: boolean;
|
||||
bottomSheet?: boolean;
|
||||
}) {
|
||||
const { t, i18n } = useTranslation();
|
||||
@@ -123,6 +125,7 @@ export function ComposerUsagePopover({
|
||||
const RoundTrigger = bottomSheet ? PopoverTrigger : TooltipTrigger;
|
||||
const RoundContent = bottomSheet ? PopoverContent : TooltipContent;
|
||||
const RoundBar = bottomSheet ? "button" : "span";
|
||||
const showTextLabel = showLabel && (!compactLabel || contextPercentage !== null);
|
||||
const trigger = (
|
||||
<Trigger asChild>
|
||||
<button
|
||||
@@ -133,7 +136,7 @@ export function ComposerUsagePopover({
|
||||
"touch-target inline-flex size-5 shrink-0 items-center justify-center rounded-full",
|
||||
"text-muted-foreground transition-colors hover:text-foreground",
|
||||
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
||||
showLabel && "w-auto gap-1.5 px-2 text-xs",
|
||||
showTextLabel && "w-auto gap-1.5 px-2 text-xs",
|
||||
)}
|
||||
>
|
||||
{contextPercentage === null ? (
|
||||
@@ -179,7 +182,11 @@ export function ComposerUsagePopover({
|
||||
/>
|
||||
</svg>
|
||||
)}
|
||||
{showLabel ? <span aria-hidden>{contextDescription}</span> : null}
|
||||
{showTextLabel ? (
|
||||
<span aria-hidden className="whitespace-nowrap tabular-nums">
|
||||
{compactLabel && contextPercentage !== null ? `${contextPercentage}%` : contextDescription}
|
||||
</span>
|
||||
) : null}
|
||||
</button>
|
||||
</Trigger>
|
||||
);
|
||||
|
||||
@@ -2547,8 +2547,9 @@ export function ThreadComposer({
|
||||
onClick={modelNeedsSetup ? onModelBadgeClick : undefined}
|
||||
/>
|
||||
) : null;
|
||||
const usageInMeta = mobileWorkspaceControls || compactControls;
|
||||
const usageControl = !voiceRecorder.isRecording && (contextUsage || recentRoundUsage.length) ? (
|
||||
<ComposerUsagePopover context={contextUsage} rounds={recentRoundUsage} showLabel={compactControls} bottomSheet={compactControls} />
|
||||
<ComposerUsagePopover context={contextUsage} rounds={recentRoundUsage} showLabel={usageInMeta} compactLabel={mobileWorkspaceControls} bottomSheet={usageInMeta} />
|
||||
) : null;
|
||||
const inputTextClasses = cn(
|
||||
// Keep the overlay's CJK/Latin spacing aligned with the native textarea caret.
|
||||
@@ -2610,7 +2611,7 @@ export function ThreadComposer({
|
||||
"thread-composer-form relative w-full [--composer-action-margin:0px]",
|
||||
isHero
|
||||
? "px-0 [--composer-action-size:2rem] [--composer-footer-inset:0.75rem] sm:[--composer-footer-inset:1rem]"
|
||||
: "px-1 pb-1.5 pt-1 [--composer-action-size:2.25rem] [--composer-footer-inset:0.625rem] sm:px-0 sm:[--composer-footer-inset:0.75rem]",
|
||||
: "px-1 pb-0 pt-1 [--composer-action-size:2.25rem] [--composer-footer-inset:0.625rem] sm:px-0 sm:pb-1.5 sm:[--composer-footer-inset:0.75rem]",
|
||||
compactWhenIdle && "thread-composer-collapsible-layout",
|
||||
paletteBeside && "grid grid-cols-2 items-start gap-2 p-0",
|
||||
)}
|
||||
@@ -2838,7 +2839,7 @@ export function ThreadComposer({
|
||||
)}
|
||||
>
|
||||
{modelControl}
|
||||
{!compactControls ? usageControl : null}
|
||||
{!usageInMeta ? usageControl : null}
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
@@ -2899,18 +2900,22 @@ export function ThreadComposer({
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{workspaceControl || mobileWorkspaceControls && accessControl || compactControls && usageControl ? (
|
||||
{workspaceControl || mobileWorkspaceControls && accessControl || usageInMeta && usageControl ? (
|
||||
<div className={cn(
|
||||
"thread-composer-meta mx-auto mt-1 flex w-full min-w-0 flex-wrap items-center gap-x-2 gap-y-1 pr-2 sm:pr-3",
|
||||
"thread-composer-meta mx-auto mt-1 flex w-full min-w-0 items-center gap-x-2 pr-2 sm:pr-3",
|
||||
mobileWorkspaceControls ? "flex-nowrap gap-x-1 pr-0" : "flex-wrap gap-y-1",
|
||||
isHero ? "max-w-[58rem]" : "max-w-[49.5rem]",
|
||||
paletteBeside && "col-start-1 row-start-2",
|
||||
)}>
|
||||
{mobileWorkspaceControls && compactControls && usageControl ? <div className="flex w-full justify-end">{usageControl}</div> : null}
|
||||
<div className={cn("thread-composer-workspace-group flex min-w-0 items-center gap-1", mobileWorkspaceControls ? "flex-1" : "flex-auto max-[359px]:flex-wrap")}>
|
||||
{workspaceControl}
|
||||
</div>
|
||||
{!mobileWorkspaceControls && compactControls && usageControl ? <div className="ml-auto shrink-0">{usageControl}</div> : null}
|
||||
{mobileWorkspaceControls && accessControl ? <div className="ml-auto min-w-0 max-w-[55%] shrink">{accessControl}</div> : null}
|
||||
{usageInMeta && usageControl || mobileWorkspaceControls && accessControl ? (
|
||||
<div className={cn("ml-auto flex shrink-0 items-center gap-1", mobileWorkspaceControls && "h-11 max-w-[calc(100%-3rem)]")}>
|
||||
{usageInMeta ? usageControl : null}
|
||||
{mobileWorkspaceControls ? accessControl : null}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
</form>
|
||||
|
||||
@@ -1213,7 +1213,7 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
|
||||
<div
|
||||
className={cn(
|
||||
hasThreadLayout
|
||||
? "px-3 pb-[calc(0.75rem+env(safe-area-inset-bottom))] sm:px-4"
|
||||
? "px-3 pb-[calc(0.5rem+env(safe-area-inset-bottom))] sm:px-4 sm:pb-[calc(0.75rem+env(safe-area-inset-bottom))]"
|
||||
: "",
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -830,7 +830,7 @@ export function PaneWorkbench({
|
||||
</div>
|
||||
|
||||
{chrome ? (
|
||||
<footer className="workbench-composer-footer shrink-0 bg-background px-3 pb-[calc(0.75rem+env(safe-area-inset-bottom))] sm:px-4">
|
||||
<footer className="workbench-composer-footer shrink-0 bg-background px-3 pb-[calc(0.5rem+env(safe-area-inset-bottom))] sm:px-4 sm:pb-[calc(0.75rem+env(safe-area-inset-bottom))]">
|
||||
<div
|
||||
ref={setComposerPortalTarget}
|
||||
data-testid="workbench-composer-host"
|
||||
|
||||
+19
-5
@@ -567,6 +567,7 @@
|
||||
*/
|
||||
.thread-layout {
|
||||
--thread-composer-fade-height: 2.25rem;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
grid-template-rows: minmax(min-content, 1fr) auto 0fr;
|
||||
transition: grid-template-rows 220ms ease-out;
|
||||
}
|
||||
@@ -585,23 +586,36 @@
|
||||
/**
|
||||
* Keep the transcript and composer visually continuous. The scrollport owns
|
||||
* the fade because overflow clips its contents before an adjacent overlay
|
||||
* can soften the edge. The matching in-flow gap keeps the last line fully
|
||||
* visible once the user reaches the bottom.
|
||||
* can soften the edge. On phones, the same mask keeps a clear top edge even
|
||||
* after the initial inset scrolls away. The matching bottom in-flow gap keeps
|
||||
* the last line fully visible once the user reaches the bottom.
|
||||
*/
|
||||
.thread-message-viewport {
|
||||
--thread-top-clearance: 0px;
|
||||
--thread-top-fade-height: 0px;
|
||||
-webkit-mask-image: linear-gradient(
|
||||
to bottom,
|
||||
#000 0,
|
||||
transparent 0,
|
||||
transparent var(--thread-top-clearance),
|
||||
#000 var(--thread-top-fade-height),
|
||||
#000 calc(100% - var(--thread-composer-fade-height)),
|
||||
transparent 100%
|
||||
);
|
||||
mask-image: linear-gradient(
|
||||
to bottom,
|
||||
#000 0,
|
||||
transparent 0,
|
||||
transparent var(--thread-top-clearance),
|
||||
#000 var(--thread-top-fade-height),
|
||||
#000 calc(100% - var(--thread-composer-fade-height)),
|
||||
transparent 100%
|
||||
);
|
||||
}
|
||||
@media (max-width: 639px) {
|
||||
.thread-message-viewport {
|
||||
--thread-top-clearance: 6px;
|
||||
--thread-top-fade-height: 22px;
|
||||
}
|
||||
}
|
||||
.thread-message-end-gap {
|
||||
height: var(--thread-composer-fade-height);
|
||||
}
|
||||
@@ -1302,7 +1316,7 @@
|
||||
.thread-composer-form { --composer-action-size: 2.75rem; }
|
||||
}
|
||||
|
||||
/* Narrow composers keep message and permission actions together, with usage below. */
|
||||
/* Compact composers keep their primary actions on a stable 44px touch grid. */
|
||||
.thread-composer-form[data-compact-controls] {
|
||||
--composer-action-size: 2.25rem;
|
||||
--composer-action-margin: 0.25rem;
|
||||
|
||||
@@ -1359,7 +1359,10 @@ describe("ThreadComposer", () => {
|
||||
expect(container.querySelector(".thread-composer-surface")!.nextElementSibling).toBe(meta);
|
||||
expect(meta.querySelector(".thread-composer-workspace-group")).toContainElement(workspace);
|
||||
expect(meta).toContainElement(access);
|
||||
expect(meta).toContainElement(screen.getByTestId("composer-context-usage"));
|
||||
const usage = screen.getByTestId("composer-context-usage");
|
||||
expect(meta).toContainElement(usage);
|
||||
expect(usage).toHaveTextContent(/^50%$/);
|
||||
expect(usage).toHaveAccessibleName("Context 50%. Open context usage");
|
||||
expect(access.closest(".thread-composer-footer-primary")).toBeNull();
|
||||
const user = userEvent.setup();
|
||||
await user.click(access);
|
||||
|
||||
Reference in new issue
Block a user