Skip to content

Commit e2e24ff

Browse files
donjor-agent[bot]donjor
authored andcommitted
feat(web): simplify the window project chooser (#1669)
## Problem The project chooser's separate mode controls did not fit the app's native project list. ## Change Restores the icon-bearing **All projects** row and places the standard **Exclude** Switch at its right edge, keeping the current popup width. All projects resets picks and exclusion; the Switch retains picks while changing their meaning; clearing included picks shows **No projects**. Explicit No projects also publishes an empty desktop project scope. Stacked above #1663. The maintainer approved this design after VMON-3 review. Shared web/desktop chooser and client filter helpers; mobile UI, providers, and wire contracts are unchanged. **Preserved defect:** excluding every project still makes the new-thread picker list all excluded projects. This parent defect remains at the maintainer's request. ## Verification Head: `69eb05f7ba6205a4dae4ea903374e855365255ef`. Parent: `486b691b3eebbfe4b17960c9a9d6cdebcbef1a20`. | Check | Result | | --- | --- | | Chooser and window-scope tests | Exit 0, 24 tests | | Web typecheck and production build | Exit 0 each | | `vp run fork:ci` on this head | Exit 0 | | React Doctor, changed files | Exit 0, no findings; score 66/100 | | Real Chrome on VMON-3 | Desktop, 375px, pointer, Tab/Space, Home/Enter reset | | Search, modes, counts, All/None | Pass; None survives reload | | All-six-excluded picker | Known failure reproduced and preserved | | Required GitHub checks at 69eb05f | All eight passed | Native Electron, native mobile, and remote/relay/tunnel connections were not exercised. T3 preview was unavailable because of host AppArmor; Hypr verification was explicitly authorized. <details> <summary>Aftercare findings and limits</summary> The automated report is still marked reviewing older head `6b3d782`; its last completed findings refer to `c6a7e81`. No automated review of this head is claimed. | Item | Current source/evidence | | --- | --- | | A1: None reported as all projects | Fixed in `windowProjects.fork.ts`, with empty inclusion/publication regressions | | A2: unequal segmented controls | Superseded by the native Switch design; narrow layout inspected | | A3: all-excluded picker fallback | Intentionally preserved; reproduced with all six fixtures | Parent aftercare also remains in progress on `486b691`; all eight parent required checks passed. No aftercare job, bot-owned report, or other owner's session was modified. </details> <details> <summary>Before and after</summary> | Original parent chooser at 705e594 | Approved chooser at 69eb05f | | --- | --- | | ![Parent project chooser](https://github.com/user-attachments/assets/cdd8855a-7c84-4c57-aabe-429af7e2cab1) | ![Native All projects row with Folder icon and standard Exclude Switch](https://github.com/user-attachments/assets/d97cda94-d980-4aec-95c2-b11368897d9a) | </details> <details> <summary>Current-head Hypr recording and receipts</summary> Open the chooser, search gh, pick gh-bot and zmux, see **Projects: 2 selected**, exclude both, see **Projects: All except 2**, switch back, and reset All projects. The clean checkout at the full head above served the actual changed chooser from isolated worktree state on port 5936. https://github.com/user-attachments/assets/0c52e249-b643-4798-9829-7c1fd61ea41f Hypr take `rec-e04f.e1`, window `18000197`, VMON-3, workspace 103. H.264, 380x480, 11.2 seconds, 30fps, no audio or speed changes. Retained raw 9.8-21.0 seconds; removed opening 0-9.8 and trailing 21.0-21.07 idle; no internal cuts; crop `380:480:0:86`. Browser-only masking hides thread content and main; the chooser and its native count tooltips are unchanged. Project names and icons remain visible. The published attachment was downloaded through `ghb attachment get`, matched byte-for-byte, and played in Chrome to `ended=true`, time/duration 11.2, error null. SHA-256: `a98f972b9d82c9dc7fa5d65f573c2df5a8b2bd0a7879793c7bc7fa766f8ee68b`. GitHub's embedded player is unverified; no accepted peer or grounder handoff is claimed. The CLI returned page `pg-29`, rather than a lease UUID; no strict accept-envelope validation is claimed. Actual tool-result receipts: | Result | Observed operation | | --- | --- | | `102f5a`, exit 0 | Read hypr, chrome-debug, frontend-design, ui, zmux SKILL.md contents | | `546914`, exit 0 | Read gh-bot, gh-post, writing-md SKILL.md contents | | `076658`, exit 0 | Read evidence upload/readback guide and gh-post style | | `cf683b`, exit 0 | Read gh-bot, gh-tracking, gh-post before publication | | `7c6c78` / `6870b2`, exit 0 | Hypr capture start/stop | | `2c19fb`, exit 0 | Trim/crop final recording and hash | | `b7b1bf`, exit 0 | Upload current-head screenshot and recording | | `54949f`, exit 0 | Download and byte comparison of published recording | These are actual read/result receipts, rather than skill loading inferred from screenshots. Body publication uses the active Codex harness directly because managed-terminal publishing previously lacked caller provenance; no identity bypass is used. </details> Model: GPT-6.1-Sol. Harness: Codex. ## Fork trailers Squashes: - eb8e361 feat(web): simplify the window project chooser (#1669) (#1669) - 70f48e8 fixup! feat(web): simplify the window project chooser (#1669) (#1669) Fork-Domain: workspaces Fork-Tier: qol
1 parent a939d91 commit e2e24ff

17 files changed

Lines changed: 251 additions & 116 deletions

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ export function buildProjectChooserActionItemFork(
108108
const NEW_THREAD_IN_VIEW = "projects";
109109

110110
export interface CommandPaletteProjectScope {
111+
/** Explicit inclusion can intentionally show no projects. */
112+
readonly preserveEmpty?: boolean;
111113
/** The project keys the palette shows; `null` shows every project. */
112114
readonly projectKeys: ReadonlySet<string> | null;
113115
/** The toggle between the filter and every project; `null` when unscoped. */
@@ -150,8 +152,12 @@ export function useCommandPaletteProjectScopeFork(): CommandPaletteProjectScope
150152
keepOpen: true,
151153
run: async () => setSearchAll(true),
152154
};
153-
return { projectKeys: searchAll ? null : filterKeys, toggle };
154-
}, [filterKeys, label, searchAll]);
155+
return {
156+
projectKeys: searchAll ? null : filterKeys,
157+
toggle,
158+
preserveEmpty: filter?.mode === "include",
159+
};
160+
})();
155161
}
156162

