@devries-cameron20 / t3code Mirror · read-only / commits / f2513bd288
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 05:45 UTC

fix(web): project settings can set a checkout's grouping rule again (#23641)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 2, 2026 at 18:01 UTC f2513bd28870b0c06d0eb2bd4af3523a77ac084e
2 files changed +130 -19
apps/web/src/components/settings/ProjectSettingsPanel.tsx
+108 -18
@@ -5,7 +5,7 @@ import { useEnvironmentsWithScope } from "../../state/session";
5 import { mapAtomCommandResult, settlePromise } from "@t3tools/client-runtime/state/runtime";
6 import { scopeProjectRef, scopeThreadRef } from "@t3tools/client-runtime/environment";
7 import { planProjectRemoval } from "@t3tools/client-runtime/state/projects";
8 -import { type EnvironmentId } from "@t3tools/contracts";
8 +import { type EnvironmentId, type SidebarProjectGroupingMode } from "@t3tools/contracts";
9 import {
10 checkProjectAccess,
11 reportProjectFailure,
@@ -18,8 +18,12 @@ import { lazy, Suspense, useRef, useState, type ReactNode } from "react";
18
19 import { useComposerDraftStore } from "../../composerDraftStore";
20 import { releaseProjectDraftUploads } from "../../lib/composerDraftUploads";
21 +import { persistClientSettingsUpdate, useClientSettings } from "../../hooks/useSettings";
22 import { readLocalApi } from "../../localApi";
23 +import { derivePhysicalProjectKey } from "@t3tools/client-runtime/state/project-grouping";
24 import {
25 + PROJECT_GROUPING_MODE_LABELS,
26 + withProjectGroupingOverride,
27 type SidebarProjectGroupMember,
28 type SidebarProjectSnapshot,
29 } from "../../sidebarProjectGrouping";
@@ -30,8 +34,9 @@ import { ProjectFavicon } from "../ProjectFavicon";
34 import { Alert, AlertDescription } from "../ui/alert";
35 import { Button } from "../ui/button";
36 import { Input } from "../ui/input";
37 +import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
38 import { Switch } from "../ui/switch";
34 -import { toastManager } from "../ui/toast";
39 +import { stackedThreadToast, toastManager } from "../ui/toast";
40 import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
41 import {
42 SettingResetButton,
@@ -61,6 +66,78 @@ const ProjectIconPickerDialog = lazy(() =>
66 })),
67 );
68
69 +function isGroupingSelection(value: unknown): value is SidebarProjectGroupingMode | "inherit" {
70 + return (
71 + value === "inherit" ||
72 + value === "repository" ||
73 + value === "repository_path" ||
74 + value === "separate"
75 + );
76 +}
77 +
78 +// Grouping overrides are client settings, so they stay editable without project write access.
79 +function CheckoutGroupingSelect({ member }: { member: SidebarProjectGroupMember }) {
80 + const overrideKey = derivePhysicalProjectKey(member);
81 + const globalMode = useClientSettings((settings) => settings.sidebarProjectGroupingMode);
82 + const selection = useClientSettings(
83 + (settings) => settings.sidebarProjectGroupingOverrides?.[overrideKey] ?? "inherit",
84 + );
85 + return (
86 + <Select
87 + value={selection}
88 + onValueChange={(value) => {
89 + if (!isGroupingSelection(value)) return;
90 + persistClientSettingsUpdate((current) => ({
91 + ...current,
92 + sidebarProjectGroupingOverrides: withProjectGroupingOverride(
93 + current.sidebarProjectGroupingOverrides,
94 + overrideKey,
95 + value,
96 + ),
97 + })).catch((error) => {
98 + console.error("Failed to save checkout grouping rule", error);
99 + toastManager.add(
100 + stackedThreadToast({
101 + type: "error",
102 + title: "Could not save grouping rule",
103 + description: error instanceof Error ? error.message : "An error occurred.",
104 + }),
105 + );
106 + });
107 + }}
108 + >
109 + <SelectTrigger
110 + size="sm"
111 + aria-label={`Grouping rule for ${member.workspaceRoot} on ${
112 + member.environmentLabel
113 + ? `${member.environmentLabel} (${member.environmentId})`
114 + : member.environmentId
115 + }`}
116 + >
117 + <SelectValue>
118 + {selection === "inherit"
119 + ? `Default (${PROJECT_GROUPING_MODE_LABELS[globalMode]})`
120 + : PROJECT_GROUPING_MODE_LABELS[selection]}
121 + </SelectValue>
122 + </SelectTrigger>
123 + <SelectPopup align="end" alignItemWithTrigger={false}>
124 + <SelectItem hideIndicator value="inherit">
125 + Use global default
126 + </SelectItem>
127 + <SelectItem hideIndicator value="repository">
128 + {PROJECT_GROUPING_MODE_LABELS.repository}
129 + </SelectItem>
130 + <SelectItem hideIndicator value="repository_path">
131 + {PROJECT_GROUPING_MODE_LABELS.repository_path}
132 + </SelectItem>
133 + <SelectItem hideIndicator value="separate">
134 + {PROJECT_GROUPING_MODE_LABELS.separate}
135 + </SelectItem>
136 + </SelectPopup>
137 + </Select>
138 + );
139 +}
140 +
141 export type ProjectSettingsCategory = "general" | "source-control" | "project";
142
143 interface ProjectSelection {
@@ -334,19 +411,32 @@ function ProjectDetail({
411 if (members) members.push(member);
412 else checkoutsByEnvironment.set(member.environmentId, [member]);
413 }
337 - const checkoutRemoveButton = (member: SidebarProjectGroupMember) => (
338 - <Button
339 - size="sm"
340 - variant="outline"
341 - disabled={!editableIds.has(member.environmentId)}
342 - onClick={() => void removeMembers([member])}
343 - aria-label={`Remove checkout ${member.workspaceRoot}`}
344 - >
345 - Remove
346 - </Button>
414 + // A lone checkout is removed from the Danger section, but it still needs its grouping
415 + // rule here so "Keep separate" can be undone.
416 + const checkoutControls = (member: SidebarProjectGroupMember) => (
417 + <div className="flex w-full min-w-0 items-center gap-2 @min-[32rem]/settings-row:w-auto">
418 + <div className="min-w-0 flex-1 @min-[32rem]/settings-row:w-72 @min-[32rem]/settings-row:flex-none">
419 + <CheckoutGroupingSelect member={member} />
420 + </div>
421 + {hasMultipleCheckouts ? (
422 + <Button
423 + size="sm"
424 + variant="outline"
425 + disabled={!editableIds.has(member.environmentId)}
426 + onClick={() => void removeMembers([member])}
427 + aria-label={`Remove checkout ${member.workspaceRoot}`}
428 + >
429 + Remove
430 + </Button>
431 + ) : null}
432 + </div>
433 );
434 const checkoutChoices = (
435 <SettingsSection title="Checkouts">
436 + <p className="px-3 py-2.5 text-xs text-muted-foreground sm:px-4">
437 + Grouping rule decides how each checkout joins project groups in the sidebar. Changing it can
438 + move a checkout to a different project.
439 + </p>
440 {Array.from(checkoutsByEnvironment, ([environmentId, members]) => {
441 if (checkoutsByEnvironment.size === 1) {
442 return members.map((member) => (
@@ -354,7 +444,7 @@ function ProjectDetail({
444 key={member.physicalProjectKey}
445 title={member.environmentLabel ?? "Environment"}
446 description={member.workspaceRoot}
357 - control={checkoutRemoveButton(member)}
447 + control={checkoutControls(member)}
448 />
449 ));
450 }
@@ -383,26 +473,26 @@ function ProjectDetail({
473 ) : null}
474 </>
475 }
386 - control={hasMultiple ? undefined : checkoutRemoveButton(firstMember)}
476 + control={hasMultiple ? undefined : checkoutControls(firstMember)}
477 >
478 {hasMultiple ? (
479 <div className="space-y-3 pb-2 pt-1">
480 {members.map((member) => (
481 <div
482 key={member.physicalProjectKey}
393 - className="flex min-w-0 items-center justify-between gap-3"
483 + className="flex min-w-0 flex-col gap-1.5 @min-[36rem]/settings-row:flex-row @min-[36rem]/settings-row:items-center @min-[36rem]/settings-row:justify-between @min-[36rem]/settings-row:gap-3"
484 >
485 <Tooltip>
486 <TooltipTrigger
487 render={
398 - <span className="min-w-0 truncate text-xs text-muted-foreground/80" />
488 + <span className="min-w-0 max-w-full truncate text-xs text-muted-foreground/80" />
489 }
490 >
491 {member.workspaceRoot}
492 </TooltipTrigger>
493 <TooltipPopup>{member.workspaceRoot}</TooltipPopup>
494 </Tooltip>
405 - <div className="shrink-0">{checkoutRemoveButton(member)}</div>
495 + <div className="shrink-0">{checkoutControls(member)}</div>
496 </div>
497 ))}
498 </div>
@@ -565,7 +655,7 @@ function ProjectDetail({
655 </SettingsSection>
656 <ProjectDefaultsSettings category="project" />
657 <ProjectActionsSettings />
568 - {hasMultipleCheckouts ? checkoutChoices : null}
658 + {checkoutChoices}
659 <SettingsSection title="Danger">
660 <SettingsRow
661 title={
apps/web/src/sidebarProjectGrouping.ts
+22 -1
@@ -1,4 +1,8 @@
1 -import type { EnvironmentId, ScopedProjectRef } from "@t3tools/contracts";
1 +import type {
2 + EnvironmentId,
3 + ScopedProjectRef,
4 + SidebarProjectGroupingMode,
5 +} from "@t3tools/contracts";
6 import {
7 buildProjectGroups,
8 derivePhysicalProjectKey,
@@ -7,6 +11,23 @@ import {
11 } from "@t3tools/client-runtime/state/project-grouping";
12 import type { Project } from "./types";
13
14 +export const PROJECT_GROUPING_MODE_LABELS: Record<SidebarProjectGroupingMode, string> = {
15 + repository: "Group by repository",
16 + repository_path: "Group by repository path",
17 + separate: "Keep separate",
18 +};
19 +
20 +export function withProjectGroupingOverride(
21 + overrides: Readonly<Record<string, SidebarProjectGroupingMode>> | undefined,
22 + overrideKey: string,
23 + selection: SidebarProjectGroupingMode | "inherit",
24 +): Record<string, SidebarProjectGroupingMode> {
25 + const next = { ...overrides };
26 + if (selection === "inherit") delete next[overrideKey];
27 + else next[overrideKey] = selection;
28 + return next;
29 +}
30 +
31 export type EnvironmentPresence = "local-only" | "remote-only" | "mixed";
32
33 export interface SidebarProjectGroupMember extends Project {