Compare commits

...
Author SHA1 Message Date
Julius Marmingeandcodex ee44f639a3 handle partial grouped project removal
Co-authored-by: codex <[email protected]>
2026-07-23 14:53:57 +02:00
Julius Marmingeandcodex ebb4fa0b56 fix grouped project menu actions
Co-authored-by: codex <[email protected]>
2026-07-23 14:31:48 +02:00
Julius Marmingeandcodex 2e484a2707 restore grouped project sorter import
Co-authored-by: codex <[email protected]>
2026-07-23 14:22:07 +02:00
Julius Marmingeandcodex a4061ce9ad fix grouped project callback dependency
Co-authored-by: codex <[email protected]>
2026-07-23 14:20:20 +02:00
Julius Marmingeandcodex ce8d699b9e restore grouped projects in Sidebar V2
Co-authored-by: codex <[email protected]>
2026-07-23 14:20:20 +02:00
Julius Marmingeandcodex 4d83436415 Unify dialog glass and fix composer overlays (#4365)
Co-authored-by: codex <[email protected]>
2026-07-23 14:15:29 +02:00
Julius Marminge e51538b812 Restore light-mode surfaces and refine dialog styling
- Restore light-mode glass, dialog, dropdown, and composer colors
- Refine provider wizard, changed-file cards, sidebar controls, and buttons
- Update wizard step tests for the new list structure
2026-07-23 13:09:55 +02:00
24 changed files with 706 additions and 315 deletions

No files matched your search

+3 -3
View File
@@ -5561,7 +5561,7 @@ function ChatViewContent(props: ChatViewProps) {
ref={attachDraftHeroTransitionGroupRef}
className="chat-composer-horizontal-inset w-full"
>
<div className="pointer-events-auto relative z-10 isolate">
<div className="pointer-events-auto relative z-10">
{isDraftHeroState ? (
<div className="absolute inset-x-0 bottom-full z-0">
<div
@@ -5592,8 +5592,8 @@ function ChatViewContent(props: ChatViewProps) {
: undefined
}
>
<div className="chat-composer-glass-host mx-auto w-full max-w-3xl overflow-hidden rounded-[22px]">
<div ref={attachDraftHeroComposerAnchorRef} className="relative z-10 isolate">
<div className="chat-composer-glass-host mx-auto w-full max-w-3xl rounded-[22px]">
<div ref={attachDraftHeroComposerAnchorRef} className="relative z-10">
<ChatComposer
composerRef={composerRef}
composerDraftTarget={composerDraftTarget}
+9 -20
View File
@@ -544,10 +544,7 @@ function PublishRepositoryDialog(props: PublishRepositoryDialogProps) {
return (
<Dialog open={props.open} onOpenChange={handleOpenChange}>
<DialogPopup
backdropClassName="bg-black/40 backdrop-blur-none"
className="workflow-dialog-surface max-w-xl overflow-hidden before:hidden"
>
<DialogPopup className="max-w-xl overflow-hidden">
<div className="flex min-h-0 flex-col overflow-hidden border-foreground/10 bg-transparent">
<DialogHeader className="border-b border-border/70 bg-foreground/[0.025] dark:border-transparent dark:bg-transparent">
<DialogTitle>Publish repository</DialogTitle>
@@ -1828,16 +1825,13 @@ export default function GitActionsControl({
}
}}
>
<DialogPopup
backdropClassName="bg-black/40 backdrop-blur-none"
className="command-palette-dialog-surface workflow-dialog-surface before:hidden"
>
<DialogPopup>
<DialogHeader>
<DialogTitle>{COMMIT_DIALOG_TITLE}</DialogTitle>
<DialogDescription>{COMMIT_DIALOG_DESCRIPTION}</DialogDescription>
</DialogHeader>
<DialogPanel className="space-y-4">
<div className="space-y-3 rounded-lg border border-input bg-muted/40 p-3 text-xs dark:border-transparent dark:bg-white/[0.035]">
<div className="space-y-3 rounded-xl bg-zinc-25 p-3 text-sm ring-1 ring-black/5 dark:bg-white/[0.035] dark:ring-white/5">
<div className="grid grid-cols-[auto_1fr] items-center gap-x-2 gap-y-1">
<span className="text-muted-foreground">Branch</span>
<span className="flex items-center justify-between gap-2">
@@ -1845,9 +1839,7 @@ export default function GitActionsControl({
{gitStatusForActions?.refName ?? "(detached HEAD)"}
</span>
{isDefaultRef && (
<span className="text-right text-warning text-xs">
Warning: default refName
</span>
<span className="text-right text-warning">Warning: default refName</span>
)}
</span>
</div>
@@ -1886,14 +1878,14 @@ export default function GitActionsControl({
<p className="font-medium">none</p>
) : (
<div className="space-y-2">
<ScrollArea className="h-44 rounded-md border border-input bg-background dark:border-transparent dark:bg-white/[0.025]">
<ScrollArea className="h-44 rounded-lg bg-card ring-1 ring-black/5 dark:bg-white/[0.025] dark:ring-white/5">
<div className="space-y-1 p-1">
{allFiles.map((file) => {
const isExcluded = excludedFiles.has(file.path);
return (
<div
key={file.path}
className="flex w-full items-center gap-2 rounded-md px-2 py-1 font-mono text-xs transition-colors hover:bg-accent/50"
className="flex w-full items-center gap-2 rounded-md px-2 py-1 font-mono hover:bg-accent/50"
>
{isEditingFiles && (
<Checkbox
@@ -1952,7 +1944,7 @@ export default function GitActionsControl({
</div>
</div>
<div className="space-y-1">
<p className="text-xs font-medium">Commit message (optional)</p>
<p className="text-sm font-medium">Commit message (optional)</p>
<Textarea
value={dialogCommitMessage}
onChange={(event) => setDialogCommitMessage(event.target.value)}
@@ -1961,7 +1953,7 @@ export default function GitActionsControl({
/>
</div>
</DialogPanel>
<DialogFooter className="dark:border-transparent dark:bg-transparent">
<DialogFooter variant="bare">
<Button
variant="outline"
size="sm"
@@ -2004,10 +1996,7 @@ export default function GitActionsControl({
}
}}
>
<DialogPopup
backdropClassName="bg-black/40 backdrop-blur-none"
className="workflow-dialog-surface max-w-xl before:hidden"
>
<DialogPopup className="max-w-xl">
<DialogHeader>
<DialogTitle>
{pendingDefaultBranchActionCopy?.title ?? "Run action on default refName?"}
@@ -461,7 +461,7 @@ export default function ProjectScriptsControl({
}}
open={dialogOpen}
>
<DialogPopup className="before:hidden">
<DialogPopup>
<DialogHeader>
<DialogTitle>{isEditing ? "Edit Action" : "Add Action"}</DialogTitle>
<DialogDescription>
@@ -22,6 +22,7 @@ import {
resolveThreadStatusPill,
shouldNavigateAfterProjectRemoval,
shouldClearThreadSelectionOnMouseDown,
sortLogicalProjectsForSidebar,
sortThreadsForSidebarV2,
sortProjectsForSidebar,
sortScopedProjectsForSidebar,
@@ -1353,3 +1354,40 @@ describe("sortScopedProjectsForSidebar", () => {
]);
});
});
describe("sortLogicalProjectsForSidebar", () => {
it("uses saved order only in manual mode and activity order otherwise", () => {
const olderProjectId = ProjectId.make("project-older");
const newerProjectId = ProjectId.make("project-newer");
const projects = [
{
...makeProject({ id: olderProjectId, title: "Older project" }),
projectKey: "logical-older",
memberProjectRefs: [{ environmentId: localEnvironmentId, projectId: olderProjectId }],
},
{
...makeProject({ id: newerProjectId, title: "Newer project" }),
projectKey: "logical-newer",
memberProjectRefs: [{ environmentId: localEnvironmentId, projectId: newerProjectId }],
},
];
const threads = [
makeThread({
projectId: olderProjectId,
updatedAt: "2026-03-09T10:01:00.000Z",
}),
makeThread({
id: ThreadId.make("thread-newer"),
projectId: newerProjectId,
updatedAt: "2026-03-09T10:05:00.000Z",
}),
];
expect(sortLogicalProjectsForSidebar(projects, threads, "manual")).toEqual(projects);
expect(
sortLogicalProjectsForSidebar(projects, threads, "updated_at").map(
(project) => project.projectKey,
),
).toEqual(["logical-newer", "logical-older"]);
});
});
+46
View File
@@ -36,6 +36,14 @@ type ScopedSidebarThread = ThreadSortInput & {
archivedAt: string | null;
};
type LogicalSidebarProject = SidebarProject & {
projectKey: string;
memberProjectRefs: readonly {
environmentId: string;
projectId: string;
}[];
};
export type ThreadTraversalDirection = "previous" | "next";
export async function archiveSelectedThreadEntries<
@@ -727,6 +735,44 @@ export function sortProjectsForSidebar<
);
}
export function sortLogicalProjectsForSidebar<
TProject extends LogicalSidebarProject,
TThread extends ScopedSidebarThread,
>(
projects: readonly TProject[],
threads: readonly TThread[],
sortOrder: SidebarProjectSortOrder,
): TProject[] {
const groupKeyByProjectRef = new Map(
projects.flatMap((project) =>
project.memberProjectRefs.map(
(projectRef) =>
[`${projectRef.environmentId}\0${projectRef.projectId}`, project.projectKey] as const,
),
),
);
const threadsByProjectKey = new Map<string, TThread[]>();
for (const thread of threads) {
if (thread.archivedAt !== null) continue;
const projectKey = groupKeyByProjectRef.get(`${thread.environmentId}\0${thread.projectId}`);
if (!projectKey) continue;
const existing = threadsByProjectKey.get(projectKey);
if (existing) {
existing.push(thread);
} else {
threadsByProjectKey.set(projectKey, [thread]);
}
}
return sortProjectsByActivity(
projects,
sortOrder,
(project) => threadsByProjectKey.get(project.projectKey) ?? [],
(left, right) =>
left.title.localeCompare(right.title) || left.projectKey.localeCompare(right.projectKey),
);
}
/**
* Sorts the cross-environment project collection used by landing surfaces.
* Project ids are only unique within an environment, and archived threads
+151 -81
View File
@@ -1,10 +1,7 @@
import { autoAnimate } from "@formkit/auto-animate";
import { useAtomValue } from "@effect/atom-react";
import { effectiveSettled } from "@t3tools/client-runtime/state/thread-settled";
import type {
EnvironmentProject,
EnvironmentThreadShell,
} from "@t3tools/client-runtime/state/models";
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/models";
import {
scopeProjectRef,
scopeThreadRef,
@@ -61,7 +58,12 @@ import { selectThreadTerminalUiState, useTerminalUiStateStore } from "../termina
import { isMacPlatform } from "~/lib/utils";
import { useOpenPrLink } from "../lib/openPullRequestLink";
import { readLocalApi } from "../localApi";
import { useUiStateStore } from "../uiStateStore";
import { getProjectOrderKey, selectProjectGroupingSettings } from "../logicalProject";
import {
buildSidebarProjectSnapshots,
type SidebarProjectSnapshot,
} from "../sidebarProjectGrouping";
import { legacyProjectCwdPreferenceKey, useUiStateStore } from "../uiStateStore";
import { useThreadSelectionStore } from "../threadSelectionStore";
import { useThreadActions } from "../hooks/useThreadActions";
import { useHandleNewThread } from "../hooks/useHandleNewThread";
@@ -84,9 +86,11 @@ import {
firstValidTimestampMs,
hasUnseenCompletion,
isTrailingDoubleClick,
orderItemsByPreferredIds,
resolveAdjacentThreadId,
resolveSidebarV2Status,
shouldNavigateAfterProjectRemoval,
sortLogicalProjectsForSidebar,
sortThreadsForSidebarV2,
} from "./Sidebar.logic";
import { resolveLocalCheckoutBranchMismatch } from "./BranchToolbar.logic";
@@ -677,13 +681,13 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
<span className="text-red-600 dark:text-red-400">−{diff.deletions}</span>
</span>
) : null}
<span className="ml-auto inline-flex shrink-0 items-center gap-1">
<span
aria-hidden
className="pointer-events-none ml-auto inline-flex shrink-0 items-center gap-1"
>
{isRemote ? (
<span
aria-label={props.environmentLabel ?? "Remote environment"}
className="inline-flex shrink-0 items-center text-sidebar-muted-foreground/70"
>
<ServerIcon aria-hidden className="size-4" />
<span className="inline-flex shrink-0 items-center text-sidebar-muted-foreground/70">
<ServerIcon aria-hidden className="size-3.5" />
</span>
) : null}
{driverKind ? (
@@ -691,7 +695,7 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
<ProviderInstanceIcon
driverKind={driverKind}
displayName={thread.session?.providerName ?? modelInstanceId}
iconClassName="size-4"
iconClassName="size-3.5"
/>
</span>
) : null}
@@ -716,12 +720,15 @@ function latestTurnDiff(
export default function SidebarV2() {
const projects = useProjects();
const projectOrder = useUiStateStore((store) => store.projectOrder);
const threads = useThreadShells();
const router = useRouter();
const { isMobile, setOpenMobile } = useSidebar();
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
const autoSettleAfterDays = useClientSettings((s) => s.sidebarAutoSettleAfterDays);
const confirmThreadDelete = useClientSettings((s) => s.confirmThreadDelete);
const sidebarProjectSortOrder = useClientSettings((s) => s.sidebarProjectSortOrder);
const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings);
const { settleThread, unsettleThread, deleteThread } = useThreadActions();
const updateThreadMetadata = useAtomCommand(threadEnvironment.updateMetadata, {
reportFailure: false,
@@ -762,6 +769,40 @@ export default function SidebarV2() {
),
[environments],
);
const orderedProjects = useMemo(
() =>
orderItemsByPreferredIds({
items: projects,
preferredIds: projectOrder,
getId: getProjectOrderKey,
getPreferenceIds: (project) => [
getProjectOrderKey(project),
legacyProjectCwdPreferenceKey(project.workspaceRoot),
],
}),
[projectOrder, projects],
);
const unsortedProjectGroups = useMemo(
() =>
buildSidebarProjectSnapshots({
projects: sidebarProjectSortOrder === "manual" ? orderedProjects : projects,
settings: projectGroupingSettings,
primaryEnvironmentId,
resolveEnvironmentLabel: (environmentId) => environmentLabelById.get(environmentId) ?? null,
}),
[
environmentLabelById,
orderedProjects,
primaryEnvironmentId,
projectGroupingSettings,
projects,
sidebarProjectSortOrder,
],
);
const projectGroups = useMemo(
() => sortLogicalProjectsForSidebar(unsortedProjectGroups, threads, sidebarProjectSortOrder),
[sidebarProjectSortOrder, threads, unsortedProjectGroups],
);
const serverProviders = useAtomValue(primaryServerProvidersAtom);
const providerEntryByInstanceId = useMemo(
() =>
@@ -823,23 +864,29 @@ export default function SidebarV2() {
// Project scope: one menu above the list. Scoping filters the list without
// making the header width depend on the number or length of project names.
const [projectScopeKey, setProjectScopeKey] = useState<string | null>(null);
const scopedProject = useMemo(
const scopedProjectGroup = useMemo(
() =>
projectScopeKey === null
? null
: (projects.find(
(project) => `${project.environmentId}:${project.id}` === projectScopeKey,
) ?? null),
[projectScopeKey, projects],
: (projectGroups.find((project) => project.projectKey === projectScopeKey) ?? null),
[projectGroups, projectScopeKey],
);
const scopedProjectKeys = useMemo(
() =>
scopedProjectGroup === null
? null
: new Set(
scopedProjectGroup.memberProjectRefs.map(
(projectRef) => `${projectRef.environmentId}:${projectRef.projectId}`,
),
),
[scopedProjectGroup],
);
useEffect(() => {
if (
projectScopeKey !== null &&
!projects.some((project) => `${project.environmentId}:${project.id}` === projectScopeKey)
) {
if (projectScopeKey !== null && scopedProjectGroup === null) {
setProjectScopeKey(null);
}
}, [projectScopeKey, projects]);
}, [projectScopeKey, scopedProjectGroup]);
// Scope flips drop the selection: rows selected under the old scope may be
// hidden now, and bulk actions must never count or touch invisible rows.
useEffect(() => {
@@ -847,66 +894,90 @@ export default function SidebarV2() {
}, [clearSelection, projectScopeKey]);
const handleRemoveProject = useCallback(
async (project: EnvironmentProject) => {
async (projectGroup: SidebarProjectSnapshot) => {
const api = readLocalApi();
if (!api) return;
const projectThreads = threads.filter(
(thread) =>
thread.environmentId === project.environmentId && thread.projectId === project.id,
const memberKeys = new Set(
projectGroup.memberProjectRefs.map(
(projectRef) => `${projectRef.environmentId}:${projectRef.projectId}`,
),
);
const projectThreads = threads.filter((thread) =>
memberKeys.has(`${thread.environmentId}:${thread.projectId}`),
);
const confirmed = await settlePromise(() =>
api.dialogs.confirm(
projectThreads.length > 0
? [
`Remove project "${project.title}" and delete its ${projectThreads.length} thread${projectThreads.length === 1 ? "" : "s"}?`,
`Path: ${project.workspaceRoot}`,
`Remove project "${projectGroup.displayName}" and delete its ${projectThreads.length} thread${projectThreads.length === 1 ? "" : "s"}?`,
...(projectGroup.memberProjects.length === 1
? [`Path: ${projectGroup.workspaceRoot}`]
: [
`This removes ${projectGroup.memberProjects.length} grouped project entries.`,
]),
"This permanently clears conversation history for those threads.",
"This removes only the project entry, not the files on disk.",
"This removes only the project entries, not the files on disk.",
"This action cannot be undone.",
].join("\n")
: [
`Remove project "${project.title}"?`,
`Path: ${project.workspaceRoot}`,
"This removes only the project entry, not the files on disk.",
`Remove project "${projectGroup.displayName}"?`,
...(projectGroup.memberProjects.length === 1
? [`Path: ${projectGroup.workspaceRoot}`]
: [
`This removes ${projectGroup.memberProjects.length} grouped project entries.`,
]),
"This removes only the project entries, not the files on disk.",
].join("\n"),
),
);
if (confirmed._tag === "Failure" || !confirmed.value) return;
const projectRef = scopeProjectRef(project.environmentId, project.id);
const result = await deleteProject({
environmentId: project.environmentId,
input: {
projectId: project.id,
...(projectThreads.length > 0 ? { force: true } : {}),
},
});
if (result._tag === "Failure") {
if (!isAtomCommandInterrupted(result)) {
const error = squashAtomCommandFailure(result);
toastManager.add(
stackedThreadToast({
type: "error",
title: `Failed to remove "${project.title}"`,
description: error instanceof Error ? error.message : "An error occurred.",
}),
);
}
return;
}
const draftStore = useComposerDraftStore.getState();
const projectDraftThread = draftStore.getDraftThreadByProjectRef(projectRef);
const shouldNavigate = shouldNavigateAfterProjectRemoval({
routeTarget: routeTargetRef.current,
projectThreads,
projectDraftId: projectDraftThread?.draftId ?? null,
});
if (projectDraftThread) {
draftStore.clearDraftThread(projectDraftThread.draftId);
let shouldNavigate = false;
for (const project of projectGroup.memberProjects) {
const memberThreads = projectThreads.filter(
(thread) =>
thread.environmentId === project.environmentId && thread.projectId === project.id,
);
const projectRef = scopeProjectRef(project.environmentId, project.id);
const projectDraftThread = draftStore.getDraftThreadByProjectRef(projectRef);
const memberRemovalNeedsNavigation = shouldNavigateAfterProjectRemoval({
routeTarget: routeTargetRef.current,
projectThreads: memberThreads,
projectDraftId: projectDraftThread?.draftId ?? null,
});
const result = await deleteProject({
environmentId: project.environmentId,
input: {
projectId: project.id,
...(memberThreads.length > 0 ? { force: true } : {}),
},
});
if (result._tag === "Failure") {
if (!isAtomCommandInterrupted(result)) {
const error = squashAtomCommandFailure(result);
toastManager.add(
stackedThreadToast({
type: "error",
title: `Failed to remove "${project.title}"`,
description: error instanceof Error ? error.message : "An error occurred.",
}),
);
}
if (shouldNavigate) {
void router.navigate({ to: "/" });
}
return;
}
shouldNavigate ||= memberRemovalNeedsNavigation;
if (projectDraftThread) {
draftStore.clearDraftThread(projectDraftThread.draftId);
}
draftStore.clearProjectDraftThreadId(projectRef);
}
draftStore.clearProjectDraftThreadId(projectRef);
if (shouldNavigate) {
void router.navigate({ to: "/" });
@@ -925,9 +996,8 @@ export default function SidebarV2() {
const visible = threads.filter(
(thread) =>
thread.archivedAt === null &&
(scopedProject === null ||
(thread.environmentId === scopedProject.environmentId &&
thread.projectId === scopedProject.id)),
(scopedProjectKeys === null ||
scopedProjectKeys.has(`${thread.environmentId}:${thread.projectId}`)),
);
const active: EnvironmentThreadShell[] = [];
const settled: EnvironmentThreadShell[] = [];
@@ -961,7 +1031,7 @@ export default function SidebarV2() {
autoSettleAfterDays,
changeRequestStateByKey,
nowMinute,
scopedProject,
scopedProjectKeys,
serverConfigs,
threads,
]);
@@ -1479,7 +1549,7 @@ export default function SidebarV2() {
// for multi-project setups.
const handleNewThreadClick = useCallback(() => {
// One project: nothing to pick, create immediately.
if (projects.length <= 1) {
if (projectGroups.length <= 1) {
if (isMobile) setOpenMobile(false);
void startNewThreadFromContext({
activeDraftThread: newThreadContext.activeDraftThread,
@@ -1491,7 +1561,7 @@ export default function SidebarV2() {
}
if (isMobile) setOpenMobile(false);
openCommandPalette({ open: "new-thread-in" });
}, [isMobile, newThreadContext, projects.length, setOpenMobile]);
}, [isMobile, newThreadContext, projectGroups.length, setOpenMobile]);
const commandPaletteShortcutLabel = shortcutLabelForCommand(keybindings, "commandPalette.toggle");
// Same resolution as v1: prefer the local-thread binding, fall back to
@@ -1553,7 +1623,7 @@ export default function SidebarV2() {
</div>
</div>
</SidebarGroup>
{projects.length > 0 ? (
{projectGroups.length > 0 ? (
<SidebarGroup className="px-2 pb-2 pt-0">
<div className="flex items-center gap-1">
<Menu>
@@ -1561,17 +1631,17 @@ export default function SidebarV2() {
aria-label="Filter threads by project"
className="flex h-8 min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-md px-2 text-left text-sm font-medium text-sidebar-muted-foreground outline-none hover:bg-sidebar-row-hover hover:text-sidebar-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-sidebar"
>
{scopedProject ? (
{scopedProjectGroup ? (
<ProjectFavicon
environmentId={scopedProject.environmentId}
cwd={scopedProject.workspaceRoot}
environmentId={scopedProjectGroup.environmentId}
cwd={scopedProjectGroup.workspaceRoot}
className="size-4 shrink-0"
/>
) : (
<FolderIcon className="size-4 shrink-0 text-sidebar-muted-foreground/80" />
)}
<span className="min-w-0 flex-1 truncate">
{scopedProject?.title ?? "All projects"}
{scopedProjectGroup?.displayName ?? "All projects"}
</span>
<ChevronDownIcon className="size-4 shrink-0 text-sidebar-muted-foreground/70" />
</MenuTrigger>
@@ -1590,8 +1660,8 @@ export default function SidebarV2() {
<FolderIcon className="size-4 shrink-0" />
<span className="min-w-0 truncate text-sm">All projects</span>
</MenuRadioItem>
{projects.map((project) => {
const scopeKey = `${project.environmentId}:${project.id}`;
{projectGroups.map((project) => {
const scopeKey = project.projectKey;
return (
<MenuRadioItem
key={scopeKey}
@@ -1604,11 +1674,11 @@ export default function SidebarV2() {
cwd={project.workspaceRoot}
className="size-4 shrink-0"
/>
<span className="min-w-0 truncate text-sm">{project.title}</span>
<span className="min-w-0 truncate text-sm">{project.displayName}</span>
<button
type="button"
aria-label={`Remove project ${project.title}`}
title={`Remove ${project.title}`}
aria-label={`Remove project ${project.displayName}`}
title={`Remove ${project.displayName}`}
className="ml-auto inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground/55 outline-none transition-colors hover:bg-destructive/12 hover:text-destructive focus-visible:bg-destructive/12 focus-visible:text-destructive focus-visible:ring-2 focus-visible:ring-destructive/40"
onPointerDown={(event) => event.stopPropagation()}
onClick={(event) => {
@@ -1766,8 +1836,8 @@ export default function SidebarV2() {
Add project
</button>
</>
) : scopedProject ? (
`No threads in ${scopedProject.title} yet`
) : scopedProjectGroup ? (
`No threads in ${scopedProjectGroup.displayName} yet`
) : (
"No threads yet"
)}
@@ -41,8 +41,8 @@ export const ChangedFilesCard = memo(function ChangedFilesCard(props: {
const summaryStat = useMemo(() => summarizeTurnDiffStats(files), [files]);
return (
<div className="mt-4 rounded-2xl bg-background p-2 pt-4 shadow-xs/5 not-dark:bg-clip-padding dark:bg-input/32">
<div className="sticky top-0 z-10 mb-3 flex items-center justify-between gap-2 bg-background px-2 before:absolute before:inset-x-0 before:-top-4 before:h-4 before:bg-background before:content-[''] dark:bg-[color-mix(in_srgb,var(--foreground)_2.5%,var(--background))] dark:before:bg-[color-mix(in_srgb,var(--foreground)_2.5%,var(--background))]">
<div className="mt-4 rounded-2xl border border-border/70 bg-secondary p-2 pt-4 dark:border-transparent dark:bg-input/32">
<div className="sticky top-0 z-10 mb-3 flex items-center justify-between gap-2 bg-secondary px-2 before:absolute before:inset-x-0 before:-top-4 before:h-4 before:bg-secondary before:content-[''] dark:bg-[color-mix(in_srgb,var(--foreground)_2.5%,var(--background))] dark:before:bg-[color-mix(in_srgb,var(--foreground)_2.5%,var(--background))]">
<p className="flex items-center gap-1 whitespace-nowrap font-medium text-foreground text-xs leading-4">
<span>
{files.length} changed file{files.length === 1 ? "" : "s"}
+64 -2
View File
@@ -26,6 +26,7 @@ import { serializeComposerFileLink } from "@t3tools/shared/composerTrigger";
import { createModelSelection, normalizeModelSlug } from "@t3tools/shared/model";
import {
memo,
type ReactNode,
useCallback,
useEffect,
useImperativeHandle,
@@ -34,6 +35,7 @@ import {
useRef,
useState,
} from "react";
import { createPortal } from "react-dom";
import {
clampCollapsedComposerCursor,
type ComposerTrigger,
@@ -93,6 +95,64 @@ import { buildExpandedImagePreview, type ExpandedImagePreview } from "./Expanded
import { basenameOfPath } from "../../pierre-icons";
import { cn, randomUUID } from "~/lib/utils";
import { Separator } from "../ui/separator";
function ComposerCommandMenuLayer(props: { anchor: HTMLElement | null; children: ReactNode }) {
const [position, setPosition] = useState<{
bottom: number;
left: number;
maxHeight: number;
width: number;
} | null>(null);
useLayoutEffect(() => {
const anchor = props.anchor;
if (!anchor) {
setPosition(null);
return;
}
const updatePosition = () => {
const rect = anchor.getBoundingClientRect();
setPosition({
bottom: window.innerHeight - rect.top + 8,
left: rect.left,
maxHeight: Math.max(96, rect.top - 24),
width: rect.width,
});
};
updatePosition();
window.addEventListener("resize", updatePosition);
window.addEventListener("scroll", updatePosition, true);
const observer =
typeof ResizeObserver === "undefined" ? null : new ResizeObserver(updatePosition);
observer?.observe(anchor);
return () => {
observer?.disconnect();
window.removeEventListener("resize", updatePosition);
window.removeEventListener("scroll", updatePosition, true);
};
}, [props.anchor]);
if (!position) return null;
return createPortal(
<div
className="pointer-events-auto fixed z-[70]"
style={{
bottom: position.bottom,
left: position.left,
maxHeight: position.maxHeight,
width: position.width,
}}
>
{props.children}
</div>,
document.body,
);
}
import { Button } from "../ui/button";
import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
@@ -903,6 +963,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
const [isComposerPrimaryActionsCompact, setIsComposerPrimaryActionsCompact] = useState(false);
const [isComposerModelPickerOpen, setIsComposerModelPickerOpen] = useState(false);
const [isComposerFocused, setIsComposerFocused] = useState(false);
const [composerMenuAnchor, setComposerMenuAnchor] = useState<HTMLDivElement | null>(null);
const isMobileViewport = useMediaQuery("max-sm");
const isComposerCollapsedMobile =
isMobileViewport && !forceExpandedOnMobile && !isComposerFocused;
@@ -2337,6 +2398,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
) : null}
<div
ref={setComposerMenuAnchor}
className={cn(
"relative px-3 pb-2 sm:px-4",
hasComposerHeader ? "pt-2.5 sm:pt-3" : "pt-3.5 sm:pt-4",
@@ -2344,7 +2406,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
)}
>
{composerMenuOpen && !isComposerApprovalState && (
<div className="absolute inset-x-0 bottom-full z-20 mb-2">
<ComposerCommandMenuLayer anchor={composerMenuAnchor}>
<ComposerCommandMenu
items={composerMenuItems}
resolvedTheme={resolvedTheme}
@@ -2359,7 +2421,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
onHighlightedItemChange={onComposerMenuItemHighlighted}
onSelect={onSelectComposerItem}
/>
</div>
</ComposerCommandMenuLayer>
)}
{!isComposerCollapsedMobile &&
@@ -139,10 +139,7 @@ export const ComposerCommandMenu = memo(function ComposerCommandMenu(props: {
);
}}
>
<div
ref={listRef}
className="relative w-full overflow-hidden rounded-[20px] border border-border/80 bg-popover/96 shadow-lg/8 backdrop-blur-xs"
>
<div ref={listRef} className="dropdown-glass relative w-full overflow-hidden rounded-[20px]">
{props.items.length > 0 ? (
<CommandList className="max-h-72">
{groups.map((group, groupIndex) => (
@@ -1285,8 +1285,8 @@ function AssistantChangedFilesSectionInner({
const summaryStat = summarizeTurnDiffStats(checkpointFiles);
return (
<div className="mt-4 rounded-2xl bg-background p-2 pt-4 shadow-xs/5 not-dark:bg-clip-padding dark:bg-input/32">
<div className="sticky top-2 z-10 mb-3 flex items-center justify-between gap-2 bg-background px-2 before:absolute before:inset-x-0 before:-top-4 before:h-4 before:bg-background before:content-[''] dark:bg-[color-mix(in_srgb,var(--foreground)_2.5%,var(--background))] dark:before:bg-[color-mix(in_srgb,var(--foreground)_2.5%,var(--background))]">
<div className="mt-4 rounded-2xl border border-border/70 bg-secondary p-2 pt-4 dark:border-transparent dark:bg-input/32">
<div className="sticky top-2 z-10 mb-3 flex items-center justify-between gap-2 bg-secondary px-2 before:absolute before:inset-x-0 before:-top-4 before:h-4 before:bg-secondary before:content-[''] dark:bg-[color-mix(in_srgb,var(--foreground)_2.5%,var(--background))] dark:before:bg-[color-mix(in_srgb,var(--foreground)_2.5%,var(--background))]">
<p className="flex items-center gap-1 whitespace-nowrap font-medium text-foreground text-xs leading-4">
<span>
{checkpointFiles.length} changed file{checkpointFiles.length === 1 ? "" : "s"}
@@ -55,10 +55,10 @@ function ConfiguredT3ConnectSidebarSignIn() {
<SidebarMenuItem>
<SidebarMenuButton
size="sm"
className="gap-2 px-2 py-2 text-xs text-muted-foreground hover:bg-accent hover:text-foreground"
className="h-8 items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-sidebar-muted-foreground/80 hover:bg-sidebar-row-hover hover:text-sidebar-foreground"
onClick={openAuthPrompt}
>
<LogInIcon className="size-4" />
<LogInIcon className="size-4 shrink-0" />
<span>Sign in to T3 Connect</span>
</SidebarMenuButton>
</SidebarMenuItem>
@@ -1,6 +1,7 @@
"use client";
import { Radio as RadioPrimitive } from "@base-ui/react/radio";
import { CheckIcon } from "lucide-react";
import { useMemo, useState } from "react";
import {
ProviderInstanceId,
@@ -223,7 +224,7 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogPopup className="max-w-xl overflow-hidden">
<div className="flex min-h-0 flex-col overflow-hidden">
<DialogHeader className="border-b border-border/70">
<DialogHeader>
<DialogTitle>Add provider instance</DialogTitle>
<DialogDescription>
Configure an additional provider instance — for example, a second Codex install
@@ -239,41 +240,37 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns
<div
data-slot="dialog-panel"
className="space-y-4 border-b border-border/70 bg-foreground/[0.025] px-6 py-5"
className="space-y-4 bg-zinc-25/80 px-6 py-5 ring-1 ring-black/5 dark:bg-white/2 dark:ring-white/5"
>
<AnimatedHeight>
<div className={cn("grid gap-2", wizardStep !== 0 && "hidden")}>
<span
id="add-instance-driver-label"
className="text-xs font-medium text-foreground"
>
<div id="add-instance-driver-label" className="text-sm font-medium text-foreground">
Driver
</span>
</div>
<RadioGroup
value={driver}
onValueChange={(value) => setDriver(ProviderDriverKind.make(value))}
aria-labelledby="add-instance-driver-label"
className="grid grid-cols-2 gap-2.5"
className="grid grid-cols-1 gap-2 sm:grid-cols-2"
>
{DRIVER_OPTIONS.map((option) => {
const IconComponent = option.icon;
const isSelected = option.value === driver;
return (
<RadioPrimitive.Root
key={option.value}
value={option.value}
className={cn(
"relative flex cursor-pointer items-center gap-3 rounded-lg border px-3 py-3 text-left outline-none transition-[background-color,border-color,box-shadow]",
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",
isSelected
? "border-primary bg-background shadow-sm ring-2 ring-primary/35"
: "border-border bg-background hover:border-foreground/20 hover:bg-muted/50",
)}
className="relative flex cursor-pointer items-center gap-3 rounded-lg bg-card px-3 py-3 text-left text-muted-foreground outline-none ring-1 ring-black/5 hover:bg-zinc-50 focus-visible:ring-2 focus-visible:ring-ring data-checked:bg-primary/8 data-checked:text-foreground data-checked:ring-2 data-checked:ring-primary data-checked:hover:bg-primary/8 dark:bg-white/3 dark:ring-white/5 dark:hover:bg-white/5 dark:data-checked:bg-primary/15 dark:data-checked:ring-primary dark:data-checked:hover:bg-primary/15"
>
<IconComponent className="size-5 shrink-0" aria-hidden />
<IconComponent className="size-4 shrink-0" aria-hidden />
<span className="min-w-0 flex-1 truncate text-sm font-medium text-foreground">
{option.label}
</span>
<RadioPrimitive.Indicator
className="grid size-5 shrink-0 place-items-center rounded-full bg-primary text-primary-foreground"
aria-hidden
>
<CheckIcon className="size-3.5 shrink-0" />
</RadioPrimitive.Indicator>
{option.badgeLabel ? (
<Badge variant="warning" size="sm">
{option.badgeLabel}
@@ -290,11 +287,11 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns
value={option.value}
disabled
className={cn(
"relative flex cursor-not-allowed items-center gap-3 rounded-lg border border-border bg-background px-3 py-3 text-left opacity-55 outline-none",
"relative flex cursor-not-allowed items-center gap-3 rounded-lg bg-card/60 px-3 py-3 text-left opacity-55 outline-none ring-1 ring-black/5 dark:bg-white/2 dark:ring-white/5",
)}
>
<IconComponent
className="size-5 shrink-0 text-muted-foreground"
className="size-4 shrink-0 text-muted-foreground"
aria-hidden
/>
<span className="min-w-0 flex-1 truncate text-sm font-medium text-foreground">
@@ -409,7 +406,7 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns
</AnimatedHeight>
</div>
<DialogFooter className="border-t bg-transparent">
<DialogFooter variant="bare">
<Button
variant="outline"
size="sm"
@@ -9,6 +9,10 @@ interface StepButtonProps {
readonly onClick: () => void;
}
interface StepListItemProps {
readonly children: ReactElement<StepButtonProps>;
}
function renderStepButtons(
currentStep: number,
instanceIdError: string | null,
@@ -21,9 +25,9 @@ function renderStepButtons(
onNavigation,
});
return Children.toArray(header.props.children).filter(
(child): child is ReactElement<StepButtonProps> => isValidElement(child),
);
return Children.toArray(header.props.children)
.filter((child): child is ReactElement<StepListItemProps> => isValidElement(child))
.map((item) => item.props.children);
}
describe("AddProviderInstanceWizardSteps", () => {
@@ -21,50 +21,53 @@ export function AddProviderInstanceWizardSteps({
onNavigation,
}: AddProviderInstanceWizardStepsProps) {
return (
<div className="grid grid-cols-3 gap-2">
<ol
className="grid grid-cols-3 gap-1 rounded-xl bg-zinc-25 p-1 ring-1 ring-black/5 dark:bg-white/4 dark:ring-white/5"
role="list"
>
{ADD_PROVIDER_WIZARD_STEPS.map((step, index) => (
<button
key={step}
type="button"
className={cn(
"grid min-w-0 grid-cols-[1rem_minmax(0,1fr)] gap-x-2 rounded-lg border px-3 py-2 text-left",
index === currentStep
? "border-primary bg-primary/10 ring-1 ring-primary/25"
: index < currentStep
? "border-border bg-background"
: "border-border bg-muted/40",
)}
aria-current={index === currentStep ? "step" : undefined}
onClick={() =>
onNavigation(
resolveWizardNavigation(currentStep, index, ADD_PROVIDER_WIZARD_STEPS.length, {
instanceIdError,
}),
)
}
>
<span
<li key={step} className="min-w-0">
<button
type="button"
className={cn(
"row-span-2 mt-0.5 grid size-4 place-items-center rounded-full border",
index < currentStep
? "border-primary bg-primary text-primary-foreground"
: index === currentStep
? "border-primary bg-background"
: "border-muted-foreground/35 bg-background",
"flex w-full min-w-0 cursor-pointer items-center gap-2 rounded-lg px-2.5 py-2 text-left outline-none hover:bg-card focus-visible:ring-2 focus-visible:ring-ring max-sm:justify-center max-sm:px-2",
index === currentStep &&
"bg-card text-foreground shadow-xs ring-1 ring-black/5 hover:bg-card dark:shadow-none dark:ring-white/5",
)}
aria-hidden
aria-current={index === currentStep ? "step" : undefined}
aria-label={`${step}, step ${index + 1}${index < currentStep && summaries[index] ? `, ${summaries[index]}` : ""}`}
onClick={() =>
onNavigation(
resolveWizardNavigation(currentStep, index, ADD_PROVIDER_WIZARD_STEPS.length, {
instanceIdError,
}),
)
}
>
{index < currentStep ? <CheckIcon className="size-3" /> : null}
</span>
<span className="text-[10px] font-medium uppercase text-muted-foreground">
Step {index + 1}
</span>
<span className="truncate text-xs font-semibold text-foreground">
{step}
{index < currentStep && summaries[index] ? `: ${summaries[index]}` : ""}
</span>
</button>
<span
className={cn(
"grid size-5 shrink-0 place-items-center rounded-full text-sm font-medium ring-1",
index < currentStep
? "bg-primary text-primary-foreground ring-primary"
: index === currentStep
? "bg-primary/10 text-primary ring-primary/30"
: "bg-card text-muted-foreground ring-black/10 dark:bg-white/5 dark:ring-white/10",
)}
aria-hidden
>
{index < currentStep ? <CheckIcon className="size-4 shrink-0" /> : index + 1}
</span>
<span
className={cn(
"min-w-0 truncate text-sm font-medium max-sm:hidden",
index === currentStep ? "text-foreground" : "text-muted-foreground",
)}
>
{step}
</span>
</button>
</li>
))}
</div>
</ol>
);
}
+9 -7
View File
@@ -3,6 +3,11 @@
import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog";
import { cn } from "~/lib/utils";
import {
DIALOG_BACKDROP_CLASS,
DIALOG_MOBILE_SHEET_CLASS,
DIALOG_POPUP_CLASS,
} from "~/components/ui/dialog-styles";
const AlertDialogCreateHandle = AlertDialogPrimitive.createHandle;
@@ -18,10 +23,7 @@ function AlertDialogBackdrop({ className, ...props }: AlertDialogPrimitive.Backd
return (
<AlertDialogPrimitive.Backdrop
forceRender
className={cn(
"fixed inset-0 z-50 bg-black/20 backdrop-blur-[2px] transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:bg-black/55",
className,
)}
className={cn(DIALOG_BACKDROP_CLASS, className)}
data-slot="alert-dialog-backdrop"
{...props}
/>
@@ -56,9 +58,9 @@ function AlertDialogPopup({
>
<AlertDialogPrimitive.Popup
className={cn(
"dialog-glass -translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 flex max-h-full min-h-0 w-full min-w-0 max-w-lg scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border border-border/70 text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]",
bottomStickOnMobile &&
"max-sm:max-w-none max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4 max-sm:before:hidden max-sm:before:rounded-none",
DIALOG_POPUP_CLASS,
"row-start-2 max-h-full max-w-lg text-popover-foreground",
bottomStickOnMobile && DIALOG_MOBILE_SHEET_CLASS,
className,
)}
data-slot="alert-dialog-popup"
+1 -1
View File
@@ -40,7 +40,7 @@ const buttonVariants = cva(
"border-transparent text-foreground data-pressed:bg-accent [:hover,[data-pressed]]:bg-accent [&_svg:not([class*='text-'])]:text-muted-foreground",
link: "border-transparent underline-offset-4 [:hover,[data-pressed]]:underline",
outline:
"border-transparent bg-popover not-dark:bg-clip-padding text-foreground shadow-none dark:bg-input/32 [:hover,[data-pressed]]:bg-accent/50 dark:[:hover,[data-pressed]]:bg-input/64 [&_svg:not([class*='text-'])]:text-muted-foreground",
"border-input bg-popover not-dark:bg-clip-padding text-foreground shadow-xs/5 not-disabled:not-active:not-data-pressed:before:shadow-[0_1px_--theme(--color-black/4%)] dark:bg-input/32 dark:not-disabled:before:shadow-[0_-1px_--theme(--color-white/2%)] dark:not-disabled:not-active:not-data-pressed:before:shadow-[0_-1px_--theme(--color-white/6%)] [:disabled,:active,[data-pressed]]:shadow-none [:hover,[data-pressed]]:bg-accent/50 dark:[:hover,[data-pressed]]:bg-input/64 [&_svg:not([class*='text-'])]:text-muted-foreground",
secondary:
"border-transparent bg-secondary text-secondary-foreground [:active,[data-pressed]]:bg-secondary/80 [:hover,[data-pressed]]:bg-secondary/90",
},
+4 -5
View File
@@ -15,6 +15,7 @@ import {
AutocompleteList,
AutocompleteSeparator,
} from "~/components/ui/autocomplete";
import { DIALOG_BACKDROP_CLASS, DIALOG_POPUP_CLASS } from "~/components/ui/dialog-styles";
const CommandDialog = CommandDialogPrimitive.Root;
@@ -29,10 +30,7 @@ function CommandDialogTrigger(props: CommandDialogPrimitive.Trigger.Props) {
function CommandDialogBackdrop({ className, ...props }: CommandDialogPrimitive.Backdrop.Props) {
return (
<CommandDialogPrimitive.Backdrop
className={cn(
"fixed inset-0 z-50 bg-black/20 backdrop-blur-[2px] transition-opacity duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:bg-black/55",
className,
)}
className={cn(DIALOG_BACKDROP_CLASS, className)}
data-slot="command-dialog-backdrop"
{...props}
/>
@@ -66,7 +64,8 @@ function CommandDialogPopup({
<CommandDialogViewport>
<CommandDialogPrimitive.Popup
className={cn(
"chat-composer-glass command-palette-glass pointer-events-auto -translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 flex max-h-105 min-h-0 w-full min-w-0 max-w-xl scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl bg-[color-mix(in_srgb,var(--background)_var(--glass-opacity),transparent)] text-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] outline-none transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 **:data-[slot=scroll-area-viewport]:data-has-overflow-y:pe-1",
DIALOG_POPUP_CLASS,
"pointer-events-auto max-h-105 max-w-xl text-foreground **:data-[slot=scroll-area-viewport]:data-has-overflow-y:pe-1",
className,
)}
data-slot="command-dialog-popup"
@@ -0,0 +1,10 @@
const DIALOG_BACKDROP_CLASS =
"dialog-backdrop fixed inset-0 z-50 transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0";
const DIALOG_POPUP_CLASS =
"dialog-glass -translate-y-[calc(1.25rem*var(--nested-dialogs))] relative flex min-h-0 w-full min-w-0 scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border opacity-[calc(1-0.1*var(--nested-dialogs))] outline-none transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0";
const DIALOG_MOBILE_SHEET_CLASS =
"max-sm:max-w-none max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4";
export { DIALOG_BACKDROP_CLASS, DIALOG_MOBILE_SHEET_CLASS, DIALOG_POPUP_CLASS };
+11 -12
View File
@@ -4,6 +4,11 @@ import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
import { XIcon } from "lucide-react";
import { cn } from "~/lib/utils";
import { Button } from "~/components/ui/button";
import {
DIALOG_BACKDROP_CLASS,
DIALOG_MOBILE_SHEET_CLASS,
DIALOG_POPUP_CLASS,
} from "~/components/ui/dialog-styles";
import { ScrollArea } from "~/components/ui/scroll-area";
const DialogCreateHandle = DialogPrimitive.createHandle;
@@ -24,10 +29,7 @@ function DialogBackdrop({ className, ...props }: DialogPrimitive.Backdrop.Props)
return (
<DialogPrimitive.Backdrop
forceRender
className={cn(
"fixed inset-0 z-50 bg-black/20 backdrop-blur-[2px] transition-all duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:bg-black/55",
className,
)}
className={cn(DIALOG_BACKDROP_CLASS, className)}
data-slot="dialog-backdrop"
{...props}
/>
@@ -49,27 +51,25 @@ function DialogViewport({ className, ...props }: DialogPrimitive.Viewport.Props)
function DialogPopup({
className,
backdropClassName,
children,
showCloseButton = true,
bottomStickOnMobile = true,
...props
}: DialogPrimitive.Popup.Props & {
backdropClassName?: string;
showCloseButton?: boolean;
bottomStickOnMobile?: boolean;
}) {
return (
<DialogPortal>
<DialogBackdrop className={backdropClassName} />
<DialogBackdrop />
<DialogViewport
className={cn(bottomStickOnMobile && "max-sm:grid-rows-[1fr_auto] max-sm:p-0 max-sm:pt-12")}
>
<DialogPrimitive.Popup
className={cn(
"dialog-glass -translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 flex max-h-full min-h-0 w-full min-w-0 max-w-lg scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border border-border/70 text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]",
bottomStickOnMobile &&
"max-sm:max-w-none max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4 max-sm:before:hidden max-sm:before:rounded-none",
DIALOG_POPUP_CLASS,
"row-start-2 max-h-full max-w-lg text-popover-foreground",
bottomStickOnMobile && DIALOG_MOBILE_SHEET_CLASS,
className,
)}
data-slot="dialog-popup"
@@ -116,8 +116,7 @@ function DialogFooter({
className={cn(
"flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]",
variant === "default" && "border-t bg-muted/72 py-4",
variant === "bare" &&
"in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pt-3 pt-4 pb-6",
variant === "bare" && "py-4",
className,
)}
data-slot="dialog-footer"
+109
View File
@@ -5,12 +5,16 @@ import {
deriveLogicalProjectKey,
deriveLogicalProjectKeyFromSettings,
derivePhysicalProjectKey,
getProjectOrderKey,
resolveProjectGroupingMode,
} from "./logicalProject";
import {
buildPhysicalToLogicalProjectKeyMap,
buildSidebarProjectPickerEntries,
buildSidebarProjectSnapshots,
} from "./sidebarProjectGrouping";
import { orderItemsByPreferredIds } from "./components/Sidebar.logic";
import { legacyProjectCwdPreferenceKey } from "./uiStateStore";
import type { Project } from "./types";
const primaryEnvironmentId = EnvironmentId.make("env-primary");
@@ -59,6 +63,24 @@ describe("environment grouping", () => {
expect(deriveLogicalProjectKey(remote)).toBe(repositoryIdentity.canonicalKey);
});
it("counts cross-environment copies as one new-thread project choice", () => {
const primary = makeProject({ repositoryIdentity });
const remote = makeProject({
id: ProjectId.make("project-remote"),
environmentId: remoteEnvironmentId,
repositoryIdentity,
});
const projectGroupCount = buildSidebarProjectSnapshots({
projects: [primary, remote],
settings: defaultGroupingSettings,
primaryEnvironmentId,
resolveEnvironmentLabel: () => null,
}).length;
expect(projectGroupCount).toBe(1);
});
it("keeps projects without repository identity physically scoped", () => {
const primary = makeProject();
const remote = makeProject({
@@ -216,6 +238,24 @@ describe("environment grouping", () => {
canonical.id,
remote.id,
]);
expect(snapshots[0]?.memberProjectRefs).toEqual([
{
environmentId: primaryEnvironmentId,
projectId: staleWithoutRepositoryIdentity.id,
},
{ environmentId: primaryEnvironmentId, projectId: canonical.id },
{ environmentId: remoteEnvironmentId, projectId: remote.id },
]);
const [pickerEntry] = buildSidebarProjectPickerEntries({
groups: snapshots,
preferredProjectRef: {
environmentId: primaryEnvironmentId,
projectId: staleWithoutRepositoryIdentity.id,
},
});
expect(pickerEntry?.isPreferred).toBe(true);
expect(pickerEntry?.targetProject.id).toBe(canonical.id);
});
it("routes duplicate physical project keys to the winning logical group", () => {
@@ -240,4 +280,73 @@ describe("environment grouping", () => {
repositoryIdentity.canonicalKey,
);
});
it("builds one picker entry per logical project and targets the preferred environment", () => {
const primary = makeProject({ repositoryIdentity });
const remote = makeProject({
id: ProjectId.make("project-remote"),
environmentId: remoteEnvironmentId,
repositoryIdentity,
});
const separate = makeProject({
id: ProjectId.make("project-separate"),
title: "separate",
workspaceRoot: "/tmp/separate",
});
const groups = buildSidebarProjectSnapshots({
projects: [separate, primary, remote],
settings: defaultGroupingSettings,
primaryEnvironmentId,
resolveEnvironmentLabel: () => null,
});
const entries = buildSidebarProjectPickerEntries({
groups,
preferredProjectRef: {
environmentId: remoteEnvironmentId,
projectId: remote.id,
},
});
expect(entries).toHaveLength(2);
expect(entries[0]?.group.projectKey).toBe(repositoryIdentity.canonicalKey);
expect(entries[0]?.targetProject).toMatchObject({
environmentId: remoteEnvironmentId,
id: remote.id,
});
expect(entries[0]?.isPreferred).toBe(true);
expect(entries[1]?.group.displayName).toBe("separate");
});
it("keeps manual project order when building grouped sidebar entries", () => {
const primary = makeProject({ repositoryIdentity });
const remote = makeProject({
id: ProjectId.make("project-remote"),
environmentId: remoteEnvironmentId,
repositoryIdentity,
});
const separate = makeProject({
id: ProjectId.make("project-separate"),
title: "separate",
workspaceRoot: "/tmp/separate",
});
const orderedProjects = orderItemsByPreferredIds({
items: [primary, remote, separate],
preferredIds: [getProjectOrderKey(separate), getProjectOrderKey(primary)],
getId: getProjectOrderKey,
getPreferenceIds: (project) => [
getProjectOrderKey(project),
legacyProjectCwdPreferenceKey(project.workspaceRoot),
],
});
const groups = buildSidebarProjectSnapshots({
projects: orderedProjects,
settings: defaultGroupingSettings,
primaryEnvironmentId,
resolveEnvironmentLabel: () => null,
});
expect(groups.map((group) => group.displayName)).toEqual(["separate", "shared-repo"]);
});
});
+104 -106
View File
@@ -77,7 +77,9 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
:root {
--app-scrollbar-width: 6px;
--glass-blur: 12px;
--glass-opacity: 80%;
--glass-saturation: 1.14;
--desktop-window-right-resize-inset: 0px;
--workspace-topbar-height: 52px;
--workspace-controls-top: 0px;
@@ -88,6 +90,11 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
--workspace-titlebar-control-gap: 0.75rem;
}
.dark {
--glass-blur: 16px;
--glass-saturation: 1.08;
}
[data-slot="sidebar-wrapper"] {
--workspace-titlebar-content-left: calc(
var(--workspace-controls-left) + var(--workspace-titlebar-control-size) +
@@ -108,6 +115,7 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
}
@theme inline {
--color-zinc-25: oklch(99.2% 0 0);
--animate-skeleton: skeleton 2s -1s infinite linear;
/* Duty-cycled indicator animations: long holds with stepped ramps, so the
compositor updates discrete frames instead of every vsync. */
@@ -365,25 +373,39 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
.chat-composer-glass {
background: color-mix(in srgb, var(--background) var(--glass-opacity), transparent);
-webkit-backdrop-filter: blur(16px);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
}
.chat-composer-glass-host {
--chat-composer-glass-surface: color-mix(in srgb, var(--background) 96%, var(--color-black));
--chat-composer-glass-surface: var(--card);
position: relative;
box-shadow:
0 0 0 1px rgb(0 0 0 / 8%),
0 12px 28px -18px rgb(0 0 0 / 40%);
}
.chat-composer-glass-host::before {
pointer-events: none;
position: absolute;
z-index: 0;
inset: 0;
border-radius: inherit;
background: color-mix(
in srgb,
var(--chat-composer-glass-surface) var(--glass-opacity),
transparent
);
box-shadow: 0 12px 28px -18px rgb(0 0 0 / 40%);
-webkit-backdrop-filter: blur(16px);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
content: "";
}
.dark .chat-composer-glass-host {
--chat-composer-glass-surface: color-mix(in srgb, var(--background) 96%, var(--color-white));
--chat-composer-glass-surface: color-mix(in srgb, var(--background) 84%, var(--color-white));
box-shadow: 0 0 0 1px rgb(255 255 255 / 10%);
}
.alert-glass {
@@ -395,8 +417,8 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
color-mix(in srgb, var(--alert-glass-tint) 4%, transparent)
),
color-mix(in srgb, var(--background) var(--glass-opacity), transparent) !important;
-webkit-backdrop-filter: blur(16px) saturate(1.1);
backdrop-filter: blur(16px) saturate(1.1);
-webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
}
.alert-glass[data-variant="error"] {
@@ -416,12 +438,16 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
}
.dropdown-glass,
.dialog-glass,
.workflow-dialog-surface,
.command-palette-dialog-surface {
.dialog-glass {
background: color-mix(in srgb, var(--background) var(--glass-opacity), transparent);
-webkit-backdrop-filter: blur(16px);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
}
.dialog-backdrop {
background: color-mix(in srgb, var(--background) 60%, transparent);
-webkit-backdrop-filter: blur(4px);
backdrop-filter: blur(4px);
}
.dropdown-glass {
@@ -429,30 +455,12 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
box-shadow: 0 16px 40px -18px rgb(0 0 0 / 55%);
}
.command-palette-glass {
box-shadow: 0 24px 64px -24px rgb(0 0 0 / 65%);
}
.command-menu-surface {
background: color-mix(in srgb, var(--background) var(--glass-opacity), transparent);
-webkit-backdrop-filter: blur(16px);
backdrop-filter: blur(16px);
box-shadow: 0 24px 64px -24px rgb(0 0 0 / 65%);
}
.workflow-dialog-surface {
.dialog-glass {
border-color: color-mix(in srgb, var(--foreground) 10%, transparent);
box-shadow: 0 24px 64px -24px rgb(0 0 0 / 65%);
}
.command-palette-dialog-surface {
border-color: color-mix(in srgb, var(--foreground) 10%, transparent) !important;
background: color-mix(in srgb, var(--background) var(--glass-opacity), transparent) !important;
box-shadow: 0 24px 64px -24px rgb(0 0 0 / 65%) !important;
}
.dark .dropdown-glass,
.dark .dialog-glass {
.dark .dropdown-glass {
box-shadow: 0 18px 44px -18px rgb(0 0 0 / 80%);
}
@@ -460,33 +468,15 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
background: color-mix(in srgb, var(--background) var(--glass-opacity), transparent);
}
.dark .command-menu-surface,
.dark .command-palette-glass,
.dark .workflow-dialog-surface {
box-shadow: none;
.dark .dialog-glass {
border-color: color-mix(in srgb, var(--color-white) 8%, transparent);
box-shadow:
inset 0 1px rgb(255 255 255 / 4%),
0 24px 72px -20px rgb(0 0 0 / 90%);
}
.dark .command-palette-dialog-surface {
box-shadow: none !important;
}
.dark
.command-palette-dialog-surface
:is([data-slot="input-control"], [data-slot="textarea-control"]) {
background: var(--secondary) !important;
}
.dark
.command-palette-dialog-surface
:is([data-slot="input-control"], [data-slot="textarea-control"]):not(:has(:focus-visible)) {
border-color: transparent !important;
box-shadow: none !important;
}
.dark
.command-palette-dialog-surface
:is([data-slot="input-control"], [data-slot="textarea-control"])::before {
box-shadow: none !important;
.dark .dialog-backdrop {
background: color-mix(in srgb, var(--background) 64%, transparent);
}
.glass-opacity-slider {
@@ -622,15 +612,12 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
background: var(--background) !important;
}
.chat-composer-glass-host {
.chat-composer-glass-host::before {
background: var(--chat-composer-glass-surface);
}
.dialog-glass,
.dropdown-glass,
.command-menu-surface,
.command-palette-dialog-surface,
.workflow-dialog-surface {
.dropdown-glass {
background: var(--popover) !important;
}
}
@@ -673,25 +660,25 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
:root {
color-scheme: light;
--radius: 0.625rem;
--background: var(--color-white);
--background: var(--color-zinc-25);
--app-chrome-background: var(--background);
--surface-raised: var(--secondary);
--foreground: var(--color-neutral-800);
--surface-raised: color-mix(in srgb, var(--card) 20%, transparent);
--foreground: var(--color-zinc-800);
--card: var(--color-white);
--card-foreground: var(--color-neutral-800);
--card-foreground: var(--color-zinc-800);
--popover: var(--color-white);
--popover-foreground: var(--color-neutral-800);
--popover-foreground: var(--color-zinc-800);
--primary: oklch(0.488 0.217 264);
--primary-foreground: var(--color-white);
--secondary: --alpha(var(--color-black) / 4%);
--secondary-foreground: var(--color-neutral-800);
--muted: --alpha(var(--color-black) / 4%);
--muted-foreground: color-mix(in srgb, var(--color-neutral-500) 90%, var(--color-black));
--accent: --alpha(var(--color-black) / 4%);
--accent-foreground: var(--color-neutral-800);
--secondary: var(--color-zinc-50);
--secondary-foreground: var(--color-zinc-800);
--muted: var(--color-zinc-50);
--muted-foreground: var(--color-zinc-500);
--accent: var(--color-zinc-100);
--accent-foreground: var(--color-zinc-900);
--destructive: var(--color-red-500);
--border: --alpha(var(--color-black) / 8%);
--input: --alpha(var(--color-black) / 10%);
--border: var(--color-zinc-200);
--input: var(--color-zinc-300);
--ring: oklch(0.488 0.217 264);
--destructive-foreground: var(--color-red-700);
--info: var(--color-blue-500);
@@ -700,16 +687,17 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
--success-foreground: var(--color-emerald-700);
--warning: var(--color-amber-500);
--warning-foreground: var(--color-amber-700);
/* Fallbacks for standalone sidebar primitives. App sidebars override these
roles on their own root so the surface hierarchy stays out of page content. */
--sidebar: var(--card);
/* Keep every sidebar primitive on the same light surface hierarchy, including
portaled mobile sheets and settings navigation outside the app sidebar. */
--sidebar: var(--color-zinc-50);
--sidebar-foreground: var(--foreground);
--sidebar-muted-foreground: var(--muted-foreground);
--sidebar-control-surface: var(--accent);
--sidebar-row-hover: var(--accent);
--sidebar-row-active: var(--accent);
--sidebar-row-selected: var(--muted);
--sidebar-control-surface: var(--color-zinc-100);
--sidebar-row-hover: var(--color-zinc-25);
--sidebar-row-active: var(--color-white);
--sidebar-row-selected: var(--color-white);
--sidebar-border: var(--border);
--sidebar-stage-fade: var(--sidebar);
@variant dark {
color-scheme: dark;
@@ -742,34 +730,44 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
--success-foreground: var(--color-emerald-400);
--warning: var(--color-amber-500);
--warning-foreground: var(--color-amber-400);
--sidebar: var(--card);
--sidebar-foreground: var(--foreground);
--sidebar-muted-foreground: var(--muted-foreground);
--sidebar-control-surface: var(--muted);
--sidebar-row-hover: var(--accent);
--sidebar-row-active: var(--accent);
--sidebar-row-selected: var(--muted);
--sidebar-border: var(--border);
--sidebar-stage-fade: var(--card);
}
}
/* Give both navigation implementations the same cool graphite surface. The
version attribute remains useful for layout-specific styling, but color is
shared so switching the beta does not switch visual systems. */
/* Keep both navigation implementations on the same quiet zinc hierarchy:
zinc-50 navigation, zinc-25 hover, and white selected/raised surfaces.
The version attribute remains useful for layout-specific styling without
changing the color system when the beta is toggled. */
[data-sidebar-version="v1"],
[data-sidebar-version="v2"] {
--background: oklch(0.965 0.009 265);
--foreground: oklch(0.27 0.025 265);
--card: oklch(0.945 0.014 265);
--card-foreground: var(--foreground);
--accent: oklch(0.875 0.008 265);
--accent-foreground: oklch(0.24 0.012 265);
--muted: oklch(0.9 0.018 265);
--muted-foreground: oklch(0.49 0.03 265);
--border: oklch(0.72 0.025 265 / 28%);
--input: oklch(0.62 0.03 265 / 28%);
--sidebar: var(--card);
--sidebar-foreground: var(--foreground);
--sidebar-muted-foreground: var(--muted-foreground);
--sidebar-control-surface: var(--muted);
--sidebar-row-hover: color-mix(in srgb, var(--foreground) 6%, transparent);
--sidebar-row-active: color-mix(in srgb, var(--foreground) 11%, transparent);
--sidebar-row-selected: color-mix(in srgb, var(--foreground) 7%, transparent);
--sidebar-border: var(--border);
--background: var(--color-zinc-25);
--foreground: var(--color-zinc-800);
--card: var(--color-white);
--card-foreground: var(--color-zinc-800);
--accent: var(--color-zinc-100);
--accent-foreground: var(--color-zinc-900);
--muted: var(--color-zinc-50);
--muted-foreground: var(--color-zinc-500);
--border: var(--color-zinc-200);
--input: var(--color-zinc-300);
--sidebar: var(--color-zinc-50);
--sidebar-foreground: var(--color-zinc-800);
--sidebar-muted-foreground: var(--color-zinc-500);
--sidebar-control-surface: var(--color-zinc-100);
--sidebar-row-hover: var(--color-zinc-25);
--sidebar-row-active: var(--color-white);
--sidebar-row-selected: var(--color-white);
--sidebar-border: var(--color-zinc-200);
--sidebar-stage-fade: var(--sidebar);
background-color: var(--card);
background-color: var(--sidebar);
}
.dark [data-sidebar-version="v1"],
+69 -1
View File
@@ -31,6 +31,12 @@ export interface SidebarProjectSnapshot extends Project {
remoteEnvironmentLabels: readonly string[];
}
export interface SidebarProjectPickerEntry {
group: SidebarProjectSnapshot;
targetProject: SidebarProjectGroupMember;
isPreferred: boolean;
}
interface SidebarProjectGroupCandidate {
readonly logicalKey: string;
readonly project: Project;
@@ -133,6 +139,26 @@ export function buildSidebarProjectSnapshots(input: {
}
}
const projectRefsByLogicalKey = new Map<string, ScopedProjectRef[]>();
const seenProjectRefs = new Set<string>();
for (const project of input.projects) {
const physicalProjectKey = derivePhysicalProjectKey(project);
const logicalKey =
winnersByPhysicalKey.get(physicalProjectKey)?.logicalKey ??
deriveLogicalProjectKeyFromSettings(project, input.settings);
const projectRefKey = `${project.environmentId}:${project.id}`;
if (seenProjectRefs.has(projectRefKey)) continue;
seenProjectRefs.add(projectRefKey);
const projectRef = scopeProjectRef(project.environmentId, project.id);
const existingRefs = projectRefsByLogicalKey.get(logicalKey);
if (existingRefs) {
existingRefs.push(projectRef);
} else {
projectRefsByLogicalKey.set(logicalKey, [projectRef]);
}
}
const result: SidebarProjectSnapshot[] = [];
const seen = new Set<string>();
for (const project of input.projects) {
@@ -185,10 +211,52 @@ export function buildSidebarProjectSnapshots(input: {
hasLocal && hasRemote ? "mixed" : hasRemote ? "remote-only" : "local-only",
allRemoteMembersAreDesktopLocal,
memberProjects: members,
memberProjectRefs: members.map((member) => scopeProjectRef(member.environmentId, member.id)),
memberProjectRefs: projectRefsByLogicalKey.get(logicalKey) ?? [],
remoteEnvironmentLabels,
});
}
return result;
}
export function buildSidebarProjectPickerEntries(input: {
groups: ReadonlyArray<SidebarProjectSnapshot>;
preferredProjectRef: ScopedProjectRef | null;
}) {
const entries = input.groups.flatMap((group): SidebarProjectPickerEntry[] => {
const isPreferred = input.preferredProjectRef
? group.memberProjectRefs.some(
(projectRef) =>
projectRef.environmentId === input.preferredProjectRef?.environmentId &&
projectRef.projectId === input.preferredProjectRef.projectId,
)
: false;
const preferredProject = isPreferred
? (group.memberProjects.find(
(project) =>
project.environmentId === input.preferredProjectRef?.environmentId &&
project.id === input.preferredProjectRef?.projectId,
) ??
group.memberProjects.find(
(project) => project.environmentId === input.preferredProjectRef?.environmentId,
))
: null;
const targetProject =
preferredProject ??
group.memberProjects.find(
(project) => project.environmentId === group.environmentId && project.id === group.id,
) ??
group.memberProjects[0];
if (!targetProject) return [];
return [{ group, targetProject, isPreferred }];
});
const preferredIndex = entries.findIndex((entry) => entry.isPreferred);
if (preferredIndex <= 0) return entries;
return [
entries[preferredIndex]!,
...entries.slice(0, preferredIndex),
...entries.slice(preferredIndex + 1),
];
}
+2 -2
View File
@@ -38,12 +38,12 @@ describe("ClientSettings glass opacity", () => {
expect(decodeClientSettings({}).glassOpacity).toBe(80);
});
it.each([49, 101, 72.5])("rejects an invalid glass opacity: %s", (value) => {
it.each([39, 101, 72.5])("rejects an invalid glass opacity: %s", (value) => {
expect(() => decodeClientSettings({ glassOpacity: value })).toThrow();
expect(() => decodeClientSettingsPatch({ glassOpacity: value })).toThrow();
});
it.each([50, 75, 100])("accepts a glass opacity within the supported range: %s", (value) => {
it.each([40, 75, 100])("accepts a glass opacity within the supported range: %s", (value) => {
expect(decodeClientSettings({ glassOpacity: value }).glassOpacity).toBe(value);
expect(decodeClientSettingsPatch({ glassOpacity: value }).glassOpacity).toBe(value);
});
+1 -1
View File
@@ -48,7 +48,7 @@ export const SidebarAutoSettleAfterDays = Schema.Number.check(
);
export type SidebarAutoSettleAfterDays = typeof SidebarAutoSettleAfterDays.Type;
export const DEFAULT_SIDEBAR_AUTO_SETTLE_AFTER_DAYS: SidebarAutoSettleAfterDays = 3;
export const MIN_GLASS_OPACITY = 50;
export const MIN_GLASS_OPACITY = 40;
export const MAX_GLASS_OPACITY = 100;
export const GlassOpacity = Schema.Int.check(
Schema.isBetween({