Skip to content

Commit 35d7d7e

Browse files
donjor-agent[bot]rsi-pr-agent
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: - e16eaa2 feat(web): simplify the window project chooser (#1669) (#1669) - 3af673d fixup! feat(web): simplify the window project chooser (#1669) (#1669) - e2e24ff feat(web): simplify the window project chooser (#1669) (#1669) - 96f2eb5 fixup! feat(web): simplify the window project chooser (#1669) (#1669) Fork-Domain: workspaces Fork-Tier: qol Fork-Upstreamable: no
1 parent 5d52d3b commit 35d7d7e

19 files changed

Lines changed: 346 additions & 136 deletions

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

Lines changed: 59 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ export function buildProjectChooserActionItemFork(
105105
const NEW_THREAD_IN_VIEW = "projects";
106106

107107
export interface CommandPaletteProjectScope {
108+
/** Explicit inclusion can intentionally show no projects. */
109+
readonly preserveEmpty?: boolean;
108110
/** The project keys the palette shows; `null` shows every project. */
109111
readonly projectKeys: ReadonlySet<string> | null;
110112
/** The toggle between the filter and every project; `null` when unscoped. */
@@ -147,8 +149,12 @@ export function useCommandPaletteProjectScopeFork(): CommandPaletteProjectScope
147149
keepOpen: true,
148150
run: async () => setSearchAll(true),
149151
};
150-
return { projectKeys: searchAll ? null : filterKeys, toggle };
151-
}, [filterKeys, label, searchAll]);
152+
return {
153+
projectKeys: searchAll ? null : filterKeys,
154+
toggle,
155+
preserveEmpty: filter?.mode === "include",
156+
};
157+
})();
152158
}
153159

