Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import {
MAX_WEBHOOK_DELIVERY_AGE_MINUTES,
MAX_WEBHOOK_FILTERS,
resolveEnvironmentMachineKind,
scheduledTaskThreadMode,
} from "@t3tools/contracts";
import { useSelectWorkspaceDetail } from "../layout/workspace/useSelectWorkspaceDetail";
import type { MenuAction } from "@react-native-menu/menu";
import { DateTimePicker } from "@expo/ui/community/datetime-picker";
import {
Expand Down Expand Up @@ -1412,6 +1414,7 @@ function EnvironmentTasks({
label: "scheduled task delete",
reportFailure: false,
});
const selectDetail = useSelectWorkspaceDetail();
const failure = (title: string, result: AtomCommandResult<unknown, unknown>) => {
if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
Dialog.alert(title, String(squashAtomCommandFailure(result)));
Expand Down Expand Up @@ -1493,6 +1496,9 @@ function EnvironmentTasks({
<Menu
actions={[
{ id: "edit", title: "Edit" },
...(task.threadId !== null && scheduledTaskThreadMode(task) !== "new_thread"
? [{ id: "thread", title: "Open thread" }]
: []),
{
id: "toggle",
title: task.enabled ? "Pause" : "Resume",
Expand All @@ -1511,6 +1517,14 @@ function EnvironmentTasks({
const action = nativeEvent.event;
if (action === "edit") {
onEdit(task);
} else if (action === "thread" && task.threadId !== null) {
selectDetail({
name: "Thread",
params: {
environmentId: String(environmentId),
threadId: String(task.threadId),
},
});
} else if (action === "delete") {
Dialog.alert("Delete task?", task.title, [
{ text: "Cancel", style: "cancel" },
Expand Down
27 changes: 26 additions & 1 deletion apps/web/src/components/settings/ScheduledTasksSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
MIN_SCHEDULED_TASK_INTERVAL_MS,
ProviderInstanceId,
resolveEnvironmentMachineKind,
scheduledTaskThreadMode,
} from "@t3tools/contracts";
import {
isAtomCommandInterrupted,
Expand All @@ -60,7 +61,8 @@ import {
useEnvironmentHttpBaseUrl,
type EnvironmentPresentation,
} from "../../state/environments";
import { useProjects, useThreadShell } from "../../state/entities";
import { useProjects, useQuietThreadShell, useThreadShell } from "../../state/entities";
import { buildThreadRouteParams } from "../../threadRoutes";
import { scopeThreadRef } from "@t3tools/client-runtime/environment";
import { environmentAtomList, environmentIdsKey } from "../../state/environmentAtomList";
import { formatEnvironmentQueryError, useEnvironmentQuery } from "../../state/query";
Expand Down Expand Up @@ -787,6 +789,9 @@ function ScheduledTaskRow({
{task.lastRunStatus !== "never" ? (
<Badge variant={statusVariant(task.lastRunStatus)}>{task.lastRunStatus}</Badge>
) : null}
{task.threadId !== null && scheduledTaskThreadMode(task) !== "new_thread" ? (
<ScheduledTaskThreadLink environmentId={environmentId} threadId={task.threadId} />
) : null}
{task.lastRunError ? <span className="text-destructive">{task.lastRunError}</span> : null}
</div>
}
Expand Down Expand Up @@ -847,6 +852,26 @@ function ScheduledTaskRow({
);
}

function ScheduledTaskThreadLink({
environmentId,
threadId,
}: {
readonly environmentId: EnvironmentId;
readonly threadId: ThreadId;
}) {
const ref = scopeThreadRef(environmentId, threadId);
const title = useQuietThreadShell(ref)?.title.trim();
return (
<Link
to="/$environmentId/$threadId"
params={buildThreadRouteParams(ref)}
className="max-w-64 truncate underline underline-offset-2 hover:text-foreground"
>
{title || "Open thread"}
</Link>
);
}

function WebhookDeliveriesDialog({
environmentId,
task,
Expand Down
Loading