Skip to content

Commit a195af9

Browse files
t3dotggclaude
andcommitted
fix: council round 3 for project pins and archives
- "No project" in the new-thread palette follows every pinned project. - New-thread choices and shortcuts count only open projects. - Thread menus no longer offer an archived project as a filter. - Mobile share auto-select skips archived projects. - Scheduled task editors keep a picked project after it is archived elsewhere, and mobile defaults to a pinned project first, like web. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b184dd2 commit a195af9

8 files changed

Lines changed: 98 additions & 26 deletions

File tree

‎apps/mobile/src/features/settings/scheduled-task-editor.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ export function useScheduledTaskEditor() {
3737
(member) =>
3838
member.project.environmentId === environmentId && member.project.id === project.id,
3939
),
40-
) ?? environmentProjects.find((project) => project.archivedAt == null);
40+
) ??
41+
environmentProjects.find(
42+
(project) => project.pinnedAt != null && project.archivedAt == null,
43+
) ??
44+
environmentProjects.find((project) => project.archivedAt == null);
4145
return createDraft(
4246
project?.id ?? null,
4347
scheduledTaskDefaultModel(configs.get(environmentId) ?? null, project ?? null),

‎apps/mobile/src/features/threads/NewTaskDraftScreen.tsx‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import * as Dialog from "../../components/ui/Dialog";
1818
import { useAtomValue } from "@effect/atom-react";
1919
import * as Cause from "effect/Cause";
2020
import { AsyncResult } from "effect/reactivity";
21+
import { pickableProjectGroups } from "@t3tools/client-runtime/state/project-grouping";
2122
import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
2223
import {
2324
CommonActions,
@@ -456,10 +457,15 @@ export function NewTaskDraftScreen(props: {
456457
return;
457458
}
458459

459-
const selection = resolveDraftProjectSelection(selectedProjectKey, projects, projectScopes, {
460-
incomingShareId: props.incomingShareId,
461-
pickerClosed: initialPickerRef.current === "open" && isFocused,
462-
});
460+
const selection = resolveDraftProjectSelection(
461+
selectedProjectKey,
462+
projects,
463+
pickableProjectGroups(projectScopes),
464+
{
465+
incomingShareId: props.incomingShareId,
466+
pickerClosed: initialPickerRef.current === "open" && isFocused,
467+
},
468+
);
463469
if (selection.kind === "preserve") {
464470
initialPickerRef.current = null;
465471
return;

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { EnvironmentId, ProjectId, ProviderInstanceId, ThreadId } from "@t3tools
33
import type { Thread } from "../types";
44
import { makeThreadFixture } from "../test-fixtures";
55
import {
6+
newThreadNoProjectIndex,
67
buildNestedSearchItems,
78
buildThreadActionItems,
89
buildLinkedThreadActionItems,
@@ -918,3 +919,25 @@ describe("returning from file and content search", () => {
918919
expect(reduceCommandPaletteUiState(closed, { _tag: "SetOpen", open: true })).toEqual(root);
919920
});
920921
});
922+
923+
describe("newThreadNoProjectIndex", () => {
924+
const entry = (pinned = false, isPreferred = false, isScratch = false) => ({
925+
pinned,
926+
isPreferred,
927+
isScratch,
928+
});
929+
930+
it("goes after the pinned projects and the first unpinned one", () => {
931+
expect(newThreadNoProjectIndex([entry(true), entry(true), entry(false, true), entry()])).toBe(
932+
3,
933+
);
934+
expect(newThreadNoProjectIndex([entry(false, true), entry(), entry(false, false, true)])).toBe(
935+
1,
936+
);
937+
});
938+
939+
it("keeps a pinned or current scratch project in its own place", () => {
940+
expect(newThreadNoProjectIndex([entry(false, true, true), entry()])).toBe(0);
941+
expect(newThreadNoProjectIndex([entry(true), entry(true, false, true), entry()])).toBe(1);
942+
});
943+
});

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,3 +860,25 @@ export function overlayModeForCommand(command: string | null): SearchOverlayMode
860860
? OVERLAY_MODE_BY_COMMAND[command as keyof typeof OVERLAY_MODE_BY_COMMAND]
861861
: null;
862862
}
863+
864+
/**
865+
* Where "No project" goes among the new-thread picker's real projects: at the
866+
* scratch project's own place when it is pinned or current, else after the
867+
* pinned projects and the first unpinned one.
868+
*/
869+
export function newThreadNoProjectIndex(
870+
entries: ReadonlyArray<{
871+
readonly isScratch: boolean;
872+
readonly pinned: boolean;
873+
readonly isPreferred: boolean;
874+
}>,
875+
): number {
876+
const projects = entries.filter((entry) => !entry.isScratch);
877+
const scratchAt = entries.findIndex((entry) => entry.isScratch);
878+
const scratch = entries[scratchAt];
879+
if (scratch && (scratch.pinned || scratch.isPreferred)) {
880+
return entries.slice(0, scratchAt).filter((entry) => !entry.isScratch).length;
881+
}
882+
const pinnedCount = projects.filter((entry) => entry.pinned).length;
883+
return Math.min(pinnedCount + 1, projects.length);
884+
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ import {
158158
buildLinkedThreadActionItems,
159159
buildCommandPaletteRows,
160160
enumerateCommandPaletteItems,
161+
newThreadNoProjectIndex,
161162
findHighlightedCommandPaletteItem,
162163
type CommandPaletteActionItem,
163164
type CommandPaletteOpenIntent,
@@ -784,7 +785,16 @@ function OpenCommandPaletteDialog(props: {
784785
);
785786
if (scratchTargetEnvironmentId === null) return projectItems;
786787

787-
const noProjectIndex = pickerProjects[0] !== undefined && isScratch(pickerProjects[0]) ? 0 : 1;
788+
const noProjectIndex = newThreadNoProjectIndex(
789+
projectPickerEntries.map(({ group, targetProject, isPreferred }) => ({
790+
isScratch: isScratchProject(
791+
targetProject,
792+
scratchWorkspaceRootFor(targetProject.environmentId),
793+
),
794+
pinned: group.pinned,
795+
isPreferred,
796+
})),
797+
);
788798
return [
789799
...projectItems.slice(0, noProjectIndex),
790800
{

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2421,12 +2421,14 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
24212421
AuthOrchestrationOperateScope,
24222422
),
24232423
branch: thread.branch ?? null,
2424-
projectFilter: threadProjectGroup
2425-
? {
2426-
label: threadProjectGroup.displayName,
2427-
isActive: projectScopeKey === threadProjectGroup.projectKey,
2428-
}
2429-
: null,
2424+
// An archived project is not a filter choice.
2425+
projectFilter:
2426+
threadProjectGroup && !threadProjectGroup.archived
2427+
? {
2428+
label: threadProjectGroup.displayName,
2429+
isActive: projectScopeKey === threadProjectGroup.projectKey,
2430+
}
2431+
: null,
24302432
isPinned,
24312433
isSettled,
24322434
autoSettleEnabled: thread.autoSettleDisabledAt == null,
@@ -2712,7 +2714,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
27122714
const showJumpHints = useThreadJumpHintsVisible(shouldShowJumpHintsNow);
27132715

27142716
const handleNewThreadClick = (event?: ReactMouseEvent) => {
2715-
if (shouldCreateNewThreadInCurrentProject(event?.shiftKey ?? false, projectGroups.length)) {
2717+
if (shouldCreateNewThreadInCurrentProject(event?.shiftKey ?? false, scopeGroups.length)) {
27162718
if (isMobile) setOpenMobile(false);
27172719
void startNewThreadFromContext({
27182720
activeDraftThread: newThreadContext.activeDraftThread,
@@ -2728,7 +2730,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
27282730

27292731
const newThreadShortcutLabel =
27302732
shortcutLabelForCommand(keybindings, "chat.new") ??
2731-
(projectGroups.length <= 1 ? shortcutLabelForCommand(keybindings, "chat.newLocal") : undefined);
2733+
(scopeGroups.length <= 1 ? shortcutLabelForCommand(keybindings, "chat.newLocal") : undefined);
27322734
const newThreadInProjectShortcutLabel = shortcutLabelForCommand(keybindings, "chat.newLocal");
27332735
return (
27342736
<>
@@ -2912,7 +2914,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
29122914
newThreadDisabled={projects.length === 0}
29132915
newThreadShortcutLabel={newThreadShortcutLabel}
29142916
newThreadInProjectShortcutLabel={newThreadInProjectShortcutLabel}
2915-
showNewThreadInProjectHint={projectGroups.length > 1}
2917+
showNewThreadInProjectHint={scopeGroups.length > 1}
29162918
searchInputRef={threadSearchInputRef}
29172919
searchQuery={threadSearchQuery}
29182920
onSearchQueryChange={(value) => {

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,15 +1124,11 @@ function ScheduledTaskEditorForm({
11241124
connected ? serverEnvironment.scheduledTasksLive({ environmentId, input: {} }) : null,
11251125
);
11261126
const allProjects = useProjects();
1127-
// Pinned first. An existing task keeps its project after that project is archived.
1128-
const projects = allProjects
1129-
.filter(
1130-
(project) =>
1131-
project.environmentId === environmentId &&
1132-
matchesScheduledTaskScope(scope, environmentId, project.id) &&
1133-
(project.archivedAt == null || project.id === task?.projectId),
1134-
)
1135-
.sort((left, right) => Number(right.pinnedAt != null) - Number(left.pinnedAt != null));
1127+
const scopedProjects = allProjects.filter(
1128+
(project) =>
1129+
project.environmentId === environmentId &&
1130+
matchesScheduledTaskScope(scope, environmentId, project.id),
1131+
);
11361132
const settings = useEnvironmentSettings(environmentId);
11371133
const providers =
11381134
useAtomValue(serverEnvironment.providersValueAtom(environmentId)) ?? EMPTY_SERVER_PROVIDERS;
@@ -1143,8 +1139,17 @@ function ScheduledTaskEditorForm({
11431139
label: "scheduled task upsert",
11441140
});
11451141
const [draft, setDraft] = useState<DraftState>(() =>
1146-
task ? taskToDraft(task) : { ...EMPTY_DRAFT, projectId: projects[0]?.id ?? "" },
1142+
task
1143+
? taskToDraft(task)
1144+
: {
1145+
...EMPTY_DRAFT,
1146+
projectId: scopedProjects.find((project) => project.archivedAt == null)?.id ?? "",
1147+
},
11471148
);
1149+
// Pinned first. The chosen project stays listed after it is archived.
1150+
const projects = scopedProjects
1151+
.filter((project) => project.archivedAt == null || project.id === draft.projectId)
1152+
.sort((left, right) => Number(right.pinnedAt != null) - Number(left.pinnedAt != null));
11481153
const submissionPending = useRef(false);
11491154
const editingTaskMissing =
11501155
draft.editingId !== null &&

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function installChatRouteCommands(router: AnyRouter): () => void {
8181
settings: selectProjectGroupingSettings(getClientSettings()),
8282
primaryEnvironmentId: appAtomRegistry.get(primaryEnvironmentIdAtom),
8383
resolveEnvironmentLabel: () => null,
84-
}).length;
84+
}).filter((group) => !group.archived).length;
8585
const canOperatePreview = (environmentId: EnvironmentId) =>
8686
readEnvironmentScope(environmentId, AuthPreviewOperateScope);
8787

0 commit comments

Comments
 (0)