@agent-native/core 0.167.1 → 0.167.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/templates/analytics/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/corpus/templates/assets/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/corpus/templates/brain/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/corpus/templates/calendar/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/corpus/templates/chat/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/corpus/templates/clips/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/corpus/templates/clips/app/routes/download.tsx +78 -131
- package/corpus/templates/content/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/corpus/templates/crm/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/corpus/templates/design/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/corpus/templates/dispatch/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/corpus/templates/factory/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/corpus/templates/forms/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/corpus/templates/macros/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/corpus/templates/mail/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/corpus/templates/plan/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/corpus/templates/slides/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/corpus/templates/tasks/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/dist/chat-threads/store.d.ts +7 -0
- package/dist/chat-threads/store.js +15 -0
- package/dist/client/AgentPanel.d.ts +5 -1
- package/dist/client/AgentPanel.js +8 -8
- package/dist/client/AssistantChat.d.ts +3 -1
- package/dist/client/AssistantChat.js +22 -6
- package/dist/client/MultiTabAssistantChat.d.ts +3 -1
- package/dist/client/MultiTabAssistantChat.js +5 -4
- package/dist/client/agent-page/AgentJobsTab.js +39 -6
- package/dist/client/agent-page/AutomationScheduleDialog.d.ts +10 -1
- package/dist/client/agent-page/AutomationScheduleDialog.js +3 -2
- package/dist/client/agent-page/ScheduledTriggerNotice.d.ts +22 -0
- package/dist/client/agent-page/ScheduledTriggerNotice.js +84 -0
- package/dist/client/agent-page/scheduled-trigger-state.d.ts +28 -0
- package/dist/client/agent-page/scheduled-trigger-state.js +10 -0
- package/dist/client/agent-page/use-jobs.d.ts +7 -0
- package/dist/client/agent-page/use-jobs.js +14 -0
- package/dist/client/blocks/library/diagram.config.d.ts +4 -1
- package/dist/client/blocks/library/diagram.js +1 -1
- package/dist/client/chat/run-recovery.js +15 -7
- package/dist/client/use-chat-threads.d.ts +7 -0
- package/dist/client/use-chat-threads.js +144 -40
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/deploy/build.d.ts +5 -0
- package/dist/deploy/build.js +12 -1
- package/dist/framework-tools.js +1 -0
- package/dist/jobs/actions/get-scheduled-trigger-status.d.ts +13 -0
- package/dist/jobs/actions/get-scheduled-trigger-status.js +21 -0
- package/dist/localization/default-messages.d.ts +14 -0
- package/dist/localization/default-messages.js +14 -0
- package/dist/mcp/screen-memory-stdio.d.ts +7 -7
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/observability/routes.d.ts +3 -3
- package/dist/provider-api/actions/custom-provider-registration.d.ts +4 -4
- package/dist/provider-api/actions/provider-api.d.ts +13 -13
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/server/action-discovery.js +4 -0
- package/dist/server/agent-chat/recurring-jobs-runtime.d.ts +42 -1
- package/dist/server/agent-chat/recurring-jobs-runtime.js +102 -9
- package/dist/server/agent-chat-plugin.d.ts +3 -1
- package/dist/server/agent-chat-plugin.js +115 -24
- package/dist/server/attribution.d.ts +29 -0
- package/dist/server/attribution.js +68 -0
- package/dist/server/auth.js +58 -15
- package/dist/server/better-auth-instance.js +16 -4
- package/dist/server/identity-sso.js +14 -2
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/server/request-context.d.ts +8 -0
- package/dist/server/request-context.js +4 -0
- package/dist/templates/chat/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/dist/templates/default/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/dist/templates/headless/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/dist/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/dist/vite/client.js +10 -0
- package/docs/content/deployment.mdx +3 -1
- package/docs/content/recurring-jobs.mdx +6 -0
- package/package.json +2 -2
- package/src/templates/chat/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/src/templates/default/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/src/templates/headless/.agents/skills/agent-native-docs/SKILL.md +11 -0
- package/src/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +11 -0
|
@@ -436,7 +436,7 @@ function CodeAccessUnavailablePanel({ title, description, ctaLabel, ctaHref, sec
|
|
|
436
436
|
});
|
|
437
437
|
}, className: "inline-flex items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-foreground hover:bg-accent", children: secondaryCtaLabel })] })] }));
|
|
438
438
|
}
|
|
439
|
-
function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, emptyStateText, emptyStateAddon, suggestions, dynamicSuggestions, showHeader = true, onCollapse, isFullscreen, onToggleFullscreen, onFullViewRequest, onSnapTo75Percent, isWideDrawer, onExitWideDrawer, devAppUrl, storageKey, restoreActiveThread = true, scope, showScopeBadge, browserTabId, threadUrlSync, chatNotice, showTabBar = true, showPageNewChatButton = false, allowSettingsMode = true, chatOnly = false, agentPageHref, codeAccess, ...assistantChatProps }) {
|
|
439
|
+
function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, emptyStateText, emptyStateAddon, suggestions, dynamicSuggestions, showHeader = true, onCollapse, isFullscreen, onToggleFullscreen, onFullViewRequest, onSnapTo75Percent, isWideDrawer, onExitWideDrawer, devAppUrl, storageKey, restoreActiveThread = true, scope, isolateHistoryByScope = false, showScopeBadge, browserTabId, threadUrlSync, chatNotice, showTabBar = true, showPageNewChatButton = false, allowSettingsMode = true, chatOnly = false, agentPageHref, codeAccess, ...assistantChatProps }) {
|
|
440
440
|
const t = useT();
|
|
441
441
|
const navigate = useNavigate();
|
|
442
442
|
const location = useLocation();
|
|
@@ -838,7 +838,7 @@ function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, empty
|
|
|
838
838
|
const isActive = tab.id === activeTabId ||
|
|
839
839
|
(tab.id === focusParentId &&
|
|
840
840
|
activeTab?.parentThreadId === tab.id);
|
|
841
|
-
return (_jsxs("div", { role: "button", tabIndex: 0, ref: isActive ? activeTabRefCb : undefined, onClick: () => setActiveTabId(tab.id), onKeyDown: activateOnKeyDown(() => setActiveTabId(tab.id)), className: cn("agent-tab relative flex shrink-0 items-center gap-1 rounded-md px-2.5 py-1.5 text-[11px] font-medium cursor-pointer max-w-[150px]", isActive
|
|
841
|
+
return (_jsxs("div", { role: "button", tabIndex: 0, ref: isActive ? activeTabRefCb : undefined, onClick: () => setActiveTabId(tab.id), onKeyDown: activateOnKeyDown(() => setActiveTabId(tab.id)), className: cn("agent-tab relative flex shrink-0 items-center gap-1 rounded-md px-2.5 py-1.5 text-[11px] font-medium cursor-pointer min-w-[56px] max-w-[150px]", isActive
|
|
842
842
|
? "bg-accent text-foreground"
|
|
843
843
|
: "text-muted-foreground hover:bg-accent hover:text-foreground"), children: [_jsx("span", { className: "truncate pe-1", children: tab.label }), tab.status === "running" && (_jsx("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full bg-muted-foreground/50 animate-pulse" })), _jsx("button", { type: "button", "aria-label": t("agentPanel.closeTab"), onClick: (e) => {
|
|
844
844
|
e.stopPropagation();
|
|
@@ -881,7 +881,7 @@ function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, empty
|
|
|
881
881
|
const isActive = tab.id === activeTabId ||
|
|
882
882
|
(tab.id === focusParentId &&
|
|
883
883
|
activeTab?.parentThreadId === tab.id);
|
|
884
|
-
return (_jsxs("div", { role: "button", tabIndex: 0, ref: isActive ? activeTabRefCb : undefined, onClick: () => setActiveTabId(tab.id), onKeyDown: activateOnKeyDown(() => setActiveTabId(tab.id)), className: cn("agent-tab relative flex shrink-0 items-center gap-1 rounded-md px-2.5 py-1.5 text-[11px] font-medium cursor-pointer max-w-[150px]", isActive
|
|
884
|
+
return (_jsxs("div", { role: "button", tabIndex: 0, ref: isActive ? activeTabRefCb : undefined, onClick: () => setActiveTabId(tab.id), onKeyDown: activateOnKeyDown(() => setActiveTabId(tab.id)), className: cn("agent-tab relative flex shrink-0 items-center gap-1 rounded-md px-2.5 py-1.5 text-[11px] font-medium cursor-pointer min-w-[56px] max-w-[150px]", isActive
|
|
885
885
|
? "bg-accent text-foreground"
|
|
886
886
|
: "text-muted-foreground hover:bg-accent hover:text-foreground"), children: [_jsx("span", { className: "truncate pe-1", children: tab.label }), tab.status === "running" && (_jsx("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full bg-muted-foreground/50 animate-pulse" })), _jsx("button", { type: "button", "aria-label": t("agentPanel.closeTab"), onClick: (e) => {
|
|
887
887
|
e.stopPropagation();
|
|
@@ -899,7 +899,7 @@ function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, empty
|
|
|
899
899
|
})
|
|
900
900
|
: cliTabs.map((id, i) => (_jsxs("div", { role: "button", tabIndex: 0, ref: id === activeCliTab
|
|
901
901
|
? activeTabRefCb
|
|
902
|
-
: undefined, onClick: () => setActiveCliTab(id), onKeyDown: activateOnKeyDown(() => setActiveCliTab(id)), className: cn("agent-tab relative flex shrink-0 items-center gap-1 rounded-md px-2.5 py-1.5 text-[11px] font-medium cursor-pointer", id === activeCliTab
|
|
902
|
+
: undefined, onClick: () => setActiveCliTab(id), onKeyDown: activateOnKeyDown(() => setActiveCliTab(id)), className: cn("agent-tab relative flex shrink-0 items-center gap-1 rounded-md px-2.5 py-1.5 text-[11px] font-medium cursor-pointer min-w-[56px]", id === activeCliTab
|
|
903
903
|
? "bg-accent text-foreground"
|
|
904
904
|
: "text-muted-foreground hover:bg-accent hover:text-foreground"), children: [_jsxs("span", { children: ["Terminal ", i + 1] }), _jsx("button", { type: "button", "aria-label": t("agentPanel.closeTab"), onClick: (e) => {
|
|
905
905
|
e.stopPropagation();
|
|
@@ -917,7 +917,7 @@ function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, empty
|
|
|
917
917
|
? "bg-accent text-foreground"
|
|
918
918
|
: "text-muted-foreground hover:bg-accent hover:text-foreground"), children: "Main" }), childTabs.map((tab) => (_jsxs("div", { role: "button", tabIndex: 0, ref: tab.id === activeTabId
|
|
919
919
|
? activeTabRefCb
|
|
920
|
-
: undefined, onClick: () => setActiveTabId(tab.id), onKeyDown: activateOnKeyDown(() => setActiveTabId(tab.id)), className: cn("agent-tab relative flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium cursor-pointer max-w-[140px]", tab.id === activeTabId
|
|
920
|
+
: undefined, onClick: () => setActiveTabId(tab.id), onKeyDown: activateOnKeyDown(() => setActiveTabId(tab.id)), className: cn("agent-tab relative flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium cursor-pointer min-w-[48px] max-w-[140px]", tab.id === activeTabId
|
|
921
921
|
? "bg-accent text-foreground"
|
|
922
922
|
: "text-muted-foreground hover:bg-accent hover:text-foreground"), children: [_jsx("span", { className: "truncate pe-1", children: tab.subAgentName || tab.label }), tab.status === "running" && (_jsx("span", { className: "h-1 w-1 shrink-0 rounded-full bg-muted-foreground/50 animate-pulse" })), _jsx("button", { type: "button", "aria-label": t("agentPanel.closeTab"), onClick: (e) => {
|
|
923
923
|
e.stopPropagation();
|
|
@@ -981,7 +981,7 @@ function AgentPanelInner({ defaultMode = "chat", className, style, apiUrl, empty
|
|
|
981
981
|
`margin-left:auto;margin-right:auto;width:100%;}`,
|
|
982
982
|
} }), SHOW_ONBOARDING && mounted && (_jsx(Suspense, { fallback: null, children: _jsx(OnboardingPanel, {}) })), showFirstRunOnboarding && mounted && !insideAgentSidebar && (_jsx(Suspense, { fallback: null, children: _jsx(FirstRunOnboarding, {}) })), _jsx("div", { className: cn("flex flex-col min-h-0", mode === "chat" ? "flex-1" : "shrink-0"), children: mounted && (_jsx(Suspense, { fallback: _jsx(ChatLoadingSkeleton, { renderHeader: showHeader ? renderChatHeader : undefined, centerComposerWhenEmpty: assistantChatProps.centerComposerWhenEmpty, composerSlot: assistantChatProps.composerSlot, composerAreaClassName: assistantChatProps.composerAreaClassName, composerLayoutVariant: assistantChatProps.composerLayoutVariant }), children: _jsx(MultiTabAssistantChatLazy, { ...assistantChatProps, agentChatSurface: effectiveAgentChatSurface, apiUrl: apiUrl, showHeader: false, renderHeader: showHeader ? renderChatHeader : undefined, showTabBar: showTabBar, renderOverlay: showPageNewChatButton && !showHeader
|
|
983
983
|
? renderPageChatOverlay
|
|
984
|
-
: undefined, contentHidden: mode !== "chat", emptyStateText: emptyStateText, emptyStateAddon: emptyStateAddon, suggestions: suggestions, dynamicSuggestions: dynamicSuggestions, onSwitchToCli: () => switchMode("cli"), execMode: execMode, onExecModeChange: switchExecMode, storageKey: storageKey, restoreActiveThread: restoreActiveThread, scope: scope, showScopeBadge: showScopeBadge, browserTabId: browserTabId, threadUrlSync: threadUrlSync }) })) }), canUseCodeTools
|
|
984
|
+
: undefined, contentHidden: mode !== "chat", emptyStateText: emptyStateText, emptyStateAddon: emptyStateAddon, suggestions: suggestions, dynamicSuggestions: dynamicSuggestions, onSwitchToCli: () => switchMode("cli"), execMode: execMode, onExecModeChange: switchExecMode, storageKey: storageKey, restoreActiveThread: restoreActiveThread, scope: scope, isolateHistoryByScope: isolateHistoryByScope, showScopeBadge: showScopeBadge, browserTabId: browserTabId, threadUrlSync: threadUrlSync }) })) }), canUseCodeTools
|
|
985
985
|
? mode === "cli" &&
|
|
986
986
|
cliTabs.map((id) => (_jsx("div", { className: "min-h-0 relative flex-1", style: {
|
|
987
987
|
display: id === activeCliTab ? undefined : "none",
|
|
@@ -1418,7 +1418,7 @@ export function AgentChatSurface({ mode = "panel", className, defaultMode = "cha
|
|
|
1418
1418
|
* Wraps app content with a toggleable agent sidebar.
|
|
1419
1419
|
* Use AgentToggleButton in your header to open/close it.
|
|
1420
1420
|
*/
|
|
1421
|
-
export function AgentSidebar({ children, emptyStateText = "How can I help you?", suggestions, dynamicSuggestions, composerToolbarSlot, composerSlot, onComposerTextChange, imageModelMenu, availableAgents, availableModels, modelListLoading, selectedAgent, onAgentChange, onConnectLocalRuntime, runtime, adapterReloadKey, threadFooterSlot, defaultSidebarWidth, sidebarWidth, position = "right", defaultOpen = false, animateMobile = true, animateDesktop = true, chatViewTransition = false, chatViewTransitionHandoff = false, storageKey, openStorageKey, apiUrl, agentChatSurface, desktopIdentityUnauthenticated, desktopIdentityAuthenticated, showTabBar = true, suppressInlineOpenApp, composerPlaceholder, openOnChatRunning = false, onFullscreenRequest, scope, showScopeBadge, browserTabId, threadUrlSync, agentPageHref, suppressFirstRunOnboarding = false, }) {
|
|
1421
|
+
export function AgentSidebar({ children, emptyStateText = "How can I help you?", suggestions, dynamicSuggestions, composerToolbarSlot, composerSlot, onComposerTextChange, imageModelMenu, availableAgents, availableModels, modelListLoading, selectedAgent, onAgentChange, onConnectLocalRuntime, runtime, adapterReloadKey, threadFooterSlot, defaultSidebarWidth, sidebarWidth, position = "right", defaultOpen = false, animateMobile = true, animateDesktop = true, chatViewTransition = false, chatViewTransitionHandoff = false, storageKey, openStorageKey, apiUrl, agentChatSurface, desktopIdentityUnauthenticated, desktopIdentityAuthenticated, showTabBar = true, suppressInlineOpenApp, composerPlaceholder, openOnChatRunning = false, onFullscreenRequest, scope, isolateHistoryByScope = false, showScopeBadge, browserTabId, threadUrlSync, agentPageHref, suppressFirstRunOnboarding = false, }) {
|
|
1422
1422
|
const staticHostedHarnessEnabled = isHostedHarnessConfigured(injectedAgentNativeConfig().harness);
|
|
1423
1423
|
const hostedHarnessQuery = useActionQuery("get-hosted-harness-config", undefined, { enabled: staticHostedHarnessEnabled });
|
|
1424
1424
|
const hostedHarnessStatus = hostedHarnessQuery.data;
|
|
@@ -2059,7 +2059,7 @@ export function AgentSidebar({ children, emptyStateText = "How can I help you?",
|
|
|
2059
2059
|
? "desktop"
|
|
2060
2060
|
: undefined, "data-agent-sidebar-layout": panelLayout, "data-agent-sidebar-position": effectivePosition, "data-agent-native-hosted-harness-ui": hostedHarnessUi ? "desktop" : undefined, "data-agent-sidebar-state": panelOpen ? "open" : "closed", "data-agent-sidebar-per-app-chat": isPerAppChatSidebar ? "true" : undefined, "data-agent-sidebar-resizing": isResizing ? "true" : undefined, "data-agent-sidebar-chat-handoff": chatViewTransitionHandoff ? "true" : undefined, style: chatViewTransition
|
|
2061
2061
|
? getAgentChatViewTransitionStyle(panelStyle)
|
|
2062
|
-
: panelStyle, inert: sidebarAnimationEnabled && !panelOpen ? true : undefined, "aria-hidden": sidebarAnimationEnabled && !panelOpen ? true : undefined, children: _jsx("div", { className: "agent-sidebar-panel-inner flex min-h-0 flex-1 flex-col", children: _jsx(AgentPanel, { emptyStateText: emptyStateText, suggestions: suggestions, dynamicSuggestions: dynamicSuggestions, composerToolbarSlot: composerToolbarSlot, composerSlot: composerSlot, onComposerTextChange: onComposerTextChange, imageModelMenu: imageModelMenu, availableAgents: effectiveAvailableAgents, availableModels: availableModels, modelListLoading: modelListLoading, selectedAgent: effectiveSelectedAgent, onAgentChange: effectiveOnAgentChange, hostedHarness: hostedHarnessEnabled, onConnectLocalRuntime: onConnectLocalRuntime, runtime: runtime, adapterReloadKey: adapterReloadKey, threadFooterSlot: threadFooterSlot, apiUrl: apiUrl, agentChatSurface: agentChatSurface, desktopIdentityUnauthenticated: desktopIdentityUnauthenticated, desktopIdentityAuthenticated: desktopIdentityAuthenticated, showTabBar: effectiveShowTabBar, suppressInlineOpenApp: suppressInlineOpenApp, composerPlaceholder: composerPlaceholder, missingApiKeySetupLayout: "sidebar", onCollapse: () => setOpenPersisted(false), onSnapTo75Percent: isMobile ? undefined : snapTo75Percent, isWideDrawer: isMobile ? false : isWideDrawer, onExitWideDrawer: isMobile ? undefined : exitWideDrawer, onFullViewRequest: onFullscreenRequest, storageKey: storageKey, scope: scope, showScopeBadge: showScopeBadge, browserTabId: browserTabId, threadUrlSync: threadUrlSync, agentPageHref: agentPageHref, allowSettingsMode: false, chatOnly: true }) }) }), showResizeHandle && isLeft && (_jsx(ResizeHandle, { position: effectivePosition, onDrag: handleDrag, onResizeStart: handleResizeStart, onResizeEnd: handleResizeEnd }))] })) : null;
|
|
2062
|
+
: panelStyle, inert: sidebarAnimationEnabled && !panelOpen ? true : undefined, "aria-hidden": sidebarAnimationEnabled && !panelOpen ? true : undefined, children: _jsx("div", { className: "agent-sidebar-panel-inner flex min-h-0 flex-1 flex-col", children: _jsx(AgentPanel, { emptyStateText: emptyStateText, suggestions: suggestions, dynamicSuggestions: dynamicSuggestions, composerToolbarSlot: composerToolbarSlot, composerSlot: composerSlot, onComposerTextChange: onComposerTextChange, imageModelMenu: imageModelMenu, availableAgents: effectiveAvailableAgents, availableModels: availableModels, modelListLoading: modelListLoading, selectedAgent: effectiveSelectedAgent, onAgentChange: effectiveOnAgentChange, hostedHarness: hostedHarnessEnabled, onConnectLocalRuntime: onConnectLocalRuntime, runtime: runtime, adapterReloadKey: adapterReloadKey, threadFooterSlot: threadFooterSlot, apiUrl: apiUrl, agentChatSurface: agentChatSurface, desktopIdentityUnauthenticated: desktopIdentityUnauthenticated, desktopIdentityAuthenticated: desktopIdentityAuthenticated, showTabBar: effectiveShowTabBar, suppressInlineOpenApp: suppressInlineOpenApp, composerPlaceholder: composerPlaceholder, missingApiKeySetupLayout: "sidebar", onCollapse: () => setOpenPersisted(false), onSnapTo75Percent: isMobile ? undefined : snapTo75Percent, isWideDrawer: isMobile ? false : isWideDrawer, onExitWideDrawer: isMobile ? undefined : exitWideDrawer, onFullViewRequest: onFullscreenRequest, storageKey: storageKey, scope: scope, isolateHistoryByScope: isolateHistoryByScope, showScopeBadge: showScopeBadge, browserTabId: browserTabId, threadUrlSync: threadUrlSync, agentPageHref: agentPageHref, allowSettingsMode: false, chatOnly: true }) }) }), showResizeHandle && isLeft && (_jsx(ResizeHandle, { position: effectivePosition, onDrag: handleDrag, onResizeStart: handleResizeStart, onResizeEnd: handleResizeEnd }))] })) : null;
|
|
2063
2063
|
const drawerPlaceholder = wideDrawerEnabled && !presentationMode && panelOpen ? (_jsx("div", { "aria-hidden": "true", className: "agent-sidebar-drawer-placeholder shrink-0", "data-agent-sidebar-placeholder": "true", style: { width: drawerPlaceholderWidth + 1 } })) : null;
|
|
2064
2064
|
return (_jsx(AgentSidebarOnboardingContext.Provider, { value: true, children: _jsxs(RealtimeVoiceModeProvider, { browserTabId: browserTabId, children: [showFirstRunOnboarding && (_jsx(Suspense, { fallback: null, children: _jsx(FirstRunOnboarding, {}) })), _jsxs("div", { className: "agent-sidebar-shell flex min-w-0 flex-1 h-screen overflow-hidden", "data-agent-sidebar-position": effectivePosition, "data-agent-native-hosted-harness-ui": hostedHarnessUi ? "desktop" : undefined, "data-agent-native-hosted-chat": isPerAppChatHosted ? "true" : undefined, "data-agent-sidebar-resizing": isResizing ? "true" : undefined, children: [isMobile &&
|
|
2065
2065
|
!isPerAppChatHosted &&
|
|
@@ -11,7 +11,7 @@ import { type AgentChatRuntime } from "./chat/runtime.js";
|
|
|
11
11
|
import { type AgentComposerLayoutVariant, type ComposerSubmitIntent, type Reference } from "./composer/index.js";
|
|
12
12
|
import { type AgentDynamicSuggestionsOption } from "./dynamic-suggestions.js";
|
|
13
13
|
import { type ContentPart } from "./sse-event-processor.js";
|
|
14
|
-
import type
|
|
14
|
+
import { type ChatThreadScope, type ChatThreadSnapshot } from "./use-chat-threads.js";
|
|
15
15
|
export { AssistantMessageListErrorBoundary, AssistantUiStaleIndexErrorBoundary, assistantUiRecoverableRenderErrorKind, isAssistantUiRecoverableRenderError, isAssistantUiStaleIndexError, } from "./assistant-ui-recovery.js";
|
|
16
16
|
export { displayableUserMessageText } from "./chat/message-components.js";
|
|
17
17
|
export declare function shouldSuppressUnauthenticatedDesktopThreadRestore(surface: AgentChatSurfaceKind, status: number, desktopIdentityUnauthenticated?: boolean): boolean;
|
|
@@ -269,6 +269,8 @@ export interface AssistantChatProps {
|
|
|
269
269
|
threadId?: string;
|
|
270
270
|
/** Resource scope to include with chat requests for server-side context. */
|
|
271
271
|
contextScope?: ChatThreadScope | null;
|
|
272
|
+
/** Restrict server-side thread restores to the supplied app scope. */
|
|
273
|
+
isolateHistoryByScope?: boolean;
|
|
272
274
|
/** Namespace used to hide ambient composer context from other host surfaces. */
|
|
273
275
|
contextNamespace?: string;
|
|
274
276
|
/** Whether this chat owns the active visible composer context snapshot. */
|
|
@@ -39,6 +39,7 @@ import { McpConnectionSuggestion } from "./resources/McpConnectionSuggestion.js"
|
|
|
39
39
|
import { claimRunStream, createRunStreamToken, ownsRunStream, releaseRunStream, } from "./run-stream-ownership.js";
|
|
40
40
|
import { AgentAutoContinueSignal, readSSEStreamRaw, settleInterruptedToolCalls, } from "./sse-event-processor.js";
|
|
41
41
|
import { useAgentEngineConfigured } from "./use-agent-engine-configured.js";
|
|
42
|
+
import { appendChatThreadScopeParams, } from "./use-chat-threads.js";
|
|
42
43
|
import { useDevMode } from "./use-dev-mode.js";
|
|
43
44
|
import { useRunStuckDetection } from "./use-run-stuck-detection.js";
|
|
44
45
|
import { cn } from "./utils.js";
|
|
@@ -1386,7 +1387,7 @@ function approvalResolutionIdentity(approvalKey, toolCallId,
|
|
|
1386
1387
|
askId) {
|
|
1387
1388
|
return `${toolCallId ?? ""}\u0000${approvalKey}\u0000${askId ?? ""}`;
|
|
1388
1389
|
}
|
|
1389
|
-
const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateText, suggestions, dynamicSuggestions, threadFooterSlot, emptyStateAddon, showHeader = true, onSwitchToCli, className, apiUrl, tabId, browserTabId, threadId, contextScope, contextNamespace, isActiveComposer = true, onMessageCountChange, onSaveThread, onGenerateTitle, composerSlot, onComposerTextChange, composerAreaClassName, composerPlaceholder, missingApiKeySetupLayout = "default", composerLayoutVariant = "default", centerComposerWhenEmpty = false, emptyStateDisplay = "default", composerToolbarSlot, composerExtraActionButton, showModelSelector = true, composerDisabled = false, composerDisabledPlaceholder, isNewThread, isThreadStateLoading, onSlashCommand, execMode, onExecModeChange, approvalActions, planModeDisabled, planModeDisabledReason, selectedModel, defaultModel, selectedEngine, selectedEffort, availableModels, modelListLoading, onModelChange, onEffortChange, availableAgents, selectedAgent, hostedHarness, onAgentChange, imageModelMenu, onForkChat, onConnectProvider, onConnectLocalRuntime, plusMenuMode = "full", providerStatusChecksEnabled = true, loadHistoryRepository, historyReloadKey, externalStreaming = false, agentChatSurface = "app", desktopIdentityUnauthenticated = false, desktopIdentityAuthenticated = false, suppressInlineOpenApp = false, }, ref) {
|
|
1390
|
+
const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateText, suggestions, dynamicSuggestions, threadFooterSlot, emptyStateAddon, showHeader = true, onSwitchToCli, className, apiUrl, tabId, browserTabId, threadId, contextScope, isolateHistoryByScope = false, contextNamespace, isActiveComposer = true, onMessageCountChange, onSaveThread, onGenerateTitle, composerSlot, onComposerTextChange, composerAreaClassName, composerPlaceholder, missingApiKeySetupLayout = "default", composerLayoutVariant = "default", centerComposerWhenEmpty = false, emptyStateDisplay = "default", composerToolbarSlot, composerExtraActionButton, showModelSelector = true, composerDisabled = false, composerDisabledPlaceholder, isNewThread, isThreadStateLoading, onSlashCommand, execMode, onExecModeChange, approvalActions, planModeDisabled, planModeDisabledReason, selectedModel, defaultModel, selectedEngine, selectedEffort, availableModels, modelListLoading, onModelChange, onEffortChange, availableAgents, selectedAgent, hostedHarness, onAgentChange, imageModelMenu, onForkChat, onConnectProvider, onConnectLocalRuntime, plusMenuMode = "full", providerStatusChecksEnabled = true, loadHistoryRepository, historyReloadKey, externalStreaming = false, agentChatSurface = "app", desktopIdentityUnauthenticated = false, desktopIdentityAuthenticated = false, suppressInlineOpenApp = false, }, ref) {
|
|
1390
1391
|
const t = useT();
|
|
1391
1392
|
const thread = useThread();
|
|
1392
1393
|
const threadRuntime = useThreadRuntime();
|
|
@@ -1418,6 +1419,14 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1418
1419
|
enabled: messages.length === 0,
|
|
1419
1420
|
});
|
|
1420
1421
|
const messageListResetKey = useMemo(() => assistantUiMessageListStructureKey(messages), [messages]);
|
|
1422
|
+
const threadScopeQuery = useMemo(() => {
|
|
1423
|
+
if (!isolateHistoryByScope || !contextScope)
|
|
1424
|
+
return "";
|
|
1425
|
+
const params = new URLSearchParams();
|
|
1426
|
+
appendChatThreadScopeParams(params, contextScope);
|
|
1427
|
+
const query = params.toString();
|
|
1428
|
+
return query ? `?${query}` : "";
|
|
1429
|
+
}, [contextScope?.id, contextScope?.type, isolateHistoryByScope]);
|
|
1421
1430
|
// Chat-wide drag-and-drop: users expect to drop a file anywhere on the agent
|
|
1422
1431
|
// sidebar (thread, header, composer) and have it attach — same as ChatGPT,
|
|
1423
1432
|
// Claude.ai, Linear, Slack, etc. Tiptap's own `handleDrop` only fires inside
|
|
@@ -1989,7 +1998,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
1989
1998
|
? setTimeout(() => ownAbort.abort(), getPollAbortMs(2000))
|
|
1990
1999
|
: null;
|
|
1991
2000
|
try {
|
|
1992
|
-
const refreshRes = await fetch(`${apiUrl}/threads/${encodeURIComponent(threadId)}`, { signal: signal ?? ownAbort?.signal });
|
|
2001
|
+
const refreshRes = await fetch(`${apiUrl}/threads/${encodeURIComponent(threadId)}${threadScopeQuery}`, { signal: signal ?? ownAbort?.signal });
|
|
1993
2002
|
if (!refreshRes.ok)
|
|
1994
2003
|
return null;
|
|
1995
2004
|
const refreshData = await refreshRes.json();
|
|
@@ -2006,7 +2015,13 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
2006
2015
|
if (ownAbortTimer)
|
|
2007
2016
|
clearTimeout(ownAbortTimer);
|
|
2008
2017
|
}
|
|
2009
|
-
}, [
|
|
2018
|
+
}, [
|
|
2019
|
+
apiUrl,
|
|
2020
|
+
importThreadData,
|
|
2021
|
+
loadHistoryRepository,
|
|
2022
|
+
threadId,
|
|
2023
|
+
threadScopeQuery,
|
|
2024
|
+
]);
|
|
2010
2025
|
const exportCleanThreadRepo = useCallback(() => ensureMessageMetadata(normalizeThreadRepository(threadRuntime.export())), [threadRuntime]);
|
|
2011
2026
|
const exportPersistableThreadRepo = useCallback(() => withLastAssistantRunDuration(exportCleanThreadRepo(), showRunningInUI ? null : lastChatRunDurationMs), [exportCleanThreadRepo, lastChatRunDurationMs, showRunningInUI]);
|
|
2012
2027
|
useEffect(() => {
|
|
@@ -2698,7 +2713,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
2698
2713
|
(async () => {
|
|
2699
2714
|
let canReconnect = false;
|
|
2700
2715
|
try {
|
|
2701
|
-
const res = await fetch(`${apiUrl}/threads/${encodeURIComponent(threadId)}`);
|
|
2716
|
+
const res = await fetch(`${apiUrl}/threads/${encodeURIComponent(threadId)}${threadScopeQuery}`);
|
|
2702
2717
|
if (!res.ok) {
|
|
2703
2718
|
if (!cancelled) {
|
|
2704
2719
|
setThreadRestoreError(shouldSuppressUnauthenticatedDesktopThreadRestore(agentChatSurface, res.status, desktopIdentityUnauthenticated)
|
|
@@ -2811,6 +2826,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
2811
2826
|
isThreadStateLoading,
|
|
2812
2827
|
desktopIdentityUnauthenticated,
|
|
2813
2828
|
restoreAttempt,
|
|
2829
|
+
threadScopeQuery,
|
|
2814
2830
|
]);
|
|
2815
2831
|
useEffect(() => {
|
|
2816
2832
|
if (!loadHistoryRepository ||
|
|
@@ -2992,7 +3008,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
2992
3008
|
const timer = setTimeout(() => {
|
|
2993
3009
|
(async () => {
|
|
2994
3010
|
try {
|
|
2995
|
-
const res = await fetch(`${apiUrl}/threads/${encodeURIComponent(threadId)}/queued`, {
|
|
3011
|
+
const res = await fetch(`${apiUrl}/threads/${encodeURIComponent(threadId)}/queued${threadScopeQuery}`, {
|
|
2996
3012
|
method: "POST",
|
|
2997
3013
|
headers: { "Content-Type": "application/json" },
|
|
2998
3014
|
body: JSON.stringify({ queuedMessages }),
|
|
@@ -3010,7 +3026,7 @@ const AssistantChatInner = forwardRef(function AssistantChatInner({ emptyStateTe
|
|
|
3010
3026
|
})();
|
|
3011
3027
|
}, 300);
|
|
3012
3028
|
return () => clearTimeout(timer);
|
|
3013
|
-
}, [queuedMessages, threadId, apiUrl]);
|
|
3029
|
+
}, [queuedMessages, threadId, apiUrl, threadScopeQuery]);
|
|
3014
3030
|
// Nudge the shared hook to re-check after a Builder connect.
|
|
3015
3031
|
const handleBuilderConnected = useCallback(() => {
|
|
3016
3032
|
focusComposerAfterConnectRef.current = true;
|
|
@@ -64,9 +64,11 @@ export type MultiTabAssistantChatProps = Omit<AssistantChatProps, "tabId" | "thr
|
|
|
64
64
|
threadUrlSync?: boolean | ChatThreadUrlSyncOptions;
|
|
65
65
|
/** Ambient resource context to show as a composer chip. */
|
|
66
66
|
scope?: ChatThreadScope | null;
|
|
67
|
+
/** Keep app-owned chat history isolated to the supplied scope. */
|
|
68
|
+
isolateHistoryByScope?: boolean;
|
|
67
69
|
/** @deprecated Scope context is now rendered in the composer. */
|
|
68
70
|
showScopeBadge?: boolean;
|
|
69
71
|
/** Cadence for hydrating agent-team sub-agent tab status. Default: 3000. */
|
|
70
72
|
agentTeamPollMs?: number;
|
|
71
73
|
};
|
|
72
|
-
export declare function MultiTabAssistantChat({ showTabBar, renderHeader, renderOverlay, contentHidden, apiUrl, storageKey, restoreActiveThread, browserTabId, threadUrlSync, scope, agentTeamPollMs, ...props }: MultiTabAssistantChatProps): React.JSX.Element;
|
|
74
|
+
export declare function MultiTabAssistantChat({ showTabBar, renderHeader, renderOverlay, contentHidden, apiUrl, storageKey, restoreActiveThread, browserTabId, threadUrlSync, scope, isolateHistoryByScope, agentTeamPollMs, ...props }: MultiTabAssistantChatProps): React.JSX.Element;
|
|
@@ -402,7 +402,7 @@ function runToAgentTeamTabInfo(run) {
|
|
|
402
402
|
status: run.status ?? "unknown",
|
|
403
403
|
};
|
|
404
404
|
}
|
|
405
|
-
export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderOverlay, contentHidden = false, apiUrl = agentNativePath("/_agent-native/agent-chat"), storageKey, restoreActiveThread = true, browserTabId, threadUrlSync = false, scope = null, agentTeamPollMs = DEFAULT_AGENT_TEAM_POLL_MS, ...props }) {
|
|
405
|
+
export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderOverlay, contentHidden = false, apiUrl = agentNativePath("/_agent-native/agent-chat"), storageKey, restoreActiveThread = true, browserTabId, threadUrlSync = false, scope = null, isolateHistoryByScope = false, agentTeamPollMs = DEFAULT_AGENT_TEAM_POLL_MS, ...props }) {
|
|
406
406
|
const translate = useT();
|
|
407
407
|
const contextNamespace = scope
|
|
408
408
|
? scope.contextKey?.trim() || `scope:${scope.type}:${scope.id}`
|
|
@@ -520,6 +520,7 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
520
520
|
routeThreadId: threadUrlSyncEnabled
|
|
521
521
|
? urlThreadId
|
|
522
522
|
: (activeDeepLinkedThreadId ?? undefined),
|
|
523
|
+
isolateHistoryByScope,
|
|
523
524
|
});
|
|
524
525
|
const switchThread = useCallback((threadId, options = {}) => {
|
|
525
526
|
switchThreadState(threadId);
|
|
@@ -1911,7 +1912,7 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
1911
1912
|
const isActive = tab.id === activeThreadId ||
|
|
1912
1913
|
(tab.id === focusParentId &&
|
|
1913
1914
|
activeTab?.parentThreadId === tab.id);
|
|
1914
|
-
return (_jsxs("div", { ref: isActive ? activeTabRefCb : undefined, className: cn("agent-tab relative flex items-center rounded-md text-[11px] font-medium shrink-0 max-w-[130px]", isActive
|
|
1915
|
+
return (_jsxs("div", { ref: isActive ? activeTabRefCb : undefined, className: cn("agent-tab relative flex items-center rounded-md text-[11px] font-medium shrink-0 min-w-[56px] max-w-[130px]", isActive
|
|
1915
1916
|
? "bg-accent text-foreground ring-1 ring-inset ring-border/60 shadow-sm"
|
|
1916
1917
|
: "text-muted-foreground hover:text-foreground hover:bg-accent/50"), children: [_jsxs("button", { type: "button", onClick: () => switchThread(tab.id), className: "flex items-center gap-1 px-2.5 py-1.5 min-w-0 flex-1 text-start", children: [_jsx("span", { className: "truncate pe-1", children: tab.label }), tab.status === "running" && (_jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-muted-foreground/50 shrink-0 animate-pulse" }))] }), _jsx("button", { type: "button", "aria-label": translate("agentChat.tabs.closeTab"), onClick: (e) => {
|
|
1917
1918
|
e.stopPropagation();
|
|
@@ -1931,7 +1932,7 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
1931
1932
|
? "bg-accent text-foreground"
|
|
1932
1933
|
: "text-muted-foreground hover:bg-accent hover:text-foreground"), children: translate("agentChat.tabs.main") }), childTabs.map((tab) => (_jsxs("div", { ref: tab.id === activeThreadId
|
|
1933
1934
|
? activeTabRefCb
|
|
1934
|
-
: undefined, className: cn("agent-tab relative flex shrink-0 items-center rounded-md text-[10px] font-medium max-w-[130px]", tab.id === activeThreadId
|
|
1935
|
+
: undefined, className: cn("agent-tab relative flex shrink-0 items-center rounded-md text-[10px] font-medium min-w-[48px] max-w-[130px]", tab.id === activeThreadId
|
|
1935
1936
|
? "bg-accent text-foreground"
|
|
1936
1937
|
: "text-muted-foreground hover:bg-accent hover:text-foreground"), children: [_jsxs("button", { type: "button", onClick: () => switchThread(tab.id), className: "flex items-center gap-1 px-2 py-1 min-w-0 flex-1 text-start", children: [_jsx("span", { className: "truncate pe-1", children: tab.subAgentName || tab.label }), tab.status === "running" && (_jsx("span", { className: "w-1 h-1 rounded-full bg-muted-foreground/50 shrink-0 animate-pulse" }))] }), _jsx("button", { type: "button", "aria-label": translate("agentChat.tabs.closeTab"), onClick: (e) => {
|
|
1937
1938
|
e.stopPropagation();
|
|
@@ -1969,7 +1970,7 @@ export function MultiTabAssistantChat({ showTabBar = true, renderHeader, renderO
|
|
|
1969
1970
|
else {
|
|
1970
1971
|
chatRefs.current.delete(tabId);
|
|
1971
1972
|
}
|
|
1972
|
-
}, threadId: tabId, tabId: tabId, browserTabId: browserTabId, contextNamespace: contextNamespace, isActiveComposer: tabId === activeThreadId, apiUrl: apiUrl, isNewThread: newThreadIds.current.has(tabId) || isNewThread(tabId), isThreadStateLoading: isLoading, onMessageCountChange: (count) => setMessageCounts((prev) => prev[tabId] === count
|
|
1973
|
+
}, threadId: tabId, tabId: tabId, browserTabId: browserTabId, contextScope: scope, contextNamespace: contextNamespace, isolateHistoryByScope: isolateHistoryByScope, isActiveComposer: tabId === activeThreadId, apiUrl: apiUrl, isNewThread: newThreadIds.current.has(tabId) || isNewThread(tabId), isThreadStateLoading: isLoading, onMessageCountChange: (count) => setMessageCounts((prev) => prev[tabId] === count
|
|
1973
1974
|
? prev
|
|
1974
1975
|
: { ...prev, [tabId]: count }), onSaveThread: handleSaveThread, onGenerateTitle: handleGenerateTitle, onSlashCommand: handleSlashCommand, selectedModel: modelSelection?.model, selectedEngine: modelSelection?.engine, selectedEffort: modelSelection?.effort ?? DEFAULT_REASONING_EFFORT, composerSlot: props.composerSlot, defaultModel: defaultModel, availableModels: availableModels, modelListLoading: modelListLoading, onModelChange: handleModelChange, onEffortChange: handleEffortChange, onForkChat: () => handleForkChat(tabId),
|
|
1975
1976
|
// Sub-agent tabs are read-only: sending a new message from the
|
|
@@ -11,7 +11,9 @@ import { AgentEmptyState } from "./AgentEmptyState.js";
|
|
|
11
11
|
import { AgentTabFrame } from "./AgentTabFrame.js";
|
|
12
12
|
import { AutomationDetailsDialog, } from "./AutomationDetailsDialog.js";
|
|
13
13
|
import { AutomationScheduleDialog } from "./AutomationScheduleDialog.js";
|
|
14
|
-
import {
|
|
14
|
+
import { scheduleFiringFor, } from "./scheduled-trigger-state.js";
|
|
15
|
+
import { ScheduledTriggerNotice } from "./ScheduledTriggerNotice.js";
|
|
16
|
+
import { useAutomations, useManageAutomation, useManageRecurringJob, useRunAutomationNow, useRecurringJobs, useScheduledTriggerState, } from "./use-jobs.js";
|
|
15
17
|
function listRecurringJobs(jobs) {
|
|
16
18
|
return jobs.map((resource) => ({
|
|
17
19
|
kind: "recurring",
|
|
@@ -37,7 +39,33 @@ function describeTrigger(entry, t) {
|
|
|
37
39
|
entry.resource.schedule ||
|
|
38
40
|
t("jobs.scheduledTrigger", { defaultValue: "Scheduled" }));
|
|
39
41
|
}
|
|
40
|
-
|
|
42
|
+
/**
|
|
43
|
+
* `nextRun` is computed from the cron expression, not from anything that
|
|
44
|
+
* promises to run it, so it must never be presented with more confidence than
|
|
45
|
+
* the scheduler check earned. Three answers, three phrasings: a known-dead
|
|
46
|
+
* scheduler replaces the date, an unverified one qualifies it, and a confirmed
|
|
47
|
+
* one shows it plainly.
|
|
48
|
+
*/
|
|
49
|
+
function nextRunValue(entry, t, formatDateTime, scheduleFiring, unset) {
|
|
50
|
+
const formatted = formatDateTime(entry.resource.nextRun);
|
|
51
|
+
if (entry.triggerType !== "schedule" || scheduleFiring === "fires") {
|
|
52
|
+
return formatted ?? unset;
|
|
53
|
+
}
|
|
54
|
+
if (scheduleFiring === "never") {
|
|
55
|
+
return t("jobs.nextRunNeverScheduler", {
|
|
56
|
+
defaultValue: "Never — no scheduler in this deploy",
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return formatted
|
|
60
|
+
? t("jobs.nextRunSchedulerUnknown", {
|
|
61
|
+
defaultValue: "{{date}} — unconfirmed, the scheduler check failed",
|
|
62
|
+
date: formatted,
|
|
63
|
+
})
|
|
64
|
+
: t("jobs.nextRunSchedulerUnknownNoDate", {
|
|
65
|
+
defaultValue: "Unknown — the scheduler check failed",
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function detailsFields(entry, t, formatDateTime, scheduleFiring) {
|
|
41
69
|
const resource = entry.resource;
|
|
42
70
|
const unset = t("jobs.notSet", { defaultValue: "—" });
|
|
43
71
|
const fields = [
|
|
@@ -66,7 +94,7 @@ function detailsFields(entry, t, formatDateTime) {
|
|
|
66
94
|
}
|
|
67
95
|
fields.push({
|
|
68
96
|
label: t("jobs.nextRun", { defaultValue: "Next run" }),
|
|
69
|
-
value:
|
|
97
|
+
value: nextRunValue(entry, t, formatDateTime, scheduleFiring, unset),
|
|
70
98
|
}, {
|
|
71
99
|
label: t("jobs.lastRun", { defaultValue: "Last run" }),
|
|
72
100
|
value: formatDateTime(resource.lastRun) ??
|
|
@@ -104,6 +132,11 @@ export function AgentJobsTab({ canManageOrg = false, hideHeader = false, }) {
|
|
|
104
132
|
const personalAutomationsQuery = useAutomations("user");
|
|
105
133
|
const organizationJobsQuery = useRecurringJobs("org");
|
|
106
134
|
const organizationAutomationsQuery = useAutomations("org");
|
|
135
|
+
const scheduledTriggerState = useScheduledTriggerState();
|
|
136
|
+
// Three states, not `!== false`: that expression also swallowed a FAILED
|
|
137
|
+
// status query, which then licensed a confident "Next run" forever. See
|
|
138
|
+
// `scheduleFiringFor` for which way each state leans and why.
|
|
139
|
+
const scheduleFiring = scheduleFiringFor(scheduledTriggerState);
|
|
107
140
|
const personalJobsMutation = useManageRecurringJob("user");
|
|
108
141
|
const personalAutomationsMutation = useManageAutomation("user");
|
|
109
142
|
const organizationJobsMutation = useManageRecurringJob("org");
|
|
@@ -240,7 +273,7 @@ export function AgentJobsTab({ canManageOrg = false, hideHeader = false, }) {
|
|
|
240
273
|
defaultValue: "Create an automation",
|
|
241
274
|
}), label: t("jobs.newAutomation", {
|
|
242
275
|
defaultValue: "New automation",
|
|
243
|
-
}) }), children: [_jsxs("div", { className: "space-y-7", children: [hideHeader ? (_jsx("div", { className: "flex justify-end", children: _jsx(AgentAskPopover, { context: automationCreationContext(), prompt: t("jobs.automationPrompt", {
|
|
276
|
+
}) }), children: [_jsxs("div", { className: "space-y-7", children: [_jsx(ScheduledTriggerNotice, { state: scheduledTriggerState }), hideHeader ? (_jsx("div", { className: "flex justify-end", children: _jsx(AgentAskPopover, { context: automationCreationContext(), prompt: t("jobs.automationPrompt", {
|
|
244
277
|
defaultValue: "Create an automation that does this: ",
|
|
245
278
|
}), title: t("jobs.automationsCreateTitle", {
|
|
246
279
|
defaultValue: "Create an automation",
|
|
@@ -296,9 +329,9 @@ export function AgentJobsTab({ canManageOrg = false, hideHeader = false, }) {
|
|
|
296
329
|
name: runTarget.resource.name,
|
|
297
330
|
scope: runTarget.resource.scope,
|
|
298
331
|
}, { onSuccess: () => setRunTarget(null) });
|
|
299
|
-
}, children: [runAutomationMutation.isPending ? (_jsx(IconLoader2, { className: "size-4 animate-spin" })) : (_jsx(IconPlayerPlay, { className: "size-4" })), t("jobs.runNow", { defaultValue: "Run now" })] })] })] }) }), detailsTarget ? (_jsx(AutomationDetailsDialog, { open: true, name: detailsTarget.resource.name, scope: detailsTarget.resource.scope === "organization" ? "org" : "user", triggerSummary: describeTrigger(detailsTarget, t), fields: detailsFields(detailsTarget, t, formatDateTime), condition: detailsTarget.kind === "automation"
|
|
332
|
+
}, children: [runAutomationMutation.isPending ? (_jsx(IconLoader2, { className: "size-4 animate-spin" })) : (_jsx(IconPlayerPlay, { className: "size-4" })), t("jobs.runNow", { defaultValue: "Run now" })] })] })] }) }), detailsTarget ? (_jsx(AutomationDetailsDialog, { open: true, name: detailsTarget.resource.name, scope: detailsTarget.resource.scope === "organization" ? "org" : "user", triggerSummary: describeTrigger(detailsTarget, t), fields: detailsFields(detailsTarget, t, formatDateTime, scheduleFiring), condition: detailsTarget.kind === "automation"
|
|
300
333
|
? detailsTarget.resource.condition
|
|
301
334
|
: null, instructions: detailsTarget.kind === "automation"
|
|
302
335
|
? detailsTarget.resource.body
|
|
303
|
-
: detailsTarget.resource.instructions, mcpTools: detailsTarget.resource.mcpTools ?? [], lastError: detailsTarget.resource.lastError, formatTimestamp: (value) => formatDateTime(new Date(value).toISOString()) ?? String(value), onClose: () => setDetailsTarget(null) })) : null, scheduleTarget ? (_jsx(AutomationScheduleDialog, { open: true, name: scheduleTarget.resource.name, schedule: scheduleTarget.resource.schedule ?? "", timezone: scheduleTarget.resource.timezone ?? null, saving: mutationPending, error: mutationError ? mutationError.message : null, onCancel: () => setScheduleTarget(null), onSave: (next) => mutateEntry(scheduleTarget, "update", next, () => setScheduleTarget(null)) })) : null] }));
|
|
336
|
+
: detailsTarget.resource.instructions, mcpTools: detailsTarget.resource.mcpTools ?? [], lastError: detailsTarget.resource.lastError, formatTimestamp: (value) => formatDateTime(new Date(value).toISOString()) ?? String(value), onClose: () => setDetailsTarget(null) })) : null, scheduleTarget ? (_jsx(AutomationScheduleDialog, { open: true, name: scheduleTarget.resource.name, schedule: scheduleTarget.resource.schedule ?? "", timezone: scheduleTarget.resource.timezone ?? null, saving: mutationPending, error: mutationError ? mutationError.message : null, scheduledTriggerState: scheduledTriggerState, onCancel: () => setScheduleTarget(null), onSave: (next) => mutateEntry(scheduleTarget, "update", next, () => setScheduleTarget(null)) })) : null] }));
|
|
304
337
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ScheduledTriggerState } from "./scheduled-trigger-state.js";
|
|
1
2
|
export interface AutomationScheduleDialogProps {
|
|
2
3
|
open: boolean;
|
|
3
4
|
name: string;
|
|
@@ -5,10 +6,18 @@ export interface AutomationScheduleDialogProps {
|
|
|
5
6
|
timezone: string | null;
|
|
6
7
|
saving: boolean;
|
|
7
8
|
error?: string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Passed in rather than queried here so this dialog stays presentational, the
|
|
11
|
+
* way the rest of its props already are. Carries the whole query state so a
|
|
12
|
+
* failed check is distinguishable from a healthy one — this dialog is where
|
|
13
|
+
* someone is actively picking a cadence, so an unverified scheduler is exactly
|
|
14
|
+
* what they need told.
|
|
15
|
+
*/
|
|
16
|
+
scheduledTriggerState: ScheduledTriggerState;
|
|
8
17
|
onCancel: () => void;
|
|
9
18
|
onSave: (next: {
|
|
10
19
|
schedule: string;
|
|
11
20
|
timezone: string;
|
|
12
21
|
}) => void;
|
|
13
22
|
}
|
|
14
|
-
export declare function AutomationScheduleDialog({ open, name, schedule, timezone, saving, error, onCancel, onSave, }: AutomationScheduleDialogProps): import("react").JSX.Element;
|
|
23
|
+
export declare function AutomationScheduleDialog({ open, name, schedule, timezone, saving, error, scheduledTriggerState, onCancel, onSave, }: AutomationScheduleDialogProps): import("react").JSX.Element;
|
|
@@ -5,6 +5,7 @@ import { IconLoader2 } from "@tabler/icons-react";
|
|
|
5
5
|
import { useEffect, useState } from "react";
|
|
6
6
|
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "../components/ui/dialog.js";
|
|
7
7
|
import { useT } from "../i18n.js";
|
|
8
|
+
import { ScheduledTriggerNotice } from "./ScheduledTriggerNotice.js";
|
|
8
9
|
import { TimezoneSelect, browserTimezone } from "./TimezoneSelect.js";
|
|
9
10
|
const PRESETS = [
|
|
10
11
|
{ label: "Every hour", cron: "0 * * * *" },
|
|
@@ -16,7 +17,7 @@ const CRON_FIELD_COUNT = 5;
|
|
|
16
17
|
function looksLikeCron(value) {
|
|
17
18
|
return value.trim().split(/\s+/).length === CRON_FIELD_COUNT;
|
|
18
19
|
}
|
|
19
|
-
export function AutomationScheduleDialog({ open, name, schedule, timezone, saving, error, onCancel, onSave, }) {
|
|
20
|
+
export function AutomationScheduleDialog({ open, name, schedule, timezone, saving, error, scheduledTriggerState, onCancel, onSave, }) {
|
|
20
21
|
const t = useT();
|
|
21
22
|
const [value, setValue] = useState(schedule);
|
|
22
23
|
const [zone, setZone] = useState(timezone || browserTimezone());
|
|
@@ -37,7 +38,7 @@ export function AutomationScheduleDialog({ open, name, schedule, timezone, savin
|
|
|
37
38
|
name: name.replace(/-/g, " "),
|
|
38
39
|
}) }), _jsx(DialogDescription, { children: t("jobs.editScheduleDescription", {
|
|
39
40
|
defaultValue: "The clock time below is read in the timezone you pick, so 8:00 means 8:00 there.",
|
|
40
|
-
}) })] }), _jsxs("div", { className: "space-y-3", children: [_jsxs("div", { children: [_jsx("label", { className: "text-xs font-medium text-foreground", htmlFor: "automation-schedule", children: t("jobs.cronExpression", { defaultValue: "Cron expression" }) }), _jsx(Input, { id: "automation-schedule", className: "mt-1 font-mono text-sm", value: value, spellCheck: false, autoComplete: "off", disabled: saving, onChange: (event) => setValue(event.target.value) }), _jsx("p", { className: "mt-1 text-[11px] text-muted-foreground", children: t("jobs.cronFormatHint", {
|
|
41
|
+
}) })] }), _jsxs("div", { className: "space-y-3", children: [_jsx(ScheduledTriggerNotice, { state: scheduledTriggerState, variant: "inline" }), _jsxs("div", { children: [_jsx("label", { className: "text-xs font-medium text-foreground", htmlFor: "automation-schedule", children: t("jobs.cronExpression", { defaultValue: "Cron expression" }) }), _jsx(Input, { id: "automation-schedule", className: "mt-1 font-mono text-sm", value: value, spellCheck: false, autoComplete: "off", disabled: saving, onChange: (event) => setValue(event.target.value) }), _jsx("p", { className: "mt-1 text-[11px] text-muted-foreground", children: t("jobs.cronFormatHint", {
|
|
41
42
|
defaultValue: "minute hour day-of-month month day-of-week",
|
|
42
43
|
}) })] }), _jsx("div", { className: "flex flex-wrap gap-1.5", children: PRESETS.map((preset) => (_jsx(Button, { type: "button", variant: "outline", size: "sm", className: "h-7 cursor-pointer text-[11px]", disabled: saving, onClick: () => setValue(preset.cron), children: preset.label }, preset.cron))) }), _jsxs("div", { children: [_jsx("label", { className: "text-xs font-medium text-foreground", htmlFor: "automation-timezone", children: t("jobs.timezone", { defaultValue: "Timezone" }) }), _jsx("div", { className: "mt-1", children: _jsx(TimezoneSelect, { id: "automation-timezone", value: zone, disabled: saving, onChange: setZone, suggested: [browserTimezone()] }) })] }), trimmed && !valid ? (_jsx("p", { className: "text-xs text-destructive", children: t("jobs.cronFieldCount", {
|
|
43
44
|
defaultValue: "A cron expression needs exactly 5 fields.",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ScheduledTriggerState } from "./scheduled-trigger-state.js";
|
|
2
|
+
export interface ScheduledTriggerNoticeProps {
|
|
3
|
+
state: ScheduledTriggerState;
|
|
4
|
+
/** `banner` heads the page; `inline` sits inside the schedule dialog. */
|
|
5
|
+
variant?: "banner" | "inline";
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Warns that schedule-triggered automations will not fire in this deploy.
|
|
9
|
+
*
|
|
10
|
+
* Worth a persistent surface rather than a one-time toast: whether a schedule
|
|
11
|
+
* fires is decided by the BUILD, while automations are created at runtime, so
|
|
12
|
+
* the mismatch is invisible at the moment it bites. Without this, a scheduled
|
|
13
|
+
* automation reports "Enabled" with a plausible "Next run" and silently never
|
|
14
|
+
* runs. Shown on the Automations page and again inside the schedule editor,
|
|
15
|
+
* which is the one place a user is actively choosing a cadence.
|
|
16
|
+
*
|
|
17
|
+
* Takes the whole query state, not just a resolved status, because a status
|
|
18
|
+
* check that FAILED has to look different from one that came back healthy: the
|
|
19
|
+
* failure is why the next-run dates alongside it are unverified, and silently
|
|
20
|
+
* rendering nothing would present them as confirmed.
|
|
21
|
+
*/
|
|
22
|
+
export declare function ScheduledTriggerNotice({ state, variant, }: ScheduledTriggerNoticeProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { IconAlertCircle, IconAlertTriangle, IconChevronRight, } from "@tabler/icons-react";
|
|
3
|
+
import { useT } from "../i18n.js";
|
|
4
|
+
/**
|
|
5
|
+
* Warns that schedule-triggered automations will not fire in this deploy.
|
|
6
|
+
*
|
|
7
|
+
* Worth a persistent surface rather than a one-time toast: whether a schedule
|
|
8
|
+
* fires is decided by the BUILD, while automations are created at runtime, so
|
|
9
|
+
* the mismatch is invisible at the moment it bites. Without this, a scheduled
|
|
10
|
+
* automation reports "Enabled" with a plausible "Next run" and silently never
|
|
11
|
+
* runs. Shown on the Automations page and again inside the schedule editor,
|
|
12
|
+
* which is the one place a user is actively choosing a cadence.
|
|
13
|
+
*
|
|
14
|
+
* Takes the whole query state, not just a resolved status, because a status
|
|
15
|
+
* check that FAILED has to look different from one that came back healthy: the
|
|
16
|
+
* failure is why the next-run dates alongside it are unverified, and silently
|
|
17
|
+
* rendering nothing would present them as confirmed.
|
|
18
|
+
*/
|
|
19
|
+
export function ScheduledTriggerNotice({ state, variant = "banner", }) {
|
|
20
|
+
const t = useT();
|
|
21
|
+
// Still in flight: resolves in milliseconds, so say nothing rather than
|
|
22
|
+
// flash a caveat at every reader on a perfectly healthy deploy.
|
|
23
|
+
if (state.kind === "loading")
|
|
24
|
+
return null;
|
|
25
|
+
const shell = variant === "banner"
|
|
26
|
+
? "flex items-start gap-2.5 rounded-xl border px-4 py-3"
|
|
27
|
+
: "flex items-start gap-2 rounded-lg border px-3 py-2";
|
|
28
|
+
// Muted rather than amber: "we could not check" is a weaker claim than "this
|
|
29
|
+
// will not run", and dressing it identically would teach readers to discount
|
|
30
|
+
// the one that means something.
|
|
31
|
+
if (state.kind === "unknown") {
|
|
32
|
+
return (_jsxs("div", { role: "status", "data-testid": "scheduled-trigger-notice", "data-reason": "check-failed", className: `${shell} border-border/70 bg-muted/50`, children: [_jsx(IconAlertCircle, { className: "mt-px size-4 shrink-0 text-muted-foreground" }), _jsxs("div", { className: "min-w-0", children: [_jsx("p", { className: "text-xs font-medium text-foreground", children: t("jobs.scheduleUnknownTitle", {
|
|
33
|
+
defaultValue: "Couldn't check whether schedules run here",
|
|
34
|
+
}) }), _jsx("p", { className: "mt-0.5 text-[11px] leading-4 text-muted-foreground", children: t("jobs.scheduleUnknownDetail", {
|
|
35
|
+
defaultValue: "The scheduler status check failed, so the next run times below " +
|
|
36
|
+
"are unconfirmed. Reload to check again.",
|
|
37
|
+
}) })] })] }));
|
|
38
|
+
}
|
|
39
|
+
const status = state.status;
|
|
40
|
+
if (status.available)
|
|
41
|
+
return null;
|
|
42
|
+
const headline = status.reason === "local-development"
|
|
43
|
+
? t("jobs.scheduleUnavailableLocalTitle", {
|
|
44
|
+
defaultValue: "Schedules don't run in local development",
|
|
45
|
+
})
|
|
46
|
+
: t("jobs.scheduleUnavailableTitle", {
|
|
47
|
+
defaultValue: "Schedules won't run in this deploy",
|
|
48
|
+
});
|
|
49
|
+
const detail = status.reason === "disabled-by-env"
|
|
50
|
+
? t("jobs.scheduleUnavailableDisabled", {
|
|
51
|
+
defaultValue: "This app was built with recurring jobs turned off, so no scheduled " +
|
|
52
|
+
"automation will fire. Event-triggered automations and Run now still work.",
|
|
53
|
+
})
|
|
54
|
+
: status.reason === "no-platform-scheduler"
|
|
55
|
+
? t("jobs.scheduleUnavailableNoScheduler", {
|
|
56
|
+
defaultValue: "This hosting target has no durable scheduler, so no scheduled automation will fire. Event-triggered automations and Run now still work.",
|
|
57
|
+
})
|
|
58
|
+
: t("jobs.scheduleUnavailableLocal", {
|
|
59
|
+
defaultValue: "Schedules stay off on a dev machine unless you opt in. " +
|
|
60
|
+
"Event-triggered automations and Run now still work.",
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* Recovery steps, collapsed by default: the notice has to say what is wrong
|
|
64
|
+
* before it says how to change it, and the how is longer than the what. Null
|
|
65
|
+
* where nothing is actually toggleable — `no-platform-scheduler` means the
|
|
66
|
+
* host has no scheduler to enable, so an empty disclosure would promise a fix
|
|
67
|
+
* that does not exist.
|
|
68
|
+
*/
|
|
69
|
+
const fix = status.reason === "disabled-by-env"
|
|
70
|
+
? t("jobs.scheduleUnavailableDisabledFix", {
|
|
71
|
+
defaultValue: "To enable recurring jobs, set AGENT_NATIVE_DISABLE_RECURRING_JOBS=false in the build environment.",
|
|
72
|
+
})
|
|
73
|
+
: status.reason === "local-development"
|
|
74
|
+
? t("jobs.scheduleUnavailableLocalFix", {
|
|
75
|
+
defaultValue: "Set AGENT_NATIVE_ENABLE_LOCAL_RECURRING_JOBS=true to run " +
|
|
76
|
+
"schedules on this machine.",
|
|
77
|
+
})
|
|
78
|
+
: null;
|
|
79
|
+
return (_jsxs("div", { role: "status", "data-testid": "scheduled-trigger-notice", "data-reason": status.reason, className: `${shell} border-amber-500/40 bg-amber-500/10`, children: [_jsx(IconAlertTriangle, { className: "mt-px size-4 shrink-0 text-amber-600 dark:text-amber-400" }), _jsxs("div", { className: "min-w-0", children: [_jsx("p", { className: "text-xs font-medium text-amber-700 dark:text-amber-300", children: headline }), _jsx("p", { className: "mt-0.5 text-[11px] leading-4 text-amber-700/90 dark:text-amber-300/90", children: detail }), fix ? (_jsxs("details", { className: "group mt-1", children: [_jsxs("summary", { className: "-ml-1.5 inline-flex w-fit cursor-pointer select-none list-none items-center gap-1 rounded-md px-1.5 py-1 text-[11px] font-medium text-amber-700 transition-colors hover:bg-amber-500/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/40 dark:text-amber-300 dark:hover:bg-amber-400/15 [&::-webkit-details-marker]:hidden", children: [_jsx(IconChevronRight, { className: "size-3 shrink-0 transition-transform duration-150 group-open:rotate-90" }), _jsx("span", { className: "group-open:hidden", children: t("jobs.scheduleUnavailableFixLabel", {
|
|
80
|
+
defaultValue: "Show more",
|
|
81
|
+
}) }), _jsx("span", { className: "hidden group-open:inline", children: t("jobs.scheduleUnavailableFixLabelOpen", {
|
|
82
|
+
defaultValue: "Show less",
|
|
83
|
+
}) })] }), _jsx("p", { className: "mt-1 whitespace-pre-line text-[11px] leading-4 text-amber-700/90 dark:text-amber-300/90", children: fix })] })) : null] })] }));
|
|
84
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ScheduledTriggerStatus } from "../../jobs/actions/get-scheduled-trigger-status.js";
|
|
2
|
+
export type { ScheduledTriggerStatus };
|
|
3
|
+
/**
|
|
4
|
+
* Three-state view of the scheduler status query.
|
|
5
|
+
*
|
|
6
|
+
* `unknown` exists so a FAILED check cannot pass for a healthy one. The status
|
|
7
|
+
* action can 404 on an older deploy, 403 behind an auth boundary, or fail
|
|
8
|
+
* discovery — none of which say anything about whether schedules fire, and all
|
|
9
|
+
* of which read as "fine" under a plain `data?.available !== false`. `loading`
|
|
10
|
+
* stays separate because it resolves on its own in milliseconds; an error does
|
|
11
|
+
* not.
|
|
12
|
+
*
|
|
13
|
+
* Deliberately kept in its own module, free of the query hook: the pure
|
|
14
|
+
* state→consequence mapping below is what the UI branches on, and it stays real
|
|
15
|
+
* in tests that mock the data layer.
|
|
16
|
+
*/
|
|
17
|
+
export type ScheduledTriggerState = {
|
|
18
|
+
kind: "loading";
|
|
19
|
+
} | {
|
|
20
|
+
kind: "unknown";
|
|
21
|
+
error: Error | null;
|
|
22
|
+
} | {
|
|
23
|
+
kind: "resolved";
|
|
24
|
+
status: ScheduledTriggerStatus;
|
|
25
|
+
};
|
|
26
|
+
/** Whether a schedule-triggered automation will fire, as far as the UI knows. */
|
|
27
|
+
export type ScheduleFiring = "fires" | "never" | "unknown";
|
|
28
|
+
export declare function scheduleFiringFor(state: ScheduledTriggerState): ScheduleFiring;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function scheduleFiringFor(state) {
|
|
2
|
+
if (state.kind === "resolved") {
|
|
3
|
+
return state.status.available ? "fires" : "never";
|
|
4
|
+
}
|
|
5
|
+
// Loading leans optimistic on purpose: accusing a working deploy of being
|
|
6
|
+
// broken mid-flight is worse than showing the warning a beat late. An errored
|
|
7
|
+
// check gets no such benefit — it never resolves, so the optimism would be
|
|
8
|
+
// permanent and would license a confident "Next run" forever.
|
|
9
|
+
return state.kind === "unknown" ? "unknown" : "fires";
|
|
10
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ScheduledTriggerState, ScheduledTriggerStatus } from "./scheduled-trigger-state.js";
|
|
1
2
|
export type JobsScope = "user" | "org";
|
|
2
3
|
export interface RecurringJob {
|
|
3
4
|
id: string;
|
|
@@ -75,6 +76,12 @@ export interface AutomationRun {
|
|
|
75
76
|
finishedAt: number | null;
|
|
76
77
|
error: string | null;
|
|
77
78
|
}
|
|
79
|
+
export type { ScheduledTriggerState, ScheduledTriggerStatus };
|
|
80
|
+
/**
|
|
81
|
+
* Deploy-scoped and fixed for the life of the process, so it is cached far
|
|
82
|
+
* longer than the automation lists.
|
|
83
|
+
*/
|
|
84
|
+
export declare function useScheduledTriggerState(): ScheduledTriggerState;
|
|
78
85
|
export declare function useRecurringJobs(scope: JobsScope): import("@tanstack/react-query").UseQueryResult<NoInfer<RecurringJob[]>, Error>;
|
|
79
86
|
export declare function useAutomations(scope: JobsScope): import("@tanstack/react-query").UseQueryResult<NoInfer<Automation[]>, Error>;
|
|
80
87
|
export declare function useManageRecurringJob(scope: JobsScope): import("@tanstack/react-query").UseMutationResult<{
|
|
@@ -6,6 +6,20 @@ function recurringParams(scope) {
|
|
|
6
6
|
function automationParams(scope) {
|
|
7
7
|
return { scope: scope === "org" ? "organization" : "personal" };
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Deploy-scoped and fixed for the life of the process, so it is cached far
|
|
11
|
+
* longer than the automation lists.
|
|
12
|
+
*/
|
|
13
|
+
export function useScheduledTriggerState() {
|
|
14
|
+
const query = useActionQuery("get-scheduled-trigger-status", {}, { staleTime: 5 * 60_000 });
|
|
15
|
+
// Data first: a cached answer with a failing background refetch is still an
|
|
16
|
+
// answer, and downgrading it to `unknown` would flicker the warning off.
|
|
17
|
+
if (query.data)
|
|
18
|
+
return { kind: "resolved", status: query.data };
|
|
19
|
+
if (query.error)
|
|
20
|
+
return { kind: "unknown", error: query.error };
|
|
21
|
+
return { kind: "loading" };
|
|
22
|
+
}
|
|
9
23
|
export function useRecurringJobs(scope) {
|
|
10
24
|
return useActionQuery("list-recurring-jobs", recurringParams(scope), { staleTime: 5_000 });
|
|
11
25
|
}
|