Skip to content

Commit 8bac3c2

Browse files
donjor-agent[bot]donjor
authored andcommitted
feat(web): the project chooser selects several projects
## What Changed The sidebar scope combobox is now a multi-select project chooser, through a fork-owned adapter. - **Header:** `Projects: All`, one project's name, or `Projects: N selected` - **Rows:** check mark, Show only, click to add or remove - **Offline entry:** stays selected, marked Unavailable - **Palette:** "Choose projects" entry - **Keybinding:** `projectFilter.choose` on `mod+alt+f` (no other default uses it) - **Issues and PR lists:** a scope label that opens the same chooser The earlier "several entries shows All projects" interim is gone: upstream's stale reset no longer wipes a filter of several entries. ## Why Each window filters several projects since #1373, but the chooser could only pick one. ## Mobile Mobile keeps single-select because its choosers are native menus that dismiss on every press, and the Home list filters by one selected project. ## UI Changes No screenshots yet; live proof is done separately. ## Checklist - [x] This PR is small and focused - [x] I explained what changed and why - [ ] I included before/after screenshots for any UI changes - [ ] I included a video for animation/interaction changes ## Close conditions - [ ] **Chooser:** value, label, icon, empty state - [x] **Stale keys:** reset keeps valid entries - [ ] **Surfaces:** each table row opens it Tests cover the chooser's value, label and empty state, but not its icon. The surfaces still need a live check. Closes #1352 Claude Opus 5.5 in Claude Code. ## Fork trailers Fork-Domain: workspaces Fork-Tier: core Co-authored-by: donjor <[email protected]>
1 parent 8eefa56 commit 8bac3c2

14 files changed

Lines changed: 539 additions & 67 deletions

‎apps/server/src/keybindings.fork.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ describe("fork keybinding defaults", () => {
2727
).map((binding) => binding.command);
2828
assert.deepEqual(owners, ["window.new"]);
2929
});
30+
31+
it("gives the project chooser a chord no other default uses", () => {
32+
const owners = Keybindings.DEFAULT_KEYBINDINGS.filter(
33+
(binding) => binding.key === "mod+alt+f",
34+
).map((binding) => binding.command);
35+
assert.deepEqual(owners, ["projectFilter.choose"]);
36+
});
3037
});
3138

