Skip to content

Commit d28c828

Browse files
t3dotggclaude
andcommitted
fix: council round 4 for project pins and archives
- New thread opens the picker when every project is archived. - Web new scheduled tasks default to a pinned project again, and an archived Settings scope still offers its project. - Editing a scheduled task keeps its original project listed (web and mobile). Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a195af9 commit d28c828

6 files changed

Lines changed: 51 additions & 8 deletions

File tree

‎apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,9 @@ function TaskForm({
670670
.filter(
671671
(project) =>
672672
project.environmentId === environmentId &&
673-
(project.archivedAt == null || project.id === draft.projectId),
673+
(project.archivedAt == null ||
674+
project.id === draft.projectId ||
675+
project.id === draft.task?.projectId),
674676
)
675677
.sort((left, right) => Number(right.pinnedAt != null) - Number(left.pinnedAt != null));
676678
const config = useEnvironmentServerConfig(environmentId);

‎apps/web/src/components/Sidebar.logic.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { describe, expect, it, vi } from "vite-plus/test";
55
import * as Cause from "effect/Cause";
66
import { AsyncResult } from "effect/reactivity";
77
import {
8+
shouldCreateNewThreadInCurrentProject,
89
archiveSelectedThreadEntries,
910
deleteSelectedThreadEntries,
1011
getFallbackThreadIdAfterDelete,
@@ -1356,3 +1357,13 @@ describe("resolveSidebarRouteReveal", () => {
13561357
).toEqual({ pendingKey: hiddenKey, widensScope: false });
13571358
});
13581359
});
1360+
1361+
describe("shouldCreateNewThreadInCurrentProject", () => {
1362+
it("opens the picker when several projects are open, or only archived ones exist", () => {
1363+
expect(shouldCreateNewThreadInCurrentProject(false, 2, 3)).toBe(false);
1364+
expect(shouldCreateNewThreadInCurrentProject(false, 0, 2)).toBe(false);
1365+
expect(shouldCreateNewThreadInCurrentProject(false, 1, 3)).toBe(true);
1366+
expect(shouldCreateNewThreadInCurrentProject(false, 0, 0)).toBe(true);
1367+
expect(shouldCreateNewThreadInCurrentProject(true, 2, 2)).toBe(true);
1368+
});
1369+
});

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,11 +749,13 @@ export function isSidebarNestedLinkClick(target: EventTarget | null): boolean {
749749
return nodeClosest(parent, "a[href]") !== null;
750750
}
751751

752+
/** The "New thread in" picker opens unless one open project, or none at all, decides it. */
752753
export function shouldCreateNewThreadInCurrentProject(
753754
shiftKey: boolean,
755+
openProjectGroupCount: number,
754756
projectGroupCount: number,
755757
): boolean {
756-
return shiftKey || projectGroupCount <= 1;
758+
return shiftKey || openProjectGroupCount === 1 || projectGroupCount === 0;
757759
}
758760

759761
export function orderItemsByPreferredIds<TItem, TId>(input: {

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2714,7 +2714,13 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
27142714
const showJumpHints = useThreadJumpHintsVisible(shouldShowJumpHintsNow);
27152715

27162716
const handleNewThreadClick = (event?: ReactMouseEvent) => {
2717-
if (shouldCreateNewThreadInCurrentProject(event?.shiftKey ?? false, scopeGroups.length)) {
2717+
if (
2718+
shouldCreateNewThreadInCurrentProject(
2719+
event?.shiftKey ?? false,
2720+
scopeGroups.length,
2721+
projectGroups.length,
2722+
)
2723+
) {
27182724
if (isMobile) setOpenMobile(false);
27192725
void startNewThreadFromContext({
27202726
activeDraftThread: newThreadContext.activeDraftThread,

‎apps/web/src/components/settings/ScheduledTasksSettings.tsx‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,12 +1143,25 @@ function ScheduledTaskEditorForm({
11431143
? taskToDraft(task)
11441144
: {
11451145
...EMPTY_DRAFT,
1146-
projectId: scopedProjects.find((project) => project.archivedAt == null)?.id ?? "",
1146+
// Pinned first; a Settings scope on an archived project still offers it.
1147+
projectId:
1148+
(
1149+
scopedProjects.find(
1150+
(project) => project.pinnedAt != null && project.archivedAt == null,
1151+
) ??
1152+
scopedProjects.find((project) => project.archivedAt == null) ??
1153+
scopedProjects[0]
1154+
)?.id ?? "",
11471155
},
11481156
);
11491157
// Pinned first. The chosen project stays listed after it is archived.
11501158
const projects = scopedProjects
1151-
.filter((project) => project.archivedAt == null || project.id === draft.projectId)
1159+
.filter(
1160+
(project) =>
1161+
project.archivedAt == null ||
1162+
project.id === draft.projectId ||
1163+
project.id === task?.projectId,
1164+
)
11521165
.sort((left, right) => Number(right.pinnedAt != null) - Number(left.pinnedAt != null));
11531166
const submissionPending = useRef(false);
11541167
const editingTaskMissing =

‎apps/web/src/shortcuts/chatRouteCommands.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { isCommandPaletteOpen, openCommandPalette } from "../commandPaletteBus";
77
import { useComposerDraftStore } from "../composerDraftStore";
88
import { dispatchPreviewAction, type PreviewAction } from "../components/preview/previewActionBus";
99
import { isAppModalPage } from "../components/sidebar/mainAppLocation";
10+
import { shouldCreateNewThreadInCurrentProject } from "../components/Sidebar.logic";
1011
import { createNewThreadHandler, resolveDefaultProjectRef } from "../hooks/useHandleNewThread";
1112
import { createScratchProjectActions } from "../hooks/useScratchProject";
1213
import { getClientSettings } from "../hooks/useSettings";
@@ -75,13 +76,13 @@ export function installChatRouteCommands(router: AnyRouter): () => void {
7576
handleNewThread,
7677
};
7778
};
78-
const readProjectGroupCount = () =>
79+
const readProjectGroups = () =>
7980
buildSidebarProjectSnapshots({
8081
projects: readProjects(),
8182
settings: selectProjectGroupingSettings(getClientSettings()),
8283
primaryEnvironmentId: appAtomRegistry.get(primaryEnvironmentIdAtom),
8384
resolveEnvironmentLabel: () => null,
84-
}).filter((group) => !group.archived).length;
85+
});
8586
const canOperatePreview = (environmentId: EnvironmentId) =>
8687
readEnvironmentScope(environmentId, AuthPreviewOperateScope);
8788

@@ -119,7 +120,15 @@ export function installChatRouteCommands(router: AnyRouter): () => void {
119120
},
120121
"chat.new": (event) => {
121122
// Pre-hydration settings are the defaults, where the legacy sidebar is off.
122-
if (!getClientSettings().legacySidebarEnabled && readProjectGroupCount() > 1) {
123+
const groups = readProjectGroups();
124+
if (
125+
!getClientSettings().legacySidebarEnabled &&
126+
!shouldCreateNewThreadInCurrentProject(
127+
false,
128+
groups.filter((group) => !group.archived).length,
129+
groups.length,
130+
)
131+
) {
123132
claim(event);
124133
openCommandPalette({ open: "new-thread-in" });
125134
return;

0 commit comments

Comments
 (0)