()
-
-export function emitSidebarAction(action: SidebarActionKey) {
- if (!handlerCounts.get(action)) {
- console.warn(`Sidebar action "${action}" was dispatched but no mounted page handles it`)
- }
- window.dispatchEvent(new CustomEvent(SIDEBAR_ACTION_EVENT, { detail: { action } }))
-}
-
-export function useSidebarAction(action: SidebarActionKey, handler: () => void) {
- useEffect(() => {
- handlerCounts.set(action, (handlerCounts.get(action) ?? 0) + 1)
- const listener = (event: Event) => {
- const detail = (event as CustomEvent<{ action?: SidebarActionKey }>).detail
- if (detail?.action === action) {
- handler()
- }
- }
- window.addEventListener(SIDEBAR_ACTION_EVENT, listener)
- return () => {
- window.removeEventListener(SIDEBAR_ACTION_EVENT, listener)
- handlerCounts.set(action, Math.max(0, (handlerCounts.get(action) ?? 1) - 1))
- }
- }, [action, handler])
-}
diff --git a/frontend/src/pages/AssistantRedirect.tsx b/frontend/src/pages/AssistantRedirect.tsx
index c7818be9..d4f05bfe 100644
--- a/frontend/src/pages/AssistantRedirect.tsx
+++ b/frontend/src/pages/AssistantRedirect.tsx
@@ -3,7 +3,6 @@ import { useQuery } from "@tanstack/react-query"
import { getRepo } from "@/api/repos"
import { useCreateSession } from "@/hooks/useOpenCode"
import { useDialogParam } from "@/hooks/useDialogParam"
-import { useSidebarAction } from "@/hooks/useSidebarAction"
import { useSSE } from "@/hooks/useSSE"
import { getSessionPath } from "@/lib/navigation"
import { Button } from "@/components/ui/button"
@@ -43,10 +42,6 @@ export function AssistantRedirect() {
await createSessionMutation.mutateAsync({ agent: undefined })
}
- useSidebarAction('new-session', () => {
- handleCreateSession()
- })
-
return (
diff --git a/frontend/src/pages/GlobalSchedules.tsx b/frontend/src/pages/GlobalSchedules.tsx
index 490be737..e6fdd966 100644
--- a/frontend/src/pages/GlobalSchedules.tsx
+++ b/frontend/src/pages/GlobalSchedules.tsx
@@ -16,7 +16,6 @@ import { CalendarClock, Loader2, Plus, ArrowLeft, SlidersHorizontal } from 'luci
import { useScheduleUrlState } from '@/hooks/useScheduleUrlState'
import type { ScheduleTab } from '@/hooks/useScheduleUrlState'
-import { useSidebarAction } from '@/hooks/useSidebarAction'
import { useDebouncedValue } from '@/hooks/useDebouncedValue'
import type { ScheduleJobWithRepo, ScheduleRunWithContext } from '@/api/schedules'
@@ -50,11 +49,6 @@ export function GlobalSchedules() {
const cancelRunMutation = useCancelRepoScheduleRun()
const cancelRunPending = cancelRunMutation.isPending
- useSidebarAction('new-schedule', () => {
- openNewJob()
- setSelectedRepoId(undefined)
- })
-
useEffect(() => {
runOffsetRef.current = runOffset
}, [runOffset])
@@ -547,7 +541,7 @@ export function GlobalSchedules() {
-
+
{!hasJobs ? (
@@ -596,7 +590,7 @@ export function GlobalSchedules() {
) : (
-
+
-
-
+
+
handleCreateSession()}
disabled={createSessionMutation.isPending}
size="sm"
+ className="hidden sm:inline-flex bg-primary hover:bg-primary-hover text-primary-foreground transition-all duration-200 hover:scale-105"
+ >
+
+ New Session
+
+