Skip to content

Commit 5dd48c0

Browse files
committed
feat(web): settle the current thread from the command palette
1 parent 5e22256 commit 5dd48c0

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import {
5151
ChartNoAxesColumnIcon,
5252
CheckIcon,
5353
ChevronRightIcon,
54+
CircleCheckIcon,
5455
CornerLeftUpIcon,
5556
FileSearchIcon,
5657
FolderGit2Icon,
@@ -67,6 +68,7 @@ import {
6768
SquarePenIcon,
6869
SunIcon,
6970
TextSearchIcon,
71+
Undo2Icon,
7072
} from "lucide-react";
7173
import {
7274
useCallback,
@@ -86,6 +88,7 @@ import { useAtomValue } from "@effect/atom-react";
8688
import { isDesktopLocalConnectionTarget } from "../connection/desktopLocal";
8789
import { useDesktopLocalBootstraps } from "../connection/useDesktopLocalBootstraps";
8890
import { useHandleNewThread } from "../hooks/useHandleNewThread";
91+
import { useThreadActions } from "../hooks/useThreadActions";
8992
import { useOpenPanelPullRequestUrl } from "../hooks/useOpenPanelPullRequestUrl";
9093
import { writeTextToClipboard } from "../hooks/useCopyToClipboard";
9194
import { useClientSettings } from "../hooks/useSettings";
@@ -759,6 +762,11 @@ function OpenCommandPaletteDialog(props: {
759762
const activeThreadServerConfig = useServerConfigs().get(
760763
activeThread?.environmentId ?? ("" as EnvironmentId),
761764
);
765+
const { settleThread, unsettleThread } = useThreadActions();
766+
const canOperateActiveThread = useEnvironmentScope(
767+
activeThread?.environmentId ?? null,
768+
AuthOrchestrationOperateScope,
769+
);
762770
const activeThreadReferenceCopyTarget =
763771
referenceThreadRef === null || (pathname === "/pull-requests" && !openPanelPullRequestUrl)
764772
? null
@@ -1973,6 +1981,36 @@ function OpenCommandPaletteDialog(props: {
19731981
}
19741982
}
19751983

1984+
if (
1985+
activeThread !== null &&
1986+
canOperateActiveThread &&
1987+
activeThreadServerConfig?.environment.capabilities.threadSettlement === true
1988+
) {
1989+
const threadRef = scopeThreadRef(activeThread.environmentId, activeThread.id);
1990+
const settled = activeThread.settledOverride === "settled";
1991+
actionItems.push({
1992+
kind: "action",
1993+
value: settled ? "action:unsettle-thread" : "action:settle-thread",
1994+
searchTerms: settled
1995+
? ["unsettle", "un-settle", "reopen", "thread"]
1996+
: ["settle", "done", "finish", "close", "thread"],
1997+
title: settled ? "Un-settle thread" : "Settle thread",
1998+
icon: settled ? (
1999+
<Undo2Icon className={ITEM_ICON_CLASS} />
2000+
) : (
2001+
<CircleCheckIcon className={ITEM_ICON_CLASS} />
2002+
),
2003+
shortcutCommand: "thread.settle",
2004+
// Failures throw into executeItem's error toast.
2005+
run: async () => {
2006+
const result = await (settled ? unsettleThread(threadRef) : settleThread(threadRef));
2007+
if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
2008+
throw squashAtomCommandFailure(result);
2009+
}
2010+
},
2011+
});
2012+
}
2013+
19762014
if (activeThread !== null) {
19772015
const thread = activeThread;
19782016
actionItems.push({

0 commit comments

Comments
 (0)