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
6 changes: 3 additions & 3 deletions apps/web/src/components/CommandPalette.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("reduceCommandPaletteUiState", () => {

expect(
reduceCommandPaletteUiState(contentOpen, { _tag: "ToggleMode", mode: "content" }),
).toEqual({ open: false, mode: "command", openIntent: null });
).toEqual({ open: false, mode: "content", openIntent: null });
});

it("switches between open modes without closing", () => {
Expand Down Expand Up @@ -62,15 +62,15 @@ describe("reduceCommandPaletteUiState", () => {
});
});

it("resets to command mode for dialog-driven opens and closes", () => {
it("preserves the mode on close and resets it on open", () => {
const filesOpen = reduceCommandPaletteUiState(closedState, {
_tag: "ToggleMode",
mode: "files",
});

expect(reduceCommandPaletteUiState(filesOpen, { _tag: "SetOpen", open: false })).toEqual({
open: false,
mode: "command",
mode: "files",
openIntent: null,
});
expect(reduceCommandPaletteUiState(filesOpen, { _tag: "SetOpen", open: true })).toEqual({
Expand Down
10 changes: 4 additions & 6 deletions apps/web/src/components/CommandPalette.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,12 @@ export function reduceCommandPaletteUiState(
): CommandPaletteUiState {
switch (action._tag) {
case "SetOpen":
return {
open: action.open,
mode: "command",
openIntent: action.open ? state.openIntent : null,
};
return action.open
? { open: true, mode: "command", openIntent: state.openIntent }
: { ...state, open: false, openIntent: null };
case "ToggleMode":
return state.open && state.mode === action.mode
? { open: false, mode: "command", openIntent: null }
? { ...state, open: false, openIntent: null }
: { open: true, mode: action.mode, openIntent: null };
case "OpenAddProject":
return { open: true, mode: "command", openIntent: { kind: "add-project" } };
Expand Down
6 changes: 0 additions & 6 deletions apps/web/src/components/CommandPalette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@ export function CommandPalette({ children }: { children: ReactNode }) {
>
{children}
<CommandPaletteDialog
open={state.open}
Comment thread
tarik02 marked this conversation as resolved.
mode={state.mode}
openIntent={state.openIntent}
setOpen={setOpen}
Expand All @@ -471,7 +470,6 @@ export function CommandPalette({ children }: { children: ReactNode }) {
}

function CommandPaletteDialog(props: {
readonly open: boolean;
readonly mode: SearchOverlayMode;
readonly openIntent: CommandPaletteOpenIntent | null;
readonly setOpen: (open: boolean) => void;
Expand All @@ -480,10 +478,6 @@ function CommandPaletteDialog(props: {
}) {
const composerHandleRef = useComposerHandleContext();

if (!props.open) {
return null;
}

Comment thread
cursor[bot] marked this conversation as resolved.
Comment thread
tarik02 marked this conversation as resolved.
return (
<CommandDialogPopup
Comment thread
tarik02 marked this conversation as resolved.
Comment thread
tarik02 marked this conversation as resolved.
aria-label={
Expand Down
Loading