The best way to control Claude Code, Codex and more from any computer or phone
refactor(web): the command palette's add-project views are components (#22707)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 21, 2026 at 01:13 UTC
28a8d2b3d81699d6203671d62eae76cc8859681d
2 files changed
+244
-207
apps/web/src/components/CommandPalette.tsx
+73
-207
@@ -12,7 +12,6 @@ import {
12
getNewProjectPublishTarget,
13
getNewProjectPublishTargets,
14
getNewProjectRepository,
15
- type NewProjectPublishTarget,
15
normalizePastedCloneUrl,
16
addProjectRemoteSourceLabel,
17
addProjectRemoteSourcePathHint,
@@ -196,6 +195,14 @@ import {
195
buildNewThreadInProjectItems,
196
buildProjectSearchItems,
197
} from "./CommandPaletteProjectItems";
198
+import {
199
+ CommandPaletteSubmitButton,
200
+ NewProjectPublishHostPicker,
201
+ NewProjectSummary,
202
+ RemoteRepositorySummary,
203
+ remoteProjectSourceIcon,
204
+ sourceControlHostIcon,
205
+} from "./CommandPaletteAddProject";
206
import { useCommandPaletteThreadItems } from "./CommandPaletteThreadItems";
207
import {
208
APPEARANCE_OPTIONS,
@@ -203,11 +210,9 @@ import {
210
useCommandPaletteThemeItems,
211
} from "./CommandPaletteThemeItems";
212
import {
206
- CommandPaletteTitleIcon,
213
CommandPaletteVirtualizedResults,
214
scrollCommandPaletteRowIntoView,
215
} from "./CommandPaletteResults";
210
-import { sourceControlIcon } from "~/sourceControlPresentation";
216
import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon";
217
import { Checkbox } from "./ui/checkbox";
218
import { ProjectFilePicker } from "./files/ProjectFilePicker";
@@ -219,8 +224,6 @@ import { primaryServerKeybindingsAtom } from "../state/server";
224
import { resolveShortcutCommand, threadJumpIndexFromCommand } from "../keybindings";
225
import { CommandDialog, CommandDialogPopup, CommandFooterAction } from "./ui/command";
226
import { Button } from "./ui/button";
222
-import { Kbd, KbdGroup } from "./ui/kbd";
223
-import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "./ui/select";
227
import { stackedThreadToast, toastManager } from "./ui/toast";
228
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
229
import { ComposerHandleContext, useComposerHandleContext } from "../composerHandleContext";
@@ -232,20 +235,6 @@ import { useThreadRouteTarget } from "../hooks/useThreadRouteTarget";
235
236
const EMPTY_BROWSE_ENTRIES: FilesystemBrowseResult["entries"] = [];
237
235
-function remoteProjectSourceIcon(source: AddProjectRemoteSource, className: string): ReactNode {
236
- if (source === "url") return <LinkIcon className={className} />;
237
- const Icon = sourceControlIcon(sourceControlClients.get(source));
238
- return <Icon className={className} />;
239
-}
240
-
241
-function sourceControlHostIcon(
242
- definition: NewProjectPublishTarget["definition"],
243
- className: string,
244
-): ReactNode {
245
- const Icon = sourceControlIcon(definition);
246
- return <Icon className={className} />;
247
-}
248
-
238
export function CommandPalette({ children }: { children: ReactNode }) {
239
const navigate = useNavigate();
240
const [state, dispatch] = useReducer(reduceCommandPaletteUiState, {
@@ -599,7 +588,6 @@ function OpenCommandPaletteDialog(props: {
588
const [newProjectPublishes, setNewProjectPublishes] = useState(false);
589
const [newProjectPublishKind, setNewProjectPublishKind] =
590
useState<SourceControlProviderKind | null>(null);
602
- const [newProjectHostPickerOpen, setNewProjectHostPickerOpen] = useState(false);
591
const [isCreatingNewProject, setIsCreatingNewProject] = useState(false);
592
// State lags a render behind, so a repeated Enter could start a second create.
593
const newProjectSubmittingRef = useRef(false);
@@ -2091,18 +2079,6 @@ function OpenCommandPaletteDialog(props: {
2079
group.value === "directories" ? { ...group, label: "Select where to clone" } : group,
2080
);
2081
2094
- const remoteProjectContext = (() => {
2095
- if (addProjectCloneFlow?.step !== "confirm") {
2096
- return null;
2097
- }
2098
-
2099
- return {
2100
- title: addProjectCloneFlow.repository?.nameWithOwner ?? addProjectCloneFlow.repositoryInput,
2101
- description: addProjectCloneFlow.repository?.url ?? addProjectCloneFlow.remoteUrl,
2102
- icon: remoteProjectSourceIcon(addProjectCloneFlow.source, ITEM_ICON_CLASS),
2103
- };
2104
- })();
2105
-
2082
const newProjectsRoot = newProjectFlow ? newProjectsRootFor(newProjectFlow.environmentId) : null;
2083
const newProjectPathPreview =
2084
newProjectsRoot === null ? null : getNewProjectPathPreview(newProjectsRoot, newProjectName);
@@ -2209,55 +2185,12 @@ function OpenCommandPaletteDialog(props: {
2185
titleTrailingContent: (
2186
<span className="ms-auto flex items-center gap-2">
2187
{newProjectPublishTargets.length > 1 ? (
2212
- // The row toggles on click, so the picker keeps its clicks to itself. The
2213
- // row also cancels pointerdown to keep focus in the input, which drops the
2214
- // mousedown Select opens on, so the picker opens on click instead.
2215
- <span
2216
- className="flex"
2217
- onClick={(event) => {
2218
- event.stopPropagation();
2219
- // React bubbles the popup's clicks here through its portal; only the
2220
- // trigger opens the picker.
2221
- if (!event.currentTarget.contains(event.target as Node)) return;
2222
- if (!isCreatingNewProject) setNewProjectHostPickerOpen(true);
2223
- }}
2224
- >
2225
- <Select
2226
- disabled={isCreatingNewProject}
2227
- open={newProjectHostPickerOpen}
2228
- onOpenChange={setNewProjectHostPickerOpen}
2229
- value={newProjectPublishTarget.definition.kind}
2230
- onValueChange={(kind) => {
2231
- if (kind !== null) setNewProjectPublishKind(kind);
2232
- }}
2233
- >
2234
- <SelectTrigger
2235
- size="xs"
2236
- variant="ghost"
2237
- aria-label="Host for the new repository"
2238
- >
2239
- <SelectValue>
2240
- {(kind: SourceControlProviderKind) =>
2241
- sourceControlClients.get(kind).label
2242
- }
2243
- </SelectValue>
2244
- </SelectTrigger>
2245
- <SelectPopup align="end" alignItemWithTrigger={false}>
2246
- {newProjectPublishTargets.map((target) => (
2247
- <SelectItem
2248
- key={target.definition.kind}
2249
- hideIndicator
2250
- value={target.definition.kind}
2251
- >
2252
- <span className="inline-flex items-center gap-1.5">
2253
- {sourceControlHostIcon(target.definition, "size-3.5")}
2254
- {target.definition.label}
2255
- </span>
2256
- </SelectItem>
2257
- ))}
2258
- </SelectPopup>
2259
- </Select>
2260
- </span>
2188
+ <NewProjectPublishHostPicker
2189
+ disabled={isCreatingNewProject}
2190
+ targets={newProjectPublishTargets}
2191
+ value={newProjectPublishTarget.definition.kind}
2192
+ onValueChange={setNewProjectPublishKind}
2193
+ />
2194
) : null}
2195
<span className="pointer-events-none flex">
2196
<Checkbox checked={newProjectPublishes} tabIndex={-1} aria-hidden />
@@ -2622,106 +2555,56 @@ function OpenCommandPaletteDialog(props: {
2555
2556
const inputAccessory =
2557
newProjectFlow !== null ? (
2625
- <Tooltip>
2626
- <TooltipTrigger
2627
- render={
2628
- <Button
2629
- variant="outline"
2630
- size="xs"
2631
- tabIndex={-1}
2632
- className="absolute inset-e-2.5 top-1/2 -translate-y-1/2"
2633
- aria-label={`Create (${createShortcutLabel})`}
2634
- disabled={!canSubmitNewProject}
2635
- onMouseDown={(event) => {
2636
- event.preventDefault();
2637
- }}
2638
- onClick={() => {
2639
- void submitNewProject();
2640
- }}
2641
- />
2642
- }
2643
- >
2644
- <span>{isCreatingNewProject ? "Creating" : "Create"}</span>
2645
- <KbdGroup className="pointer-events-none -me-0.5">
2646
- <Kbd>{createShortcutLabel}</Kbd>
2647
- </KbdGroup>
2648
- </TooltipTrigger>
2649
- <TooltipPopup side="top">{`Create (${createShortcutLabel})`}</TooltipPopup>
2650
- </Tooltip>
2558
+ <CommandPaletteSubmitButton
2559
+ label={isCreatingNewProject ? "Creating" : "Create"}
2560
+ shortcutLabel={createShortcutLabel}
2561
+ ariaLabel={`Create (${createShortcutLabel})`}
2562
+ tooltip={`Create (${createShortcutLabel})`}
2563
+ disabled={!canSubmitNewProject}
2564
+ onSubmit={() => {
2565
+ void submitNewProject();
2566
+ }}
2567
+ />
2568
) : addProjectCloneFlow?.step === "repository" ? (
2652
- <Tooltip>
2653
- <TooltipTrigger
2654
- render={
2655
- <Button
2656
- variant="outline"
2657
- size="xs"
2658
- tabIndex={-1}
2659
- className="absolute inset-e-2.5 top-1/2 -translate-y-1/2"
2660
- aria-label={`${remoteProjectButtonLabel ?? "Continue"} (Enter)`}
2661
- disabled={!canSubmitRemoteProjectFlow}
2662
- onMouseDown={(event) => {
2663
- event.preventDefault();
2664
- }}
2665
- onClick={() => {
2666
- void submitAddProjectCloneFlow();
2667
- }}
2668
- />
2669
- }
2670
- >
2671
- <span>{isRemoteProjectPending ? "Working" : remoteProjectButtonLabel}</span>
2672
- <KbdGroup className="pointer-events-none -me-0.5">
2673
- <Kbd>Enter</Kbd>
2674
- </KbdGroup>
2675
- </TooltipTrigger>
2676
- <TooltipPopup side="top">{remoteProjectButtonLabel ?? "Continue"} (Enter)</TooltipPopup>
2677
- </Tooltip>
2569
+ <CommandPaletteSubmitButton
2570
+ label={isRemoteProjectPending ? "Working" : remoteProjectButtonLabel}
2571
+ shortcutLabel="Enter"
2572
+ ariaLabel={`${remoteProjectButtonLabel ?? "Continue"} (Enter)`}
2573
+ tooltip={`${remoteProjectButtonLabel ?? "Continue"} (Enter)`}
2574
+ disabled={!canSubmitRemoteProjectFlow}
2575
+ onSubmit={() => {
2576
+ void submitAddProjectCloneFlow();
2577
+ }}
2578
+ />
2579
) : isBrowsing ? (
2679
- <Tooltip>
2680
- <TooltipTrigger
2681
- render={
2682
- <Button
2683
- variant="outline"
2684
- size="xs"
2685
- tabIndex={-1}
2686
- className="absolute inset-e-2.5 top-1/2 -translate-y-1/2"
2687
- aria-label={`${submitActionLabel} (${addShortcutLabel})`}
2688
- disabled={
2689
- !canCreateProject ||
2690
- !canCreateProjectInEnvironment(browseEnvironment?.connection.phase) ||
2691
- relativePathNeedsActiveProject ||
2692
- (isCloneDestinationStep && (!canCloneProject || isRemoteProjectPending))
2693
- }
2694
- onMouseDown={(event) => {
2695
- event.preventDefault();
2696
- }}
2697
- onClick={() => {
2698
- if (relativePathNeedsActiveProject) {
2699
- return;
2700
- }
2701
- if (isCloneDestinationStep) {
2702
- void submitAddProjectCloneFlow(resolvedAddProjectPath);
2703
- } else {
2704
- void handleAddProject(resolvedAddProjectPath);
2705
- }
2706
- }}
2707
- />
2708
- }
2709
- >
2710
- <span>
2711
- {isCloneDestinationStep && isRemoteProjectPending ? "Cloning" : submitActionLabel}
2712
- </span>
2713
- <KbdGroup className="pointer-events-none -me-0.5">
2714
- <Kbd>{hasHighlightedBrowseItem ? `${submitModifierLabel} Enter` : "Enter"}</Kbd>
2715
- </KbdGroup>
2716
- </TooltipTrigger>
2717
- <TooltipPopup side="top">
2718
- {isCloneDestinationStep && !canCloneProject
2580
+ <CommandPaletteSubmitButton
2581
+ label={isCloneDestinationStep && isRemoteProjectPending ? "Cloning" : submitActionLabel}
2582
+ shortcutLabel={addShortcutLabel}
2583
+ ariaLabel={`${submitActionLabel} (${addShortcutLabel})`}
2584
+ tooltip={
2585
+ isCloneDestinationStep && !canCloneProject
2586
? "This connection needs permission to write source control and add projects."
2587
: canCreateProject
2588
? `${submitActionLabel} (${addShortcutLabel})`
2722
- : "This connection cannot add projects."}
2723
- </TooltipPopup>
2724
- </Tooltip>
2589
+ : "This connection cannot add projects."
2590
+ }
2591
+ disabled={
2592
+ !canCreateProject ||
2593
+ !canCreateProjectInEnvironment(browseEnvironment?.connection.phase) ||
2594
+ relativePathNeedsActiveProject ||
2595
+ (isCloneDestinationStep && (!canCloneProject || isRemoteProjectPending))
2596
+ }
2597
+ onSubmit={() => {
2598
+ if (relativePathNeedsActiveProject) {
2599
+ return;
2600
+ }
2601
+ if (isCloneDestinationStep) {
2602
+ void submitAddProjectCloneFlow(resolvedAddProjectPath);
2603
+ } else {
2604
+ void handleAddProject(resolvedAddProjectPath);
2605
+ }
2606
+ }}
2607
+ />
2608
) : null;
2609
2610
const footerActionLabel =
@@ -2803,38 +2686,21 @@ function OpenCommandPaletteDialog(props: {
2686
value={query}
2687
>
2688
{newProjectPathPreview !== null ? (
2806
- <div className="p-2 pb-0">
2807
- <div className="flex min-h-8 items-center gap-2 rounded-sm px-2 py-1.5">
2808
- <CommandPaletteTitleIcon>
2809
- <FolderGit2Icon className={ITEM_ICON_CLASS} />
2810
- </CommandPaletteTitleIcon>
2811
- <span className="flex min-w-0 flex-1 flex-col">
2812
- <span className="truncate text-foreground text-sm">
2813
- {newProjectName.length > 0 ? newProjectName : "New project"}
2814
- </span>
2815
- <span className="truncate text-muted-foreground/85 text-xs">
2816
- {newProjectName.length > 0
2817
- ? `Creates ${newProjectPathPreview}`
2818
- : `Goes in ${newProjectsRoot}`}
2819
- {newProjectEnvironmentLabel === null ? null : ` on ${newProjectEnvironmentLabel}`}
2820
- </span>
2821
- </span>
2822
- </div>
2823
- </div>
2689
+ <NewProjectSummary
2690
+ name={newProjectName}
2691
+ pathPreview={newProjectPathPreview}
2692
+ projectsRoot={newProjectsRoot}
2693
+ environmentLabel={newProjectEnvironmentLabel}
2694
+ />
2695
) : null}
2825
- {remoteProjectContext ? (
2826
- <div className="shrink-0 p-2 pb-0">
2827
- <div className="px-2 py-1.5 font-medium text-muted-foreground text-xs">Repository</div>
2828
- <div className="flex min-h-8 items-center gap-2 rounded-sm px-2 py-1.5">
2829
- <CommandPaletteTitleIcon>{remoteProjectContext.icon}</CommandPaletteTitleIcon>
2830
- <span className="flex min-w-0 flex-1 flex-col">
2831
- <span className="truncate text-foreground text-sm">{remoteProjectContext.title}</span>
2832
- <span className="truncate text-muted-foreground/85 text-xs">
2833
- {remoteProjectContext.description}
2834
- </span>
2835
- </span>
2836
- </div>
2837
- </div>
2696
+ {addProjectCloneFlow?.step === "confirm" ? (
2697
+ <RemoteRepositorySummary
2698
+ source={addProjectCloneFlow.source}
2699
+ title={
2700
+ addProjectCloneFlow.repository?.nameWithOwner ?? addProjectCloneFlow.repositoryInput
2701
+ }
2702
+ description={addProjectCloneFlow.repository?.url ?? addProjectCloneFlow.remoteUrl}
2703
+ />
2704
) : null}
2705
{browseAccessError ? (
2706
<div role="alert" className="px-4 py-3 text-sm text-muted-foreground">
apps/web/src/components/CommandPaletteAddProject.tsx
new
+171
@@ -0,0 +1,171 @@
1
+import {
2
+ type AddProjectRemoteSource,
3
+ type NewProjectPublishTarget,
4
+} from "@t3tools/client-runtime/operations/projects";
5
+import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
6
+import type { SourceControlProviderKind } from "@t3tools/contracts";
7
+import { FolderGit2Icon, LinkIcon } from "lucide-react";
8
+import { type ReactNode, useState } from "react";
9
+
10
+import { sourceControlIcon } from "~/sourceControlPresentation";
11
+import { ITEM_ICON_CLASS } from "./CommandPalette.logic";
12
+import { CommandPaletteTitleIcon } from "./CommandPaletteResults";
13
+import { Button } from "./ui/button";
14
+import { Kbd, KbdGroup } from "./ui/kbd";
15
+import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "./ui/select";
16
+import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
17
+
18
+export function remoteProjectSourceIcon(
19
+ source: AddProjectRemoteSource,
20
+ className: string,
21
+): ReactNode {
22
+ if (source === "url") return <LinkIcon className={className} />;
23
+ const Icon = sourceControlIcon(sourceControlClients.get(source));
24
+ return <Icon className={className} />;
25
+}
26
+
27
+export function sourceControlHostIcon(
28
+ definition: NewProjectPublishTarget["definition"],
29
+ className: string,
30
+): ReactNode {
31
+ const Icon = sourceControlIcon(definition);
32
+ return <Icon className={className} />;
33
+}
34
+
35
+/** The input's trailing submit button for the add-project, clone, and new-project flows. */
36
+export function CommandPaletteSubmitButton(props: {
37
+ readonly label: ReactNode;
38
+ readonly shortcutLabel: string;
39
+ readonly ariaLabel: string;
40
+ readonly tooltip: ReactNode;
41
+ readonly disabled: boolean;
42
+ readonly onSubmit: () => void;
43
+}) {
44
+ return (
45
+ <Tooltip>
46
+ <TooltipTrigger
47
+ render={
48
+ <Button
49
+ variant="outline"
50
+ size="xs"
51
+ tabIndex={-1}
52
+ className="absolute inset-e-2.5 top-1/2 -translate-y-1/2"
53
+ aria-label={props.ariaLabel}
54
+ disabled={props.disabled}
55
+ onMouseDown={(event) => {
56
+ event.preventDefault();
57
+ }}
58
+ onClick={props.onSubmit}
59
+ />
60
+ }
61
+ >
62
+ <span>{props.label}</span>
63
+ <KbdGroup className="pointer-events-none -me-0.5">
64
+ <Kbd>{props.shortcutLabel}</Kbd>
65
+ </KbdGroup>
66
+ </TooltipTrigger>
67
+ <TooltipPopup side="top">{props.tooltip}</TooltipPopup>
68
+ </Tooltip>
69
+ );
70
+}
71
+
72
+/**
73
+ * Picks which host a new project publishes to. The row it sits in toggles on click, so the
74
+ * picker keeps its clicks to itself. The row also cancels pointerdown to keep focus in the
75
+ * input, which drops the mousedown Select opens on, so the picker opens on click instead.
76
+ */
77
+export function NewProjectPublishHostPicker(props: {
78
+ readonly disabled: boolean;
79
+ readonly targets: ReadonlyArray<NewProjectPublishTarget>;
80
+ readonly value: SourceControlProviderKind;
81
+ readonly onValueChange: (kind: SourceControlProviderKind) => void;
82
+}) {
83
+ const [open, setOpen] = useState(false);
84
+ return (
85
+ <span
86
+ className="flex"
87
+ onClick={(event) => {
88
+ event.stopPropagation();
89
+ // React bubbles the popup's clicks here through its portal; only the
90
+ // trigger opens the picker.
91
+ if (!event.currentTarget.contains(event.target as Node)) return;
92
+ if (!props.disabled) setOpen(true);
93
+ }}
94
+ >
95
+ <Select
96
+ disabled={props.disabled}
97
+ open={open}
98
+ onOpenChange={setOpen}
99
+ value={props.value}
100
+ onValueChange={(kind) => {
101
+ if (kind !== null) props.onValueChange(kind);
102
+ }}
103
+ >
104
+ <SelectTrigger size="xs" variant="ghost" aria-label="Host for the new repository">
105
+ <SelectValue>
106
+ {(kind: SourceControlProviderKind) => sourceControlClients.get(kind).label}
107
+ </SelectValue>
108
+ </SelectTrigger>
109
+ <SelectPopup align="end" alignItemWithTrigger={false}>
110
+ {props.targets.map((target) => (
111
+ <SelectItem key={target.definition.kind} hideIndicator value={target.definition.kind}>
112
+ <span className="inline-flex items-center gap-1.5">
113
+ {sourceControlHostIcon(target.definition, "size-3.5")}
114
+ {target.definition.label}
115
+ </span>
116
+ </SelectItem>
117
+ ))}
118
+ </SelectPopup>
119
+ </Select>
120
+ </span>
121
+ );
122
+}
123
+
124
+export function NewProjectSummary(props: {
125
+ readonly name: string;
126
+ readonly pathPreview: string;
127
+ readonly projectsRoot: string | null;
128
+ readonly environmentLabel: string | null;
129
+}) {
130
+ return (
131
+ <div className="p-2 pb-0">
132
+ <div className="flex min-h-8 items-center gap-2 rounded-sm px-2 py-1.5">
133
+ <CommandPaletteTitleIcon>
134
+ <FolderGit2Icon className={ITEM_ICON_CLASS} />
135
+ </CommandPaletteTitleIcon>
136
+ <span className="flex min-w-0 flex-1 flex-col">
137
+ <span className="truncate text-foreground text-sm">
138
+ {props.name.length > 0 ? props.name : "New project"}
139
+ </span>
140
+ <span className="truncate text-muted-foreground/85 text-xs">
141
+ {props.name.length > 0
142
+ ? `Creates ${props.pathPreview}`
143
+ : `Goes in ${props.projectsRoot}`}
144
+ {props.environmentLabel === null ? null : ` on ${props.environmentLabel}`}
145
+ </span>
146
+ </span>
147
+ </div>
148
+ </div>
149
+ );
150
+}
151
+
152
+export function RemoteRepositorySummary(props: {
153
+ readonly source: AddProjectRemoteSource;
154
+ readonly title: string;
155
+ readonly description: string;
156
+}) {
157
+ return (
158
+ <div className="shrink-0 p-2 pb-0">
159
+ <div className="px-2 py-1.5 font-medium text-muted-foreground text-xs">Repository</div>
160
+ <div className="flex min-h-8 items-center gap-2 rounded-sm px-2 py-1.5">
161
+ <CommandPaletteTitleIcon>
162
+ {remoteProjectSourceIcon(props.source, ITEM_ICON_CLASS)}
163
+ </CommandPaletteTitleIcon>
164
+ <span className="flex min-w-0 flex-1 flex-col">
165
+ <span className="truncate text-foreground text-sm">{props.title}</span>
166
+ <span className="truncate text-muted-foreground/85 text-xs">{props.description}</span>
167
+ </span>
168
+ </div>
169
+ </div>
170
+ );
171
+}