fix(web): align composer notices and stash (#8890)
Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
1 parent
941acb4f91
commit
e9db39ce05
8 files changed
+82
-69
No files matched your search
@@ -25,10 +25,7 @@ import {
|
||||
RuntimeMode,
|
||||
TerminalOpenInput,
|
||||
} from "@t3tools/contracts";
|
||||
import {
|
||||
connectionStatusTitle,
|
||||
type EnvironmentConnectionPresentation,
|
||||
} from "@t3tools/client-runtime/connection";
|
||||
import { type EnvironmentConnectionPresentation } from "@t3tools/client-runtime/connection";
|
||||
import { wasBootstrapThreadDeleted } from "@t3tools/client-runtime/errors";
|
||||
import { type CodexArtifactTemplate } from "@t3tools/client-runtime/codex-artifact-templates";
|
||||
import { effectiveSnoozed, threadWokeAt } from "@t3tools/client-runtime/state/thread-settled";
|
||||
@@ -2267,21 +2264,20 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
/>
|
||||
),
|
||||
title: `${unavailableConnection.phase === "connecting" ? "Connecting" : "Reconnecting"} to ${activeEnvironmentUnavailableState.label}`,
|
||||
description: "It may be finishing an update. One moment.",
|
||||
description: "Finishing an update",
|
||||
});
|
||||
} else {
|
||||
items.push({
|
||||
id: `environment-unavailable:${activeEnvironmentUnavailableState.environmentId}`,
|
||||
variant: unavailableConnection.phase === "error" ? "error" : "warning",
|
||||
icon: <WifiOffIcon />,
|
||||
title: `${activeEnvironmentUnavailableState.label}: ${connectionStatusTitle(unavailableConnection)}`,
|
||||
description:
|
||||
unavailableConnection.error ??
|
||||
"Reconnect this environment before sending messages or running actions.",
|
||||
title: `${activeEnvironmentUnavailableState.label} is ${environmentReconnecting ? "reconnecting" : "offline"}`,
|
||||
description: environmentReconnecting ? "Trying again" : "Reconnect to continue",
|
||||
actions: (
|
||||
<>
|
||||
<Button
|
||||
size="xs"
|
||||
variant="ghost"
|
||||
disabled={environmentReconnecting}
|
||||
onClick={() =>
|
||||
void handleReconnectActiveEnvironment(
|
||||
@@ -2293,7 +2289,7 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
variant="outline"
|
||||
variant="ghost"
|
||||
onClick={() => void navigate({ to: "/settings/connections" })}
|
||||
>
|
||||
Connections
|
||||
@@ -2344,13 +2340,10 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
description:
|
||||
!updateInProgress &&
|
||||
!updateFailed &&
|
||||
versionMismatchSelfUpdate === "desktop-managed" &&
|
||||
!versionMismatchDesktopAppUpdate
|
||||
? serverUpdateGuidance(versionMismatchSelfUpdate, versionMismatchServerLabel)
|
||||
versionMismatchSelfUpdate !== null &&
|
||||
(versionMismatchSelfUpdate !== "desktop-managed" || !versionMismatchDesktopAppUpdate)
|
||||
? serverUpdateGuidance(versionMismatchSelfUpdate)
|
||||
: undefined,
|
||||
// The desktop-managed guidance is already the description; the action
|
||||
// slot would only repeat it. When the desktop app accepts remote
|
||||
// update requests, the action button takes over instead.
|
||||
actions:
|
||||
updateInProgress ||
|
||||
!versionMismatch ||
|
||||
@@ -2363,6 +2356,7 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
desktopAppUpdate={versionMismatchDesktopAppUpdate}
|
||||
targetVersion={versionMismatch.clientVersion}
|
||||
label={updateFailed ? "Retry" : "Update"}
|
||||
variant="ghost"
|
||||
/>
|
||||
),
|
||||
...(updateInProgress || (!updateFailed && !versionMismatchDismissKey)
|
||||
@@ -5000,8 +4994,8 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
id: `thread-woke:${activeThread?.id ?? "unknown"}`,
|
||||
variant: "info",
|
||||
icon: <AlarmClockIcon />,
|
||||
title: "This thread woke from snooze",
|
||||
description: "Dismiss to clear the Woke indicator, or send a message to keep going.",
|
||||
title: "Thread woke from snooze",
|
||||
description: "Send a message to continue",
|
||||
dismissLabel: "Dismiss Woke notification",
|
||||
onDismiss: acknowledgeActiveThreadWoke,
|
||||
};
|
||||
@@ -5016,13 +5010,11 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
variant: "info",
|
||||
icon: isSnoozed ? <AlarmClockIcon /> : <CheckCircle2Icon />,
|
||||
title: `This thread is ${isSnoozed ? "snoozed" : "settled"}`,
|
||||
description: isSnoozed
|
||||
? "Sending a message wakes it and moves it back to Active in the sidebar."
|
||||
: "Sending a message moves it back to Active in the sidebar.",
|
||||
description: `Send a message to ${isSnoozed ? "wake" : "unsettle"}`,
|
||||
actions: (
|
||||
<Button
|
||||
size="xs"
|
||||
variant="outline"
|
||||
variant="ghost"
|
||||
disabled={isSnoozed ? isUnsnoozing : isUnsettling}
|
||||
onClick={() =>
|
||||
void (isSnoozed ? handleUnsnoozeActiveThread() : handleUnsettleActiveThread())
|
||||
@@ -5106,7 +5098,7 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
const compactAction = (
|
||||
<Button
|
||||
size="xs"
|
||||
variant="outline"
|
||||
variant="ghost"
|
||||
disabled={compactDisabled}
|
||||
onClick={() => {
|
||||
if (compactDisabled) return;
|
||||
@@ -5121,7 +5113,7 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
variant: "info",
|
||||
icon: <Minimize2Icon />,
|
||||
title: "Resume with less context",
|
||||
description: `${formatContextWindowTokens(activeContextWindow.usedTokens)} tokens from an older session`,
|
||||
description: `${formatContextWindowTokens(activeContextWindow.usedTokens)} tokens from earlier`,
|
||||
actions: compactDisabledReason ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger render={<span className="inline-flex">{compactAction}</span>} />
|
||||
@@ -5198,7 +5190,6 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
</Tooltip>
|
||||
</span>
|
||||
),
|
||||
className: "dark:shadow-none",
|
||||
actions: (
|
||||
<Button
|
||||
size="xs"
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
isAtomCommandInterrupted,
|
||||
squashAtomCommandFailure,
|
||||
} from "@t3tools/client-runtime/state/runtime";
|
||||
import type { ComponentProps } from "react";
|
||||
|
||||
import { requestConfirmDialog } from "~/confirmDialog";
|
||||
import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
|
||||
@@ -79,6 +80,7 @@ export function ServerUpdateAction({
|
||||
desktopAppUpdate = false,
|
||||
targetVersion,
|
||||
label = "Update",
|
||||
variant = "outline",
|
||||
}: {
|
||||
readonly environmentId: EnvironmentId;
|
||||
readonly serverLabel: string;
|
||||
@@ -88,6 +90,7 @@ export function ServerUpdateAction({
|
||||
readonly desktopAppUpdate?: boolean;
|
||||
readonly targetVersion: string;
|
||||
readonly label?: string;
|
||||
readonly variant?: ComponentProps<typeof Button>["variant"];
|
||||
}) {
|
||||
const isDesktopAppUpdate = selfUpdate === "desktop-managed";
|
||||
const updateServer = useAtomCommand(serverEnvironment.updateServer, {
|
||||
@@ -170,14 +173,14 @@ export function ServerUpdateAction({
|
||||
if (selfUpdate === null) {
|
||||
const command = manualServerUpdateCommand(targetVersion);
|
||||
return (
|
||||
<Button size="xs" variant="outline" onClick={() => copyToClipboard(command, { command })}>
|
||||
<Button size="xs" variant={variant} onClick={() => copyToClipboard(command, { command })}>
|
||||
Copy update command
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Button size="xs" variant="outline" onClick={() => void handleUpdate()}>
|
||||
<Button size="xs" variant={variant} onClick={() => void handleUpdate()}>
|
||||
{label}
|
||||
</Button>
|
||||
);
|
||||
|
||||
@@ -143,11 +143,13 @@ function Column({ className, ...props }: ComponentProps<"div">) {
|
||||
|
||||
function Root({
|
||||
className,
|
||||
density = "default",
|
||||
placement = "attached",
|
||||
variant = "default",
|
||||
width = "fill",
|
||||
...props
|
||||
}: ComponentProps<"div"> & {
|
||||
density?: "default" | "comfortable";
|
||||
placement?: "attached" | "floating";
|
||||
variant?: ComposerBannerVariant;
|
||||
width?: "fill" | "content";
|
||||
@@ -155,7 +157,8 @@ function Root({
|
||||
return (
|
||||
<Surface
|
||||
className={cn(
|
||||
"min-w-0 p-1 pb-[calc(var(--chat-composer-attachment-overlap)+(--spacing(1)))] text-xs/4 [--composer-banner-icon-column:--spacing(7)] sm:[--composer-banner-icon-column:--spacing(6)]",
|
||||
"min-w-0 px-1 pt-(--composer-banner-padding-block) pb-[calc(var(--chat-composer-attachment-overlap)+var(--composer-banner-padding-block))] text-xs/4 [--composer-banner-icon-column:--spacing(7)] [--composer-banner-padding-block:--spacing(1)] sm:[--composer-banner-icon-column:--spacing(6)]",
|
||||
density === "comfortable" && "[--composer-banner-padding-block:--spacing(1.25)]",
|
||||
width === "content" ? "w-fit max-w-full flex-none" : "@container",
|
||||
className,
|
||||
)}
|
||||
@@ -183,7 +186,7 @@ function Row({
|
||||
"not-has-[>[data-slot=composer-banner-actions]]:grid-cols-[var(--composer-banner-icon-column)_minmax(0,1fr)]",
|
||||
"[&:is(button)]:cursor-pointer [&:is(button)]:rounded-[0.5rem] [&:is(button)]:focus-visible:outline-2 [&:is(button)]:focus-visible:-outline-offset-2 [&:is(button)]:focus-visible:outline-ring",
|
||||
layout === "wrap-actions" &&
|
||||
"@max-[400px]:flex @max-[400px]:flex-wrap @max-[400px]:gap-y-1 @max-[400px]:*:data-[slot=composer-banner-actions]:ms-auto @max-[400px]:*:data-[slot=composer-banner-actions]:max-w-full @max-[400px]:has-[>[data-slot=composer-banner-icon]]:*:data-[slot=composer-banner-actions]:max-w-[calc(100%-var(--composer-banner-icon-column)-(--spacing(1)))] @max-[400px]:*:data-[slot=composer-banner-content]:min-h-(--composer-banner-icon-column) @max-[400px]:*:data-[slot=composer-banner-content]:flex-[1_1_10rem]",
|
||||
"@max-[400px]:*:data-[slot=composer-banner-content]:min-h-(--composer-banner-icon-column)",
|
||||
className,
|
||||
),
|
||||
"data-composer-banner-row": "true",
|
||||
@@ -243,6 +246,7 @@ function Actions({ className, ...props }: ComponentProps<"span">) {
|
||||
data-slot="composer-banner-actions"
|
||||
className={cn(
|
||||
"col-start-3 row-start-1 flex flex-wrap items-center justify-end gap-1",
|
||||
"@max-[400px]:group-data-[composer-banner-layout=wrap-actions]/banner-row:has-[>:nth-child(2)]:col-start-2 @max-[400px]:group-data-[composer-banner-layout=wrap-actions]/banner-row:has-[>:nth-child(2)]:col-end-4 @max-[400px]:group-data-[composer-banner-layout=wrap-actions]/banner-row:has-[>:nth-child(2)]:row-start-2 @max-[400px]:group-data-[composer-banner-layout=wrap-actions]/banner-row:has-[>:nth-child(2)]:-ms-2 @max-[400px]:group-data-[composer-banner-layout=wrap-actions]/banner-row:has-[>:nth-child(2)]:justify-start",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { InfoIcon } from "lucide-react";
|
||||
import { useEffect, useId, useLayoutEffect, useRef, useState, type ReactNode } from "react";
|
||||
|
||||
import { cn } from "~/lib/utils";
|
||||
import { Button } from "../ui/button";
|
||||
import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover";
|
||||
import { ComposerBanner, type ComposerBannerVariant } from "./ComposerBanner";
|
||||
|
||||
// Match the duration-220 exit transition before removing a dismissed notice.
|
||||
@@ -15,14 +18,13 @@ export interface ComposerBannerStackItem {
|
||||
readonly description?: ReactNode;
|
||||
readonly children?: ReactNode;
|
||||
readonly actions?: ReactNode;
|
||||
readonly className?: string;
|
||||
readonly dismissLabel?: string;
|
||||
readonly onDismiss?: () => void;
|
||||
}
|
||||
|
||||
export type ComposerBannerStackContent = Pick<
|
||||
ComposerBannerStackItem,
|
||||
"id" | "variant" | "priority" | "className"
|
||||
"id" | "variant" | "priority"
|
||||
> & { readonly content: ReactNode };
|
||||
|
||||
type ComposerBannerStackEntry = ComposerBannerStackItem | ComposerBannerStackContent;
|
||||
@@ -252,37 +254,63 @@ function ComposerBannerStackAlert({
|
||||
if ("content" in item) {
|
||||
return (
|
||||
<ComposerBanner.Root
|
||||
density="comfortable"
|
||||
placement={attached ? "attached" : "floating"}
|
||||
variant={item.variant}
|
||||
className={item.className}
|
||||
>
|
||||
{item.content}
|
||||
</ComposerBanner.Root>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ComposerBanner.Root
|
||||
role="alert"
|
||||
placement={attached ? "attached" : "floating"}
|
||||
variant={item.variant}
|
||||
className={item.className}
|
||||
density="comfortable"
|
||||
>
|
||||
<ComposerBanner.Row layout="wrap-actions">
|
||||
<ComposerBanner.Icon className={item.description ? "min-h-4 self-start" : undefined}>
|
||||
<ComposerBanner.Icon className="h-(--composer-banner-icon-column) self-start">
|
||||
{item.icon}
|
||||
</ComposerBanner.Icon>
|
||||
<ComposerBanner.Content
|
||||
className={item.description ? "flex-col items-start gap-0" : "font-medium"}
|
||||
>
|
||||
<ComposerBanner.Content className="whitespace-nowrap">
|
||||
<span
|
||||
className={cn(
|
||||
"min-w-0 font-medium leading-7 sm:leading-6",
|
||||
typeof item.title === "string" && "truncate",
|
||||
)}
|
||||
>
|
||||
{item.title}
|
||||
</span>
|
||||
{item.description ? (
|
||||
<>
|
||||
<span className="font-medium">{item.title}</span>
|
||||
<span className="text-muted-foreground">{item.description}</span>
|
||||
<span className="min-w-0 shrink-[9999] truncate text-muted-foreground @max-[400px]:sr-only">
|
||||
{item.description}
|
||||
</span>
|
||||
<Popover>
|
||||
<PopoverTrigger
|
||||
openOnHover
|
||||
render={
|
||||
<Button
|
||||
size="icon-xs"
|
||||
variant="ghost"
|
||||
aria-label="Show notice details"
|
||||
className="hidden flex-none text-muted-foreground hover:text-foreground @max-[400px]:inline-flex"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<InfoIcon className="size-3.5" />
|
||||
</PopoverTrigger>
|
||||
<PopoverPopup
|
||||
tooltipStyle
|
||||
side="top"
|
||||
className="max-w-72 whitespace-normal text-pretty"
|
||||
>
|
||||
{item.description}
|
||||
</PopoverPopup>
|
||||
</Popover>
|
||||
</>
|
||||
) : (
|
||||
item.title
|
||||
)}
|
||||
) : null}
|
||||
</ComposerBanner.Content>
|
||||
{item.actions || item.onDismiss ? (
|
||||
<ComposerBanner.Actions>
|
||||
|
||||
@@ -34,7 +34,12 @@ export const ComposerStashBadge = memo(function ComposerStashBadge(props: {
|
||||
);
|
||||
|
||||
return (
|
||||
<ComposerBanner.Root width="content" data-composer-shoulder-tab className="ml-auto">
|
||||
<ComposerBanner.Root
|
||||
density="comfortable"
|
||||
width="content"
|
||||
data-composer-shoulder-tab
|
||||
className="ml-auto"
|
||||
>
|
||||
<ComposerBanner.Row
|
||||
render={<button type="button" />}
|
||||
data-prompt-stash-badge="true"
|
||||
|
||||
@@ -123,7 +123,9 @@ export const ComposerTasksBadge = memo(function ComposerTasksBadge({
|
||||
return placement === "inline" ? (
|
||||
row
|
||||
) : (
|
||||
<ComposerBanner.Root data-composer-shoulder-tab>{row}</ComposerBanner.Root>
|
||||
<ComposerBanner.Root density="comfortable" data-composer-shoulder-tab>
|
||||
{row}
|
||||
</ComposerBanner.Root>
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -215,14 +215,7 @@ describe("versionSkew", () => {
|
||||
});
|
||||
|
||||
it("matches version-drift guidance to the advertised update path", () => {
|
||||
expect(serverUpdateGuidance("respawn", "Remote server")).toBe(
|
||||
"Update the Remote server so they stay in sync.",
|
||||
);
|
||||
expect(serverUpdateGuidance("desktop-managed", "Desktop server")).toBe(
|
||||
"Update the desktop app that runs the Desktop server.",
|
||||
);
|
||||
expect(serverUpdateGuidance(null, "Local server")).toBe(
|
||||
"Relaunch the Local server with the copied command to sync them.",
|
||||
);
|
||||
expect(serverUpdateGuidance("respawn")).toBe("Update to stay in sync");
|
||||
expect(serverUpdateGuidance("desktop-managed")).toBe("Update the desktop app");
|
||||
});
|
||||
});
|
||||
@@ -111,21 +111,8 @@ export function manualServerUpdateCommand(targetVersion: string): string {
|
||||
return `npx t3@${targetVersion}`;
|
||||
}
|
||||
|
||||
/** One sentence telling the user how to resolve version skew for a server,
|
||||
matched to the update path it offers. */
|
||||
export function serverUpdateGuidance(
|
||||
capability: ServerSelfUpdateCapability | null,
|
||||
serverLabel: string,
|
||||
): string {
|
||||
switch (capability) {
|
||||
case "boot-service":
|
||||
case "respawn":
|
||||
return `Update the ${serverLabel} so they stay in sync.`;
|
||||
case "desktop-managed":
|
||||
return `Update the desktop app that runs the ${serverLabel}.`;
|
||||
default:
|
||||
return `Relaunch the ${serverLabel} with the copied command to sync them.`;
|
||||
}
|
||||
export function serverUpdateGuidance(capability: ServerSelfUpdateCapability): string {
|
||||
return capability === "desktop-managed" ? "Update the desktop app" : "Update to stay in sync";
|
||||
}
|
||||
|
||||
export function buildVersionMismatchDismissalKey(
|
||||
|
||||
Reference in new issue
Block a user