157163
/**
@@ -197,17 +203,20 @@ export function scopedPaletteThreadsFork<
197203
}
198204

199205
/**
200-
* The palette's project picker entries under the scope. A scope that leaves no
201-
* entry (its projects not loaded yet) shows every project, so the picker is
202-
* never empty.
206+
* Explicit inclusion keeps an empty picker empty. Legacy/exclusion filters
207+
* retain the existing fallback when none of their projects are available.
203208
*/
204209
export function scopePaletteProjectEntriesFork<
205210
Entry extends { readonly group: { readonly memberProjectRefs: ReadonlyArray<ScopedProjectRef> } },
206-
>(entries: ReadonlyArray<Entry>, projectKeys: ReadonlySet<string> | null): ReadonlyArray<Entry> {
211+
>(
212+
entries: ReadonlyArray<Entry>,
213+
projectKeys: ReadonlySet<string> | null,
214+
preserveEmpty = false,
215+
): ReadonlyArray<Entry> {
207216
const scoped = scopeToProjectKeys(entries, projectKeys, (entry) =>
208217
entry.group.memberProjectRefs.map((ref) => `${ref.environmentId}:${ref.projectId}`),
209218
);
210-
return scoped.length > 0 ? scoped : entries;
219+
return scoped.length === 0 && !preserveEmpty ? entries : scoped;
211220
}
212221

213222
/**

‎apps/web/src/components/CommandPalette.logic.fork.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ describe("palette project scope", () => {
6969
expect(scopePaletteProjectEntriesFork(entries, null)).toBe(entries);
7070
});
7171

72+
it("explicit inclusion keeps No projects empty, with Search all as the escape", () => {
73+
const entries = [entryOf("api"), entryOf("web")];
74+
expect(scopePaletteProjectEntriesFork(entries, new Set(), true)).toEqual([]);
75+
expect(scopePaletteProjectEntriesFork(entries, new Set(["local:gone"]), true)).toEqual([]);
76+
expect(scopePaletteProjectEntriesFork(entries, null, true)).toBe(entries);
77+
// Preserve the known parent all-excluded picker fallback.
78+
expect(scopePaletteProjectEntriesFork(entries, new Set())).toBe(entries);
79+
});
80+
7281
it("Search all: the pushed new-thread picker follows the scope, keeping its lead first", () => {
7382
const pushed = [{ value: "projects", label: "Projects", items: [item("b"), item("a")] }];
7483
const refreshed = refreshNewThreadInViewFork(pushed, [item("a"), item("b"), item("c")]);

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,10 +630,14 @@ function OpenCommandPaletteDialog(props: {
630630
groups: projectGroups,
631631
preferredProjectRef: contextualProjectRef,
632632
});
633-
const pickerProjects = scopePaletteProjectEntriesFork(projectPickerEntries, paletteProjectScope.projectKeys).map(({ group, targetProject }) => ({ // fork-hook: workspaces/palette-scope-projects
633+
const pickerProjects = scopePaletteProjectEntriesFork(
634+
projectPickerEntries,
635+
paletteProjectScope.projectKeys,
636+
paletteProjectScope.preserveEmpty,
637+
).map(({ group, targetProject }) => ({
634638
...targetProject,
635639
displayName: group.displayName,
636-
}));
640+
})); // fork-hook: workspaces/palette-scope-projects
637641
const projectGroupByTargetKey = new Map(
638642
projectPickerEntries.map(({ group, targetProject }) => [
639643
`${targetProject.environmentId}:${targetProject.id}`,

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2888,12 +2888,6 @@ export default function Sidebar() {
28882888
anchor={headerSearchRef}
28892889
className="max-w-[min(18rem,var(--available-width))] overflow-hidden"
28902890
>
2891-
{/* fork-hook: workspaces/chooser-mode */}
2892-
<ProjectChooserModeFork
2893-
filter={windowFilter.filter}
2894-
setFilter={windowFilter.setFilter}
2895-
/>
2896-
{/* fork-hook-end */}
28972891
<ComboboxSearchInput
28982892
aria-label="Search projects"
28992893
placeholder="Search projects..."
@@ -2947,6 +2941,14 @@ export default function Sidebar() {
29472941
<FolderIcon className="size-4 shrink-0" />
29482942
)}
29492943
<span className="min-w-0 flex-1 truncate text-sm">{item.label}</span>
2944+
{/* fork-hook: workspaces/chooser-mode */}
2945+
{item.value === "all" ? (
2946+
<ProjectChooserModeFork
2947+
filter={windowFilter.filter}
2948+
setFilter={windowFilter.setFilter}
2949+
/>
2950+
) : null}
2951+
{/* fork-hook-end */}
29502952
{/* fork-hook: workspaces/chooser-row-unavailable */}
29512953
<ProjectChooserUnavailableFork
29522954
unavailable={projectChooser.unavailableValues.has(item.value)}