3239
describe("fork keybinding command renames", () => {

‎apps/web/src/components/CommandPalette.fork.tsx‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
// upstream `CommandPalette.tsx` carries only marked hook lines pointing here;
44
// the capability probe, the navigation command, and the action item are built
55
// in this module.
6-
import { CircleDotIcon } from "lucide-react";
6+
import { CircleDotIcon, ListFilterIcon } from "lucide-react";
77

8+
import { openProjectChooser } from "../projectChooser.fork";
89
import { listRouteTarget, resolveProjectRefFromPathname } from "../projectRoutes";
910
import { ITEM_ICON_CLASS, type CommandPaletteActionItem } from "./CommandPalette.logic";
1011
import type { ScopedProjectRef } from "@t3tools/contracts";
@@ -55,3 +56,28 @@ export function buildGitHubIssuesActionItemFork(input: {
5556
},
5657
};
5758
}
59+
60+
/**
61+
* The palette's "Choose projects" entry (RSI-Software/t3code-hyprws#1352), or
62+
* `null` where no sidebar chooser serves this window (`label` is `null`).
63+
*/
64+
export function buildProjectChooserActionItemFork(
65+
label: string | null,
66+
): CommandPaletteActionItem | null {
67+
if (label === null) return null;
68+
return {
69+
kind: "action",
70+
value: "action:choose-projects",
71+
searchTerms: ["projects", "filter", "choose", "scope", "sidebar", "select"],
72+
title: "Choose projects",
73+
description: label,
74+
icon: <ListFilterIcon className={ITEM_ICON_CLASS} />,
75+
shortcutCommand: "projectFilter.choose",
76+
run: async () => {
77+
// Open once the palette has closed, so its focus return does not land after.
78+
requestAnimationFrame(() => {
79+
openProjectChooser();
80+
});
81+
},
82+
};
83+
}

‎apps/web/src/components/CommandPalette.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ import {
5050
resolveEnvironmentMachineKind,
5151
} from "@t3tools/contracts";
5252
import { buildGitHubIssuesActionItemFork } from "./CommandPalette.fork"; // fork-hook: github-issues/command-palette-import
53+
import { buildProjectChooserActionItemFork } from "./CommandPalette.fork"; // fork-hook: workspaces/chooser-palette
54+
import { useProjectChooserLabel } from "../projectChooser.fork"; // fork-hook: workspaces/chooser-palette
5355
import { useLocation, useNavigate } from "@tanstack/react-router";
5456
import {
5557
ArrowLeftIcon,
@@ -367,6 +369,7 @@ function OpenCommandPaletteDialog(props: {
367369
const pathname = useLocation({ select: (location) => location.pathname });
368370
const routeFamily = useThreadRouteFamily();
369371
const { openChildSearch, setOpen } = props;
372+
const projectChooserLabel = useProjectChooserLabel(); // fork-hook: workspaces/chooser-palette
370373
// Keyed by palette session: the intent and restored search only seed this
371374
// mount, and closing must not change what the closing palette shows.
372375
const [initialSearch] = useState(
@@ -1512,6 +1515,8 @@ function OpenCommandPaletteDialog(props: {
15121515
navigate,
15131516
}); // fork-hook: github-issues/command-palette-entry
15141517
if (githubIssuesActionItem) actionItems.push(githubIssuesActionItem); // fork-hook: github-issues/command-palette-entry-push
1518+
const projectChooserActionItem = buildProjectChooserActionItemFork(projectChooserLabel); // fork-hook: workspaces/chooser-palette
1519+
if (projectChooserActionItem) actionItems.push(projectChooserActionItem); // fork-hook: workspaces/chooser-palette
15151520

15161521
actionItems.push({
15171522
kind: "action",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Fork-owned: the Issues and Pull requests scope label for the window's project
2+
// chooser (RSI-Software/t3code-hyprws#1352). It names the window's project
3+
// filter and opens the sidebar's chooser; a project window, which has no
4+
// chooser, keeps its "This project / All projects" toggle instead.
5+
import { FolderIcon } from "lucide-react";
6+
7+
import { openProjectChooser, useProjectChooserLabel } from "../projectChooser.fork";
8+
import { Button } from "./ui/button";
9+
10+
export function ProjectChooserScopeLabelFork() {
11+
const label = useProjectChooserLabel();
12+
if (label === null) return null;
13+
return (
14+
<Button
15+
size="sm"
16+
variant="outline"
17+
aria-label={`Choose projects (${label})`}
18+
onClick={() => openProjectChooser()}
19+
>
20+
<FolderIcon />
21+
{label}
22+
</Button>
23+
);
24+
}

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import {
6666
} from "@t3tools/contracts";
6767
import type { OlderSettledScope } from "@t3tools/client-runtime/state/threads";
6868

69-
import { ChevronDownIcon, FolderIcon, ListFilterIcon, PlusIcon, SettingsIcon } from "lucide-react";
69+
import { ChevronDownIcon, FolderIcon, PlusIcon, SettingsIcon } from "lucide-react"; // fork-hook: workspaces/chooser-icons
7070
import {
7171
useEffect,
7272
useLayoutEffect,
@@ -92,6 +92,13 @@ import { useOpenProjectWindowFork } from "./Sidebar.fork"; // fork-hook: project
9292
import { SidebarOpenProjectWindowButtonFork } from "./Sidebar.fork"; // fork-hook: project-windows/sidebar-open-window-button-import
9393
import { useWindowSidebarScopeSeed } from "../windowSidebarScope.fork"; // fork-hook: multi-window/window-sidebar-scope-seed-import
9494
import { useWindowProjectFilter } from "../windowProjectFilter.fork"; // fork-hook: workspaces/filter-import
95+
import {
96+
ProjectChooserRowCheckFork,
97+
ProjectChooserShowOnlyButtonFork,
98+
ProjectChooserTriggerIconFork,
99+
ProjectChooserUnavailableFork,
100+
useSidebarProjectChooserFork,
101+
} from "./sidebar/SidebarProjectChooser.fork"; // fork-hook: workspaces/chooser-import
95102
import { isElectron } from "../env";
96103
import {
97104
resolveShortcutCommand,
@@ -212,7 +219,6 @@ import {
212219
sortWorkingThreadsBySend,
213220
useSnoozeWakeClock,
214221
useThreadJumpHintsVisible,
215-
type SidebarListItem,
216222
type SidebarSection,
217223
resolveSidebarRowThreadId,
218224
} from "./Sidebar.logic";
@@ -950,6 +956,14 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
950956
reduceSidebarProjectScopeMenuState,
951957
{ open: false, query: "" },
952958
);
959+
const windowFilter = useWindowProjectFilter(projectGroups); // fork-hook: workspaces/filter
960+
const projectChooser = useSidebarProjectChooserFork({
961+
filter: windowFilter.filter,
962+
setFilter: windowFilter.setFilter,
963+
projectGroups,
964+
enabled: projectGroups.length > 0, // fork-hook: workspaces/chooser
965+
setMenuOpen: (open) => dispatchProjectScopeMenu({ type: "open-changed", open }),
966+
}); // fork-hook: workspaces/chooser
953967
const projectScopeFilter = useComboboxFilter();
954968
const allProjectSnapshotsReady = useAllEnvironmentProjectSnapshotsReady();
955969
const allProjectConfigsReady = useAtomValue(environmentProjects.projectConfigsReadyAtom);
@@ -1208,7 +1222,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
12081222
pinnedKeysById,
12091223
activeKeysById,
12101224
} = useSidebarThreads({
1211-
projectScopeKey,
1225+
projectScopeKey: projectChooser.label, // fork-hook: workspaces/chooser-settled-reset
12121226
scopedProjectKeys,
12131227
serverConfigs,
12141228
optimisticDrop,
@@ -3017,7 +3031,8 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
30173031
hasProjects={projectGroups.length > 0}
30183032
projectScope={
30193033
<Combobox
3020-
items={projectScopeItems}
3034+
multiple // fork-hook: workspaces/chooser-multiple
3035+
items={projectChooser.items} // fork-hook: workspaces/chooser-items
30213036
filteredItems={filteredProjectScopeItems}
30223037
autoHighlight
30233038
itemToStringLabel={(item) => item.label}
@@ -3031,28 +3046,20 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
30313046
onItemHighlighted={(item) => {
30323047
highlightedProjectScopeKeyRef.current = item?.value ?? null;
30333048
}}
3034-
value={selectedProjectScopeItem}
3049+
value={projectChooser.value} // fork-hook: workspaces/chooser-value
30353050
onValueChange={(item) => {
30363051
if (suppressNextScopeChangeRef.current) {
30373052
suppressNextScopeChangeRef.current = false;
30383053
return;
30393054
}
3040-
if (!item || forcedProjectRef !== null) return;
3041-
setSidebarLogicalScope(
3042-
forcedProjectRef,
3043-
item.value === "all" ? null : item.value,
3044-
setProjectScopeKey,
3045-
);
3055+
if (forcedProjectRef !== null) return; // fork-hook: workspaces/chooser-change
3056+
projectChooser.onValueChange(item); // fork-hook: workspaces/chooser-change
30463057
}}
30473058
>
30483059
<ComboboxTrigger
30493060
render={
30503061
<SidebarHeaderIconButton
3051-
label={
3052-
scopedProjectGroup
3053-
? `Filter threads by project: ${scopedProjectGroup.displayName}`
3054-
: "Filter threads by project"
3055-
}
3062+
label={projectChooser.label} // fork-hook: workspaces/chooser-label
30563063
disabled={forcedProjectRef !== null}
30573064
/>
30583065
}
@@ -3062,7 +3069,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
30623069
<ProjectFavicon project={scopedProjectGroup} className="size-4" />
30633070
</span>
30643071
) : (
3065-
<ListFilterIcon className="size-4" />
3072+
<ProjectChooserTriggerIconFork count={projectChooser.count} /> // fork-hook: workspaces/chooser-trigger-icon
30663073
)}
30673074
</ComboboxTrigger>
30683075
<ComboboxPopup
@@ -3109,20 +3116,38 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
31093116
if (project) handleProjectSettings(event, project);
31103117
}}
31113118
>
3119+
{/* fork-hook: workspaces/chooser-row-check */}
3120+
<ProjectChooserRowCheckFork
3121+
selected={projectChooser.selectedValues.has(item.value)}
3122+
/>
3123+
{/* fork-hook-end */}
31123124
{project ? (
31133125
<ProjectFavicon project={project} className="size-4 shrink-0" />
31143126
) : (
31153127
<FolderIcon className="size-4 shrink-0" />
31163128
)}
31173129
<span className="min-w-0 flex-1 truncate text-sm">{item.label}</span>
3130+
{/* fork-hook: workspaces/chooser-row-unavailable */}
3131+
<ProjectChooserUnavailableFork
3132+
unavailable={projectChooser.unavailableValues.has(item.value)}
3133+
/>
3134+
{/* fork-hook-end */}
31183135
{project && showProjectEnvironments ? (
31193136
<ProjectEnvironmentBadge
31203137
group={project}
31213138
primaryEnvironmentId={primaryEnvironmentId}
31223139
machineByEnvironmentId={environmentMachineById}
31233140
/>
31243141
) : null}
3125-
{/* fork-hook: project-windows/sidebar-open-window-button */}
3142+
{/* fork-hook: workspaces/chooser-row-show-only */}
3143+
{project ? (
3144+
<ProjectChooserShowOnlyButtonFork
3145+
project={project}
3146+
onShowOnly={projectChooser.showOnly}
3147+
/>
3148+
) : null}
3149+
{/* fork-hook-end */}
3150+
{/* fork-hook: multi-window/sidebar-open-window-button */}
31263151
{project ? (
31273152
<SidebarOpenProjectWindowButtonFork
31283153
desktopBridge={desktopBridge}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// Fork-owned: the sidebar scope combobox as the window's multi-select project
2+
// chooser (RSI-Software/t3code-hyprws#1352). `Sidebar.tsx` keeps upstream's
3+
// combobox and carries marked hook lines pointing here: the chooser state, its
4+
// value and change handler, the trigger's label and icon, and the row extras.
5+
import type { ProjectFilter } from "@t3tools/client-runtime/state/project-filter";
6+
import { CheckIcon, FocusIcon, FolderIcon, FoldersIcon } from "lucide-react";
7+
import { useCallback, useMemo, type MouseEvent as ReactMouseEvent } from "react";
8+
9+
import { cn } from "~/lib/utils";
10+
import {
11+
projectChooserState,
12+
projectFilterFromChooser,
13+
showOnlyProjectFilter,
14+
useProjectChooserHost,
15+
type ProjectChooserGroup,
16+
type ProjectChooserItem,
17+
} from "../../projectChooser.fork";
18+
import { Button } from "../ui/button";
19+
import { useSidebar } from "../ui/sidebar";
20+
21+
export function useSidebarProjectChooserFork<Group extends ProjectChooserGroup>(input: {
22+
readonly filter: ProjectFilter;
23+
readonly setFilter: (filter: ProjectFilter) => void;
24+
readonly projectGroups: ReadonlyArray<Group>;
25+
/** False where the header shows no chooser: a project window, or no projects. */
26+
readonly enabled: boolean;
27+
readonly setMenuOpen: (open: boolean) => void;
28+
}) {
29+
const { filter, setFilter, projectGroups, enabled, setMenuOpen } = input;
30+
const state = projectChooserState(filter, projectGroups);
31+
const selectedValues = new Set(state.value.map((item) => item.value));
32+
const unavailableValues = new Set(
33+
state.items.filter((item) => item.unavailable).map((item) => item.value),
34+
);
35+
const onValueChange = (items: ReadonlyArray<ProjectChooserItem>) =>
36+
setFilter(
37+
projectFilterFromChooser(
38+
filter,
39+
items.map((item) => item.value),
40+
projectGroups,
41+
),
42+
[filter, projectGroups, setFilter],
43+
);
44+
const showOnly = useCallback(
45+
(event: ReactMouseEvent<HTMLButtonElement>, group: Group) => {
46+
event.preventDefault();
47+
event.stopPropagation();
48+
setFilter(showOnlyProjectFilter(group));
49+
setMenuOpen(false);
50+
},
51+
[setFilter, setMenuOpen],
52+
);
53+
const { isMobile, setOpen, setOpenMobile } = useSidebar();
54+
const open = useCallback(() => {
55+
// The chooser sits in the sidebar header, so a hidden sidebar shows first.
56+
if (isMobile) setOpenMobile(true);
57+
else setOpen(true);
58+
setMenuOpen(true);
59+
}, [isMobile, setMenuOpen, setOpen, setOpenMobile]);
60+
useProjectChooserHost(open, state.label, enabled);
61+
return { ...state, selectedValues, unavailableValues, onValueChange, showOnly };
62+
}
63+
64+
/** The trigger's icon while no single project is selected: all, or several. */
65+
export function ProjectChooserTriggerIconFork({ count }: { readonly count: number }) {
66+
return count > 1 ? <FoldersIcon className="size-4" /> : <FolderIcon className="size-4" />;
67+
}
68+
69+
/** A row's selection mark; kept in layout when unselected so labels stay aligned. */
70+
export function ProjectChooserRowCheckFork({ selected }: { readonly selected: boolean }) {
71+
return (
72+
<CheckIcon aria-hidden className={cn("size-3.5 shrink-0", selected ? null : "invisible")} />
73+
);
74+
}
75+
76+
/** Marks a selected entry no current project carries, e.g. while its server is offline. */
77+
export function ProjectChooserUnavailableFork({ unavailable }: { readonly unavailable: boolean }) {
78+
if (!unavailable) return null;
79+
return <span className="ml-auto shrink-0 text-muted-foreground text-xs">Unavailable</span>;
80+
}
81+
82+
/** A project row's Show only: the filter becomes this project alone. */
83+
export function ProjectChooserShowOnlyButtonFork<Group extends ProjectChooserGroup>(props: {
84+
readonly project: Group;
85+
readonly onShowOnly: (event: ReactMouseEvent<HTMLButtonElement>, project: Group) => void;
86+
}) {
87+
return (
88+
<Button
89+
size="icon-xs"
90+
variant="ghost-muted"
91+
tabIndex={-1}
92+
aria-hidden="true"
93+
title={`Show only ${props.project.displayName}`}
94+
onPointerDown={(event) => event.stopPropagation()}
95+
onClick={(event) => props.onShowOnly(event, props.project)}
96+
>
97+
<FocusIcon className="size-3.5" />
98+
</Button>
99+
);
100+
}

0 commit comments

Comments
 (0)