@@ -37,6 +37,12 @@ export interface InboxCloudTaskCopy {
3737 signedOut : string ;
3838 /** Error description when no model can be resolved. */
3939 missingModel : string ;
40+ /**
41+ * Title for the success toast shown when `redirectOnSuccess` is false and the
42+ * runner stays in place instead of navigating to the task. Defaults to
43+ * "Task started".
44+ */
45+ successTitle ?: string ;
4046}
4147
4248/** Context the variant uses to assemble the TaskCreationInput. */
@@ -62,6 +68,12 @@ export interface UseInboxCloudTaskRunnerOptions {
6268 buildInput : ( ctx : InboxCloudTaskInputContext ) => TaskCreationInput ;
6369 /** Telemetry extras merged into the TASK_CREATED event when the run succeeds. */
6470 analyticsExtras ?: Record < string , unknown > ;
71+ /**
72+ * When false, the runner does not navigate to the created task. The task is
73+ * still added to the sidebar via `invalidateTasks`, and a success toast with a
74+ * "View task" action lets the user open it on demand. Defaults to true.
75+ */
76+ redirectOnSuccess ?: boolean ;
6577}
6678
6779export interface UseInboxCloudTaskRunnerReturn {
@@ -85,6 +97,7 @@ export function useInboxCloudTaskRunner({
8597 loggerScope,
8698 buildInput,
8799 analyticsExtras,
100+ redirectOnSuccess = true ,
88101} : UseInboxCloudTaskRunnerOptions ) : UseInboxCloudTaskRunnerReturn {
89102 const [ isRunning , setIsRunning ] = useState ( false ) ;
90103 const { getUserIntegrationIdForRepo } = useUserRepositoryIntegration ( ) ;
@@ -144,13 +157,31 @@ export function useInboxCloudTaskRunner({
144157 } ) ;
145158
146159 try {
160+ let createdTask : Parameters < typeof openTask > [ 0 ] | null = null ;
147161 const result = await taskService . createTask ( input , ( output ) => {
162+ createdTask = output . task ;
148163 invalidateTasks ( output . task ) ;
149- void openTask ( output . task ) ;
164+ if ( redirectOnSuccess ) {
165+ void openTask ( output . task ) ;
166+ }
150167 } ) ;
151168
152169 if ( result . success ) {
153170 sonnerToast . dismiss ( toastId ) ;
171+ if ( ! redirectOnSuccess ) {
172+ const task = createdTask ;
173+ toast . success ( copy . successTitle ?? "Task started" , {
174+ description : reportTitle ?? undefined ,
175+ action : task
176+ ? {
177+ label : "View task" ,
178+ onClick : ( ) => {
179+ void openTask ( task ) ;
180+ } ,
181+ }
182+ : undefined ,
183+ } ) ;
184+ }
154185 track ( ANALYTICS_EVENTS . TASK_CREATED , {
155186 auto_run : true ,
156187 created_from : "command-menu" ,
@@ -206,6 +237,7 @@ export function useInboxCloudTaskRunner({
206237 analyticsExtras ,
207238 modelResolver ,
208239 taskService ,
240+ redirectOnSuccess ,
209241 ] ) ;
210242
211243 return { run, isRunning } ;
0 commit comments