Skip to content

Commit ad80797

Browse files
fix(web): keep "No project" under the draft headline, out of the picker
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b124ee9 commit ad80797

1 file changed

Lines changed: 6 additions & 22 deletions

File tree

‎apps/web/src/components/chat/DraftHeroHeadline.tsx‎

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ import { composerDraftHasUserContent, useComposerDraftStore } from "~/composerDr
33
import { resolveEnvironmentMachineKind, type ScopedProjectRef } from "@t3tools/contracts";
44
import { scopedProjectKey, scopeProjectRef } from "@t3tools/client-runtime/environment";
55
import { isScratchProject } from "@t3tools/client-runtime/state/projects";
6-
import { FolderPlusIcon, MessageSquareDashedIcon } from "lucide-react";
6+
import { FolderPlusIcon } from "lucide-react";
77
import { useAtomValue } from "@effect/atom-react";
88
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
99

1010
import { openCommandPalette } from "~/commandPaletteBus";
1111
import { shortcutLabelForCommand } from "~/keybindings";
12-
import { projectIconColorClassName } from "~/projectIconColors";
1312
import { primaryServerKeybindingsAtom } from "~/state/server";
1413
import { useNewThreadHandler } from "~/hooks/useHandleNewThread";
1514
import { useScratchProject } from "~/hooks/useScratchProject";
@@ -43,9 +42,8 @@ import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
4342
import { InlineButton } from "../ui/button";
4443
import { resolveProjectSettings } from "@t3tools/shared/projectSettings";
4544

46-
// Picker values for the non-project rows; real entries are keyed by logical
45+
// Picker value for the "Add project" row; real entries are keyed by logical
4746
// project key.
48-
const NO_PROJECT_VALUE = "no-project";
4947
const ADD_PROJECT_VALUE = "add-project";
5048

5149
interface PickerItem {
@@ -155,8 +153,8 @@ export function DraftHeroHeadline({
155153
const hasResolvedProject = activeProjectTitle !== null;
156154
const canChooseProject = projectPickerEntries.length > 0;
157155
const shouldShowProjectMenu = canChooseProject;
158-
// The project that hosts threads without a project appears once, as the
159-
// "No project" item, not as a project row.
156+
// The project that hosts threads without a project is not a row: the line
157+
// under the headline is the way into it.
160158
const menuEntries = useMemo(
161159
() =>
162160
projectPickerEntries.filter(
@@ -185,11 +183,10 @@ export function DraftHeroHeadline({
185183
// a project, so it only trails the unfiltered list.
186184
const pickerItems = useMemo<readonly PickerItem[]>(
187185
() => [
188-
...(scratchWorkspaceRoot === null ? [] : [{ value: NO_PROJECT_VALUE, label: "No project" }]),
189186
...menuEntries.map(({ group }) => ({ value: group.projectKey, label: group.displayName })),
190187
{ value: ADD_PROJECT_VALUE, label: "Add project" },
191188
],
192-
[menuEntries, scratchWorkspaceRoot],
189+
[menuEntries],
193190
);
194191
const [pickerOpen, setPickerOpen] = useState(false);
195192
const [pickerQuery, setPickerQuery] = useState("");
@@ -203,8 +200,7 @@ export function DraftHeroHeadline({
203200
pickerFilter.contains(item, query, (candidate) => candidate.label),
204201
);
205202
}, [pickerFilter, pickerItems, pickerQuery]);
206-
const selectedPickerValue = isScratchDraft ? NO_PROJECT_VALUE : activeProjectKey;
207-
const selectedPickerItem = pickerItems.find((item) => item.value === selectedPickerValue) ?? null;
203+
const selectedPickerItem = pickerItems.find((item) => item.value === activeProjectKey) ?? null;
208204

209205
// The picker can change the draft's target while the no-project home is
210206
// still being opened; a stale continuation must not retarget it again.
@@ -291,10 +287,6 @@ export function DraftHeroHeadline({
291287
openAddProject();
292288
return;
293289
}
294-
if (item.value === NO_PROJECT_VALUE) {
295-
void startScratch();
296-
return;
297-
}
298290
const entry = projectEntryByKey.get(item.value);
299291
if (!entry || item.value === activeProjectKey) {
300292
return;
@@ -339,14 +331,6 @@ export function DraftHeroHeadline({
339331
<ComboboxItem key={item.value} hideIndicator value={item}>
340332
{item.value === ADD_PROJECT_VALUE ? (
341333
<FolderPlusIcon className="size-4 shrink-0" />
342-
) : item.value === NO_PROJECT_VALUE ? (
343-
// Boxed like ProjectFavicon so the label lines up with project rows.
344-
<span
345-
aria-hidden="true"
346-
className={`inline-flex size-4 shrink-0 ${projectIconColorClassName("gray")}`}
347-
>
348-
<MessageSquareDashedIcon className="size-full" />
349-
</span>
350334
) : entry ? (
351335
<ProjectFavicon project={entry.group} className="size-4 shrink-0" />
352336
) : null}

0 commit comments

Comments
 (0)