154160
/**
@@ -184,27 +190,66 @@ export function dropNewThreadHintFork(
184190
items[index] = withoutHint;
185191
}
186192

187-
/** The palette's threads under the scope. */
188-
export function scopedPaletteThreadsFork<
189-
Thread extends { readonly environmentId: string; readonly projectId: string },
190-
>(threads: ReadonlyArray<Thread>, projectKeys: ReadonlySet<string> | null) {
191-
return scopeToProjectKeys(threads, projectKeys, (thread) => [
192-
`${thread.environmentId}:${thread.projectId}`,
193-
]);
193+
// These arrays are freshly derived for this render, never store-owned. Filtering
194+
// them after construction keeps the upstream palette calls as insertion-only seams.
195+
export function scopePaletteThreadItemsFork(
196+
items: CommandPaletteActionItem[],
197+
projectKeys: ReadonlySet<string> | null,
198+
): void {
199+
if (projectKeys === null) return;
200+
const scoped = scopeToProjectKeys(items, projectKeys, (item) =>
201+
"projectKeyFork" in item && typeof item.projectKeyFork === "string"
202+
? [item.projectKeyFork]
203+
: [],
204+
);
205+
items.splice(0, items.length, ...scoped);
206+
}
207+
208+
export function scopePalettePickerProjectsFork<
209+
Project extends { readonly environmentId: string; readonly id: string },
210+
>(
211+
projects: Project[],
212+
entries: ReadonlyArray<{
213+
readonly group: { readonly memberProjectRefs: ReadonlyArray<ScopedProjectRef> };
214+
readonly targetProject: { readonly environmentId: string; readonly id: string };
215+
}>,
216+
scope: CommandPaletteProjectScope,
217+
): void {
218+
if (scope.projectKeys === null) return;
219+
const allowed = new Set(
220+
scopePaletteProjectEntriesFork(entries, scope.projectKeys, scope.preserveEmpty).map(
221+
({ targetProject }) => `${targetProject.environmentId}:${targetProject.id}`,
222+
),
223+
);
224+
const scoped = projects.filter((project) =>
225+
allowed.has(`${project.environmentId}:${project.id}`),
226+
);
227+
projects.splice(0, projects.length, ...scoped);
228+
}
229+
230+
export function paletteGroupsInputFork(
231+
groups: ReadonlyArray<CommandPaletteGroup>,
232+
projectThreadItems: ReadonlyArray<CommandPaletteActionItem>,
233+
) {
234+
const refreshed = refreshNewThreadInViewFork(groups, projectThreadItems);
235+
return refreshed === groups ? {} : { activeGroups: refreshed };
194236
}
195237

196238
/**
197-
* The palette's project picker entries under the scope. A scope that leaves no
198-
* entry (its projects not loaded yet) shows every project, so the picker is
199-
* never empty.
239+
* Explicit inclusion keeps an empty picker empty. Legacy/exclusion filters
240+
* retain the existing fallback when none of their projects are available.
200241
*/
201242
export function scopePaletteProjectEntriesFork<
202243
Entry extends { readonly group: { readonly memberProjectRefs: ReadonlyArray<ScopedProjectRef> } },
203-
>(entries: ReadonlyArray<Entry>, projectKeys: ReadonlySet<string> | null): ReadonlyArray<Entry> {
244+
>(
245+
entries: ReadonlyArray<Entry>,
246+
projectKeys: ReadonlySet<string> | null,
247+
preserveEmpty = false,
248+
): ReadonlyArray<Entry> {
204249
const scoped = scopeToProjectKeys(entries, projectKeys, (entry) =>
205250
entry.group.memberProjectRefs.map((ref) => `${ref.environmentId}:${ref.projectId}`),
206251
);
207-
return scoped.length > 0 ? scoped : entries;
252+
return scoped.length === 0 && !preserveEmpty ? entries : scoped;
208253
}
209254

210255
/**

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ import { describe, expect, it } from "vite-plus/test";
33

44
import {
55
browseInputEndPaddingClass,
6+
buildThreadActionItems,
67
filterCommandPaletteGroups,
78
type CommandPaletteActionItem,
89
} from "./CommandPalette.logic";
10+
import { makeThreadFixture } from "../test-fixtures";
911
import {
1012
buildLinkGitHubIssueActionItemFork,
1113
refreshNewThreadInViewFork,
1214
scopePaletteProjectEntriesFork,
15+
scopePalettePickerProjectsFork,
16+
scopePaletteThreadItemsFork,
1317
withProjectScopeToggleFork,
1418
} from "./CommandPalette.fork";
1519

@@ -69,6 +73,56 @@ describe("palette project scope", () => {
6973
expect(scopePaletteProjectEntriesFork(entries, null)).toBe(entries);
7074
});
7175

76+
it("explicit inclusion keeps No projects empty, with Search all as the escape", () => {
77+
const entries = [entryOf("api"), entryOf("web")];
78+
expect(scopePaletteProjectEntriesFork(entries, new Set(), true)).toEqual([]);
79+
expect(scopePaletteProjectEntriesFork(entries, new Set(["local:gone"]), true)).toEqual([]);
80+
expect(scopePaletteProjectEntriesFork(entries, null, true)).toBe(entries);
81+
// Preserve the known parent all-excluded picker fallback.
82+
expect(scopePaletteProjectEntriesFork(entries, new Set())).toBe(entries);
83+
});
84+
85+
it("filters extracted thread items by project and environment, not thread id", () => {
86+
const threads = ["local", "remote"].map((environmentId) =>
87+
makeThreadFixture({
88+
id: ThreadId.make("shared-thread-id"),
89+
projectId: ProjectId.make("api"),
90+
environmentId: EnvironmentId.make(environmentId),
91+
}),
92+
);
93+
const items = buildThreadActionItems({
94+
threads,
95+
projectByKey: new Map(),
96+
icon: null,
97+
runThread: async () => {},
98+
});
99+
const remoteItem = items[1];
100+
scopePaletteThreadItemsFork(items, new Set(["remote:api"]));
101+
expect(items).toEqual([remoteItem]);
102+
scopePaletteThreadItemsFork(items, new Set());
103+
expect(items).toEqual([]);
104+
});
105+
106+
it("filters derived picker projects through group members and preserves explicit empty", () => {
107+
const entries = ["api", "web"].map((id) => ({
108+
...entryOf(id),
109+
targetProject: { environmentId: "local", id },
110+
}));
111+
entries[1]!.group.memberProjectRefs.push(ref("remote", "alias"));
112+
const projects = entries.map(({ targetProject }) => ({ ...targetProject }));
113+
scopePalettePickerProjectsFork(projects, entries, {
114+
projectKeys: new Set(["remote:alias"]),
115+
toggle: null,
116+
});
117+
expect(projects.map(({ id }) => id)).toEqual(["web"]);
118+
scopePalettePickerProjectsFork(projects, entries, {
119+
projectKeys: new Set(),
120+
preserveEmpty: true,
121+
toggle: null,
122+
});
123+
expect(projects).toEqual([]);
124+
});
125+
72126
it("Search all: the pushed new-thread picker follows the scope, keeping its lead first", () => {
73127
const pushed = [{ value: "projects", label: "Projects", items: [item("b"), item("a")] }];
74128
const refreshed = refreshNewThreadInViewFork(pushed, [item("a"), item("b"), item("c")]);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ export function buildThreadActionItems<TThread extends BuildThreadActionItemsThr
452452
{
453453
kind: "action" as const,
454454
value: `thread:${thread.environmentId}:${thread.id}`,
455+
projectKeyFork: `${thread.environmentId}:${thread.projectId}`, // fork-hook: workspaces/palette-thread-project-key
455456
searchTerms: [thread.title],
456457
threadSearch: threadSearchSubject(
457458
{

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ import { buildLinkGitHubIssueActionItemFork } from "./CommandPalette.fork"; // f
5454
import { buildProjectChooserActionItemFork } from "./CommandPalette.fork"; // fork-hook: workspaces/chooser-palette
5555
import {
5656
dropNewThreadHintFork,
57-
refreshNewThreadInViewFork,
58-
scopePaletteProjectEntriesFork,
57+
paletteGroupsInputFork,
58+
scopePalettePickerProjectsFork,
59+
scopePaletteThreadItemsFork,
5960
useCommandPaletteProjectScopeFork,
6061
useNewThreadHintFork,
6162
withProjectScopeToggleFork,
@@ -530,10 +531,11 @@ function OpenCommandPaletteDialog(props: {
530531
groups: projectGroups,
531532
preferredProjectRef: contextualProjectRef,
532533
});
533-
const pickerProjects = scopePaletteProjectEntriesFork(projectPickerEntries, paletteProjectScope.projectKeys).map(({ group, targetProject }) => ({ // fork-hook: workspaces/palette-scope-projects
534+
const pickerProjects = projectPickerEntries.map(({ group, targetProject }) => ({
534535
...targetProject,
535536
displayName: group.displayName,
536537
}));
538+
scopePalettePickerProjectsFork(pickerProjects, projectPickerEntries, paletteProjectScope); // fork-hook: workspaces/palette-scope-projects
537539
const projectGroupByTargetKey = new Map(
538540
projectPickerEntries.map(({ group, targetProject }) => [
539541
`${targetProject.environmentId}:${targetProject.id}`,
@@ -825,8 +827,8 @@ function OpenCommandPaletteDialog(props: {
825827
} = useCommandPaletteThreadItems({
826828
activeThread: activeThread ?? null,
827829
threadSearchQuery,
828-
projectKeysFork: paletteProjectScope.projectKeys,
829-
}); // fork-hook: workspaces/palette-scope-threads
830+
});
831+
scopePaletteThreadItemsFork(allThreadItems, paletteProjectScope.projectKeys); // fork-hook: workspaces/palette-scope-threads
830832
// Recent means used recently: written in or opened, whichever is later. The
831833
// open thread would always lead that list, so it is left out.
832834
const activeThreadValue = activeThread
@@ -1648,12 +1650,13 @@ function OpenCommandPaletteDialog(props: {
16481650
? changeThemeItem.groups
16491651
: currentView?.groups[0]?.value === "appearance"
16501652
? changeAppearanceItem.groups
1651-
: refreshNewThreadInViewFork(currentView?.groups ?? rootGroups, projectThreadItems); // fork-hook: workspaces/palette-scope-picker
1653+
: (currentView?.groups ?? rootGroups);
16521654

16531655
const isLinkedThreadSearch =
16541656
linkedThreadSearch?.linkedThreads !== undefined && deferredQuery === linkedThreadSearch.query;
16551657
const filteredGroups = filterCommandPaletteGroups({
16561658
activeGroups,
1659+
...paletteGroupsInputFork(activeGroups, projectThreadItems), // fork-hook: workspaces/palette-scope-picker
16571660
query: deferredQuery,
16581661
isInSubmenu: currentView !== null,
16591662
...(deferredQuery.trim().length > 0

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { scopedThreadKey, scopeThreadRef } from "@t3tools/client-runtime/environment";
2-
import { scopedPaletteThreadsFork } from "./CommandPalette.fork"; // fork-hook: workspaces/palette-scope-threads-import
32
import { findForMessageMatch, openThreadFindOnQuery } from "./chat/threadFindStore";
43
import {
54
claimThreadOpen,
@@ -97,7 +96,6 @@ function useConnectedThreadSearch(query: string) {
9796
export function useCommandPaletteThreadItems(input: {
9897
readonly activeThread: { readonly environmentId: EnvironmentId; readonly id: ThreadId } | null;
9998
readonly threadSearchQuery: string;
100-
readonly projectKeysFork?: ReadonlySet<string> | null; // fork-hook: workspaces/palette-scope-threads-input
10199
}) {
102100
const { activeThread, threadSearchQuery } = input;
103101
const navigate = useNavigate();
@@ -112,7 +110,7 @@ export function useCommandPaletteThreadItems(input: {
112110

113111
const { environments } = useEnvironments();
114112
const threadItems = buildThreadActionItems({
115-
threads: scopedPaletteThreadsFork(threads, input.projectKeysFork ?? null), // fork-hook: workspaces/palette-scope-threads
113+
threads,
116114
...(environments.length > 1
117115
? {
118116
environmentLabelOf: (thread: (typeof threads)[number]) =>

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3012,12 +3012,6 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
30123012
anchor={headerSearchRef}
30133013
className="max-w-[min(18rem,var(--available-width))] overflow-hidden"
30143014
>
3015-
{/* fork-hook: workspaces/chooser-mode */}
3016-
<ProjectChooserModeFork
3017-
filter={windowFilter.filter}
3018-
setFilter={windowFilter.setFilter}
3019-
/>
3020-
{/* fork-hook-end */}
30213015
<ComboboxSearchInput
30223016
aria-label="Search projects"
30233017
placeholder="Search projects..."
@@ -3071,6 +3065,14 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
30713065
<FolderIcon className="size-4 shrink-0" />
30723066
)}
30733067
<span className="min-w-0 flex-1 truncate text-sm">{item.label}</span>
3068+
{/* fork-hook: workspaces/chooser-mode */}
3069+
{item.value === "all" ? (
3070+
<ProjectChooserModeFork
3071+
filter={windowFilter.filter}
3072+
setFilter={windowFilter.setFilter}
3073+
/>
3074+
) : null}
3075+
{/* fork-hook-end */}
30743076
{/* fork-hook: workspaces/chooser-row-unavailable */}
30753077
<ProjectChooserUnavailableFork
30763078
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;
@@ -89,34 +92,31 @@ export function ProjectChooserRowMarkFork({
8992
return <Icon aria-hidden className={cn("size-3.5 shrink-0", selected ? null : "invisible")} />;
9093
}
9194

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

0 commit comments

Comments
 (0)