Move project settings to contextual project routes (#5923)

This commit is contained in:
Julius Marminge authored and GitHub committed 2026-08-10 02:57:39 +02:00
1 parent 9a1472d955
commit f21d5e444e
13 files changed
+688 -675

No files matched your search

+26 -10
View File
@@ -1506,16 +1506,32 @@ function OpenCommandPaletteDialog(props: {
},
});
actionItems.push({
kind: "action",
value: "action:project-settings",
searchTerms: ["project", "settings", "scripts", "model", "grouping", "checkout"],
title: "Project settings",
icon: <FolderIcon className={ITEM_ICON_CLASS} />,
run: async () => {
await navigate({ to: "/settings/projects" });
},
});
// There is no projects listing page; the action targets the contextual
// project (active thread/draft, falling back to the first sidebar group).
const contextualProjectGroup =
(contextualProjectRef
? projectGroupByTargetKey.get(
`${contextualProjectRef.environmentId}:${contextualProjectRef.projectId}`,
)
: null) ??
projectGroups[0] ??
null;
if (contextualProjectGroup) {
actionItems.push({
kind: "action",
value: "action:project-settings",
searchTerms: ["project", "settings", "scripts", "model", "grouping", "checkout"],
title: "Project settings",
description: contextualProjectGroup.displayName,
icon: <FolderIcon className={ITEM_ICON_CLASS} />,
run: async () => {
await navigate({
to: "/projects/$projectKey",
params: { projectKey: contextualProjectGroup.projectKey },
});
},
});
}
const rootGroups = buildRootGroups({ actionItems, recentThreadItems });
const sourceSelectionViewValue =
+7 -7
View File
@@ -42,12 +42,12 @@ import {
FolderIcon,
FolderPlusIcon,
GitBranchIcon,
EllipsisIcon,
MessageSquareIcon,
PinIcon,
PlusIcon,
SearchIcon,
ServerIcon,
SettingsIcon,
SquarePenIcon,
TerminalIcon,
Undo2Icon,
@@ -1836,7 +1836,7 @@ export default function Sidebar() {
clearSelection();
}, [clearSelection, projectScopeKey]);
const handleProjectActions = useCallback(
const handleProjectSettings = useCallback(
(event: ReactMouseEvent<HTMLButtonElement>, projectGroup: SidebarProjectSnapshot) => {
event.preventDefault();
event.stopPropagation();
@@ -1845,7 +1845,7 @@ export default function Sidebar() {
setOpenMobile(false);
}
void router.navigate({
to: "/settings/projects/$projectKey",
to: "/projects/$projectKey",
params: { projectKey: projectGroup.projectKey },
});
},
@@ -3295,15 +3295,15 @@ export default function Sidebar() {
<span className="min-w-0 truncate text-sm">{project.displayName}</span>
<button
type="button"
aria-label={`Project actions for ${project.displayName}`}
title={`Project actions for ${project.displayName}`}
aria-label={`Project settings for ${project.displayName}`}
title={`Project settings for ${project.displayName}`}
className="ml-auto inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-icon-muted outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground focus-visible:ring-2 focus-visible:ring-ring"
onPointerDown={(event) => event.stopPropagation()}
onClick={(event) => {
void handleProjectActions(event, project);
void handleProjectSettings(event, project);
}}
>
<EllipsisIcon className="size-3.5" />
<SettingsIcon className="size-3.5" />
</button>
</MenuRadioItem>
);
File diff suppressed because it is too large. Load diff
@@ -11,7 +11,6 @@ import {
ArchiveIcon,
ArrowLeftIcon,
BotIcon,
FolderIcon,
GitBranchIcon,
KeyboardIcon,
Link2Icon,
@@ -49,7 +48,6 @@ const SETTINGS_SECTION_ICONS: Readonly<
"/settings/general": Settings2Icon,
"/settings/appearance": PaletteIcon,
"/settings/keybindings": KeyboardIcon,
"/settings/projects": FolderIcon,
"/settings/providers": BotIcon,
"/settings/source-control": GitBranchIcon,
"/settings/connections": Link2Icon,
@@ -279,8 +277,6 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) {
))
: SETTINGS_NAV_ITEMS.map((item) => {
const Icon = item.icon;
// Prefix match keeps the section active on nested routes
// like /settings/projects/$projectKey.
const isActive = pathname === item.to || pathname.startsWith(`${item.to}/`);
return (
<SidebarMenuItem key={item.to}>
@@ -160,7 +160,7 @@ export function SettingsRow({
...rowProps
}: Omit<ComponentPropsWithoutRef<"div">, "title"> & {
title: ReactNode;
description: ReactNode;
description?: ReactNode;
status?: ReactNode;
resetAction?: ReactNode;
control?: ReactNode;
@@ -183,9 +183,11 @@ export function SettingsRow({
{resetAction}
</span>
</div>
<p className="max-w-xl text-[13px] leading-[1.45] text-muted-foreground/80">
{description}
</p>
{description ? (
<p className="max-w-xl text-[13px] leading-[1.45] text-muted-foreground/80">
{description}
</p>
) : null}
{status ? <div className="pt-0.5 text-xs text-muted-foreground">{status}</div> : null}
</div>
{control ? (
@@ -45,7 +45,7 @@ describe("searchSettings", () => {
it("matches normalized title substrings", () => {
expect(searchSettings(" WORD WRAP ", ITEMS).map((item) => item.id)).toEqual(["word-wrap"]);
expect(searchSettings("work").map((item) => item.id)).toEqual(["project-new-thread-workspace"]);
expect(searchSettings("glass").map((item) => item.id)).toEqual(["setting-glass-opacity"]);
expect(searchSettings("xyzzy")).toEqual([]);
});
@@ -2,7 +2,6 @@ export type SettingsPath =
| "/settings/general"
| "/settings/appearance"
| "/settings/keybindings"
| "/settings/projects"
| "/settings/providers"
| "/settings/source-control"
| "/settings/connections"
@@ -23,7 +22,6 @@ export const SETTINGS_SECTION_LABELS: Readonly<Record<SettingsPath, string>> = {
"/settings/general": "General",
"/settings/appearance": "Appearance",
"/settings/keybindings": "Keybindings",
"/settings/projects": "Projects",
"/settings/providers": "Providers",
"/settings/source-control": "Source Control",
"/settings/connections": "Connections",
@@ -176,31 +174,6 @@ export const SETTINGS_SEARCH_ITEMS = [
title: "Keybindings",
to: "/settings/keybindings",
},
{
id: "projects",
title: "Projects",
to: "/settings/projects",
},
{
id: "project-default-model",
title: "Project default model",
to: "/settings/projects",
},
{
id: "project-new-thread-workspace",
title: "Project new-thread workspace",
to: "/settings/projects",
},
{
id: "project-scripts",
title: "Project scripts",
to: "/settings/projects",
},
{
id: "project-checkouts",
title: "Project checkouts",
to: "/settings/projects",
},
{
id: "providers",
title: "Providers",
+21 -43
View File
@@ -17,15 +17,14 @@ import { Route as ChatRouteImport } from './routes/_chat'
import { Route as ChatIndexRouteImport } from './routes/_chat.index'
import { Route as SettingsSourceControlRouteImport } from './routes/settings.source-control'
import { Route as SettingsProvidersRouteImport } from './routes/settings.providers'
import { Route as SettingsProjectsRouteImport } from './routes/settings.projects'
import { Route as SettingsKeybindingsRouteImport } from './routes/settings.keybindings'
import { Route as SettingsGeneralRouteImport } from './routes/settings.general'
import { Route as SettingsDiagnosticsRouteImport } from './routes/settings.diagnostics'
import { Route as SettingsConnectionsRouteImport } from './routes/settings.connections'
import { Route as SettingsArchivedRouteImport } from './routes/settings.archived'
import { Route as SettingsAppearanceRouteImport } from './routes/settings.appearance'
import { Route as ProjectsProjectKeyRouteImport } from './routes/projects.$projectKey'
import { Route as ConnectCallbackRouteImport } from './routes/connect_.callback'
import { Route as SettingsProjectsProjectKeyRouteImport } from './routes/settings.projects_.$projectKey'
import { Route as ChatDraftDraftIdRouteImport } from './routes/_chat.draft.$draftId'
import { Route as ChatEnvironmentIdThreadIdRouteImport } from './routes/_chat.$environmentId.$threadId'
@@ -68,11 +67,6 @@ const SettingsProvidersRoute = SettingsProvidersRouteImport.update({
path: '/providers',
getParentRoute: () => SettingsRoute,
} as any)
const SettingsProjectsRoute = SettingsProjectsRouteImport.update({
id: '/projects',
path: '/projects',
getParentRoute: () => SettingsRoute,
} as any)
const SettingsKeybindingsRoute = SettingsKeybindingsRouteImport.update({
id: '/keybindings',
path: '/keybindings',
@@ -103,17 +97,16 @@ const SettingsAppearanceRoute = SettingsAppearanceRouteImport.update({
path: '/appearance',
getParentRoute: () => SettingsRoute,
} as any)
const ProjectsProjectKeyRoute = ProjectsProjectKeyRouteImport.update({
id: '/projects/$projectKey',
path: '/projects/$projectKey',
getParentRoute: () => rootRouteImport,
} as any)
const ConnectCallbackRoute = ConnectCallbackRouteImport.update({
id: '/connect_/callback',
path: '/connect/callback',
getParentRoute: () => rootRouteImport,
} as any)
const SettingsProjectsProjectKeyRoute =
SettingsProjectsProjectKeyRouteImport.update({
id: '/projects_/$projectKey',
path: '/projects/$projectKey',
getParentRoute: () => SettingsRoute,
} as any)
const ChatDraftDraftIdRoute = ChatDraftDraftIdRouteImport.update({
id: '/draft/$draftId',
path: '/draft/$draftId',
@@ -133,18 +126,17 @@ export interface FileRoutesByFullPath {
'/settings': typeof SettingsRouteWithChildren
'/usage': typeof UsageRoute
'/connect/callback': typeof ConnectCallbackRoute
'/projects/$projectKey': typeof ProjectsProjectKeyRoute
'/settings/appearance': typeof SettingsAppearanceRoute
'/settings/archived': typeof SettingsArchivedRoute
'/settings/connections': typeof SettingsConnectionsRoute
'/settings/diagnostics': typeof SettingsDiagnosticsRoute
'/settings/general': typeof SettingsGeneralRoute
'/settings/keybindings': typeof SettingsKeybindingsRoute
'/settings/projects': typeof SettingsProjectsRoute
'/settings/providers': typeof SettingsProvidersRoute
'/settings/source-control': typeof SettingsSourceControlRoute
'/$environmentId/$threadId': typeof ChatEnvironmentIdThreadIdRoute
'/draft/$draftId': typeof ChatDraftDraftIdRoute
'/settings/projects/$projectKey': typeof SettingsProjectsProjectKeyRoute
}
export interface FileRoutesByTo {
'/connect': typeof ConnectRoute
@@ -152,19 +144,18 @@ export interface FileRoutesByTo {
'/settings': typeof SettingsRouteWithChildren
'/usage': typeof UsageRoute
'/connect/callback': typeof ConnectCallbackRoute
'/projects/$projectKey': typeof ProjectsProjectKeyRoute
'/settings/appearance': typeof SettingsAppearanceRoute
'/settings/archived': typeof SettingsArchivedRoute
'/settings/connections': typeof SettingsConnectionsRoute
'/settings/diagnostics': typeof SettingsDiagnosticsRoute
'/settings/general': typeof SettingsGeneralRoute
'/settings/keybindings': typeof SettingsKeybindingsRoute
'/settings/projects': typeof SettingsProjectsRoute
'/settings/providers': typeof SettingsProvidersRoute
'/settings/source-control': typeof SettingsSourceControlRoute
'/': typeof ChatIndexRoute
'/$environmentId/$threadId': typeof ChatEnvironmentIdThreadIdRoute
'/draft/$draftId': typeof ChatDraftDraftIdRoute
'/settings/projects/$projectKey': typeof SettingsProjectsProjectKeyRoute
}
export interface FileRoutesById {
__root__: typeof rootRouteImport
@@ -174,19 +165,18 @@ export interface FileRoutesById {
'/settings': typeof SettingsRouteWithChildren
'/usage': typeof UsageRoute
'/connect_/callback': typeof ConnectCallbackRoute
'/projects/$projectKey': typeof ProjectsProjectKeyRoute
'/settings/appearance': typeof SettingsAppearanceRoute
'/settings/archived': typeof SettingsArchivedRoute
'/settings/connections': typeof SettingsConnectionsRoute
'/settings/diagnostics': typeof SettingsDiagnosticsRoute
'/settings/general': typeof SettingsGeneralRoute
'/settings/keybindings': typeof SettingsKeybindingsRoute
'/settings/projects': typeof SettingsProjectsRoute
'/settings/providers': typeof SettingsProvidersRoute
'/settings/source-control': typeof SettingsSourceControlRoute
'/_chat/': typeof ChatIndexRoute
'/_chat/$environmentId/$threadId': typeof ChatEnvironmentIdThreadIdRoute
'/_chat/draft/$draftId': typeof ChatDraftDraftIdRoute
'/settings/projects_/$projectKey': typeof SettingsProjectsProjectKeyRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
@@ -197,18 +187,17 @@ export interface FileRouteTypes {
| '/settings'
| '/usage'
| '/connect/callback'
| '/projects/$projectKey'
| '/settings/appearance'
| '/settings/archived'
| '/settings/connections'
| '/settings/diagnostics'
| '/settings/general'
| '/settings/keybindings'
| '/settings/projects'
| '/settings/providers'
| '/settings/source-control'
| '/$environmentId/$threadId'
| '/draft/$draftId'
| '/settings/projects/$projectKey'
fileRoutesByTo: FileRoutesByTo
to:
| '/connect'
@@ -216,19 +205,18 @@ export interface FileRouteTypes {
| '/settings'
| '/usage'
| '/connect/callback'
| '/projects/$projectKey'
| '/settings/appearance'
| '/settings/archived'
| '/settings/connections'
| '/settings/diagnostics'
| '/settings/general'
| '/settings/keybindings'
| '/settings/projects'
| '/settings/providers'
| '/settings/source-control'
| '/'
| '/$environmentId/$threadId'
| '/draft/$draftId'
| '/settings/projects/$projectKey'
id:
| '__root__'
| '/_chat'
@@ -237,19 +225,18 @@ export interface FileRouteTypes {
| '/settings'
| '/usage'
| '/connect_/callback'
| '/projects/$projectKey'
| '/settings/appearance'
| '/settings/archived'
| '/settings/connections'
| '/settings/diagnostics'
| '/settings/general'
| '/settings/keybindings'
| '/settings/projects'
| '/settings/providers'
| '/settings/source-control'
| '/_chat/'
| '/_chat/$environmentId/$threadId'
| '/_chat/draft/$draftId'
| '/settings/projects_/$projectKey'
fileRoutesById: FileRoutesById
}
export interface RootRouteChildren {
@@ -259,6 +246,7 @@ export interface RootRouteChildren {
SettingsRoute: typeof SettingsRouteWithChildren
UsageRoute: typeof UsageRoute
ConnectCallbackRoute: typeof ConnectCallbackRoute
ProjectsProjectKeyRoute: typeof ProjectsProjectKeyRoute
}
declare module '@tanstack/react-router' {
@@ -319,13 +307,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof SettingsProvidersRouteImport
parentRoute: typeof SettingsRoute
}
'/settings/projects': {
id: '/settings/projects'
path: '/projects'
fullPath: '/settings/projects'
preLoaderRoute: typeof SettingsProjectsRouteImport
parentRoute: typeof SettingsRoute
}
'/settings/keybindings': {
id: '/settings/keybindings'
path: '/keybindings'
@@ -368,6 +349,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof SettingsAppearanceRouteImport
parentRoute: typeof SettingsRoute
}
'/projects/$projectKey': {
id: '/projects/$projectKey'
path: '/projects/$projectKey'
fullPath: '/projects/$projectKey'
preLoaderRoute: typeof ProjectsProjectKeyRouteImport
parentRoute: typeof rootRouteImport
}
'/connect_/callback': {
id: '/connect_/callback'
path: '/connect/callback'
@@ -375,13 +363,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ConnectCallbackRouteImport
parentRoute: typeof rootRouteImport
}
'/settings/projects_/$projectKey': {
id: '/settings/projects_/$projectKey'
path: '/projects/$projectKey'
fullPath: '/settings/projects/$projectKey'
preLoaderRoute: typeof SettingsProjectsProjectKeyRouteImport
parentRoute: typeof SettingsRoute
}
'/_chat/draft/$draftId': {
id: '/_chat/draft/$draftId'
path: '/draft/$draftId'
@@ -420,10 +401,8 @@ interface SettingsRouteChildren {
SettingsDiagnosticsRoute: typeof SettingsDiagnosticsRoute
SettingsGeneralRoute: typeof SettingsGeneralRoute
SettingsKeybindingsRoute: typeof SettingsKeybindingsRoute
SettingsProjectsRoute: typeof SettingsProjectsRoute
SettingsProvidersRoute: typeof SettingsProvidersRoute
SettingsSourceControlRoute: typeof SettingsSourceControlRoute
SettingsProjectsProjectKeyRoute: typeof SettingsProjectsProjectKeyRoute
}
const SettingsRouteChildren: SettingsRouteChildren = {
@@ -433,10 +412,8 @@ const SettingsRouteChildren: SettingsRouteChildren = {
SettingsDiagnosticsRoute: SettingsDiagnosticsRoute,
SettingsGeneralRoute: SettingsGeneralRoute,
SettingsKeybindingsRoute: SettingsKeybindingsRoute,
SettingsProjectsRoute: SettingsProjectsRoute,
SettingsProvidersRoute: SettingsProvidersRoute,
SettingsSourceControlRoute: SettingsSourceControlRoute,
SettingsProjectsProjectKeyRoute: SettingsProjectsProjectKeyRoute,
}
const SettingsRouteWithChildren = SettingsRoute._addFileChildren(
@@ -450,6 +427,7 @@ const rootRouteChildren: RootRouteChildren = {
SettingsRoute: SettingsRouteWithChildren,
UsageRoute: UsageRoute,
ConnectCallbackRoute: ConnectCallbackRoute,
ProjectsProjectKeyRoute: ProjectsProjectKeyRoute,
}
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
@@ -0,0 +1,15 @@
import { createFileRoute, redirect } from "@tanstack/react-router";
import { ProjectSettingsPage } from "../components/settings/ProjectSettingsPanel";
export const Route = createFileRoute("/projects/$projectKey")({
beforeLoad: async ({ context }) => {
if (
context.authGateState.status !== "authenticated" &&
context.authGateState.status !== "hosted-static"
) {
throw redirect({ to: "/pair", replace: true });
}
},
component: () => <ProjectSettingsPage projectKey={Route.useParams().projectKey} />,
});
-11
View File
@@ -1,11 +0,0 @@
import { createFileRoute } from "@tanstack/react-router";
import { ProjectSettingsPanel } from "../components/settings/ProjectSettingsPanel";
function SettingsProjectsRoute() {
return <ProjectSettingsPanel selectedProjectKey={null} />;
}
export const Route = createFileRoute("/settings/projects")({
component: SettingsProjectsRoute,
});
@@ -1,12 +0,0 @@
import { createFileRoute } from "@tanstack/react-router";
import { ProjectSettingsPanel } from "../components/settings/ProjectSettingsPanel";
function SettingsProjectDetailRoute() {
const { projectKey } = Route.useParams();
return <ProjectSettingsPanel selectedProjectKey={projectKey} />;
}
export const Route = createFileRoute("/settings/projects_/$projectKey")({
component: SettingsProjectDetailRoute,
});
@@ -71,6 +71,28 @@ describe("buildProjectGroups", () => {
}
});
it("uses a shared custom title as the repository group's label", () => {
const projects = [
makeProject("first", "/work/t3code", { title: "Custom project" }),
makeProject("second", "/work/t3code-2", { title: "Custom project" }),
];
expect(buildProjectGroups({ projects, settings: settings("repository") })[0]?.label).toBe(
"Custom project",
);
});
it("keeps the repository label when shared titles match its repository name", () => {
const projects = [
makeProject("first", "/work/t3code", { title: "t3code" }),
makeProject("second", "/work/t3code-2", { title: "t3code" }),
];
expect(buildProjectGroups({ projects, settings: settings("repository") })[0]?.label).toBe(
"T3 Code",
);
});
it("keeps physical clones in separate groups when requested", () => {
const projects = [
makeProject("t3code", "/work/t3code"),
@@ -169,16 +169,26 @@ export function deriveProjectGroupLabel(input: {
readonly representative: Pick<EnvironmentProject, "title" | "repositoryIdentity">;
readonly members: ReadonlyArray<Pick<EnvironmentProject, "title" | "repositoryIdentity">>;
}): string {
const sharedTitles = uniqueNonEmptyValues(input.members.map((member) => member.title));
const sharedDisplayNames = uniqueNonEmptyValues(
input.members.map((member) => member.repositoryIdentity?.displayName),
);
const sharedRepositoryNames = uniqueNonEmptyValues(
input.members.map((member) => member.repositoryIdentity?.name),
);
const sharedTitle = sharedTitles[0];
if (
sharedTitles.length === 1 &&
sharedTitle !== undefined &&
!sharedDisplayNames.includes(sharedTitle) &&
!sharedRepositoryNames.includes(sharedTitle)
) {
return sharedTitle;
}
if (sharedDisplayNames.length === 1) {
return sharedDisplayNames[0]!;
}
const sharedRepositoryNames = uniqueNonEmptyValues(
input.members.map((member) => member.repositoryIdentity?.name),
);
if (sharedRepositoryNames.length === 1) {
return sharedRepositoryNames[0]!;
}