Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/desktop/src/settings/DesktopClientSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const clientSettings: ClientSettings = {
sidebarProjectGroupingOverrides: {
"environment-1:/tmp/project-a": "separate",
},
sidebarProjectGroupingInheritance: {},
sidebarProjectSortOrder: "manual",
sidebarThreadSortOrder: "created_at",
sidebarThreadPreviewCount: 6,
Expand Down
1 change: 1 addition & 0 deletions apps/mobile/src/features/home/homeThreadList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export function buildHomeProjectScopes(input: {
settings: {
sidebarProjectGroupingMode: input.projectGroupingMode,
sidebarProjectGroupingOverrides: {},
sidebarProjectGroupingInheritance: {},
},
}).map((group) => {
return {
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/state/project-grouping.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { Preferences } from "../persistence/mobile-preferences";
export const DEFAULT_MOBILE_PROJECT_GROUPING_SETTINGS: ProjectGroupingSettings = {
sidebarProjectGroupingMode: "repository",
sidebarProjectGroupingOverrides: {},
sidebarProjectGroupingInheritance: {},
};

export function resolveMobileProjectGroupingSettings(
Expand All @@ -16,6 +17,7 @@ export function resolveMobileProjectGroupingSettings(
preferences.projectGroupingMode ??
(preferences.projectGroupingEnabled === false ? "separate" : "repository"),
sidebarProjectGroupingOverrides: {},
sidebarProjectGroupingInheritance: {},
};
}

Expand Down
14 changes: 11 additions & 3 deletions apps/web/src/commandPaletteBus.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import type { EnvironmentId } from "@t3tools/contracts";

// Tiny event bus allowing components to programmatically open the command palette
// without owning its React state.
const COMMAND_PALETTE_OPEN_EVENT = "t3code:open-command-palette";

export interface CommandPaletteOpenDetail {
readonly open?: "add-project" | "new-thread-in";
}
export type CommandPaletteOpenDetail =
| { readonly open?: undefined }
| { readonly open: "add-project" | "new-thread-in" }
| {
readonly open: "select-directory";
readonly environmentId: EnvironmentId;
readonly initialPath: string;
readonly onSelect: (path: string) => boolean | Promise<boolean>;
};

export function openCommandPalette(detail?: CommandPaletteOpenDetail): void {
window.dispatchEvent(
Expand Down
30 changes: 30 additions & 0 deletions apps/web/src/components/CommandPalette.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe("browseInputEndPaddingClass", () => {
browseInputEndPaddingClass({
willCreateProjectPath: true,
hasHighlightedBrowseItem: false,
isDirectoryPicker: false,
}),
).toContain("pe-38");
});
Expand All @@ -27,6 +28,7 @@ describe("browseInputEndPaddingClass", () => {
browseInputEndPaddingClass({
willCreateProjectPath: false,
hasHighlightedBrowseItem: true,
isDirectoryPicker: false,
}),
).toContain("pe-30");
});
Expand All @@ -36,9 +38,20 @@ describe("browseInputEndPaddingClass", () => {
browseInputEndPaddingClass({
willCreateProjectPath: false,
hasHighlightedBrowseItem: false,
isDirectoryPicker: false,
}),
).toContain("pe-24");
});

it("reserves space for the directory picker action", () => {
expect(
browseInputEndPaddingClass({
willCreateProjectPath: false,
hasHighlightedBrowseItem: false,
isDirectoryPicker: true,
}),
).toContain("pe-30");
});
});

describe("reduceCommandPaletteUiState", () => {
Expand Down Expand Up @@ -91,6 +104,23 @@ describe("reduceCommandPaletteUiState", () => {
mode: "command",
openIntent: { kind: "new-thread-in" },
});

const directoryIntent = {
kind: "select-directory",
environmentId: EnvironmentId.make("test-environment"),
initialPath: "/projects/current",
onSelect: vi.fn(async () => true),
} as const;
expect(
reduceCommandPaletteUiState(filesOpen, {
_tag: "OpenDirectoryPicker",
intent: directoryIntent,
}),
).toEqual({
open: true,
mode: "command",
openIntent: directoryIntent,
});
});

it("preserves the mode on close and resets it on open", () => {
Expand Down
21 changes: 17 additions & 4 deletions apps/web/src/components/CommandPalette.logic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
type EnvironmentId,
type FilesystemBrowseEntry,
type KeybindingCommand,
THREAD_JUMP_KEYBINDING_COMMANDS,
Expand All @@ -19,11 +20,12 @@ export const ADDON_ICON_CLASS = "size-4";
export function browseInputEndPaddingClass(input: {
readonly willCreateProjectPath: boolean;
readonly hasHighlightedBrowseItem: boolean;
readonly isDirectoryPicker: boolean;
}): string {
if (input.willCreateProjectPath) {
return "*:data-[slot=autocomplete-input]:pe-38!";
}
if (input.hasHighlightedBrowseItem) {
if (input.hasHighlightedBrowseItem || input.isDirectoryPicker) {
return "*:data-[slot=autocomplete-input]:pe-30!";
}
return "*:data-[slot=autocomplete-input]:pe-24!";
Expand All @@ -37,9 +39,14 @@ export function browseInputEndPaddingClass(input: {
*/
export type SearchOverlayMode = "command" | "files" | "content";

export interface CommandPaletteOpenIntent {
readonly kind: "add-project" | "new-thread-in";
}
export type CommandPaletteOpenIntent =
| { readonly kind: "add-project" | "new-thread-in" }
| {
readonly kind: "select-directory";
readonly environmentId: EnvironmentId;
readonly initialPath: string;
readonly onSelect: (path: string) => boolean | Promise<boolean>;
};

export interface CommandPaletteUiState {
readonly open: boolean;
Expand All @@ -52,6 +59,10 @@ export type CommandPaletteUiAction =
| { readonly _tag: "ToggleMode"; readonly mode: SearchOverlayMode }
| { readonly _tag: "OpenAddProject" }
| { readonly _tag: "OpenNewThreadIn" }
| {
readonly _tag: "OpenDirectoryPicker";
readonly intent: Extract<CommandPaletteOpenIntent, { kind: "select-directory" }>;
}
| { readonly _tag: "ClearOpenIntent" };

export function reduceCommandPaletteUiState(
Expand All @@ -71,6 +82,8 @@ export function reduceCommandPaletteUiState(
return { open: true, mode: "command", openIntent: { kind: "add-project" } };
case "OpenNewThreadIn":
return { open: true, mode: "command", openIntent: { kind: "new-thread-in" } };
case "OpenDirectoryPicker":
return { open: true, mode: "command", openIntent: action.intent };
case "ClearOpenIntent":
return state.openIntent ? { ...state, openIntent: null } : state;
}
Expand Down
Loading
Loading