Skip to content

Commit a2c283e

Browse files
fix(inbox): don't auto-redirect after creating PR task from report (#2555)
1 parent 30e4ce8 commit a2c283e

2 files changed

Lines changed: 46 additions & 6 deletions

File tree

packages/ui/src/features/inbox/hooks/useCreatePrReport.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ interface UseCreatePrReportOptions {
1414
}
1515

1616
interface UseCreatePrReportReturn {
17-
/** Create an auto-mode implementation task for the report and navigate to it on success. */
17+
/**
18+
* Create an auto-mode implementation task for the report. Adds the task to the
19+
* sidebar and surfaces a success toast with a "View task" action instead of
20+
* navigating away.
21+
*/
1822
createPrReport: () => Promise<void>;
1923
/** True while the task is being created. */
2024
isCreatingPr: boolean;
@@ -23,10 +27,12 @@ interface UseCreatePrReportReturn {
2327
/**
2428
* Create an implementation (PR) task directly from the inbox detail pane.
2529
*
26-
* Bypasses TaskInput so the user stays on the inbox until the task is ready,
27-
* then jumps straight to the task detail page. The agent receives a short
28-
* prompt pointing it at the inbox MCP tools instead of inlining the report
29-
* summary. The base branch comes from the team-level autostart override map.
30+
* Bypasses TaskInput so the user stays on the inbox until the task is ready.
31+
* Rather than navigating away, the task is added to the sidebar and a success
32+
* toast offers a "View task" action to open the task detail page on demand. The
33+
* agent receives a short prompt pointing it at the inbox MCP tools instead of
34+
* inlining the report summary. The base branch comes from the team-level
35+
* autostart override map.
3036
*/
3137
export function useCreatePrReport({
3238
reportId,
@@ -86,6 +92,7 @@ export function useCreatePrReport({
8692
loggerScope: "create-pr-report",
8793
copy: {
8894
loadingTitle: "Starting PR task...",
95+
successTitle: "PR task started",
8996
errorTitle: "Failed to start PR task",
9097
missingRepository: "Pick a cloud repository before creating a PR",
9198
missingIntegration: "Connect a GitHub integration to create a PR",
@@ -95,6 +102,7 @@ export function useCreatePrReport({
95102
},
96103
buildInput,
97104
analyticsExtras,
105+
redirectOnSuccess: false,
98106
});
99107

100108
return { createPrReport: run, isCreatingPr: isRunning };

packages/ui/src/features/inbox/hooks/useInboxCloudTaskRunner.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

6779
export 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

Comments
 (0)