Skip to content

Commit 32958fa

Browse files
committed
Refetch onboarding on agent run
1 parent 63384a8 commit 32958fa

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

autogpt_platform/backend/backend/data/onboarding.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ async def complete_onboarding_step(user_id: str, step: OnboardingStep):
186186

187187

188188
async def _send_onboarding_notification(
189-
user_id: str, step: OnboardingStep, event: str = "step_completed"
189+
user_id: str, step: OnboardingStep | None, event: str = "step_completed"
190190
):
191191
"""
192192
Sends an onboarding notification to the user.
@@ -364,7 +364,7 @@ async def increment_runs(user_id: str):
364364
await UserOnboarding.prisma().update(
365365
where={"userId": user_id},
366366
data={
367-
"agentRuns": new_run_count,
367+
"agentRuns": {"increment": 1},
368368
"lastRunAt": last_run_at,
369369
"consecutiveRunDays": consecutive_run_days,
370370
},
@@ -375,6 +375,9 @@ async def increment_runs(user_id: str):
375375

376376
for step in new_steps:
377377
await complete_onboarding_step(user_id, step)
378+
# Send progress notification if no steps were completed, so client refetches onboarding state
379+
if not new_steps:
380+
await _send_onboarding_notification(user_id, None, event="increment_runs")
378381

379382

380383
async def get_recommended_agents(user_id: str) -> list[StoreAgentDetails]:

autogpt_platform/backend/backend/server/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,4 @@ class NotificationPayload(pydantic.BaseModel):
9393

9494

9595
class OnboardingNotificationPayload(NotificationPayload):
96-
step: OnboardingStep
96+
step: OnboardingStep | None

autogpt_platform/frontend/src/lib/autogpt-server-api/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,8 +956,8 @@ export interface UserOnboarding {
956956

957957
export interface OnboardingNotificationPayload {
958958
type: "onboarding";
959-
event: "step_completed";
960-
step: OnboardingStep;
959+
event: "step_completed" | "increment_runs";
960+
step: OnboardingStep | null;
961961
}
962962

963963
export type WebSocketNotification =

0 commit comments

Comments
 (0)