feat(web): attach composer state drawers (#7150)
This commit is contained in:
1 parent
105cd5e0c5
commit
792a1404f6
34 files changed
+2244
-804
No files matched your search
@@ -2,6 +2,7 @@ import {
|
||||
IconAdjustmentsHorizontal,
|
||||
IconAlertCircle,
|
||||
IconAlertTriangle,
|
||||
IconApps,
|
||||
IconArchive,
|
||||
IconArrowBackUp,
|
||||
IconArrowDownCircle,
|
||||
@@ -13,6 +14,7 @@ import {
|
||||
IconArrowsMaximize,
|
||||
IconBellRinging,
|
||||
IconBolt,
|
||||
IconBox,
|
||||
IconCamera,
|
||||
IconChartBar,
|
||||
IconCheck,
|
||||
@@ -104,6 +106,7 @@ const ANDROID_ICON_BY_SF_SYMBOL: Partial<Record<SFSymbol, Icon>> = {
|
||||
checkmark: IconCheck,
|
||||
"checkmark.circle": IconCircleCheck,
|
||||
clock: IconClock,
|
||||
cube: IconBox,
|
||||
"chevron.down": IconChevronDown,
|
||||
"chevron.left": IconChevronLeft,
|
||||
"chevron.left.forwardslash.chevron.right": IconCode,
|
||||
@@ -141,6 +144,7 @@ const ANDROID_ICON_BY_SF_SYMBOL: Partial<Record<SFSymbol, Icon>> = {
|
||||
"sidebar.right": IconLayoutSidebarRight,
|
||||
"slider.horizontal.3": IconAdjustmentsHorizontal,
|
||||
"square.and.pencil": IconEdit,
|
||||
"square.grid.2x2": IconApps,
|
||||
"square.split.2x1": IconLayoutColumns,
|
||||
"sun.max": IconSun,
|
||||
"stop.fill": IconPlayerStopFilled,
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import type { ComposerTriggerKind } from "@t3tools/shared/composerTrigger";
|
||||
import {
|
||||
resolveProviderSkillSourceKind,
|
||||
type ProviderSkillSourceKind,
|
||||
} from "@t3tools/client-runtime/providerSkills";
|
||||
import type { ServerProviderSkill, ServerProviderSlashCommand } from "@t3tools/contracts";
|
||||
import { SymbolView } from "../../components/AppSymbol";
|
||||
import type { ComposerTriggerKind } from "@t3tools/shared/composerTrigger";
|
||||
import { memo } from "react";
|
||||
import { Pressable, ScrollView, View, type ViewStyle } from "react-native";
|
||||
|
||||
import { SymbolView, type AppSymbolName } from "../../components/AppSymbol";
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { GlassSurface } from "../../components/GlassSurface";
|
||||
import { PierreEntryIcon } from "../../components/PierreEntryIcon";
|
||||
@@ -61,13 +65,22 @@ function PopoverSurface(props: { readonly children: React.ReactNode; readonly st
|
||||
);
|
||||
}
|
||||
|
||||
function itemIcon(item: ComposerCommandItem) {
|
||||
const SKILL_SOURCE_SYMBOL_BY_KIND: Record<ProviderSkillSourceKind, AppSymbolName> = {
|
||||
app: "square.grid.2x2",
|
||||
repo: "folder",
|
||||
project: "folder",
|
||||
personal: "person.crop.circle",
|
||||
system: "gearshape",
|
||||
other: "cube",
|
||||
};
|
||||
|
||||
function itemIcon(item: ComposerCommandItem): AppSymbolName | null {
|
||||
switch (item.type) {
|
||||
case "slash-command":
|
||||
case "provider-slash-command":
|
||||
return "terminal" as const;
|
||||
return "terminal";
|
||||
case "skill":
|
||||
return "cube" as const;
|
||||
return SKILL_SOURCE_SYMBOL_BY_KIND[resolveProviderSkillSourceKind(item.skill)];
|
||||
case "path":
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -4183,6 +4183,14 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
// partition (same shell, same capability gate, same PR auto-settle input)
|
||||
// so the banner and the sidebar row never disagree.
|
||||
const activeThreadShell = useThreadShell(isServerThread ? activeThreadRef : null);
|
||||
const activeComposerTasksProgress =
|
||||
activeLatestTurn !== null && !latestTurnSettled
|
||||
? (activeThreadShell?.planProgress ?? null)
|
||||
: null;
|
||||
const activeComposerTaskSteps =
|
||||
activeComposerTasksProgress && activePlan && activePlan.turnId === activeLatestTurn?.turnId
|
||||
? activePlan.steps
|
||||
: null;
|
||||
const autoSettleAfterDays = useClientSettings((settings) => settings.sidebarAutoSettleAfterDays);
|
||||
const autoSettleOnMerge = useClientSettings((settings) => settings.sidebarAutoSettleOnMerge);
|
||||
const activeThreadPr = resolveDisplayedThreadPr({
|
||||
@@ -4519,13 +4527,13 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
),
|
||||
title: working
|
||||
? liveCount > 0
|
||||
? `${liveCount} ${liveCount === 1 ? "agent" : "agents"} working in the background`
|
||||
: "Background work running"
|
||||
: "Monitoring in the background",
|
||||
? `${liveCount} ${liveCount === 1 ? "agent" : "agents"} working`
|
||||
: "Background work"
|
||||
: "Monitoring",
|
||||
actions: (
|
||||
<Button
|
||||
size="xs"
|
||||
variant="outline"
|
||||
variant="ghost"
|
||||
disabled={isStoppingBackgroundWork}
|
||||
onClick={() => void handleStopBackgroundWork()}
|
||||
>
|
||||
@@ -4687,7 +4695,6 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
systemComposerBannerItems,
|
||||
wokeThreadBannerItem,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
setPendingServerThreadEnvMode(null);
|
||||
setPendingServerThreadBranch(undefined);
|
||||
@@ -6282,6 +6289,8 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
setDragActive: setIsWorkspaceFileDragActive,
|
||||
addFiles: (files) => composerRef.current?.addDroppedFiles(files),
|
||||
});
|
||||
const externalComposerDrawerAttached =
|
||||
composerBannerItems.length > 0 || Boolean(threadSyncPhase && !activeEnvironmentUnavailable);
|
||||
|
||||
return (
|
||||
<div className="relative flex min-h-0 min-w-0 flex-1 overflow-hidden bg-background">
|
||||
@@ -6485,6 +6494,7 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
<div
|
||||
className={cn(
|
||||
"chat-composer-glass-shell relative mx-auto w-full max-w-3xl",
|
||||
externalComposerDrawerAttached && "chat-composer-glass-shell-attached",
|
||||
showComposerContextStrip && "chat-composer-glass-shell-with-context",
|
||||
)}
|
||||
>
|
||||
@@ -6509,6 +6519,7 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
isSendBusy={isSendBusy}
|
||||
sendDisabledReason={threadDetailLoading ? "Messages loading" : null}
|
||||
isPreparingWorktree={isPreparingWorktree}
|
||||
externalDrawerAttached={externalComposerDrawerAttached}
|
||||
environmentUnavailable={activeEnvironmentUnavailableState}
|
||||
activePendingApproval={activePendingApproval}
|
||||
pendingApprovals={pendingApprovals}
|
||||
@@ -6521,6 +6532,8 @@ function ChatViewContent(props: ChatViewProps) {
|
||||
respondingRequestIds={respondingRequestIds}
|
||||
showPlanFollowUpPrompt={showPlanFollowUpPrompt}
|
||||
activeProposedPlan={activeProposedPlan}
|
||||
activeTasksProgress={activeComposerTasksProgress}
|
||||
activeTaskSteps={activeComposerTaskSteps}
|
||||
runtimeMode={runtimeMode}
|
||||
interactionMode={interactionMode}
|
||||
lockedProvider={lockedProvider}
|
||||
|
||||
@@ -73,13 +73,13 @@ import { basenameOfPath } from "~/pierre-icons";
|
||||
import {
|
||||
COMPOSER_INLINE_CHIP_DECORATOR_CLASS_NAME,
|
||||
COMPOSER_INLINE_CHIP_ICON_CLASS_NAME,
|
||||
COMPOSER_INLINE_CHIP_LABEL_CLASS_NAME,
|
||||
COMPOSER_INLINE_SKILL_CHIP_CLASS_NAME,
|
||||
COMPOSER_INLINE_SKILL_CHIP_LABEL_CLASS_NAME,
|
||||
SKILL_CHIP_ICON_SVG,
|
||||
} from "./composerInlineChip";
|
||||
import { FILE_TAG_CHIP_CLASS_NAME, FileTagChipContent } from "./chat/FileTagChip";
|
||||
import { ComposerPendingTerminalContextChip } from "./chat/ComposerPendingTerminalContexts";
|
||||
import { formatProviderSkillDisplayName } from "~/providerSkillPresentation";
|
||||
import { formatProviderSkillDisplayName } from "@t3tools/client-runtime/providerSkills";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
|
||||
import { registerComposerInlineTokenPaste } from "./composerInlineTokenPaste";
|
||||
|
||||
@@ -257,7 +257,7 @@ function ComposerSkillDecorator(props: { skillLabel: string; skillDescription: s
|
||||
className={COMPOSER_INLINE_CHIP_ICON_CLASS_NAME}
|
||||
dangerouslySetInnerHTML={{ __html: SKILL_CHIP_ICON_SVG }}
|
||||
/>
|
||||
<span className={COMPOSER_INLINE_SKILL_CHIP_LABEL_CLASS_NAME}>{props.skillLabel}</span>
|
||||
<span className={COMPOSER_INLINE_CHIP_LABEL_CLASS_NAME}>{props.skillLabel}</span>
|
||||
</span>
|
||||
);
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -36,7 +36,9 @@ describe("ComposerBannerStack", () => {
|
||||
const neutralBehind = renderToStaticMarkup(
|
||||
<ComposerBannerStack items={[banner("front", "default"), banner("stacked", "default")]} />,
|
||||
);
|
||||
expect(neutralBehind).toContain("border-border");
|
||||
expect(neutralBehind).toContain("chat-composer-banner-stack-cap");
|
||||
expect(neutralBehind).toContain("border-[var(--chat-composer-attached-outline)]");
|
||||
expect(neutralBehind).not.toContain("border-border");
|
||||
expect(neutralBehind).not.toContain("border-warning/24");
|
||||
|
||||
const warningBehind = renderToStaticMarkup(
|
||||
@@ -49,12 +51,14 @@ describe("ComposerBannerStack", () => {
|
||||
const markup = renderToStaticMarkup(<ComposerBannerStack items={[banner("front")]} />);
|
||||
|
||||
expect(markup).not.toContain("data-composer-banner-stack-expanded-items");
|
||||
expect(markup).toContain("alert-glass");
|
||||
expect(markup).toContain("chat-composer-drawer-surface");
|
||||
expect(markup).toContain("chat-composer-drawer-attached");
|
||||
expect(markup).toContain("text-xs");
|
||||
expect(markup).toContain('data-composer-banner-drawer="true"');
|
||||
expect(markup).toContain('data-variant="warning"');
|
||||
expect(markup).toContain("transform:none");
|
||||
expect(markup).not.toContain("will-change:transform");
|
||||
});
|
||||
|
||||
it("applies item-specific surface and action layout classes", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerBannerStack
|
||||
|
||||
@@ -26,7 +26,7 @@ const exitTransitionStyle = {
|
||||
// banners are stacked behind it, so its border must match the severity of the
|
||||
// first hidden banner — a neutral banner must not masquerade as a warning.
|
||||
const stackCapBorderClass: Record<ComposerBannerStackItem["variant"], string> = {
|
||||
default: "border-border",
|
||||
default: "border-[var(--chat-composer-attached-outline)]",
|
||||
error: "border-destructive/24",
|
||||
info: "border-info/24",
|
||||
success: "border-success/24",
|
||||
@@ -98,7 +98,10 @@ export function ComposerBannerStack({ className, items }: ComposerBannerStackPro
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={cn("group/banner-stack mx-auto mb-2 max-w-3xl", className)}>
|
||||
<div
|
||||
className={cn("group/banner-stack chat-composer-drawer-slot", className)}
|
||||
data-composer-banner-drawer="true"
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"relative flex flex-col-reverse",
|
||||
@@ -108,8 +111,8 @@ export function ComposerBannerStack({ className, items }: ComposerBannerStackPro
|
||||
{showCollapsedStackCap && firstStackedItem ? (
|
||||
<div
|
||||
className={cn(
|
||||
"pointer-events-none absolute inset-x-0 -top-3 z-0 mx-auto h-3 rounded-t-[22px]",
|
||||
"border border-b-0 bg-background/96 shadow-[0_6px_18px_rgba(0,0,0,0.06)]",
|
||||
"pointer-events-none absolute inset-x-0 -top-3 z-0 mx-auto h-3 rounded-t-2xl",
|
||||
"chat-composer-banner-stack-cap border border-b-0 shadow-[0_6px_18px_rgba(0,0,0,0.06)]",
|
||||
stackCapBorderClass[firstStackedItem.variant],
|
||||
"transition-opacity duration-150 ease-out",
|
||||
"group-hover/banner-stack:opacity-0 group-focus-within/banner-stack:opacity-0",
|
||||
@@ -130,6 +133,7 @@ export function ComposerBannerStack({ className, items }: ComposerBannerStackPro
|
||||
>
|
||||
<ComposerBannerStackAlert
|
||||
item={frontItem}
|
||||
attached
|
||||
exiting={exitingItemId === frontItem.id}
|
||||
onDismissRequest={() => requestDismiss(frontItem)}
|
||||
/>
|
||||
@@ -162,6 +166,7 @@ export function ComposerBannerStack({ className, items }: ComposerBannerStackPro
|
||||
>
|
||||
<ComposerBannerStackAlert
|
||||
item={item}
|
||||
attached={false}
|
||||
exiting={exitingItemId === item.id}
|
||||
onDismissRequest={() => requestDismiss(item)}
|
||||
/>
|
||||
@@ -178,10 +183,12 @@ export function ComposerBannerStack({ className, items }: ComposerBannerStackPro
|
||||
|
||||
function ComposerBannerStackAlert({
|
||||
item,
|
||||
attached,
|
||||
exiting,
|
||||
onDismissRequest,
|
||||
}: {
|
||||
readonly item: ComposerBannerStackItem;
|
||||
readonly attached: boolean;
|
||||
readonly exiting: boolean;
|
||||
readonly onDismissRequest: () => void;
|
||||
}) {
|
||||
@@ -190,7 +197,12 @@ function ComposerBannerStackAlert({
|
||||
return (
|
||||
<Alert
|
||||
variant={item.variant}
|
||||
className={cn("alert-glass rounded-[22px]", item.className)}
|
||||
className={cn(
|
||||
attached
|
||||
? "chat-composer-drawer-surface chat-composer-drawer-attached px-3 pt-2 pb-[calc(var(--chat-composer-attachment-overlap)_+_0.375rem)] text-xs sm:px-4"
|
||||
: "alert-glass rounded-[22px]",
|
||||
item.className,
|
||||
)}
|
||||
data-variant={item.variant}
|
||||
>
|
||||
{item.icon}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { ProviderDriverKind } from "@t3tools/contracts";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { ComposerCommandMenu } from "./ComposerCommandMenu";
|
||||
|
||||
describe("ComposerCommandMenu", () => {
|
||||
it("renders slash-command results as an attached composer drawer", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerCommandMenu
|
||||
items={[]}
|
||||
resolvedTheme="dark"
|
||||
isLoading={false}
|
||||
triggerKind="slash-command"
|
||||
activeItemId={null}
|
||||
onHighlightedItemChange={() => {}}
|
||||
onSelect={() => {}}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain('data-composer-command-drawer="true"');
|
||||
expect(markup).toContain("chat-composer-drawer-surface");
|
||||
expect(markup).toContain("chat-composer-drawer-attached");
|
||||
expect(markup).not.toContain("dropdown-glass");
|
||||
});
|
||||
|
||||
it("renders commands without a category heading or invented icons", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerCommandMenu
|
||||
items={[
|
||||
{
|
||||
id: "slash:model",
|
||||
type: "slash-command",
|
||||
command: "model",
|
||||
label: "/model",
|
||||
description: "Switch response model for this thread",
|
||||
},
|
||||
]}
|
||||
resolvedTheme="dark"
|
||||
isLoading={false}
|
||||
triggerKind="slash-command"
|
||||
activeItemId="slash:model"
|
||||
onHighlightedItemChange={() => {}}
|
||||
onSelect={() => {}}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain("/model");
|
||||
expect(markup).toContain("Switch response model for this thread");
|
||||
expect(markup).not.toContain("Built-in");
|
||||
expect(markup).not.toContain("<svg");
|
||||
expect(markup).toContain("font-sans text-xs font-medium");
|
||||
expect(markup).not.toContain("font-mono");
|
||||
expect(markup).toContain("text-right");
|
||||
});
|
||||
|
||||
it("renders a skill source icon with an accessible source label", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerCommandMenu
|
||||
items={[
|
||||
{
|
||||
id: "skill:codex:browser",
|
||||
type: "skill",
|
||||
provider: ProviderDriverKind.make("codex"),
|
||||
skill: {
|
||||
name: "browser",
|
||||
path: "/Users/maria/.codex/plugins/browser/skills/browser/SKILL.md",
|
||||
scope: "user",
|
||||
enabled: true,
|
||||
},
|
||||
label: "Browser",
|
||||
description: "Open and control the in-app browser",
|
||||
},
|
||||
]}
|
||||
resolvedTheme="dark"
|
||||
isLoading={false}
|
||||
triggerKind="skill"
|
||||
activeItemId="skill:codex:browser"
|
||||
onHighlightedItemChange={() => {}}
|
||||
onSelect={() => {}}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain("Browser");
|
||||
expect(markup).toContain('<span class="sr-only">App skill</span>');
|
||||
expect(markup).toContain("<svg");
|
||||
expect(markup).toContain("text-icon-muted");
|
||||
});
|
||||
});
|
||||
@@ -1,23 +1,27 @@
|
||||
import {
|
||||
resolveProviderSkillSourceKind,
|
||||
type ProviderSkillSourceKind,
|
||||
} from "@t3tools/client-runtime/providerSkills";
|
||||
import {
|
||||
type ProjectEntry,
|
||||
type ProviderDriverKind,
|
||||
type ServerProviderSkill,
|
||||
type ServerProviderSlashCommand,
|
||||
} from "@t3tools/contracts";
|
||||
import { BotIcon } from "lucide-react";
|
||||
import { memo, useLayoutEffect, useMemo, useRef } from "react";
|
||||
import {
|
||||
BlocksIcon,
|
||||
FolderGit2Icon,
|
||||
FolderIcon,
|
||||
PackageIcon,
|
||||
SettingsIcon,
|
||||
UserRoundIcon,
|
||||
type LucideIcon,
|
||||
} from "lucide-react";
|
||||
import { memo, useLayoutEffect, useRef } from "react";
|
||||
|
||||
import { type ComposerSlashCommand, type ComposerTriggerKind } from "../../composer-logic";
|
||||
import { formatProviderSkillInstallSource } from "~/providerSkillPresentation";
|
||||
import { cn } from "~/lib/utils";
|
||||
import {
|
||||
Command,
|
||||
CommandGroup,
|
||||
CommandGroupLabel,
|
||||
CommandItem,
|
||||
CommandList,
|
||||
CommandSeparator,
|
||||
} from "../ui/command";
|
||||
import { Command, CommandGroup, CommandItem, CommandList } from "../ui/command";
|
||||
import { PierreEntryIcon } from "./PierreEntryIcon";
|
||||
|
||||
export type ComposerCommandItem =
|
||||
@@ -53,73 +57,17 @@ export type ComposerCommandItem =
|
||||
description: string;
|
||||
};
|
||||
|
||||
type ComposerCommandGroup = {
|
||||
id: string;
|
||||
label: string | null;
|
||||
items: ComposerCommandItem[];
|
||||
};
|
||||
|
||||
function SkillGlyph(props: { className?: string }) {
|
||||
return (
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.85"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
className={props.className}
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z" />
|
||||
<path d="m3.3 7 8.7 5 8.7-5" />
|
||||
<path d="M12 22V12" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
function groupCommandItems(
|
||||
items: ComposerCommandItem[],
|
||||
triggerKind: ComposerTriggerKind | null,
|
||||
groupSlashCommandSections: boolean,
|
||||
): ComposerCommandGroup[] {
|
||||
if (triggerKind === "skill") {
|
||||
return items.length > 0 ? [{ id: "skills", label: "Skills", items }] : [];
|
||||
}
|
||||
if (triggerKind !== "slash-command" || !groupSlashCommandSections) {
|
||||
return [{ id: "default", label: null, items }];
|
||||
}
|
||||
|
||||
const builtInItems = items.filter((item) => item.type === "slash-command");
|
||||
const providerItems = items.filter((item) => item.type === "provider-slash-command");
|
||||
|
||||
const groups: ComposerCommandGroup[] = [];
|
||||
if (builtInItems.length > 0) {
|
||||
groups.push({ id: "built-in", label: "Built-in", items: builtInItems });
|
||||
}
|
||||
if (providerItems.length > 0) {
|
||||
groups.push({ id: "provider", label: "Provider", items: providerItems });
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
export const ComposerCommandMenu = memo(function ComposerCommandMenu(props: {
|
||||
items: ComposerCommandItem[];
|
||||
resolvedTheme: "light" | "dark";
|
||||
isLoading: boolean;
|
||||
triggerKind: ComposerTriggerKind | null;
|
||||
groupSlashCommandSections?: boolean;
|
||||
emptyStateText?: string;
|
||||
activeItemId: string | null;
|
||||
onHighlightedItemChange: (itemId: string | null) => void;
|
||||
onSelect: (item: ComposerCommandItem) => void;
|
||||
}) {
|
||||
const listRef = useRef<HTMLDivElement>(null);
|
||||
const groups = useMemo(
|
||||
() =>
|
||||
groupCommandItems(props.items, props.triggerKind, props.groupSlashCommandSections ?? true),
|
||||
[props.groupSlashCommandSections, props.items, props.triggerKind],
|
||||
);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (!props.activeItemId || !listRef.current) return;
|
||||
@@ -141,57 +89,38 @@ export const ComposerCommandMenu = memo(function ComposerCommandMenu(props: {
|
||||
>
|
||||
<div
|
||||
ref={listRef}
|
||||
className="dropdown-glass relative w-full overflow-hidden rounded-[20px] shadow-[0_16px_40px_-18px_rgb(0_0_0/55%)] **:data-[slot=scroll-area-scrollbar]:data-[orientation=vertical]:my-4 dark:shadow-[0_18px_44px_-18px_rgb(0_0_0/80%)]"
|
||||
className="chat-composer-drawer-surface chat-composer-drawer-attached relative w-full overflow-hidden **:data-[slot=scroll-area-scrollbar]:data-[orientation=vertical]:my-4"
|
||||
data-composer-command-drawer="true"
|
||||
>
|
||||
{props.items.length > 0 ? (
|
||||
<CommandList className="max-h-72 not-empty:py-3">
|
||||
{groups.map((group, groupIndex) => (
|
||||
<div key={group.id}>
|
||||
{groupIndex > 0 ? <CommandSeparator className="my-0.5" /> : null}
|
||||
<CommandGroup>
|
||||
{group.label ? (
|
||||
<CommandGroupLabel className="px-3 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-[0.08em] text-secondary-label">
|
||||
{group.label}
|
||||
</CommandGroupLabel>
|
||||
) : null}
|
||||
{group.items.map((item) => (
|
||||
<ComposerCommandMenuItem
|
||||
key={item.id}
|
||||
item={item}
|
||||
resolvedTheme={props.resolvedTheme}
|
||||
isActive={props.activeItemId === item.id}
|
||||
onHighlight={props.onHighlightedItemChange}
|
||||
onSelect={props.onSelect}
|
||||
/>
|
||||
))}
|
||||
</CommandGroup>
|
||||
</div>
|
||||
))}
|
||||
<CommandList className="max-h-72 scroll-pb-6">
|
||||
<CommandGroup>
|
||||
{props.items.map((item) => (
|
||||
<ComposerCommandMenuItem
|
||||
key={item.id}
|
||||
item={item}
|
||||
resolvedTheme={props.resolvedTheme}
|
||||
isActive={props.activeItemId === item.id}
|
||||
onHighlight={props.onHighlightedItemChange}
|
||||
onSelect={props.onSelect}
|
||||
/>
|
||||
))}
|
||||
</CommandGroup>
|
||||
</CommandList>
|
||||
) : (
|
||||
<div className="px-5 py-3.5">
|
||||
{props.triggerKind === "skill" ? (
|
||||
<CommandGroup>
|
||||
<CommandGroupLabel className="px-0 pt-0 pb-1 text-[10px] font-semibold uppercase tracking-[0.08em] text-secondary-label">
|
||||
Skills
|
||||
</CommandGroupLabel>
|
||||
<p className="text-secondary-label text-xs">
|
||||
{props.isLoading
|
||||
? "Searching workspace skills..."
|
||||
: (props.emptyStateText ??
|
||||
"No skills found. Try / to browse provider commands.")}
|
||||
</p>
|
||||
</CommandGroup>
|
||||
) : (
|
||||
<p className="text-secondary-label text-xs">
|
||||
{props.isLoading
|
||||
? "Searching workspace files..."
|
||||
: (props.emptyStateText ??
|
||||
(props.triggerKind === "path"
|
||||
<div className="px-5 pt-3.5 pb-7">
|
||||
<p className="text-secondary-label text-xs">
|
||||
{props.isLoading
|
||||
? props.triggerKind === "skill"
|
||||
? "Searching workspace skills..."
|
||||
: "Searching workspace files..."
|
||||
: (props.emptyStateText ??
|
||||
(props.triggerKind === "skill"
|
||||
? "No skills found. Try / to browse provider commands."
|
||||
: props.triggerKind === "path"
|
||||
? "No matching files or folders."
|
||||
: "No matching command."))}
|
||||
</p>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -206,15 +135,15 @@ const ComposerCommandMenuItem = memo(function ComposerCommandMenuItem(props: {
|
||||
onHighlight: (itemId: string | null) => void;
|
||||
onSelect: (item: ComposerCommandItem) => void;
|
||||
}) {
|
||||
const skillSourceLabel =
|
||||
props.item.type === "skill" ? formatProviderSkillInstallSource(props.item.skill) : null;
|
||||
const skillSourceKind =
|
||||
props.item.type === "skill" ? resolveProviderSkillSourceKind(props.item.skill) : null;
|
||||
|
||||
return (
|
||||
<CommandItem
|
||||
value={props.item.id}
|
||||
data-composer-item-id={props.item.id}
|
||||
className={cn(
|
||||
"cursor-pointer select-none gap-2 hover:bg-transparent hover:text-inherit data-highlighted:bg-transparent data-highlighted:text-inherit",
|
||||
"cursor-pointer select-none gap-3 rounded-lg px-3 py-2! hover:bg-transparent hover:text-inherit data-highlighted:bg-transparent data-highlighted:text-inherit",
|
||||
props.isActive && "bg-accent! text-accent-foreground!",
|
||||
)}
|
||||
onMouseMove={() => {
|
||||
@@ -233,29 +162,43 @@ const ComposerCommandMenuItem = memo(function ComposerCommandMenuItem(props: {
|
||||
kind={props.item.pathKind}
|
||||
theme={props.resolvedTheme}
|
||||
/>
|
||||
) : skillSourceKind ? (
|
||||
<SkillSourceIcon kind={skillSourceKind} />
|
||||
) : null}
|
||||
{props.item.type === "slash-command" ? (
|
||||
<BotIcon className="size-4 shrink-0 text-icon-muted" />
|
||||
) : null}
|
||||
{props.item.type === "provider-slash-command" ? (
|
||||
<span className="inline-flex size-4 shrink-0 items-center justify-center text-icon-muted">
|
||||
<SkillGlyph className="size-3.5" />
|
||||
</span>
|
||||
) : null}
|
||||
{props.item.type === "skill" ? (
|
||||
<span className="inline-flex size-4 shrink-0 items-center justify-center text-icon-muted">
|
||||
<SkillGlyph className="size-3.5" />
|
||||
</span>
|
||||
) : null}
|
||||
<span className="flex min-w-0 flex-1 items-center gap-2">
|
||||
<span className="shrink-0">{props.item.label}</span>
|
||||
<span className="min-w-0 flex-1 truncate text-secondary-label text-xs">
|
||||
<span className="flex min-w-0 flex-1 items-baseline gap-3">
|
||||
<span className="shrink-0 font-sans text-xs font-medium">{props.item.label}</span>
|
||||
<span className="min-w-0 flex-1 truncate text-right text-secondary-label text-xs">
|
||||
{props.item.description}
|
||||
</span>
|
||||
</span>
|
||||
{skillSourceLabel ? (
|
||||
<span className="shrink-0 pl-2 text-secondary-label text-xs">{skillSourceLabel}</span>
|
||||
) : null}
|
||||
</CommandItem>
|
||||
);
|
||||
});
|
||||
|
||||
const SKILL_SOURCE_ICON_BY_KIND: Record<ProviderSkillSourceKind, LucideIcon> = {
|
||||
app: BlocksIcon,
|
||||
repo: FolderGit2Icon,
|
||||
project: FolderIcon,
|
||||
personal: UserRoundIcon,
|
||||
system: SettingsIcon,
|
||||
other: PackageIcon,
|
||||
};
|
||||
|
||||
const SKILL_SOURCE_LABEL_BY_KIND: Record<ProviderSkillSourceKind, string> = {
|
||||
app: "App",
|
||||
repo: "Repo",
|
||||
project: "Project",
|
||||
personal: "Personal",
|
||||
system: "System",
|
||||
other: "Other",
|
||||
};
|
||||
|
||||
function SkillSourceIcon(props: { kind: ProviderSkillSourceKind }) {
|
||||
const Icon = SKILL_SOURCE_ICON_BY_KIND[props.kind];
|
||||
return (
|
||||
<>
|
||||
<Icon aria-hidden="true" className="size-4 shrink-0 text-icon-muted" />
|
||||
<span className="sr-only">{SKILL_SOURCE_LABEL_BY_KIND[props.kind]} skill</span>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { ApprovalRequestId } from "@t3tools/contracts";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { ComposerPendingApprovalActions } from "./ComposerPendingApprovalActions";
|
||||
|
||||
describe("ComposerPendingApprovalActions", () => {
|
||||
it("states that the persistent approval lasts for this session", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerPendingApprovalActions
|
||||
requestId={ApprovalRequestId.make("approval-1")}
|
||||
isResponding={false}
|
||||
onRespondToApproval={async () => undefined}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain(">Cancel<");
|
||||
expect(markup).toContain("Always allow this session");
|
||||
expect(markup).not.toContain(">Always allow<");
|
||||
expect(markup).toContain("h-5");
|
||||
expect(markup).toContain("sm:text-[11px]");
|
||||
expect(markup).not.toContain("sm:h-6");
|
||||
});
|
||||
});
|
||||
@@ -11,6 +11,8 @@ interface ComposerPendingApprovalActionsProps {
|
||||
) => Promise<unknown>;
|
||||
}
|
||||
|
||||
const APPROVAL_ACTION_CLASS_NAME = "font-normal";
|
||||
|
||||
export const ComposerPendingApprovalActions = memo(function ComposerPendingApprovalActions({
|
||||
requestId,
|
||||
isResponding,
|
||||
@@ -19,36 +21,40 @@ export const ComposerPendingApprovalActions = memo(function ComposerPendingAppro
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
size="micro"
|
||||
variant="ghost-muted"
|
||||
className={APPROVAL_ACTION_CLASS_NAME}
|
||||
disabled={isResponding}
|
||||
onClick={() => void onRespondToApproval(requestId, "cancel")}
|
||||
>
|
||||
Cancel turn
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="destructive-outline"
|
||||
size="micro"
|
||||
variant="ghost-muted"
|
||||
className={`${APPROVAL_ACTION_CLASS_NAME} text-destructive-foreground [:hover,[data-pressed]]:text-destructive-foreground`}
|
||||
disabled={isResponding}
|
||||
onClick={() => void onRespondToApproval(requestId, "decline")}
|
||||
>
|
||||
Decline
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
size="micro"
|
||||
variant="ghost-muted"
|
||||
className={APPROVAL_ACTION_CLASS_NAME}
|
||||
disabled={isResponding}
|
||||
onClick={() => void onRespondToApproval(requestId, "acceptForSession")}
|
||||
>
|
||||
Always allow this session
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="default"
|
||||
size="micro"
|
||||
variant="ghost-muted"
|
||||
className={`${APPROVAL_ACTION_CLASS_NAME} text-foreground`}
|
||||
disabled={isResponding}
|
||||
onClick={() => void onRespondToApproval(requestId, "accept")}
|
||||
>
|
||||
Approve once
|
||||
Approve
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -5,7 +5,7 @@ import { describe, expect, it } from "vite-plus/test";
|
||||
import { ComposerPendingApprovalPanel } from "./ComposerPendingApprovalPanel";
|
||||
|
||||
describe("ComposerPendingApprovalPanel", () => {
|
||||
it("renders complete multiline command details without hover or truncation", () => {
|
||||
it("keeps the complete command readable in the compact row", () => {
|
||||
const detail = `bun run release -- ${"x".repeat(500)}\nsecond line`;
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerPendingApprovalPanel
|
||||
@@ -21,11 +21,33 @@ describe("ComposerPendingApprovalPanel", () => {
|
||||
|
||||
expect(markup).toContain('data-approval-detail="complete"');
|
||||
expect(markup).toContain('aria-label="Command"');
|
||||
expect(markup).toContain('role="group"');
|
||||
expect(markup).toContain('tabindex="0"');
|
||||
expect(markup).toContain(detail);
|
||||
expect(markup).toContain("max-h-20");
|
||||
expect(markup).toContain("overflow-auto");
|
||||
expect(markup).toContain("whitespace-pre");
|
||||
expect(markup).toContain("[scrollbar-width:thin]");
|
||||
expect(markup).toContain("[&::-webkit-scrollbar]:h-1.5");
|
||||
expect(markup).not.toContain("truncate");
|
||||
expect(markup).not.toContain("line-clamp");
|
||||
expect(markup).toContain("min-w-0");
|
||||
expect(markup).toContain("max-w-full");
|
||||
expect(markup).toContain("[overflow-wrap:anywhere]");
|
||||
expect(markup).not.toContain("Command approval requested");
|
||||
});
|
||||
|
||||
it("falls back to the approval kind when the provider sends an empty detail", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerPendingApprovalPanel
|
||||
approval={{
|
||||
requestId: ApprovalRequestId.make("approval-2"),
|
||||
requestKind: "file-read",
|
||||
createdAt: "2026-07-18T00:00:00.000Z",
|
||||
detail: "",
|
||||
}}
|
||||
pendingCount={1}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain("File read approval");
|
||||
});
|
||||
});
|
||||
@@ -1,22 +1,25 @@
|
||||
import { memo } from "react";
|
||||
import { type PendingApproval } from "../../session-logic";
|
||||
import { cn } from "~/lib/utils";
|
||||
|
||||
interface ComposerPendingApprovalPanelProps {
|
||||
approval: PendingApproval;
|
||||
pendingCount: number;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export const ComposerPendingApprovalPanel = memo(function ComposerPendingApprovalPanel({
|
||||
approval,
|
||||
pendingCount,
|
||||
className,
|
||||
}: ComposerPendingApprovalPanelProps) {
|
||||
const approvalSummary =
|
||||
const fallbackLabel =
|
||||
approval.requestKind === "command"
|
||||
? "Command approval requested"
|
||||
? "Command approval"
|
||||
: approval.requestKind === "file-read"
|
||||
? "File-read approval requested"
|
||||
: "File-change approval requested";
|
||||
const detailLabel =
|
||||
? "File read approval"
|
||||
: "File change approval";
|
||||
const detailAriaLabel =
|
||||
approval.requestKind === "command"
|
||||
? "Command"
|
||||
: approval.requestKind === "file-read"
|
||||
@@ -24,25 +27,23 @@ export const ComposerPendingApprovalPanel = memo(function ComposerPendingApprova
|
||||
: "File change";
|
||||
|
||||
return (
|
||||
<div className="min-w-0 px-4 py-3.5 sm:px-5 sm:py-4">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="uppercase text-sm tracking-[0.2em]">PENDING APPROVAL</span>
|
||||
<span className="text-sm font-medium">{approvalSummary}</span>
|
||||
{pendingCount > 1 ? (
|
||||
<span className="text-xs text-muted-foreground">1/{pendingCount}</span>
|
||||
) : null}
|
||||
</div>
|
||||
{approval.detail ? (
|
||||
<div className="mt-3 min-w-0 max-w-full rounded-lg border border-border/65 bg-background/70 p-3">
|
||||
<p className="text-xs font-medium text-muted-foreground">{detailLabel}</p>
|
||||
<pre
|
||||
aria-label={detailLabel}
|
||||
className="mt-2 min-w-0 max-w-full max-h-40 overflow-auto whitespace-pre-wrap [overflow-wrap:anywhere] font-mono text-xs leading-relaxed text-foreground"
|
||||
data-approval-detail="complete"
|
||||
>
|
||||
{approval.detail}
|
||||
</pre>
|
||||
</div>
|
||||
<div
|
||||
aria-label={fallbackLabel}
|
||||
className={cn("flex min-w-0 flex-1 items-center gap-2", className)}
|
||||
role="group"
|
||||
>
|
||||
<code
|
||||
aria-label={detailAriaLabel}
|
||||
className="block max-h-20 min-w-0 flex-1 overflow-auto whitespace-pre font-mono text-[11px] text-foreground/85 [scrollbar-width:thin] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70 [&::-webkit-scrollbar]:h-1.5"
|
||||
data-approval-detail="complete"
|
||||
tabIndex={0}
|
||||
>
|
||||
{approval.detail || fallbackLabel}
|
||||
</code>
|
||||
{pendingCount > 1 ? (
|
||||
<span className="shrink-0 text-[10px] font-medium text-muted-foreground tabular-nums">
|
||||
1/{pendingCount}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -167,7 +167,7 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
|
||||
|
||||
return (
|
||||
<Collapsible
|
||||
className="py-3"
|
||||
className="py-2"
|
||||
open={!isCollapsed}
|
||||
onOpenChange={(open) => {
|
||||
setCollapsedQuestionId(open ? null : activeQuestion.id);
|
||||
@@ -179,19 +179,19 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
|
||||
header label and the chevron still line up with the left and right
|
||||
edges of the question text below. The negative block margin keeps the
|
||||
taller hit area from pushing the panel down. */}
|
||||
<div className="px-1.5 sm:px-2.5">
|
||||
<div className="flex items-center gap-1 px-1 sm:px-2">
|
||||
<CollapsibleTrigger
|
||||
title={
|
||||
isCollapsed ? "Show the question and its options" : "Hide the question and its options"
|
||||
}
|
||||
data-pending-user-input-toggle={isCollapsed ? "collapsed" : "expanded"}
|
||||
className="group -my-1 flex w-full items-center gap-3 rounded-md px-2.5 py-1.5 text-left outline-none transition-colors duration-150 hover:bg-muted/40 focus-visible:ring-1 focus-visible:ring-primary/25"
|
||||
className="group -my-1 flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-left outline-none transition-colors duration-150 hover:bg-muted/35 focus-visible:ring-1 focus-visible:ring-primary/25"
|
||||
>
|
||||
<span className="text-secondary-label text-[11px] font-semibold tracking-widest uppercase group-hover:text-foreground">
|
||||
<span className="text-xs font-medium text-muted-foreground group-hover:text-foreground/85">
|
||||
{activeQuestion.header}
|
||||
</span>
|
||||
{prompt.questions.length > 1 ? (
|
||||
<span className="flex h-5 items-center rounded-md bg-muted/60 px-1.5 text-secondary-label text-[10px] font-medium tabular-nums">
|
||||
<span className="text-[10px] font-medium text-muted-foreground tabular-nums">
|
||||
{questionIndex + 1}/{prompt.questions.length}
|
||||
</span>
|
||||
) : null}
|
||||
@@ -217,13 +217,13 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
|
||||
{/* The panel carries the horizontal padding itself: it clips its content
|
||||
while the height animates, so the option buttons have to sit inside
|
||||
that padding or their focus rings get shaved off at the edges. */}
|
||||
<CollapsiblePanel className="px-4 sm:px-5">
|
||||
<CollapsiblePanel className="px-3 sm:px-4">
|
||||
<div className="pt-2 pb-0.5">
|
||||
<p className="text-sm text-foreground/90">{activeQuestion.question}</p>
|
||||
<p className="text-sm text-foreground/85">{activeQuestion.question}</p>
|
||||
{activeQuestion.multiSelect ? (
|
||||
<p className="mt-1 text-secondary-label text-xs">Select one or more options.</p>
|
||||
) : null}
|
||||
<div className="mt-3 space-y-1.5">
|
||||
<div className="mt-2 space-y-0.5">
|
||||
{activeQuestion.options.map((option, index) => {
|
||||
const isOptimisticallySelected =
|
||||
optimisticSingleSelect?.questionId === activeQuestion.id &&
|
||||
@@ -233,10 +233,10 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
|
||||
(!customAnswerActive && progress.selectedOptionLabels.includes(option.label));
|
||||
const shortcutKey = index < 9 ? index + 1 : null;
|
||||
const className = cn(
|
||||
"group flex w-full items-center gap-3 rounded-lg border px-3 py-2 text-left outline-none transition-all duration-150 focus-visible:border-primary/40 focus-visible:ring-1 focus-visible:ring-primary/25",
|
||||
"group flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-left outline-none transition-colors duration-150 focus-visible:ring-1 focus-visible:ring-primary/25",
|
||||
isSelected
|
||||
? "border-primary/30 bg-primary/8 text-foreground"
|
||||
: "border-transparent bg-muted/22 text-foreground/85 hover:border-border/45 hover:bg-muted/34",
|
||||
? "bg-muted/55 text-foreground"
|
||||
: "bg-transparent text-foreground/85 hover:bg-muted/30",
|
||||
isResponding && "opacity-50 cursor-not-allowed",
|
||||
!isResponding && "cursor-pointer",
|
||||
);
|
||||
@@ -245,7 +245,7 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
|
||||
<div className="min-w-0 flex-1 flex flex-col gap-0.5">
|
||||
<span className="text-sm font-medium">{option.label}</span>
|
||||
{option.description && option.description !== option.label ? (
|
||||
<span className="text-secondary-label text-xs">{option.description}</span>
|
||||
<span className="text-secondary-label text-[11px]">{option.description}</span>
|
||||
) : null}
|
||||
</div>
|
||||
{isSelected ? (
|
||||
@@ -253,8 +253,7 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
|
||||
) : shortcutKey !== null ? (
|
||||
<kbd
|
||||
className={cn(
|
||||
"flex size-5 shrink-0 items-center justify-center rounded border border-border/50 text-[11px] font-medium tabular-nums transition-colors duration-150",
|
||||
"bg-background/35 text-secondary-label group-hover:border-border/70 group-hover:text-foreground",
|
||||
"flex size-5 shrink-0 items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums",
|
||||
)}
|
||||
>
|
||||
{shortcutKey}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { memo } from "react";
|
||||
import { Badge } from "../ui/badge";
|
||||
|
||||
export const ComposerPlanFollowUpBanner = memo(function ComposerPlanFollowUpBanner({
|
||||
planTitle,
|
||||
@@ -7,17 +6,11 @@ export const ComposerPlanFollowUpBanner = memo(function ComposerPlanFollowUpBann
|
||||
planTitle: string | null;
|
||||
}) {
|
||||
return (
|
||||
<div className="px-4 py-3.5 sm:px-5 sm:py-4">
|
||||
<div className="px-3 py-2 sm:px-4">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Badge
|
||||
variant="info"
|
||||
size="sm"
|
||||
className="rounded-md px-1.5 py-0 font-semibold tracking-wide uppercase"
|
||||
>
|
||||
Plan Ready
|
||||
</Badge>
|
||||
<span className="text-xs font-medium text-muted-foreground">Plan ready</span>
|
||||
{planTitle ? (
|
||||
<span className="min-w-0 flex-1 truncate text-sm font-medium">{planTitle}</span>
|
||||
<span className="min-w-0 flex-1 truncate text-xs text-foreground/85">{planTitle}</span>
|
||||
) : null}
|
||||
</div>
|
||||
{/* <div className="mt-2 text-xs text-muted-foreground">
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { ComposerStashBadge } from "./ComposerStashBadge";
|
||||
|
||||
describe("ComposerStashBadge", () => {
|
||||
it("renders as an attached composer tab instead of a floating pill", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerStashBadge
|
||||
count={3}
|
||||
menuOpen={false}
|
||||
pulseKey={0}
|
||||
pulsing={false}
|
||||
onToggleMenu={() => {}}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain("chat-composer-stash-tab");
|
||||
expect(markup).toContain("rounded-t-xl");
|
||||
expect(markup).toContain("border-b-0");
|
||||
expect(markup).toContain("items-center");
|
||||
expect(markup).not.toContain("items-start");
|
||||
expect(markup).not.toContain("rounded-full");
|
||||
expect(markup).not.toContain("opacity-70");
|
||||
expect(markup).not.toContain("border-border");
|
||||
expect(markup).toContain('aria-expanded="false"');
|
||||
});
|
||||
|
||||
it("reports when the stash drawer is open", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerStashBadge
|
||||
count={3}
|
||||
menuOpen
|
||||
pulseKey={0}
|
||||
pulsing={false}
|
||||
onToggleMenu={() => {}}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain('aria-expanded="true"');
|
||||
expect(markup).toContain("text-foreground");
|
||||
expect(markup).toContain("pointer-events-none");
|
||||
expect(markup).not.toContain("invisible");
|
||||
});
|
||||
|
||||
it("keeps a compact inline entry point when a drawer occupies the tab", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerStashBadge
|
||||
count={3}
|
||||
menuOpen
|
||||
placement="inline"
|
||||
pulseKey={0}
|
||||
pulsing={false}
|
||||
onToggleMenu={() => {}}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain('data-slot="button"');
|
||||
expect(markup).toContain("rounded-sm");
|
||||
expect(markup).toContain("focus-visible:ring-2");
|
||||
expect(markup).toContain("pointer-coarse:after:min-h-11");
|
||||
expect(markup).toContain("Stashed prompts: 3. Open stash.");
|
||||
expect(markup).toContain('aria-expanded="true"');
|
||||
expect(markup).not.toContain("chat-composer-stash-tab");
|
||||
expect(markup).not.toContain("rounded-t-xl");
|
||||
expect(markup).not.toContain(" pointer-events-none ");
|
||||
});
|
||||
});
|
||||
@@ -2,10 +2,12 @@ import { BookmarkIcon } from "lucide-react";
|
||||
import { memo } from "react";
|
||||
|
||||
import { cn } from "~/lib/utils";
|
||||
import { Button } from "../ui/button";
|
||||
|
||||
/**
|
||||
* Bookmark pill perched on the composer's top-right shoulder. Shows the
|
||||
* stash count and doubles as the click target for opening the stash menu.
|
||||
* Bookmark control that shows the stash count and opens the stash menu. It
|
||||
* sits behind the composer's shoulder unless another drawer needs that space,
|
||||
* then moves into the composer's existing controls.
|
||||
*
|
||||
* On save the badge gives one quiet acknowledgement: it lifts to full
|
||||
* opacity and the count ticks over. `pulseKey` changes per stash, remounting
|
||||
@@ -13,12 +15,49 @@ import { cn } from "~/lib/utils";
|
||||
*/
|
||||
export const ComposerStashBadge = memo(function ComposerStashBadge(props: {
|
||||
count: number;
|
||||
menuOpen: boolean;
|
||||
placement?: "inline" | "tab";
|
||||
pulseKey: number;
|
||||
pulsing: boolean;
|
||||
menuOpen: boolean;
|
||||
onToggleMenu: () => void;
|
||||
}) {
|
||||
if (props.count === 0) return null;
|
||||
const inline = props.placement === "inline";
|
||||
const count = (
|
||||
<span
|
||||
key={props.pulseKey}
|
||||
className={cn(
|
||||
"text-[10px] font-medium leading-none tabular-nums",
|
||||
props.pulsing
|
||||
? "animate-[prompt-stash-count-enter_180ms_ease-out_both] text-primary motion-reduce:animate-none"
|
||||
: "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{props.count}
|
||||
</span>
|
||||
);
|
||||
|
||||
if (inline) {
|
||||
return (
|
||||
<Button
|
||||
size="micro"
|
||||
variant="ghost-muted"
|
||||
data-prompt-stash-badge="true"
|
||||
aria-label={`Stashed prompts: ${props.count}. Open stash.`}
|
||||
aria-expanded={props.menuOpen}
|
||||
className={cn(
|
||||
"shrink-0 gap-1 px-1.5",
|
||||
(props.menuOpen || props.pulsing) &&
|
||||
"[--control-icon-color:currentColor] text-foreground",
|
||||
)}
|
||||
onPointerDown={(event) => event.preventDefault()}
|
||||
onClick={props.onToggleMenu}
|
||||
>
|
||||
<BookmarkIcon className="size-3 shrink-0" aria-hidden="true" />
|
||||
{count}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<button
|
||||
@@ -27,11 +66,12 @@ export const ComposerStashBadge = memo(function ComposerStashBadge(props: {
|
||||
aria-label={`Stashed prompts: ${props.count}. Open stash.`}
|
||||
aria-expanded={props.menuOpen}
|
||||
className={cn(
|
||||
"absolute -top-3 right-4 z-10 inline-flex cursor-pointer items-center gap-1.5 rounded-full border bg-popover px-2.5 py-0.5 text-xs shadow-sm",
|
||||
"transition-[color,border-color,opacity] duration-200",
|
||||
"chat-composer-shoulder-tab chat-composer-stash-tab absolute -top-7 right-4 z-0 inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-t-xl border border-b-0 px-3 pb-1 text-xs leading-none",
|
||||
"transition-[color,border-color] duration-200",
|
||||
props.menuOpen && "pointer-events-none",
|
||||
props.menuOpen || props.pulsing
|
||||
? "border-border text-foreground opacity-100"
|
||||
: "border-border/70 text-muted-foreground opacity-70 hover:opacity-100 hover:text-foreground",
|
||||
? "text-foreground"
|
||||
: "text-muted-foreground hover:text-foreground",
|
||||
)}
|
||||
onPointerDown={(event) => {
|
||||
// Keep composer focus so Escape/typing flows stay intact.
|
||||
@@ -39,19 +79,9 @@ export const ComposerStashBadge = memo(function ComposerStashBadge(props: {
|
||||
}}
|
||||
onClick={props.onToggleMenu}
|
||||
>
|
||||
<BookmarkIcon className="size-3" aria-hidden="true" />
|
||||
<BookmarkIcon className="size-3 shrink-0" aria-hidden="true" />
|
||||
Stash
|
||||
<span
|
||||
key={props.pulseKey}
|
||||
className={cn(
|
||||
"rounded-full px-1.5 text-[10px] font-medium tabular-nums",
|
||||
props.pulsing
|
||||
? "animate-[prompt-stash-count-enter_180ms_ease-out_both] bg-primary text-primary-foreground motion-reduce:animate-none"
|
||||
: "bg-muted text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{props.count}
|
||||
</span>
|
||||
{count}
|
||||
</button>
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,74 @@
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { ComposerStashMenu } from "./ComposerStashMenu";
|
||||
|
||||
describe("ComposerStashMenu", () => {
|
||||
it("renders saved prompts as an attached composer drawer", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerStashMenu
|
||||
entries={[]}
|
||||
onRestore={() => {}}
|
||||
onDelete={() => {}}
|
||||
onClose={() => {}}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain('data-composer-stash-drawer="true"');
|
||||
expect(markup).toContain("chat-composer-drawer-surface");
|
||||
expect(markup).toContain("chat-composer-drawer-attached");
|
||||
expect(markup).toContain('aria-label="Close stash"');
|
||||
expect(markup).not.toContain("dropdown-glass");
|
||||
expect(markup).not.toContain("Stashed prompts");
|
||||
});
|
||||
|
||||
it("shows saved image thumbnails and incomplete image states", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerStashMenu
|
||||
entries={[
|
||||
{
|
||||
id: "with-images",
|
||||
createdAt: new Date(0).toISOString(),
|
||||
prompt: "Compare these screenshots",
|
||||
attachments: [
|
||||
{
|
||||
id: "image-one",
|
||||
name: "before.png",
|
||||
mimeType: "image/png",
|
||||
sizeBytes: 128,
|
||||
dataUrl: "data:image/png;base64,AA==",
|
||||
},
|
||||
],
|
||||
droppedImageNames: ["after.png"],
|
||||
unreadableImageNames: [],
|
||||
pendingImageCount: 0,
|
||||
},
|
||||
{
|
||||
id: "saving-images",
|
||||
createdAt: new Date(0).toISOString(),
|
||||
prompt: "Save this image",
|
||||
attachments: [],
|
||||
droppedImageNames: [],
|
||||
unreadableImageNames: [],
|
||||
pendingImageCount: 1,
|
||||
},
|
||||
]}
|
||||
onRestore={() => {}}
|
||||
onDelete={() => {}}
|
||||
onClose={() => {}}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain('src="data:image/png;base64,AA=="');
|
||||
expect(markup).toContain("1 image dropped");
|
||||
expect(markup).toContain("saving 1 image");
|
||||
expect(markup).not.toContain("absolute top-1/2 right-2");
|
||||
expect(markup).toContain("pointer-events-none");
|
||||
expect(markup).toContain("pointer-coarse:pointer-events-auto");
|
||||
expect(markup).toContain("pointer-coarse:opacity-100");
|
||||
expect(markup).not.toContain("bg-popover!");
|
||||
expect(markup).toContain("[--control-icon-color:currentColor]");
|
||||
expect(markup).toContain("size-3.5 stroke-2");
|
||||
expect(markup).not.toContain("bg-background/90");
|
||||
});
|
||||
});
|
||||
@@ -1,10 +1,10 @@
|
||||
import { BookmarkIcon, XIcon } from "lucide-react";
|
||||
import { memo, useEffect, useState } from "react";
|
||||
import { XIcon } from "lucide-react";
|
||||
import { memo, useEffect, useRef, useState } from "react";
|
||||
|
||||
import { formatRelativeTimeLabel } from "../../timestampFormat";
|
||||
import { cn } from "~/lib/utils";
|
||||
import { type PromptStashEntry } from "../../promptStashStore";
|
||||
import { Command, CommandGroup, CommandGroupLabel, CommandItem, CommandList } from "../ui/command";
|
||||
import { Command, CommandGroup, CommandItem, CommandList } from "../ui/command";
|
||||
import { Button } from "../ui/button";
|
||||
|
||||
const SNIPPET_MAX_CHARS = 90;
|
||||
@@ -36,10 +36,27 @@ export const ComposerStashMenu = memo(function ComposerStashMenu(props: {
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const { entries, onRestore, onDelete, onClose } = props;
|
||||
const drawerRef = useRef<HTMLDivElement>(null);
|
||||
const [highlightedId, setHighlightedId] = useState<string | null>(entries[0]?.id ?? null);
|
||||
|
||||
const highlightedEntry = entries.find((entry) => entry.id === highlightedId) ?? entries[0];
|
||||
|
||||
useEffect(() => {
|
||||
const closeOnOutsidePointer = (event: PointerEvent) => {
|
||||
const drawer = drawerRef.current;
|
||||
if (
|
||||
(drawer && event.composedPath().includes(drawer)) ||
|
||||
(event.target instanceof Element &&
|
||||
event.target.closest('[data-prompt-stash-badge="true"]'))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
onClose();
|
||||
};
|
||||
document.addEventListener("pointerdown", closeOnOutsidePointer, true);
|
||||
return () => document.removeEventListener("pointerdown", closeOnOutsidePointer, true);
|
||||
}, [onClose]);
|
||||
|
||||
useEffect(() => {
|
||||
if (entries.length === 0) return;
|
||||
if (!entries.some((entry) => entry.id === highlightedId)) {
|
||||
@@ -91,15 +108,26 @@ export const ComposerStashMenu = memo(function ComposerStashMenu(props: {
|
||||
|
||||
return (
|
||||
<Command autoHighlight={false} mode="none">
|
||||
<div className="dropdown-glass relative w-full overflow-hidden rounded-[20px] shadow-[0_16px_40px_-18px_rgb(0_0_0/55%)] dark:shadow-[0_18px_44px_-18px_rgb(0_0_0/80%)]">
|
||||
<CommandList className="max-h-72">
|
||||
<div
|
||||
ref={drawerRef}
|
||||
className="chat-composer-drawer-surface chat-composer-drawer-attached relative w-full overflow-hidden"
|
||||
data-composer-stash-drawer="true"
|
||||
>
|
||||
<div className="flex h-7 items-center justify-end px-2 pt-1">
|
||||
<Button
|
||||
variant="ghost-muted"
|
||||
size="icon-micro"
|
||||
aria-label="Close stash"
|
||||
onPointerDown={(event) => event.preventDefault()}
|
||||
onClick={onClose}
|
||||
>
|
||||
<XIcon className="size-3" />
|
||||
</Button>
|
||||
</div>
|
||||
<CommandList className="max-h-64 scroll-pb-6">
|
||||
<CommandGroup>
|
||||
<CommandGroupLabel className="flex items-center gap-1.5 px-3 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-[0.08em] text-secondary-label">
|
||||
<BookmarkIcon className="size-3" aria-hidden="true" />
|
||||
Stashed prompts
|
||||
</CommandGroupLabel>
|
||||
{entries.length === 0 ? (
|
||||
<p className="px-3 pb-3 pt-1 text-secondary-label text-xs">
|
||||
<p className="px-3 py-1.5 text-secondary-label text-xs">
|
||||
Nothing stashed yet. Press ⌘S with a prompt in the composer to stash it.
|
||||
</p>
|
||||
) : (
|
||||
@@ -108,7 +136,7 @@ export const ComposerStashMenu = memo(function ComposerStashMenu(props: {
|
||||
key={entry.id}
|
||||
value={entry.id}
|
||||
className={cn(
|
||||
"group/stash cursor-pointer select-none gap-2 hover:bg-transparent hover:text-inherit data-highlighted:bg-transparent data-highlighted:text-inherit",
|
||||
"group/stash relative cursor-pointer select-none gap-3 rounded-lg px-3 py-1.5! hover:bg-transparent hover:text-inherit data-highlighted:bg-transparent data-highlighted:text-inherit",
|
||||
highlightedId === entry.id && "bg-accent! text-accent-foreground!",
|
||||
)}
|
||||
onMouseMove={() => {
|
||||
@@ -121,22 +149,7 @@ export const ComposerStashMenu = memo(function ComposerStashMenu(props: {
|
||||
onRestore(entry);
|
||||
}}
|
||||
>
|
||||
{entry.attachments.length > 0 ? (
|
||||
<span className="flex shrink-0 items-center -space-x-1.5">
|
||||
{entry.attachments.slice(0, 3).map((attachment) => (
|
||||
<img
|
||||
key={attachment.id}
|
||||
src={attachment.dataUrl}
|
||||
alt=""
|
||||
aria-hidden="true"
|
||||
className="size-5 rounded border border-border/70 object-cover"
|
||||
/>
|
||||
))}
|
||||
</span>
|
||||
) : (
|
||||
<BookmarkIcon className="size-4 shrink-0 text-icon-muted" />
|
||||
)}
|
||||
<span className="min-w-0 flex-1 truncate text-sm">
|
||||
<span className="min-w-0 flex-1 truncate text-xs">
|
||||
{stashEntrySnippet(entry)}
|
||||
</span>
|
||||
{entry.pendingImageCount ? (
|
||||
@@ -150,20 +163,33 @@ export const ComposerStashMenu = memo(function ComposerStashMenu(props: {
|
||||
{missingImageCount(entry) === 1 ? "" : "s"} dropped
|
||||
</span>
|
||||
) : null}
|
||||
<span className="shrink-0 text-secondary-label text-xs">
|
||||
{entry.attachments.length > 0 ? (
|
||||
<span className="flex shrink-0 items-center -space-x-1.5">
|
||||
{entry.attachments.slice(0, 3).map((attachment) => (
|
||||
<img
|
||||
key={attachment.id}
|
||||
src={attachment.dataUrl}
|
||||
alt=""
|
||||
aria-hidden="true"
|
||||
className="size-5 rounded border border-border/70 object-cover"
|
||||
/>
|
||||
))}
|
||||
</span>
|
||||
) : null}
|
||||
<span className="shrink-0 text-secondary-label text-xs max-sm:hidden">
|
||||
{formatRelativeTimeLabel(entry.createdAt)}
|
||||
</span>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
className="shrink-0 opacity-0 transition-opacity group-hover/stash:opacity-100"
|
||||
className="pointer-events-none shrink-0 [--control-icon-color:currentColor] opacity-0 shadow-none! transition-opacity pointer-coarse:pointer-events-auto pointer-coarse:opacity-100 group-hover/stash:pointer-events-auto group-hover/stash:opacity-100 group-focus-within/stash:pointer-events-auto group-focus-within/stash:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100"
|
||||
aria-label="Delete stashed prompt"
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
onDelete(entry);
|
||||
}}
|
||||
>
|
||||
<XIcon />
|
||||
<XIcon className="size-3.5 stroke-2" />
|
||||
</Button>
|
||||
</CommandItem>
|
||||
))
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { ComposerTasksBadge, ComposerTasksDrawer } from "./ComposerTasksBadge";
|
||||
|
||||
const progress = {
|
||||
step: "Attach task progress",
|
||||
completedSteps: 1,
|
||||
totalSteps: 3,
|
||||
};
|
||||
const steps = [
|
||||
{ durationMs: 4_000, step: "Inspect the composer", status: "completed" as const },
|
||||
{ step: "Attach task progress", status: "inProgress" as const },
|
||||
{ step: "Verify the result", status: "pending" as const },
|
||||
];
|
||||
|
||||
describe("ComposerTasksBadge", () => {
|
||||
it("renders active progress as an attached composer tab", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerTasksBadge
|
||||
expanded={false}
|
||||
onDismiss={() => undefined}
|
||||
onToggle={() => undefined}
|
||||
progress={progress}
|
||||
steps={steps}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain('data-composer-tasks-badge="true"');
|
||||
expect(markup).toContain('aria-expanded="false"');
|
||||
expect(markup).toContain("chat-composer-shoulder-tab");
|
||||
expect(markup).toContain("chat-composer-tasks-tab");
|
||||
expect(markup).toContain("rounded-t-xl");
|
||||
expect(markup).toContain("border-b-0");
|
||||
expect(markup).toContain("left-4");
|
||||
expect(markup).toContain("right-4");
|
||||
expect(markup).toContain('data-composer-task-current="true"');
|
||||
expect(markup).toContain("min-w-0 flex-1 truncate");
|
||||
expect(markup).toContain("w-20");
|
||||
expect(markup).toContain("Tasks");
|
||||
expect(markup).toContain("Attach task progress");
|
||||
expect(markup).not.toContain("·");
|
||||
expect(markup).toContain("1/3");
|
||||
expect(markup).toContain("Current task: Attach task progress");
|
||||
expect(markup).toContain("lucide-list-todo");
|
||||
expect(markup).toContain('aria-label="Dismiss tasks for this turn"');
|
||||
expect(markup).toContain("lucide-x");
|
||||
expect(markup).not.toContain("lucide-chevron");
|
||||
expect(markup).toContain("bg-success");
|
||||
expect(markup).toContain("bg-primary");
|
||||
expect(markup).toContain("bg-muted-foreground/25");
|
||||
});
|
||||
|
||||
it("leaves room for the stash tab when both shoulders are present", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerTasksBadge
|
||||
expanded={false}
|
||||
hasTrailingShoulder
|
||||
onDismiss={() => undefined}
|
||||
onToggle={() => undefined}
|
||||
progress={progress}
|
||||
steps={steps}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain("right-28");
|
||||
expect(markup).not.toContain("right-4");
|
||||
});
|
||||
|
||||
it("has a compact inline fallback for occupied composer shoulders", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerTasksBadge
|
||||
expanded={false}
|
||||
onDismiss={() => undefined}
|
||||
onToggle={() => undefined}
|
||||
placement="inline"
|
||||
progress={progress}
|
||||
steps={steps}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain("rounded-sm");
|
||||
expect(markup).toContain("1/3");
|
||||
expect(markup).not.toContain("chat-composer-shoulder-tab");
|
||||
expect(markup).not.toContain("rounded-t-xl");
|
||||
});
|
||||
|
||||
it("expands into a read-only attached task list", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerTasksDrawer
|
||||
onCollapse={() => undefined}
|
||||
onDismiss={() => undefined}
|
||||
progress={progress}
|
||||
steps={steps}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toContain('data-chat-composer-tasks-drawer="true"');
|
||||
expect(markup).not.toContain("data-variant");
|
||||
expect(markup).toContain('aria-expanded="true"');
|
||||
expect(markup).toContain('role="list"');
|
||||
expect(markup).toContain("Inspect the composer");
|
||||
expect(markup).toContain('data-composer-task-duration="true"');
|
||||
expect(markup).toContain("ml-auto w-10");
|
||||
expect(markup).toContain("4.0s");
|
||||
expect(markup).toContain("now");
|
||||
expect(markup).toContain("Attach task progress");
|
||||
expect(markup).toContain("Verify the result");
|
||||
expect(markup).toContain("lucide-list-todo");
|
||||
expect(markup).toContain('aria-label="Dismiss tasks for this turn"');
|
||||
expect(markup).not.toContain("lucide-chevron");
|
||||
expect(markup).not.toContain("bg-success");
|
||||
expect(markup).not.toContain("bg-primary");
|
||||
expect(markup).not.toContain("bg-muted-foreground/25");
|
||||
});
|
||||
|
||||
it("does not render an empty task count", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
<ComposerTasksBadge
|
||||
expanded={false}
|
||||
onDismiss={() => undefined}
|
||||
onToggle={() => undefined}
|
||||
progress={{ ...progress, totalSteps: 0 }}
|
||||
steps={steps}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(markup).toBe("");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,246 @@
|
||||
import { ListTodoIcon, XIcon } from "lucide-react";
|
||||
import { memo } from "react";
|
||||
|
||||
import { formatDuration } from "../../session-logic";
|
||||
import { cn } from "~/lib/utils";
|
||||
import { Button } from "../ui/button";
|
||||
|
||||
export interface ComposerTasksProgress {
|
||||
readonly step: string;
|
||||
readonly completedSteps: number;
|
||||
readonly totalSteps: number;
|
||||
}
|
||||
|
||||
export interface ComposerTaskStep {
|
||||
readonly durationMs?: number;
|
||||
readonly step: string;
|
||||
readonly status: "pending" | "inProgress" | "completed";
|
||||
}
|
||||
|
||||
function keyedTaskSteps(steps: readonly ComposerTaskStep[]) {
|
||||
const occurrences = new Map<string, number>();
|
||||
return steps.map((step) => {
|
||||
const occurrence = occurrences.get(step.step) ?? 0;
|
||||
occurrences.set(step.step, occurrence + 1);
|
||||
return { key: `${step.step}:${occurrence}`, step };
|
||||
});
|
||||
}
|
||||
|
||||
function TaskSegments({
|
||||
className,
|
||||
steps,
|
||||
}: {
|
||||
readonly className?: string;
|
||||
readonly steps: readonly ComposerTaskStep[];
|
||||
}) {
|
||||
if (steps.length <= 1) return null;
|
||||
|
||||
return (
|
||||
<span aria-hidden className={cn("flex w-10 shrink-0 items-center gap-0.5", className)}>
|
||||
{keyedTaskSteps(steps).map(({ key, step }) => (
|
||||
<span
|
||||
key={key}
|
||||
className={cn(
|
||||
"h-[3px] min-w-0 flex-1 rounded-full",
|
||||
step.status === "completed"
|
||||
? "bg-success"
|
||||
: step.status === "inProgress"
|
||||
? "bg-primary"
|
||||
: "bg-muted-foreground/25",
|
||||
)}
|
||||
/>
|
||||
))}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export const ComposerTasksBadge = memo(function ComposerTasksBadge({
|
||||
expanded,
|
||||
hasTrailingShoulder = false,
|
||||
onDismiss,
|
||||
onToggle,
|
||||
placement = "tab",
|
||||
progress,
|
||||
steps,
|
||||
}: {
|
||||
readonly expanded: boolean;
|
||||
readonly hasTrailingShoulder?: boolean;
|
||||
readonly onDismiss: () => void;
|
||||
readonly onToggle: () => void;
|
||||
readonly placement?: "inline" | "tab";
|
||||
readonly progress: ComposerTasksProgress;
|
||||
readonly steps: readonly ComposerTaskStep[];
|
||||
}) {
|
||||
if (progress.totalSteps <= 0) return null;
|
||||
|
||||
const allDone = progress.completedSteps >= progress.totalSteps;
|
||||
const label = `Tasks: ${progress.completedSteps} of ${progress.totalSteps} complete. Current task: ${progress.step}`;
|
||||
if (placement === "inline") {
|
||||
return (
|
||||
<span className="inline-flex shrink-0 items-center gap-0.5" data-composer-tasks-badge="true">
|
||||
<Button
|
||||
size="micro"
|
||||
variant="ghost-muted"
|
||||
aria-expanded={expanded}
|
||||
aria-label={label}
|
||||
className="shrink-0 gap-1 px-1.5"
|
||||
onClick={onToggle}
|
||||
onPointerDown={(event) => event.preventDefault()}
|
||||
>
|
||||
<ListTodoIcon aria-hidden className="size-3 shrink-0" />
|
||||
<span>Tasks</span>
|
||||
<TaskSegments steps={steps} />
|
||||
<span
|
||||
className={cn(
|
||||
"font-medium tabular-nums",
|
||||
allDone ? "text-success" : "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{progress.completedSteps}/{progress.totalSteps}
|
||||
</span>
|
||||
</Button>
|
||||
<Button
|
||||
size="icon-micro"
|
||||
variant="ghost-muted"
|
||||
aria-label="Dismiss tasks for this turn"
|
||||
className="shrink-0"
|
||||
onClick={onDismiss}
|
||||
onPointerDown={(event) => event.preventDefault()}
|
||||
>
|
||||
<XIcon aria-hidden className="size-2.5" />
|
||||
</Button>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"chat-composer-shoulder-tab chat-composer-tasks-tab absolute -top-7 left-4 z-0 flex h-8 items-center gap-1 rounded-t-xl border border-b-0 px-2 pb-1 text-xs leading-none text-muted-foreground",
|
||||
hasTrailingShoulder ? "right-28" : "right-4",
|
||||
allDone && "text-foreground",
|
||||
)}
|
||||
data-composer-tasks-badge="true"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
aria-expanded={expanded}
|
||||
aria-label={label}
|
||||
className="flex min-w-0 flex-1 cursor-pointer items-center gap-2 self-stretch text-muted-foreground hover:text-foreground"
|
||||
onClick={onToggle}
|
||||
onPointerDown={(event) => event.preventDefault()}
|
||||
>
|
||||
<ListTodoIcon aria-hidden className="size-3.5 shrink-0" />
|
||||
<span className="shrink-0">Tasks</span>
|
||||
<span
|
||||
className="min-w-0 flex-1 truncate text-left font-medium text-foreground/80"
|
||||
data-composer-task-current="true"
|
||||
>
|
||||
{progress.step}
|
||||
</span>
|
||||
<span
|
||||
className={cn(
|
||||
"shrink-0 font-medium tabular-nums",
|
||||
allDone ? "text-success" : "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{progress.completedSteps}/{progress.totalSteps}
|
||||
</span>
|
||||
<TaskSegments className="w-20" steps={steps} />
|
||||
</button>
|
||||
<Button
|
||||
size="icon-micro"
|
||||
variant="ghost-muted"
|
||||
aria-label="Dismiss tasks for this turn"
|
||||
className="shrink-0"
|
||||
onClick={onDismiss}
|
||||
onPointerDown={(event) => event.preventDefault()}
|
||||
>
|
||||
<XIcon aria-hidden className="size-3" />
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
export const ComposerTasksDrawer = memo(function ComposerTasksDrawer({
|
||||
onDismiss,
|
||||
onCollapse,
|
||||
progress,
|
||||
steps,
|
||||
}: {
|
||||
readonly onDismiss: () => void;
|
||||
readonly onCollapse: () => void;
|
||||
readonly progress: ComposerTasksProgress;
|
||||
readonly steps: readonly ComposerTaskStep[];
|
||||
}) {
|
||||
return (
|
||||
<div className="chat-composer-top-drawer" data-chat-composer-tasks-drawer="true">
|
||||
<div className="flex items-center gap-1 px-3 py-1.5 sm:px-4">
|
||||
<button
|
||||
type="button"
|
||||
aria-expanded="true"
|
||||
className="flex min-w-0 flex-1 cursor-pointer items-center gap-2 self-stretch text-left text-xs text-muted-foreground hover:text-foreground"
|
||||
onClick={onCollapse}
|
||||
onPointerDown={(event) => event.preventDefault()}
|
||||
>
|
||||
<ListTodoIcon aria-hidden className="size-3.5 shrink-0" />
|
||||
<span className="font-medium text-foreground">Tasks</span>
|
||||
<span className="tabular-nums">
|
||||
{progress.completedSteps}/{progress.totalSteps}
|
||||
</span>
|
||||
</button>
|
||||
<Button
|
||||
size="icon-micro"
|
||||
variant="ghost-muted"
|
||||
aria-label="Dismiss tasks for this turn"
|
||||
className="shrink-0"
|
||||
onClick={onDismiss}
|
||||
onPointerDown={(event) => event.preventDefault()}
|
||||
>
|
||||
<XIcon aria-hidden className="size-3" />
|
||||
</Button>
|
||||
</div>
|
||||
<div className="space-y-px px-3 pb-4 sm:px-4" role="list">
|
||||
{keyedTaskSteps(steps).map(({ key, step }) => (
|
||||
<div key={key} className="flex items-baseline gap-2 text-xs leading-5" role="listitem">
|
||||
<span
|
||||
aria-hidden
|
||||
className={cn(
|
||||
"w-3 shrink-0 text-center font-mono text-[10px]",
|
||||
step.status === "completed"
|
||||
? "text-success"
|
||||
: step.status === "inProgress"
|
||||
? "text-primary"
|
||||
: "text-muted-foreground/40",
|
||||
)}
|
||||
>
|
||||
{step.status === "completed" ? "✓" : step.status === "inProgress" ? "●" : "○"}
|
||||
</span>
|
||||
<span
|
||||
className={cn(
|
||||
"min-w-0 flex-1",
|
||||
step.status === "completed"
|
||||
? "text-muted-foreground/55"
|
||||
: step.status === "inProgress"
|
||||
? "text-foreground/90"
|
||||
: "text-muted-foreground/70",
|
||||
)}
|
||||
>
|
||||
{step.step}
|
||||
</span>
|
||||
<span
|
||||
className="ml-auto w-10 shrink-0 text-right text-[10px] text-muted-foreground/45 tabular-nums"
|
||||
data-composer-task-duration="true"
|
||||
>
|
||||
{step.durationMs !== undefined
|
||||
? formatDuration(step.durationMs)
|
||||
: step.status === "inProgress"
|
||||
? "now"
|
||||
: null}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Children, cloneElement, isValidElement, type ReactNode } from "react";
|
||||
import type { ServerProviderSkill } from "@t3tools/contracts";
|
||||
import { formatProviderSkillDisplayName } from "@t3tools/client-runtime/providerSkills";
|
||||
|
||||
import { formatProviderSkillDisplayName } from "../../providerSkillPresentation";
|
||||
import {
|
||||
CHAT_INLINE_CHIP_CLASS_NAME,
|
||||
CHAT_INLINE_CHIP_LABEL_CLASS_NAME,
|
||||
|
||||
@@ -11,6 +11,11 @@ describe("ThreadSyncStatusPill", () => {
|
||||
const markup = renderToStaticMarkup(<ThreadSyncStatusPill phase={phase} />);
|
||||
|
||||
expect(markup).toContain('role="status"');
|
||||
expect(markup).toContain('data-thread-sync-drawer="true"');
|
||||
expect(markup).toContain("chat-composer-drawer-surface");
|
||||
expect(markup).toContain("chat-composer-drawer-attached");
|
||||
expect(markup).toContain("chat-composer-drawer-slot");
|
||||
expect(markup).toContain("pb-[calc(var(--chat-composer-attachment-overlap)_+_0.375rem)]");
|
||||
expect(markup).toContain(label);
|
||||
expect(markup).not.toContain("animate-");
|
||||
});
|
||||
|
||||
@@ -8,7 +8,8 @@ export function ThreadSyncStatusPill({ phase }: { readonly phase: ThreadSyncPhas
|
||||
return (
|
||||
<div
|
||||
aria-label={label}
|
||||
className="pointer-events-none mx-auto mb-2 flex w-fit max-w-full items-center gap-2 rounded-full border border-border/60 bg-card/95 px-3 py-1.5 text-foreground text-xs font-medium shadow-sm"
|
||||
className="chat-composer-drawer-surface chat-composer-drawer-attached chat-composer-drawer-slot pointer-events-none flex items-center gap-2 px-3 pt-2 pb-[calc(var(--chat-composer-attachment-overlap)_+_0.375rem)] text-foreground text-xs font-medium sm:px-4"
|
||||
data-thread-sync-drawer="true"
|
||||
role="status"
|
||||
>
|
||||
<LoaderCircleIcon aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
// Chip metrics are in em so the pills scale with the text they sit in (the
|
||||
// composer honors the prompt font-size preference). The chat variant pins the
|
||||
// original 12px, where every em value resolves to the same pixels as before.
|
||||
const INLINE_CHIP_CLASS_NAME =
|
||||
"inline-flex max-w-full items-center gap-[0.33em] rounded-[0.5em] border border-border/70 bg-accent/40 px-[0.5em] py-[0.08em] font-medium leading-[1.1] text-foreground align-middle";
|
||||
const INLINE_CHIP_GEOMETRY_CLASS_NAME =
|
||||
"inline-flex h-[1.41em] max-w-full items-center gap-[0.33em] rounded-[0.5em] px-[0.5em] font-medium leading-none align-middle";
|
||||
|
||||
const INLINE_CHIP_CLASS_NAME = `${INLINE_CHIP_GEOMETRY_CLASS_NAME} border border-border/70 bg-accent/40 text-foreground`;
|
||||
|
||||
export const CHAT_INLINE_CHIP_CLASS_NAME = `${INLINE_CHIP_CLASS_NAME} text-[12px]`;
|
||||
|
||||
@@ -11,18 +13,15 @@ export const COMPOSER_INLINE_CHIP_CLASS_NAME = `${INLINE_CHIP_CLASS_NAME} text-[
|
||||
export const COMPOSER_INLINE_CHIP_DECORATOR_CLASS_NAME =
|
||||
"relative inline-flex align-[-0.125em] leading-none data-[composer-chip-selected]:after:pointer-events-none data-[composer-chip-selected]:after:absolute data-[composer-chip-selected]:after:inset-0 data-[composer-chip-selected]:after:rounded-[6px] data-[composer-chip-selected]:after:bg-[Highlight] data-[composer-chip-selected]:after:opacity-30 data-[composer-chip-selected]:after:content-['']";
|
||||
|
||||
export const COMPOSER_INLINE_CHIP_ICON_CLASS_NAME = "size-[1.17em] shrink-0 opacity-85";
|
||||
export const COMPOSER_INLINE_CHIP_ICON_CLASS_NAME =
|
||||
"block size-[1.17em] shrink-0 self-center opacity-85 [&>svg]:block";
|
||||
|
||||
export const CHAT_INLINE_CHIP_LABEL_CLASS_NAME = "truncate leading-tight";
|
||||
|
||||
export const COMPOSER_INLINE_CHIP_LABEL_CLASS_NAME = `${CHAT_INLINE_CHIP_LABEL_CLASS_NAME} select-none`;
|
||||
export const COMPOSER_INLINE_CHIP_LABEL_CLASS_NAME =
|
||||
"block self-center truncate leading-tight select-none";
|
||||
|
||||
// The skill label is smaller than the surrounding prompt text; offset its
|
||||
// glyphs without moving the pill box or changing the editor's line height.
|
||||
export const COMPOSER_INLINE_SKILL_CHIP_LABEL_CLASS_NAME = `${COMPOSER_INLINE_CHIP_LABEL_CLASS_NAME} relative top-[0.15em]`;
|
||||
|
||||
export const COMPOSER_INLINE_SKILL_CHIP_CLASS_NAME =
|
||||
"inline-flex max-w-full select-none items-center gap-[0.33em] rounded-[0.5em] border border-fuchsia-500/25 bg-fuchsia-500/12 px-[0.5em] py-[0.08em] font-medium text-[0.86em] leading-[1.1] text-fuchsia-700 align-middle dark:text-fuchsia-300";
|
||||
export const COMPOSER_INLINE_SKILL_CHIP_CLASS_NAME = `${INLINE_CHIP_GEOMETRY_CLASS_NAME} select-none border border-fuchsia-500/25 bg-fuchsia-500/12 text-[0.86em] text-fuchsia-700 dark:text-fuchsia-300`;
|
||||
|
||||
export const SKILL_CHIP_ICON_SVG = `<svg width="100%" height="100%" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.85" stroke-linecap="round" stroke-linejoin="round"><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/></svg>`;
|
||||
|
||||
|
||||
@@ -31,6 +31,11 @@ describe("button geometry tokens", () => {
|
||||
|
||||
it("owns shared compact and micro control geometry", () => {
|
||||
const compact = renderToStaticMarkup(<Button size="compact">Condition</Button>);
|
||||
const microLabel = renderToStaticMarkup(
|
||||
<Button size="micro">
|
||||
<FlaskConicalIcon /> Run
|
||||
</Button>,
|
||||
);
|
||||
const micro = renderToStaticMarkup(
|
||||
<Button size="icon-micro" variant="ghost-muted" aria-label="Add action">
|
||||
<span>+</span>
|
||||
@@ -39,6 +44,9 @@ describe("button geometry tokens", () => {
|
||||
|
||||
expect(compact).toContain("h-7");
|
||||
expect(compact).toContain("rounded-md");
|
||||
expect(microLabel).toContain("text-[11px]");
|
||||
expect(microLabel).toContain("sm:text-[11px]");
|
||||
expect(microLabel).toContain("sm:[&_svg:not([class*='size-'])]:size-3");
|
||||
expect(micro).toContain("size-5");
|
||||
expect(micro).toContain("rounded-sm");
|
||||
expect(micro).toContain("text-muted-foreground");
|
||||
|
||||
@@ -29,6 +29,8 @@ const buttonVariants = cva(
|
||||
"icon-xs":
|
||||
"size-7 sm:size-6 not-in-data-[slot=input-group]:[&_svg:not([class*='size-'])]:size-4 sm:not-in-data-[slot=input-group]:[&_svg:not([class*='size-'])]:size-3.5",
|
||||
lg: "h-10 px-[calc(--spacing(3.5)-1px)] sm:h-9",
|
||||
micro:
|
||||
"h-5 gap-1 rounded-sm px-[calc(--spacing(1.5)-1px)] text-[11px] before:rounded-[calc(var(--radius-sm)-1px)] sm:text-[11px] [&_svg:not([class*='size-'])]:size-3 sm:[&_svg:not([class*='size-'])]:size-3",
|
||||
sm: "h-8 gap-1.5 px-[calc(--spacing(2.5)-1px)] sm:h-7",
|
||||
xl: "h-11 px-[calc(--spacing(4)-1px)] text-lg sm:h-10 sm:text-base [&_svg:not([class*='size-'])]:size-5 sm:[&_svg:not([class*='size-'])]:size-4.5",
|
||||
xs: "h-7 gap-1 px-[calc(--spacing(2)-1px)] text-sm sm:h-6 sm:text-xs [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5",
|
||||
|
||||
+321
-2
@@ -680,7 +680,191 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.chat-composer-shoulder-tab {
|
||||
border-color: var(
|
||||
--chat-composer-outline,
|
||||
color-mix(in srgb, var(--foreground) 8%, transparent)
|
||||
);
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--chat-composer-glass-surface, var(--card)) var(--glass-opacity),
|
||||
transparent
|
||||
);
|
||||
-webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
|
||||
backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
|
||||
box-shadow: 0 -8px 24px -18px rgb(0 0 0 / 45%);
|
||||
|
||||
@variant dark {
|
||||
box-shadow: 0 -10px 28px -18px rgb(0 0 0 / 80%);
|
||||
}
|
||||
|
||||
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
|
||||
background: var(--chat-composer-glass-surface, var(--card));
|
||||
}
|
||||
}
|
||||
|
||||
.chat-composer-banner-stack-cap {
|
||||
--chat-composer-attached-surface: var(--chat-composer-glass-surface, var(--card));
|
||||
--chat-composer-attached-outline: var(
|
||||
--chat-composer-outline,
|
||||
color-mix(in srgb, var(--foreground) 8%, transparent)
|
||||
);
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--chat-composer-attached-surface) var(--glass-opacity),
|
||||
transparent
|
||||
);
|
||||
-webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
|
||||
backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
|
||||
|
||||
@variant dark {
|
||||
--chat-composer-attached-surface: var(
|
||||
--chat-composer-glass-surface,
|
||||
color-mix(in srgb, var(--background) 96%, var(--color-white))
|
||||
);
|
||||
--chat-composer-attached-outline: var(
|
||||
--chat-composer-outline,
|
||||
color-mix(in srgb, var(--color-white) 5%, transparent)
|
||||
);
|
||||
}
|
||||
|
||||
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
|
||||
background: var(--chat-composer-attached-surface);
|
||||
}
|
||||
}
|
||||
|
||||
/* Mirror the run-context strip above the composer. These surfaces deliberately
|
||||
own no card fill or border themselves: a masked pseudo-element draws the
|
||||
same inset glass, 16px outer corners, quiet outline, and open attachment
|
||||
seam as the strip below. */
|
||||
.chat-composer-drawer-surface,
|
||||
.chat-composer-top-drawer {
|
||||
--chat-composer-attachment-overlap: calc(1rem + 1px);
|
||||
--chat-composer-attached-surface: var(--chat-composer-glass-surface, var(--card));
|
||||
--chat-composer-attached-outline: var(
|
||||
--chat-composer-outline,
|
||||
color-mix(in srgb, var(--foreground) 8%, transparent)
|
||||
);
|
||||
--chat-composer-attached-tint: transparent;
|
||||
position: relative;
|
||||
isolation: isolate;
|
||||
border: 0 !important;
|
||||
background: transparent !important;
|
||||
box-shadow: none;
|
||||
|
||||
@variant dark {
|
||||
--chat-composer-attached-surface: var(
|
||||
--chat-composer-glass-surface,
|
||||
color-mix(in srgb, var(--background) 96%, var(--color-white))
|
||||
);
|
||||
--chat-composer-attached-outline: var(
|
||||
--chat-composer-outline,
|
||||
color-mix(in srgb, var(--color-white) 5%, transparent)
|
||||
);
|
||||
|
||||
&::before {
|
||||
background:
|
||||
linear-gradient(var(--chat-composer-attached-tint), var(--chat-composer-attached-tint)),
|
||||
linear-gradient(
|
||||
to top,
|
||||
transparent 0 var(--chat-composer-attachment-overlap),
|
||||
rgb(0 0 0 / 18%) var(--chat-composer-attachment-overlap),
|
||||
transparent calc(var(--chat-composer-attachment-overlap) + 10px)
|
||||
),
|
||||
color-mix(
|
||||
in srgb,
|
||||
var(--chat-composer-attached-surface) var(--glass-opacity),
|
||||
transparent
|
||||
);
|
||||
box-shadow: 0 14px 32px -18px rgb(0 0 0 / 75%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.chat-composer-drawer-attached,
|
||||
.chat-composer-top-drawer {
|
||||
padding-bottom: var(--chat-composer-attachment-overlap);
|
||||
}
|
||||
|
||||
[data-chat-composer-form="true"],
|
||||
.chat-composer-drawer-slot,
|
||||
.chat-composer-top-drawer {
|
||||
--chat-composer-drawer-inset: 1.375rem;
|
||||
}
|
||||
|
||||
.chat-composer-drawer-slot,
|
||||
.chat-composer-top-drawer {
|
||||
--chat-composer-attachment-overlap: calc(1rem + 1px);
|
||||
width: calc(100% - var(--chat-composer-drawer-inset) - var(--chat-composer-drawer-inset));
|
||||
max-width: calc(48rem - var(--chat-composer-drawer-inset) - var(--chat-composer-drawer-inset));
|
||||
margin-inline: auto;
|
||||
margin-bottom: calc(-1 * var(--chat-composer-attachment-overlap));
|
||||
}
|
||||
|
||||
:is(.chat-composer-drawer-surface, .chat-composer-top-drawer)::before {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
z-index: -1;
|
||||
inset: 0;
|
||||
border: 1px solid var(--chat-composer-attached-outline);
|
||||
border-radius: 16px 16px 0 0;
|
||||
background:
|
||||
linear-gradient(var(--chat-composer-attached-tint), var(--chat-composer-attached-tint)),
|
||||
color-mix(in srgb, var(--chat-composer-attached-surface) var(--glass-opacity), transparent);
|
||||
-webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
|
||||
backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
|
||||
-webkit-mask-image: linear-gradient(
|
||||
to top,
|
||||
transparent 0 var(--chat-composer-attachment-overlap),
|
||||
black var(--chat-composer-attachment-overlap)
|
||||
);
|
||||
mask-image: linear-gradient(
|
||||
to top,
|
||||
transparent 0 var(--chat-composer-attachment-overlap),
|
||||
black var(--chat-composer-attachment-overlap)
|
||||
);
|
||||
box-shadow: 0 12px 28px -18px rgb(0 0 0 / 40%);
|
||||
content: "";
|
||||
|
||||
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
|
||||
background:
|
||||
linear-gradient(var(--chat-composer-attached-tint), var(--chat-composer-attached-tint)),
|
||||
var(--chat-composer-attached-surface) !important;
|
||||
}
|
||||
}
|
||||
|
||||
.chat-composer-drawer-slot + .chat-composer-drawer-slot::before,
|
||||
.chat-composer-drawer-slot + :has(.chat-composer-top-drawer) .chat-composer-top-drawer::before {
|
||||
border-top: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.chat-composer-top-drawer {
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
:is(.chat-composer-drawer-surface, .chat-composer-top-drawer)[data-variant="error"] {
|
||||
--chat-composer-attached-outline: color-mix(in srgb, var(--error) 32%, transparent);
|
||||
--chat-composer-attached-tint: color-mix(in srgb, var(--error) 8%, transparent);
|
||||
}
|
||||
|
||||
:is(.chat-composer-drawer-surface, .chat-composer-top-drawer)[data-variant="info"] {
|
||||
--chat-composer-attached-outline: color-mix(in srgb, var(--info) 32%, transparent);
|
||||
--chat-composer-attached-tint: color-mix(in srgb, var(--info) 4%, transparent);
|
||||
}
|
||||
|
||||
:is(.chat-composer-drawer-surface, .chat-composer-top-drawer)[data-variant="success"] {
|
||||
--chat-composer-attached-outline: color-mix(in srgb, var(--success) 32%, transparent);
|
||||
--chat-composer-attached-tint: color-mix(in srgb, var(--success) 4%, transparent);
|
||||
}
|
||||
|
||||
:is(.chat-composer-drawer-surface, .chat-composer-top-drawer)[data-variant="warning"] {
|
||||
--chat-composer-attached-outline: color-mix(in srgb, var(--warning) 28%, transparent);
|
||||
--chat-composer-attached-tint: color-mix(in srgb, var(--warning) 8%, transparent);
|
||||
}
|
||||
|
||||
.chat-composer-glass-shell {
|
||||
--chat-composer-attachment-overlap: calc(1rem + 1px);
|
||||
--chat-composer-glass-surface: var(--card);
|
||||
--chat-composer-outline: rgb(0 0 0 / 8%);
|
||||
|
||||
@@ -775,7 +959,83 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
|
||||
content: "";
|
||||
}
|
||||
|
||||
.chat-composer-glass-shell-with-context .chat-composer-glass-host::after {
|
||||
/* A top attachment cannot share the shell's single clipped backdrop: it
|
||||
needs the composer surface and outline to paint in front of its overlap.
|
||||
Split the glass into exact surfaces while a drawer or tab is present; the
|
||||
default composer keeps the cheaper continuous layer. */
|
||||
.chat-composer-glass-shell:is(
|
||||
.chat-composer-glass-shell-attached,
|
||||
:has(:is(.chat-composer-top-drawer, .chat-composer-shoulder-tab))
|
||||
)::before,
|
||||
.chat-composer-glass-shell:is(
|
||||
.chat-composer-glass-shell-attached,
|
||||
:has(:is(.chat-composer-top-drawer, .chat-composer-shoulder-tab))
|
||||
)
|
||||
.chat-composer-glass-host::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.chat-composer-glass-shell:is(
|
||||
.chat-composer-glass-shell-attached,
|
||||
:has(:is(.chat-composer-top-drawer, .chat-composer-shoulder-tab))
|
||||
)
|
||||
.chat-composer-glass-host {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.chat-composer-glass-shell:is(
|
||||
.chat-composer-glass-shell-attached,
|
||||
:has(:is(.chat-composer-top-drawer, .chat-composer-shoulder-tab))
|
||||
)
|
||||
.chat-composer-glass-host
|
||||
[data-chat-composer-main-surface="true"] {
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--chat-composer-glass-surface) var(--glass-opacity),
|
||||
transparent
|
||||
);
|
||||
-webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
|
||||
backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
|
||||
box-shadow: 0 12px 28px -18px rgb(0 0 0 / 40%);
|
||||
|
||||
&::after {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
z-index: 20;
|
||||
inset: 0;
|
||||
border: 1px solid var(--chat-composer-outline);
|
||||
border-radius: inherit;
|
||||
content: "";
|
||||
}
|
||||
|
||||
@variant dark {
|
||||
box-shadow: none;
|
||||
|
||||
&::after {
|
||||
box-shadow: inset 0 1px var(--chat-composer-highlight);
|
||||
}
|
||||
}
|
||||
|
||||
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
|
||||
background: var(--chat-composer-glass-surface);
|
||||
}
|
||||
}
|
||||
|
||||
.chat-composer-glass-shell:is(
|
||||
.chat-composer-glass-shell-attached,
|
||||
:has(.chat-composer-top-drawer)
|
||||
)
|
||||
.chat-composer-glass-host
|
||||
[data-chat-composer-mobile-collapsed="true"] {
|
||||
min-height: var(--chat-composer-attachment-overlap);
|
||||
}
|
||||
|
||||
.chat-composer-glass-shell-with-context .chat-composer-glass-host::after,
|
||||
.chat-composer-glass-shell-with-context:is(
|
||||
.chat-composer-glass-shell-attached,
|
||||
:has(:is(.chat-composer-top-drawer, .chat-composer-shoulder-tab))
|
||||
)
|
||||
[data-chat-composer-main-surface="true"]::after {
|
||||
/* Keep the attachment seam open; the strip continues the outer outline below. */
|
||||
clip-path: polygon(
|
||||
0 0,
|
||||
@@ -822,6 +1082,36 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
|
||||
content: "";
|
||||
}
|
||||
|
||||
.chat-composer-glass-shell:is(
|
||||
.chat-composer-glass-shell-attached,
|
||||
:has(:is(.chat-composer-top-drawer, .chat-composer-shoulder-tab))
|
||||
)
|
||||
.chat-composer-context-strip {
|
||||
&::before {
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--chat-composer-glass-surface) var(--glass-opacity),
|
||||
transparent
|
||||
);
|
||||
-webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
|
||||
backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
|
||||
}
|
||||
|
||||
@variant dark {
|
||||
&::before {
|
||||
background:
|
||||
linear-gradient(
|
||||
to bottom,
|
||||
transparent 0 1rem,
|
||||
rgb(0 0 0 / 18%) 1rem,
|
||||
transparent calc(1rem + 10px)
|
||||
),
|
||||
linear-gradient(rgb(255 255 255 / 2%), rgb(255 255 255 / 2%)),
|
||||
color-mix(in srgb, var(--chat-composer-glass-surface) var(--glass-opacity), transparent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@supports not (clip-path: shape(from 0 0, line to 1px 1px)) {
|
||||
.chat-composer-glass-shell-with-context::before {
|
||||
inset-block-end: var(--chat-composer-context-extension);
|
||||
@@ -1255,6 +1545,26 @@ html[data-theme-id] .chat-composer-glass-shell {
|
||||
}
|
||||
}
|
||||
|
||||
html[data-theme-id]
|
||||
:is(.chat-composer-banner-stack-cap, .chat-composer-drawer-surface, .chat-composer-top-drawer) {
|
||||
--chat-composer-attached-surface: var(--app-theme-surface-raised);
|
||||
}
|
||||
|
||||
html[data-theme-id]
|
||||
:is(.chat-composer-banner-stack-cap, .chat-composer-drawer-surface, .chat-composer-top-drawer):is(
|
||||
:not([data-variant]),
|
||||
[data-variant="default"]
|
||||
) {
|
||||
--chat-composer-attached-outline: var(--chat-composer-outline, var(--app-theme-toolbar-border));
|
||||
|
||||
@variant dark {
|
||||
--chat-composer-attached-outline: var(
|
||||
--chat-composer-outline,
|
||||
color-mix(in srgb, var(--app-theme-input) 30%, var(--background))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
html[data-theme-id="t3-chat"] .chat-composer-glass-shell {
|
||||
/* T3 Chat's visible composer edge is a dark plum, not the stock translucent
|
||||
white outline. Its highlight is derived from --chat-input-gradient. */
|
||||
@@ -1264,6 +1574,16 @@ html[data-theme-id="t3-chat"] .chat-composer-glass-shell {
|
||||
}
|
||||
}
|
||||
|
||||
html[data-theme-id="t3-chat"]
|
||||
:is(.chat-composer-banner-stack-cap, .chat-composer-drawer-surface, .chat-composer-top-drawer):is(
|
||||
:not([data-variant]),
|
||||
[data-variant="default"]
|
||||
) {
|
||||
@variant dark {
|
||||
--chat-composer-attached-outline: #241e28;
|
||||
}
|
||||
}
|
||||
|
||||
/* Theme-token dependency probes are restored synchronously, before paint. Keep
|
||||
transitions from observing the temporary sentinel color in between. */
|
||||
html[data-theme-token-probe],
|
||||
@@ -1933,7 +2253,6 @@ code {
|
||||
#ff6b6b 100%
|
||||
);
|
||||
position: relative;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.ultrathink-frame::before {
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import type { ServerProviderSkill } from "@t3tools/contracts";
|
||||
import { formatProviderSkillDisplayName } from "@t3tools/client-runtime/providerSkills";
|
||||
import {
|
||||
insertRankedSearchResult,
|
||||
normalizeSearchQuery,
|
||||
scoreQueryMatch,
|
||||
} from "@t3tools/shared/searchRanking";
|
||||
|
||||
import { formatProviderSkillDisplayName } from "./providerSkillPresentation";
|
||||
|
||||
function scoreProviderSkill(skill: ServerProviderSkill, query: string): number | null {
|
||||
const normalizedName = skill.name.toLowerCase();
|
||||
const normalizedLabel = formatProviderSkillDisplayName(skill).toLowerCase();
|
||||
|
||||
@@ -408,6 +408,60 @@ describe("deriveActivePlanState", () => {
|
||||
steps: [{ step: "Write tests", status: "completed" }],
|
||||
});
|
||||
});
|
||||
|
||||
it("starts timing again after a plan is cleared and recreated", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "plan-old-start",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
kind: "turn.plan.updated",
|
||||
summary: "Plan updated",
|
||||
tone: "info",
|
||||
turnId: "turn-1",
|
||||
payload: { plan: [{ step: "Check", status: "inProgress" }] },
|
||||
}),
|
||||
makeActivity({
|
||||
id: "plan-old-complete",
|
||||
createdAt: "2026-02-23T00:00:05.000Z",
|
||||
kind: "turn.plan.updated",
|
||||
summary: "Plan updated",
|
||||
tone: "info",
|
||||
turnId: "turn-1",
|
||||
payload: { plan: [{ step: "Check", status: "completed" }] },
|
||||
}),
|
||||
makeActivity({
|
||||
id: "plan-clear",
|
||||
createdAt: "2026-02-23T00:00:06.000Z",
|
||||
kind: "turn.plan.updated",
|
||||
summary: "Plan updated",
|
||||
tone: "info",
|
||||
turnId: "turn-1",
|
||||
payload: { plan: [] },
|
||||
}),
|
||||
makeActivity({
|
||||
id: "plan-new-start",
|
||||
createdAt: "2026-02-23T00:00:10.000Z",
|
||||
kind: "turn.plan.updated",
|
||||
summary: "Plan updated",
|
||||
tone: "info",
|
||||
turnId: "turn-1",
|
||||
payload: { plan: [{ step: "Check", status: "inProgress" }] },
|
||||
}),
|
||||
makeActivity({
|
||||
id: "plan-new-complete",
|
||||
createdAt: "2026-02-23T00:00:13.000Z",
|
||||
kind: "turn.plan.updated",
|
||||
summary: "Plan updated",
|
||||
tone: "info",
|
||||
turnId: "turn-1",
|
||||
payload: { plan: [{ step: "Check", status: "completed" }] },
|
||||
}),
|
||||
];
|
||||
|
||||
expect(deriveActivePlanState(activities, TurnId.make("turn-1"))?.steps).toEqual([
|
||||
{ durationMs: 3_000, step: "Check", status: "completed" },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("deriveTurnPlans", () => {
|
||||
@@ -455,7 +509,9 @@ describe("deriveTurnPlans", () => {
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
turnId: "turn-1",
|
||||
});
|
||||
expect(turnPlans[0]?.plan.steps).toEqual([{ step: "Inspect code", status: "completed" }]);
|
||||
expect(turnPlans[0]?.plan.steps).toEqual([
|
||||
{ durationMs: 4_000, step: "Inspect code", status: "completed" },
|
||||
]);
|
||||
expect(turnPlans[1]?.plan.steps).toEqual([{ step: "Ship it", status: "pending" }]);
|
||||
});
|
||||
|
||||
@@ -474,6 +530,110 @@ describe("deriveTurnPlans", () => {
|
||||
expect(deriveTurnPlans(activities)).toEqual([]);
|
||||
});
|
||||
|
||||
it("tracks repeated step labels independently", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "plan-1a",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
kind: "turn.plan.updated",
|
||||
summary: "Plan updated",
|
||||
tone: "info",
|
||||
turnId: "turn-1",
|
||||
payload: {
|
||||
plan: [
|
||||
{ step: "Check", status: "inProgress" },
|
||||
{ step: "Check", status: "pending" },
|
||||
],
|
||||
},
|
||||
}),
|
||||
makeActivity({
|
||||
id: "plan-1b",
|
||||
createdAt: "2026-02-23T00:00:05.000Z",
|
||||
kind: "turn.plan.updated",
|
||||
summary: "Plan updated",
|
||||
tone: "info",
|
||||
turnId: "turn-1",
|
||||
payload: {
|
||||
plan: [
|
||||
{ step: "Check", status: "completed" },
|
||||
{ step: "Check", status: "inProgress" },
|
||||
],
|
||||
},
|
||||
}),
|
||||
makeActivity({
|
||||
id: "plan-1c",
|
||||
createdAt: "2026-02-23T00:00:11.000Z",
|
||||
kind: "turn.plan.updated",
|
||||
summary: "Plan updated",
|
||||
tone: "info",
|
||||
turnId: "turn-1",
|
||||
payload: {
|
||||
plan: [
|
||||
{ step: "Check", status: "completed" },
|
||||
{ step: "Check", status: "completed" },
|
||||
],
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
expect(deriveTurnPlans(activities)[0]?.plan.steps).toEqual([
|
||||
{ durationMs: 4_000, step: "Check", status: "completed" },
|
||||
{ durationMs: 6_000, step: "Check", status: "completed" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("derives fallback durations in completion order", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "plan-start",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
kind: "turn.plan.updated",
|
||||
summary: "Plan updated",
|
||||
tone: "info",
|
||||
turnId: "turn-1",
|
||||
payload: {
|
||||
plan: [
|
||||
{ step: "First", status: "pending" },
|
||||
{ step: "Second", status: "pending" },
|
||||
],
|
||||
},
|
||||
}),
|
||||
makeActivity({
|
||||
id: "plan-second-complete",
|
||||
createdAt: "2026-02-23T00:00:06.000Z",
|
||||
kind: "turn.plan.updated",
|
||||
summary: "Plan updated",
|
||||
tone: "info",
|
||||
turnId: "turn-1",
|
||||
payload: {
|
||||
plan: [
|
||||
{ step: "First", status: "pending" },
|
||||
{ step: "Second", status: "completed" },
|
||||
],
|
||||
},
|
||||
}),
|
||||
makeActivity({
|
||||
id: "plan-first-complete",
|
||||
createdAt: "2026-02-23T00:00:11.000Z",
|
||||
kind: "turn.plan.updated",
|
||||
summary: "Plan updated",
|
||||
tone: "info",
|
||||
turnId: "turn-1",
|
||||
payload: {
|
||||
plan: [
|
||||
{ step: "First", status: "completed" },
|
||||
{ step: "Second", status: "completed" },
|
||||
],
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
expect(deriveTurnPlans(activities)[0]?.plan.steps).toEqual([
|
||||
{ durationMs: 5_000, step: "First", status: "completed" },
|
||||
{ durationMs: 5_000, step: "Second", status: "completed" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("drops a turn's chip when a later snapshot clears the plan", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
|
||||
@@ -123,6 +123,7 @@ export interface ActivePlanState {
|
||||
turnId: TurnId | null;
|
||||
explanation?: string | null;
|
||||
steps: Array<{
|
||||
durationMs?: number;
|
||||
step: string;
|
||||
status: "pending" | "inProgress" | "completed";
|
||||
}>;
|
||||
@@ -579,6 +580,64 @@ function planStateFromActivity(activity: OrchestrationThreadActivity): ActivePla
|
||||
};
|
||||
}
|
||||
|
||||
function addPlanStepDurations(
|
||||
plan: ActivePlanState,
|
||||
activities: ReadonlyArray<OrchestrationThreadActivity>,
|
||||
): ActivePlanState {
|
||||
const timings = new Map<string, { completedAt?: number; startedAt?: number }>();
|
||||
let planStartedAt: number | undefined;
|
||||
|
||||
const keyedSteps = (steps: ActivePlanState["steps"]) => {
|
||||
const occurrences = new Map<string, number>();
|
||||
return steps.map((step) => {
|
||||
const occurrence = occurrences.get(step.step) ?? 0;
|
||||
occurrences.set(step.step, occurrence + 1);
|
||||
return { key: `${step.step}:${occurrence}`, step };
|
||||
});
|
||||
};
|
||||
|
||||
for (const activity of activities) {
|
||||
const snapshot = planStateFromActivity(activity);
|
||||
const activityAt = Date.parse(activity.createdAt);
|
||||
if (!snapshot || Number.isNaN(activityAt)) continue;
|
||||
planStartedAt ??= activityAt;
|
||||
|
||||
for (const { key, step } of keyedSteps(snapshot.steps)) {
|
||||
const timing = timings.get(key) ?? {};
|
||||
if (step.status === "inProgress" && timing.startedAt === undefined) {
|
||||
timing.startedAt = activityAt;
|
||||
}
|
||||
if (step.status === "completed" && timing.completedAt === undefined) {
|
||||
timing.completedAt = activityAt;
|
||||
}
|
||||
timings.set(key, timing);
|
||||
}
|
||||
}
|
||||
|
||||
const durationByKey = new Map<string, number>();
|
||||
let previousCompletedAt = planStartedAt;
|
||||
for (const [key, timing] of [...timings.entries()].toSorted(
|
||||
(left, right) => (left[1].completedAt ?? Infinity) - (right[1].completedAt ?? Infinity),
|
||||
)) {
|
||||
const completedAt = timing.completedAt;
|
||||
const startedAt = timing.startedAt ?? previousCompletedAt;
|
||||
if (completedAt === undefined) continue;
|
||||
if (startedAt !== undefined && completedAt > startedAt) {
|
||||
durationByKey.set(key, completedAt - startedAt);
|
||||
}
|
||||
previousCompletedAt = completedAt;
|
||||
}
|
||||
|
||||
return {
|
||||
...plan,
|
||||
steps: keyedSteps(plan.steps).map(({ key, step }) => {
|
||||
if (step.status !== "completed") return step;
|
||||
const durationMs = durationByKey.get(key);
|
||||
return durationMs === undefined ? step : { ...step, durationMs };
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
export function deriveActivePlanState(
|
||||
activities: ReadonlyArray<OrchestrationThreadActivity>,
|
||||
latestTurnId: TurnId | undefined,
|
||||
@@ -596,7 +655,15 @@ export function deriveActivePlanState(
|
||||
if (!latest) {
|
||||
return null;
|
||||
}
|
||||
return planStateFromActivity(latest);
|
||||
const plan = planStateFromActivity(latest);
|
||||
if (!plan) return null;
|
||||
const matchingActivities = allPlanActivities.filter(
|
||||
(activity) => activity.turnId === latest.turnId,
|
||||
);
|
||||
const latestClearIndex = matchingActivities.findLastIndex(
|
||||
(activity) => planStateFromActivity(activity) === null,
|
||||
);
|
||||
return addPlanStepDurations(plan, matchingActivities.slice(latestClearIndex + 1));
|
||||
}
|
||||
|
||||
export interface TurnPlanEntry {
|
||||
@@ -617,7 +684,10 @@ export function deriveTurnPlans(
|
||||
activities: ReadonlyArray<OrchestrationThreadActivity>,
|
||||
): TurnPlanEntry[] {
|
||||
const ordered = [...activities].toSorted(compareActivitiesByOrder);
|
||||
const byTurn = new Map<string, TurnPlanEntry>();
|
||||
const byTurn = new Map<
|
||||
string,
|
||||
{ activities: OrchestrationThreadActivity[]; entry: TurnPlanEntry }
|
||||
>();
|
||||
for (const activity of ordered) {
|
||||
if (activity.kind !== "turn.plan.updated") {
|
||||
continue;
|
||||
@@ -632,17 +702,24 @@ export function deriveTurnPlans(
|
||||
}
|
||||
const existing = byTurn.get(key);
|
||||
if (existing) {
|
||||
existing.plan = plan;
|
||||
existing.entry.plan = plan;
|
||||
existing.activities.push(activity);
|
||||
} else {
|
||||
byTurn.set(key, {
|
||||
id: `turn-plan:${key}`,
|
||||
createdAt: activity.createdAt,
|
||||
turnId: activity.turnId,
|
||||
plan,
|
||||
activities: [activity],
|
||||
entry: {
|
||||
id: `turn-plan:${key}`,
|
||||
createdAt: activity.createdAt,
|
||||
turnId: activity.turnId,
|
||||
plan,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
return [...byTurn.values()];
|
||||
return [...byTurn.values()].map(({ activities: planActivities, entry }) => ({
|
||||
...entry,
|
||||
plan: addPlanStepDurations(entry.plan, planActivities),
|
||||
}));
|
||||
}
|
||||
|
||||
export function findLatestProposedPlan(
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
"types": "./src/platform/index.ts",
|
||||
"default": "./src/platform/index.ts"
|
||||
},
|
||||
"./providerSkills": {
|
||||
"types": "./src/providerSkills.ts",
|
||||
"default": "./src/providerSkills.ts"
|
||||
},
|
||||
"./relay": {
|
||||
"types": "./src/relay/index.ts",
|
||||
"default": "./src/relay/index.ts"
|
||||
|
||||
+38
-18
@@ -2,8 +2,8 @@ import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
formatProviderSkillDisplayName,
|
||||
formatProviderSkillInstallSource,
|
||||
} from "./providerSkillPresentation";
|
||||
resolveProviderSkillSourceKind,
|
||||
} from "./providerSkills.ts";
|
||||
|
||||
describe("formatProviderSkillDisplayName", () => {
|
||||
it("prefers the provider display name", () => {
|
||||
@@ -24,34 +24,54 @@ describe("formatProviderSkillDisplayName", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatProviderSkillInstallSource", () => {
|
||||
describe("resolveProviderSkillSourceKind", () => {
|
||||
it("marks plugin-backed skills as app installs", () => {
|
||||
expect(
|
||||
formatProviderSkillInstallSource({
|
||||
resolveProviderSkillSourceKind({
|
||||
path: "/Users/julius/.codex/plugins/cache/openai-curated/github/skills/gh-fix-ci/SKILL.md",
|
||||
scope: "user",
|
||||
}),
|
||||
).toBe("App");
|
||||
).toBe("app");
|
||||
});
|
||||
|
||||
it("maps standard scopes to user-facing labels", () => {
|
||||
it("maps standard scopes to source kinds", () => {
|
||||
expect(
|
||||
formatProviderSkillInstallSource({
|
||||
path: "/Users/julius/.agents/skills/agent-browser/SKILL.md",
|
||||
scope: "user",
|
||||
resolveProviderSkillSourceKind({
|
||||
path: "/workspace/.codex/skills/review-follow-up/SKILL.md",
|
||||
scope: "repo",
|
||||
}),
|
||||
).toBe("Personal");
|
||||
).toBe("repo");
|
||||
expect(
|
||||
formatProviderSkillInstallSource({
|
||||
path: "/usr/local/share/codex/skills/imagegen/SKILL.md",
|
||||
scope: "system",
|
||||
}),
|
||||
).toBe("System");
|
||||
expect(
|
||||
formatProviderSkillInstallSource({
|
||||
resolveProviderSkillSourceKind({
|
||||
path: "/workspace/.codex/skills/review-follow-up/SKILL.md",
|
||||
scope: "project",
|
||||
}),
|
||||
).toBe("Project");
|
||||
).toBe("project");
|
||||
expect(
|
||||
resolveProviderSkillSourceKind({
|
||||
path: "/Users/julius/.agents/skills/agent-browser/SKILL.md",
|
||||
scope: "user",
|
||||
}),
|
||||
).toBe("personal");
|
||||
expect(
|
||||
resolveProviderSkillSourceKind({
|
||||
path: "/usr/local/share/codex/skills/imagegen/SKILL.md",
|
||||
scope: "system",
|
||||
}),
|
||||
).toBe("system");
|
||||
});
|
||||
|
||||
it("keeps unknown and missing scopes usable", () => {
|
||||
expect(
|
||||
resolveProviderSkillSourceKind({
|
||||
path: "/opt/skills/team-review/SKILL.md",
|
||||
scope: "team_shared",
|
||||
}),
|
||||
).toBe("other");
|
||||
expect(
|
||||
resolveProviderSkillSourceKind({
|
||||
path: "/opt/skills/team-review/SKILL.md",
|
||||
}),
|
||||
).toBe("other");
|
||||
});
|
||||
});
|
||||
+23
-20
@@ -1,5 +1,7 @@
|
||||
import type { ServerProviderSkill } from "@t3tools/contracts";
|
||||
|
||||
export type ProviderSkillSourceKind = "app" | "repo" | "project" | "personal" | "system" | "other";
|
||||
|
||||
function titleCaseWords(value: string): string {
|
||||
const words: string[] = [];
|
||||
for (const segment of value.split(/[\s:_-]+/)) {
|
||||
@@ -23,31 +25,32 @@ export function formatProviderSkillDisplayName(
|
||||
return titleCaseWords(skill.name);
|
||||
}
|
||||
|
||||
export function formatProviderSkillInstallSource(
|
||||
export function resolveProviderSkillSourceKind(
|
||||
skill: Pick<ServerProviderSkill, "path" | "scope">,
|
||||
): string | null {
|
||||
): ProviderSkillSourceKind {
|
||||
const normalizedPath = normalizePathSeparators(skill.path);
|
||||
if (normalizedPath.includes("/.codex/plugins/") || normalizedPath.includes("/.agents/plugins/")) {
|
||||
return "App";
|
||||
return "app";
|
||||
}
|
||||
|
||||
const normalizedScope = skill.scope?.trim().toLowerCase();
|
||||
if (normalizedScope === "system") {
|
||||
return "System";
|
||||
switch (normalizedScope) {
|
||||
case "repo":
|
||||
case "repository":
|
||||
return "repo";
|
||||
case "project":
|
||||
case "workspace":
|
||||
case "local":
|
||||
return "project";
|
||||
case "user":
|
||||
case "personal":
|
||||
return "personal";
|
||||
case "system":
|
||||
return "system";
|
||||
case undefined:
|
||||
case "":
|
||||
return "other";
|
||||
default:
|
||||
return "other";
|
||||
}
|
||||
if (
|
||||
normalizedScope === "project" ||
|
||||
normalizedScope === "workspace" ||
|
||||
normalizedScope === "local"
|
||||
) {
|
||||
return "Project";
|
||||
}
|
||||
if (normalizedScope === "user" || normalizedScope === "personal") {
|
||||
return "Personal";
|
||||
}
|
||||
if (normalizedScope) {
|
||||
return titleCaseWords(normalizedScope);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in new issue
Block a user