feat(server): run a project action when a worktree thread settles (#16290)
Co-authored-by: spoukyii <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
20 files changed
+409
-56
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
isAtomCommandInterrupted,
|
||||
squashAtomCommandFailure,
|
||||
} from "@t3tools/client-runtime/state/runtime";
|
||||
import { projectScriptMenuLabel } from "@t3tools/shared/projectScripts";
|
||||
import { ChevronDownIcon, DownloadIcon, PlusIcon, SettingsIcon, WrenchIcon } from "lucide-react";
|
||||
import React, { useCallback, useMemo, useState } from "react";
|
||||
|
||||
@@ -147,6 +148,7 @@ export default function ProjectScriptsControl({
|
||||
icon: fileScript.icon ?? "play",
|
||||
runOnWorktreeCreate: fileScript.runOnWorktreeCreate ?? false,
|
||||
waitForSetup: fileScript.runOnWorktreeCreate === true && fileScript.async === false,
|
||||
runOnSettle: fileScript.runOnSettle ?? false,
|
||||
...(readEnvironmentScope(environmentId, AuthSettingsWriteScope) ? { keybinding: null } : {}),
|
||||
previewUrl: fileScript.previewUrl ?? null,
|
||||
autoOpenPreview: fileScript.previewUrl ? (fileScript.autoOpenPreview ?? false) : false,
|
||||
@@ -166,7 +168,7 @@ export default function ProjectScriptsControl({
|
||||
|
||||
const importMenuItems = importableScripts.length > 0 && (
|
||||
<>
|
||||
{primaryScript && <MenuSeparator />}
|
||||
{scripts.length > 0 && <MenuSeparator />}
|
||||
<MenuGroup>
|
||||
<MenuGroupLabel>From t3.json</MenuGroupLabel>
|
||||
{importableScripts.map((fileScript) => (
|
||||
@@ -202,9 +204,7 @@ export default function ProjectScriptsControl({
|
||||
onClick={() => onRunScript?.(script)}
|
||||
>
|
||||
<ScriptIcon icon={script.icon} className="size-4" />
|
||||
<MenuItemLabel>
|
||||
{script.runOnWorktreeCreate ? `${script.name} (setup)` : script.name}
|
||||
</MenuItemLabel>
|
||||
<MenuItemLabel>{projectScriptMenuLabel(script)}</MenuItemLabel>
|
||||
<span className="relative ms-auto flex h-6 min-w-6 items-center justify-end">
|
||||
{shortcutLabel &&
|
||||
(presentation === "menu" ? (
|
||||
@@ -266,7 +266,7 @@ export default function ProjectScriptsControl({
|
||||
</MenuShortcut>
|
||||
</MenuItem>
|
||||
)}
|
||||
{primaryScript || importableScripts.length > 0 ? (
|
||||
{scripts.length > 0 || importableScripts.length > 0 ? (
|
||||
<MenuSub
|
||||
open={actionsMenuOpen.scripts}
|
||||
onOpenChange={(open) =>
|
||||
@@ -369,7 +369,9 @@ export default function ProjectScriptsControl({
|
||||
</MenuPopup>
|
||||
</Menu>
|
||||
</ActionGroup>
|
||||
) : importableScripts.length > 0 ? (
|
||||
) : scripts.length > 0 || importableScripts.length > 0 ? (
|
||||
// No one-click action (only a settle action, or only t3.json imports),
|
||||
// so the saved actions stay reachable through this menu.
|
||||
isPanel ? (
|
||||
<div
|
||||
role="group"
|
||||
@@ -408,11 +410,7 @@ export default function ProjectScriptsControl({
|
||||
<ChevronDownIcon className={THREAD_DETAILS_PANEL_CHEVRON_CLASS} />
|
||||
</MenuTrigger>
|
||||
<MenuPopup align="end" anchor={panelAnchorRef} className="w-(--anchor-width)">
|
||||
{importMenuItems}
|
||||
<MenuItem onClick={openAddDialog}>
|
||||
<PlusIcon className="size-4" />
|
||||
Add action
|
||||
</MenuItem>
|
||||
{scriptItems}
|
||||
</MenuPopup>
|
||||
</Menu>
|
||||
</div>
|
||||
@@ -433,13 +431,7 @@ export default function ProjectScriptsControl({
|
||||
</span>
|
||||
<ChevronDownIcon className="size-3.5" />
|
||||
</MenuTrigger>
|
||||
<MenuPopup align="end">
|
||||
{importMenuItems}
|
||||
<MenuItem onClick={openAddDialog}>
|
||||
<PlusIcon className="size-4" />
|
||||
Add action
|
||||
</MenuItem>
|
||||
</MenuPopup>
|
||||
<MenuPopup align="end">{scriptItems}</MenuPopup>
|
||||
</Menu>
|
||||
)
|
||||
) : (
|
||||
|
||||
Reference in new issue
Block a user