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
28 changes: 28 additions & 0 deletions apps/web/src/components/CommandPalette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
ArrowDownIcon,
ArrowLeftIcon,
ArrowUpIcon,
ArchiveIcon,
CornerLeftUpIcon,
FolderIcon,
FolderPlusIcon,
Expand Down Expand Up @@ -47,6 +48,7 @@ import {
} from "../environments/runtime";
import { useHandleNewThread } from "../hooks/useHandleNewThread";
import { useSettings } from "../hooks/useSettings";
import { useThreadActions } from "../hooks/useThreadActions";
import { readLocalApi } from "../localApi";
import {
getSourceControlDiscoverySnapshot,
Expand Down Expand Up @@ -404,6 +406,7 @@ function OpenCommandPaletteDialog() {
const settings = useSettings();
const { activeDraftThread, activeThread, defaultProjectRef, handleNewThread } =
useHandleNewThread();
const { archiveThread } = useThreadActions();
const projects = useStore(useShallow(selectProjectsAcrossEnvironments));
const threads = useStore(useShallow(selectSidebarThreadsAcrossEnvironments));
const keybindings = useServerKeybindings();
Expand Down Expand Up @@ -1021,6 +1024,31 @@ function OpenCommandPaletteDialog() {
});
}

if (activeThread) {
actionItems.push({
kind: "action",
value: "action:archive-current-thread",
searchTerms: ["archive", "current thread", "hide thread"],
title: "Archive current thread",
description: activeThread.title,
icon: <ArchiveIcon className={ITEM_ICON_CLASS} />,
shortcutCommand: "thread.archiveCurrent",
run: async () => {
await archiveThread(scopeThreadRef(activeThread.environmentId, activeThread.id)).catch(
(error: unknown) => {
toastManager.add(
stackedThreadToast({
type: "error",
title: "Failed to archive thread",
description: error instanceof Error ? error.message : "An error occurred.",
}),
);
},
);
},
});
}

actionItems.push({
kind: "action",
value: "action:add-project",
Expand Down
21 changes: 21 additions & 0 deletions apps/web/src/routes/_chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useEffect } from "react";

import { useCommandPaletteStore } from "../commandPaletteStore";
import { useHandleNewThread } from "../hooks/useHandleNewThread";
import { useThreadActions } from "../hooks/useThreadActions";
import {
startNewLocalThreadFromContext,
startNewThreadFromContext,
Expand All @@ -11,6 +12,7 @@ import { isTerminalFocused } from "../lib/terminalFocus";
import { resolveShortcutCommand } from "../keybindings";
import { selectThreadTerminalState, useTerminalStateStore } from "../terminalStateStore";
import { useThreadSelectionStore } from "../threadSelectionStore";
import { stackedThreadToast, toastManager } from "~/components/ui/toast";
import { resolveSidebarNewThreadEnvMode } from "~/components/Sidebar.logic";
import { useSettings } from "~/hooks/useSettings";
import { useServerKeybindings } from "~/rpc/serverState";
Expand All @@ -20,6 +22,7 @@ function ChatRouteGlobalShortcuts() {
const selectedThreadKeysSize = useThreadSelectionStore((state) => state.selectedThreadKeys.size);
const { activeDraftThread, activeThread, defaultProjectRef, handleNewThread, routeThreadRef } =
useHandleNewThread();
const { archiveThread } = useThreadActions();
const keybindings = useServerKeybindings();
const terminalOpen = useTerminalStateStore((state) =>
routeThreadRef
Expand Down Expand Up @@ -75,6 +78,22 @@ function ChatRouteGlobalShortcuts() {
}),
handleNewThread,
});
return;
}

if (command === "thread.archiveCurrent") {
if (!routeThreadRef) return;
event.preventDefault();
event.stopPropagation();
void archiveThread(routeThreadRef).catch((error: unknown) => {
toastManager.add(
stackedThreadToast({
type: "error",
title: "Failed to archive thread",
description: error instanceof Error ? error.message : "An error occurred.",
}),
);
});
}
};

Expand All @@ -85,10 +104,12 @@ function ChatRouteGlobalShortcuts() {
}, [
activeDraftThread,
activeThread,
archiveThread,
clearSelection,
handleNewThread,
keybindings,
defaultProjectRef,
routeThreadRef,
selectedThreadKeysSize,
terminalOpen,
appSettings.defaultThreadEnvMode,
Expand Down
1 change: 1 addition & 0 deletions packages/contracts/src/keybindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type ModelPickerJumpKeybindingCommand =
export const THREAD_KEYBINDING_COMMANDS = [
"thread.previous",
"thread.next",
"thread.archiveCurrent",
...THREAD_JUMP_KEYBINDING_COMMANDS,
] as const;
export type ThreadKeybindingCommand = (typeof THREAD_KEYBINDING_COMMANDS)[number];
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/keybindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const DEFAULT_KEYBINDINGS: ReadonlyArray<KeybindingRule> = [
{ key: "mod+o", command: "editor.openFavorite" },
{ key: "mod+shift+[", command: "thread.previous" },
{ key: "mod+shift+]", command: "thread.next" },
{ key: "mod+shift+a", command: "thread.archiveCurrent", when: "!terminalFocus" },
...THREAD_JUMP_KEYBINDING_COMMANDS.map((command, index) => ({
key: `mod+${index + 1}`,
command,
Expand Down
Loading