‎apps/web/src/components/sidebar/SidebarProjectChooser.fork.tsx‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ import { useLayoutEffect, useRef, type MouseEvent as ReactMouseEvent } from "rea
99
import { cn } from "~/lib/utils";
1010
import {
1111
projectChooserState,
12+
projectChooserMode,
13+
projectFilterFromMode,
1214
projectFilterFromChooser,
1315
showOnlyProjectFilter,
1416
useProjectChooserHost,
1517
type ProjectChooserGroup,
1618
type ProjectChooserItem,
1719
} from "../../projectChooser.fork";
1820
import { Button } from "../ui/button";
21+
import { Label } from "../ui/label";
1922
import { useSidebar } from "../ui/sidebar";
20-
import { Toggle, ToggleGroup } from "../ui/toggle-group";
23+
import { Switch } from "../ui/switch";
2124

2225
export function useSidebarProjectChooserFork<Group extends ProjectChooserGroup>(input: {
2326
readonly filter: ProjectFilter;
@@ -88,34 +91,31 @@ export function ProjectChooserRowMarkFork({
8891
return <Icon aria-hidden className={cn("size-3.5 shrink-0", selected ? null : "invisible")} />;
8992
}
9093

91-
/** Switching modes keeps the picks; their meaning changes explicitly, not via a modifier key. */
94+
/** The All projects row's exclusion switch changes the picks' meaning without resetting them. */
9295
export function ProjectChooserModeFork({
9396
filter,
9497
setFilter,
9598
}: {
9699
readonly filter: ProjectFilter;
97100
readonly setFilter: (filter: ProjectFilter) => void;
98101
}) {
99-
const mode = filter.mode ?? "include";
102+
const mode = projectChooserMode(filter);
100103
return (
101-
<div className="flex flex-col gap-2 px-2 pt-2 pb-1">
102-
<ToggleGroup
103-
aria-label="Project filter mode"
104-
value={[mode]}
105-
onValueChange={(values) => {
106-
const next = values[0];
107-
if (next === "include" || next === "exclude") setFilter({ ...filter, mode: next });
108-
}}
109-
>
110-
<Toggle value="include">Only selected</Toggle>
111-
<Toggle value="exclude">All except selected</Toggle>
112-
</ToggleGroup>
113-
<p className="text-xs text-muted-foreground">
114-
{mode === "exclude"
115-
? "Select projects to hide. New projects stay visible."
116-
: "Select projects to show. No selection shows all."}
117-
</p>
118-
</div>
104+
<Label
105+
className="shrink-0"
106+
onPointerDown={(event) => event.stopPropagation()}
107+
onClick={(event) => event.stopPropagation()}
108+
onKeyDown={(event) => event.stopPropagation()}
109+
onFocus={(event) => event.stopPropagation()}
110+
>
111+
Exclude
112+
<Switch
113+
checked={mode === "exclude"}
114+
onCheckedChange={(checked) =>
115+
setFilter(projectFilterFromMode(filter, checked ? "exclude" : "include"))
116+
}
117+
/>
118+
</Label>
119119
);
120120
}
121121

‎apps/web/src/projectChooser.fork.test.ts‎

Lines changed: 60 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { EnvironmentId, ProjectId, type ScopedProjectRef } from "@t3tools/contra
66
import { describe, expect, it } from "vite-plus/test";
77

88
import {
9-
ALL_PROJECTS_CHOOSER_VALUE,
9+
projectChooserMode,
10+
projectFilterFromMode,
1011
projectChooserState,
1112
projectFilterFromChooser,
1213
showOnlyProjectFilter,
@@ -30,6 +31,7 @@ const web = {
3031
const groups = [api, web];
3132

3233
const filterOf = (...selected: Array<typeof api>): ProjectFilter => ({
34+
mode: "include",
3335
entries: selected.map((group) => ({ key: group.projectKey, members: group.memberProjectRefs })),
3436
});
3537
const values = (filter: ProjectFilter) =>
@@ -48,31 +50,48 @@ describe("project chooser", () => {
4850
mode: "exclude",
4951
});
5052
expect(projectFilterFromChooser(filter, [], groups)).toEqual({ entries: [], mode: "exclude" });
51-
expect(
52-
projectFilterFromChooser(filter, [web.projectKey, ALL_PROJECTS_CHOOSER_VALUE], groups),
53-
).toEqual({ entries: [], mode: "exclude" });
5453
expect(showOnlyProjectFilter(api)).toEqual(filterOf(api));
5554
});
5655

5756
it("exclusion can pick its first hidden project from an empty selection", () => {
5857
const empty: ProjectFilter = { mode: "exclude", entries: [] };
5958
expect(projectChooserState(empty, groups).label).toBe("Projects: All");
60-
expect(
61-
projectFilterFromChooser(empty, [ALL_PROJECTS_CHOOSER_VALUE, web.projectKey], groups),
62-
).toEqual({ ...filterOf(web), mode: "exclude" });
59+
expect(projectFilterFromChooser(empty, [web.projectKey], groups)).toEqual({
60+
...filterOf(web),
61+
mode: "exclude",
62+
});
6363
});
6464

65-
it("Empty: an empty filter selects All projects and reads Projects: All", () => {
65+
it("All heads the list and is selected without counting as a project pick", () => {
6666
const state = projectChooserState(ALL_PROJECTS_FILTER, groups);
67-
expect(state.value.map((item) => item.value)).toEqual([ALL_PROJECTS_CHOOSER_VALUE]);
67+
expect(state.value.map((item) => item.value)).toEqual(["all"]);
6868
expect(state.label).toBe("Projects: All");
6969
expect(state.count).toBe(0);
7070
expect(state.single).toBeNull();
71-
expect(state.items.map((item) => item.value)).toEqual([
72-
ALL_PROJECTS_CHOOSER_VALUE,
73-
api.projectKey,
74-
web.projectKey,
75-
]);
71+
expect(state.items.map((item) => item.value)).toEqual(["all", api.projectKey, web.projectKey]);
72+
});
73+
74+
it("All resets picks, while picking a project from All drops its sentinel", () => {
75+
expect(projectFilterFromChooser(filterOf(api), [api.projectKey, "all"], groups)).toBe(
76+
ALL_PROJECTS_FILTER,
77+
);
78+
expect(
79+
projectFilterFromChooser(
80+
{ ...filterOf(web), mode: "exclude" },
81+
[web.projectKey, "all"],
82+
groups,
83+
),
84+
).toBe(ALL_PROJECTS_FILTER);
85+
expect(projectFilterFromChooser(ALL_PROJECTS_FILTER, ["all", api.projectKey], groups)).toEqual(
86+
filterOf(api),
87+
);
88+
const excluding: ProjectFilter = { mode: "exclude", entries: [] };
89+
expect(projectFilterFromChooser(excluding, ["all", web.projectKey], groups)).toEqual({
90+
...filterOf(web),
91+
mode: "exclude",
92+
});
93+
expect(projectFilterFromChooser(excluding, [], groups)).toBe(ALL_PROJECTS_FILTER);
94+
expect(projectFilterFromChooser(ALL_PROJECTS_FILTER, [], groups)).toBe(ALL_PROJECTS_FILTER);
7695
});
7796

7897
it("Label: one entry shows its name, several show a count", () => {
@@ -108,24 +127,36 @@ describe("project chooser", () => {
108127
const removed = projectFilterFromChooser(added, [web.projectKey], groups);
109128
expect(removed).toEqual(filterOf(web));
110129

111-
// From All projects, the combobox reports All beside the new pick.
112-
const fromAll = projectFilterFromChooser(
113-
ALL_PROJECTS_FILTER,
114-
[ALL_PROJECTS_CHOOSER_VALUE, api.projectKey],
115-
groups,
116-
);
130+
const fromAll = projectFilterFromChooser(ALL_PROJECTS_FILTER, [api.projectKey], groups);
117131
expect(fromAll).toEqual(filterOf(api));
118132
});
119133

120-
it("Toggle: All projects clears the filter, and unpicking the last entry returns to all", () => {
121-
expect(
122-
projectFilterFromChooser(
123-
filterOf(api, web),
124-
[api.projectKey, web.projectKey, ALL_PROJECTS_CHOOSER_VALUE],
125-
groups,
126-
),
127-
).toBe(ALL_PROJECTS_FILTER);
128-
expect(projectFilterFromChooser(filterOf(api), [], groups)).toBe(ALL_PROJECTS_FILTER);
134+
it("unselecting the last project shows none until All resets the filter", () => {
135+
const none = projectFilterFromChooser(filterOf(api), [], groups);
136+
expect(none).toEqual({ mode: "include", entries: [] });
137+
expect(projectChooserState(none, groups)).toMatchObject({
138+
label: "Projects: None",
139+
titleLabel: "No projects",
140+
value: [],
141+
single: null,
142+
});
143+
expect(projectFilterFromMode(none, "all")).toBe(ALL_PROJECTS_FILTER);
144+
expect(projectFilterFromMode(filterOf(api, web), "all")).toBe(ALL_PROJECTS_FILTER);
145+
});
146+
147+
it("mode switches preserve picks, including empty selections and legacy filters", () => {
148+
expect(projectChooserMode(ALL_PROJECTS_FILTER)).toBe("all");
149+
expect(projectChooserMode({ entries: filterOf(api).entries })).toBe("include");
150+
const excluded = projectFilterFromMode(filterOf(api, web), "exclude");
151+
expect(projectChooserMode(excluded)).toBe("exclude");
152+
expect(excluded.entries).toEqual(filterOf(api, web).entries);
153+
expect(projectFilterFromMode(excluded, "include")).toEqual(filterOf(api, web));
154+
const none = projectFilterFromMode(ALL_PROJECTS_FILTER, "include");
155+
expect(projectChooserMode(none)).toBe("include");
156+
expect(projectChooserState(none, groups).label).toBe("Projects: None");
157+
const allExceptNone = projectFilterFromMode(none, "exclude");
158+
expect(projectChooserState(allExceptNone, groups).label).toBe("Projects: All");
159+
expect(projectChooserMode(allExceptNone)).toBe("exclude");
129160
});
130161

131162
it("Offline: an entry no group carries stays selected and is marked unavailable", () => {

0 commit comments

Comments
 (0)